summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-23 12:49:33 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-23 12:49:33 +0200
commitd6bf11f104a6f4326b7efab308228949cbcf601e (patch)
tree4478eedc399a962ba149ff512a9a26839d0f1e58 /bin
parent56bbfce22cc0f0b567f650167f82ce3f7d90e625 (diff)
checkpoint
Diffstat (limited to 'bin')
-rwxr-xr-xbin/extra/gccg2
-rwxr-xr-xbin/extra/gdbcore45
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"