Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions dape.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
(require 'hexl)
(require 'tramp)
(require 'jsonrpc)
(require 'which-func)


;;; Obsolete aliases
Expand Down Expand Up @@ -219,6 +220,26 @@
:type "debug"
:cwd "."
:program ".")
(go-gdb-test
modes (go-mode go-ts-mode)
Copy link
Owner

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)

command "gdb"
command-args ("--interpreter=dap")
command-cwd (lambda () (file-name-directory (buffer-file-name)))
Copy link
Owner

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))

compile (lambda () (format "go test -c -o %s -gcflags '-N -l'" (dape--go-test-binary-name))) ;; compile without optimizations
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above

Copy link
Author

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.

:request "launch"
:program dape--go-test-binary-name
Copy link
Owner

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

:args []
:stopAtBeginningOfMainSubprogram t)
(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))) ;; compile without optimizations
:request "launch"
:program dape--go-binary-name
:args []
:stopAtBeginningOfMainSubprogram t)
(flutter
ensure dape-ensure-command
modes (dart-mode)
Expand Down Expand Up @@ -822,6 +843,22 @@ Non interactive global minor mode."

;;; Utils

(defun dape--go-test-name ()
Copy link
Owner

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)

Copy link
Author

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.

"Retrieve Go test function name from current cursor position."
(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 ()
"Format path to Go debugged test binary executable file."
(concat (temporary-file-directory) "__test.bin"))

(defun dape--go-binary-name ()
"Format path to Go debugger binary exectuable file."
(concat (temporary-file-directory) "__prog.bin"))

(defun dape--warn (format &rest args)
"Display warning/error message with FORMAT and ARGS."
(dape--repl-insert-error (format "* %s *\n" (apply #'format format args))))
Expand Down