u/Szufliadka

▲ 47 r/neovim

Can't we just make a better DAP? Part 2.

DVAP *with gdb-dashboard

Some time ago I've written a post with the same title about my attempt to make Neovim debugging experience better by giving up on the DAP protocol and making one myself called DVAP:
https://www.reddit.com/r/neovim/comments/1rc47ys/cant_we_just_make_a_better_dap_i_tried/
In short - the main idea is to limit responsibility of the editor during a debugging session to just rendering and listing threads and breakpoint positions, as well as leaving everything else to the debugger's native interface for the sake of easier configuration and debuggee launching.

And I'm happy to say, that at least partially I succeeded.
Currently there are 3 supported debugger adapters:
- gdb
- lldb
- delve

All accesseble here:
https://github.com/Isletier/DVAP

As promised there is no non-UI configuration from the client side - just call plugin setup and all you need to do after is type the adapter server port to connect.

On the debugger side (for gdb and lldb) you just need to add a one-liner in .gdbinit and .lldbinit to source the adapter server python script. In the case of delve - things are not so bright, I did end up forking the debugger and modifying its front-end (the core debugger part is preserved as a dependency), since delve doesn't support the required extensibility.

What it takes to do the thing? Currently the whole protocol is based on HTTP SSE and looks like this:

selected;;{id};;{conc_type}||
thread;;{id};;{conc_type};;{file};;{line};;{os_thread_id}||
bp;;{id};;{file};;{line};;{nonconditional};;{enabled}

Aaand that's it, no, seriously, that's it. For comparison, the original Microsoft DAP protocol specification JSON is 4617 lines, I think it's less than the amount of lines I needed to implement all of the 3 adapters and the client.

However, there are some drawbacks to mention:
This approach shifts the configuration problem down the stack, but because the protocol is so simple, there is currently not much to configure except the server endpoint.
Also, the editor view model I chose means you cannot insert breakpoints directly through the editor. This sounds worse than it is in practice; debugger REPLs provide autocompletion for filenames, functions, and short paths for current file (like b 34 for line 34). For "far" breakpoints. Also, plugin provide a command that copies {file_path}:{line_number} to the system clipboard. It takes some time getting used to, but in the end costs no more keystrokes than the default approach.

So, I've done my best to polish this and welcome everyone interested to try it, I'm quite serious about supporting it further.
https://github.com/Isletier/nvim-DVAP-ui

If you have any questions/hesitations about the workflow - I will be glad to answer them below.
Next in the line are python and JS.

reddit.com
u/Szufliadka — 3 days ago