hide random home http://www.fmi.uni-passau.de/archive/doc/unix/gdb/gdb_5.html (Einblicke ins Internet, 10/1995)

Debugging with _GDBN__ - _GDBN__ Commands

Go to the previous, next section.

_GDBN__ Commands

You can abbreviate a _GDBN__ command to the first few letters of the command name, if that abbreviation is unambiguous; and you can repeat certain _GDBN__ commands by typing just RET. You can also use the TAB key to get _GDBN__ to fill out the rest of a word in a command (or to show you the alternatives available, if there's more than one possibility).

Command Syntax

A _GDBN__ 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 command names do not allow any arguments.

_GDBN__ command names may always be truncated if that abbreviation is unambiguous. Other possible command abbreviations are listed in the documentation for individual commands. In some cases, even ambiguous abbreviations are allowed; for example, s is specially defined as equivalent to step even though there are other commands whose names start with s. You can test abbreviations by using them as arguments to the help command.

A blank line as input to _GDBN__ (typing just RET) means to repeat the previous command. Certain commands (for example, run) will not repeat this way; these are commands for which unintentional repetition might cause trouble and which you are unlikely to want to repeat.

The list and x commands, when you repeat them with RET, construct new arguments rather than repeating exactly as typed. This permits easy scanning of source or memory.

_GDBN__ can also use RET in another way: to partition lengthy output, in a way similar to the common utility more (see section Screen Size). Since it is easy to press one RET too many in this situation, _GDBN__ disables command repetition after any command that generates this sort of display.

A line of input starting with # is a comment; it does nothing. This is useful mainly in command files (see section Command Files).

Command Completion

_GDBN__ can fill in the rest of a word in a command for you, if there's only one possibility; it can also show you what the valid possibilities are for the next word in a command, at any time. This works for _GDBN__ commands, _GDBN__ subcommands, and the names of symbols in your program.

Press the TAB key whenever you want _GDBN__ to fill out the rest of a word. If there's only one possibility, _GDBN__ will fill in the word, and wait for you to finish the command (or press RET to enter it). For example, if you type

(_GDBP__) info bre TAB

_GDBN__ fills in the rest of the word `breakpoints', since that's the only info subcommand beginning with `bre':

(_GDBP__) info breakpoints

You can either press RET at this point, to run the info breakpoints command, or backspace and enter something else, if `breakpoints' doesn't look like the command you expected. (If you were sure you wanted info breakpoints in the first place, you might as well just type RET immediately after `info bre', to exploit command abbreviations rather than command completion).

If there is more than one possibility for the next word when you press TAB, _GDBN__ will sound a bell. You can either supply more characters and try again, or just press TAB a second time, and _GDBN__ will display all the possible completions for that word. For example, you might want to set a breakpoint on a subroutine whose name begins with `make_', but when you type b make_TAB _GDBN__ just sounds the bell. Typing TAB again will display all the function names in your program that begin with those characters, for example:

(_GDBP__) b make_ TAB
_GDBN__ sounds bell; press TAB again, to see:
make_a_section_from_file     make_environ               
make_abs_section             make_function_type         
make_blockvector             make_pointer_type          
make_cleanup                 make_reference_type        
make_command                 make_symbol_completion_list
(GDBP__) b make_

After displaying the available possibilities, _GDBN__ copies your partial input (`b make_' in the example) so you can finish the command.

If you just want to see the list of alternatives in the first place, you can press M-? rather than pressing TAB twice. M-? means META ?. You can type this _if__(_GENERIC__||!_DOSHOST__) either by holding down a key designated as the META shift on your keyboard (if there is one) while typing ?, or _fi__(_GENERIC__||!_DOSHOST__) as ESC followed by ?.

Sometimes the string you need, while logically a "word", may contain parentheses or other characters that _GDBN__ normally excludes from its notion of a word. To permit word completion to work in this situation, you may enclose words in ' (single quote marks) in _GDBN__ commands.

The most likely situation where you might need this is in typing the name of a C++ function. This is because C++ allows function overloading (multiple definitions of the same function, distinguished by argument type). For example, when you want to set a breakpoint you may need to distinguish whether you mean the version of name that takes an int parameter, name(int), or the version that takes a float parameter, name(float). To use the word-completion facilities in this situation, type a single quote ' at the beginning of the function name. This alerts _GDBN__ that it may need to consider more information than usual when you press TAB or M-? to request word completion:

(_GDBP__) b 'bubble( M-?
bubble(double,double)    bubble(int,int)
(_GDBP__) b 'bubble(

In some cases, _GDBN__ can tell that completing a name will require quotes. When this happens, _GDBN__ will insert the quote for you (while completing as much as it can) if you do not type the quote in the first place:

(_GDBP__) b bub TAB
_GDBN__ alters your input line to the following, and rings a bell:
(_GDBP__) b 'bubble(

In general, _GDBN__ can tell that a quote is needed (and inserts it) if you have not yet started typing the argument list when you ask for completion on an overloaded symbol.

Getting Help

You can always ask _GDBN__ itself for information on its commands, using the command help.

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

(_GDBP__) help
List of classes of commands:

running -- Running the program
stack -- Examining the stack
data -- Examining data
breakpoints -- Making program stop at certain points
files -- Specifying and examining files
status -- Status inquiries
support -- Support facilities
user-defined -- User-defined commands
aliases -- Aliases of other commands
obscure -- Obscure features

Type "help" followed by a class name for a list of 
commands in that class.
Type "help" followed by command name for full 
documentation.
Command name abbreviations are allowed if unambiguous.
(_GDBP__)

help class
Using one of the general help classes as an argument, you can get a list of the individual commands in that class. For example, here is the help display for the class status:

(_GDBP__) help status
Status inquiries.

List of commands:

show -- Generic command for showing things set with "set"
info -- Generic command for printing status

Type "help" followed by command name for full 
documentation.
Command name abbreviations are allowed if unambiguous.
(_GDBP__)

help command
With a command name as help argument, _GDBN__ will display a short paragraph on how to use that command.

In addition to help, you can use the _GDBN__ commands info and show to inquire about the state of your program, or the state of _GDBN__ 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 Index.

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

show
In contrast, show is for describing the state of _GDBN__ itself. You can change most of the things you can show, by using the related command set; for example, you can control what number system is used for displays with set radix, or simply inquire which is currently in use with show radix.

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 what version of _GDBN__ is running. You should include this information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are in use at your site, you may occasionally want to make sure what version of _GDBN__ you are running; as _GDBN__ evolves, new commands are introduced, and old ones may wither away. The version number is also announced when you start _GDBN__ with no arguments.

show copying
Display information about permission for copying _GDBN__.

show warranty
Display the GNU "NO WARRANTY" statement.

Go to the previous, next section.