diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-23 12:49:33 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-23 12:49:33 +0200 |
commit | d6bf11f104a6f4326b7efab308228949cbcf601e (patch) | |
tree | 4478eedc399a962ba149ff512a9a26839d0f1e58 /bin | |
parent | 56bbfce22cc0f0b567f650167f82ce3f7d90e625 (diff) |
checkpoint
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/extra/gccg | 2 | ||||
-rwxr-xr-x | bin/extra/gdbcore | 45 |
2 files changed, 29 insertions, 18 deletions
diff --git a/bin/extra/gccg b/bin/extra/gccg new file mode 100755 index 0000000..89cc822 --- /dev/null +++ b/bin/extra/gccg @@ -0,0 +1,2 @@ +#!/bin/sh +gcc -ggdb -Wall -pedantic -std=c99 -o ${1%.c} $@ diff --git a/bin/extra/gdbcore b/bin/extra/gdbcore index 24c058a..3364ce8 100755 --- a/bin/extra/gdbcore +++ b/bin/extra/gdbcore @@ -9,7 +9,7 @@ # 4 - wrong usage if [ "$#" -lt 1 ]; then - >&2 printf 'usage: fcore <program>\n' + >&2 printf 'usage: gdbcore <program>\n' fi prog="$1" @@ -23,24 +23,33 @@ coredir=/var/lib/systemd/coredump # Temporary file listing core files location, later used as location for the corefile tmp="$(mktemp)" -find "$coredir" -name "core.${prog##*/}*" -printf '%f %TF %TT\n' > "$tmp" - -choice="$(sed \ - -e 's/\.[0-9]\+$//' \ - -e 's/^core\.//' \ - -e 's/\.[0-9]\+\.[0-9a-f]\+\.[0-9]\+\.[0-9]\+\.zst / /' \ - "$tmp" | - awk '{print NR ".", "[" $3,$2"]", $1}' | - sort -k 2 -k 3 -r | - fzf -0 --with-nth=2..)" -if [ -z "$choice" ]; then - rm "$tmp" - exit 2 -fi +if [ "$2" = "-r" ]; then + recent="$(find "$coredir" -name 'core.assert*' -printf '%Ts %f\n' | + sort -n | + head -n 1 | + cut -f 2- -d' ')" + corefile="$coredir"/"$recent" +else + + find "$coredir" -name "core.${prog##*/}*" -printf '%f %TF %TT\n' > "$tmp" -nr="${choice%%.*}" -line="$(sed -n "${nr}p" "$tmp")" -corefile="$coredir"/"${line%% *}" + choice="$(sed \ + -e 's/\.[0-9]\+$//' \ + -e 's/^core\.//' \ + -e 's/\.[0-9]\+\.[0-9a-f]\+\.[0-9]\+\.[0-9]\+\.zst / /' \ + "$tmp" | + awk '{print NR ".", "[" $3,$2"]", $1}' | + sort -k 2 -k 3 -r | + fzf -0 --with-nth=2..)" + if [ -z "$choice" ]; then + rm "$tmp" + exit 2 + fi + + nr="${choice%%.*}" + line="$(sed -n "${nr}p" "$tmp")" + corefile="$coredir"/"${line%% *}" +fi if [ ! -f "$corefile" ]; then rm -f "$tmp" |