From 9fd078128c401695243bda6fbc844039b049d528 Mon Sep 17 00:00:00 2001 From: Misomosi Date: Fri, 4 Oct 2024 19:53:54 -0400 Subject: [PATCH] Eanble auto-load & coredumps on SIGSEGV --- .bashrc | 14 +++++++++++++- .gdbinit | 5 ++++- README.md | 19 ++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.bashrc b/.bashrc index f1a57cb..4e8bba6 100644 --- a/.bashrc +++ b/.bashrc @@ -1,4 +1,16 @@ +function gdb-posix () { + # Producing coredumps on segfaults is usually what I want by default + if [ ! -f .breakpoints ] ; then echo ' +catch signal SIGSEGV +commands +gcore core.latest +end +' >.breakpoints ; fi + gdb "$@" +} export PATH="$HOME/.local/bin:$PATH" export LD_LIBRARY_PATH="$HOME/.local/lib:$LD_LIBRARY_PATH" -alias gdb="gdb -ex 'source .breakpoints'" +# This is equivalent to 'auto-load' but with '.breakpoints' +# Remove this as well if you don't like 'auto-load' +alias gdb="gdb-posix -ex 'source .breakpoints'" diff --git a/.gdbinit b/.gdbinit index 72e86ea..74956e0 100644 --- a/.gdbinit +++ b/.gdbinit @@ -1,4 +1,7 @@ +# I don't mind auto-load, surprisingly enough. +# If I start debugging, I've probably executed build scripts +# and/or intend to run the program itself locally anyways. +set auto-load safe-path / define hook-quit save breakpoints .breakpoints end - diff --git a/README.md b/README.md index c9b8fad..e9ea56e 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ set -g mode-keys vi ## .gdbinit ``` +# I don't mind auto-load, surprisingly enough. +# If I start debugging, I've probably executed build scripts +# and/or intend to run the program itself locally anyways. +set auto-load safe-path / define hook-quit save breakpoints .breakpoints end @@ -40,9 +44,22 @@ end ## .bashrc or similar ``` +function gdb-posix () { + # Producing coredumps on segfaults is usually what I want by default + if [ ! -f .breakpoints ] ; then echo ' +catch signal SIGSEGV +commands +gcore core.latest +end +' >.breakpoints ; fi + gdb "$@" +} export PATH="$HOME/.local/bin:$PATH" export LD_LIBRARY_PATH="$HOME/.local/lib:$LD_LIBRARY_PATH" -alias gdb="gdb -ex 'source .breakpoints'" + +# This is equivalent to 'auto-load' but with '.breakpoints' +# Remove this as well if you don't like 'auto-load' +alias gdb="gdb-posix -ex 'source .breakpoints'" ``` ## .ssh config -- 2.49.1