From 0b7a19555a9e3a4dd72c59fc5e789bc51ca009a5 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sun, 3 Oct 2021 19:42:43 +0530 Subject: [PATCH] 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. --- gdb/.gdbinit.d/auto | 19 +++++++++++++ gdb/.gdbinit.d/hooks | 67 ++++++++++++++++++++++++++++++++++++++++++++ gdb/.gdbinit.d/init | 17 +++++++++++ 3 files changed, 103 insertions(+) create mode 100644 gdb/.gdbinit.d/auto create mode 100644 gdb/.gdbinit.d/hooks create mode 100644 gdb/.gdbinit.d/init diff --git a/gdb/.gdbinit.d/auto b/gdb/.gdbinit.d/auto new file mode 100644 index 0000000..e666ba3 --- /dev/null +++ b/gdb/.gdbinit.d/auto @@ -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 diff --git a/gdb/.gdbinit.d/hooks b/gdb/.gdbinit.d/hooks new file mode 100644 index 0000000..0269891 --- /dev/null +++ b/gdb/.gdbinit.d/hooks @@ -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 diff --git a/gdb/.gdbinit.d/init b/gdb/.gdbinit.d/init new file mode 100644 index 0000000..fe76691 --- /dev/null +++ b/gdb/.gdbinit.d/init @@ -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