diff options
Diffstat (limited to 'bin/extra')
| -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"  | 
