mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 06:40:03 +00:00
backtrace_symbols has slightly different output than backtrace_symbols_fd: ```./build/bin/uv(+0x24d92)[0x7b9c947ad92]``` In the first, there is a space between `(+0x24d92)` and `[0x7b9c947ad92]`: ```./build/bin/uv(+0x24d92) [0x7b9c947ad92]``` so support both syntaxes (the absolute address is ignored anyways, there were just missing quotes around a variable)
49 lines
1.0 KiB
Bash
Executable File
49 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
SILENT=
|
|
|
|
while getopts 'hs' opt; do
|
|
case "$opt" in
|
|
'h'|'?')
|
|
cat <<-EOF
|
|
Usage:
|
|
$0 [-s] [STACKTRACE_FILE]
|
|
where
|
|
-s - silent
|
|
STACKTRACE_FILE - file containg stacktrace from UG (if not set, stdin is used)
|
|
EOF
|
|
[ $opt = h ] && exit 0 || exit 1
|
|
;;
|
|
's')
|
|
SILENT=yes
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
IN=${1-/dev/stdin}
|
|
|
|
while read n; do
|
|
if ! expr "$n" : ".*(.*\+.*)" > /dev/null; then
|
|
continue
|
|
fi
|
|
EXE=$(expr "$n" : "\([^(]*\)")
|
|
addr=$(expr "$n" : ".*(\(.*\))")
|
|
# addr in format "func+addr"
|
|
if expr $addr : "[^\+]" >/dev/null; then
|
|
FUNC=$(expr $addr : "\([^\+]*\)")
|
|
OFFSET=$(expr $addr : "[^\+]*\+\(.*\)")
|
|
LINE=$(objdump -d -F $EXE | grep "<$FUNC>" | grep -v '^ ')
|
|
FUNC_OFFSET=$(expr "$LINE" : '.*File Offset: \([^)]*\)')
|
|
addr=$(($FUNC_OFFSET + $OFFSET))
|
|
addr=$(printf 0x%x $addr) # addr2line requires hex
|
|
fi
|
|
[ -z $SILENT ] && printf -- "- decoding $n:\n"
|
|
ARGS=
|
|
[ -z $SILENT ] && ARGS='-f -i -p'
|
|
addr2line -e $EXE $ARGS -C $addr
|
|
done <$IN
|
|
|
|
# vim: set noexpandtab:
|