-
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
Configuration to run golang tests under GDB #94
Comments
Hey something like this could be fine to add, I am not the biggest fan of assuming "/tmp". Maybe one could use Would you mind explaining the need for And how hard would it be to extend the configuration be able to configure the test selection? Example for how it's done with ...
:args
(lambda ()
(require 'which-func)
(if-let* ((file-name (buffer-file-name))
((string-suffix-p "_test.go" file-name))
(fn-name (which-function)))
`["-test.run"
,(substring-no-properties (concat "^" fn-name "$"))]
[]))))
... |
Yes. I think it should be used. Hardcoding
Debugging optimized code prevents GDB from showing local variables consistently, so I disabled optimizations. There might be more issues that I haven't seen yet. I'm not 100% sure if this is really necessary, as I can reliabily print local vars from console, but they are not shown in the
The code from
|
@svaante what do you think about that? (require 'which-func)
(defun dape-go-test-name ()
(if-let* ((file-name (buffer-file-name))
((string-suffix-p "_test.go" file-name))
(fn-name (which-function)))
`["-test.run" ,(concat "^" (car (split-string (substring-no-properties fn-name))) "$")]
[]))
(defun dape-go-test-binary-name ()
(concat (temporary-file-directory) "__test.bin"))
(defun dape-go-binary-name ()
(concat (temporary-file-directory) "__prog.bin")) ;; .dir-locals.el
((nil . ((dape-configs . ((go-gdb-test
modes (go-mode go-ts-mode)
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)))
:request "launch"
:program dape-go-test-binary-name
:args []
:stopAtBeginningOfMainSubprogram nil)
(go-gdb
modes (go-mode go-ts-mode)
command "gdb"
command-args ("--interpreter=dap")
command-cwd dape-command-cwd
compile (lambda () (format "go build -o %s -gcflags '-N -l'" (dape-go-binary-name)))
:request "launch"
:program dape-go-binary-name
:args []
:stopAtBeginningOfMainSubprogram nil)))))) |
Sorry for taking such a long time to respond. but this looks great. Would you mind opening up an PR? For this big change an copyright assignment with FSF is needed (see Contribute in the Readme) |
Native
dlv
is not supported on all platforms, butgdb
has pretty decentgo
support that works for most cases.Here is my snippet that allowed me to debug go test file with a simple
C-x C-a d
on OpenBSD:This probably can benefit from more massaging, but is it something you'd be keen on adding to the release? @svaante
The text was updated successfully, but these errors were encountered: