Created
April 3, 2018 11:41
-
-
Save andrey-utkin/264e9e8e14008ab68ac0f500e3c90978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Taken from http://dustymabe.com/2012/10/14/trace-function-calls-using-gdb/ | |
# Make a function call trace using GDB. This is stupid, but it should work | |
if [ "$*" = "" ]; then | |
echo "usage: $0 [args]" | |
exit | |
fi | |
_CMDFILE=/tmp/`basename $0`.$$ | |
_PROG=$1 | |
shift | |
echo Writing GDB commands file | |
# Write the temporary GDB commands file | |
echo "set args $*" > $_CMDFILE | |
for i in `nm -f posix $_PROG | awk '$2 == "T" { print $1}'`; do | |
(echo break $i | |
echo command | |
echo silent | |
echo backtrace 1 | |
echo continue | |
echo end | |
echo | |
) >> $_CMDFILE | |
done | |
echo run >> $_CMDFILE | |
# Now do the run | |
echo Starting GDB | |
gdb -quiet -command=$_CMDFILE $_PROG < /dev/null | |
# and clean up | |
echo GDB run finished | |
rm -f $_CMDFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment