To start with, I do not know if this is something trivial and common knowledge; I don't know, so am asking here.
I am running a 3rd party app and trying to nail down a problem for which I need to find out the call stack.
When I call a Bash script, it calls a number of other scripts and binaries, processing stuff and exits.
What I need is a way of finding out exactly which scripts and binaries it called. pstree shows a stack but only for a process that is currently executing.
function stacktrace {
local i=1 line file func
while read -r line func file < <(caller $i); do
echo >&2 "[$i] $file:$line $func(): $(sed -n ${line}p $file)"
((i++))
done
}
from https://gitlab.com/kyb/autorsync/-/blob/master/utils.bash#L84
Run the script with bash -x, which will produce output on standard error to show each command that is executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With