Debugging with the BASH debugger
BASH Debugger

This file describes the BASH debugger, the BASH symbolic debugger.

This is the 4.2-0.8 Edition, 29 November 2011, for BASH.

Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011 Rocky Bernstein


1. Summary of the BASH Debugger

The purpose of a debugger such as the BASH debugger is to allow you to see what is going on “inside” a bash script while it executes.

the BASH debugger can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

  • Start your script, specifying anything that might affect its behavior.
  • Make your script stop on specified conditions.
  • Examine what has happened, when your script has stopped.
  • Change things in your script, so you can experiment with correcting the effects of one bug and go on to learn about another.

Although you can use the BASH debugger to debug scripts written in BASH, it can also be used just as a front-end for learning more about programming in BASH. As an additional aid, the debugger can be used within the context of an existing script with its functions and variables that have already been initialized; fragments of the existing can be experimented with by entering them inside the debugger.

1.1 A Sample BASH Debugger Session

You can use this manual at your leisure to read all about the BASH debugger. However, a handful of commands are enough to get started using the debugger. This chapter illustrates those commands.

Below we will debug a script that contains a function to compute the factorial of a number: fact(0) is 1 and fact(n) is n*fact(n-1).

 
$ bashdb -L .  /tmp/fact.sh
Bourne-Again Shell Debugger, release bash-4.2-0.8
Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011 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:9):
  9:	echo fact 0 is: `fact 0`
bashdb<0> -

  1:    #!/usr/local/bin/bash
  2:    fact() {
  3:    ((n==0)) && echo 1 && return
  4:    ((nm1=n-1))
  5:    ((result=n*`fact $nm1`))
  6:    echo $result
  7:    }
  8:    
  9:==> echo fact 0 is: `fact 0`
bashdb<1> list
 10:   echo fact 3 is: $(fact 3)

The command invocation uses the option “-L .” Here we assume that the bashdb script and the debugger files are in the same location. If you are running from the source code, this will be the case. However if bashdb has been installed this probably won’t be true and here you probably don’t need to use “-L .” Instead you would type simply bashdb /tmp/fact.sh.

Position information consists of a filename and line number, e.g. (/tmp/fact.sh:9) and is given parenthesis. This position format is similar to that used in a dozen or so other debuggers; GNU Emacs and DDD can parse this format.

In the first debugger command we gave -, we listed a window of lines before where we were executing. Because the window, 10 lines, is larger than the number of lines to the top of the file we printed only 9 lines here. The next command, list, starts from the current line and again wants to print 10 lines but because there are only one remaining line, that is what is printed.

 
bashdb<2> step

