dape icon indicating copy to clipboard operation
dape copied to clipboard

Support for Julia Debugger

Open reachtarunhere opened this issue 1 year ago • 4 comments

Hello I am trying to get Julia Debugger working with dape.

There has already been done with neovim so I assume it would be possible in emacs with dape

https://github.com/kdheepak/nvim-dap-julia/blob/main/lua/nvim-dap-julia.lua

Below is my experimental config that is not working

(setq dape-configs `((julia-debug
			  modes (julia-mode)
			  command "/home/tarun/.local/bin/julia"
			  port 9020
			  :type "server"
			  :request "launch"
			  :cwd dape-cwd-fn
			  :program dape-find-file-buffer-default
			  :args ["/home/tarun/Downloads/information/server.jl"])))

I get the error: Doing vform no such file or directory

I have tried running the server directly with the command and it does run. Any help would be appreciated! I am willing to try and report back on the suggestions

reachtarunhere avatar Aug 08 '24 08:08 reachtarunhere

There are some pain points/issues with DebugAdapter.jl currently:

  1. It does not follow the spec, it uses "success": "true" rather then "success": true in responses (see dape patch below).
  2. There are no "official" bin/script to launch the debug adapter with command line args, therefore I recommend using the nvim-dap-julia neovim plugin to package the launcher script server.jl.

I would rather see that DebugAdapter.jl follows the DAP protocol then merging the patch below.

Apply patch:

diff --git a/dape.el b/dape.el
index cda9d7e..8977c14 100644
--- a/dape.el
+++ b/dape.el
@@ -1369,7 +1369,9 @@ On failure, ERROR will be an string."
                          (when (functionp cb)
                            (lambda (result)
                              (funcall cb (plist-get result :body)
-                                      (unless (eq (plist-get result :success) t)
+                                      (unless (or (eq (plist-get result :success) t)
+                                                  (equal (plist-get result :success)
+                                                         "true"))
                                         (or (plist-get result :message) "")))))
                          :error-fn 'ignore ;; will never be called
                          :timeout-fn

Install bridge and DebugAdapter.jl:

mkdir -p ~/.emacs.d/debug-adapters
cd ~/.emacs.d/debug-adapters
git clone https://github.com/kdheepak/nvim-dap-julia
# install dependencies from nvim-dap-julia TOML

Add default config:

(add-to-list 'dape-configs
             `(julia command "julia"
                     command-args
                     (,(expand-file-name
                        (file-name-concat
                         dape-adapter-dir "nvim-dap-julia" "scripts" "server.jl"))
                      :autoport)
                     port :autoport
                     :type "julia"
                     :program dape-buffer-default
                     :stopOnEntry nil
                     :cwd dape-cwd
                     :args []
                     :juliaEnv dape-cwd
                     :exitAfterTaskReturns nil
                     :debugAutoInterpretAllModules nil))

svaante avatar Aug 17 '24 10:08 svaante

Added an issue for wrong response.success type.

https://github.com/julia-vscode/DebugAdapter.jl/issues/87.

svaante avatar Aug 17 '24 10:08 svaante

Tracking https://github.com/julia-vscode/DebugAdapter.jl/issues/93 for eas of integration, otherwise server script in https://github.com/kdheepak/nvim-dap-julia is an possibility.

svaante avatar Sep 11 '24 17:09 svaante

I was going to add the following configuration for julia in the last release but notice that the julia Debug adapter and Dape was not playing nice on termination events.

See https://github.com/julia-vscode/DebugAdapter.jl/pull/103

(julia
 command "julia"
 command-cwd dape-command-cwd
 command-args
 ("-e" "using Sockets;using DebugAdapter;\
conn=Sockets.accept(Sockets.listen(:autoport));\
run(DebugAdapter.DebugSession(conn));close(conn);")
 port :autoport
 :type "julia"
 :program dape-buffer-default
 :stopOnEntry nil
 :cwd "."
 :args []
 :juliaEnv dape-cwd
 :exitAfterTaskReturns nil
 :debugAutoInterpretAllModules nil)

svaante avatar Jan 25 '25 11:01 svaante