|
From: R. B. <ro...@pa...> - 2006-04-06 04:42:44
|
First a little recap: through involvment with the Python debugger and
feedback from that I've extended the bash debugger to allow calling
the debugger in the middle of a complex script. It has a benefit of
not causing a slowdown for the part of the code that doesn't need
debugging. (And in bash much more that Python this is needed.)
Sourceforge CVS is back so I've committed these changes.
One of the things I've always found annoying about "set -x" traces is
that there is no position information given in the trace output, in
particular the line number and the file name. Although function
nesting information is shown, other important Information such as BASH
shell and subshell nesting count is not. From a programming
standpoint, these are just as important because they affect the
namespace, or the scope over which variables are seen.
Although I this is best fixed inside BASH, the debugger provides a way
to do better I think. So I've just added and committed "set linetrace"
on. Here's a simple session.
/usr/local/bin/bashdb /tmp/fact.sh
Bourne-Again Shell Debugger, release bash-3.1-0.05
Copyright 2002, 2003, 2004, 2006 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
(/tmp/fact.sh:11):
11: echo fact 0 is: `fact 0`
bashdb<0> set linetrace on
bashdb<1> cont
(/tmp/fact.sh:11):
level 1, subshell 1, depth 0: echo fact 0 is: `fact 0`
fact 0
(/tmp/fact.sh:2):
level 1, subshell 1, depth 1: fact() @{
(/tmp/fact.sh:3):
level 1, subshell 1, depth 1: local -i n=$@{1:0@}
(/tmp/fact.sh:4):
level 1, subshell 1, depth 1: ((n==0)) && echo 1 && return
(/tmp/fact.sh:4):
...
An explanation of the output. The "level" is how many invocations of
BASH are in effect before the statement shown is executed. The
"subshell" is how many subshells you are nested in. The depth is the
function depth or how many calls you are nested in. (A ``source''
command also increases this depth.)
Notice also that in contrast to "set -x" tracing, the line shown
is exactly as you entered it in the source.
As this is new, if folks have comments or suggestions now is the best
time to voice them.
Thanks
|