1 |
1181 |
sfurman |
This is gdb.info, produced by makeinfo version 4.1 from ./gdb.texinfo.
|
2 |
|
|
|
3 |
|
|
INFO-DIR-SECTION Programming & development tools.
|
4 |
|
|
START-INFO-DIR-ENTRY
|
5 |
|
|
* Gdb: (gdb). The GNU debugger.
|
6 |
|
|
END-INFO-DIR-ENTRY
|
7 |
|
|
|
8 |
|
|
This file documents the GNU debugger GDB.
|
9 |
|
|
|
10 |
|
|
This is the Ninth Edition, December 2001, of `Debugging with GDB:
|
11 |
|
|
the GNU Source-Level Debugger' for GDB Version 5.3.
|
12 |
|
|
|
13 |
|
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
|
14 |
|
|
1998,
|
15 |
|
|
1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
16 |
|
|
|
17 |
|
|
Permission is granted to copy, distribute and/or modify this document
|
18 |
|
|
under the terms of the GNU Free Documentation License, Version 1.1 or
|
19 |
|
|
any later version published by the Free Software Foundation; with the
|
20 |
|
|
Invariant Sections being "Free Software" and "Free Software Needs Free
|
21 |
|
|
Documentation", with the Front-Cover Texts being "A GNU Manual," and
|
22 |
|
|
with the Back-Cover Texts as in (a) below.
|
23 |
|
|
|
24 |
|
|
(a) The Free Software Foundation's Back-Cover Text is: "You have
|
25 |
|
|
freedom to copy and modify this GNU Manual, like GNU software. Copies
|
26 |
|
|
published by the Free Software Foundation raise funds for GNU
|
27 |
|
|
development."
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
File: gdb.info, Node: ST2000, Next: Z8000, Prev: Sparclite, Up: Embedded Processors
|
31 |
|
|
|
32 |
|
|
Tandem ST2000
|
33 |
|
|
-------------
|
34 |
|
|
|
35 |
|
|
GDB may be used with a Tandem ST2000 phone switch, running Tandem's
|
36 |
|
|
STDBUG protocol.
|
37 |
|
|
|
38 |
|
|
To connect your ST2000 to the host system, see the manufacturer's
|
39 |
|
|
manual. Once the ST2000 is physically attached, you can run:
|
40 |
|
|
|
41 |
|
|
target st2000 DEV SPEED
|
42 |
|
|
|
43 |
|
|
to establish it as your debugging environment. DEV is normally the
|
44 |
|
|
name of a serial device, such as `/dev/ttya', connected to the ST2000
|
45 |
|
|
via a serial line. You can instead specify DEV as a TCP connection
|
46 |
|
|
(for example, to a serial line attached via a terminal concentrator)
|
47 |
|
|
using the syntax `HOSTNAME:PORTNUMBER'.
|
48 |
|
|
|
49 |
|
|
The `load' and `attach' commands are _not_ defined for this target;
|
50 |
|
|
you must load your program into the ST2000 as you normally would for
|
51 |
|
|
standalone operation. GDB reads debugging information (such as
|
52 |
|
|
symbols) from a separate, debugging version of the program available on
|
53 |
|
|
your host computer.
|
54 |
|
|
|
55 |
|
|
These auxiliary GDB commands are available to help you with the
|
56 |
|
|
ST2000 environment:
|
57 |
|
|
|
58 |
|
|
`st2000 COMMAND'
|
59 |
|
|
Send a COMMAND to the STDBUG monitor. See the manufacturer's
|
60 |
|
|
manual for available commands.
|
61 |
|
|
|
62 |
|
|
`connect'
|
63 |
|
|
Connect the controlling terminal to the STDBUG command monitor.
|
64 |
|
|
When you are done interacting with STDBUG, typing either of two
|
65 |
|
|
character sequences gets you back to the GDB command prompt:
|
66 |
|
|
`~.' (Return, followed by tilde and period) or `~'
|
67 |
|
|
(Return, followed by tilde and control-D).
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
File: gdb.info, Node: Z8000, Prev: ST2000, Up: Embedded Processors
|
71 |
|
|
|
72 |
|
|
Zilog Z8000
|
73 |
|
|
-----------
|
74 |
|
|
|
75 |
|
|
When configured for debugging Zilog Z8000 targets, GDB includes a
|
76 |
|
|
Z8000 simulator.
|
77 |
|
|
|
78 |
|
|
For the Z8000 family, `target sim' simulates either the Z8002 (the
|
79 |
|
|
unsegmented variant of the Z8000 architecture) or the Z8001 (the
|
80 |
|
|
segmented variant). The simulator recognizes which architecture is
|
81 |
|
|
appropriate by inspecting the object code.
|
82 |
|
|
|
83 |
|
|
`target sim ARGS'
|
84 |
|
|
Debug programs on a simulated CPU. If the simulator supports setup
|
85 |
|
|
options, specify them via ARGS.
|
86 |
|
|
|
87 |
|
|
After specifying this target, you can debug programs for the simulated
|
88 |
|
|
CPU in the same style as programs for your host computer; use the
|
89 |
|
|
`file' command to load a new program image, the `run' command to run
|
90 |
|
|
your program, and so on.
|
91 |
|
|
|
92 |
|
|
As well as making available all the usual machine registers (*note
|
93 |
|
|
Registers: Registers.), the Z8000 simulator provides three additional
|
94 |
|
|
items of information as specially named registers:
|
95 |
|
|
|
96 |
|
|
`cycles'
|
97 |
|
|
Counts clock-ticks in the simulator.
|
98 |
|
|
|
99 |
|
|
`insts'
|
100 |
|
|
Counts instructions run in the simulator.
|
101 |
|
|
|
102 |
|
|
`time'
|
103 |
|
|
Execution time in 60ths of a second.
|
104 |
|
|
|
105 |
|
|
You can refer to these values in GDB expressions with the usual
|
106 |
|
|
conventions; for example, `b fputc if $cycles>5000' sets a conditional
|
107 |
|
|
breakpoint that suspends only after at least 5000 simulated clock ticks.
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
File: gdb.info, Node: Architectures, Prev: Embedded Processors, Up: Configurations
|
111 |
|
|
|
112 |
|
|
Architectures
|
113 |
|
|
=============
|
114 |
|
|
|
115 |
|
|
This section describes characteristics of architectures that affect
|
116 |
|
|
all uses of GDB with the architecture, both native and cross.
|
117 |
|
|
|
118 |
|
|
* Menu:
|
119 |
|
|
|
120 |
|
|
* A29K::
|
121 |
|
|
* Alpha::
|
122 |
|
|
* MIPS::
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
File: gdb.info, Node: A29K, Next: Alpha, Up: Architectures
|
126 |
|
|
|
127 |
|
|
A29K
|
128 |
|
|
----
|
129 |
|
|
|
130 |
|
|
`set rstack_high_address ADDRESS'
|
131 |
|
|
On AMD 29000 family processors, registers are saved in a separate
|
132 |
|
|
"register stack". There is no way for GDB to determine the extent
|
133 |
|
|
of this stack. Normally, GDB just assumes that the stack is
|
134 |
|
|
"large enough". This may result in GDB referencing memory
|
135 |
|
|
locations that do not exist. If necessary, you can get around
|
136 |
|
|
this problem by specifying the ending address of the register
|
137 |
|
|
stack with the `set rstack_high_address' command. The argument
|
138 |
|
|
should be an address, which you probably want to precede with `0x'
|
139 |
|
|
to specify in hexadecimal.
|
140 |
|
|
|
141 |
|
|
`show rstack_high_address'
|
142 |
|
|
Display the current limit of the register stack, on AMD 29000
|
143 |
|
|
family processors.
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
File: gdb.info, Node: Alpha, Next: MIPS, Prev: A29K, Up: Architectures
|
147 |
|
|
|
148 |
|
|
Alpha
|
149 |
|
|
-----
|
150 |
|
|
|
151 |
|
|
See the following section.
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
File: gdb.info, Node: MIPS, Prev: Alpha, Up: Architectures
|
155 |
|
|
|
156 |
|
|
MIPS
|
157 |
|
|
----
|
158 |
|
|
|
159 |
|
|
Alpha- and MIPS-based computers use an unusual stack frame, which
|
160 |
|
|
sometimes requires GDB to search backward in the object code to find
|
161 |
|
|
the beginning of a function.
|
162 |
|
|
|
163 |
|
|
To improve response time (especially for embedded applications, where
|
164 |
|
|
GDB may be restricted to a slow serial line for this search) you may
|
165 |
|
|
want to limit the size of this search, using one of these commands:
|
166 |
|
|
|
167 |
|
|
`set heuristic-fence-post LIMIT'
|
168 |
|
|
Restrict GDB to examining at most LIMIT bytes in its search for
|
169 |
|
|
the beginning of a function. A value of 0 (the default) means
|
170 |
|
|
there is no limit. However, except for 0, the larger the limit
|
171 |
|
|
the more bytes `heuristic-fence-post' must search and therefore
|
172 |
|
|
the longer it takes to run.
|
173 |
|
|
|
174 |
|
|
`show heuristic-fence-post'
|
175 |
|
|
Display the current limit.
|
176 |
|
|
|
177 |
|
|
These commands are available _only_ when GDB is configured for
|
178 |
|
|
debugging programs on Alpha or MIPS processors.
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
File: gdb.info, Node: Controlling GDB, Next: Sequences, Prev: Configurations, Up: Top
|
182 |
|
|
|
183 |
|
|
Controlling GDB
|
184 |
|
|
***************
|
185 |
|
|
|
186 |
|
|
You can alter the way GDB interacts with you by using the `set'
|
187 |
|
|
command. For commands controlling how GDB displays data, see *Note
|
188 |
|
|
Print settings: Print Settings. Other settings are described here.
|
189 |
|
|
|
190 |
|
|
* Menu:
|
191 |
|
|
|
192 |
|
|
* Prompt:: Prompt
|
193 |
|
|
* Editing:: Command editing
|
194 |
|
|
* History:: Command history
|
195 |
|
|
* Screen Size:: Screen size
|
196 |
|
|
* Numbers:: Numbers
|
197 |
|
|
* Messages/Warnings:: Optional warnings and messages
|
198 |
|
|
* Debugging Output:: Optional messages about internal happenings
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
File: gdb.info, Node: Prompt, Next: Editing, Up: Controlling GDB
|
202 |
|
|
|
203 |
|
|
Prompt
|
204 |
|
|
======
|
205 |
|
|
|
206 |
|
|
GDB indicates its readiness to read a command by printing a string
|
207 |
|
|
called the "prompt". This string is normally `(gdb)'. You can change
|
208 |
|
|
the prompt string with the `set prompt' command. For instance, when
|
209 |
|
|
debugging GDB with GDB, it is useful to change the prompt in one of the
|
210 |
|
|
GDB sessions so that you can always tell which one you are talking to.
|
211 |
|
|
|
212 |
|
|
_Note:_ `set prompt' does not add a space for you after the prompt
|
213 |
|
|
you set. This allows you to set a prompt which ends in a space or a
|
214 |
|
|
prompt that does not.
|
215 |
|
|
|
216 |
|
|
`set prompt NEWPROMPT'
|
217 |
|
|
Directs GDB to use NEWPROMPT as its prompt string henceforth.
|
218 |
|
|
|
219 |
|
|
`show prompt'
|
220 |
|
|
Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
File: gdb.info, Node: Editing, Next: History, Prev: Prompt, Up: Controlling GDB
|
224 |
|
|
|
225 |
|
|
Command editing
|
226 |
|
|
===============
|
227 |
|
|
|
228 |
|
|
GDB reads its input commands via the "readline" interface. This GNU
|
229 |
|
|
library provides consistent behavior for programs which provide a
|
230 |
|
|
command line interface to the user. Advantages are GNU Emacs-style or
|
231 |
|
|
"vi"-style inline editing of commands, `csh'-like history substitution,
|
232 |
|
|
and a storage and recall of command history across debugging sessions.
|
233 |
|
|
|
234 |
|
|
You may control the behavior of command line editing in GDB with the
|
235 |
|
|
command `set'.
|
236 |
|
|
|
237 |
|
|
`set editing'
|
238 |
|
|
`set editing on'
|
239 |
|
|
Enable command line editing (enabled by default).
|
240 |
|
|
|
241 |
|
|
`set editing off'
|
242 |
|
|
Disable command line editing.
|
243 |
|
|
|
244 |
|
|
`show editing'
|
245 |
|
|
Show whether command line editing is enabled.
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
File: gdb.info, Node: History, Next: Screen Size, Prev: Editing, Up: Controlling GDB
|
249 |
|
|
|
250 |
|
|
Command history
|
251 |
|
|
===============
|
252 |
|
|
|
253 |
|
|
GDB can keep track of the commands you type during your debugging
|
254 |
|
|
sessions, so that you can be certain of precisely what happened. Use
|
255 |
|
|
these commands to manage the GDB command history facility.
|
256 |
|
|
|
257 |
|
|
`set history filename FNAME'
|
258 |
|
|
Set the name of the GDB command history file to FNAME. This is
|
259 |
|
|
the file where GDB reads an initial command history list, and
|
260 |
|
|
where it writes the command history from this session when it
|
261 |
|
|
exits. You can access this list through history expansion or
|
262 |
|
|
through the history command editing characters listed below. This
|
263 |
|
|
file defaults to the value of the environment variable
|
264 |
|
|
`GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS)
|
265 |
|
|
if this variable is not set.
|
266 |
|
|
|
267 |
|
|
`set history save'
|
268 |
|
|
`set history save on'
|
269 |
|
|
Record command history in a file, whose name may be specified with
|
270 |
|
|
the `set history filename' command. By default, this option is
|
271 |
|
|
disabled.
|
272 |
|
|
|
273 |
|
|
`set history save off'
|
274 |
|
|
Stop recording command history in a file.
|
275 |
|
|
|
276 |
|
|
`set history size SIZE'
|
277 |
|
|
Set the number of commands which GDB keeps in its history list.
|
278 |
|
|
This defaults to the value of the environment variable `HISTSIZE',
|
279 |
|
|
or to 256 if this variable is not set.
|
280 |
|
|
|
281 |
|
|
History expansion assigns special meaning to the character `!'.
|
282 |
|
|
|
283 |
|
|
Since `!' is also the logical not operator in C, history expansion
|
284 |
|
|
is off by default. If you decide to enable history expansion with the
|
285 |
|
|
`set history expansion on' command, you may sometimes need to follow
|
286 |
|
|
`!' (when it is used as logical not, in an expression) with a space or
|
287 |
|
|
a tab to prevent it from being expanded. The readline history
|
288 |
|
|
facilities do not attempt substitution on the strings `!=' and `!(',
|
289 |
|
|
even when history expansion is enabled.
|
290 |
|
|
|
291 |
|
|
The commands to control history expansion are:
|
292 |
|
|
|
293 |
|
|
`set history expansion on'
|
294 |
|
|
`set history expansion'
|
295 |
|
|
Enable history expansion. History expansion is off by default.
|
296 |
|
|
|
297 |
|
|
`set history expansion off'
|
298 |
|
|
Disable history expansion.
|
299 |
|
|
|
300 |
|
|
The readline code comes with more complete documentation of
|
301 |
|
|
editing and history expansion features. Users unfamiliar with GNU
|
302 |
|
|
Emacs or `vi' may wish to read it.
|
303 |
|
|
|
304 |
|
|
`show history'
|
305 |
|
|
`show history filename'
|
306 |
|
|
`show history save'
|
307 |
|
|
`show history size'
|
308 |
|
|
`show history expansion'
|
309 |
|
|
These commands display the state of the GDB history parameters.
|
310 |
|
|
`show history' by itself displays all four states.
|
311 |
|
|
|
312 |
|
|
`show commands'
|
313 |
|
|
Display the last ten commands in the command history.
|
314 |
|
|
|
315 |
|
|
`show commands N'
|
316 |
|
|
Print ten commands centered on command number N.
|
317 |
|
|
|
318 |
|
|
`show commands +'
|
319 |
|
|
Print ten commands just after the commands last printed.
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
File: gdb.info, Node: Screen Size, Next: Numbers, Prev: History, Up: Controlling GDB
|
323 |
|
|
|
324 |
|
|
Screen size
|
325 |
|
|
===========
|
326 |
|
|
|
327 |
|
|
Certain commands to GDB may produce large amounts of information
|
328 |
|
|
output to the screen. To help you read all of it, GDB pauses and asks
|
329 |
|
|
you for input at the end of each page of output. Type when you
|
330 |
|
|
want to continue the output, or `q' to discard the remaining output.
|
331 |
|
|
Also, the screen width setting determines when to wrap lines of output.
|
332 |
|
|
Depending on what is being printed, GDB tries to break the line at a
|
333 |
|
|
readable place, rather than simply letting it overflow onto the
|
334 |
|
|
following line.
|
335 |
|
|
|
336 |
|
|
Normally GDB knows the size of the screen from the terminal driver
|
337 |
|
|
software. For example, on Unix GDB uses the termcap data base together
|
338 |
|
|
with the value of the `TERM' environment variable and the `stty rows'
|
339 |
|
|
and `stty cols' settings. If this is not correct, you can override it
|
340 |
|
|
with the `set height' and `set width' commands:
|
341 |
|
|
|
342 |
|
|
`set height LPP'
|
343 |
|
|
`show height'
|
344 |
|
|
`set width CPL'
|
345 |
|
|
`show width'
|
346 |
|
|
These `set' commands specify a screen height of LPP lines and a
|
347 |
|
|
screen width of CPL characters. The associated `show' commands
|
348 |
|
|
display the current settings.
|
349 |
|
|
|
350 |
|
|
If you specify a height of zero lines, GDB does not pause during
|
351 |
|
|
output no matter how long the output is. This is useful if output
|
352 |
|
|
is to a file or to an editor buffer.
|
353 |
|
|
|
354 |
|
|
Likewise, you can specify `set width 0' to prevent GDB from
|
355 |
|
|
wrapping its output.
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
File: gdb.info, Node: Numbers, Next: Messages/Warnings, Prev: Screen Size, Up: Controlling GDB
|
359 |
|
|
|
360 |
|
|
Numbers
|
361 |
|
|
=======
|
362 |
|
|
|
363 |
|
|
You can always enter numbers in octal, decimal, or hexadecimal in
|
364 |
|
|
GDB by the usual conventions: octal numbers begin with `0', decimal
|
365 |
|
|
numbers end with `.', and hexadecimal numbers begin with `0x'. Numbers
|
366 |
|
|
that begin with none of these are, by default, entered in base 10;
|
367 |
|
|
likewise, the default display for numbers--when no particular format is
|
368 |
|
|
specified--is base 10. You can change the default base for both input
|
369 |
|
|
and output with the `set radix' command.
|
370 |
|
|
|
371 |
|
|
`set input-radix BASE'
|
372 |
|
|
Set the default base for numeric input. Supported choices for
|
373 |
|
|
BASE are decimal 8, 10, or 16. BASE must itself be specified
|
374 |
|
|
either unambiguously or using the current default radix; for
|
375 |
|
|
example, any of
|
376 |
|
|
|
377 |
|
|
set radix 012
|
378 |
|
|
set radix 10.
|
379 |
|
|
set radix 0xa
|
380 |
|
|
|
381 |
|
|
sets the base to decimal. On the other hand, `set radix 10'
|
382 |
|
|
leaves the radix unchanged no matter what it was.
|
383 |
|
|
|
384 |
|
|
`set output-radix BASE'
|
385 |
|
|
Set the default base for numeric display. Supported choices for
|
386 |
|
|
BASE are decimal 8, 10, or 16. BASE must itself be specified
|
387 |
|
|
either unambiguously or using the current default radix.
|
388 |
|
|
|
389 |
|
|
`show input-radix'
|
390 |
|
|
Display the current default base for numeric input.
|
391 |
|
|
|
392 |
|
|
`show output-radix'
|
393 |
|
|
Display the current default base for numeric display.
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
File: gdb.info, Node: Messages/Warnings, Next: Debugging Output, Prev: Numbers, Up: Controlling GDB
|
397 |
|
|
|
398 |
|
|
Optional warnings and messages
|
399 |
|
|
==============================
|
400 |
|
|
|
401 |
|
|
By default, GDB is silent about its inner workings. If you are
|
402 |
|
|
running on a slow machine, you may want to use the `set verbose'
|
403 |
|
|
command. This makes GDB tell you when it does a lengthy internal
|
404 |
|
|
operation, so you will not think it has crashed.
|
405 |
|
|
|
406 |
|
|
Currently, the messages controlled by `set verbose' are those which
|
407 |
|
|
announce that the symbol table for a source file is being read; see
|
408 |
|
|
`symbol-file' in *Note Commands to specify files: Files.
|
409 |
|
|
|
410 |
|
|
`set verbose on'
|
411 |
|
|
Enables GDB output of certain informational messages.
|
412 |
|
|
|
413 |
|
|
`set verbose off'
|
414 |
|
|
Disables GDB output of certain informational messages.
|
415 |
|
|
|
416 |
|
|
`show verbose'
|
417 |
|
|
Displays whether `set verbose' is on or off.
|
418 |
|
|
|
419 |
|
|
By default, if GDB encounters bugs in the symbol table of an object
|
420 |
|
|
file, it is silent; but if you are debugging a compiler, you may find
|
421 |
|
|
this information useful (*note Errors reading symbol files: Symbol
|
422 |
|
|
Errors.).
|
423 |
|
|
|
424 |
|
|
`set complaints LIMIT'
|
425 |
|
|
Permits GDB to output LIMIT complaints about each type of unusual
|
426 |
|
|
symbols before becoming silent about the problem. Set LIMIT to
|
427 |
|
|
zero to suppress all complaints; set it to a large number to
|
428 |
|
|
prevent complaints from being suppressed.
|
429 |
|
|
|
430 |
|
|
`show complaints'
|
431 |
|
|
Displays how many symbol complaints GDB is permitted to produce.
|
432 |
|
|
|
433 |
|
|
By default, GDB is cautious, and asks what sometimes seems to be a
|
434 |
|
|
lot of stupid questions to confirm certain commands. For example, if
|
435 |
|
|
you try to run a program which is already running:
|
436 |
|
|
|
437 |
|
|
(gdb) run
|
438 |
|
|
The program being debugged has been started already.
|
439 |
|
|
Start it from the beginning? (y or n)
|
440 |
|
|
|
441 |
|
|
If you are willing to unflinchingly face the consequences of your own
|
442 |
|
|
commands, you can disable this "feature":
|
443 |
|
|
|
444 |
|
|
`set confirm off'
|
445 |
|
|
Disables confirmation requests.
|
446 |
|
|
|
447 |
|
|
`set confirm on'
|
448 |
|
|
Enables confirmation requests (the default).
|
449 |
|
|
|
450 |
|
|
`show confirm'
|
451 |
|
|
Displays state of confirmation requests.
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
File: gdb.info, Node: Debugging Output, Prev: Messages/Warnings, Up: Controlling GDB
|
455 |
|
|
|
456 |
|
|
Optional messages about internal happenings
|
457 |
|
|
===========================================
|
458 |
|
|
|
459 |
|
|
`set debug arch'
|
460 |
|
|
Turns on or off display of gdbarch debugging info. The default is
|
461 |
|
|
off
|
462 |
|
|
|
463 |
|
|
`show debug arch'
|
464 |
|
|
Displays the current state of displaying gdbarch debugging info.
|
465 |
|
|
|
466 |
|
|
`set debug event'
|
467 |
|
|
Turns on or off display of GDB event debugging info. The default
|
468 |
|
|
is off.
|
469 |
|
|
|
470 |
|
|
`show debug event'
|
471 |
|
|
Displays the current state of displaying GDB event debugging info.
|
472 |
|
|
|
473 |
|
|
`set debug expression'
|
474 |
|
|
Turns on or off display of GDB expression debugging info. The
|
475 |
|
|
default is off.
|
476 |
|
|
|
477 |
|
|
`show debug expression'
|
478 |
|
|
Displays the current state of displaying GDB expression debugging
|
479 |
|
|
info.
|
480 |
|
|
|
481 |
|
|
`set debug overload'
|
482 |
|
|
Turns on or off display of GDB C++ overload debugging info. This
|
483 |
|
|
includes info such as ranking of functions, etc. The default is
|
484 |
|
|
off.
|
485 |
|
|
|
486 |
|
|
`show debug overload'
|
487 |
|
|
Displays the current state of displaying GDB C++ overload
|
488 |
|
|
debugging info.
|
489 |
|
|
|
490 |
|
|
`set debug remote'
|
491 |
|
|
Turns on or off display of reports on all packets sent back and
|
492 |
|
|
forth across the serial line to the remote machine. The info is
|
493 |
|
|
printed on the GDB standard output stream. The default is off.
|
494 |
|
|
|
495 |
|
|
`show debug remote'
|
496 |
|
|
Displays the state of display of remote packets.
|
497 |
|
|
|
498 |
|
|
`set debug serial'
|
499 |
|
|
Turns on or off display of GDB serial debugging info. The default
|
500 |
|
|
is off.
|
501 |
|
|
|
502 |
|
|
`show debug serial'
|
503 |
|
|
Displays the current state of displaying GDB serial debugging info.
|
504 |
|
|
|
505 |
|
|
`set debug target'
|
506 |
|
|
Turns on or off display of GDB target debugging info. This info
|
507 |
|
|
includes what is going on at the target level of GDB, as it
|
508 |
|
|
happens. The default is off.
|
509 |
|
|
|
510 |
|
|
`show debug target'
|
511 |
|
|
Displays the current state of displaying GDB target debugging info.
|
512 |
|
|
|
513 |
|
|
`set debug varobj'
|
514 |
|
|
Turns on or off display of GDB variable object debugging info. The
|
515 |
|
|
default is off.
|
516 |
|
|
|
517 |
|
|
`show debug varobj'
|
518 |
|
|
Displays the current state of displaying GDB variable object
|
519 |
|
|
debugging info.
|
520 |
|
|
|
521 |
|
|
|
522 |
|
|
File: gdb.info, Node: Sequences, Next: TUI, Prev: Controlling GDB, Up: Top
|
523 |
|
|
|
524 |
|
|
Canned Sequences of Commands
|
525 |
|
|
****************************
|
526 |
|
|
|
527 |
|
|
Aside from breakpoint commands (*note Breakpoint command lists:
|
528 |
|
|
Break Commands.), GDB provides two ways to store sequences of commands
|
529 |
|
|
for execution as a unit: user-defined commands and command files.
|
530 |
|
|
|
531 |
|
|
* Menu:
|
532 |
|
|
|
533 |
|
|
* Define:: User-defined commands
|
534 |
|
|
* Hooks:: User-defined command hooks
|
535 |
|
|
* Command Files:: Command files
|
536 |
|
|
* Output:: Commands for controlled output
|
537 |
|
|
|
538 |
|
|
|
539 |
|
|
File: gdb.info, Node: Define, Next: Hooks, Up: Sequences
|
540 |
|
|
|
541 |
|
|
User-defined commands
|
542 |
|
|
=====================
|
543 |
|
|
|
544 |
|
|
A "user-defined command" is a sequence of GDB commands to which you
|
545 |
|
|
assign a new name as a command. This is done with the `define'
|
546 |
|
|
command. User commands may accept up to 10 arguments separated by
|
547 |
|
|
whitespace. Arguments are accessed within the user command via
|
548 |
|
|
$ARG0...$ARG9. A trivial example:
|
549 |
|
|
|
550 |
|
|
define adder
|
551 |
|
|
print $arg0 + $arg1 + $arg2
|
552 |
|
|
|
553 |
|
|
To execute the command use:
|
554 |
|
|
|
555 |
|
|
adder 1 2 3
|
556 |
|
|
|
557 |
|
|
This defines the command `adder', which prints the sum of its three
|
558 |
|
|
arguments. Note the arguments are text substitutions, so they may
|
559 |
|
|
reference variables, use complex expressions, or even perform inferior
|
560 |
|
|
functions calls.
|
561 |
|
|
|
562 |
|
|
`define COMMANDNAME'
|
563 |
|
|
Define a command named COMMANDNAME. If there is already a command
|
564 |
|
|
by that name, you are asked to confirm that you want to redefine
|
565 |
|
|
it.
|
566 |
|
|
|
567 |
|
|
The definition of the command is made up of other GDB command
|
568 |
|
|
lines, which are given following the `define' command. The end of
|
569 |
|
|
these commands is marked by a line containing `end'.
|
570 |
|
|
|
571 |
|
|
`if'
|
572 |
|
|
Takes a single argument, which is an expression to evaluate. It
|
573 |
|
|
is followed by a series of commands that are executed only if the
|
574 |
|
|
expression is true (nonzero). There can then optionally be a line
|
575 |
|
|
`else', followed by a series of commands that are only executed if
|
576 |
|
|
the expression was false. The end of the list is marked by a line
|
577 |
|
|
containing `end'.
|
578 |
|
|
|
579 |
|
|
`while'
|
580 |
|
|
The syntax is similar to `if': the command takes a single argument,
|
581 |
|
|
which is an expression to evaluate, and must be followed by the
|
582 |
|
|
commands to execute, one per line, terminated by an `end'. The
|
583 |
|
|
commands are executed repeatedly as long as the expression
|
584 |
|
|
evaluates to true.
|
585 |
|
|
|
586 |
|
|
`document COMMANDNAME'
|
587 |
|
|
Document the user-defined command COMMANDNAME, so that it can be
|
588 |
|
|
accessed by `help'. The command COMMANDNAME must already be
|
589 |
|
|
defined. This command reads lines of documentation just as
|
590 |
|
|
`define' reads the lines of the command definition, ending with
|
591 |
|
|
`end'. After the `document' command is finished, `help' on command
|
592 |
|
|
COMMANDNAME displays the documentation you have written.
|
593 |
|
|
|
594 |
|
|
You may use the `document' command again to change the
|
595 |
|
|
documentation of a command. Redefining the command with `define'
|
596 |
|
|
does not change the documentation.
|
597 |
|
|
|
598 |
|
|
`help user-defined'
|
599 |
|
|
List all user-defined commands, with the first line of the
|
600 |
|
|
documentation (if any) for each.
|
601 |
|
|
|
602 |
|
|
`show user'
|
603 |
|
|
`show user COMMANDNAME'
|
604 |
|
|
Display the GDB commands used to define COMMANDNAME (but not its
|
605 |
|
|
documentation). If no COMMANDNAME is given, display the
|
606 |
|
|
definitions for all user-defined commands.
|
607 |
|
|
|
608 |
|
|
`show max-user-call-depth'
|
609 |
|
|
`set max-user-call-depth'
|
610 |
|
|
The value of `max-user-call-depth' controls how many recursion
|
611 |
|
|
levels are allowed in user-defined commands before GDB suspects an
|
612 |
|
|
infinite recursion and aborts the command.
|
613 |
|
|
|
614 |
|
|
When user-defined commands are executed, the commands of the
|
615 |
|
|
definition are not printed. An error in any command stops execution of
|
616 |
|
|
the user-defined command.
|
617 |
|
|
|
618 |
|
|
If used interactively, commands that would ask for confirmation
|
619 |
|
|
proceed without asking when used inside a user-defined command. Many
|
620 |
|
|
GDB commands that normally print messages to say what they are doing
|
621 |
|
|
omit the messages when used in a user-defined command.
|
622 |
|
|
|
623 |
|
|
|
624 |
|
|
File: gdb.info, Node: Hooks, Next: Command Files, Prev: Define, Up: Sequences
|
625 |
|
|
|
626 |
|
|
User-defined command hooks
|
627 |
|
|
==========================
|
628 |
|
|
|
629 |
|
|
You may define "hooks", which are a special kind of user-defined
|
630 |
|
|
command. Whenever you run the command `foo', if the user-defined
|
631 |
|
|
command `hook-foo' exists, it is executed (with no arguments) before
|
632 |
|
|
that command.
|
633 |
|
|
|
634 |
|
|
A hook may also be defined which is run after the command you
|
635 |
|
|
executed. Whenever you run the command `foo', if the user-defined
|
636 |
|
|
command `hookpost-foo' exists, it is executed (with no arguments) after
|
637 |
|
|
that command. Post-execution hooks may exist simultaneously with
|
638 |
|
|
pre-execution hooks, for the same command.
|
639 |
|
|
|
640 |
|
|
It is valid for a hook to call the command which it hooks. If this
|
641 |
|
|
occurs, the hook is not re-executed, thereby avoiding infinte recursion.
|
642 |
|
|
|
643 |
|
|
In addition, a pseudo-command, `stop' exists. Defining
|
644 |
|
|
(`hook-stop') makes the associated commands execute every time
|
645 |
|
|
execution stops in your program: before breakpoint commands are run,
|
646 |
|
|
displays are printed, or the stack frame is printed.
|
647 |
|
|
|
648 |
|
|
For example, to ignore `SIGALRM' signals while single-stepping, but
|
649 |
|
|
treat them normally during normal execution, you could define:
|
650 |
|
|
|
651 |
|
|
define hook-stop
|
652 |
|
|
handle SIGALRM nopass
|
653 |
|
|
end
|
654 |
|
|
|
655 |
|
|
define hook-run
|
656 |
|
|
handle SIGALRM pass
|
657 |
|
|
end
|
658 |
|
|
|
659 |
|
|
define hook-continue
|
660 |
|
|
handle SIGLARM pass
|
661 |
|
|
end
|
662 |
|
|
|
663 |
|
|
As a further example, to hook at the begining and end of the `echo'
|
664 |
|
|
command, and to add extra text to the beginning and end of the message,
|
665 |
|
|
you could define:
|
666 |
|
|
|
667 |
|
|
define hook-echo
|
668 |
|
|
echo <<<---
|
669 |
|
|
end
|
670 |
|
|
|
671 |
|
|
define hookpost-echo
|
672 |
|
|
echo --->>>\n
|
673 |
|
|
end
|
674 |
|
|
|
675 |
|
|
(gdb) echo Hello World
|
676 |
|
|
<<<---Hello World--->>>
|
677 |
|
|
(gdb)
|
678 |
|
|
|
679 |
|
|
You can define a hook for any single-word command in GDB, but not
|
680 |
|
|
for command aliases; you should define a hook for the basic command
|
681 |
|
|
name, e.g. `backtrace' rather than `bt'. If an error occurs during
|
682 |
|
|
the execution of your hook, execution of GDB commands stops and GDB
|
683 |
|
|
issues a prompt (before the command that you actually typed had a
|
684 |
|
|
chance to run).
|
685 |
|
|
|
686 |
|
|
If you try to define a hook which does not match any known command,
|
687 |
|
|
you get a warning from the `define' command.
|
688 |
|
|
|
689 |
|
|
|
690 |
|
|
File: gdb.info, Node: Command Files, Next: Output, Prev: Hooks, Up: Sequences
|
691 |
|
|
|
692 |
|
|
Command files
|
693 |
|
|
=============
|
694 |
|
|
|
695 |
|
|
A command file for GDB is a file of lines that are GDB commands.
|
696 |
|
|
Comments (lines starting with `#') may also be included. An empty line
|
697 |
|
|
in a command file does nothing; it does not mean to repeat the last
|
698 |
|
|
command, as it would from the terminal.
|
699 |
|
|
|
700 |
|
|
When you start GDB, it automatically executes commands from its
|
701 |
|
|
"init files", normally called `.gdbinit'(1). During startup, GDB does
|
702 |
|
|
the following:
|
703 |
|
|
|
704 |
|
|
1. Reads the init file (if any) in your home directory(2).
|
705 |
|
|
|
706 |
|
|
2. Processes command line options and operands.
|
707 |
|
|
|
708 |
|
|
3. Reads the init file (if any) in the current working directory.
|
709 |
|
|
|
710 |
|
|
4. Reads command files specified by the `-x' option.
|
711 |
|
|
|
712 |
|
|
The init file in your home directory can set options (such as `set
|
713 |
|
|
complaints') that affect subsequent processing of command line options
|
714 |
|
|
and operands. Init files are not executed if you use the `-nx' option
|
715 |
|
|
(*note Choosing modes: Mode Options.).
|
716 |
|
|
|
717 |
|
|
On some configurations of GDB, the init file is known by a different
|
718 |
|
|
name (these are typically environments where a specialized form of GDB
|
719 |
|
|
may need to coexist with other forms, hence a different name for the
|
720 |
|
|
specialized version's init file). These are the environments with
|
721 |
|
|
special init file names:
|
722 |
|
|
|
723 |
|
|
* VxWorks (Wind River Systems real-time OS): `.vxgdbinit'
|
724 |
|
|
|
725 |
|
|
* OS68K (Enea Data Systems real-time OS): `.os68gdbinit'
|
726 |
|
|
|
727 |
|
|
* ES-1800 (Ericsson Telecom AB M68000 emulator): `.esgdbinit'
|
728 |
|
|
|
729 |
|
|
You can also request the execution of a command file with the
|
730 |
|
|
`source' command:
|
731 |
|
|
|
732 |
|
|
`source FILENAME'
|
733 |
|
|
Execute the command file FILENAME.
|
734 |
|
|
|
735 |
|
|
The lines in a command file are executed sequentially. They are not
|
736 |
|
|
printed as they are executed. An error in any command terminates
|
737 |
|
|
execution of the command file and control is returned to the console.
|
738 |
|
|
|
739 |
|
|
Commands that would ask for confirmation if used interactively
|
740 |
|
|
proceed without asking when used in a command file. Many GDB commands
|
741 |
|
|
that normally print messages to say what they are doing omit the
|
742 |
|
|
messages when called from command files.
|
743 |
|
|
|
744 |
|
|
GDB also accepts command input from standard input. In this mode,
|
745 |
|
|
normal output goes to standard output and error output goes to standard
|
746 |
|
|
error. Errors in a command file supplied on standard input do not
|
747 |
|
|
terminate execution of the command file -- execution continues with the
|
748 |
|
|
next command.
|
749 |
|
|
|
750 |
|
|
gdb < cmds > log 2>&1
|
751 |
|
|
|
752 |
|
|
(The syntax above will vary depending on the shell used.) This
|
753 |
|
|
example will execute commands from the file `cmds'. All output and
|
754 |
|
|
errors would be directed to `log'.
|
755 |
|
|
|
756 |
|
|
---------- Footnotes ----------
|
757 |
|
|
|
758 |
|
|
(1) The DJGPP port of GDB uses the name `gdb.ini' instead, due to the
|
759 |
|
|
limitations of file names imposed by DOS filesystems.
|
760 |
|
|
|
761 |
|
|
(2) On DOS/Windows systems, the home directory is the one pointed to
|
762 |
|
|
by the `HOME' environment variable.
|
763 |
|
|
|
764 |
|
|
|
765 |
|
|
File: gdb.info, Node: Output, Prev: Command Files, Up: Sequences
|
766 |
|
|
|
767 |
|
|
Commands for controlled output
|
768 |
|
|
==============================
|
769 |
|
|
|
770 |
|
|
During the execution of a command file or a user-defined command,
|
771 |
|
|
normal GDB output is suppressed; the only output that appears is what is
|
772 |
|
|
explicitly printed by the commands in the definition. This section
|
773 |
|
|
describes three commands useful for generating exactly the output you
|
774 |
|
|
want.
|
775 |
|
|
|
776 |
|
|
`echo TEXT'
|
777 |
|
|
Print TEXT. Nonprinting characters can be included in TEXT using
|
778 |
|
|
C escape sequences, such as `\n' to print a newline. *No newline
|
779 |
|
|
is printed unless you specify one.* In addition to the standard C
|
780 |
|
|
escape sequences, a backslash followed by a space stands for a
|
781 |
|
|
space. This is useful for displaying a string with spaces at the
|
782 |
|
|
beginning or the end, since leading and trailing spaces are
|
783 |
|
|
otherwise trimmed from all arguments. To print ` and foo = ', use
|
784 |
|
|
the command `echo \ and foo = \ '.
|
785 |
|
|
|
786 |
|
|
A backslash at the end of TEXT can be used, as in C, to continue
|
787 |
|
|
the command onto subsequent lines. For example,
|
788 |
|
|
|
789 |
|
|
echo This is some text\n\
|
790 |
|
|
which is continued\n\
|
791 |
|
|
onto several lines.\n
|
792 |
|
|
|
793 |
|
|
produces the same output as
|
794 |
|
|
|
795 |
|
|
echo This is some text\n
|
796 |
|
|
echo which is continued\n
|
797 |
|
|
echo onto several lines.\n
|
798 |
|
|
|
799 |
|
|
`output EXPRESSION'
|
800 |
|
|
Print the value of EXPRESSION and nothing but that value: no
|
801 |
|
|
newlines, no `$NN = '. The value is not entered in the value
|
802 |
|
|
history either. *Note Expressions: Expressions, for more
|
803 |
|
|
information on expressions.
|
804 |
|
|
|
805 |
|
|
`output/FMT EXPRESSION'
|
806 |
|
|
Print the value of EXPRESSION in format FMT. You can use the same
|
807 |
|
|
formats as for `print'. *Note Output formats: Output Formats, for
|
808 |
|
|
more information.
|
809 |
|
|
|
810 |
|
|
`printf STRING, EXPRESSIONS...'
|
811 |
|
|
Print the values of the EXPRESSIONS under the control of STRING.
|
812 |
|
|
The EXPRESSIONS are separated by commas and may be either numbers
|
813 |
|
|
or pointers. Their values are printed as specified by STRING,
|
814 |
|
|
exactly as if your program were to execute the C subroutine
|
815 |
|
|
|
816 |
|
|
printf (STRING, EXPRESSIONS...);
|
817 |
|
|
|
818 |
|
|
For example, you can print two values in hex like this:
|
819 |
|
|
|
820 |
|
|
printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
|
821 |
|
|
|
822 |
|
|
The only backslash-escape sequences that you can use in the format
|
823 |
|
|
string are the simple ones that consist of backslash followed by a
|
824 |
|
|
letter.
|
825 |
|
|
|
826 |
|
|
|
827 |
|
|
File: gdb.info, Node: TUI, Next: Emacs, Prev: Sequences, Up: Top
|
828 |
|
|
|
829 |
|
|
GDB Text User Interface
|
830 |
|
|
***********************
|
831 |
|
|
|
832 |
|
|
* Menu:
|
833 |
|
|
|
834 |
|
|
* TUI Overview:: TUI overview
|
835 |
|
|
* TUI Keys:: TUI key bindings
|
836 |
|
|
* TUI Single Key Mode:: TUI single key mode
|
837 |
|
|
* TUI Commands:: TUI specific commands
|
838 |
|
|
* TUI Configuration:: TUI configuration variables
|
839 |
|
|
|
840 |
|
|
The GDB Text User Interface, TUI in short, is a terminal interface
|
841 |
|
|
which uses the `curses' library to show the source file, the assembly
|
842 |
|
|
output, the program registers and GDB commands in separate text windows.
|
843 |
|
|
The TUI is available only when GDB is configured with the
|
844 |
|
|
`--enable-tui' configure option (*note Configure Options::).
|
845 |
|
|
|
846 |
|
|
|
847 |
|
|
File: gdb.info, Node: TUI Overview, Next: TUI Keys, Up: TUI
|
848 |
|
|
|
849 |
|
|
TUI overview
|
850 |
|
|
============
|
851 |
|
|
|
852 |
|
|
The TUI has two display modes that can be switched while GDB runs:
|
853 |
|
|
|
854 |
|
|
* A curses (or TUI) mode in which it displays several text windows
|
855 |
|
|
on the terminal.
|
856 |
|
|
|
857 |
|
|
* A standard mode which corresponds to the GDB configured without
|
858 |
|
|
the TUI.
|
859 |
|
|
|
860 |
|
|
In the TUI mode, GDB can display several text window on the terminal:
|
861 |
|
|
|
862 |
|
|
_command_
|
863 |
|
|
This window is the GDB command window with the GDB prompt and the
|
864 |
|
|
GDB outputs. The GDB input is still managed using readline but
|
865 |
|
|
through the TUI. The _command_ window is always visible.
|
866 |
|
|
|
867 |
|
|
_source_
|
868 |
|
|
The source window shows the source file of the program. The
|
869 |
|
|
current line as well as active breakpoints are displayed in this
|
870 |
|
|
window.
|
871 |
|
|
|
872 |
|
|
_assembly_
|
873 |
|
|
The assembly window shows the disassembly output of the program.
|
874 |
|
|
|
875 |
|
|
_register_
|
876 |
|
|
This window shows the processor registers. It detects when a
|
877 |
|
|
register is changed and when this is the case, registers that have
|
878 |
|
|
changed are highlighted.
|
879 |
|
|
|
880 |
|
|
The source and assembly windows show the current program position by
|
881 |
|
|
highlighting the current line and marking them with the `>' marker.
|
882 |
|
|
Breakpoints are also indicated with two markers. A first one indicates
|
883 |
|
|
the breakpoint type:
|
884 |
|
|
|
885 |
|
|
`B'
|
886 |
|
|
Breakpoint which was hit at least once.
|
887 |
|
|
|
888 |
|
|
`b'
|
889 |
|
|
Breakpoint which was never hit.
|
890 |
|
|
|
891 |
|
|
`H'
|
892 |
|
|
Hardware breakpoint which was hit at least once.
|
893 |
|
|
|
894 |
|
|
`h'
|
895 |
|
|
Hardware breakpoint which was never hit.
|
896 |
|
|
|
897 |
|
|
The second marker indicates whether the breakpoint is enabled or not:
|
898 |
|
|
|
899 |
|
|
`+'
|
900 |
|
|
Breakpoint is enabled.
|
901 |
|
|
|
902 |
|
|
`-'
|
903 |
|
|
Breakpoint is disabled.
|
904 |
|
|
|
905 |
|
|
The source, assembly and register windows are attached to the thread
|
906 |
|
|
and the frame position. They are updated when the current thread
|
907 |
|
|
changes, when the frame changes or when the program counter changes.
|
908 |
|
|
These three windows are arranged by the TUI according to several
|
909 |
|
|
layouts. The layout defines which of these three windows are visible.
|
910 |
|
|
The following layouts are available:
|
911 |
|
|
|
912 |
|
|
* source
|
913 |
|
|
|
914 |
|
|
* assembly
|
915 |
|
|
|
916 |
|
|
* source and assembly
|
917 |
|
|
|
918 |
|
|
* source and registers
|
919 |
|
|
|
920 |
|
|
* assembly and registers
|
921 |
|
|
|
922 |
|
|
|
923 |
|
|
On top of the command window a status line gives various information
|
924 |
|
|
concerning the current process begin debugged. The status line is
|
925 |
|
|
updated when the information it shows changes. The following fields
|
926 |
|
|
are displayed:
|
927 |
|
|
|
928 |
|
|
_target_
|
929 |
|
|
Indicates the current gdb target (*note Specifying a Debugging
|
930 |
|
|
Target: Targets.).
|
931 |
|
|
|
932 |
|
|
_process_
|
933 |
|
|
Gives information about the current process or thread number.
|
934 |
|
|
When no process is being debugged, this field is set to `No
|
935 |
|
|
process'.
|
936 |
|
|
|
937 |
|
|
_function_
|
938 |
|
|
Gives the current function name for the selected frame. The name
|
939 |
|
|
is demangled if demangling is turned on (*note Print Settings::).
|
940 |
|
|
When there is no symbol corresponding to the current program
|
941 |
|
|
counter the string `??' is displayed.
|
942 |
|
|
|
943 |
|
|
_line_
|
944 |
|
|
Indicates the current line number for the selected frame. When
|
945 |
|
|
the current line number is not known the string `??' is displayed.
|
946 |
|
|
|
947 |
|
|
_pc_
|
948 |
|
|
Indicates the current program counter address.
|
949 |
|
|
|
950 |
|
|
|
951 |
|
|
File: gdb.info, Node: TUI Keys, Next: TUI Single Key Mode, Prev: TUI Overview, Up: TUI
|
952 |
|
|
|
953 |
|
|
TUI Key Bindings
|
954 |
|
|
================
|
955 |
|
|
|
956 |
|
|
The TUI installs several key bindings in the readline keymaps (*note
|
957 |
|
|
Command Line Editing::). They allow to leave or enter in the TUI mode
|
958 |
|
|
or they operate directly on the TUI layout and windows. The TUI also
|
959 |
|
|
provides a _SingleKey_ keymap which binds several keys directly to GDB
|
960 |
|
|
commands. The following key bindings are installed for both TUI mode
|
961 |
|
|
and the GDB standard mode.
|
962 |
|
|
|
963 |
|
|
`C-x C-a'
|
964 |
|
|
`C-x a'
|
965 |
|
|
`C-x A'
|
966 |
|
|
Enter or leave the TUI mode. When the TUI mode is left, the
|
967 |
|
|
curses window management is left and GDB operates using its
|
968 |
|
|
standard mode writing on the terminal directly. When the TUI mode
|
969 |
|
|
is entered, the control is given back to the curses windows. The
|
970 |
|
|
screen is then refreshed.
|
971 |
|
|
|
972 |
|
|
`C-x 1'
|
973 |
|
|
Use a TUI layout with only one window. The layout will either be
|
974 |
|
|
`source' or `assembly'. When the TUI mode is not active, it will
|
975 |
|
|
switch to the TUI mode.
|
976 |
|
|
|
977 |
|
|
Think of this key binding as the Emacs `C-x 1' binding.
|
978 |
|
|
|
979 |
|
|
`C-x 2'
|
980 |
|
|
Use a TUI layout with at least two windows. When the current
|
981 |
|
|
layout shows already two windows, a next layout with two windows
|
982 |
|
|
is used. When a new layout is chosen, one window will always be
|
983 |
|
|
common to the previous layout and the new one.
|
984 |
|
|
|
985 |
|
|
Think of it as the Emacs `C-x 2' binding.
|
986 |
|
|
|
987 |
|
|
`C-x s'
|
988 |
|
|
Use the TUI _SingleKey_ keymap that binds single key to gdb
|
989 |
|
|
commands (*note TUI Single Key Mode::).
|
990 |
|
|
|
991 |
|
|
The following key bindings are handled only by the TUI mode:
|
992 |
|
|
|
993 |
|
|
|
994 |
|
|
Scroll the active window one page up.
|
995 |
|
|
|
996 |
|
|
|
997 |
|
|
Scroll the active window one page down.
|
998 |
|
|
|
999 |
|
|
|
1000 |
|
|
Scroll the active window one line up.
|
1001 |
|
|
|
1002 |
|
|
|
1003 |
|
|
Scroll the active window one line down.
|
1004 |
|
|
|
1005 |
|
|
|
1006 |
|
|
Scroll the active window one column left.
|
1007 |
|
|
|
1008 |
|
|
|
1009 |
|
|
Scroll the active window one column right.
|
1010 |
|
|
|
1011 |
|
|
|
1012 |
|
|
Refresh the screen.
|
1013 |
|
|
|
1014 |
|
|
In the TUI mode, the arrow keys are used by the active window for
|
1015 |
|
|
scrolling. This means they are not available for readline. It is
|
1016 |
|
|
necessary to use other readline key bindings such as , ,
|
1017 |
|
|
and .
|
1018 |
|
|
|
1019 |
|
|
|
1020 |
|
|
File: gdb.info, Node: TUI Single Key Mode, Next: TUI Commands, Prev: TUI Keys, Up: TUI
|
1021 |
|
|
|
1022 |
|
|
TUI Single Key Mode
|
1023 |
|
|
===================
|
1024 |
|
|
|
1025 |
|
|
The TUI provides a _SingleKey_ mode in which it installs a particular
|
1026 |
|
|
key binding in the readline keymaps to connect single keys to some gdb
|
1027 |
|
|
commands.
|
1028 |
|
|
|
1029 |
|
|
`c'
|
1030 |
|
|
continue
|
1031 |
|
|
|
1032 |
|
|
`d'
|
1033 |
|
|
down
|
1034 |
|
|
|
1035 |
|
|
`f'
|
1036 |
|
|
finish
|
1037 |
|
|
|
1038 |
|
|
`n'
|
1039 |
|
|
next
|
1040 |
|
|
|
1041 |
|
|
`q'
|
1042 |
|
|
exit the _SingleKey_ mode.
|
1043 |
|
|
|
1044 |
|
|
`r'
|
1045 |
|
|
run
|
1046 |
|
|
|
1047 |
|
|
`s'
|
1048 |
|
|
step
|
1049 |
|
|
|
1050 |
|
|
`u'
|
1051 |
|
|
up
|
1052 |
|
|
|
1053 |
|
|
`v'
|
1054 |
|
|
info locals
|
1055 |
|
|
|
1056 |
|
|
`w'
|
1057 |
|
|
where
|
1058 |
|
|
|
1059 |
|
|
Other keys temporarily switch to the GDB command prompt. The key
|
1060 |
|
|
that was pressed is inserted in the editing buffer so that it is
|
1061 |
|
|
possible to type most GDB commands without interaction with the TUI
|
1062 |
|
|
_SingleKey_ mode. Once the command is entered the TUI _SingleKey_ mode
|
1063 |
|
|
is restored. The only way to permanently leave this mode is by hitting
|
1064 |
|
|
or ` '.
|
1065 |
|
|
|
1066 |
|
|
|
1067 |
|
|
File: gdb.info, Node: TUI Commands, Next: TUI Configuration, Prev: TUI Single Key Mode, Up: TUI
|
1068 |
|
|
|
1069 |
|
|
TUI specific commands
|
1070 |
|
|
=====================
|
1071 |
|
|
|
1072 |
|
|
The TUI has specific commands to control the text windows. These
|
1073 |
|
|
commands are always available, that is they do not depend on the
|
1074 |
|
|
current terminal mode in which GDB runs. When GDB is in the standard
|
1075 |
|
|
mode, using these commands will automatically switch in the TUI mode.
|
1076 |
|
|
|
1077 |
|
|
`info win'
|
1078 |
|
|
List and give the size of all displayed windows.
|
1079 |
|
|
|
1080 |
|
|
`layout next'
|
1081 |
|
|
Display the next layout.
|
1082 |
|
|
|
1083 |
|
|
`layout prev'
|
1084 |
|
|
Display the previous layout.
|
1085 |
|
|
|
1086 |
|
|
`layout src'
|
1087 |
|
|
Display the source window only.
|
1088 |
|
|
|
1089 |
|
|
`layout asm'
|
1090 |
|
|
Display the assembly window only.
|
1091 |
|
|
|
1092 |
|
|
`layout split'
|
1093 |
|
|
Display the source and assembly window.
|
1094 |
|
|
|
1095 |
|
|
`layout regs'
|
1096 |
|
|
Display the register window together with the source or assembly
|
1097 |
|
|
window.
|
1098 |
|
|
|
1099 |
|
|
`focus next | prev | src | asm | regs | split'
|
1100 |
|
|
Set the focus to the named window. This command allows to change
|
1101 |
|
|
the active window so that scrolling keys can be affected to
|
1102 |
|
|
another window.
|
1103 |
|
|
|
1104 |
|
|
`refresh'
|
1105 |
|
|
Refresh the screen. This is similar to using key.
|
1106 |
|
|
|
1107 |
|
|
`update'
|
1108 |
|
|
Update the source window and the current execution point.
|
1109 |
|
|
|
1110 |
|
|
`winheight NAME +COUNT'
|
1111 |
|
|
`winheight NAME -COUNT'
|
1112 |
|
|
Change the height of the window NAME by COUNT lines. Positive
|
1113 |
|
|
counts increase the height, while negative counts decrease it.
|
1114 |
|
|
|
1115 |
|
|
|
1116 |
|
|
File: gdb.info, Node: TUI Configuration, Prev: TUI Commands, Up: TUI
|
1117 |
|
|
|
1118 |
|
|
TUI configuration variables
|
1119 |
|
|
===========================
|
1120 |
|
|
|
1121 |
|
|
The TUI has several configuration variables that control the
|
1122 |
|
|
appearance of windows on the terminal.
|
1123 |
|
|
|
1124 |
|
|
`set tui border-kind KIND'
|
1125 |
|
|
Select the border appearance for the source, assembly and register
|
1126 |
|
|
windows. The possible values are the following:
|
1127 |
|
|
`space'
|
1128 |
|
|
Use a space character to draw the border.
|
1129 |
|
|
|
1130 |
|
|
`ascii'
|
1131 |
|
|
Use ascii characters + - and | to draw the border.
|
1132 |
|
|
|
1133 |
|
|
`acs'
|
1134 |
|
|
Use the Alternate Character Set to draw the border. The
|
1135 |
|
|
border is drawn using character line graphics if the terminal
|
1136 |
|
|
supports them.
|
1137 |
|
|
|
1138 |
|
|
`set tui active-border-mode MODE'
|
1139 |
|
|
Select the attributes to display the border of the active window.
|
1140 |
|
|
The possible values are `normal', `standout', `reverse', `half',
|
1141 |
|
|
`half-standout', `bold' and `bold-standout'.
|
1142 |
|
|
|
1143 |
|
|
`set tui border-mode MODE'
|
1144 |
|
|
Select the attributes to display the border of other windows. The
|
1145 |
|
|
MODE can be one of the following:
|
1146 |
|
|
`normal'
|
1147 |
|
|
Use normal attributes to display the border.
|
1148 |
|
|
|
1149 |
|
|
`standout'
|
1150 |
|
|
Use standout mode.
|
1151 |
|
|
|
1152 |
|
|
`reverse'
|
1153 |
|
|
Use reverse video mode.
|
1154 |
|
|
|
1155 |
|
|
`half'
|
1156 |
|
|
Use half bright mode.
|
1157 |
|
|
|
1158 |
|
|
`half-standout'
|
1159 |
|
|
Use half bright and standout mode.
|
1160 |
|
|
|
1161 |
|
|
`bold'
|
1162 |
|
|
Use extra bright or bold mode.
|
1163 |
|
|
|
1164 |
|
|
`bold-standout'
|
1165 |
|
|
Use extra bright or bold and standout mode.
|
1166 |
|
|
|
1167 |
|
|
|
1168 |
|
|
File: gdb.info, Node: Emacs, Next: Annotations, Prev: TUI, Up: Top
|
1169 |
|
|
|
1170 |
|
|
Using GDB under GNU Emacs
|
1171 |
|
|
*************************
|
1172 |
|
|
|
1173 |
|
|
A special interface allows you to use GNU Emacs to view (and edit)
|
1174 |
|
|
the source files for the program you are debugging with GDB.
|
1175 |
|
|
|
1176 |
|
|
To use this interface, use the command `M-x gdb' in Emacs. Give the
|
1177 |
|
|
executable file you want to debug as an argument. This command starts
|
1178 |
|
|
GDB as a subprocess of Emacs, with input and output through a newly
|
1179 |
|
|
created Emacs buffer.
|
1180 |
|
|
|
1181 |
|
|
Using GDB under Emacs is just like using GDB normally except for two
|
1182 |
|
|
things:
|
1183 |
|
|
|
1184 |
|
|
* All "terminal" input and output goes through the Emacs buffer.
|
1185 |
|
|
|
1186 |
|
|
This applies both to GDB commands and their output, and to the input
|
1187 |
|
|
and output done by the program you are debugging.
|
1188 |
|
|
|
1189 |
|
|
This is useful because it means that you can copy the text of
|
1190 |
|
|
previous commands and input them again; you can even use parts of the
|
1191 |
|
|
output in this way.
|
1192 |
|
|
|
1193 |
|
|
All the facilities of Emacs' Shell mode are available for interacting
|
1194 |
|
|
with your program. In particular, you can send signals the usual
|
1195 |
|
|
way--for example, `C-c C-c' for an interrupt, `C-c C-z' for a stop.
|
1196 |
|
|
|
1197 |
|
|
* GDB displays source code through Emacs.
|
1198 |
|
|
|
1199 |
|
|
Each time GDB displays a stack frame, Emacs automatically finds the
|
1200 |
|
|
source file for that frame and puts an arrow (`=>') at the left margin
|
1201 |
|
|
of the current line. Emacs uses a separate buffer for source display,
|
1202 |
|
|
and splits the screen to show both your GDB session and the source.
|
1203 |
|
|
|
1204 |
|
|
Explicit GDB `list' or search commands still produce output as
|
1205 |
|
|
usual, but you probably have no reason to use them from Emacs.
|
1206 |
|
|
|
1207 |
|
|
_Warning:_ If the directory where your program resides is not your
|
1208 |
|
|
current directory, it can be easy to confuse Emacs about the
|
1209 |
|
|
location of the source files, in which case the auxiliary display
|
1210 |
|
|
buffer does not appear to show your source. GDB can find programs
|
1211 |
|
|
by searching your environment's `PATH' variable, so the GDB input
|
1212 |
|
|
and output session proceeds normally; but Emacs does not get
|
1213 |
|
|
enough information back from GDB to locate the source files in
|
1214 |
|
|
this situation. To avoid this problem, either start GDB mode from
|
1215 |
|
|
the directory where your program resides, or specify an absolute
|
1216 |
|
|
file name when prompted for the `M-x gdb' argument.
|
1217 |
|
|
|
1218 |
|
|
A similar confusion can result if you use the GDB `file' command to
|
1219 |
|
|
switch to debugging a program in some other location, from an
|
1220 |
|
|
existing GDB buffer in Emacs.
|
1221 |
|
|
|
1222 |
|
|
By default, `M-x gdb' calls the program called `gdb'. If you need
|
1223 |
|
|
to call GDB by a different name (for example, if you keep several
|
1224 |
|
|
configurations around, with different names) you can set the Emacs
|
1225 |
|
|
variable `gdb-command-name'; for example,
|
1226 |
|
|
|
1227 |
|
|
(setq gdb-command-name "mygdb")
|
1228 |
|
|
|
1229 |
|
|
(preceded by `M-:' or `ESC :', or typed in the `*scratch*' buffer, or
|
1230 |
|
|
in your `.emacs' file) makes Emacs call the program named "`mygdb'"
|
1231 |
|
|
instead.
|
1232 |
|
|
|
1233 |
|
|
In the GDB I/O buffer, you can use these special Emacs commands in
|
1234 |
|
|
addition to the standard Shell mode commands:
|
1235 |
|
|
|
1236 |
|
|
`C-h m'
|
1237 |
|
|
Describe the features of Emacs' GDB Mode.
|
1238 |
|
|
|
1239 |
|
|
`M-s'
|
1240 |
|
|
Execute to another source line, like the GDB `step' command; also
|
1241 |
|
|
update the display window to show the current file and location.
|
1242 |
|
|
|
1243 |
|
|
`M-n'
|
1244 |
|
|
Execute to next source line in this function, skipping all function
|
1245 |
|
|
calls, like the GDB `next' command. Then update the display window
|
1246 |
|
|
to show the current file and location.
|
1247 |
|
|
|
1248 |
|
|
`M-i'
|
1249 |
|
|
Execute one instruction, like the GDB `stepi' command; update
|
1250 |
|
|
display window accordingly.
|
1251 |
|
|
|
1252 |
|
|
`M-x gdb-nexti'
|
1253 |
|
|
Execute to next instruction, using the GDB `nexti' command; update
|
1254 |
|
|
display window accordingly.
|
1255 |
|
|
|
1256 |
|
|
`C-c C-f'
|
1257 |
|
|
Execute until exit from the selected stack frame, like the GDB
|
1258 |
|
|
`finish' command.
|
1259 |
|
|
|
1260 |
|
|
`M-c'
|
1261 |
|
|
Continue execution of your program, like the GDB `continue'
|
1262 |
|
|
command.
|
1263 |
|
|
|
1264 |
|
|
_Warning:_ In Emacs v19, this command is `C-c C-p'.
|
1265 |
|
|
|
1266 |
|
|
`M-u'
|
1267 |
|
|
Go up the number of frames indicated by the numeric argument
|
1268 |
|
|
(*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'
|
1269 |
|
|
command.
|
1270 |
|
|
|
1271 |
|
|
_Warning:_ In Emacs v19, this command is `C-c C-u'.
|
1272 |
|
|
|
1273 |
|
|
`M-d'
|
1274 |
|
|
Go down the number of frames indicated by the numeric argument,
|
1275 |
|
|
like the GDB `down' command.
|
1276 |
|
|
|
1277 |
|
|
_Warning:_ In Emacs v19, this command is `C-c C-d'.
|
1278 |
|
|
|
1279 |
|
|
`C-x &'
|
1280 |
|
|
Read the number where the cursor is positioned, and insert it at
|
1281 |
|
|
the end of the GDB I/O buffer. For example, if you wish to
|
1282 |
|
|
disassemble code around an address that was displayed earlier,
|
1283 |
|
|
type `disassemble'; then move the cursor to the address display,
|
1284 |
|
|
and pick up the argument for `disassemble' by typing `C-x &'.
|
1285 |
|
|
|
1286 |
|
|
You can customize this further by defining elements of the list
|
1287 |
|
|
`gdb-print-command'; once it is defined, you can format or
|
1288 |
|
|
otherwise process numbers picked up by `C-x &' before they are
|
1289 |
|
|
inserted. A numeric argument to `C-x &' indicates that you wish
|
1290 |
|
|
special formatting, and also acts as an index to pick an element
|
1291 |
|
|
of the list. If the list element is a string, the number to be
|
1292 |
|
|
inserted is formatted using the Emacs function `format'; otherwise
|
1293 |
|
|
the number is passed as an argument to the corresponding list
|
1294 |
|
|
element.
|
1295 |
|
|
|
1296 |
|
|
In any source file, the Emacs command `C-x SPC' (`gdb-break') tells
|
1297 |
|
|
GDB to set a breakpoint on the source line point is on.
|
1298 |
|
|
|
1299 |
|
|
If you accidentally delete the source-display buffer, an easy way to
|
1300 |
|
|
get it back is to type the command `f' in the GDB buffer, to request a
|
1301 |
|
|
frame display; when you run under Emacs, this recreates the source
|
1302 |
|
|
buffer if necessary to show you the context of the current frame.
|
1303 |
|
|
|
1304 |
|
|
The source files displayed in Emacs are in ordinary Emacs buffers
|
1305 |
|
|
which are visiting the source files in the usual way. You can edit the
|
1306 |
|
|
files with these buffers if you wish; but keep in mind that GDB
|
1307 |
|
|
communicates with Emacs in terms of line numbers. If you add or delete
|
1308 |
|
|
lines from the text, the line numbers that GDB knows cease to
|
1309 |
|
|
correspond properly with the code.
|
1310 |
|
|
|
1311 |
|
|
|
1312 |
|
|
File: gdb.info, Node: Annotations, Next: GDB/MI, Prev: Emacs, Up: Top
|
1313 |
|
|
|
1314 |
|
|
GDB Annotations
|
1315 |
|
|
***************
|
1316 |
|
|
|
1317 |
|
|
This chapter describes annotations in GDB. Annotations are designed
|
1318 |
|
|
to interface GDB to graphical user interfaces or other similar programs
|
1319 |
|
|
which want to interact with GDB at a relatively high level.
|
1320 |
|
|
|
1321 |
|
|
* Menu:
|
1322 |
|
|
|
1323 |
|
|
* Annotations Overview:: What annotations are; the general syntax.
|
1324 |
|
|
* Server Prefix:: Issuing a command without affecting user state.
|
1325 |
|
|
* Value Annotations:: Values are marked as such.
|
1326 |
|
|
* Frame Annotations:: Stack frames are annotated.
|
1327 |
|
|
* Displays:: GDB can be told to display something periodically.
|
1328 |
|
|
* Prompting:: Annotations marking GDB's need for input.
|
1329 |
|
|
* Errors:: Annotations for error messages.
|
1330 |
|
|
* Breakpoint Info:: Information on breakpoints.
|
1331 |
|
|
* Invalidation:: Some annotations describe things now invalid.
|
1332 |
|
|
* Annotations for Running::
|
1333 |
|
|
Whether the program is running, how it stopped, etc.
|
1334 |
|
|
* Source Annotations:: Annotations describing source code.
|
1335 |
|
|
* TODO:: Annotations which might be added in the future.
|
1336 |
|
|
|
1337 |
|
|
|
1338 |
|
|
File: gdb.info, Node: Annotations Overview, Next: Server Prefix, Up: Annotations
|
1339 |
|
|
|
1340 |
|
|
What is an Annotation?
|
1341 |
|
|
======================
|
1342 |
|
|
|
1343 |
|
|
To produce annotations, start GDB with the `--annotate=2' option.
|
1344 |
|
|
|
1345 |
|
|
Annotations start with a newline character, two `control-z'
|
1346 |
|
|
characters, and the name of the annotation. If there is no additional
|
1347 |
|
|
information associated with this annotation, the name of the annotation
|
1348 |
|
|
is followed immediately by a newline. If there is additional
|
1349 |
|
|
information, the name of the annotation is followed by a space, the
|
1350 |
|
|
additional information, and a newline. The additional information
|
1351 |
|
|
cannot contain newline characters.
|
1352 |
|
|
|
1353 |
|
|
Any output not beginning with a newline and two `control-z'
|
1354 |
|
|
characters denotes literal output from GDB. Currently there is no need
|
1355 |
|
|
for GDB to output a newline followed by two `control-z' characters, but
|
1356 |
|
|
if there was such a need, the annotations could be extended with an
|
1357 |
|
|
`escape' annotation which means those three characters as output.
|
1358 |
|
|
|
1359 |
|
|
A simple example of starting up GDB with annotations is:
|
1360 |
|
|
|
1361 |
|
|
$ gdb --annotate=2
|
1362 |
|
|
GNU GDB 5.0
|
1363 |
|
|
Copyright 2000 Free Software Foundation, Inc.
|
1364 |
|
|
GDB is free software, covered by the GNU General Public License,
|
1365 |
|
|
and you are welcome to change it and/or distribute copies of it
|
1366 |
|
|
under certain conditions.
|
1367 |
|
|
Type "show copying" to see the conditions.
|
1368 |
|
|
There is absolutely no warranty for GDB. Type "show warranty"
|
1369 |
|
|
for details.
|
1370 |
|
|
This GDB was configured as "sparc-sun-sunos4.1.3"
|
1371 |
|
|
|
1372 |
|
|
^Z^Zpre-prompt
|
1373 |
|
|
(gdb)
|
1374 |
|
|
^Z^Zprompt
|
1375 |
|
|
quit
|
1376 |
|
|
|
1377 |
|
|
^Z^Zpost-prompt
|
1378 |
|
|
$
|
1379 |
|
|
|
1380 |
|
|
Here `quit' is input to GDB; the rest is output from GDB. The three
|
1381 |
|
|
lines beginning `^Z^Z' (where `^Z' denotes a `control-z' character) are
|
1382 |
|
|
annotations; the rest is output from GDB.
|
1383 |
|
|
|
1384 |
|
|
|
1385 |
|
|
File: gdb.info, Node: Server Prefix, Next: Value Annotations, Prev: Annotations Overview, Up: Annotations
|
1386 |
|
|
|
1387 |
|
|
The Server Prefix
|
1388 |
|
|
=================
|
1389 |
|
|
|
1390 |
|
|
To issue a command to GDB without affecting certain aspects of the
|
1391 |
|
|
state which is seen by users, prefix it with `server '. This means
|
1392 |
|
|
that this command will not affect the command history, nor will it
|
1393 |
|
|
affect GDB's notion of which command to repeat if is pressed on a
|
1394 |
|
|
line by itself.
|
1395 |
|
|
|
1396 |
|
|
The server prefix does not affect the recording of values into the
|
1397 |
|
|
value history; to print a value without recording it into the value
|
1398 |
|
|
history, use the `output' command instead of the `print' command.
|
1399 |
|
|
|