svaante / dape

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

Feature request: tbreak #39

Closed TatriX closed 8 months ago

TatriX commented 9 months ago

Hi!

Oftentimes I need to continue running until certain point in code. In order to do that, right now I can go to repl R, put a temporary breakpoint by manually typing tbreak $line and then continue c. Instead it would be awesome if I could for example C-x C-a j, or jump to the current line, which would do what I described earlier - put a temporary breakpoint on the current line and continue.

And probably it would also be useful to expose dape-breakpoint-temporary so one could bind it directly and use together with dape-continue.

Personally I would bind dape-breakpoint-toggle to b, dape-breakpoint-temporary to say C-b and dape-breakpoint-expression to M-b, and then use e for dape-evaluate-expression. Which I can surely do in my config, and I'm sharing this just because it may be a useful addition for the README, to show how to configure dape to better fit one's needs.

Thank you for this project, it looks very promising!

svaante commented 8 months ago

Hi! Temporary breakpoints are not supported by the debug adapter protocol. The repl passes evaluations down to the adapter which does whatever it want's with it. I am guessing is that you use cpptools with MIMode gdb, which then passes tbreak to gdb. These kinds of specialised bindings that are adapter specific wont be a part of dape.

In the latest release dape-evaluate-expression will send expressions in repl context which means that repl commands like tbrake (when running gdb backed adapter) will be executed by the adapter.

Then you can do something like the following to improve your workflow:

(defun dape-until-gdb ()
  (interactive)
  ;; Or tbreak but it sound like you want until instead
  ;; https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_37.html
  (dape-evaluate-expression (format "until %d" (line-number-at-pos))))

(defun dape-until-lldb ()
  (interactive)
  (dape-evaluate-expression (format "thread until %d" (line-number-at-pos))))

(define-key dape-global-map "u" 'dape-until-gdb)

Hope this helps

joaotavora commented 8 months ago

Sorry for the offtopic, but where would one get this DAP-enabled gdb? Does one have to compile oneself?

TatriX commented 8 months ago

I've just grabbed one mentioned in the readme: https://github.com/vadimcn/codelldb/releases (So it's lldb, not gdb)

svaante commented 8 months ago

@joaotavora Have not tried I believe cpptools use gdb mi interface when it uses gdb as it's backend but that is just a qualified guess. gdb 14.1 adds support, unfortunately gdb is not supported on system (last time I checked) so I have not tried it out.