gdb: Add gdb configuration based on gdb-dashboard

For the most part adapted from
https://gavinhoward.com/2020/12/my-development-environment-and-how-i-got-there/

Also contains support for opening current line in neovim.

This assumes we are running inside neovim terminal and hence the use of
nvr viz. neovim-remote. We will try adding support for kitty window and
single instances later if possible.
This commit is contained in:
Sanchayan Maity 2021-10-03 19:42:43 +05:30
parent 79e4022b0e
commit 0b7a19555a
3 changed files with 103 additions and 0 deletions

19
gdb/.gdbinit.d/auto Normal file
View File

@ -0,0 +1,19 @@
dashboard -enabled on
dashboard -layout breakpoints variables source stack threads
dashboard -style prompt 'gdb>'
dashboard -style max_value_length 0
dashboard variables -style compact True
dashboard variables -style align True
dashboard variables -style sort True
dashboard expressions -style align True
dashboard stack -style sort True
define expand
dashboard -style compact_values False
end
define pack
dashboard -style compact_values True
end
expand

67
gdb/.gdbinit.d/hooks Normal file
View File

@ -0,0 +1,67 @@
define hookpost-up
dashboard
end
define hookpost-down
dashboard
end
define hookpost-frame
dashboard
end
define hookpost-finish
dashboard
end
define hookpost-return
dashboard
end
define hook-quit
set confirm off
end
define hookpost-enable
dashboard
end
define hookpost-disable
dashboard
end
define hookpost-break
dashboard
end
define hookpost-tbreak
dashboard
end
define hookpost-delete
dashboard
end
define hookpost-watch
dashboard
end
define hookpost-rwatch
dashboard
end
define hookpost-awatch
dashboard
end
define hookpost-condition
dashboard
end
define hookpost-core-file
dashboard
end
define hookpost-thread
dashboard
end

17
gdb/.gdbinit.d/init Normal file
View File

@ -0,0 +1,17 @@
set confirm off
set breakpoint pending on
set print pretty on
set auto-load safe-path /
set logging off
# 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