From ddbb985e96c9bb76dd7844654d4175be3cd65d45 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 2 Nov 2024 22:34:00 +0100 Subject: checkpoint --- bin/extra/gdbcore | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/gdbcore b/bin/extra/gdbcore index 69b1a64..667db3e 100755 --- a/bin/extra/gdbcore +++ b/bin/extra/gdbcore @@ -9,7 +9,12 @@ # 4 - wrong usage if [ "$#" -lt 1 ]; then - >&2 printf 'usage: gdbcore \n' + >&2 printf 'usage: gdbcore [-r] \n' +fi + +if [ "$1" = "-r" ]; then + recent=1 + shift fi prog="$1" @@ -24,11 +29,11 @@ coredir=/var/lib/systemd/coredump tmp="$(mktemp)" -if [ "$2" = "-r" ]; then - recent="$(find "$coredir" -name "core.${prog##*/}*" -printf '%Ts %f\n' | +if [ "$recent" ]; then + file="$(find "$coredir" -name "core.${prog##*/}*" -printf '%Ts %f\n' | sort -n -r | head -n 1 | cut -f 2- -d' ')" - corefile="$coredir"/"$recent" + corefile="$coredir"/"$file" else find "$coredir" -name "core.${prog##*/}*" -printf '%f %TF %TT\n' > "$tmp" @@ -61,6 +66,6 @@ if ! zstd -d "$corefile" -f -o "$tmp" 2>/dev/null; then exit 3 fi -gdb "$prog" "$tmp" +gdb -q "$prog" "$tmp" rm -f "$tmp" -- cgit v1.2.3