diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-01-09 16:52:07 +0100 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-01-09 16:52:07 +0100 |
commit | c8283a1ef06b15ab0b5871655f4bfaefe9518673 (patch) | |
tree | ee892a974ed799f708078def24e02f42cb70b5fa /bin/extra/gdbcore | |
parent | cc216ca760a6b22c8b8041f525859f4201a52d1f (diff) | |
parent | 11137f566712166f593eee3466a0287b8f3fad7b (diff) |
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/extra/gdbcore')
-rwxr-xr-x | bin/extra/gdbcore | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/extra/gdbcore b/bin/extra/gdbcore index 667db3e..6daafa8 100755 --- a/bin/extra/gdbcore +++ b/bin/extra/gdbcore @@ -1,6 +1,7 @@ #!/bin/sh -# Open the latest core file for program with gdb +# Open the latest core file for program $1 with gdb +# If no program supplied then use the most recent one # RETURN VALUES # 0 - success # 1 - if the program was not found or not executable @@ -8,6 +9,8 @@ # 3 - zstd failed # 4 - wrong usage +cache="$HOME/.cache/gdbcore_prog" + if [ "$#" -lt 1 ]; then >&2 printf 'usage: gdbcore [-r] <program>\n' fi @@ -17,7 +20,13 @@ if [ "$1" = "-r" ]; then shift fi -prog="$1" +if [ "$1" ]; then + prog="$1" + printf '%s\n' "$prog" > "$cache" +else + prog="$(cat "$cache")" +fi + if [ ! -x "$prog" ]; then prog="$(which "$prog" 2>/dev/null)" [ -x "$prog" ] || exit 1 |