Open critiqjo opened 8 years ago
I started this in a spur of the moment! I wasn't planning on this at first. I was actually trying to get GDB to work with Neovim. But debugging got a bit painful, so I thought to give Vim a try, and I gotta say -- Vim's channel/job API is much simpler and more flexible (at least imo). Debugging is a lot easier (due to flexibility). You can find it at https://github.com/johncf/gdb.vim
It was just a day's work, and it's not yet in working condition. There are a few more bugs to clear to get it into a barely working condition. But the good news is that the code is lot simpler. There's only a single thread which takes care of interactions from both the front-end and the debugger.
To try it now:
gdb.vim
set rtp+=/path/to/gdb.vim
in you vimrctest
directorygcc -g -o ab ab.c
vim ab.c
(./run.sh
no longer works):GGsession new
:GGmode debug
Nothing interesting can be seen in the editor either, but if you inspect the log file at /tmp/gdb.vim.log
, you'd see a lot of activity. I'm going to take another long break. So feel free to poke around. A lot of it is marked as TODO
, which should be easy once you know how pygdbmi works.
Note: This will not work in Windows, because it does not support select
with files. (Can probably be made to work in Mac.)
PS: This is an alias of @critiqjo
Just in case someone wants to poke around, here are a few heads up:
[gdb]logs
buffer is actually directly connected to the stderr of the process. So you can print(..., file=sys.stderr)
, sys.stderr.flush()
(flush is important!), and see it in Vim. But if the process exits with an error, it probably won't be displayed in that buffer because it exits before Vim could read from the pipe. So replace buffer
in this line to file
to redirect stderr to a file instead.Adding a try block around this line would probably fix the issue I pointed to in the above comment:
[...] if the process exits with an error, it probably won't be displayed in that buffer because it exits before Vim could read from the pipe.
The change could be as follows:
try:
Middleman(vimx).loop()
except:
import time, traceback
traceback.print_exc() # print traceback to stderr
time.sleep(2) # hope for vim to read
cc @lenfien in case you're planning to hack on it.
Basically, these 3 files have to be re-implemented:
autoload/lldb/remote.vim
: This is responsible for sending all events to the backend. This needs to be replaced with something which encodes these events in json and sends it to backend.rplugin/python/lldb_nvim/__init__.py
: This is the listener in the backend. This needs to be replaced with a listener which understands json fromremote.vim
.rplugin/python/lldb_nvim/vim_x.py
: This in the backend is what tells Neovim to take all sorts of actions. This needs to be replaced with:Note: There is only one RPC-like interaction from Neovim where it waits for a "response" for a "request" it sent and that is for auto-completion. Everything else is event-based, that is Neovim gets notified of stuff from backend. But RPC-like calls from the backend to Neovim are used extensively (wherever you see
async=False
and use of aQueue
invim_x.py
like this).PS: I'm not planning on implementing this. If anyone is interested, I would be happy to help.