]> localhost Git - dotfiles.git/commitdiff
Eanble auto-load & coredumps on SIGSEGV
authorMisomosi <[email protected]>
Fri, 4 Oct 2024 23:53:54 +0000 (19:53 -0400)
committerMisomosi <[email protected]>
Fri, 4 Oct 2024 23:53:54 +0000 (19:53 -0400)
.bashrc
.gdbinit
README.md

diff --git a/.bashrc b/.bashrc
index f1a57cb7c5fc49c724685f8d6b300eabda042912..4e8bba66554630c4db9ea6ea2c71e2c99ccc6641 100644 (file)
--- 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'"
index 72e86ea9d3fa535640585cab05f3f36f301a4ef4..74956e0698575e8a3a0efedeba3f42fcde4a14b4 100644 (file)
--- 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
-
index c9b8fadf961896b2e3d18367fbee0882009340af..e9ea56e25ea16deb3efbd423151c0958d98869cc 100644 (file)
--- 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