sakhnik / nvim-gdb

Neovim thin wrapper for GDB, LLDB, PDB/PDB++ and BashDB
723 stars 39 forks source link

Support PerlDB #195

Closed mozirilla213 closed 1 year ago

mozirilla213 commented 1 year ago

Can we support PerlDB?

I already have one commit here: https://github.com/mozirilla213/nvim-gdb/tree/perl

but don't know how to go forward since

local response = proxy:query('handle-command L') -- or info breaks

would keep looping L in the debugger and cannot parse the response

sakhnik commented 1 year ago

Hello, thanks for reaching out! To give you heads up, could you please rebase on top of the branch pty. There's active development to support MinGW gdb, and quite a lot has changed. Most likely, the loop is the following:

This can be investigated in the proxy.log and nvimgdb.log (run with the environment variable CI=1).

To step back a little bit, would it be possible to extend perldb to run an additional thread, receive external commands via a UDP socket and interact with the debugger to execute those commands? If the answer is yes, the debugger could be hooked up more reliably. See gdb_commands.py and lldb_commands.py. I also realized that this could be done for PDB too (future plan).

mozirilla213 commented 1 year ago

Thanks for the heads up! I rebased on pty.

I checked and apparently PerlDB can carry a debugging session over a socket: https://perldoc.perl.org/perl5db#SOCKET-HANDLING, but I have not test that yet. I can probably take a look at it next weekend.

One question, are the <debugger>_commands.py files planned to be ported to lua? I know on Unix we could use posix.sys.socket from the luaposix package on luarocks

sakhnik commented 1 year ago

I'm afraid, that's not the socket handling that's required. We extend the debuggers, inject some code into it and that script has access to the debugger bypassing CLI. LLDB and GDB support Python extensions, and LLDB does support Lua, unlike GDB. So that wasn't a choice of preference. I could imagine that perldb, being written in Perl, could allow some kind of subclassing to spawn a separate thread. Most likely all in the Perl language. That's what could be helpful. If this is impossible, the only way remains to debug the pseudoterminal proxy, and deal with all the peculiarities of the CLI.

sakhnik commented 1 year ago

I see there's a Perl debugger for nvim-dap: https://github.com/Nihilus118/vscode-perl-debug . I'd suggest trying out those.