(/tmp/fact.sh:9):
fact 0
9:	echo fact 0 is: `fact 0`
bashdb<(3)> <RET>
2:	fact() {
bashdb<(4)> <RET>
3:	((n==0)) && echo 1 && return
bashdb<(5)> print $n

bashdb<(6)>

Ooops... The variable n isn’t initialized.(1)

The first step command steps the script one instruction. It may seem odd that the line printed is exactly the same one as before. What has happened though is that we’ve “stepped” into the subshell needed to run `fact 0`; we haven’t however started running anything inside that subshell yet though.

To indicate that which piece of the multi-part line echo fact 0 is: `fact 0` we show that part all by itself fact 0. If nothing is shown then it means we are running the beginning statement or in this case the outermost statement.

To indicate that we are now nested in a subshell, notice that the command number, starting with 3, or the third command entered, now appears in parenthesis. Each subshell nesting adds a set of parenthesis.

The first step command steps the script one instruction; it didn’t advance the line number, 9, at all. That is because we were stopping before the command substitution or backtick is to take place. The second command we entered was just hitting the return key; bashdb remembers that you entered step previously, so it runs the step rather than next, the other alternative when you hit <RET>. Step one more instruction and we are just before running the first statement of the function.

Next, we print the value of the variable n. Notice we need to add a preceding dollar simple to get the substitution or value of n. As we will see later, if the pe command were used this would not be necessary.

We now modify the file to add an assignment to local variable n and restart.

 
bashdb<6> restart

Restarting with: /usr/local/bin/bashdb -L . fact.sh
(/tmp/fact.sh:10):
10:	echo fact 0 is: `fact 0`
bashdb<0> list 1
  1:    #!/usr/local/bin/bash
  2:    fact() {
  3:    local -i n=${1:0}
  4:    ((n==0)) && echo 1 && return
  5:    ((nm1=n-1))
  6:    ((result=n*`fact $nm1`))
  7:    echo $result
  8:    }
  9:    
 10:==> echo fact 0 is: `fact 0`
bashdb<1> s 3

(/tmp/fact.sh:3):
3:	local -i n=${1:0}
bashdb<(2)> step
(/tmp/fact.sh:4):
4:	((n==0)) && echo 1 && return
bashdb<(3)> print $n
print $n
0

This time we use the list debugger command to list the lines in the file. From before we know it takes three step commands before we get into the fact() function, so we add a count onto the step command. Notice we abbreviate step with s; we could have done likewise and abbreviated list with l.

 
bashdb<(4)> <RET>
(/tmp/fact.sh:4):
4:	((n==0)) && echo 1 && return
echo 1
bashdb<(5)> <RET>
(/tmp/fact.sh:4): 
4:	((n==0)) && echo 1 && return
return

Again we just use <RET> to repeat the last step commands. And again the fact that we are staying on the same line 4 means that the next condition in the line is about to be executed. Notice that we see the command (echo 1 or return) listed when we stay on the same line which has multiple stopping points in it. Given the information above, we know that the value echo’ed on return will be 1.

 
bashdb<(6)> <RET>
fact 0 is: 1
(/tmp/fact.sh:12): 
12:	echo fact 3 is: $(fact 3)
bashdb<(7)> break 5
Breakpoint 1 set in file fact.sh, line 5.
bashdb<(8)> continue

We saw that we could step with a count into the function fact(). However above took another approach: we set a stopping point or “breakpoint” at line 5 to get us a little ways into the fact() subroutine. Just before line 5 is to executed, we will get back into the debugger. The continue command just resumes execution until the next stopping point which has been set up in some way.

 
(/tmp/fact.sh:5):
5:      ((nm1=n-1))
Breakpoint 1 hit(1 times).
bashdb<(8)> x n-1

2
bashdb<(9)> s
(/tmp/fact.sh:5):
6:     ((result=n*`fact $nm1`))
bashdb<(10)> c
fact.sh: line 6: ((: result=n*: syntax error: operand expected (error token is "*")
bashdb<(7)> R

Restarting with: bash --debugger fact.sh 
11:	echo fact 0 is: `fact 0`
bashdb<0> l fact
 2:    fact () 
 3:    { 
 4:       local -i n=${1:0};
 5:       (( "n==0" )) && echo 1 && return;
 6:       (( nm1=n-1 ));
 7:       ((fact_nm1=`fact $nm1`))
 8:       (( "result=n*fact_nm1" ));
 9:       echo $result
10:    }

In addition to listing by line numbers, we can also list giving a function name. Below, instead of setting a breakpoint at line 5 and running “continue” as we did above, we try something slightly shorter and slightly different. We give the line number on the “continue” statement. This is a little different in that a one-time break is made on line 5. Once that statement is reached the breakpoint is removed.

 
bashdb<1> continue 5

One-time breakpoint 1 set in file fact.sh, line 5.
fact 0 is: 1
(/tmp/fact.sh:5):
5:	((nm1=n-1))
bashdb<(2)> s
6:	((fact_nm1=`fact $nm1`))
bashdb<(3)> s
2:	fact() {
bashdb<(4)> T
->0 in file `fact.sh' at line 2
##1 fact("3") called from file `fact.sh' at line 12
##2 source("fact.sh") called from file `/usr/local/bin/bashdb' at line 154
##3 main("fact.sh") called from file `/usr/local/bin/bashdb' at line 0
bashdb<(5)> c

fact 3 is: 6
Debugged program terminated normally. Use q to quit or R to restart.

When we stop at line 5 above, we have already run fact(0) and output the correct results. The output from the program “fact 0 is: 1” is intermixed with the debugger output. The T command above requests call stack output and this confirms that we are not in the fact(0) call but in the fact(3) call. There are 4 lines listed in the stack trace even though there is just one call from the main program. The top line of the trace doesn’t really represent a call, it’s just where we currently are in the program. That last line is an artifact of invoking bash from the bashdb script rather than running bash --debugger.

The last message in the output above ‘Debugged program exited normally.’ is from the BASH debugger; it indicates script has finished executing. We can end our bashdb session with the quit command.

Above we did our debugging session on the command line. If you are a GNU Emacs user, you can do your debugging inside that. Also there is a(nother) GUI interface called DDD that supports the BASH debugger.

1.2 Interactive Line Tracing Session

One of the things I had found disappointing about the default set -x tracing behavior is that no position information is given in the trace output, in particular the line number and the file name. However with the introduction in Bash 3.0 of the introspection variables, also needed to support the debugger, one can set $PS4 to rectify this. (I became of this in a defunct blog http://raz.cx/blog/2005/08/handy-bash-debugging-trick.html.)

Here’s what I use:

 
  PS4='(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]} - [${SHLVL},${BASH_SUBSHELL}, $?]
'

Note that the string is in single quotes, not double quotes and there is a newline in the string. By using single quotes, variables which have a dollar in front of them in the string are expanded in the current environment of the line that is about to be run rather than at the time the variable PS4 is set.

You might want to add this in your shell’s start-up script, e.g., .bashrc, or .profile.

There is also facility inside the bash debugger showing position information when tracing a script. Here’s a simple session.

 
/usr/local/bin/bashdb /tmp/fact.sh
Bourne-Again Shell Debugger, release bash-4.2-0.8
Copyright 2002, 2003, 2004, 2006, 2007, 2008 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):
level 1, subshell 1, depth 1:	    ((n==0)) && echo 1 && return
echo 1
(/tmp/fact.sh:4):
level 1, subshell 1, depth 1:	    ((n==0)) && echo 1 && return
return
fact 0 is: 1
(/tmp/fact.sh:13):
level 1, subshell 0, depth 0:	echo fact 3 is: $(fact 3)
(/tmp/fact.sh:13):
level 1, subshell 1, depth 0:	echo fact 3 is: $(fact 3)
fact 3
(/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:5):
level 1, subshell 1, depth 1:	    ((nm1=n-1))
(/tmp/fact.sh:6):
level 1, subshell 1, depth 1:	    ((fact_nm1=`fact $nm1`))
(/tmp/fact.sh:6):
level 1, subshell 2, depth 1:	    ((fact_nm1=`fact $nm1`))
fact $nm1
(/tmp/fact.sh:2):
level 1, subshell 2, depth 2:	fact() {
...
level 1, subshell 4, depth 4:	fact() {
(/tmp/fact.sh:3):
level 1, subshell 4, depth 4:	    local -i n=${1:}
(/tmp/fact.sh:4):
level 1, subshell 4, depth 4:	    ((n==0)) && echo 1 && return
(/tmp/fact.sh:4):
level 1, subshell 4, depth 4:	    ((n==0)) && echo 1 && return
echo 1
(/tmp/fact.sh:4):
level 1, subshell 4, depth 4:	    ((n==0)) && echo 1 && return
return
(/tmp/fact.sh:7):
level 1, subshell 3, depth 3:	    ((result=n*fact_nm1))
(/tmp/fact.sh:8):
level 1, subshell 3, depth 3:	    echo $result
(/tmp/fact.sh:7):
level 1, subshell 2, depth 2:	    ((result=n*fact_nm1))
(/tmp/fact.sh:8):
level 1, subshell 2, depth 2:	    echo $result
(/tmp/fact.sh:7):
level 1, subshell 1, depth 1:	    ((result=n*fact_nm1))
(/tmp/fact.sh:8):
level 1, subshell 1, depth 1:	    echo $result
fact 3 is: 6
(/usr/local/bin/bashdb:260):
level 1, subshell 0, depth -1:	
Debugged program terminated normally. Use q to quit or R to restart.
bashdb<2> 

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. Subshells are used by command substitution—`..' and $(...)—as well as arithmetic expressions ((...)). 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. So if you indented statements in a meaningful way, it will help you understand the statement nesting level. But as before, if a line contains multiple statements, you are not executing the first statement in the line and set showcommand is not turned off (by default it is on), that statement is shown in addition below the multi-statement line. Such an example can be seen right at the beginning where fact 0 is shown.

If what you want to do is trace the entire script as was done above (and not stop in the debugger when the script is over), you can get the same effect by using the -X or --trace option on the bashdb command:

 
/usr/local/bin/bashdb -X /tmp/fact.sh
Bourne-Again Shell Debugger, release bash-4.2-0.8
Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011 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.

(/usr/local/bin/bashdb:272):
level 1, subshell 0, depth -1:	  . $_source_file
(/tmp/fact.sh:11):
level 1, subshell 0, depth 0:	echo fact 0 is: `fact 0`
(/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}
...
level 1, subshell 2, depth 2:	    echo $result
(/tmp/fact.sh:7):
level 1, subshell 1, depth 1:	    ((result=n*fact_nm1))
(/tmp/fact.sh:8):
level 1, subshell 1, depth 1:	    echo $result
fact 3 is: 6
(/usr/local/bin/bashdb:285):
level 1, subshell 0, depth -1:	

If you issue a break (e.g. send a SIGINT signal) while the program is running you will go into the debugger (assuming your program doesn’t trap SIGINT).

2. Getting in and out

This chapter discusses how to start the BASH debugger, and how to get out of it. The essentials are:

  • type ‘bash --debugger script-name’ or ‘bashdb script-name’ to start the BASH debugger. Or...
  • type ‘bashdb -c command string’ to give a string to run under the debugger. Or ..
  • modify your program to enter the debugger at a particular point: source ../bashdb-trace and _Dbg_debugger.
  • type quit or C-d inside the debugger to exit.

There are also two front-ends available as well. An emacs front-end which has bashdb support among others is https://github.com/rocky/emacs-dbgr/wiki.

2.1 Starting the BASH debugger

Note: it is important to use a debugger-enabled bash. You will get an error message if the debugger is run under a version of BASH that does not have debugging support.

As mentioned above, one can enter the BASH debugger via Emacs or DDD. However you don’t have to use either of these. And these still need a way on their own to get things started.

There are in fact two other ways to start the BASH debugger. The first way is to pass the ‘--debugger’ option to bash with the name of your script the scripts arguments following that, or with a command string (-c).

 
bash --debugger script script-arguments...
bash --debugger -c command-string...

This calls a debugger initialization script. It works much like a BASH login profile which may set variables and define functions. But this shell profile is customized for debugging and as such arranges for itself to get called before each statement is executed. Although there are some problems at present in I/O redirection that the method described next doesn’t have, it is expected that over time more features will be enabled in bash when the ‘--debugger’ option is in effect.

The form ‘bash --debugger -c ...’ can be used to get into the debugger without having to give a script name to debug. Sometimes you may want to do this just to see how the debugger works: try some debugger commands or maybe get online help. If you run ddd --bash without giving a script name, it in fact uses this form.

In order for the ‘--debugger’ option to work however, you must have the debugger scripts installed in a place where the BASH debugger can find them. For this reason, in developing the BASH debugger, I use a second method more often; it doesn’t require the bash debugger to be installed. This method uses another script called bashdb which allows for giving its own options, the final option is signaled by adding --). After this, the name of the script to debugged and any the arguments to pass to that script are given. Using this method, one would start the debugger like this:

 
bash path-to-bashdb/bashdb bashdb-options -- script script-arguments...

If you don’t need to pass dash options to your program which might get confused with the debugger options, then you don’t need to add the --.(2)

As with the first method, bash should be a debugger-enabled bash. If bashdb has the path to bash in it at the top (e.g. via #!), and bashdb can be found in your program-search path, then this might be equivalent to the above:

 
bashdb bashdb-options -- script script-arguments...

There are two or three disadvantages however of running a debugger this way. First $0 will have the value bashdb rather than the script you are trying to run. For some scripts this may change the behavior of the debugged script. Second a traceback will contain additional lines showing the “source”-ing of the debugged script from bashdb. And third, although this way works better than the first method, over time this way may come into disuse.

An option that you’ll probably need to use if bashdb isn’t installed but run out of the source code directory is ‘-L’ which specifies the directory that contains the debugger script files.

You can further control how bashdb starts up by using command-line options. bashdb itself can remind you of the options available.

Type

 
bashdb -h

to display all available options and briefly describe their use.

When the bash debugger is invoked either by the bashdb front-end script or bash --debugging, the first argument that does not have an associated option flag for bashdb or bash (as the case may be) is used as the name a the script file to be debugged, and any following options get passed the debugged script.

Options for the bashdb front-end are shown in the following list.

2.1.1 Command-line options for bashdb script

You can run the BASH debugger in various alternative modes—for example, in batch mode or quiet mode.

-h | --help

This option causes the BASH debugger to print some basic help and exit.

-V | --version

This option causes the BASH debugger to print its version number, no-warranty blurb, and exit.

-A | --annodate level

Add additional output which allows front-ends to track what’s going on without having to poll for such vital information. The default annotation level is 0 (none). If you are running inside GNU Emacs using the Emacs code from this package, an annotation level 3 when set will allow for automatic tracking of frames and breakpoints. See section Annotation Level (‘set annotate’).

-c | --command cmd

Run the string instead of running a script

-B | --basename

This option causes the BASH debugger to print its version number and no-warranty blurb, and exit.

-n | --nx | --no-init

Do not execute commands found in any initialization files. Normally, BASH executes the commands in these files after all the command options and arguments have been processed. See section Command files.

-q | --quiet

“Quiet”. Do not print the introductory and copyright messages. These messages are also suppressed in batch mode.

-t | --terminal | --tty tty

“Terminal output”. Set the file or terminal that you want debugger command output to go to. Note that the debugger output is independent of the debugged script output.

-x | --eval-command

execute debugger commands from cmdfile.

-L | --library directory

Set directory where debugger files reside to directory. The default location is ../lib/bashdb relative to the place that the bashdb script is located. For example if bashdb is located in /usr/local/bin/bashdb, the default library location will be /usr/local/lib/bashdb which may or may not exist. If it doesn’t you’ll get an error when you run bashdb. Only if the default location is incorrect, should you need to use the -L option.

-T | --tempdir directory

Set directory to use for writing temporary files.

2.2 Quitting the BASH debugger

An interrupt (often C-c) does not exit from the BASH debugger, but rather terminates the action of any the BASH debugger command that is in progress and returns to the BASH debugger command level. Inside a debugger command interpreter, use quit command (see section Quitting the BASH debugger).

There way to terminate the debugger is to use the kill command. This does more forceful kill -9. It can be used in cases where quit doesn’t work.

2.3 Calling the BASH debugger from inside your program

Running a program from the debugger adds a bit of overhead and slows down your program quite a bit. Addressing this better would mean some serious changes to BASH internals, and judging from experience in other languages there still the slowdown is still noticeable. If you have a configure script generated by autoconf, and you want to stop in the middle of the script, it can take quite a while.

Furthermore, by necessity, debuggers change the operation of the program they are debugging. And this can lead to unexpected and unwanted differences. It has happened so often that the term “Heisenbugs” (see http://en.wikipedia.org/wiki/Heisenbug) was coined to describe the situation where the addition of the use of a debugger (among other possibilities) changes behavior of the program so that the bug doesn’t manifest itself anymore.

There is another way to get into the debugger aside from calling bashdb from the outset, and this adds no overhead or slowdown until you reach the point at which you want to start debugging. However for this method you must change the script. Because the debugger isn’t involved before the first call, there is no overhead; the script will run at the same speed as if there were no debugger up to the point where it is first invoked.

2.3.1 Debugging a Running Shell Script

In this section we’ll show how to modify your script so that it enters the debugger when you send it a signal, and then we will show how you can call the debugger directly.

In either case, you’ll need to modify the script to load some the debugger code. The name of file to load is bashdb-trace and it is located in the directory where the other bash debugger files live. For example on GNU/Linux if it is in directory /usr/local/share/bashdb, you would first add to a BASH script the line:

 
    source /usr/local/share/bashdb/bashdb-trace

Although I said that running under the debugger adds overhead which slows down you program, the above command in of itself will not cause any slowdown. If possible, it’s best to put this somewhere in the main-line code rather than in a function or in a subshell. If it is put in a function of subshell and you step outside of that, some of the global variables set up in bashdb-trace may be lost. One the other hand if you know your debugging will be confined to just the scope of the source command there is no problem.

Here’s a complete example. In file ‘debugit.sh

 
# This is my extra debug hook
  source /usr/share/bashdb/bashdb-trace # adjust location

  echo $$
  while : ; do
        date=$(date)
        echo "$date"
        sleep 2
  done 

Now run:

 
  $ bash ./debugit.sh

  Bourne-Again Shell Debugger, release bash-3.1-0.08
  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.

  9435
  Thu Jun 19 02:43:06 EDT 2008
  Thu Jun 19 02:43:08 EDT 2008

Sent it an "interrupt" signal

 
  kill -INT 9435

And back to the running program:

 
  Program received signal SIGINT (2)...
  ->0 in file `./debugit.sh' at line 251  # not sure where 251 came from!
  ##1 main() called from file `./debugit.sh' at line 0
  bashdb<0> where
  ->0 in file `./debugit.sh' at line 9    # but this line number is now right
  ##1 main() called from file `./debugit.sh' at line 0
  bashdb<1> list 1
    1:   # Set up some interrupt handlers to go into the debugger
    2:   source /usr/share/bashdb/bashdb-trace
    3:  
    4:   echo $$
    5:   while : ; do
    6:   date=$(date)
    7:   echo "$date"
    8:   sleep 2
    9:==>done
  bashdb<2> step

  (./debugit.sh:5):
  5:      while : ; do
  bashdb<3> step
  (./debugit.sh:6):
  6:      date=$(date)
  bashdb<4> continue -

The command continue - not only continues execution but it removes the debug trap allowing the program to run at full speed. It is suitable only if there are no breakpoints that you care to stop at.

By default, bashdb-trace sets up a handler for the ‘INT’ exception. If you down’t want this or you want enter the debugger on a different signal to be use, _Dbg_handler. With this function you can specify whether to show a call stack, stop (enter the debugger) and/or print an indication that the a signal was seen.

Here are some examples:

 
    _Dbg_handler INT print showstack nostop  # this is the default
    _Dbg_handler INT                         # same thing
    _Dbg_hander                              # same thing
    _Dbg_handler HUP print stop              # stop in debugger when getting
2.3.1.1 Explicit Debugging Calls.

As we saw in the last section bashdb-trace installs some signal handlers. However you can make an explicit call to the debugger

 
     _Dbg_debugger

Let’s show an example of that. We’ll even do it under a condition:

 
  for ((i=1; i<=10; i++)) ; 
        (( 5 == i )) && { _Dbg_debugger }
        date=$(date)
        echo "$date"
        sleep 2
  done 

The debugger will be called on the 5th iteration of this loop, when i has the value 5.

You can also supply the number of statements to skip and the options to _Dbg_debugger just as you would to the debugger itself. All of the options listed in Command-line options for bashdb script can be used with the exception of -c (run a command) and of course you don’t supply the name of a BASH script.

For example to stop at the next line and suppress the banner you could use _Dbg_debugger 1 -q in the above example.

2.3.2 Program-Controlled Line Tracing

You can also turn on and off line tracing. Here’s an example

 
  source path-to-program/bashdb-trace # modify location
   ...
  _Dbg_linetrace_on
  for i in `seq 10` ; do
     echo $i
  done
  _Dbg_linetrace_off
   _Dbg_QUIT_ON_QUIT=1  

The _Dbg_QUIT_ON_QUIT variable make sure the program doesn’t stay inside the debugger after it quits. It can also be set earlier in the program.

Again <path-to-program> is whatever path needed to located <bashdb-trace>. For example it might be </usr/local/share> on some GNU/Linux installations.

3. Script Setup inside the BASH Debugger
3.1 Starting your script

After invoking the debugger you should be on the first stoppable line of your program to be debugged. At this point you can issue debugger commands to set breakpoints (see section Setting breakpoints), or watchpoints (see section Setting watchpoints), or start continue the execution of the program (see section Resuming Execution).

restart [args] run [args] R [args]

Use the restart command to restart your script under the BASH debugger. Without any arguments, the script name and parameters from the last invocation are used. The BASH debugger tries to maintain the settings, watchpoints, breakpoints, actions and so on. Internally it uses line numbers and filenames to record he position of interesting places in your program; so if your program changes some or all of these numbers may be off. Environment variable DBG_RESTART_FILE is and a temporary file are used to signal a restart, so you shouldn’t uset DBG_RESTART_FILE (or any environment variable starting with BASHDB_.

3.2 Command files

A command file for the BASH debugger is a file of lines that are the BASH debugger commands. Comments (lines starting with #) may also be included. An empty line in a command file does nothing; it does not mean to repeat the last command, as it would from the terminal.

When you start the BASH debugger, it automatically executes commands from its init files, normally called ‘.bashdbinit(3). During startup, the BASH debugger does the following:

  1. Reads the init file (if any) in your home directory(4).
  2. Processes command line options and operands.
  3. Reads the init file (if any) in the current working directory.
  4. Reads command files specified by the ‘-x’ option.

The init file in your home directory can set options (such as ‘set complaints’) that affect subsequent processing of command line options and operands. Init files are not executed if you use the ‘-x’ option (see section bashdb script options).

On some configurations of the BASH debugger, the init file is known by a different name (these are typically environments where a specialized form of the BASH debugger may need to coexist with other forms, hence a different name for the specialized version’s init file). These are the environments with special init file names:

You can also request the execution of a command file with the source command:

source filename

Execute the command file filename.

The lines in a command file are executed sequentially. They are not printed as they are executed. If there is an error, execution proceeds to the next command in the file.

3.3 Your script’s arguments

The arguments to your script can be specified by the arguments of the restart command. They are passed to a shell, which expands wild-card characters and performs redirection of I/O, and thence to your script.

restart with no arguments uses the same arguments used by the previous restart, or those set by the set args command..

set args

Specify the arguments to be used if your program is rerun. If set args has no arguments, restart executes your program with no arguments. Once you have run your program with arguments, using set args before the next restart is the only way to run it again without arguments.

show args

Show the arguments to give your program when it is started.

3.4 Your script’s input and output

By default, the script you run under the BASH debugger does input and output to the same terminal that BASH uses. Before running the script to be debugged, the debugger records the tty that was in effect. All of its output is then written to that. However you can change this when using the ‘bashdb’ script using the ‘-t’ option.

info terminal

Displays information recorded by the BASH debugger about the terminal modes your program is using.

Another way to specify where your script should do input and output is with the tty command. This command accepts a file name as argument, and causes this file to be the default for future restart commands. It also resets the controlling terminal for the child process, for future restart commands. For example,

 
tty /dev/ttyb

directs that processes started with subsequent restart commands default to do input and output on the terminal ‘/dev/ttyb’ and have that as their controlling terminal.

An explicit redirection in restart overrides the tty command’s effect on the input/output device, but not its effect on the controlling terminal.

When you use the tty command or redirect input in the restart command, only the input for your script is affected. The input for the BASH debugger still comes from your terminal.

3.5 Script/Debugger Interaction

The BASH debugger and your program live in the same variable space so to speak. BASH does not have a notion of module scoping or lexical hiding (yet) as is found in modern programming languages and in modern versions of the Korn shell. This then imposes some additional care and awareness.

Most of the variables and functions used inside the BASH debugger start _Dbg_, so please don’t use variables or functions with these names in your program.

Note: there are some other variables that begin with just an underscore (_); over time these will be phased out. But until then, avoid those or consult what is used by the debugger. Run ‘bashdb --debugger -c "declare -p"’ to list all the variables in use including those used by the debugger.

A number of environment variables are also reserved for use; these start with DBG_. For example: DBG_INPUT, DBG_LEVEL and, _Dbg_QUIT_ON_QUIT (see section Debug), DBG_RESTART_FILE (see section Starting), to name a few. Finally, there are some BASH environment dynamic variables and these start with BASH_. For example BASH_SUBSHELL (see section Debug), BASH_COMMAND (see section Command Display), BASH_LINENO, and BASH_SOURCE to name a few.

Inside the debugger some variables may be redefined. In particular IFS and PS4, and various dollar variables $?, $1, $2, etc. The values before entering the debugger are saved and those variables have their old values restored when leaving the debugger. However you may notice these difference in various debugger commands. For example examine PS4 might not return the same value as eval declare -p PS4. The former is picking the debugger value while the eval is careful to restore the value to what it was before entering the debugger.

In order to do its work The BASH debugger sets up a DEBUG trap. Consequently a script shouldn’t reset this or the debugger will lose control. The BASH debugger also sets up an EXIT handler so that it can gain control after the script finishes. Another signal intercepted is the an interrupt or INT signal. For more information about signal handling, see section Signals

4. BASH Debugger Command Reference

You can abbreviate the long name of the BASH debugger command to the first few letters of the command name, if that abbreviation is unambiguous; and you can repeat the next or step commands by typing just <RET>. Some commands which require a parameter, such as print remember the argument that was given to them.

4.1 Command syntax

A BASH debugger command is a single line of input. There is no limit on how long it can be. It starts with a command name, which is followed by arguments whose meaning depends on the command name. For example, the command step accepts an argument which is the number of times to step, as in ‘step 5’. You can also use the step command with no arguments. Some commands do not allow any arguments.

A blank line as input to the BASH debugger (typing just <RET>) means to repeat the previous next or step command.

Any text from a # to the end of the line is a comment; it does nothing. This is useful mainly in command files (see section Command files).

4.2 Getting help (‘help’)

Once inside the BASH debugger, you can always ask it for information on its commands, using the command help.

help h

You can use help (abbreviated h) with no arguments to display a short list of named classes of commands:

 
bashdb<0> help
Available commands:
  action     condition  edit     frame    load     run     source  unalias  
  alias      continue   enable   handle   next     search  step    undisplay
  backtrace  debug      eval     help     print    set     step-   untrace  
  break      delete     examine  history  pwd      shell   step+   up       
  clear      disable    export   info     quit     show    tbreak  watch    
  commands   display    file     kill     return   signal  trace   watche   
  complete   down       finish   list     reverse  skip    tty   

Readline command line editing (emacs/vi mode) is available.
Type "help" followed by command name for full documentation.
help command

With a command name as help argument, the BASH debugger displays short information on how to use that command.

 
bashdb<0> help list
list [START|.|FN] [COUNT] -- List lines of a script.

START is the starting line or dot (.) for current line. Subsequent
list commands continue from the last line listed. If a function name
is given list the text of the function.

If COUNT is omitted, use the setting LISTSIZE. Use "set listsize" to 
change this setting.

Aliases for list: l

In addition to help, you can use the debugger command info to inquire about the state of your script, or the state of the BASH debugger itself. The listings under info in the Index point to all the sub-commands. See section Command Index.

info

This command (abbreviated i) is for describing the state of your program. For example, you can list the arguments given to your script with info args, or list the breakpoints you have set with info breakpoints. You can get a complete list of the info sub-commands with help info.

 
bashdb<0> help info
List of info subcommands:

info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
info breakpoints -- Status of user-settable breakpoints
info display -- Show all display expressions
info files -- Source files in the program
info functions -- All function names
info line -- list current line number and and file name
info program -- Execution status of the program.
info signals -- What debugger does when program gets various signals
info source -- Information about the current source file
info stack -- Backtrace of the stack
info terminal -- Print terminal device
info variables -- All global and static variable names
info warranty -- Various kinds of warranty you do not have

Aliases for info: i
bashdb<1> info source
Current script file is parm.sh
Located in /tmp/parm.sh
Contains 34 lines.
4.3 Quitting the BASH debugger (‘quit’, ‘kill’)
quit [expression] quit [expression [subshell-levels]] q

To exit the BASH debugger, use the quit command (abbreviated q), or type an end-of-file character (usually C-d). If you do not supply expression, the BASH debugger will try to terminate normally or with exit code 0. Otherwise it will terminate using the result of expression as the exit code.

A simple quit tries to terminate all nested subshells that may be in effect. If you are nested a subshell, this is normally indicated in a debugger prompt by the number of parentheses that the history number is inside — no parenthesis means there is no subshell in effect. The dynamic variable BASH_SUBSHELL also contains the number of subshells in effect.

If you want only to terminate some number of subshells but not all of them, you can give a count of the number of subshells to leave after the return-code expression. To leave just one level of subshell return does almost the same thing. (See see section Returning) There is a subtle difference between the two though: return will leave you at the beginning of the next statement while quit may leave you at the place the subshell was invoked which may be in the middle of another command such as an assignment statement or condition test.

If the environment variable _Dbg_QUIT_ON_QUIT is set, when the program terminates, the debugger will also terminate too. This may be useful if you are debugging a script which calls another script and you want this inner script just to return to the outer script.

kill
k

In situations where quit doesn’t work we provide an alternative and more forceful quit command: kill. This sends to the OS non-maskable KILL signal with the debugger process number. No cleanup of temporary files is done by the program.

4.4 Stopping and Resuming Execution

One important use of a debugger is to stop your program before it terminates so that if your script might run into trouble, you can investigate and find out why. However should your script accidentally continue to termination, the BASH debugger has arranged for it not to leave the debugger without your explicit instruction. That way, you can restart the program using the same command arguments.

Inside the BASH debugger, your script may stop for any of several reasons, such as a signal, a breakpoint, or reaching a new line after a debugger command such as step. You may then examine and change variables, set new breakpoints or remove old ones, and then continue execution.

4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)

A breakpoint makes your script stop whenever a certain point in the program is reached. For each breakpoint, you can add conditions to control in finer detail whether your script stops.

You specify the place where your script should stop with the break command and its variants (see section Setting breakpoints). These commands allow own to specify the location by line number and file name or function name.

A watchpoint is a special breakpoint that stops your script when the value of an expression changes. There is a different command to set watchpoints (see section Setting watchpoints).

But aside from that, you can manage a watchpoint like any other breakpoint: you delete enable, and disable both breakpoints and watchpoints using the same commands.

You can arrange to have values from your program displayed automatically whenever BASH stops at a breakpoint. See section Automatic display.

The BASH debugger assigns a number to each breakpoint when you create it; these numbers are successive integers starting with one. In many of the commands for controlling various features of breakpoints you use the breakpoint number to say which breakpoint you want to change. Each breakpoint may be enabled or disabled; if disabled, it has no effect on your script until you enable it again.

Watchpoint numbers however are distinguished from breakpoint numbers by virtue of their being suffixed with the either an upper- or lower-case ‘W’. For example, to enable breakpoint entry 0 along with watchpoint entry 1 you would write ‘enable 1 2w’, the “2w” refers to the watchpoint; “2W” would work just as well.

4.4.1.1 Setting breakpoints (‘break’ ‘tbreak’)

Breakpoints are set with the break command (abbreviated b).

break function

Set a breakpoint at entry to function function.

break linenum

Set a breakpoint at line linenum in the current source file. The current source file is the last file whose source text was printed. The breakpoint will stop your script just before it executes any of the code on that line.

break filename:linenum

Set a breakpoint at line linenum in source file filename; filename has to be one of the files previously read in and has to be specified exactly as the name used when read in. For a list of read-in files, use the ‘info files’ command.

break … if cond

Set a breakpoint with condition cond; evaluate the expression cond each time the breakpoint is reached, and stop only if the value is nonzero—that is, if cond evaluates as true. The expression is evaluated via the let built-in function. ‘’ stands for one of the possible arguments described above (or no argument) specifying where to break. The word “if” is often optional and is necessary only ‘’ is omitted. See section Break conditions, for more information on breakpoint conditions.

Examples:

 
bashdb<0> break fn1
Breakpoint 1 set in file parm.sh, line 3.
bashdb<1> break 28
Breakpoint 2 set in file parm.sh, line 28.
bashdb<2> break parm.sh:29

Breakpoint 3 set in file parm.sh, line 29.
bashdb<3> break 28 if x==5
Breakpoint 4 set in file parm.sh, line 28.
tbreak args

Set a breakpoint enabled only for one stop. args are the same as for the break command, and the breakpoint is set in the same way, but the breakpoint is automatically deleted after the first time your program stops there. See section Disabling breakpoints.

info breakpoints [n] info break [n] info watchpoints [n]

Print a table of all breakpoints, watchpoints set and not deleted, with the following columns for each breakpoint:

Breakpoint Numbers (‘Num’) Enabled or Disabled (‘Enb’)

Enabled breakpoints are marked with ‘1’. ‘0’ marks breakpoints that are disabled (not enabled).

Count

The number of times that breakpoint or watchpoint has been hit.

File and Line (‘file:line’)

The filename and line number inside that file where of breakpoint in the script. The file and line are separated with a colon.

Condition

A condition (an arithmetic expression) which when true causes the breakpoint to take effect.

If a breakpoint is conditional, info break shows the condition on the line following the affected breakpoint; breakpoint commands, if any, are listed after that.

info break displays a count of the number of times the breakpoint has been hit.

info break with a breakpoint number n as argument lists only that breakpoint.

Examples:

 
bashdb<4> info break
Breakpoints at following places:
Num Type       Disp Enb What
1   breakpoint keep y   parm.sh:3
2   breakpoint keep y   parm.sh:28
3   breakpoint keep y   parm.sh:29
4   breakpoint keep y   parm.sh:28
No watch expressions have been set.
bashdb<5> info break 4
Num Type       Disp Enb What
4   breakpoint keep y   parm.sh:28
No watch expressions have been set.

the BASH debugger allows you to set any number of breakpoints at the same place in your script. There is nothing silly or meaningless about this. When the breakpoints are conditional, this is even useful (see section Break conditions).

4.4.1.2 Setting watchpoints (‘watch’, ‘watche’)

You can use a watchpoint to stop execution whenever the value of an expression changes, without having to predict a particular place where this may happen. As with the print (see section Examining Data), the idiosyncrasies of a BASH or any POSIX shell derivative suggest using two commands. The watch command is just for a single variables; the watche command uses the builtin “let” command to evaluate an expression. If the variable you are tracking can take a string value, issuing something like ‘watch foo’ will not have the desired effect—any string assignment to foo will have a value 0 when it is assigned via “let.”

watch var

Set a watchpoint for a variable. the BASH debugger will break when the value of var changes. In this command do not add a leading dollar symbol to var.

watche expr

Set a watchpoint for an expression via the builtin “let” command. the BASH debugger will break when expr is written into by the program and its value changes. Not that this may not work for tracking arbitrary string value changes. For that use watch described earlier.

4.4.1.3 Breakpoint command lists (‘commands’)
commands [bnum] command-list end

Specify a list of commands for breakpoint number bnum. The commands themselves appear on the following lines. Type a line containing just end to terminate the commands.

To remove all commands from a breakpoint, type commands and follow it immediately with end; that is, give no commands.

With no bnum argument, commands refers to the last breakpoint, watchpoint, or catchpoint set (not to the breakpoint most recently encountered).

Pressing <RET> as a means of repeating the last debugger command is disabled within a command-list.

You can use breakpoint commands to start your program up again. Simply use the continue command, or step, or any other command that resumes execution.

Any other commands in the command list, after a command that resumes execution, are ignored. This is because any time you resume execution (even with a simple next or step), you may encounter another breakpoint—which could have its own command list, leading to ambiguities about which list to execute.

If the first command you specify in a command list is silent, the usual message about stopping at a breakpoint is not printed. This may be desirable for breakpoints that are to print a specific message and then continue. If none of the remaining commands print anything, you see no sign that the breakpoint was reached. silent is meaningful only at the beginning of a breakpoint command list.

The commands echo, output, and printf allow you to print precisely controlled output, and are often useful in silent breakpoints.

For example, here is how you could use breakpoint commands to print the value of x at entry to foo whenever x is positive.

 
break foo if x>0
commands
silent
printf "x is %d\n",x
cont
end

One application for breakpoint commands is to compensate for one bug so you can test for another. Put a breakpoint just after the erroneous line of code, give it a condition to detect the case in which something erroneous has been done, and give it commands to assign correct values to any variables that need them. End with the continue command so that your program does not stop, and start with the silent command so that no output is produced. Here is an example:

 
break 403
commands
silent
set x = y + 4
cont
end
4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)

It may desirable to eliminate a breakpoint or watchpoint once it has done its job and you no longer want your script to stop there. This is called deleting the breakpoint. A breakpoint that has been deleted no longer exists; it is forgotten.

With the clear command you can delete breakpoints according to where they are in your script. With the delete command you can delete individual breakpoints, or watchpoints by specifying their breakpoint numbers. Note: as described below under the “clear” command, “d” is an alias for “clear”, not “delete”.

It is not necessary to delete a breakpoint to proceed past it. the BASH debugger automatically ignores breakpoints on the first instruction to be executed when you continue execution.

clear

Delete any breakpoints at the next instruction to be executed in the selected stack frame (see section Selecting a frame). When the innermost frame is selected, this is a good way to delete a breakpoint where your script just stopped.

It may seem odd that we have an alias “d” for “clear.” It so happens that Perl’s debugger use “d” for its delete command and the delete concept in Perl’s debugger corresponds to “clear” in GDB. (Perl doesn’t have a notion of breakpoint entry numbers). So in order to be compatible with both debugger interfaces, “d” is used as an alias for “clear.” Clear?

clear function clear filename:function

Delete any breakpoints set at entry to the function function.

clear linenum d linenum

Delete any breakpoints set at or within the code of the specified line.

delete [breakpoints]

Delete the breakpoints, watchpoints specified as arguments.

If no argument is specified, delete all breakpoints (the BASH debugger asks confirmation, unless you have set confirm off). You can abbreviate this command as de.

Note that for compatibility with Perl’s debugger, d means something else: clear.

4.4.1.5 Disabling breakpoints (‘disable’, ‘enable’)

Rather than deleting a breakpoint or watchpoint, you might prefer to disable it. This makes the breakpoint inoperative as if it had been deleted, but remembers the information on the breakpoint so that you can enable it again later.

You disable and enable breakpoints, watchpoints, and catchpoints with the enable and disable commands, optionally specifying one or more breakpoint numbers as arguments. Use info break or info watch to print a list of breakpoints, watchpoints, and catchpoints if you do not know which numbers to use.

A breakpoint, watchpoint, or catchpoint can have any of four different states of enablement:

  • Enabled. The breakpoint stops your program. A breakpoint set with the break command starts out in this state.
  • Disabled. The breakpoint has no effect on your program.
  • Enabled once. The breakpoint stops your program, but then becomes disabled.
  • Enabled for deletion. The breakpoint stops your program, but immediately after it does so it is deleted permanently. A breakpoint set with the tbreak command starts out in this state.

You can use the following commands to enable or disable breakpoints, watchpoints, and catchpoints:

disable [breakpoints]

Disable the specified breakpoints—or all breakpoints, if none are listed. A disabled breakpoint has no effect but is not forgotten. All options such as ignore-counts, conditions and commands are remembered in case the breakpoint is enabled again later. You may abbreviate disable as dis.

enable [breakpoints]

Enable the specified breakpoints (or all defined breakpoints). They become effective once again in stopping your program.

Except for a breakpoint set with tbreak (see section Setting breakpoints), breakpoints that you set are initially enabled; subsequently, they become disabled or enabled only when you use one of the commands above. (The command until can set and delete a breakpoint of its own, but it does not change the state of your other breakpoints; see Resuming Execution.)

4.4.1.6 Break conditions (‘condition’)

The simplest sort of breakpoint breaks every time your script reaches a specified place. You can also specify a condition for a breakpoint. A condition is just a BASH expression.

Break conditions can be specified when a breakpoint is set, by using ‘if’ in the arguments to the break command. See section Setting breakpoints. A breakpoint with a condition evaluates the expression each time your script reaches it, and your script stops only if the condition is true. They can also be changed at any time with the condition command.

There is also a notion of a “one-time” breakpoint which gets deleted as soon as it is hit, so that that breakpoint is executed once only.

Conditions are also accepted for watchpoints; you may not need them, since a watchpoint is inspecting the value of an expression anyhow—but it might be simpler, say, to just set a watchpoint on a variable name, and specify a condition that tests whether the new value is an interesting one.

condition bnum expression

Specify expression as the break condition for breakpoint bnum. After you set a condition, breakpoint bnum stops your program only if the value of expression is true (nonzero).

condition bnum

Remove the condition from breakpoint number bnum. It becomes an ordinary unconditional breakpoint.

BASH does not actually evaluate expression at the time the condition command (or a command that sets a breakpoint with a condition, like break if …) is given, however.

Examples;

 
condition 1 x>5   # Stop on breakpoint 0 only if x>5 is true.
condition 1       # Change that! Unconditinally stop on breakpoint 1.
4.4.2 Resuming Execution (‘step’, ‘next’, ‘finish’, ‘skip’, ‘continue’, ‘debug’, ‘return’)

A typical technique for using stepping is to set a breakpoint (see section Breakpoints; watchpoints) at the beginning of the function or the section of your script where a problem is believed to lie, run your script until it stops at that breakpoint, and then step through the suspect area, examining the variables that are interesting, until you see the problem happen.

Continuing means resuming program execution until your script completes normally. In contrast, stepping means executing just one more “step” of your script, where “step” may mean either one line of source code. Either when continuing or when stepping, your script may stop even sooner, due to a breakpoint or a signal.

4.4.2.1 Step (‘step’)
step[+|-] [count]

Continue running your script until control reaches a different source line, then stop it and return control to the BASH debugger. An default alias alias for this is s.

The step command only stops at the first instruction of a source line. This prevents the multiple stops that could otherwise occur in switch statements, for loops, etc. step continues to stop if a function that has debugging information is called within the line. In other words, step steps inside any functions called within the line.

Sometimes you want to step ensure that the next line is different from the one you currently are on. To do this, add the + suffix. And if you find you want to do this all of the time there is a setting force that will have this be the default behavior. On the other hand if you want to be explicit about not having this behavior even when force is in effect add the - suffix.

With a count, continue running as in step, but do so count times. If a breakpoint is reached, or a signal not related to stepping occurs before count steps, stepping stops right away.

4.4.2.2 Next (‘next’)
next [count]

Continue to the next source line in the current (innermost) stack frame. This is similar to step, but function calls that appear within the line of code are executed without stopping. Execution stops when control reaches a different line of code at the original stack level that was executing when you gave the next command. This command is abbreviated n.

An argument count is a repeat count, as for step.

4.4.2.3 Finish (‘finish’)
finish

Continue running until just after function returns. Currently, the line shown on a return is the function header, unless the return builtin function is executed in which case it is the line number of the return function.

Contrast this with the return command (see section Returning from a function) and the quit (see section Quitting the BASH debugger).

4.4.2.4 Skip (‘skip’)
skip [count]

Skip execution of the next source line. This may be useful if you have an action that “fixes” existing code in the script. The debug command internally uses the skip command to skip over existing non-debugged invocation that was presumably just run.

4.4.2.5 Continue (‘continue’)
continue [- | line-specification] c [line-specification]

Resume program execution, at the address where your script last stopped; any breakpoints set at that address are bypassed.

The optional argument line-specification allows you to specify a location (a line number, function, or filename linenumber combination) to set a one-time breakpoint which is deleted when that breakpoint is reached. Should the program stop before that breakpoint is reached, in a listing of the breakpoints you will see this entry with the condition 9999 which indicates a one-time breakpoint.

If instead of a line specification you enter -, debugging will be turned of after continuing causing the program to run at full speed.

To resume execution at a different place, you can use return (see section Returning from a function) to go back to the calling function or sourced script. If you are nested inside a subshell, quit with a value for the number of subshells to exit also functions like a return.

4.4.2.6 Debug (‘debug’)
debug [script-name]

Debug into script-name. If no name is given the current source line is used. In either case the options are prepended to cause the debugger to run.

The nesting level of the debugger is saved inside environment variable _Dbg_DEBUGGER_LEVEL. The debugger prompt indicates the level of nesting by enclosing the history in that many nestings of <> symbols.

4.4.2.7 Returning from a function, sourced file, or subshell (‘return’)
return

You can cancel execution of a function call or a subshell with the return command.

The return command does not resume execution; it leaves the program stopped in the state that would exist if the function had just returned. See also the quit command (Quitting the BASH debugger). In some situations return is similar to quit: in particular when the script is not currently inside in a function and the number of subshells in effect is 0, or when a subshell count of 1 is given on the quit command.

In contrast, the finish command (see section Finish) resumes execution until the selected stack frame returns naturally.

4.4.3 Signals (‘handle’, ‘info handle’, ‘signal’)

A signal is an asynchronous event that can happen in a program. The operating system defines the possible kinds of signals, and gives each kind a name and a number. For example, in Unix SIGINT is the signal a program gets when you type an interrupt character (often C-c); SIGALRM occurs when the alarm clock timer goes off (which happens only if your program has requested an alarm).

Some signal handlers are installed and changed for the BASH debugger’s normal use: SIGDEBUG and SIGEXIT. SIGDEBUG is used by the debugger to potentially stop your program before execution of each statement occurs, and SIGEXIT is used to catch your program just before it is set to leave so you have the option of restarting the program with the same options (and not leave the debugger) or let the program quit.

Signal handlers that the debugged script might have installed are saved and called before the corresponding debugger handler. Thus, the debugged program should work roughly in the same fashion as when it is not debugged. However there are some call-stack variables which inevitably will differ. To try to hedge this a little so the behavior is the same, the BASH debugger will modify arguments to the traps if it finds one of the call-stack that change as a result of the debugger being in place. In particular $LINENO will get replaced with ${BASH_LINENO[0]}; also ${BASH_LINENO[0]} and ${BASH_SOURCE[0]} get replaced with ${BASH_LINENO[1]} and ${BASH_SOURCE[1]} respectively.

The debugger also installs an interrupt handler SIGINT so that errant programs can be interrupted and you can find out where the program was when you interrupted it.

Some signals, including SIGALRM, are a normal part of the functioning of your program. Others, such as SIGSEGV, indicate errors; these signals are fatal (they kill your program immediately) if the program has not specified in advance some other way to handle the signal. SIGINT does not indicate an error in your program, but it is normally fatal so it can carry out the purpose of the interrupt: to kill the program.

BASH has the ability to detect any occurrence of a signal in your program. You can tell BASH in advance what to do for each kind of signal.

Normally, BASH is set up to let the non-erroneous signals like SIGALRM be silently passed to your program (so as not to interfere with their role in the program’s functioning) but to stop your program immediately whenever an error signal happens. You can change these settings with the handle command.

4.4.3.1 Intercepting Signals (‘handle’, ‘info handle’)
handle signal keywords

Change the way BASH handles signal signal. signal can be the number of a signal or its name (with or without the ‘SIG’ at the beginning). The keywords say what change to make.

info signals info handle

Print a table of all the kinds of signals and how BASH has been told to handle each one. You can use this to see the signal numbers of all the defined types of signals.

info handle is an alias for info signals.

The keywords allowed by the handle command can be abbreviated. Their full names are:

stop

BASH should stop your program when this signal happens. This implies the print keyword as well.

nostop

BASH should not stop your program when this signal happens. It may still print a message telling you that the signal has come in.

print

BASH should print a message when this signal happens.

noprint

BASH should not mention the occurrence of the signal at all.

stack

BASH should print a stack trace when this signal happens.

nostack

BASH should not print a stack trace when this signal occurs.

4.4.3.2 Sending your program a signal (‘signal’)
signal signal-name | signal-number

You can use the signal command send a signal to your program. Supply either the signal name, e.g. SIGINT, or the signal number 15.

4.5 Examining the Stack Frame (‘where’, ‘frame’, ‘up’, ‘down’)

When your script has stopped, one thing you’ll probably want to know is where it stopped and some idea of how it got there.

Each time your script performs a function call (either as part of a command substitution or not), or ‘source’s a file, information about this action is saved. The call stack then is this a history of the calls that got you to the point that you are currently stopped at.

One of the stack frames is selected by the BASH debugger and many the BASH debugger commands refer implicitly to the selected frame. In particular, whenever you ask the BASH debugger to list lines without giving a line number or location the value is found in the selected frame. There are special the BASH debugger commands to select whichever frame you are interested in. See section Selecting a frame.

When your program stops, BASH automatically selects the currently executing frame and describes it briefly, similar to the frame command.

4.5.1 Stack frames

The call stack is divided up into contiguous pieces called stack frames, or frames for short; each frame is the data associated with one call to one function. The frame contains the line number of the caller of the function, the source-file name that the line refers to a function name (which could be the built-in name “source”)..

When your script is started, the stack has only one frame, that of the function main. This is called the initial frame or the outermost frame. Each time a function is called, a new frame is made. Each time a function returns, the frame for that function invocation is eliminated. If a function is recursive, there can be many frames for the same function. The frame for the function in which execution is actually occurring is called the innermost frame. This is the most recently created of all the stack frames that still exist.

the BASH debugger assigns numbers to all existing stack frames, starting with zero for the innermost frame, one for the frame that called it, and so on upward. These numbers do not really exist in your script; they are assigned by the BASH debugger to give you a way of designating stack frames in the BASH debugger commands.

4.5.2 Backtraces (‘where’)

A backtrace is essentially the same as the call stack: a summary of how your script got where it is. It shows one line per frame, for many frames, starting with the place that you are stopped at (frame zero), followed by its caller (frame one), and on up the stack.

backtrace bt where T

Print a backtrace of the entire stack: one line per frame for all frames in the stack.

backtrace n bt n where n T n

Similar, but print only the innermost n frames.

The names where and T are additional aliases for backtrace.

Each line in the backtrace shows the frame number and the function name, the source file name and line number, as well as the function name.

Here is an example of a backtrace taken a program in the regression-tests ‘parm.sh’.

 
% ../bashdb -n -L .. parm.sh
Bourne-Again Shell Debugger, release 4.2-0.8
Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011 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.

(./parm.sh:21):
21:	fn1 5
bashdb<0> continue fn3
One-time breakpoint 1 set in file ./parm.sh, line 17.
fn2: testing 1 2 3
(./parm.sh:17):
17:	fn3() {
bashdb<1> where

->0 in file `./parm.sh' at line 14
##1 fn3() called from file `./parm.sh' at line 14
##2 fn2("testing 1", "2 3") called from file `parm.sh' at line 5
##3 fn1("0") called from file `parm.sh' at line 9
##4 fn1("1") called from file `parm.sh' at line 9
##5 fn1("2") called from file `parm.sh' at line 9
##6 fn1("3") called from file `parm.sh' at line 9
##7 fn1("4") called from file `parm.sh' at line 9
##8 fn1("5") called from file `parm.sh' at line 21
##9 source("parm.sh") called from file `bashdb' at line 143
##10 main("-n", "-L", "..", "parm.sh") called from file `bashdb' at line 0

The display for “frame” zero isn’t a frame at all, although it has the same information minus a function name; it just indicates that your script has stopped at the code for line 14 of ./parm.sh.

4.5.3 Selecting a frame (‘up’, ‘down’, ‘frame’)

Commands for listing source code in your script work on whichever stack frame is selected at the moment. Here are the commands for selecting a stack frame; all of them finish by printing a brief description of the stack frame just selected.

up [n]

Move n frames up the stack. For positive numbers n, this advances toward the outermost frame, to higher frame numbers, to frames that have existed longer. Using a negative n is the same as issuing a down command of the absolute value of the n. Using zero for n does no frame adjustment, but since the current position is redisplayed, it may trigger a resynchronization if there is a front end also watching over things.

n defaults to one. You may abbreviate up as u.

down [n]

Move n frames down the stack. For positive numbers n, this advances toward the innermost frame, to lower frame numbers, to frames that were created more recently. Using a negative n is the same as issuing a up command of the absolute value of the n. Using zero for n does no frame adjustment, but since the current position is redisplayed, it may trigger a resynchronization if there is a front end also watching over things.

n defaults to one. You may abbreviate down as do.

All of these commands end by printing two lines of output describing the frame. The first line shows the frame number, the function name, the arguments, and the source file and line number of execution in that frame. The second line shows the text of that source line.

For example:

 
bashdb<8> up

19:	sourced_fn
bashdb<8> T
##0 in file `./bashtest-sourced' at line 8
->1 sourced_fn() called from file `bashtest-sourced' at line 19
##2 source() called from file `bashdb-test1' at line 23
##3 fn2() called from file `bashdb-test1' at line 33
##4 fn1() called from file `bashdb-test1' at line 42
##5 main() called from file `bashdb-test1' at line 0

After such a printout, the list command with no arguments prints ten lines centered on the point of execution in the frame. See section Printing source lines.

frame args

The frame command allows you to move from one stack frame to another, and to print the stack frame you select. args is the the stack frame number; frame 0 then will always show the current and most recent stack frame.

If a negative number is given, counting is from the other end of the stack frame, so frame -1 shows the least-recent, outermost or most “main” stack frame.

Without an argument, frame prints the current stack frame. Since the current position is redisplayed, it may trigger a resynchronization if there is a front end also watching over things.

4.6 Examining Source Files (‘list’)

the BASH debugger can print parts of your script’s source. When your script stops, the BASH debugger spontaneously prints the line where it stopped. Likewise, when you select a stack frame (see section Selecting a frame), the BASH debugger prints the line where execution in that frame has stopped. You can print other portions of source files by explicit command.

If you use the BASH debugger through its GNU Emacs interface, you may prefer to use Emacs facilities to view source.

To print lines from a source file, use the list command (abbreviated l). By default, ten lines are printed. There are several ways to specify what part of the file you want to print.

Here are the forms of the list command most commonly used:

list linenum l linenum

Print lines centered around line number linenum in the current source file.

list function l function

Print the text of function.

list l

Print more lines. If the last lines printed were printed with a list command, this prints lines following the last lines printed; however, if the last line printed was a solitary line printed as part of displaying a stack frame (see section Examining the Stack), this prints lines centered around that line.

list - l -

Print lines just before the lines last printed.

By default, the BASH debugger prints ten source lines with any of these forms of the list command. You can change this using set listsize:

set listsize count

Make the list command display count source lines (unless the list argument explicitly specifies some other number).

show listsize

Display the number of lines that list prints.

Repeating a list command with <RET> discards the argument, so it is equivalent to typing just list. This is more useful than listing the same lines again. An exception is made for an argument of ‘-’; that argument is preserved in repetition so that each repetition moves up in the source file.

In general, the list command expects you to supply a linespecs. Linespecs specify source lines; there are several ways of writing them, but the effect is always to specify some source line.

Here is a complete description of the possible arguments for list:

list linespec

Print lines centered around the line specified by linespec.

list first increment

Print increment lines starting from first

list first

Print lines starting with first.

list -

Print lines just before the lines last printed.

list .

Print lines after where the script is stopped.

list

As described in the preceding table.

Here are the ways of specifying a single source line—all the kinds of linespec.

number

Specifies line number of the current source file. When a list command has two linespecs, this refers to the same source file as the first linespec.

filename:number

Specifies line number in the source file filename.

function

Specifies the line that function function is listed on.

4.7 Editing Source files (‘edit’)

To edit the lines in a source file, use the edit command. The editing program of your choice is invoked with the current line set to the active line in the program. Alternatively, you can give a line specification to specify what part of the file you want to print if you want to see other parts of the program.

You can customize to use any editor you want by using the EDITOR environment variable. The only restriction is that your editor (say ex), recognizes the following command-line syntax:

 
ex +number file

The optional numeric value +number specifies the number of the line in the file where to start editing. For example, to configure the BASH debugger to use the vi editor, you could use these commands with the sh shell:

 
EDITOR=/usr/bin/vi
export EDITOR
gdb …

or in the csh shell,

 
setenv EDITOR /usr/bin/vi
gdb …
edit [line specification]

Edit line specification using the editor specified by the EDITOR environment variable.

4.8 Searching source files (‘search’, ‘reverse’, ‘/.../’, ‘?..?’)

There are two commands for searching through the current source file for a BASH extended pattern-matching expression.

forward bash-pattern search bash-pattern

The command ‘forward bash-pattern’ checks each line, starting with the one following the current line, for a match for bash-pattern which is an extended bash pattern-matching expression. It lists the line that is found. You can use the synonym ‘search bash-pattern’ or abbreviate the command name as fo or /pat/.

reverse bash-pattern

The command ‘reverse bash-pattern’ checks each line, starting with the one before the last line listed and going backward, for a match for bash-pattern. It lists the line that is found. You can abbreviate this command as rev or ?bash-pattern?.

4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)

One way to examine string data in your script is with the print command (abbreviated p). However a more versatile print command is x; it can print variable and function definitions and can do arithmetic computations. Finally, the most general method would be via eval echo.

print expr

Use print to display strings as you would from echo. And as such, variable names to be substituted have to be preceded with a dollar sign. As with echo, filename expansion, e.g. tilde expansion, is performed on unquoted strings. So for example if you want to print a *, you would write ‘print "*"’, not ‘print *’. If you want to have the special characters dollars sign appear, use a backslash.

 
bashdb<0> print the value of x is $x
the value of x is 22
bashdb<1> p The home directory for root is ~root
The home directory for root is /root
bashdb<2> p '*** You may have won $$$ ***'
*** You may have won $$$ ***
bashdb<3> # Note the use of the single quotes.
bashdb<3> # Compare what happens with double quotes or no quotes

print p

If you omit expr, the BASH debugger displays the last expression again.

x variable1 [variable2...] x expr

This is a smarter, more versatile “print” command, and although sometimes it might not be what you want, and you may want to resort to either print or eval echo....

As with print, if you omit expr, the BASH debugger displays the last expression again.

The x command first checks if expr is variable or a list of variables delimited by spaces. If it is, the definition(s) and value(s) of each printed via BASH’s declare -p command. This will show the variable’s attributes such as if it is read only or if it is an integer. If the variable is an array, that is show and the array values are printed.

If instead expr is a function, the function definition is printed via BASH’s declare -f command. If expr was neither a variable nor an expression, then we try to get a value via let. And if this returns an error, as a last resort we call print and give what it outputs.

Since let may be used internally and since (to my thinking) let does funny things, the results may seem odd unless you understand the sequence tried above and how let works. For “example if the variable foo has value 5, then ‘x foo’ shows the definition of foo with value 5, and ‘x foo+5’ prints 10 as expected. So far so good. However if foo is has the value ‘alpha’, ‘x foo+5’ prints 5 because let has converted the string ‘alpha’ into the numeric value 0. So ‘p foo+5’ will simply print “foo+5”; if you want the value of “foo” substituted inside a string, for example you expect “the value of foo is $foo” to come out “the value of foo is 5”, then the right command to use is print rather than x, making sure you add the dollar onto the beginning of the variable.

 
bashdb<0> examine x y
declare -- x="22"

declare -- y="23"
bashdb<1> examine x+y
45
bashdb<2> x fn1
fn1 () 
{ 
    echo "fn1 here";
    x=5;
    fn3
}
bashdb<2> x FUNCNAME

declare -a FUNCNAME='([0]="_Dbg_cmd_x" [1]="_Dbg_cmdloop" [2]="_Dbg_debug_trap_handler" [3]="main")'
V [!][pattern]

If you want to all list variables and values or a set of variables by pattern, use this command.

 
bashdb<0> V dq*
dq_args="dq_*"
dq_cmd="V"
bashdb<1> V FUNCNAME

FUNCNAME='([0]="_Dbg_cmd_list_variables" [1]="_Dbg_cmdloop" [2]="_Dbg_debug_trap_handler" [3]="main")'
4.10 Automatic display (‘display’, ‘undisplay’)

If you find that you want to print the value of an expression frequently (to see how it changes), you might want to add it to the automatic display list so that the BASH debugger evaluates a statement each time your program stops. Each expression added to the list is given a number to identify it; to remove an expression from the list, you specify that number. The automatic display looks like this:

 
2 (echo $x): 38

This display shows item numbers, expressions and their current values.

display expr

Add the expression expr to the list of expressions to display each time your program stops.

display

Display the current values of the expressions on the list, just as is done when your program stops.

undisplay dnums delete display dnums

Remove item numbers dnums from the list of expressions to display.

undisplay does not repeat if you press <RET> after using it. (Otherwise you would just get the error ‘No display number …’.)

disable display dnums

Disable the display of item numbers dnums. A disabled display item is not printed automatically, but is not forgotten. It may be enabled again later.

enable display dnums

Enable display of item numbers dnums. It becomes effective once again in auto display of its expression, until you specify otherwise.

info display

Print the list of expressions previously set up to display automatically, each one with its item number, but without showing the values. This includes disabled expressions, which are marked as such. It also includes expressions which would not be displayed right now because they refer to automatic variables not currently available.

4.11 Running Arbitrary BASH and Shell commands (‘eval’, ‘shell’)

The two most general commands and most “low-level” are eval and shell.

eval [ bash-code ] e

In contrast to the commands of the last section the most general way to examine data is through eval. But you do much more with this; you can change the values of variables, since, you are just evaluating BASH code.

If you expect output, you should arrange that in the command, such as via echo or printf. For example, to print the value of foo, you would type ‘e echo $foo’. This is bit longer than ‘p $foo’ or (when possible) ‘x foo’. However suppose you wanted to find out how the builtin test operator ‘[’ works with the ‘-z’ test condition. You could use eval to do this such as ‘e [ -z "$foo"] && echo "yes"’.

eval

I find I sometimes want to run the line that’s about to be executed to see if I want to step into methods that are called.

For example:

 
(/etc/apparmor/functions:24):
PROFILES="/etc/apparmor.d"
bashdb<2> 

I had been cutting and pasting the command as shown, but realized I could do better if I made a command for this. So that’s what I’ve done.

If you run the ‘eval’ command without any arguments, it will run the command that is about to be run.

 
(/etc/apparmor/functions:24):
PROFILES="/etc/apparmor.d"
bashdb<2> eval
eval: PROFILES="/etc/apparmor.d"

$? is 0
bashdb<3> 

This was working fine, until I started coming across tests inside if, elsif, case, return or while blocks. For example:

 
(/etc/init.d/apparmor:70):
if [ "$1" = "recache" ]

Suppose I want to know which branch I’m going to take before taking the branch. That way I might even be able to change which way to go by changing the test before it runs in the debugged program. (In the above example, I could print $1

 
bashdb<2> pr $1
status

But I’m lazy. I’d rather let the debugger do the work for me:

 
bashdb<1> eval?
eval: [ "$1" = "recache" ]
$? is 1

If you alias eval with a name that ends in ? it will strip off any leading if, case, while, elsif, or return.

!! command string

If you need to execute occasional shell commands during your debugging session, there is no need to leave or suspend the BASH debugger; you can just use the shell command or its alias !!.

Invoke a shell to execute command string.

shell

Although the debugger allows one to evaluate arbitrary BASH code using eval, or via the set autoeval mode, sometimes you might prefer to work inside a BASH shell to see variables, experiment, issue commands (using the currently-set up environment), and even change variables and functions.

For this we, the debugger shell command, enters a nested shell session. But before it does this, it saves out variable and function definitions in the current context of the running program. That way, you have access to those.

This however creates a new problem: getting changes you make reflected back into the running program. Right now any variable you change can be flagged to have its value re-read when the shell exits. This is done using the save_var function inside the nested shell. save_var takes a list of variable names.

Here is an example session

 
bashdb /etc/init.d/apparmor status
bashdb debugger, release 4.2-0.8

Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 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.
...
(/etc/init.d/apparmor:35):
. /etc/apparmor/functions
bashdb<1> s
(/etc/apparmor/functions:24):
PROFILES="/etc/apparmor.d"

bashdb<2> s
(/etc/apparmor/functions:25):
PARSER="/sbin/apparmor_parser"
bashdb<3> shell
bashdb $ typeset -p PROFILES
typeset -p PROFILES
typeset PROFILES=/etc/apparmor.d
bashdb $ PROFILES='Hi, Mom!'
bashdb $ save_vars PROFILES
bashdb $  <EOF>
(/etc/apparmor/functions:25):
PARSER="/sbin/apparmor_parser"
bashdb<4> x PROFILES
typeset PROFILES='Hi, Mom!'

Note that inside the nested shell the we have set the prompt has been set to bashdb $ .

4.12 Interfacing to the OS (‘cd’, ‘pwd’)
cd

Set working directory to directory for debugger and program being debugged. Tilde expansion, variable and filename expansion is performed on directory. If no directory is given, we print out the current directory which is really the same things as running pwd.

Note that gdb is a little different in that it performs tilde expansion but not filename or variable expansion and the directory argument is not optional as it is here.

pwd

Prints the working directory as the program sees things.

4.13 Status and Debugger Settings (‘info’, ‘show’)

In addition to help, you can use the BASH commands info and show to inquire about the state of your program, or the state of BASH itself. Each command supports many topics of inquiry; here we introduce each of them in the appropriate context. The listings under info and under show in the Index point to all the sub-commands. See section Command Index.

4.13.1 Showing information about the program being debugged (‘info’)

This info command (abbreviated i) is for describing the state of your program. For example, you can list the current $1, $2 parameters with info args, or list the breakpoints you have set with info breakpoints or info watchpoints. You can get a complete list of the info sub-commands with help info.

info args

Argument variables (e.g. $1, $2, ...) of the current stack frame.

info breakpoints

Status of user-settable breakpoints

info display

Show all display expressions

info files

Source files in the program

info functions

All function names

info line

list current line number and and file name

info program

Execution status of the program.

info signals

What debugger does when program gets various signals

info source

Information about the current source file

info stack

Backtrace of the stack

info terminal

Print terminal device

info variables

All global and static variable names

4.13.2 Show information about the debugger (‘show’)

In contrast to info, show is for describing the state of BASH itself. You can change most of the things you can show, by using the related command set;

The distinction between info and show however is a bit fuzzy and is kept here to try to follow the GDB interface. For example, to list the arguments given to your script use show args; info args does something different.

Here are three miscellaneous show subcommands, all of which are exceptional in lacking corresponding set commands:

show version

Show what version of BASH is running. You should include this information in BASH bug-reports. If multiple versions of BASH are in use at your site, you may need to determine which version of BASH you are running; as BASH evolves, new commands are introduced, and old ones may wither away. Also, many system vendors ship variant versions of BASH, and there are variant versions of BASH in GNU/Linux distributions as well. The version number is the same as the one announced when you start BASH.

show copying

Display information about permission for copying BASH.

show linetrace show logging

Show summary information of logging variables which can be set via set logging. See also Logging output (‘set logging’, ‘set logging file’...).

show logging file

Show the current logging file.

show logging overwrite

Show whether logging overwrites or appends to the log file.

show warranty

Display the GNU “NO WARRANTY” statement, or a warranty, if your version of the BASH debugger comes with one.

4.14 Controlling bashdb (‘set’, ‘file’, ‘prompt’, ‘history’...)

You can alter the way BASH interacts with you in various ways given below.

4.14.1 Debugger Command Aliases (‘alias’)
alias name command

Add name as an alias for command

Remove name as an alias for command

unalias name command
4.14.2 Annotation Level (‘set annotate’)
set annotate integer

The annotation level controls how much information the BASH debugger prints in its prompt; right new it just controls whether we show full filenames in output or the base part of the filename without path information. Level 0 is the normal, level 1 is for use when the BASH debugger is run as a subprocess of GNU Emacs of DDD, level 2 is the maximum annotation suitable for programs that control the BASH debugger.

4.14.3 Set/Show auto-eval (‘set autoeval’)
set autoeval [ on | 1 | off | 0 ]

Specify that debugger input that isn’t recognized as a command should be passed to Ruby for evaluation (using the current debugged program namespace). Note however that we first check input to see if it is a debugger command and only if it is not do we consider it as Ruby code. This means for example that if you have variable called n and you want to see its value, you could use p n, because just entering n will be interpreted as the debugger “next” command.

When autoeval is set on, you’ll get a different error message when you invalid commands are encountered. Here’s a session fragment to show the difference

 
bashdb<1> stepp

Unknown command
bashdb<2> set autoeval on
autoeval is on.
bashdb<3> stepp
NameError Exception: undefined local variable or method `stepp' for ...
show args

Shows whether Ruby evaluation of debugger input should occur or not.

4.14.4 Set/Show listing on stop (‘set autolist’)
set autolist [ on | 1 | off | 0 ]

When set runs a “list” command on each stop in the debugger.

4.14.5 File basename (‘set basename’)
set basename [ on | 1 ]

When set on, source filenames are shown as the shorter “basename” only. (Directory paths are omitted). This is useful in running the regression tests and may useful in showing debugger examples as in this text. You may also just want less verbose filename display.

set basename [ off | 0 ]

Source filenames are shown as with their full path. This is the default.

4.14.6 Allow Debugging the debugger (‘set debugger’)
set debugger [ on | 1 ]

Allow the possibility of debugging this debugger. Somewhat of an arcane thing to do. For gurus, and even he doesn’t use it all that much.

set debugger [ off | 0 ]

Don’t allow debugging into the debugger. This is the default.

4.14.7 Specifying a Script-File Association (‘file’)

Sometimes the BASH debugger gets confused about where to find the script source file for the name reported to it by bash. To resolve relative file names that bash supplies via BASH_SOURCE, the BASH debugger uses the current working directory when the debugged script was started as well as the current working directory now (which might be different if a “cd” command was issued to change the working directory).

However sometimes this doesn’t work and there is a way to override this.

file script-file

Directs the BASH debugger to use script-file whenever bash would have it refers to the filename given in BASH_SOURCE. The filename specified in BASH_SOURCE that gets overridden is shown when is this command is issued.

4.14.8 Show position information as statements are executed (‘set linetrace’)

BASH has “set -x” tracing to show commands as they are run. However missing from this is file and line position information. So the debugger compensates here for what I think is deficiency of BASH by providing this information. The downside is that this tracing is slower than the built-in tracing of BASH.

The status of whether line tracing is enabled can be show via show linetrace.

set linetrace [ on | 1 ]

Turn on line tracing.

set linetrace [ off | 0 ]

Turn off line tracing.

4.14.9 Logging output (‘set logging’, ‘set logging file’...)

You may want to save the output of the debugger commands to a file. There are several commands to control the debuggers’s logging.

set logging

Prints set logging usage.

set logging [ on | 1 ]

Enable or Disable logging.

set logging file filename

Change the name of the current logfile. The default logfile is ‘bashdb.txt’.

set logging overwrite [ on | 1 ]

By default, the debugger will append to the logfile. Set overwrite if you want set logging on to overwrite the logfile instead.

set logging redirect [ on | 1 ]

By default, the debugger output will go to both the terminal and the logfile. Set redirect if you want output to go only to the log file.

show logging

Show the current values of the logging settings.

4.14.10 Prompt (‘set prompt’, ‘show prompt’)

The BASH debugger indicates its readiness to read a command by printing a string called the prompt. This string is normally:

 
bashdb${_Dbg_less}${#_Dbg_history[@]}${_Dbg_greater}$_Dbg_space

When variables inside the the prompt string are evaluated, the above becomes something like ‘bashdb<5>’ if this is the fifth command executed or perhaps ‘bashdb<<2>>’ if you have called the debugger from inside a debugger session and this is the second command inside the debugger session or perhaps ‘bashdb<(6)>’ if you entered a subshell after the fifth command.

You can change the prompt string with the set prompt command, although it is not normally advisable to do so without understanding the implications. If you are using the DDD GUI, it changes the changes the prompt and should not do so. In certain other circumstances (such as writing a GUI like DDD), it may be is useful to change the prompt.

Note: set prompt does not add a space for you after the prompt you set. This allows you to set a prompt which ends in a space or a prompt that does not. Furthermore due to a implementation limitation (resulting from a limitation of the bash built-in function “read”), to put a space at the end of the prompt use the ‘$_Dbg_space’ variable.

set prompt newprompt

Directs the BASH debugger to use newprompt as its prompt string henceforth.

Warning: changing the prompt can DDD’s ability to understand when the debugger is waiting for input.

show prompt

Prints a line of the form: ‘bashdb's prompt is: your-prompt

4.14.11 Command editing (‘set editing’, ‘show editing’)

the BASH debugger reads its input commands through bash which uses via the readline interface. This GNU library provides consistent behavior for programs which provide a command line interface to the user. Advantages are GNU Emacs-style or vi-style inline editing of commands, csh-like history substitution, and a storage and recall of command history across debugging sessions.

You may control the behavior of command line editing in BASH with the command set.

set editing set editing [ on | 1 ]

Enable command line editing (enabled by default).

set editing [ off | 0 ]

Disable command line editing.

show editing

Show whether command line editing is enabled.

4.14.12 Debugger Commands Tracing (‘set trace-commands’, ‘show trace-commands’)

If you need to debug user-defined commands or sourced files you may find it useful to enable command tracing. In this mode each command will be printed as it is executed, prefixed with one or more ‘+’ symbols, the quantity denoting the call depth of each command.

set trace-commands on

Enable command tracing.

set trace-commands off

Disable command tracing.

show trace-commands

Display the current state of command tracing.

4.14.13 Command Display (‘set showcommand’)

The debugger normally lists the line number and source line of the for the statement to be next executed. Often this line contains one expression or one statement and it is clear from this line what’s going to happen. However BASH allows many expressions or statements to be put on a single source line; some lines contain several units of execution. Some examples of this behavior are listed below:

 
x=1; y=2; x=3
(( x > 5 )) && x=5
y=`echo *`

In the first line of the example above, we have three assignment statements on a single line. In the second line of the example above we have a statement which gets run only if a condition tests true. And in the third line of the example above, we have a command that gets run and then the output of that is substituted in an assignment statement. If you were single stepping inside the debugger, each line might get listed more than once before each of the actions that might get performed. (In the case of the conditional statement, the line gets listed only once when the condition is false.)

In order to assist understanding where you are, the enhanced version of BASH maintains a dynamic variable BASH_COMMAND that contains piece of code next to be run (or is currently being run). The debugger has arranged to save this and can display this information or not. This is controlled by set showcommand.

set showcommand [auto | on | 1 | off | 0 ]

controls whether or not to show the saved BASH_COMMAND for the command next to be executed.

When the value is auto the following heuristic is used to determine whether or not to display the saved BASH_COMMAND. If the last time you stopped you were at the same place and the command string has changed, then show the command. When the value on is used, the debugger always shows BASH_COMMAND and when off is used, the debugger never shows BASH_COMMAND. Note that listing the text of the source line is independent of whether or not the command is also listed.

Some examples:

 
set showcommand auto      This is the default
set showcommand on        Always show the next command to be executed
set showcommand off       Never show the next command to be executed
4.14.14 Command history (‘H’, ‘history’, ‘!’)

The BASH debugger can keep track of the commands you type during your debugging sessions, so that you can be certain of precisely what happened. If the prompt has not been changed (see Prompt), the history number that will be in use next is by default listed in the debugger prompt. Invalid commands and history commands are not saved on the history stack.

H [start-number [end-number]] H [-count] ![-]n:p

You can list what is in the history stack with H. Debugger commands in the history stack are listed from most recent to least recent. If no start-number is given we start with the most recently executed command and end with the first entry in the history stack. If start-number is given, that history number is listed first. If end-number is given, that history number is listed last. If a single negative number is given list that many history commands.

An alternate form is !n:p or !-n:p where n is an integer. If a minus sign is used, n is taken as the count to go back from the end rather than as a absolute history number. In contrast H, this form only prints a single history item.

Some examples:

 
H      List entire history
H -2   List the last two history items
!-2:p  List a single history item starting at the same place as above
H 5    List history from history number 5 to the beginning (number 0)
H 5 0  Same as above

H 5 3  List history from history number 5 down to history number 3
!5:p   List a single history item 5
history [[-]n] ![-]n

Use this command to reexecute a given history number. If no number is given, the last debugger command in the history is executed.

An alternate form is !n or !-n where n is an integer.

If a minus sign is used in in either form, n is taken as the count to go back from the end rather than as a absolute history number.

Use these commands to manage the the BASH debugger command history facility.

set history save set history save [ on | 1 ]

Record command history in a file, whose name may be specified with the set history filename command. By default, this option is enabled.

set history save [ off | 0 ]

Stop recording command history in a file.

set history size size

Set the number of commands which BASH keeps in its history list. This defaults to the value of the environment variable HISTSIZE, or to 256 if this variable is not set.

show history show history save show history size

These commands display the state of the BASH history parameters. show history by itself displays all states.

show commands

Display the last ten commands in the command history.

show commands n

Print ten commands centered on command number n.

show commands +

Print ten commands just after the commands last printed.

4.14.15 Command Completion (‘complete’)

The complete args command lists all the possible completions for the beginning of a command. We can also show completions for set, show and info subcommands. Use args to specify the beginning of the command you want completed. For example:

 
complete d

results in:

 
d
debug
delete
disable
display
deleteall
down

And

 
complete set a

results in:

 
set args
set annotate

This is intended for use by front-ends such as GNU Emacs and DDD.

5. Reporting Bugs

Your bug reports play an essential role in making the BASH debugger reliable.

Reporting a bug may help you by bringing a solution to your problem, or it may not. But in any case the principal function of a bug report is to help the entire community by making the next version of the BASH debugger work better. Bug reports are your contribution to the maintenance of the BASH debugger.

In order for a bug report to serve its purpose, you must include the information that enables us to fix the bug.

5.1 Have you found a bug?

If you are not sure whether you have found a bug, here are some guidelines:

  • If the debugger gets a fatal signal, for any input whatever, that is a the BASH debugger bug. Reliable debuggers never crash.
  • If the BASH debugger produces an error message for valid input, that is a bug. (Note that if you’re cross debugging, the problem may also be somewhere in the connection to the target.)
  • If the BASH debugger does not produce an error message for invalid input, that is a bug. However, you should note that your idea of “invalid input” might be our idea of “an extension” or “support for traditional practice”.
  • If you are an experienced user of debugging tools, your suggestions for improvement of the BASH debugger are welcome in any case.
5.2 How to report bugs

Bug reports can sent via the sourceforge bug tracking mechanism at http://sourceforge.net/tracker/?group_id=61395&atid=497159. Of course patches are very much welcome too. Those can also be sent via the same mechanism.

The fundamental principle of reporting bugs usefully is this: report all the facts. If you are not sure whether to state a fact or leave it out, state it!

Often people omit facts because they think they know what causes the problem and assume that some details do not matter. Thus, you might assume that the name of the variable you use in an example does not matter. Well, probably it does not, but one cannot be sure. Perhaps the bug is a stray memory reference which happens to fetch from the location where that name is stored in memory; perhaps, if the name were different, the contents of that location would fool the debugger into doing the right thing despite the bug. Play it safe and give a specific, complete example. That is the easiest thing for you to do, and the most helpful.

Keep in mind that the purpose of a bug report is to enable us to fix the bug. It may be that the bug has been reported previously, but neither you nor we can know that unless your bug report is complete and self-contained.

Sometimes people give a few sketchy facts and ask, “Does this ring a bell?” Those bug reports are useless, and we urge everyone to refuse to respond to them except to chide the sender to report bugs properly.

To enable us to fix the bug, you should include all these things:

  • The version of the BASH debugger. the BASH debugger announces it if you start with no arguments; you can also print it at any time using version command.

    Without this, we will not know whether there is any point in looking for the bug in the current version of the BASH debugger.

  • The type of machine you are using, and the operating system name and version number.
  • What compiler (and its version) was used to compile BASH—e.g. “gcc 3.4”.
  • The command arguments you gave the compiler to compile your example and observe the bug. For example, did you use ‘-O’? To guarantee you will not omit something important, list them all. A copy of the Makefile (or the output from make) is sufficient.

    If we were to try to guess the arguments, we would probably guess wrong and then we might not encounter the bug.

  • A complete input script, and all necessary source files, that will reproduce the bug.
  • A description of what behavior you observe that you believe is incorrect. For example, “It gets a fatal signal.”

    Of course, if the bug is that the BASH debugger gets a fatal signal, then we will certainly notice it. But if the bug is incorrect output, we might not notice unless it is glaringly wrong. You might as well not give us a chance to make a mistake.

    Even if the problem you experience is a fatal signal, you should still say so explicitly. Suppose something strange is going on, such as, your copy of the BASH debugger is out of synch, or you have encountered a bug in the C library on your system. (This has happened!) Your copy might crash and ours would not. If you told us to expect a crash, then when ours fails to crash, we would know that the bug was not happening for us. If you had not told us to expect a crash, then we would not be able to draw any conclusion from our observations.

  • If you wish to suggest changes to the the BASH debugger source, send us context diffs. If you even discuss something in the the BASH debugger source, refer to it by context, not by line number.

    The line numbers in our development sources will not match those in your sources. Your line numbers would convey no useful information to us.

Here are some things that are not necessary:

  • A description of the envelope of the bug.

    Often people who encounter a bug spend a lot of time investigating which changes to the input file will make the bug go away and which changes will not affect it.

    This is often time consuming and not very useful, because the way we will find the bug is by running a single example under the debugger with breakpoints, not by pure deduction from a series of examples. We recommend that you save your time for something else.

    Of course, if you can find a simpler example to report instead of the original one, that is a convenience for us. Errors in the output will be easier to spot, running under the debugger will take less time, and so on.

    However, simplification is not vital; if you do not want to do this, report the bug anyway and send us the entire test case you used.

  • A patch for the bug.

    A patch for the bug does help us if it is a good one. But do not omit the necessary information, such as the test case, on the assumption that a patch is all we need. We might see problems with your patch and decide to fix the problem another way, or we might not understand it at all.

    Sometimes with a program as complicated as the BASH debugger it is very hard to construct an example that will make the program follow a certain path through the code. If you do not send us the example, we will not be able to construct one, so we will not be able to verify that the bug is fixed.

    And if we cannot understand what bug you are trying to fix, or why your patch should be an improvement, we will not install it. A test case will help us to understand.

  • A guess about what the bug is or what it depends on.

    Such guesses are usually wrong. Even we cannot guess right about such things without first using the debugger to find the facts.

6. History and Acknowledgments

The suggestion for a debugger for a Bourne-like shell came from the book “Learning the Korn Shell”, by Bill Rosenblatt Copyright (C) 1993 by O’Reilly and Associates, Inc. Others such as Cigy Cyriac, Chet Ramey, Rocky Bernstein, and Gary V. Vaughan expanded and improved on that.

However Bourne-Shell debuggers rely on a signal mechanism (SIGDEBUG) to call a debugger routine. In the Korn shell as well as BASH in versions prior to 2.05, there was a fundamental flaw: the routine that you registered in the trap, got called after the statement was executed. It takes little imagination to realize that this is a bit too late to find and correct errors, especially if the offending command happens to do serious damage like remove filesystems or reboot a server. As a horrible hack, these debuggers added one to the line number that was just executed on the wishful thinking that this would then be the line of next statement to execute. Sometimes this was correct, but it was too often wrong, such as in loops and conditionals, comments, or commands that are continued on the next line.

Another failing of these debuggers was the inability to debug into functions or into sourced files, provide a stack trace, dynamically skip a statement to be run, unconditionally trace into a function or subshell, or stop when a subroutine, sourced file, or subshell completed. In truth, the crux of the problem lay in debugging support in BASH. Given that there was limited bash debugging support, it is not surprising that these debuggers could not do any of the things listed above and could debug only a single shell in a single source file: lines could be listed only from a single text, breakpoints were set into the text which was in fact a copy of the script name prepended with debugger routines.

In version 2.04 of BASH, Rocky Bernstein started hacking on BASH to add call-stack information, source file information, allow for debugging into functions and for reporting line numbers in functions as relative to the file rather than the beginning of a function whose origin line number was not accessible from BASH. He started changing the user commands in bashdb to be like other more-advanced debuggers, in particular perl5db and gdb. However he gave up on this project when realizing that stopping before a line was crucial. A patch for this was nontrivial and wildly changed semantics. Furthermore the chance of getting his other patches into BASH was was not going to happen in version 2.04.

In version 2.05, the fundamental necessary change to the semantics of SIGDEBUG trap handling (suggested at least two years earlier) was made. Also, version 2.05 changed the line-number reporting in a function to be relative to the beginning of the file rather than the beginning of a function—sometimes. Rocky then picked up where he left off and this then became this debugger. A complete rewrite of the debugger, some of which started in 2.04 was undertaken. Debugger internals were changed to support multiple file names, save and restore the calling environment (such as variables $1 and $?) and install debugger signal handlers. Work was also done on the BASH in conjunction with the debugger to save stack trace information, provide a means for stopping after a routine finished, debugging into a subshell and so on. And a number of changes were made to BASH just to improve the accuracy of the line number reporting which is crucial in a debugger.

This documentation was modified from the GNU Debugger (GDB) Reference manual.

Additions to this section are particularly welcome. If you or your friends (or enemies, to be evenhanded) have been unfairly omitted from this list, we would like to add your names!

The following have contributed directly or indirectly to bashdb:

Rocky Bernstein (initial full-featured bashdb with stack tracing and multi-file support)

Masatake YAMATO (help to merge Rocky’s hack to the official bash source tree)

Rod Smith (for creating and hosting a nicely formatted version of this manual that you are probably reading online)

Bill Rosenblatt (kshdb), Michael Loukides (kshdb), Cigy Cyriac (proto bashdb), Chet Ramey (proto bashdb), and Gary V. Vaughan (proto bashdb).

Authors of per5ldb:

Ray Lischner, Johan Vromans, and Ilya Zakharevich.

Authors of GDB:

Richard Stallman, Andrew Cagney, Jim Blandy, Jason Molenda, Stan Shebs, Fred Fish, Stu Grossman, John Gilmore, Jim Kingdon, and Randy Smith (to name just a few).

Authors of GUD:

Eric S. Raymond.

A. GNU General Public License version 3
[OSI Approved License]
GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Preamble

The GNU General Public License is a free, copyleft license for software and other kinds of works.

The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.

To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.

For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.

Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.

Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS
0. Definitions.

“This License” refers to version 3 of the GNU General Public License.

“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.

“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.

To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.

A “covered work” means either the unmodified Program or a work based on the Program.

To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.

To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.

An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.

1. Source Code.

The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.

A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.

The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form.

A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.

The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.

The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.

The Corresponding Source for a work in source code form is that same work.

2. Basic Permissions.

All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.

You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.

Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.

3. Protecting Users Legal Rights From Anti Circumvention Law.

No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.

When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.

4. Conveying Verbatim Copies.

You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.

You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.

5. Conveying Modified Source Versions.

You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:

  • a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
  • b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
  • c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
  • d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.

A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.

6. Conveying Non Source Forms.

You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:

  • a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
  • b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
  • c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
  • d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
  • e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.

A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.

A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.

“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.

If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).

The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.

Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.

7. Additional Terms.

“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.

When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.

Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:

  • a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
  • b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
  • c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
  • d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
  • e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
  • f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.

All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.

If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.

Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.

8. Termination.

You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).

However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.

9. Acceptance Not Required for Having Copies.

You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.

10. Automatic Licensing of Downstream Recipients.

Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.

An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.

You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.

11. Patents.

A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.

A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.

Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.

In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.

If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.

If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.

A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.

Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.

12. No Surrender of Others Freedom.

If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.

13. Use with the GNU Affero General Public License.

Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.

14. Revised Versions of this License.

The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.

If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.

Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.

15. Disclaimer of Warranty.

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

16. Limitation of Liability.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

17. Interpretation of Sections 15 and 16.

If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>

This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.

You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

B. GNU Free Documentation License

Version 1.1, March 2000

 
Copyright (C) 2000  Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

1. PREAMBLE

The purpose of this License is to make a manual, textbook, or other written document “free” in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

2. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you.”

A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License.

The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License.

A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not “Transparent” is called “Opaque.”

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only.

The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text. 

3. VERBATIM COPYING

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and you may publicly display copies. 

4. COPYING IN QUANTITY

If you publish printed copies of the Document numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 

5. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five).
C. State on the Title page the name of the publisher of the Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice.
H. Include an unaltered copy of this License.
I. Preserve the section entitled “History”, and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
K. In any section entitled “Acknowledgements” or “Dedications”, preserve the section’s title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
M. Delete any section entitled “Endorsements.” Such a section may not be included in the Modified Version.
N. Do not retitle any existing section as “Endorsements” or to conflict in title with any Invariant Section.

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

You may add a section entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties–for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. 

6. COMBINING DOCUMENTS

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.

The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections entitled “History” in the various original documents, forming one section entitled “History”; likewise combine any sections entitled “Acknowledgements”, and any sections entitled “Dedications.” You must delete all sections entitled “Endorsements.” 

7. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 

8. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an “aggregate”, and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document’s Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate. 

9. TRANSLATION

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail. 

10. TERMINATION

You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 

11. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

 
Copyright (C)  year  your name.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with the Invariant Sections being list their titles, with the
Front-Cover Texts being list, and with the Back-Cover Texts being list.
A copy of the license is included in the section entitled "GNU
Free Documentation License."

If you have no Invariant Sections, write “with no Invariant Sections” instead of saying which ones are invariant. If you have no Front-Cover Texts, write “no Front-Cover Texts” instead of “Front-Cover Texts being list”; likewise for Back-Cover Texts.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

Command Index
Jump to:   !   #  
A   B   C   D   E   F   H   I   K   L   N   P   Q   R   S   T   U   V   W   X  
Index Entry Section

!
!! (shell)4.11 Running Arbitrary BASH and Shell commands (‘eval’, ‘shell’)
![-]n (history)4.14.14 Command history (‘H’, ‘history’, ‘!’)

#
# (a comment)4.1 Command syntax

A
alias name command4.14.1 Debugger Command Aliases (‘alias’)

B
b (break)4.4.1.1 Setting breakpoints (‘break’ ‘tbreak’)
backtrace4.5.2 Backtraces (‘where’)
break4.4.1.1 Setting breakpoints (‘break’ ‘tbreak’)
bt (backtrace)4.5.2 Backtraces (‘where’)

C
c (continue)4.4.2.5 Continue (‘continue’)
cd [directory]4.12 Interfacing to the OS (‘cd’, ‘pwd’)
clear4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)
commands4.4.1.3 Breakpoint command lists (‘commands’)
condition4.4.1.6 Break conditions (‘condition’)
continue4.4.2.5 Continue (‘continue’)

D
d (clear)4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)
de (delete)4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)
debug4.4.2.6 Debug (‘debug’)
delete4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)
delete display4.10 Automatic display (‘display’, ‘undisplay’)
dis (disable)4.4.1.5 Disabling breakpoints (‘disable’, ‘enable’)
disable4.4.1.5 Disabling breakpoints (‘disable’, ‘enable’)
disable breakpoints4.4.1.5 Disabling breakpoints (‘disable’, ‘enable’)
disable display4.10 Automatic display (‘display’, ‘undisplay’)
display4.10 Automatic display (‘display’, ‘undisplay’)
do (down)4.5.3 Selecting a frame (‘up’, ‘down’, ‘frame’)
down4.5.3 Selecting a frame (‘up’, ‘down’, ‘frame’)

E
e (eval)4.11 Running Arbitrary BASH and Shell commands (‘eval’, ‘shell’)
edit [line-specification]4.7 Editing Source files (‘edit’)
enable4.4.1.5 Disabling breakpoints (‘disable’, ‘enable’)
enable breakpoints4.4.1.5 Disabling breakpoints (‘disable’, ‘enable’)
enable display4.10 Automatic display (‘display’, ‘undisplay’)
end4.4.1.3 Breakpoint command lists (‘commands’)
eval4.11 Running Arbitrary BASH and Shell commands (‘eval’, ‘shell’)
examine4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)

F
file4.14.7 Specifying a Script-File Association (‘file’)
finish4.4.2.3 Finish (‘finish’)
forward4.8 Searching source files (‘search’, ‘reverse’, ‘/.../’, ‘?..?’)
frame4.5.3 Selecting a frame (‘up’, ‘down’, ‘frame’)

H
h (help)4.2 Getting help (‘help’)
H [start-number [end-number]]4.14.14 Command history (‘H’, ‘history’, ‘!’)
handle4.4.3.1 Intercepting Signals (‘handle’, ‘info handle’)
history [-][n]4.14.14 Command history (‘H’, ‘history’, ‘!’)

I
i (info)4.2 Getting help (‘help’)
info4.2 Getting help (‘help’)
info args4.13.1 Showing information about the program being debugged (‘info’)
info breakpoints4.4.1.1 Setting breakpoints (‘break’ ‘tbreak’)
info breakpoints4.13.1 Showing information about the program being debugged (‘info’)
info display4.10 Automatic display (‘display’, ‘undisplay’)
info display4.13.1 Showing information about the program being debugged (‘info’)
info files4.13.1 Showing information about the program being debugged (‘info’)
info functions4.13.1 Showing information about the program being debugged (‘info’)
info line4.13.1 Showing information about the program being debugged (‘info’)
info program4.13.1 Showing information about the program being debugged (‘info’)
info signals4.4.3.1 Intercepting Signals (‘handle’, ‘info handle’)
info signals4.13.1 Showing information about the program being debugged (‘info’)
info source4.13.1 Showing information about the program being debugged (‘info’)
info stack4.13.1 Showing information about the program being debugged (‘info’)
info terminal3.4 Your script’s input and output
info terminal4.13.1 Showing information about the program being debugged (‘info’)
info variables4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)
info variables4.13.1 Showing information about the program being debugged (‘info’)

K
k (kill)4.3 Quitting the BASH debugger (‘quit’, ‘kill’)

L
l (list)4.6 Examining Source Files (‘list’)
list4.6 Examining Source Files (‘list’)

N
n (next)4.4.2.2 Next (‘next’)
next4.4.2.2 Next (‘next’)

P
p (print)4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)
print4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)
print4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)
pwd4.12 Interfacing to the OS (‘cd’, ‘pwd’)

Q
q (quit)4.3 Quitting the BASH debugger (‘quit’, ‘kill’)
quit [expression [subshell-levels]]4.3 Quitting the BASH debugger (‘quit’, ‘kill’)

R
R (restart)3.1 Starting your script
restart [args]3.1 Starting your script
RET (repeat last command)4.1 Command syntax
return4.4.2.7 Returning from a function, sourced file, or subshell (‘return’)
reverse-search4.8 Searching source files (‘search’, ‘reverse’, ‘/.../’, ‘?..?’)
run (restart)3.1 Starting your script

S
s (step)4.4.2.1 Step (‘step’)
search4.8 Searching source files (‘search’, ‘reverse’, ‘/.../’, ‘?..?’)
set annotate4.14.2 Annotation Level (‘set annotate’)
set args3.3 Your script’s arguments
set autoeval [ on | 1 | off | 0 ]4.14.3 Set/Show auto-eval (‘set autoeval’)
set autolist [ on | 1 | off | 0 ]4.14.4 Set/Show listing on stop (‘set autolist’)
set basename4.14.5 File basename (‘set basename’)
set debugger4.14.6 Allow Debugging the debugger (‘set debugger’)
set editing4.14.11 Command editing (‘set editing’, ‘show editing’)
set history save4.14.14 Command history (‘H’, ‘history’, ‘!’)
set history size4.14.14 Command history (‘H’, ‘history’, ‘!’)
set linetrace4.14.8 Show position information as statements are executed (‘set linetrace’)
set listsize4.6 Examining Source Files (‘list’)
set logging4.14.9 Logging output (‘set logging’, ‘set logging file’...)
set prompt4.14.10 Prompt (‘set prompt’, ‘show prompt’)
set showcommand4.14.13 Command Display (‘set showcommand’)
set trace-commands4.14.12 Debugger Commands Tracing (‘set trace-commands’, ‘show trace-commands’)
shell (shell)4.11 Running Arbitrary BASH and Shell commands (‘eval’, ‘shell’)
show args3.3 Your script’s arguments
show autoeval4.14.3 Set/Show auto-eval (‘set autoeval’)
show copying4.13.2 Show information about the debugger (‘show’)
show editing4.14.11 Command editing (‘set editing’, ‘show editing’)
show history4.14.14 Command history (‘H’, ‘history’, ‘!’)
show listsize4.6 Examining Source Files (‘list’)
show prompt4.14.10 Prompt (‘set prompt’, ‘show prompt’)
show version4.13.2 Show information about the debugger (‘show’)
show warranty4.13.2 Show information about the debugger (‘show’)
shows4.14.14 Command history (‘H’, ‘history’, ‘!’)
signal4.4.3.2 Sending your program a signal (‘signal’)
silent4.4.1.3 Breakpoint command lists (‘commands’)
skip4.4.2.4 Skip (‘skip’)
source3.2 Command files
step4.4.2.1 Step (‘step’)

T
tbreak4.4.1.1 Setting breakpoints (‘break’ ‘tbreak’)
tty3.4 Your script’s input and output

U
unalias name command4.14.1 Debugger Command Aliases (‘alias’)
undisplay dnums4.10 Automatic display (‘display’, ‘undisplay’)
up [n]4.5.3 Selecting a frame (‘up’, ‘down’, ‘frame’)

V
V (info variables)4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)

W
watch4.4.1.2 Setting watchpoints (‘watch’, ‘watche’)
where4.5.2 Backtraces (‘where’)

X
x (examine)4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)

Jump to:   !   #  
A   B   C   D   E   F   H   I   K   L   N   P   Q   R   S   T   U   V   W   X  
General Index
Jump to:   $   -   .  
A   B   C   D   E   F   H   I   L   N   O   P   R   S   T   V   W  
Index Entry Section

$
$PS41.2 Interactive Line Tracing Session
$_ and info breakpoints4.4.1.1 Setting breakpoints (‘break’ ‘tbreak’)

-
--annotate2.1.1 Command-line options for bashdb script
--basename2.1.1 Command-line options for bashdb script
--command2.1.1 Command-line options for bashdb script
--eval-command cmdfile2.1.1 Command-line options for bashdb script
--help2.1.1 Command-line options for bashdb script
--library2.1.1 Command-line options for bashdb script
--no-init2.1.1 Command-line options for bashdb script
--nx2.1.1 Command-line options for bashdb script
--quiet2.1.1 Command-line options for bashdb script
--tempdir2.1.1 Command-line options for bashdb script
--terminal2.1.1 Command-line options for bashdb script
--tty2.1.1 Command-line options for bashdb script
-A2.1.1 Command-line options for bashdb script
-B2.1.1 Command-line options for bashdb script
-c2.1.1 Command-line options for bashdb script
-h2.1.1 Command-line options for bashdb script
-L2.1.1 Command-line options for bashdb script
-n2.1.1 Command-line options for bashdb script
-q2.1.1 Command-line options for bashdb script
-T2.1.1 Command-line options for bashdb script
-t2.1.1 Command-line options for bashdb script
-V2.1.1 Command-line options for bashdb script
-x2.1.1 Command-line options for bashdb script

.
.bashdbinit3.2 Command files

A
arguments (to your script)3.3 Your script’s arguments
automatic display4.10 Automatic display (‘display’, ‘undisplay’)

B
backtraces4.5.2 Backtraces (‘where’)
BASH debugger bugs, reporting5.2 How to report bugs
bashdb.ini3.2 Command files
breakpoint conditions4.4.1.6 Break conditions (‘condition’)
breakpoint numbers4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)
breakpoint on variable modification4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)
breakpoints4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)
bug criteria5.1 Have you found a bug?
bug reports5.2 How to report bugs
bugs5. Reporting Bugs

C
call stack4.5 Examining the Stack Frame (‘where’, ‘frame’, ‘up’, ‘down’)
change working directory4.12 Interfacing to the OS (‘cd’, ‘pwd’)
clearing breakpoints, watchpoints4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)
command files3.2 Command files
command line editing4.14.11 Command editing (‘set editing’, ‘show editing’)
command scripts, debugging4.14.12 Debugger Commands Tracing (‘set trace-commands’, ‘show trace-commands’)
comment4.1 Command syntax
conditional breakpoints4.4.1.6 Break conditions (‘condition’)
continuing4.4.2 Resuming Execution (‘step’, ‘next’, ‘finish’, ‘skip’, ‘continue’, ‘debug’, ‘return’)
controlling terminal3.4 Your script’s input and output
crash of debugger5.1 Have you found a bug?
current stack frame4.5.3 Selecting a frame (‘up’, ‘down’, ‘frame’)

D
debugger crash5.1 Have you found a bug?
delete breakpoints4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)
deleting breakpoints, watchpoints4.4.1.4 Deleting breakpoints (‘clear’, ‘delete’)
display of expressions4.10 Automatic display (‘display’, ‘undisplay’)

E
editing4.14.11 Command editing (‘set editing’, ‘show editing’)
error on valid input5.1 Have you found a bug?
examining data4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)

F
fatal signal5.1 Have you found a bug?
fatal signals4.4.3 Signals (‘handle’, ‘info handle’, ‘signal’)
frame number4.5.1 Stack frames
frame, definition4.5.1 Stack frames

H
handling signals4.4.3 Signals (‘handle’, ‘info handle’, ‘signal’)
history save4.14.14 Command history (‘H’, ‘history’, ‘!’)
history size4.14.14 Command history (‘H’, ‘history’, ‘!’)

I
I/O3.4 Your script’s input and output
init file3.2 Command files
init file name3.2 Command files
initial frame4.5.1 Stack frames
innermost frame4.5.1 Stack frames
interrupt2.2 Quitting the BASH debugger
invalid input5.1 Have you found a bug?

L
latest breakpoint4.4.1.1 Setting breakpoints (‘break’ ‘tbreak’)
linespec4.6 Examining Source Files (‘list’)

N
nested shell4.11 Running Arbitrary BASH and Shell commands (‘eval’, ‘shell’)
numbers for breakpoints4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)
numbers for watchpoints4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)

O
one-time breakpoints4.4.1.6 Break conditions (‘condition’)
online documentation4.2 Getting help (‘help’)
outermost frame4.5.1 Stack frames

P
print working directory4.12 Interfacing to the OS (‘cd’, ‘pwd’)
printing data4.9 Examining Data (‘print’, ‘examine’, ‘info variables’)
prompt4.14.10 Prompt (‘set prompt’, ‘show prompt’)

R
readline4.14.11 Command editing (‘set editing’, ‘show editing’)
redirection3.4 Your script’s input and output
repeating next/step commands4.1 Command syntax
reporting bugs5. Reporting Bugs
resuming execution4.4.2 Resuming Execution (‘step’, ‘next’, ‘finish’, ‘skip’, ‘continue’, ‘debug’, ‘return’)
returning from a function, sourced file or subshell4.4.2.7 Returning from a function, sourced file, or subshell (‘return’)
running3.1 Starting your script

S
searching4.8 Searching source files (‘search’, ‘reverse’, ‘/.../’, ‘?..?’)
selected frame4.5 Examining the Stack Frame (‘where’, ‘frame’, ‘up’, ‘down’)
setting watchpoints4.4.1.2 Setting watchpoints (‘watch’, ‘watche’)
shell escape4.11 Running Arbitrary BASH and Shell commands (‘eval’, ‘shell’)
signals4.4.3 Signals (‘handle’, ‘info handle’, ‘signal’)
stack frame4.5.1 Stack frames
stack traces4.5.2 Backtraces (‘where’)
starting3.1 Starting your script
stepping4.4.2 Resuming Execution (‘step’, ‘next’, ‘finish’, ‘skip’, ‘continue’, ‘debug’, ‘return’)

T
terminal3.4 Your script’s input and output
tracebacks4.5.2 Backtraces (‘where’)
tracing debugger commands4.14.12 Debugger Commands Tracing (‘set trace-commands’, ‘show trace-commands’)

V
version number4.13.2 Show information about the debugger (‘show’)

W
watchpoints4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)
watchpoints numbers4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)

Jump to:   $   -   .  
A   B   C   D   E   F   H   I   L   N   O   P   R   S   T   V   W  
Footnotes

(1)

Recall that variables in BASH don’t need to be declared before they are referred to and that the default value would be the a null value which here prints as an empty string.

(2)

And in the interest of full disclosure, although this was not shown in the example it is possible to add the -- after the script name to be debugged but before the first program option with a dash.

(3)

The DJGPP port of the BASH debugger uses the name ‘bashdb.ini’ instead, due to the limitations of file names imposed by DOS filesystems.

(4)

On DOS/Windows systems, the home directory is the one pointed to by the HOME environment variable.


Table of Contents

About This Document
This document was generated by r on November 29, 2011 using texi2html 1.82.
Source, copyright etc.
That html document was used as source for this outline.  It was retrieved from:
http://bashdb.sf.net/bashdb.html

The outline content is Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Rocky Bernstein

The outlining code is (c) Rod Smith, and is licensed under GPL/MIT licenses.
Creation of this outline format
Prerequisites
  • Original 'flat' source html
    • Most of the pre-processing in this section relates to the html format that texinfo generates
  • Online outline editor -- at rodericksmith.dyndns.org
  • Firefox browser -- search google 'Firefox' for the latest download
Starting from scratch
I was not able to reconstitute the tree from the previous html outline.  Instead I started from the newest source html. (The grey tables that make the outline prettier can't always be distinguished from other tables in the document, so they can't be removed easily without damaging the remainder of the document)
Check as you go
I used the following procedure, previewing the outline and verifying its operation at several points en route, and also checking with the bash function (directly below) that anchors for links had not been lost.
Link validation code (linux)
Check that local links have corresponding anchors, e.g. by using this Bash code:

# ckrefs <filename.html> checks the file for missing local links
# Quick & dirty, doesn't eliminate all the dross -- watch the output!
#
# Put one HTML tag per line
#
 function tagPerLine() { tr "\n" " " <$1 | sed 's/>/>\n/g'|sed 's/</\n</g' | grep  "^<.*>$" ;}
#
# Extract all the anchor names to stream
#
 function names() { tagPerLine $1 |grep name= | sed 's/^.*name=\"//'|sed 's/\".*//' |sort -u ; }
#
# Extract all the link names to stream
#
 function hrefs() { tagPerLine $1 |grep href= | sed 's/^.*href=\"#//'|sed 's/\".*//' |sort -u ; }
#
# Populate anchors file and links file; find links that don't have anchors
#
 function ckrefs() { names $1 >tmp1;hrefs $1>tmp2; comm -13 tmp1 tmp2 ; }
 
Copy-paste these functions to a terminal, then use:

ckrefs <HTML outline under test>
Load the HTML into the editor
Load the flat source document into a browser page, and display the html by pressing CTRL-U.  Select all (CTRL-A), copy (CTRL-C).

Load an empty outline into the webTreeEditor in another browser pane, press the HTML button in the middle pane to display a HTML-text version of that middle rich-text editor region. 

Paste the html into that HTML code box.  Then click in  the (empty) rich text region to have it rendered there.

(The step of loading HTML text is needed, since links weren't loading the href component directly into the richtext box for some reason.)
Links in the footnote headings
Prior to separating into nodes, the hrefs links embedded in headings must be removed -- they occur in the footnotes section.

Scroll to the Footnotes section near the end of the rich-text document.

Select the footnotes text (1) through (4), and then select from Font Block then Normal.  That'll remove the heading codes from the footnote numbering, that would otherwise cause incorrect operation of the outline.
Convert headings to nodes
Convert the headed format in the rich text box to nodes in the tree clipboard by tools, Head>nodes.  Selected 'convert to divs?' 'OK' option when prompted. 

The generated nodes are left in the tree clipboard -- paste it to the tree (select a tree node, and press capital-V), and then drag-drop the second level nodes to the top level.  When satisfactory,  remove the original node that contained the full non-node text.
Eliminate redundant navigation panels
I've observed that the pre-outline navigation sections start either with a menu section or with a horizontal rule.

Each section includes a list of the subsequent sub-sections, useful in non-outlined html, but duplicated in outline mode.  Hence, these link sections have been removed. (with some care in the coding to avoid removing any anchor points, since that would disable eg many of the links needed elsewhere in the manual).

These sections in each node start (  <table class="menu"  ) and continue through to the end of each node.  The following three lines can be pasted in turn into the 'search regular expression' box of the outline editor, in each case prior to selecting tools, walkedit,g to apply the search-replacement to each node in turn.
  • \<table class\=\"menu\"[\s\S]*?\</table>
  • <hr size="6">
  • <table border="0" cellpadding="1" cellspacing="1">[\s]*?<tbody><tr><td align="left" valign="middle">[<a title="Previous section in reading order">[\s\S]*?</table>
in all three cases with empty replacement text.

The keys [\s\S] are a regular expression match to any character including newline, whereas (in JavaScript Regular Expressions) the . character doesn't match newline. Walkedit performs the edit on each richeditor node in turn.  The string *? is a general regular expression that is not 'greedy' - ie it matches the first occurrence of subsequent search strings rather than the last.

Remove also the navigation explanations no longer applicable to outline mode in 'About This Document'
Attributions, anchors etc.
Copy-paste the non-printing attributions, anchors etc. manually from the 'main' folder into the top of the initial node to preserve their position.
Suggestions on format
You might consider splitting some of the longer sections; e.g. 4.2 would readily split into three sections

Sections like 1.1 are more difficult to split on topic grounds, but the table entries there could be made nodes even if given a nondescript title like 'output' or something.

Generally my aim is to make a node about a screenful, so the user can see a bit of the context of headings witout having to scroll too far.
New to the outliner since 2010
Outline skin -- which provides the browsing interface
  • Show/hide all -- click the top right-hand asterisk.
  • Find text -- show all, then use browser's find
  • Geek modes --
    • ctrl-shift asterisk extracts <pre>-formatted text into a text box (for synchronizing documentation with code).
    • ctrl asterisk prompts for jquery/javascript command
    • shift asterisk places HTML body without grey decoration boxes, into a text box, for post-disaster (partial) recovery of an otherwise lost outline.

Outline editor -- which constructs the outline

  • Stores outline source as a javascript object notation (JSON) 'huge' text record.
  • Three storage modes are available --
    • Storage via clipboard to a text editor
    • Storage in your own browser's localStore
    • Storage in a server's mysql database
  • Menu-driven options available - more user-friendly
  • Primary creation mode for html web page is Firefox browser preview, then save-as web page.
  • New tools help conversion from html, pdf etc
  • Moved from jslinb's site to rodericksmith.dyndns.org (server link to my office).  Guest login is available.
  • Multi-user precaution -- prompts if the record's timestamp has changed since loading
  • User-specific permissions for databases and tables storing outlines

Bashdb specific

  • Navigation duplication removed
  • Links in headings fixed in the footnotes
  • Update to 4.2-0.6 Edition, 7 December 2010
[Click text above to activate outline file]

*