Closed kevinhwang91 closed 3 years ago
Right, there was a TODO list, but I completely forgot about it. Now I admit that these features would be really helpful. As well as another one that I realized when participated in the advent of code this year. To be able to store and restore breakpoints between debugging sessions. Luckily I'm just going to have holidays at the beginning of 2021. So stand by.
The idea is the following:
set efm=%m\ at\ %f:%l%.%#
cexpr GdbCustomCommand('bt')
set efm+=%m\ %f:%l%.%#
cexpr GdbCustomCommalnd("info breakpoint")
It's worth keeping the jump window focused to keep the terminal window visible.
@kevinhwang91, could you please check out the branch quickfix
(https://github.com/sakhnik/nvim-gdb/tree/quickfix)? Let me know your opinion on the new commands GdbCopenBreakpoints
and GdbCopenBacktrace
before I merge the branch.
GdbCopenBreakpoints
is so weird.topleft
, botright
, and so on.copen
or cwindow
is buggy when multiple windows in a tab? Do you consider use location as an option?Thanks for your comments. Could you please elaborate on every point for me to understand better? Maybe with examples. I can only comment on the following at the moment:
:cnext
or :cprev
. So I had to make sure the jump window is focused before populating the quickfix in the tests. I'm afraid, the location list can hardly be used instead of the quickfix list. It is buffer-specific and contains locations in a single file. Whereas both backtrace and breakpoints can jump between different files randomly.<mods>
, I found that GdbCopenBreakpoints
and GdbCopenBacktrace
don't support it.I only noticed that sometimes the terminal buffer window may be used when navigating the quickfix with
:cnext
or:cprev
. So I had to make sure the jump window is focused before populating the quickfix in the tests.
I think you have already encountered this issue. If you vsplit A
and B
window, and then run
copen
in A
, the quickfix window will split under B
. quickfix window seems global, but buggy.
Some qf plugin will fix this issue by using wincmd J
in after/ftplugin/qf.vim
I'm afraid, the location list can hardly be used instead of the quickfix list. It is buffer-specific and contains locations in a single file. Whereas both backtrace and breakpoints can jump between different files randomly.
location is related to a window, not a specified buffer or file. You can run :h location-list
for more details. If I want to make breakpoints or backtrace attach the debug window instead of the raw gdb terminal window, it's a good choice for using location rather than quickfix.
Well, I see there's a lot more for me to investigate. Thanks!
I've changed the code to populate the code window's location list and implemented <mods>
. Now, it's possible to make the list auto-updating itself by just defining the following autocmd: au User NvimGdbQuery GdbLopenBreakpoints
. But I wonder whether it's worth just documenting the possibility instead of programming it. It's not clear when to disable the auto-update.
The last issue (the first in your original list) was about the breakpoint format. Well, it roughly corresponds to the breakpoint location lines obtained with info breakpoints
. Except for the indentation. Perhaps we could ignore the issue.
I will try it tomorrow, and feedback as possible as I could.
I've changed the code to populate the code window's location list and implemented
<mods>
. Now, it's possible to make the list auto-updating itself by just defining the following autocmd:au User NvimGdbQuery GdbLopenBreakpoints
. But I wonder whether it's worth just documenting the possibility instead of programming it. It's not clear when to disable the auto-update.
I think to expose an event is enough. Embedded this function will trap you into quickfix black hole. Let users take these risks.
The last issue (the first in your original list) was about the breakpoint format. Well, it roughly corresponds to the breakpoint location lines obtained with
info breakpoints
. Except for the indentation. Perhaps we could ignore the issue.
Could we ignore this line? The valid
field in this item is 0.
Could we ignore this line? The valid field in this item is 0.
Sure, I've updated the code. There could be more to it. For example, GDB reports how many times a particular breakpoint has been hit. I believe such info should be preserved.
Relative/full file path of gdb should be consistent with nvim's. For instance, I test under directory /home/kevin/.config/nvim/plugged/nvim-gdb/test/src
and run nvim +'GdbStart gdb ./a.out'
, I can get the correct buffer with locationlist. But if I under /home/kevin/.config/nvim/plugged/nvim-gdb/test
and run nvim +'GdbStart gdb src/a.out'
, the target file of gdb is test.cpp
, but in nvim, this relative path is not existed, I got an empty buffer for test.cpp
with locationlist.
BTW, which event could I use for subscribing to a breakpoint that is updated?
Self-promotion: I just released a plugin related to quickfix. https://github.com/kevinhwang91/nvim-bqf Any feedbacks are welcome!
The paths may be tricky if relative ones were embedded into the binary. Currently, it's expected that the user handles this: https://github.com/sakhnik/nvim-gdb/blob/81930348bbb1398635cc0ecbbc88e3defd8aaa0f/doc/nvimgdb.txt#L291 . But I'm open to suggestions. I wonder how GDB-TUI is handling the issue.
I wouldn't filter out the breakpoint hit counters. They may be useful in the actual debugging. And they seem to be harmless in the navigation.
The event is User NvimGdbQuery
. I tested the following command: au User NvimGdbQuery GdbLopenBreakpoints
.
If GdbLopenBreakpoints
and GdbCopenBacktrace
could update items base on the quickfix id is better. For now, They are always creating new quickfix list instead of updating items if one exists.
Nevermind, this is an improvement, no other issues I found.
Thanks! Please let me know if there are more ideas.
By the way, I've just discovered that GDB has a neat option: set filename-display absolute
. And suddenly the files will be located just fine from any directory as long as GDB is able to do so.
By the way, I've just discovered that GDB has a neat option:
set filename-display absolute
. And suddenly the files will be located just fine from any directory as long as GDB is able to do so.125
I can confirm that it works!
I know these two features have listed in todo, I open this issue to let you know I care about them. :)