gdb: Migrate vo command to Python gdb script
This commit is contained in:
parent
55685b3084
commit
bbb5057eb1
2 changed files with 21 additions and 12 deletions
|
@ -11,15 +11,3 @@ set mi-async on
|
||||||
set non-stop off
|
set non-stop off
|
||||||
|
|
||||||
alias -a it = info threads
|
alias -a it = info threads
|
||||||
|
|
||||||
# Adapted to use neovim from https://github.com/cyrus-and/gdb-dashboard/issues/20
|
|
||||||
define vo
|
|
||||||
python
|
|
||||||
import os
|
|
||||||
sal = gdb.selected_frame().find_sal()
|
|
||||||
current_line = sal.line
|
|
||||||
if current_line != 0:
|
|
||||||
openInNvim = "nvr +" + str(current_line) + " " + sal.symtab.fullname()
|
|
||||||
os.system(openInNvim)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
21
gdb/.gdbinit.d/scripts/vo.py
Normal file
21
gdb/.gdbinit.d/scripts/vo.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Adapted to use neovim from https://github.com/cyrus-and/gdb-dashboard/issues/20
|
||||||
|
# Requires neovim-remote and can only be used from within neovim terminal
|
||||||
|
import os
|
||||||
|
import gdb # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
class OpenNvim(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("vo", gdb.COMMAND_USER)
|
||||||
|
|
||||||
|
def complete(self, _text, _word):
|
||||||
|
return gdb.COMPLETE_SYMBOL
|
||||||
|
|
||||||
|
def invoke(self, _args, _from_tty):
|
||||||
|
sal = gdb.selected_frame().find_sal()
|
||||||
|
current_line = sal.line
|
||||||
|
if current_line != 0:
|
||||||
|
openInNvim = "nvr +" + str(current_line) + " " + sal.symtab.fullname()
|
||||||
|
os.system(openInNvim)
|
||||||
|
|
||||||
|
OpenNvim()
|
Loading…
Reference in a new issue