svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
455 stars 25 forks source link

dape and golang delve - debug errors on startup #33

Closed the42 closed 7 months ago

the42 commented 9 months ago

I did read https://github.com/svaante/dape#go---dlv

dlv is in my path

I am within a golang project, M-x compile set to go build works. eglot gopls is successfully attached (and providing eg. completions through capfs)

I did inspect *dape-debug*:

[info] Starting new multi session
[info] Server process started ("dlv" "dap" "--listen" "127.0.0.1:0")
[std-server] Server stdout:
DAP server listening at: 127.0.0.1:57588

and *dape-processes* which is empty.

I start dape using M-x dape and I am prompted with

dlv command-cwd "c:/Users/UNAME/code/PROJ/" :cwd "c:/Users/UNAME/code/PROJ/" :program "c:/Users/UNAME/code/PROJ/"

I leave it as such. After maybe 10 seconds I am prompted with the error message "unable to connect to server localhost:0"

a simple dlv dap successfully starts up. What am I doing wrong or where can I find more debug information about the underlying issue?

svaante commented 9 months ago

Hi!

This smells like the auto port functionallity is failing on windows.

Could you test with the following configuration:

(add-to-list 'dape-configs
    '(dlv
      modes (go-mode go-ts-mode)
      ensure dape-ensure-command
      command "dlv"
      command-args ("dap" "--listen" "127.0.0.1:5678")
      command-cwd dape-cwd-fn
      port 5678
      :request "launch"
      :type "debug"
      :cwd dape-cwd-fn
      :program dape-cwd-fn))
the42 commented 9 months ago

Indeed, that got me further, thank you. The Window layout changes and on the status line is written Dape:starting. However, this get's soon replaced with Dape:timeout which in turn is replaced with Dape:initialized.

When I try to restart with d in repl, the prompt is dlv command-cwd "c:/Users/USER/code/Thesaurushelper/" :cwd "c:/Users/USER/code/Thesaurushelper/" :program "c:/Users/USER/code/Thesaurushelper/" so the actual executable is missing. That MAY be ok as dlv knows about the go ecosystem and like the go - tool itself is ware how to start an executable givein it's source path.

When I accept that prompt, Dape times out again.

svaante commented 9 months ago

Hmmm strange. Could you please share your dape-debug buffer again?

the42 commented 8 months ago

Sorry, took a while, here we go:

[info] Starting new multi session
[info] Server process started ("dlv" "dap" "--listen" "127.0.0.1:5678")
[std-server] Server stdout:
DAP server listening at: 127.0.0.1:5678

[info] Connection to server established localhost:5678
[io] Sending:
(:arguments (:clientID "dape" :adapterID "debug" :pathFormat "path" :linesStartAt1 t :columnsStartAt1 t :supportsRunInTerminalRequest t :supportsProgressReporting t :supportsStartDebuggingRequest t) :type "request" :command "initialize" :seq 1)
[io] Received:
(:seq 0 :type "response" :request_seq 1 :success t :command "initialize" :body (:supportsConfigurationDoneRequest t :supportsFunctionBreakpoints t :supportsConditionalBreakpoints t :supportsEvaluateForHovers t :supportsSetVariable t :supportsExceptionInfoRequest t :supportsDelayedStackTraceLoading t :supportsLogPoints t :supportsDisassembleRequest t :supportsClipboardContext t :supportsSteppingGranularity t :supportsInstructionBreakpoints t))
[io] Sending:
(:arguments (:request "launch" :type "debug" :cwd "c:/Users/HoechtlJ/code/Thesaurushelper/" :program "c:/Users/HoechtlJ/code/Thesaurushelper/") :type "request" :command "launch" :seq 2)
[error] Timeout for reached for seq 2
[io] Sending:
(:arguments (:restart nil) :type "request" :command "disconnect" :seq 3)
[io] Received:
(:seq 0 :type "event" :event "initialized")
[io] Sending:
(:arguments (:breakpoints []) :type "request" :command "setFunctionBreakpoints" :seq 4)
[io] Received:
(:seq 0 :type "response" :request_seq 2 :success t :command "launch")
[info] 
Process nil exited with 256
[info] 
Process ("dlv" "dap" "--listen" "127.0.0.1:5678") exited with 0
[error] Timeout for reached for seq 3
svaante commented 8 months ago

Hi would it be possible to try with the latest on master as it gives more information from the logs and does not send the setFunctionBreakpoints. You have to install it from source with straight or load-file.

svaante commented 7 months ago

Closing this issue, feel free to reopen if you have tried it with an later release and followed the "Bugs and issues" section in the readme

the42 commented 7 months ago

Thank you, with the sippet you provided it works now out of the box!

Hi!

This smells like the auto port functionallity is failing on windows.

Could you test with the following configuration:

(add-to-list 'dape-configs
    '(dlv
      modes (go-mode go-ts-mode)
      ensure dape-ensure-command
      command "dlv"
      command-args ("dap" "--listen" "127.0.0.1:5678")
      command-cwd dape-cwd-fn
      port 5678
      :request "launch"
      :type "debug"
      :cwd dape-cwd-fn
      :program dape-cwd-fn))