-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for debugging go with gdb #187
base: master
Are you sure you want to change the base?
Conversation
This PR introduces configuration to debug Go applications with GDB, since Delve is not supported on OpenBSD.
Hey and thank you for your contribution!
This is due to an GDB bug which dape has an workaround for but it has been fixed upstream in gdb so depending on the gdb - defer-launch-attach: If launch/attach request should be sent
after initialize or configurationDone. If nil launch/attach are
sent after initialize request else it's sent after
configurationDone. This key exist to accommodate the two different
interpretations of the DAP specification.
See: GDB bug 32090. How is your FSF status? This amount of code needs to be FSF assigned to be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start, just a couple of small things!
@@ -219,6 +220,26 @@ | |||
:type "debug" | |||
:cwd "." | |||
:program ".") | |||
(go-gdb-test | |||
modes (go-mode go-ts-mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ensure
symbol. This should be grouped with the other gdb configuration and ensure implemented once (see js-debug
configuration)
modes (go-mode go-ts-mode) | ||
command "gdb" | ||
command-args ("--interpreter=dap") | ||
command-cwd (lambda () (file-name-directory (buffer-file-name))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dape supports short cutting these functions as just (file-name-directory (buffer-file-name))
command "gdb" | ||
command-args ("--interpreter=dap") | ||
command-cwd (lambda () (file-name-directory (buffer-file-name))) | ||
compile (lambda () (format "go test -c -o %s -gcflags '-N -l'" (dape--go-test-binary-name))) ;; compile without optimizations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work for me:
compilation-start: Wrong type argument: stringp, (format "go build -o %s -gcflags '-N -l'" (dape--go-binary-name))
Error running timer: (wrong-type-argument stringp nil)
Same for command-cwd
. I can pass a function name only or string.
command-cwd (lambda () (file-name-directory (buffer-file-name))) | ||
compile (lambda () (format "go test -c -o %s -gcflags '-N -l'" (dape--go-test-binary-name))) ;; compile without optimizations | ||
:request "launch" | ||
:program dape--go-test-binary-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of language specific functions, this could be defined inline
@@ -822,6 +843,22 @@ Non interactive global minor mode." | |||
|
|||
;;; Utils | |||
|
|||
(defun dape--go-test-name () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something but where is this used? (also as stated above I don't want to define language specific functions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's not used atm.
This is a leftover from my prototype to debug test under cursor. However, the logic to construct the test runner invocation is somewhat convoluted and breaking it into pieces would help.
I'll remove it for now.
I missed that. I'll check that out and report back.
I sent a message to assign@ today. You should be in CC just FYI. |
This PR introduces configuration to debug
Go applications with GDB, since Delve is not
supported on OpenBSD.
#94
At this moment, this PR has been tested on Fedora 40 with GDB 15.2.
For reasons unknown, the debugger fails to hit the breakpoint unless
:stopAtBeginningOfMainSubprogram
is set tot
.It used to work with older version of
dape
, so could it be some sort of regression perhaps?Debugging test using
go-gdb-test
target doesn't work because it can't stop at beginning ofmain
.go-gdb
target works.@svaante I'll probably need some assistance as I'm not familiar enough with DAP to land this.