BASH Debugger"> BASH Debugger">
[Top] | [Contents] | [Index] | [ ? ] |
This file describes the BASH debugger, the BASH symbolic debugger.
This is the 2.05b rebash-0.43 Edition, April 2002, for REBASH.
Copyright (C) 2002,2003 Rocky Bernstein
1. Summary of the BASH Debugger | Overview of Debugger with a sample session | |
2. Getting in and out | ||
3. Script Setup inside the BASH Debugger | Script setup inside the BASH debugger | |
4. BASH Debugger Command Reference | BASH debugger command reference | |
5. Using the BASH debugger from a front-end user interface | ||
6. Reporting Bugs | Reporting bugs | |
7. History and Acknowledgments | ||
Appendices | ||
A. Formatting Documentation | How to format and print the BASH debugger documentation | |
B. Installing the BASH debugger | Installing bashdb | |
C. GNU GENERAL PUBLIC LICENSE | GNU General Public License says how you can copy and share bashdb | |
D. GNU Free Documentation License | The license for this documentation | |
Indexes (nodes containing large menus) | ||
Function Index | An item for each function name. | |
Command Index | An item for each command name. | |
Variable Index | An item for each documented variable. | |
General Index | An item for each concept. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
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 | A Sample BASH Debugger session | |
Free software | Freely redistributable software |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 . fact.sh Bourne-Again Shell Debugger, release bash-2.05b-rebash-0.43 Copyright 2002,2003 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. (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: return $result 7: } 8: 9:==> echo fact 0 is: `fact 0` bashdb<1> l 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 fact.sh
.
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 starting 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 (fact.sh:9): 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 |
Ooops... The variable n isn't initialized.
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--the function call.
The first step command steps the script one instruction; it
didn't advance the line number 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 (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: return $result 8: } 9: 10:==> echo fact 0 is: `fact 0` bashdb<1> s 3 (fact.sh:3): 3: local -i n=${1:0} bashdb<2> step (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 steps
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 (fact.sh:4): 4: ((n==0)) && echo 1 && return echo 1 bashdb<5> RET (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 (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.
(fact.sh:5): 5: ((nm1=n-1)) Breakpoint 1 hit(1 times). bashdb<8> x n-1 2 bashdb<9> s (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 (fact.sh:5): 5: ((nm1=n-1)) bashdb<2> s 6: ((fact_nm1=`fact $nm1`)) bashdb<2> s 2: fact() { bashdb<3> 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<4> 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 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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
the BASH debugger is free software, protected by the GNU General Public License (GPL). The GPL gives you the freedom to copy or adapt a licensed program--but every person getting a copy also gets with it the freedom to modify that copy (which means that they must get access to the source code), and the freedom to distribute further copies. Typical software companies use copyrights to limit your freedoms; the Free Software Foundation uses the GPL to preserve these freedoms.
Fundamentally, the General Public License is a license which says that you have these freedoms and that you cannot take these freedoms away from anyone else.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The biggest deficiency in the free software community today is not in the software--it is the lack of good free documentation that we can include with the free software. Many of our most important programs do not come with free reference manuals and free introductory texts. Documentation is an essential part of any software package; when an important free software package does not come with a free manual and a free tutorial, that is a major gap. We have many such gaps today.
Consider Perl, for instance. The tutorial manuals that people normally use are non-free. How did this come about? Because the authors of those manuals published them with restrictive terms--no copying, no modification, source files not available--which exclude them from the free software world.
That wasn't the first time this sort of thing happened, and it was far from the last. Many times we have heard a GNU user eagerly describe a manual that he is writing, his intended contribution to the community, only to learn that he had ruined everything by signing a publication contract to make it non-free.
Free documentation, like free software, is a matter of freedom, not price. The problem with the non-free manual is not that publishers charge a price for printed copies--that in itself is fine. (The Free Software Foundation sells printed copies of manuals, too.) The problem is the restrictions on the use of the manual. Free manuals are available in source code form, and give you permission to copy and modify. Non-free manuals do not allow this.
The criteria of freedom for a free manual are roughly the same as for free software. Redistribution (including the normal kinds of commercial redistribution) must be permitted, so that the manual can accompany every copy of the program, both on-line and on paper.
Permission for modification of the technical content is crucial too. When people modify the software, adding or changing features, if they are conscientious they will change the manual too--so they can provide accurate and clear documentation for the modified program. A manual that leaves you no choice but to write a new manual to document a changed version of the program is not really available to our community.
Some kinds of limits on the way modification is handled are acceptable. For example, requirements to preserve the original author's copyright notice, the distribution terms, or the list of authors, are ok. It is also no problem to require modified versions to include notice that they were modified. Even entire sections that may not be deleted or changed are acceptable, as long as they deal with nontechnical topics (like this one). These kinds of restrictions are acceptable because they don't obstruct the community's normal use of the manual.
However, it must be possible to modify all the technical content of the manual, and then distribute the result in all the usual media, through all the usual channels. Otherwise, the restrictions obstruct the use of the manual, it is not free, and we need another manual to replace it.
Please spread the word about this issue. Our community continues to lose manuals to proprietary publishing. If we spread the word that free software needs free reference manuals and free tutorials, perhaps the next person who wants to contribute by writing documentation will realize, before it is too late, that only free manuals contribute to the free software community.
If you are writing documentation, please insist on publishing it under the GNU Free Documentation License or another free documentation license. Remember that this decision requires your approval--you don't have to let the publisher decide. Some commercial publishers will use a free license if you insist, but they will not propose the option; it is up to you to raise the issue and say firmly that this is what you want. If the publisher you are dealing with refuses, please try other publishers. If you're not sure whether a proposed license is free, write to licensing@gnu.org.
You can encourage commercial publishers to sell more free, copylefted manuals and tutorials by buying them, and particularly by buying copies from the publishers that paid for their writing or for major improvements. Meanwhile, try to avoid buying non-free documentation at all. Check the distribution terms of a manual before you buy it, and insist that whoever seeks your business must respect your freedom. Check the history of the book, and try to reward the publishers that have paid or pay the authors to work on it.
The Free Software Foundation maintains a list of free documentation published by other publishers, at http://www.fsf.org/doc/other-free-books.html.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter discusses how to start the BASH debugger, and how to get out of it. The essentials are:
But also note there are two front-ends available as well. One can also
enter the debugger inside emacs via the command M-x bashdb
after loading Emacs' Grand Unified Debugger, gud
. See
Using the BASH debugger from GNU Emacs. And there is
support in a DDD for bash.
2.1 Starting the BASH debugger | How to enter the BASH debugger | |
2.2 Quitting the BASH debugger | How to leave the BASH debugger |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Note: it is important to use a debugger-enabled bash. You wil 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. By default, both debugging in Emacs via GUD (Using the BASH debugger under Emacs) and debugging via DDD work via this method.
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
after taking its own options takes the name of the script to debugged
and the arguments to pass to that script. Using this method, one
would start the debugger like this:
bash path-to-bashdb/bashdb bashdb-options script script-arguments... |
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 | Options you can pass in starting bashdb |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bashdb
script You can run the BASH debugger in various alternative modes--for example, in batch mode or quiet mode.
-h
-V
-n
-q
-t
-L directory
../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 directory
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.1 Starting your script | ||
3.2 Command files | ||
3.3 Your script's arguments | ||
3.4 Your script's input and output | ||
3.5 Script/Debugger Interaction | Keeping out of each other's harm |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
restart [options to debugged script]
run
R
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 porgram; so if your program changes some or all of
these numbers may be off. Environment variable
BASHDB_RESTART_FILE
is and a temporary file are used to signal
a restart, so you shouldn't uset BASHDB_RESTART_FILE
(or any
environment variable starting with BASHDB_
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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'(1). During startup, the BASH debugger does the following:
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
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The arguments to your script can be specified by the arguments of the
restart
command.
They are passed to a shell, which expands wildcard 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
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
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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) and 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 the BASH debugger environment variables are also reserved for
use; these start with BASHDB_
. For example:
BASHDB_INPUT
, BASHDB_LEVEL
and,
BASHDB_QUIT_ON_QUIT
(see section Debug),
BASHDB_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.
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
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
o rstep
commands by typing
just RET. Some commands which require a parameter, such as
print
remember the argument that was given to them.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Once inside the BASH debugger, you can always ask it for information on its
commands, using the command help
.
help
h
help
(abbreviated h
) with no arguments to
display a short list of named classes of commands:
bashdb<0> help bashdb commands: List/search source lines: Control script execution: ------------------------- ------------------------- l [start|.] [cnt] List cnt lines T [n] Stack trace from line start s [n] Single step [n times] l sub List source code fn n [n] Next, steps over subs - or . List previous/current line <CR>/<Enter> Repeat last n or s w [line] List around line c [linespec] Continue [to linespec] f filename View source in file L List all breakpoints /pat/ Search forward for pat b linespec Set breakpoint ?pat? Search backward for pat del [n].. or D Delete a/all breaks by entry number Debugger controls: skip skip execution of cmd ------------------------- cl linespec Delete breakpoints by H [num] Show last num commands line spec q [exp] or ^D Quit returning exp R [args] Attempt a restart info [cmd] Get info on cmd. u [n] Go up stack by n or 1. !n or hi n Run debugger history n do [n] Go down stack by n or 1. h or ? [cmd] Get help on command W [var] Add watchpoint. If no info [cmd] Get info on cmd no expr, delete all show [cmd] Show settings We [expr] Add Watchpoint arith expr so file read in dbg commands t Toggle trace en/di n enable/disable brkpt, set x y set a debugger variable watchpoint, or display e bash-cmd evaluate a bash command tb linespec Add one-time break disp expr add a display expr a linespec cmd eval "cmd" at linespec M Show module versions A delete all actions x expr evaluate expression ret jump out of fn or source (via declare, let, eval) finish execute until return deb debug into another cond n exp set breakpoint condition shell script !! cmd [args] execute shell command "cmd" with "args" Data Examination: also see e, t, x ------------------------- p variable Print variable V [[!]pat] List variable(s) matching or not (!) matching pattern pat S [[!]pat] List subroutine names [not] matching pattern pat Readline command line editing (emacs/vi mode) is available For more help, type h <cmd> or consult online-documentation. |
help command
help
argument, the BASH debugger displays
short information on how to use that command.
bashdb<0> help list l linespec List window lines starting at linespec. l min incr List incr lines starting at 'min' linespec. l List next window of lines. l . Same as above. Long command name: list. |
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
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> info Info subcommands are: args breakpoints display files source sources stack terminal variables watchpoints bashdb<1> info source Current script file is parm.sh Contains 34 lines. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 assingment
statement or condition test.
If the environment variable BASHDB_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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 accidently 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 | Breakpoints, watchpoints (break, watch, clear) | |
4.4.2 Resuming Execution | Resuming execution (continue, step, next, skip, debug) | |
4.4.3 Signals |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 can set breakpoints with the break
command and its variants
(see section Setting breakpoints), to specify the place where
your script should stop by line number. or function name in the
debugged script.
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 and watchpoint 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 distiguished 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') | Setting breakpoints (break, tbreak) | |
4.4.1.2 Setting watchpoints (`watch', `watche') | Setting watchpoints (watch, watche) | |
4.4.1.3 Deleting breakpoints (`clear', `delete') | Deleting breakpoints (delete, clear) | |
4.4.1.4 Disabling breakpoints (`disable', `enable') | Disabling breakpoints (disable, enable) | |
4.4.1.5 Break conditions (`condition') | Break conditions (condition) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Breakpoints are set with the break
command (abbreviated
b
).
break function
break linenum
break filename:linenum
break ... if cond
let
builtin funtion.
`...' 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
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]
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).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 idiosyncracies 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
watche expr
watch
described
earlier.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It is often necessary 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
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
clear linenum
d linenum
delete [breakpoints]
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
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
break
command starts out in this state.
tbreak
command starts out in this state.
You can use the following commands to enable or disable breakpoints, watchpoints, and catchpoints:
disable [breakpoints]
disable
as dis
.
enable [breakpoints]
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.)
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
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.
Break conditions can be specified when a breakpoint is set, by using
`if' in the arguments to the break
command. See section Setting breakpoints. They can also be changed at any time
with the condition
command.
condition bnum expression
condition bnum
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. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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') | running the next statement (step) | |
4.4.2.2 Next (`next') | running the next statement skipping over functions (skip) | |
4.4.2.3 Finish (`finish') | running until the return of a function or "source" (finish) | |
4.4.2.4 Skip (`skip') | skipping the next statement (skip) | |
4.4.2.5 Continue (`continue') | continuing execution (continue) | |
4.4.2.6 Debug (`debug') | debugging into another program (debug) | |
4.4.2.7 Returning from a function, sourced file, or subshell (`return') | returning |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
step
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.
step [count]
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
next [count]
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
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
finish
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).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
skip [count]
debug
command internally uses the skip
command
to skip over existing non-debugged invocation that was presumably just
run.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
continue [linespec]
c [line-number]
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.
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
debug [script-name]
The nesting level of the debugger is saved inside environment variable
BASHDB_LEVEL
. The debugger prompt indicates the level of nesting
by enclosing the history in that many nestings of <>
symbols.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
return
return
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 currenlty
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 behaviour
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 particluar $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.
info signals
info handle
info handle
is an alias for info signals
.
handle signal keywords...
The keywords allowed by the handle
command can be abbreviated.
Their full names are:
stop
print
keyword as well.
nostop
print
noprint
stack
nostack
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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; this
manual introduces 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.
info
i
) is for describing the state of
your program. For example, you canlist 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
.
set
set
. For example, you can set the number of lines
BASH will list by default to 20 with set listsize 20
.
show
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. For example, to list the arguments given to your script use
show args
; info args
does something different.
To display all the settable parameters and their current
values, you can use show
with no arguments; you may also use
info set
. Both commands produce the same display.
Here are three miscellaneous show
subcommands, all of which are
exceptional in lacking corresponding set
commands:
show version
show copying
show warranty
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.6.1 Stack frames | ||
4.6.2 Backtraces (`where') | Backtraces (where) | |
4.6.3 Selecting a frame (`up', `down', `frame') | Selecting a frame (up, down, frame) | |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 and 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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 sare stopped at (frame zero), followed by its caller (frame one), and on up the stack.
backtrace
bt
where
T
backtrace n
bt n
where n
T n
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 2.05b-rebash-0.43 Copyright 2002,2003 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
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
down n
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
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. Without an argument, frame
prints the
current stack frame.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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; see Using the BASH debugger under GNU Emacs.
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
list function
l function
list
l
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 -
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
list
command display count source lines (unless
the list
argument explicitly specifies some other number).
show listsize
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
list first increment
list first
list -
list .
list
Here are the ways of specifying a single source line--all the kinds of linespec.
number
list
command has two linespecs, this refers to
the same source file as the first linespec.
filename:number
function
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are two commands for searching through the current source file for a BASH extended pattern-matching expression.
forward bash-pattern
search bash-pattern
fo
or /pat/
.
reverse bash-pattern
rev
or ?bash-pattern?
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 dispay 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.
print
p
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 single variable. If
it is, the definition and value are 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' show
the definition of foo with value 5, and `x foo+5' prints 10 as
expected. So far so good. However if foo
is has value
"string", `x foo+5' prints 5 because let
has turned the
string into 0; `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.
V [!][pattern]
If you want to all list variables and there values or a set of variables by pattern, use this command.
bashdb<0> V dq* dq_args="dq_*" dq_cmd="V" |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The two most general commands and most "low-level" are eval
and shell
.
eval
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"'.
shell 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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
undisplay dnums...
delete display dnums...
undisplay
does not repeat if you press RET after using it.
(Otherwise you would just get the error `No display number ...'.)
disable display dnums...
enable display dnums...
display
info display
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can alter the way BASH interacts with you by using the
set
command.
4.12.1 Annotation Level (`set annoatate') | Annotation Level (set annotate) | |
4.12.2 Prompt (`set prompt', `show prompt') | Prompt (set prompt, show prompt) | |
4.12.3 Command editing (`set editing', `show editing') | Command editing (set editing, show editing) | |
4.12.4 Command Display (`set showcommand') | Command display (set showcommand) | |
4.12.5 Command history (`H', `history', `!') | Command history (history, !, H) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The annotation level controls how much information does the BASH debugger print together with its prompt, values of expressions, source lines, and other types of output. 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 .
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
Warning: changing the prompt can DDD's ability to understand when the debugger is waiting for input.
show prompt
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
set editing off
show editing
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 assignemnt 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 | off ]
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 nevers 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 |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 ths 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 begining (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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are two front-ends available that can use the BASH debugger as a back-end debugger are GNU Emacs and DDD.
5.1 Using the BASH debugger from GNU Emacs | ||
5.2 Using the BASH debugger from DDD |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A special interface allows you to use GNU Emacs to view (and edit) the source files for the program you are debugging with the BASH debugger.
To use this interface, use the command M-x bashdb in Emacs. Give the executable file you want to debug as an argument. This command starts the BASH debugger as a subprocess of Emacs, with input and output through a newly created Emacs buffer.
Using the BASH debugger under Emacs is just like using the BASH debugger normally except for two things:
This applies both to the BASH debugger commands and their output, and to the input and output done by the program you are debugging.
This is useful because it means that you can copy the text of previous commands and input them again; you can even use parts of the output in this way.
All the facilities of Emacs' Shell mode are available for interacting with your script. In particular, you can send signals the usual way--for example, C-c C-c for an interrupt, C-c C-z for a stop.
Each time the BASH debugger displays a stack frame, Emacs automatically finds the source file for that frame and puts an arrow (`=>') at the left margin of the current line. Emacs uses a separate buffer for source display, and splits the screen to show both your the BASH debugger session and the source.
Explicit the BASH debugger list
or search commands still produce output as
usual, but you probably have no reason to use them from Emacs.
Warning: If the directory where your script resides is not your current directory, it can be easy to confuse Emacs about the location of the source files, in which case the auxiliary display buffer does not appear to show your source. the BASH debugger can find programs by searching your environment'sPATH
variable, so the the BASH debugger input and output session proceeds normally; but Emacs does not get enough information back from the BASH debugger to locate the source files in this situation. To avoid this problem, either start the BASH debugger mode from the directory where your script resides, or specify an absolute file name when prompted for the M-x gdb argument.A similar confusion can result if you use the the BASH debugger
file
command to switch to debugging a program in some other location, from an existing the BASH debugger buffer in Emacs.
By default, M-x bashdb calls the bash --debugger
. If you
need to call the BASH debugger by a different name (for example, if you
keep several configurations around, with different names) you can set
the Emacs variable gud-bashdb-command-name
; for example,
(setq gud-bashdb-command-name "bash-debugger") |
(preceded by M-: or ESC :, or typed in the *scratch*
buffer, or
in your `.emacs' file) makes Emacs call the program named
"bash-debugger
" instead.
In the the BASH debugger I/O buffer, you can use these special Emacs commands in addition to the standard Shell mode commands:
step
command; also
update the display window to show the current file and location.
next
command. Then update the display window
to show the current file and location.
finish
command.
continue
command.
Warning: In Emacs v19, this command is C-c C-p.
up
command.
Warning: In Emacs v19, this command is C-c C-u.
down
command.
Warning: In Emacs v19, this command is C-c C-d.
disassemble
by typing C-x &.
You can customize this further by defining elements of the list
gdb-print-command
; once it is defined, you can format or
otherwise process numbers picked up by C-x & before they are
inserted. A numeric argument to C-x & indicates that you
wish special formatting, and also acts as an index to pick an element of the
list. If the list element is a string, the number to be inserted is
formatted using the Emacs function format
; otherwise the number
is passed as an argument to the corresponding list element.
In any source file, the Emacs command C-x SPC (gud-break
)
tells the BASH debugger to set a breakpoint on the source line point is on.
If you accidentally delete the source-display buffer, an easy way to get
it back is to type the command frame
in the the BASH debugger buffer, to
request a frame display; when you run under Emacs, this recreates
the source buffer if necessary to show you the context of the current
frame.
The source files displayed in Emacs are in ordinary Emacs buffers which are visiting the source files in the usual way. You can edit the files with these buffers if you wish; but keep in mind that the BASH debugger communicates with Emacs in terms of line numbers. If you add or delete lines from the text, the line numbers that the BASH debugger knows cease to correspond properly with the code.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
the BASH debugger support is rather new in DDD. As a programming language, the BASH debugger is not feature rich: there are no record structures or hash tables (yet), no pointers, package variable scoping or methods. So much of the data display and visualization features of DDD are disabled.
As with any scripting or interpreted language (e.g. Perl), one can't step by a single machine-language instruction. So the ddd Stepi/Nexti commands are disabled.
Some BASH settings are essential for DDD to work correctly. These settings with their correct values are:
set annotate 1 set prompt set prompt bashdb$_Dbg_less$_Dbg_greater$_Dbg_space |
DDD sets these values automatically when invoking BASH; if these values are changed, there may be some malfunctions.
Pay special attention when the prompt has extra angle brackets (a nested shell) or has any parenthesis (is in a subshell). Quitting may merely exit out of one of these nested (sub)shells rather than leave the program.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
6.1 Have you found a bug? | ||
6.2 How to report bugs |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you are not sure whether you have found a bug, here are some guidelines:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Submit bug reports for the BASH debugger. Until better mechanism is set up the prefered method is to submit them directly using mailto:rocky@panix.com. There are also a bug tracking system and, help, developer and open discussion forums which can be found via http://http://sourceforge.net/forum/?group_id=37260.
Although this code shares a lot with BASH, the debugger is of course
not yet supported by the BASH team, so if there is a debugger problem
reporting it via bashbug or to bug-bash@gnu.org or posted to
the newsgroup gnu.bash.bug
probably won't help, unless you are
sure the bug resides in the vanilla bash code and and show that.
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:
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.
If we were to try to guess the arguments, we would probably guess wrong and then we might not encounter the bug.
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.
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:
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 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.
Such guesses are usually wrong. Even we cannot guess right about such things without first using the debugger to find the facts.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 stop when a subroutine or a sourced file 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 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 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 indrectly 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)
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Copyright © 1989, 1991 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. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 convey 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice |
This 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 Library General Public License instead of this License.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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. |
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.
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.
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.
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.
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.
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."
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.
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.
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.
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.
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | !
#
B C D E F H I L N P Q R S T U V W X |
---|
Jump to: | !
#
B C D E F H I L N P Q R S T U V W X |
---|
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | $
-
.
A B C D E F G H I L N O P R S T V W |
---|
Jump to: | $
-
.
A B C D E F G H I L N O P R S T V W |
---|
[Top] | [Contents] | [Index] | [ ? ] |
The DJGPP port of the BASH debugger uses the name `bashdb.ini' instead, due to the limitations of file names imposed by DOS filesystems.
On
DOS/Windows systems, the home directory is the one pointed to by the
HOME
environment variable.
[Top] | [Contents] | [Index] | [ ? ] |
1. Summary of the BASH Debugger
1.1 A Sample BASH Debugger Session2. Getting in and out
Free software
Free Software Needs Free Documentation
2.1 Starting the BASH debugger3. Script Setup inside the BASH Debugger
2.1.1 Command-line options for2.2 Quitting the BASH debuggerbashdb
script
3.1 Starting your script4. BASH Debugger Command Reference
3.2 Command files
3.3 Your script's arguments
3.4 Your script's input and output
3.5 Script/Debugger Interaction
4.1 Command syntax5. Using the BASH debugger from a front-end user interface
4.2 Getting help (`help')
4.3 Quitting the BASH debugger (`quit')
4.4 Stopping and Resuming Execution (`break', `watch', `step', `cont')
4.4.1 Breakpoints, watchpoints4.5 Status and Debugger Settings (`info', `show')
4.4.1.1 Setting breakpoints (`break' `tbreak')4.4.2 Resuming Execution
4.4.1.2 Setting watchpoints (`watch', `watche')
4.4.1.3 Deleting breakpoints (`clear', `delete')
4.4.1.4 Disabling breakpoints (`disable', `enable')
4.4.1.5 Break conditions (`condition')
4.4.2.1 Step (`step')4.4.3 Signals
4.4.2.2 Next (`next')
4.4.2.3 Finish (`finish')
4.4.2.4 Skip (`skip')
4.4.2.5 Continue (`continue')
4.4.2.6 Debug (`debug')
4.4.2.7 Returning from a function, sourced file, or subshell (`return')
4.6 Examining the Stack (`where', `frame', `up', `down')
4.6.1 Stack frames4.7 Examining Source Files (`list')
4.6.2 Backtraces (`where')
4.6.3 Selecting a frame (`up', `down', `frame')
4.8 Searching source files (`search', `reverse', `/.../', `?..?')
4.9 Examining Data (`print', `examine', `info variables')
4.10 Running Arbitrary BASH and Shell commands (`eval', `shell')
4.11 Automatic display (`display', `undisplay')
4.12 Controlling the BASH debugger (`set', `history')
4.12.1 Annotation Level (`set annoatate')
4.12.2 Prompt (`set prompt', `show prompt')
4.12.3 Command editing (`set editing', `show editing')
4.12.4 Command Display (`set showcommand')
4.12.5 Command history (`H', `history', `!')
5.1 Using the BASH debugger from GNU Emacs6. Reporting Bugs
5.2 Using the BASH debugger from DDD
6.1 Have you found a bug?7. History and Acknowledgments
6.2 How to report bugs
A. Formatting Documentation
B. Installing the BASH debugger
C. GNU GENERAL PUBLIC LICENSE
PreambleD. GNU Free Documentation License
How to Apply These Terms to Your New Programs
ADDENDUM: How to use this License for your documentsFunction Index
Command Index
Variable Index
General Index
[Top] | [Contents] | [Index] | [ ? ] |
1. Summary of the BASH Debugger
2. Getting in and out
3. Script Setup inside the BASH Debugger
4. BASH Debugger Command Reference
5. Using the BASH debugger from a front-end user interface
6. Reporting Bugs
7. History and Acknowledgments
A. Formatting Documentation
B. Installing the BASH debugger
C. GNU GENERAL PUBLIC LICENSE
D. GNU Free Documentation License
Function Index
Command Index
Variable Index
General Index
[Top] | [Contents] | [Index] | [ ? ] |
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ < ] | Back | previous section in reading order | 1.2.2 |
[ > ] | Forward | next section in reading order | 1.2.4 |
[ << ] | FastBack | beginning of this chapter or previous chapter | 1 |
[ Up ] | Up | up section | 1.2 |
[ >> ] | FastForward | next chapter | 2 |
[Top] | Top | cover (top) of document | |
[Contents] | Contents | table of contents | |
[Index] | Index | concept index | |
[ ? ] | About | this page |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure: