1 |
342 |
jeremybenn |
This is gdb.info, produced by makeinfo version 4.13 from ./gdb.texinfo.
|
2 |
330 |
jeremybenn |
|
3 |
|
|
INFO-DIR-SECTION Software development
|
4 |
|
|
START-INFO-DIR-ENTRY
|
5 |
|
|
* Gdb: (gdb). The GNU debugger.
|
6 |
|
|
END-INFO-DIR-ENTRY
|
7 |
|
|
|
8 |
|
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
|
9 |
|
|
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
10 |
|
|
2010 Free Software Foundation, Inc.
|
11 |
|
|
|
12 |
|
|
Permission is granted to copy, distribute and/or modify this document
|
13 |
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
14 |
|
|
any later version published by the Free Software Foundation; with the
|
15 |
|
|
Invariant Sections being "Free Software" and "Free Software Needs Free
|
16 |
|
|
Documentation", with the Front-Cover Texts being "A GNU Manual," and
|
17 |
|
|
with the Back-Cover Texts as in (a) below.
|
18 |
|
|
|
19 |
|
|
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
|
20 |
|
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
21 |
|
|
developing GNU and promoting software freedom."
|
22 |
|
|
|
23 |
|
|
This file documents the GNU debugger GDB.
|
24 |
|
|
|
25 |
|
|
This is the Ninth Edition, of `Debugging with GDB: the GNU
|
26 |
512 |
jeremybenn |
Source-Level Debugger' for GDB (GDB) Version 7.2-or32-1.0rc3.
|
27 |
330 |
jeremybenn |
|
28 |
|
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
|
29 |
|
|
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
30 |
|
|
2010 Free Software Foundation, Inc.
|
31 |
|
|
|
32 |
|
|
Permission is granted to copy, distribute and/or modify this document
|
33 |
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
34 |
|
|
any later version published by the Free Software Foundation; with the
|
35 |
|
|
Invariant Sections being "Free Software" and "Free Software Needs Free
|
36 |
|
|
Documentation", with the Front-Cover Texts being "A GNU Manual," and
|
37 |
|
|
with the Back-Cover Texts as in (a) below.
|
38 |
|
|
|
39 |
|
|
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
|
40 |
|
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
41 |
|
|
developing GNU and promoting software freedom."
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
File: gdb.info, Node: DJGPP Native, Next: Cygwin Native, Prev: SVR4 Process Information, Up: Native
|
45 |
|
|
|
46 |
|
|
21.1.4 Features for Debugging DJGPP Programs
|
47 |
|
|
--------------------------------------------
|
48 |
|
|
|
49 |
|
|
DJGPP is a port of the GNU development tools to MS-DOS and MS-Windows.
|
50 |
|
|
DJGPP programs are 32-bit protected-mode programs that use the "DPMI"
|
51 |
|
|
(DOS Protected-Mode Interface) API to run on top of real-mode DOS
|
52 |
|
|
systems and their emulations.
|
53 |
|
|
|
54 |
|
|
GDB supports native debugging of DJGPP programs, and defines a few
|
55 |
|
|
commands specific to the DJGPP port. This subsection describes those
|
56 |
|
|
commands.
|
57 |
|
|
|
58 |
|
|
`info dos'
|
59 |
|
|
This is a prefix of DJGPP-specific commands which print
|
60 |
|
|
information about the target system and important OS structures.
|
61 |
|
|
|
62 |
|
|
`info dos sysinfo'
|
63 |
|
|
This command displays assorted information about the underlying
|
64 |
|
|
platform: the CPU type and features, the OS version and flavor, the
|
65 |
|
|
DPMI version, and the available conventional and DPMI memory.
|
66 |
|
|
|
67 |
|
|
`info dos gdt'
|
68 |
|
|
`info dos ldt'
|
69 |
|
|
`info dos idt'
|
70 |
|
|
These 3 commands display entries from, respectively, Global, Local,
|
71 |
|
|
and Interrupt Descriptor Tables (GDT, LDT, and IDT). The
|
72 |
|
|
descriptor tables are data structures which store a descriptor for
|
73 |
|
|
each segment that is currently in use. The segment's selector is
|
74 |
|
|
an index into a descriptor table; the table entry for that index
|
75 |
|
|
holds the descriptor's base address and limit, and its attributes
|
76 |
|
|
and access rights.
|
77 |
|
|
|
78 |
|
|
A typical DJGPP program uses 3 segments: a code segment, a data
|
79 |
|
|
segment (used for both data and the stack), and a DOS segment
|
80 |
|
|
(which allows access to DOS/BIOS data structures and absolute
|
81 |
|
|
addresses in conventional memory). However, the DPMI host will
|
82 |
|
|
usually define additional segments in order to support the DPMI
|
83 |
|
|
environment.
|
84 |
|
|
|
85 |
|
|
These commands allow to display entries from the descriptor tables.
|
86 |
|
|
Without an argument, all entries from the specified table are
|
87 |
|
|
displayed. An argument, which should be an integer expression,
|
88 |
|
|
means display a single entry whose index is given by the argument.
|
89 |
|
|
For example, here's a convenient way to display information about
|
90 |
|
|
the debugged program's data segment:
|
91 |
|
|
|
92 |
|
|
`(gdb) info dos ldt $ds'
|
93 |
|
|
`0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)'
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
This comes in handy when you want to see whether a pointer is
|
97 |
|
|
outside the data segment's limit (i.e. "garbled").
|
98 |
|
|
|
99 |
|
|
`info dos pde'
|
100 |
|
|
`info dos pte'
|
101 |
|
|
These two commands display entries from, respectively, the Page
|
102 |
|
|
Directory and the Page Tables. Page Directories and Page Tables
|
103 |
|
|
are data structures which control how virtual memory addresses are
|
104 |
|
|
mapped into physical addresses. A Page Table includes an entry
|
105 |
|
|
for every page of memory that is mapped into the program's address
|
106 |
|
|
space; there may be several Page Tables, each one holding up to
|
107 |
|
|
4096 entries. A Page Directory has up to 4096 entries, one each
|
108 |
|
|
for every Page Table that is currently in use.
|
109 |
|
|
|
110 |
|
|
Without an argument, `info dos pde' displays the entire Page
|
111 |
|
|
Directory, and `info dos pte' displays all the entries in all of
|
112 |
|
|
the Page Tables. An argument, an integer expression, given to the
|
113 |
|
|
`info dos pde' command means display only that entry from the Page
|
114 |
|
|
Directory table. An argument given to the `info dos pte' command
|
115 |
|
|
means display entries from a single Page Table, the one pointed to
|
116 |
|
|
by the specified entry in the Page Directory.
|
117 |
|
|
|
118 |
|
|
These commands are useful when your program uses "DMA" (Direct
|
119 |
|
|
Memory Access), which needs physical addresses to program the DMA
|
120 |
|
|
controller.
|
121 |
|
|
|
122 |
|
|
These commands are supported only with some DPMI servers.
|
123 |
|
|
|
124 |
|
|
`info dos address-pte ADDR'
|
125 |
|
|
This command displays the Page Table entry for a specified linear
|
126 |
|
|
address. The argument ADDR is a linear address which should
|
127 |
|
|
already have the appropriate segment's base address added to it,
|
128 |
|
|
because this command accepts addresses which may belong to _any_
|
129 |
|
|
segment. For example, here's how to display the Page Table entry
|
130 |
|
|
for the page where a variable `i' is stored:
|
131 |
|
|
|
132 |
|
|
`(gdb) info dos address-pte __djgpp_base_address + (char *)&i'
|
133 |
|
|
`Page Table entry for address 0x11a00d30:'
|
134 |
|
|
`Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30'
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
This says that `i' is stored at offset `0xd30' from the page whose
|
138 |
|
|
physical base address is `0x02698000', and shows all the
|
139 |
|
|
attributes of that page.
|
140 |
|
|
|
141 |
|
|
Note that you must cast the addresses of variables to a `char *',
|
142 |
|
|
since otherwise the value of `__djgpp_base_address', the base
|
143 |
|
|
address of all variables and functions in a DJGPP program, will be
|
144 |
|
|
added using the rules of C pointer arithmetics: if `i' is declared
|
145 |
|
|
an `int', GDB will add 4 times the value of `__djgpp_base_address'
|
146 |
|
|
to the address of `i'.
|
147 |
|
|
|
148 |
|
|
Here's another example, it displays the Page Table entry for the
|
149 |
|
|
transfer buffer:
|
150 |
|
|
|
151 |
|
|
`(gdb) info dos address-pte *((unsigned *)&_go32_info_block + 3)'
|
152 |
|
|
`Page Table entry for address 0x29110:'
|
153 |
|
|
`Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110'
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
(The `+ 3' offset is because the transfer buffer's address is the
|
157 |
|
|
3rd member of the `_go32_info_block' structure.) The output
|
158 |
|
|
clearly shows that this DPMI server maps the addresses in
|
159 |
|
|
conventional memory 1:1, i.e. the physical (`0x00029000' +
|
160 |
|
|
`0x110') and linear (`0x29110') addresses are identical.
|
161 |
|
|
|
162 |
|
|
This command is supported only with some DPMI servers.
|
163 |
|
|
|
164 |
|
|
In addition to native debugging, the DJGPP port supports remote
|
165 |
|
|
debugging via a serial data link. The following commands are specific
|
166 |
|
|
to remote serial debugging in the DJGPP port of GDB.
|
167 |
|
|
|
168 |
|
|
`set com1base ADDR'
|
169 |
|
|
This command sets the base I/O port address of the `COM1' serial
|
170 |
|
|
port.
|
171 |
|
|
|
172 |
|
|
`set com1irq IRQ'
|
173 |
|
|
This command sets the "Interrupt Request" (`IRQ') line to use for
|
174 |
|
|
the `COM1' serial port.
|
175 |
|
|
|
176 |
|
|
There are similar commands `set com2base', `set com3irq', etc. for
|
177 |
|
|
setting the port address and the `IRQ' lines for the other 3 COM
|
178 |
|
|
ports.
|
179 |
|
|
|
180 |
|
|
The related commands `show com1base', `show com1irq' etc. display
|
181 |
|
|
the current settings of the base address and the `IRQ' lines used
|
182 |
|
|
by the COM ports.
|
183 |
|
|
|
184 |
|
|
`info serial'
|
185 |
|
|
This command prints the status of the 4 DOS serial ports. For each
|
186 |
|
|
port, it prints whether it's active or not, its I/O base address
|
187 |
|
|
and IRQ number, whether it uses a 16550-style FIFO, its baudrate,
|
188 |
|
|
and the counts of various errors encountered so far.
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
File: gdb.info, Node: Cygwin Native, Next: Hurd Native, Prev: DJGPP Native, Up: Native
|
192 |
|
|
|
193 |
|
|
21.1.5 Features for Debugging MS Windows PE Executables
|
194 |
|
|
-------------------------------------------------------
|
195 |
|
|
|
196 |
|
|
GDB supports native debugging of MS Windows programs, including DLLs
|
197 |
|
|
with and without symbolic debugging information.
|
198 |
|
|
|
199 |
|
|
MS-Windows programs that call `SetConsoleMode' to switch off the
|
200 |
|
|
special meaning of the `Ctrl-C' keystroke cannot be interrupted by
|
201 |
|
|
typing `C-c'. For this reason, GDB on MS-Windows supports `C-'
|
202 |
|
|
as an alternative interrupt key sequence, which can be used to
|
203 |
|
|
interrupt the debuggee even if it ignores `C-c'.
|
204 |
|
|
|
205 |
|
|
There are various additional Cygwin-specific commands, described in
|
206 |
|
|
this section. Working with DLLs that have no debugging symbols is
|
207 |
342 |
jeremybenn |
described in *note Non-debug DLL Symbols::.
|
208 |
330 |
jeremybenn |
|
209 |
|
|
`info w32'
|
210 |
|
|
This is a prefix of MS Windows-specific commands which print
|
211 |
|
|
information about the target system and important OS structures.
|
212 |
|
|
|
213 |
|
|
`info w32 selector'
|
214 |
|
|
This command displays information returned by the Win32 API
|
215 |
|
|
`GetThreadSelectorEntry' function. It takes an optional argument
|
216 |
|
|
that is evaluated to a long value to give the information about
|
217 |
|
|
this given selector. Without argument, this command displays
|
218 |
|
|
information about the six segment registers.
|
219 |
|
|
|
220 |
|
|
`info w32 thread-information-block'
|
221 |
|
|
This command displays thread specific information stored in the
|
222 |
|
|
Thread Information Block (readable on the X86 CPU family using
|
223 |
|
|
`$fs' selector for 32-bit programs and `$gs' for 64-bit programs).
|
224 |
|
|
|
225 |
|
|
`info dll'
|
226 |
|
|
This is a Cygwin-specific alias of `info shared'.
|
227 |
|
|
|
228 |
|
|
`dll-symbols'
|
229 |
|
|
This command loads symbols from a dll similarly to add-sym command
|
230 |
|
|
but without the need to specify a base address.
|
231 |
|
|
|
232 |
|
|
`set cygwin-exceptions MODE'
|
233 |
|
|
If MODE is `on', GDB will break on exceptions that happen inside
|
234 |
|
|
the Cygwin DLL. If MODE is `off', GDB will delay recognition of
|
235 |
|
|
exceptions, and may ignore some exceptions which seem to be caused
|
236 |
|
|
by internal Cygwin DLL "bookkeeping". This option is meant
|
237 |
|
|
primarily for debugging the Cygwin DLL itself; the default value
|
238 |
|
|
is `off' to avoid annoying GDB users with false `SIGSEGV' signals.
|
239 |
|
|
|
240 |
|
|
`show cygwin-exceptions'
|
241 |
|
|
Displays whether GDB will break on exceptions that happen inside
|
242 |
|
|
the Cygwin DLL itself.
|
243 |
|
|
|
244 |
|
|
`set new-console MODE'
|
245 |
|
|
If MODE is `on' the debuggee will be started in a new console on
|
246 |
|
|
next start. If MODE is `off', the debuggee will be started in the
|
247 |
|
|
same console as the debugger.
|
248 |
|
|
|
249 |
|
|
`show new-console'
|
250 |
|
|
Displays whether a new console is used when the debuggee is
|
251 |
|
|
started.
|
252 |
|
|
|
253 |
|
|
`set new-group MODE'
|
254 |
|
|
This boolean value controls whether the debuggee should start a
|
255 |
|
|
new group or stay in the same group as the debugger. This affects
|
256 |
|
|
the way the Windows OS handles `Ctrl-C'.
|
257 |
|
|
|
258 |
|
|
`show new-group'
|
259 |
|
|
Displays current value of new-group boolean.
|
260 |
|
|
|
261 |
|
|
`set debugevents'
|
262 |
|
|
This boolean value adds debug output concerning kernel events
|
263 |
|
|
related to the debuggee seen by the debugger. This includes
|
264 |
|
|
events that signal thread and process creation and exit, DLL
|
265 |
|
|
loading and unloading, console interrupts, and debugging messages
|
266 |
|
|
produced by the Windows `OutputDebugString' API call.
|
267 |
|
|
|
268 |
|
|
`set debugexec'
|
269 |
|
|
This boolean value adds debug output concerning execute events
|
270 |
|
|
(such as resume thread) seen by the debugger.
|
271 |
|
|
|
272 |
|
|
`set debugexceptions'
|
273 |
|
|
This boolean value adds debug output concerning exceptions in the
|
274 |
|
|
debuggee seen by the debugger.
|
275 |
|
|
|
276 |
|
|
`set debugmemory'
|
277 |
|
|
This boolean value adds debug output concerning debuggee memory
|
278 |
|
|
reads and writes by the debugger.
|
279 |
|
|
|
280 |
|
|
`set shell'
|
281 |
|
|
This boolean values specifies whether the debuggee is called via a
|
282 |
|
|
shell or directly (default value is on).
|
283 |
|
|
|
284 |
|
|
`show shell'
|
285 |
|
|
Displays if the debuggee will be started with a shell.
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
* Menu:
|
289 |
|
|
|
290 |
|
|
* Non-debug DLL Symbols:: Support for DLLs without debugging symbols
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
File: gdb.info, Node: Non-debug DLL Symbols, Up: Cygwin Native
|
294 |
|
|
|
295 |
|
|
21.1.5.1 Support for DLLs without Debugging Symbols
|
296 |
|
|
...................................................
|
297 |
|
|
|
298 |
|
|
Very often on windows, some of the DLLs that your program relies on do
|
299 |
|
|
not include symbolic debugging information (for example,
|
300 |
|
|
`kernel32.dll'). When GDB doesn't recognize any debugging symbols in a
|
301 |
|
|
DLL, it relies on the minimal amount of symbolic information contained
|
302 |
|
|
in the DLL's export table. This section describes working with such
|
303 |
|
|
symbols, known internally to GDB as "minimal symbols".
|
304 |
|
|
|
305 |
|
|
Note that before the debugged program has started execution, no DLLs
|
306 |
|
|
will have been loaded. The easiest way around this problem is simply to
|
307 |
|
|
start the program -- either by setting a breakpoint or letting the
|
308 |
|
|
program run once to completion. It is also possible to force GDB to
|
309 |
|
|
load a particular DLL before starting the executable -- see the shared
|
310 |
342 |
jeremybenn |
library information in *note Files::, or the `dll-symbols' command in
|
311 |
|
|
*note Cygwin Native::. Currently, explicitly loading symbols from a
|
312 |
330 |
jeremybenn |
DLL with no debugging information will cause the symbol names to be
|
313 |
|
|
duplicated in GDB's lookup table, which may adversely affect symbol
|
314 |
|
|
lookup performance.
|
315 |
|
|
|
316 |
|
|
21.1.5.2 DLL Name Prefixes
|
317 |
|
|
..........................
|
318 |
|
|
|
319 |
|
|
In keeping with the naming conventions used by the Microsoft debugging
|
320 |
|
|
tools, DLL export symbols are made available with a prefix based on the
|
321 |
|
|
DLL name, for instance `KERNEL32!CreateFileA'. The plain name is also
|
322 |
|
|
entered into the symbol table, so `CreateFileA' is often sufficient.
|
323 |
|
|
In some cases there will be name clashes within a program (particularly
|
324 |
|
|
if the executable itself includes full debugging symbols) necessitating
|
325 |
|
|
the use of the fully qualified name when referring to the contents of
|
326 |
|
|
the DLL. Use single-quotes around the name to avoid the exclamation
|
327 |
|
|
mark ("!") being interpreted as a language operator.
|
328 |
|
|
|
329 |
|
|
Note that the internal name of the DLL may be all upper-case, even
|
330 |
|
|
though the file name of the DLL is lower-case, or vice-versa. Since
|
331 |
|
|
symbols within GDB are _case-sensitive_ this may cause some confusion.
|
332 |
|
|
If in doubt, try the `info functions' and `info variables' commands or
|
333 |
|
|
even `maint print msymbols' (*note Symbols::). Here's an example:
|
334 |
|
|
|
335 |
|
|
(gdb) info function CreateFileA
|
336 |
|
|
All functions matching regular expression "CreateFileA":
|
337 |
|
|
|
338 |
|
|
Non-debugging symbols:
|
339 |
|
|
0x77e885f4 CreateFileA
|
340 |
|
|
0x77e885f4 KERNEL32!CreateFileA
|
341 |
|
|
|
342 |
|
|
(gdb) info function !
|
343 |
|
|
All functions matching regular expression "!":
|
344 |
|
|
|
345 |
|
|
Non-debugging symbols:
|
346 |
|
|
0x6100114c cygwin1!__assert
|
347 |
|
|
0x61004034 cygwin1!_dll_crt0@0
|
348 |
|
|
0x61004240 cygwin1!dll_crt0(per_process *)
|
349 |
|
|
[etc...]
|
350 |
|
|
|
351 |
|
|
21.1.5.3 Working with Minimal Symbols
|
352 |
|
|
.....................................
|
353 |
|
|
|
354 |
|
|
Symbols extracted from a DLL's export table do not contain very much
|
355 |
|
|
type information. All that GDB can do is guess whether a symbol refers
|
356 |
|
|
to a function or variable depending on the linker section that contains
|
357 |
|
|
the symbol. Also note that the actual contents of the memory contained
|
358 |
|
|
in a DLL are not available unless the program is running. This means
|
359 |
|
|
that you cannot examine the contents of a variable or disassemble a
|
360 |
|
|
function within a DLL without a running program.
|
361 |
|
|
|
362 |
|
|
Variables are generally treated as pointers and dereferenced
|
363 |
|
|
automatically. For this reason, it is often necessary to prefix a
|
364 |
|
|
variable name with the address-of operator ("&") and provide explicit
|
365 |
|
|
type information in the command. Here's an example of the type of
|
366 |
|
|
problem:
|
367 |
|
|
|
368 |
|
|
(gdb) print 'cygwin1!__argv'
|
369 |
|
|
$1 = 268572168
|
370 |
|
|
|
371 |
|
|
(gdb) x 'cygwin1!__argv'
|
372 |
|
|
0x10021610: "\230y\""
|
373 |
|
|
|
374 |
|
|
And two possible solutions:
|
375 |
|
|
|
376 |
|
|
(gdb) print ((char **)'cygwin1!__argv')[0]
|
377 |
|
|
$2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
|
378 |
|
|
|
379 |
|
|
(gdb) x/2x &'cygwin1!__argv'
|
380 |
|
|
0x610c0aa8 : 0x10021608 0x00000000
|
381 |
|
|
(gdb) x/x 0x10021608
|
382 |
|
|
0x10021608: 0x0022fd98
|
383 |
|
|
(gdb) x/s 0x0022fd98
|
384 |
|
|
0x22fd98: "/cygdrive/c/mydirectory/myprogram"
|
385 |
|
|
|
386 |
|
|
Setting a break point within a DLL is possible even before the
|
387 |
|
|
program starts execution. However, under these circumstances, GDB can't
|
388 |
|
|
examine the initial instructions of the function in order to skip the
|
389 |
|
|
function's frame set-up code. You can work around this by using "*&" to
|
390 |
|
|
set the breakpoint at a raw memory address:
|
391 |
|
|
|
392 |
|
|
(gdb) break *&'python22!PyOS_Readline'
|
393 |
|
|
Breakpoint 1 at 0x1e04eff0
|
394 |
|
|
|
395 |
|
|
The author of these extensions is not entirely convinced that
|
396 |
|
|
setting a break point within a shared DLL like `kernel32.dll' is
|
397 |
|
|
completely safe.
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
File: gdb.info, Node: Hurd Native, Next: Neutrino, Prev: Cygwin Native, Up: Native
|
401 |
|
|
|
402 |
|
|
21.1.6 Commands Specific to GNU Hurd Systems
|
403 |
|
|
--------------------------------------------
|
404 |
|
|
|
405 |
|
|
This subsection describes GDB commands specific to the GNU Hurd native
|
406 |
|
|
debugging.
|
407 |
|
|
|
408 |
|
|
`set signals'
|
409 |
|
|
`set sigs'
|
410 |
|
|
This command toggles the state of inferior signal interception by
|
411 |
|
|
GDB. Mach exceptions, such as breakpoint traps, are not affected
|
412 |
|
|
by this command. `sigs' is a shorthand alias for `signals'.
|
413 |
|
|
|
414 |
|
|
`show signals'
|
415 |
|
|
`show sigs'
|
416 |
|
|
Show the current state of intercepting inferior's signals.
|
417 |
|
|
|
418 |
|
|
`set signal-thread'
|
419 |
|
|
`set sigthread'
|
420 |
|
|
This command tells GDB which thread is the `libc' signal thread.
|
421 |
|
|
That thread is run when a signal is delivered to a running
|
422 |
|
|
process. `set sigthread' is the shorthand alias of `set
|
423 |
|
|
signal-thread'.
|
424 |
|
|
|
425 |
|
|
`show signal-thread'
|
426 |
|
|
`show sigthread'
|
427 |
|
|
These two commands show which thread will run when the inferior is
|
428 |
|
|
delivered a signal.
|
429 |
|
|
|
430 |
|
|
`set stopped'
|
431 |
|
|
This commands tells GDB that the inferior process is stopped, as
|
432 |
|
|
with the `SIGSTOP' signal. The stopped process can be continued
|
433 |
|
|
by delivering a signal to it.
|
434 |
|
|
|
435 |
|
|
`show stopped'
|
436 |
|
|
This command shows whether GDB thinks the debuggee is stopped.
|
437 |
|
|
|
438 |
|
|
`set exceptions'
|
439 |
|
|
Use this command to turn off trapping of exceptions in the
|
440 |
|
|
inferior. When exception trapping is off, neither breakpoints nor
|
441 |
|
|
single-stepping will work. To restore the default, set exception
|
442 |
|
|
trapping on.
|
443 |
|
|
|
444 |
|
|
`show exceptions'
|
445 |
|
|
Show the current state of trapping exceptions in the inferior.
|
446 |
|
|
|
447 |
|
|
`set task pause'
|
448 |
|
|
This command toggles task suspension when GDB has control.
|
449 |
|
|
Setting it to on takes effect immediately, and the task is
|
450 |
|
|
suspended whenever GDB gets control. Setting it to off will take
|
451 |
|
|
effect the next time the inferior is continued. If this option is
|
452 |
|
|
set to off, you can use `set thread default pause on' or `set
|
453 |
|
|
thread pause on' (see below) to pause individual threads.
|
454 |
|
|
|
455 |
|
|
`show task pause'
|
456 |
|
|
Show the current state of task suspension.
|
457 |
|
|
|
458 |
|
|
`set task detach-suspend-count'
|
459 |
|
|
This command sets the suspend count the task will be left with when
|
460 |
|
|
GDB detaches from it.
|
461 |
|
|
|
462 |
|
|
`show task detach-suspend-count'
|
463 |
|
|
Show the suspend count the task will be left with when detaching.
|
464 |
|
|
|
465 |
|
|
`set task exception-port'
|
466 |
|
|
`set task excp'
|
467 |
|
|
This command sets the task exception port to which GDB will
|
468 |
|
|
forward exceptions. The argument should be the value of the "send
|
469 |
|
|
rights" of the task. `set task excp' is a shorthand alias.
|
470 |
|
|
|
471 |
|
|
`set noninvasive'
|
472 |
|
|
This command switches GDB to a mode that is the least invasive as
|
473 |
|
|
far as interfering with the inferior is concerned. This is the
|
474 |
|
|
same as using `set task pause', `set exceptions', and `set
|
475 |
|
|
signals' to values opposite to the defaults.
|
476 |
|
|
|
477 |
|
|
`info send-rights'
|
478 |
|
|
`info receive-rights'
|
479 |
|
|
`info port-rights'
|
480 |
|
|
`info port-sets'
|
481 |
|
|
`info dead-names'
|
482 |
|
|
`info ports'
|
483 |
|
|
`info psets'
|
484 |
|
|
These commands display information about, respectively, send
|
485 |
|
|
rights, receive rights, port rights, port sets, and dead names of
|
486 |
|
|
a task. There are also shorthand aliases: `info ports' for `info
|
487 |
|
|
port-rights' and `info psets' for `info port-sets'.
|
488 |
|
|
|
489 |
|
|
`set thread pause'
|
490 |
|
|
This command toggles current thread suspension when GDB has
|
491 |
|
|
control. Setting it to on takes effect immediately, and the
|
492 |
|
|
current thread is suspended whenever GDB gets control. Setting it
|
493 |
|
|
to off will take effect the next time the inferior is continued.
|
494 |
|
|
Normally, this command has no effect, since when GDB has control,
|
495 |
|
|
the whole task is suspended. However, if you used `set task pause
|
496 |
|
|
off' (see above), this command comes in handy to suspend only the
|
497 |
|
|
current thread.
|
498 |
|
|
|
499 |
|
|
`show thread pause'
|
500 |
|
|
This command shows the state of current thread suspension.
|
501 |
|
|
|
502 |
|
|
`set thread run'
|
503 |
|
|
This command sets whether the current thread is allowed to run.
|
504 |
|
|
|
505 |
|
|
`show thread run'
|
506 |
|
|
Show whether the current thread is allowed to run.
|
507 |
|
|
|
508 |
|
|
`set thread detach-suspend-count'
|
509 |
|
|
This command sets the suspend count GDB will leave on a thread
|
510 |
|
|
when detaching. This number is relative to the suspend count
|
511 |
|
|
found by GDB when it notices the thread; use `set thread
|
512 |
|
|
takeover-suspend-count' to force it to an absolute value.
|
513 |
|
|
|
514 |
|
|
`show thread detach-suspend-count'
|
515 |
|
|
Show the suspend count GDB will leave on the thread when detaching.
|
516 |
|
|
|
517 |
|
|
`set thread exception-port'
|
518 |
|
|
`set thread excp'
|
519 |
|
|
Set the thread exception port to which to forward exceptions. This
|
520 |
|
|
overrides the port set by `set task exception-port' (see above).
|
521 |
|
|
`set thread excp' is the shorthand alias.
|
522 |
|
|
|
523 |
|
|
`set thread takeover-suspend-count'
|
524 |
|
|
Normally, GDB's thread suspend counts are relative to the value
|
525 |
|
|
GDB finds when it notices each thread. This command changes the
|
526 |
|
|
suspend counts to be absolute instead.
|
527 |
|
|
|
528 |
|
|
`set thread default'
|
529 |
|
|
`show thread default'
|
530 |
|
|
Each of the above `set thread' commands has a `set thread default'
|
531 |
|
|
counterpart (e.g., `set thread default pause', `set thread default
|
532 |
|
|
exception-port', etc.). The `thread default' variety of commands
|
533 |
|
|
sets the default thread properties for all threads; you can then
|
534 |
|
|
change the properties of individual threads with the non-default
|
535 |
|
|
commands.
|
536 |
|
|
|
537 |
|
|
|
538 |
|
|
File: gdb.info, Node: Neutrino, Next: Darwin, Prev: Hurd Native, Up: Native
|
539 |
|
|
|
540 |
|
|
21.1.7 QNX Neutrino
|
541 |
|
|
-------------------
|
542 |
|
|
|
543 |
|
|
GDB provides the following commands specific to the QNX Neutrino target:
|
544 |
|
|
|
545 |
|
|
`set debug nto-debug'
|
546 |
|
|
When set to on, enables debugging messages specific to the QNX
|
547 |
|
|
Neutrino support.
|
548 |
|
|
|
549 |
|
|
`show debug nto-debug'
|
550 |
|
|
Show the current state of QNX Neutrino messages.
|
551 |
|
|
|
552 |
|
|
|
553 |
|
|
File: gdb.info, Node: Darwin, Prev: Neutrino, Up: Native
|
554 |
|
|
|
555 |
|
|
21.1.8 Darwin
|
556 |
|
|
-------------
|
557 |
|
|
|
558 |
|
|
GDB provides the following commands specific to the Darwin target:
|
559 |
|
|
|
560 |
|
|
`set debug darwin NUM'
|
561 |
|
|
When set to a non zero value, enables debugging messages specific
|
562 |
|
|
to the Darwin support. Higher values produce more verbose output.
|
563 |
|
|
|
564 |
|
|
`show debug darwin'
|
565 |
|
|
Show the current state of Darwin messages.
|
566 |
|
|
|
567 |
|
|
`set debug mach-o NUM'
|
568 |
|
|
When set to a non zero value, enables debugging messages while GDB
|
569 |
|
|
is reading Darwin object files. ("Mach-O" is the file format used
|
570 |
|
|
on Darwin for object and executable files.) Higher values produce
|
571 |
|
|
more verbose output. This is a command to diagnose problems
|
572 |
|
|
internal to GDB and should not be needed in normal usage.
|
573 |
|
|
|
574 |
|
|
`show debug mach-o'
|
575 |
|
|
Show the current state of Mach-O file messages.
|
576 |
|
|
|
577 |
|
|
`set mach-exceptions on'
|
578 |
|
|
`set mach-exceptions off'
|
579 |
|
|
On Darwin, faults are first reported as a Mach exception and are
|
580 |
|
|
then mapped to a Posix signal. Use this command to turn on
|
581 |
|
|
trapping of Mach exceptions in the inferior. This might be
|
582 |
|
|
sometimes useful to better understand the cause of a fault. The
|
583 |
|
|
default is off.
|
584 |
|
|
|
585 |
|
|
`show mach-exceptions'
|
586 |
|
|
Show the current state of exceptions trapping.
|
587 |
|
|
|
588 |
|
|
|
589 |
|
|
File: gdb.info, Node: Embedded OS, Next: Embedded Processors, Prev: Native, Up: Configurations
|
590 |
|
|
|
591 |
|
|
21.2 Embedded Operating Systems
|
592 |
|
|
===============================
|
593 |
|
|
|
594 |
|
|
This section describes configurations involving the debugging of
|
595 |
|
|
embedded operating systems that are available for several different
|
596 |
|
|
architectures.
|
597 |
|
|
|
598 |
|
|
* Menu:
|
599 |
|
|
|
600 |
|
|
* VxWorks:: Using GDB with VxWorks
|
601 |
|
|
|
602 |
|
|
GDB includes the ability to debug programs running on various
|
603 |
|
|
real-time operating systems.
|
604 |
|
|
|
605 |
|
|
|
606 |
|
|
File: gdb.info, Node: VxWorks, Up: Embedded OS
|
607 |
|
|
|
608 |
|
|
21.2.1 Using GDB with VxWorks
|
609 |
|
|
-----------------------------
|
610 |
|
|
|
611 |
|
|
`target vxworks MACHINENAME'
|
612 |
|
|
A VxWorks system, attached via TCP/IP. The argument MACHINENAME
|
613 |
|
|
is the target system's machine name or IP address.
|
614 |
|
|
|
615 |
|
|
|
616 |
|
|
On VxWorks, `load' links FILENAME dynamically on the current target
|
617 |
|
|
system as well as adding its symbols in GDB.
|
618 |
|
|
|
619 |
|
|
GDB enables developers to spawn and debug tasks running on networked
|
620 |
|
|
VxWorks targets from a Unix host. Already-running tasks spawned from
|
621 |
|
|
the VxWorks shell can also be debugged. GDB uses code that runs on
|
622 |
|
|
both the Unix host and on the VxWorks target. The program `gdb' is
|
623 |
|
|
installed and executed on the Unix host. (It may be installed with the
|
624 |
|
|
name `vxgdb', to distinguish it from a GDB for debugging programs on
|
625 |
|
|
the host itself.)
|
626 |
|
|
|
627 |
|
|
`VxWorks-timeout ARGS'
|
628 |
|
|
All VxWorks-based targets now support the option `vxworks-timeout'.
|
629 |
|
|
This option is set by the user, and ARGS represents the number of
|
630 |
|
|
seconds GDB waits for responses to rpc's. You might use this if
|
631 |
|
|
your VxWorks target is a slow software simulator or is on the far
|
632 |
|
|
side of a thin network line.
|
633 |
|
|
|
634 |
|
|
The following information on connecting to VxWorks was current when
|
635 |
|
|
this manual was produced; newer releases of VxWorks may use revised
|
636 |
|
|
procedures.
|
637 |
|
|
|
638 |
|
|
To use GDB with VxWorks, you must rebuild your VxWorks kernel to
|
639 |
|
|
include the remote debugging interface routines in the VxWorks library
|
640 |
|
|
`rdb.a'. To do this, define `INCLUDE_RDB' in the VxWorks configuration
|
641 |
|
|
file `configAll.h' and rebuild your VxWorks kernel. The resulting
|
642 |
|
|
kernel contains `rdb.a', and spawns the source debugging task
|
643 |
|
|
`tRdbTask' when VxWorks is booted. For more information on configuring
|
644 |
|
|
and remaking VxWorks, see the manufacturer's manual.
|
645 |
|
|
|
646 |
|
|
Once you have included `rdb.a' in your VxWorks system image and set
|
647 |
|
|
your Unix execution search path to find GDB, you are ready to run GDB.
|
648 |
|
|
From your Unix host, run `gdb' (or `vxgdb', depending on your
|
649 |
|
|
installation).
|
650 |
|
|
|
651 |
|
|
GDB comes up showing the prompt:
|
652 |
|
|
|
653 |
|
|
(vxgdb)
|
654 |
|
|
|
655 |
|
|
* Menu:
|
656 |
|
|
|
657 |
|
|
* VxWorks Connection:: Connecting to VxWorks
|
658 |
|
|
* VxWorks Download:: VxWorks download
|
659 |
|
|
* VxWorks Attach:: Running tasks
|
660 |
|
|
|
661 |
|
|
|
662 |
|
|
File: gdb.info, Node: VxWorks Connection, Next: VxWorks Download, Up: VxWorks
|
663 |
|
|
|
664 |
|
|
21.2.1.1 Connecting to VxWorks
|
665 |
|
|
..............................
|
666 |
|
|
|
667 |
|
|
The GDB command `target' lets you connect to a VxWorks target on the
|
668 |
|
|
network. To connect to a target whose host name is "`tt'", type:
|
669 |
|
|
|
670 |
|
|
(vxgdb) target vxworks tt
|
671 |
|
|
|
672 |
|
|
GDB displays messages like these:
|
673 |
|
|
|
674 |
|
|
Attaching remote machine across net...
|
675 |
|
|
Connected to tt.
|
676 |
|
|
|
677 |
|
|
GDB then attempts to read the symbol tables of any object modules
|
678 |
|
|
loaded into the VxWorks target since it was last booted. GDB locates
|
679 |
|
|
these files by searching the directories listed in the command search
|
680 |
|
|
path (*note Your Program's Environment: Environment.); if it fails to
|
681 |
|
|
find an object file, it displays a message such as:
|
682 |
|
|
|
683 |
|
|
prog.o: No such file or directory.
|
684 |
|
|
|
685 |
|
|
When this happens, add the appropriate directory to the search path
|
686 |
|
|
with the GDB command `path', and execute the `target' command again.
|
687 |
|
|
|
688 |
|
|
|
689 |
|
|
File: gdb.info, Node: VxWorks Download, Next: VxWorks Attach, Prev: VxWorks Connection, Up: VxWorks
|
690 |
|
|
|
691 |
|
|
21.2.1.2 VxWorks Download
|
692 |
|
|
.........................
|
693 |
|
|
|
694 |
|
|
If you have connected to the VxWorks target and you want to debug an
|
695 |
|
|
object that has not yet been loaded, you can use the GDB `load' command
|
696 |
|
|
to download a file from Unix to VxWorks incrementally. The object file
|
697 |
|
|
given as an argument to the `load' command is actually opened twice:
|
698 |
|
|
first by the VxWorks target in order to download the code, then by GDB
|
699 |
|
|
in order to read the symbol table. This can lead to problems if the
|
700 |
|
|
current working directories on the two systems differ. If both systems
|
701 |
|
|
have NFS mounted the same filesystems, you can avoid these problems by
|
702 |
|
|
using absolute paths. Otherwise, it is simplest to set the working
|
703 |
|
|
directory on both systems to the directory in which the object file
|
704 |
|
|
resides, and then to reference the file by its name, without any path.
|
705 |
|
|
For instance, a program `prog.o' may reside in `VXPATH/vw/demo/rdb' in
|
706 |
|
|
VxWorks and in `HOSTPATH/vw/demo/rdb' on the host. To load this
|
707 |
|
|
program, type this on VxWorks:
|
708 |
|
|
|
709 |
|
|
-> cd "VXPATH/vw/demo/rdb"
|
710 |
|
|
|
711 |
|
|
Then, in GDB, type:
|
712 |
|
|
|
713 |
|
|
(vxgdb) cd HOSTPATH/vw/demo/rdb
|
714 |
|
|
(vxgdb) load prog.o
|
715 |
|
|
|
716 |
|
|
GDB displays a response similar to this:
|
717 |
|
|
|
718 |
|
|
Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
|
719 |
|
|
|
720 |
|
|
You can also use the `load' command to reload an object module after
|
721 |
|
|
editing and recompiling the corresponding source file. Note that this
|
722 |
|
|
makes GDB delete all currently-defined breakpoints, auto-displays, and
|
723 |
|
|
convenience variables, and to clear the value history. (This is
|
724 |
|
|
necessary in order to preserve the integrity of debugger's data
|
725 |
|
|
structures that reference the target system's symbol table.)
|
726 |
|
|
|
727 |
|
|
|
728 |
|
|
File: gdb.info, Node: VxWorks Attach, Prev: VxWorks Download, Up: VxWorks
|
729 |
|
|
|
730 |
|
|
21.2.1.3 Running Tasks
|
731 |
|
|
......................
|
732 |
|
|
|
733 |
|
|
You can also attach to an existing task using the `attach' command as
|
734 |
|
|
follows:
|
735 |
|
|
|
736 |
|
|
(vxgdb) attach TASK
|
737 |
|
|
|
738 |
|
|
where TASK is the VxWorks hexadecimal task ID. The task can be running
|
739 |
|
|
or suspended when you attach to it. Running tasks are suspended at the
|
740 |
|
|
time of attachment.
|
741 |
|
|
|
742 |
|
|
|
743 |
|
|
File: gdb.info, Node: Embedded Processors, Next: Architectures, Prev: Embedded OS, Up: Configurations
|
744 |
|
|
|
745 |
|
|
21.3 Embedded Processors
|
746 |
|
|
========================
|
747 |
|
|
|
748 |
|
|
This section goes into details specific to particular embedded
|
749 |
|
|
configurations.
|
750 |
|
|
|
751 |
|
|
Whenever a specific embedded processor has a simulator, GDB allows
|
752 |
|
|
to send an arbitrary command to the simulator.
|
753 |
|
|
|
754 |
|
|
`sim COMMAND'
|
755 |
|
|
Send an arbitrary COMMAND string to the simulator. Consult the
|
756 |
|
|
documentation for the specific simulator in use for information
|
757 |
|
|
about acceptable commands.
|
758 |
|
|
|
759 |
|
|
* Menu:
|
760 |
|
|
|
761 |
|
|
* ARM:: ARM RDI
|
762 |
|
|
* M32R/D:: Renesas M32R/D
|
763 |
|
|
* M68K:: Motorola M68K
|
764 |
|
|
* MicroBlaze:: Xilinx MicroBlaze
|
765 |
|
|
* MIPS Embedded:: MIPS Embedded
|
766 |
|
|
* OpenRISC 1000:: OpenRisc 1000
|
767 |
|
|
* PA:: HP PA Embedded
|
768 |
|
|
* PowerPC Embedded:: PowerPC Embedded
|
769 |
|
|
* Sparclet:: Tsqware Sparclet
|
770 |
|
|
* Sparclite:: Fujitsu Sparclite
|
771 |
|
|
* Z8000:: Zilog Z8000
|
772 |
|
|
* AVR:: Atmel AVR
|
773 |
|
|
* CRIS:: CRIS
|
774 |
|
|
* Super-H:: Renesas Super-H
|
775 |
|
|
|
776 |
|
|
|
777 |
|
|
File: gdb.info, Node: ARM, Next: M32R/D, Up: Embedded Processors
|
778 |
|
|
|
779 |
|
|
21.3.1 ARM
|
780 |
|
|
----------
|
781 |
|
|
|
782 |
|
|
`target rdi DEV'
|
783 |
|
|
ARM Angel monitor, via RDI library interface to ADP protocol. You
|
784 |
|
|
may use this target to communicate with both boards running the
|
785 |
|
|
Angel monitor, or with the EmbeddedICE JTAG debug device.
|
786 |
|
|
|
787 |
|
|
`target rdp DEV'
|
788 |
|
|
ARM Demon monitor.
|
789 |
|
|
|
790 |
|
|
|
791 |
|
|
GDB provides the following ARM-specific commands:
|
792 |
|
|
|
793 |
|
|
`set arm disassembler'
|
794 |
|
|
This commands selects from a list of disassembly styles. The
|
795 |
|
|
`"std"' style is the standard style.
|
796 |
|
|
|
797 |
|
|
`show arm disassembler'
|
798 |
|
|
Show the current disassembly style.
|
799 |
|
|
|
800 |
|
|
`set arm apcs32'
|
801 |
|
|
This command toggles ARM operation mode between 32-bit and 26-bit.
|
802 |
|
|
|
803 |
|
|
`show arm apcs32'
|
804 |
|
|
Display the current usage of the ARM 32-bit mode.
|
805 |
|
|
|
806 |
|
|
`set arm fpu FPUTYPE'
|
807 |
|
|
This command sets the ARM floating-point unit (FPU) type. The
|
808 |
|
|
argument FPUTYPE can be one of these:
|
809 |
|
|
|
810 |
|
|
`auto'
|
811 |
|
|
Determine the FPU type by querying the OS ABI.
|
812 |
|
|
|
813 |
|
|
`softfpa'
|
814 |
|
|
Software FPU, with mixed-endian doubles on little-endian ARM
|
815 |
|
|
processors.
|
816 |
|
|
|
817 |
|
|
`fpa'
|
818 |
|
|
GCC-compiled FPA co-processor.
|
819 |
|
|
|
820 |
|
|
`softvfp'
|
821 |
|
|
Software FPU with pure-endian doubles.
|
822 |
|
|
|
823 |
|
|
`vfp'
|
824 |
|
|
VFP co-processor.
|
825 |
|
|
|
826 |
|
|
`show arm fpu'
|
827 |
|
|
Show the current type of the FPU.
|
828 |
|
|
|
829 |
|
|
`set arm abi'
|
830 |
|
|
This command forces GDB to use the specified ABI.
|
831 |
|
|
|
832 |
|
|
`show arm abi'
|
833 |
|
|
Show the currently used ABI.
|
834 |
|
|
|
835 |
|
|
`set arm fallback-mode (arm|thumb|auto)'
|
836 |
|
|
GDB uses the symbol table, when available, to determine whether
|
837 |
|
|
instructions are ARM or Thumb. This command controls GDB's
|
838 |
|
|
default behavior when the symbol table is not available. The
|
839 |
|
|
default is `auto', which causes GDB to use the current execution
|
840 |
|
|
mode (from the `T' bit in the `CPSR' register).
|
841 |
|
|
|
842 |
|
|
`show arm fallback-mode'
|
843 |
|
|
Show the current fallback instruction mode.
|
844 |
|
|
|
845 |
|
|
`set arm force-mode (arm|thumb|auto)'
|
846 |
|
|
This command overrides use of the symbol table to determine whether
|
847 |
|
|
instructions are ARM or Thumb. The default is `auto', which
|
848 |
|
|
causes GDB to use the symbol table and then the setting of `set
|
849 |
|
|
arm fallback-mode'.
|
850 |
|
|
|
851 |
|
|
`show arm force-mode'
|
852 |
|
|
Show the current forced instruction mode.
|
853 |
|
|
|
854 |
|
|
`set debug arm'
|
855 |
|
|
Toggle whether to display ARM-specific debugging messages from the
|
856 |
|
|
ARM target support subsystem.
|
857 |
|
|
|
858 |
|
|
`show debug arm'
|
859 |
|
|
Show whether ARM-specific debugging messages are enabled.
|
860 |
|
|
|
861 |
|
|
The following commands are available when an ARM target is debugged
|
862 |
|
|
using the RDI interface:
|
863 |
|
|
|
864 |
|
|
`rdilogfile [FILE]'
|
865 |
|
|
Set the filename for the ADP (Angel Debugger Protocol) packet log.
|
866 |
|
|
With an argument, sets the log file to the specified FILE. With
|
867 |
|
|
no argument, show the current log file name. The default log file
|
868 |
|
|
is `rdi.log'.
|
869 |
|
|
|
870 |
|
|
`rdilogenable [ARG]'
|
871 |
|
|
Control logging of ADP packets. With an argument of 1 or `"yes"'
|
872 |
|
|
enables logging, with an argument 0 or `"no"' disables it. With
|
873 |
|
|
no arguments displays the current setting. When logging is
|
874 |
|
|
enabled, ADP packets exchanged between GDB and the RDI target
|
875 |
|
|
device are logged to a file.
|
876 |
|
|
|
877 |
|
|
`set rdiromatzero'
|
878 |
|
|
Tell GDB whether the target has ROM at address 0. If on, vector
|
879 |
|
|
catching is disabled, so that zero address can be used. If off
|
880 |
|
|
(the default), vector catching is enabled. For this command to
|
881 |
|
|
take effect, it needs to be invoked prior to the `target rdi'
|
882 |
|
|
command.
|
883 |
|
|
|
884 |
|
|
`show rdiromatzero'
|
885 |
|
|
Show the current setting of ROM at zero address.
|
886 |
|
|
|
887 |
|
|
`set rdiheartbeat'
|
888 |
|
|
Enable or disable RDI heartbeat packets. It is not recommended to
|
889 |
|
|
turn on this option, since it confuses ARM and EPI JTAG interface,
|
890 |
|
|
as well as the Angel monitor.
|
891 |
|
|
|
892 |
|
|
`show rdiheartbeat'
|
893 |
|
|
Show the setting of RDI heartbeat packets.
|
894 |
|
|
|
895 |
|
|
`target sim [SIMARGS] ...'
|
896 |
|
|
The GDB ARM simulator accepts the following optional arguments.
|
897 |
|
|
|
898 |
|
|
`--swi-support=TYPE'
|
899 |
|
|
Tell the simulator which SWI interfaces to support. TYPE may
|
900 |
|
|
be a comma separated list of the following values. The
|
901 |
|
|
default value is `all'.
|
902 |
|
|
|
903 |
|
|
`none'
|
904 |
|
|
|
905 |
|
|
`demon'
|
906 |
|
|
|
907 |
|
|
`angel'
|
908 |
|
|
|
909 |
|
|
`redboot'
|
910 |
|
|
|
911 |
|
|
`all'
|
912 |
|
|
|
913 |
|
|
|
914 |
|
|
File: gdb.info, Node: M32R/D, Next: M68K, Prev: ARM, Up: Embedded Processors
|
915 |
|
|
|
916 |
|
|
21.3.2 Renesas M32R/D and M32R/SDI
|
917 |
|
|
----------------------------------
|
918 |
|
|
|
919 |
|
|
`target m32r DEV'
|
920 |
|
|
Renesas M32R/D ROM monitor.
|
921 |
|
|
|
922 |
|
|
`target m32rsdi DEV'
|
923 |
|
|
Renesas M32R SDI server, connected via parallel port to the board.
|
924 |
|
|
|
925 |
|
|
The following GDB commands are specific to the M32R monitor:
|
926 |
|
|
|
927 |
|
|
`set download-path PATH'
|
928 |
|
|
Set the default path for finding downloadable SREC files.
|
929 |
|
|
|
930 |
|
|
`show download-path'
|
931 |
|
|
Show the default path for downloadable SREC files.
|
932 |
|
|
|
933 |
|
|
`set board-address ADDR'
|
934 |
|
|
Set the IP address for the M32R-EVA target board.
|
935 |
|
|
|
936 |
|
|
`show board-address'
|
937 |
|
|
Show the current IP address of the target board.
|
938 |
|
|
|
939 |
|
|
`set server-address ADDR'
|
940 |
|
|
Set the IP address for the download server, which is the GDB's
|
941 |
|
|
host machine.
|
942 |
|
|
|
943 |
|
|
`show server-address'
|
944 |
|
|
Display the IP address of the download server.
|
945 |
|
|
|
946 |
|
|
`upload [FILE]'
|
947 |
|
|
Upload the specified SREC FILE via the monitor's Ethernet upload
|
948 |
|
|
capability. If no FILE argument is given, the current executable
|
949 |
|
|
file is uploaded.
|
950 |
|
|
|
951 |
|
|
`tload [FILE]'
|
952 |
|
|
Test the `upload' command.
|
953 |
|
|
|
954 |
|
|
The following commands are available for M32R/SDI:
|
955 |
|
|
|
956 |
|
|
`sdireset'
|
957 |
|
|
This command resets the SDI connection.
|
958 |
|
|
|
959 |
|
|
`sdistatus'
|
960 |
|
|
This command shows the SDI connection status.
|
961 |
|
|
|
962 |
|
|
`debug_chaos'
|
963 |
|
|
Instructs the remote that M32R/Chaos debugging is to be used.
|
964 |
|
|
|
965 |
|
|
`use_debug_dma'
|
966 |
|
|
Instructs the remote to use the DEBUG_DMA method of accessing
|
967 |
|
|
memory.
|
968 |
|
|
|
969 |
|
|
`use_mon_code'
|
970 |
|
|
Instructs the remote to use the MON_CODE method of accessing
|
971 |
|
|
memory.
|
972 |
|
|
|
973 |
|
|
`use_ib_break'
|
974 |
|
|
Instructs the remote to set breakpoints by IB break.
|
975 |
|
|
|
976 |
|
|
`use_dbt_break'
|
977 |
|
|
Instructs the remote to set breakpoints by DBT.
|
978 |
|
|
|
979 |
|
|
|
980 |
|
|
File: gdb.info, Node: M68K, Next: MicroBlaze, Prev: M32R/D, Up: Embedded Processors
|
981 |
|
|
|
982 |
|
|
21.3.3 M68k
|
983 |
|
|
-----------
|
984 |
|
|
|
985 |
|
|
The Motorola m68k configuration includes ColdFire support, and a target
|
986 |
|
|
command for the following ROM monitor.
|
987 |
|
|
|
988 |
|
|
`target dbug DEV'
|
989 |
|
|
dBUG ROM monitor for Motorola ColdFire.
|
990 |
|
|
|
991 |
|
|
|
992 |
|
|
|
993 |
|
|
File: gdb.info, Node: MicroBlaze, Next: MIPS Embedded, Prev: M68K, Up: Embedded Processors
|
994 |
|
|
|
995 |
|
|
21.3.4 MicroBlaze
|
996 |
|
|
-----------------
|
997 |
|
|
|
998 |
|
|
The MicroBlaze is a soft-core processor supported on various Xilinx
|
999 |
|
|
FPGAs, such as Spartan or Virtex series. Boards with these processors
|
1000 |
|
|
usually have JTAG ports which connect to a host system running the
|
1001 |
|
|
Xilinx Embedded Development Kit (EDK) or Software Development Kit (SDK).
|
1002 |
|
|
This host system is used to download the configuration bitstream to the
|
1003 |
|
|
target FPGA. The Xilinx Microprocessor Debugger (XMD) program
|
1004 |
|
|
communicates with the target board using the JTAG interface and
|
1005 |
|
|
presents a `gdbserver' interface to the board. By default `xmd' uses
|
1006 |
|
|
port `1234'. (While it is possible to change this default port, it
|
1007 |
|
|
requires the use of undocumented `xmd' commands. Contact Xilinx
|
1008 |
|
|
support if you need to do this.)
|
1009 |
|
|
|
1010 |
|
|
Use these GDB commands to connect to the MicroBlaze target processor.
|
1011 |
|
|
|
1012 |
|
|
`target remote :1234'
|
1013 |
|
|
Use this command to connect to the target if you are running GDB
|
1014 |
|
|
on the same system as `xmd'.
|
1015 |
|
|
|
1016 |
|
|
`target remote XMD-HOST:1234'
|
1017 |
|
|
Use this command to connect to the target if it is connected to
|
1018 |
|
|
`xmd' running on a different system named XMD-HOST.
|
1019 |
|
|
|
1020 |
|
|
`load'
|
1021 |
|
|
Use this command to download a program to the MicroBlaze target.
|
1022 |
|
|
|
1023 |
|
|
`set debug microblaze N'
|
1024 |
|
|
Enable MicroBlaze-specific debugging messages if non-zero.
|
1025 |
|
|
|
1026 |
|
|
`show debug microblaze N'
|
1027 |
|
|
Show MicroBlaze-specific debugging level.
|
1028 |
|
|
|
1029 |
|
|
|
1030 |
|
|
File: gdb.info, Node: MIPS Embedded, Next: OpenRISC 1000, Prev: MicroBlaze, Up: Embedded Processors
|
1031 |
|
|
|
1032 |
|
|
21.3.5 MIPS Embedded
|
1033 |
|
|
--------------------
|
1034 |
|
|
|
1035 |
|
|
GDB can use the MIPS remote debugging protocol to talk to a MIPS board
|
1036 |
|
|
attached to a serial line. This is available when you configure GDB
|
1037 |
|
|
with `--target=mips-idt-ecoff'.
|
1038 |
|
|
|
1039 |
|
|
Use these GDB commands to specify the connection to your target
|
1040 |
|
|
board:
|
1041 |
|
|
|
1042 |
|
|
`target mips PORT'
|
1043 |
|
|
To run a program on the board, start up `gdb' with the name of
|
1044 |
|
|
your program as the argument. To connect to the board, use the
|
1045 |
|
|
command `target mips PORT', where PORT is the name of the serial
|
1046 |
|
|
port connected to the board. If the program has not already been
|
1047 |
|
|
downloaded to the board, you may use the `load' command to
|
1048 |
|
|
download it. You can then use all the usual GDB commands.
|
1049 |
|
|
|
1050 |
|
|
For example, this sequence connects to the target board through a
|
1051 |
|
|
serial port, and loads and runs a program called PROG through the
|
1052 |
|
|
debugger:
|
1053 |
|
|
|
1054 |
|
|
host$ gdb PROG
|
1055 |
|
|
GDB is free software and ...
|
1056 |
|
|
(gdb) target mips /dev/ttyb
|
1057 |
|
|
(gdb) load PROG
|
1058 |
|
|
(gdb) run
|
1059 |
|
|
|
1060 |
|
|
`target mips HOSTNAME:PORTNUMBER'
|
1061 |
|
|
On some GDB host configurations, you can specify a TCP connection
|
1062 |
|
|
(for instance, to a serial line managed by a terminal
|
1063 |
|
|
concentrator) instead of a serial port, using the syntax
|
1064 |
|
|
`HOSTNAME:PORTNUMBER'.
|
1065 |
|
|
|
1066 |
|
|
`target pmon PORT'
|
1067 |
|
|
PMON ROM monitor.
|
1068 |
|
|
|
1069 |
|
|
`target ddb PORT'
|
1070 |
|
|
NEC's DDB variant of PMON for Vr4300.
|
1071 |
|
|
|
1072 |
|
|
`target lsi PORT'
|
1073 |
|
|
LSI variant of PMON.
|
1074 |
|
|
|
1075 |
|
|
`target r3900 DEV'
|
1076 |
|
|
Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
|
1077 |
|
|
|
1078 |
|
|
`target array DEV'
|
1079 |
|
|
Array Tech LSI33K RAID controller board.
|
1080 |
|
|
|
1081 |
|
|
|
1082 |
|
|
GDB also supports these special commands for MIPS targets:
|
1083 |
|
|
|
1084 |
|
|
`set mipsfpu double'
|
1085 |
|
|
`set mipsfpu single'
|
1086 |
|
|
`set mipsfpu none'
|
1087 |
|
|
`set mipsfpu auto'
|
1088 |
|
|
`show mipsfpu'
|
1089 |
|
|
If your target board does not support the MIPS floating point
|
1090 |
|
|
coprocessor, you should use the command `set mipsfpu none' (if you
|
1091 |
|
|
need this, you may wish to put the command in your GDB init file).
|
1092 |
|
|
This tells GDB how to find the return value of functions which
|
1093 |
|
|
return floating point values. It also allows GDB to avoid saving
|
1094 |
|
|
the floating point registers when calling functions on the board.
|
1095 |
|
|
If you are using a floating point coprocessor with only single
|
1096 |
|
|
precision floating point support, as on the R4650 processor, use
|
1097 |
|
|
the command `set mipsfpu single'. The default double precision
|
1098 |
|
|
floating point coprocessor may be selected using `set mipsfpu
|
1099 |
|
|
double'.
|
1100 |
|
|
|
1101 |
|
|
In previous versions the only choices were double precision or no
|
1102 |
|
|
floating point, so `set mipsfpu on' will select double precision
|
1103 |
|
|
and `set mipsfpu off' will select no floating point.
|
1104 |
|
|
|
1105 |
|
|
As usual, you can inquire about the `mipsfpu' variable with `show
|
1106 |
|
|
mipsfpu'.
|
1107 |
|
|
|
1108 |
|
|
`set timeout SECONDS'
|
1109 |
|
|
`set retransmit-timeout SECONDS'
|
1110 |
|
|
`show timeout'
|
1111 |
|
|
`show retransmit-timeout'
|
1112 |
|
|
You can control the timeout used while waiting for a packet, in
|
1113 |
|
|
the MIPS remote protocol, with the `set timeout SECONDS' command.
|
1114 |
|
|
The default is 5 seconds. Similarly, you can control the timeout
|
1115 |
|
|
used while waiting for an acknowledgment of a packet with the `set
|
1116 |
|
|
retransmit-timeout SECONDS' command. The default is 3 seconds.
|
1117 |
|
|
You can inspect both values with `show timeout' and `show
|
1118 |
|
|
retransmit-timeout'. (These commands are _only_ available when
|
1119 |
|
|
GDB is configured for `--target=mips-idt-ecoff'.)
|
1120 |
|
|
|
1121 |
|
|
The timeout set by `set timeout' does not apply when GDB is
|
1122 |
|
|
waiting for your program to stop. In that case, GDB waits forever
|
1123 |
|
|
because it has no way of knowing how long the program is going to
|
1124 |
|
|
run before stopping.
|
1125 |
|
|
|
1126 |
|
|
`set syn-garbage-limit NUM'
|
1127 |
|
|
Limit the maximum number of characters GDB should ignore when it
|
1128 |
|
|
tries to synchronize with the remote target. The default is 10
|
1129 |
|
|
characters. Setting the limit to -1 means there's no limit.
|
1130 |
|
|
|
1131 |
|
|
`show syn-garbage-limit'
|
1132 |
|
|
Show the current limit on the number of characters to ignore when
|
1133 |
|
|
trying to synchronize with the remote system.
|
1134 |
|
|
|
1135 |
|
|
`set monitor-prompt PROMPT'
|
1136 |
|
|
Tell GDB to expect the specified PROMPT string from the remote
|
1137 |
|
|
monitor. The default depends on the target:
|
1138 |
|
|
pmon target
|
1139 |
|
|
`PMON'
|
1140 |
|
|
|
1141 |
|
|
ddb target
|
1142 |
|
|
`NEC010'
|
1143 |
|
|
|
1144 |
|
|
lsi target
|
1145 |
|
|
`PMON>'
|
1146 |
|
|
|
1147 |
|
|
`show monitor-prompt'
|
1148 |
|
|
Show the current strings GDB expects as the prompt from the remote
|
1149 |
|
|
monitor.
|
1150 |
|
|
|
1151 |
|
|
`set monitor-warnings'
|
1152 |
|
|
Enable or disable monitor warnings about hardware breakpoints.
|
1153 |
|
|
This has effect only for the `lsi' target. When on, GDB will
|
1154 |
|
|
display warning messages whose codes are returned by the `lsi'
|
1155 |
|
|
PMON monitor for breakpoint commands.
|
1156 |
|
|
|
1157 |
|
|
`show monitor-warnings'
|
1158 |
|
|
Show the current setting of printing monitor warnings.
|
1159 |
|
|
|
1160 |
|
|
`pmon COMMAND'
|
1161 |
|
|
This command allows sending an arbitrary COMMAND string to the
|
1162 |
|
|
monitor. The monitor must be in debug mode for this to work.
|
1163 |
|
|
|
1164 |
|
|
|
1165 |
|
|
File: gdb.info, Node: OpenRISC 1000, Next: PA, Prev: MIPS Embedded, Up: Embedded Processors
|
1166 |
|
|
|
1167 |
|
|
21.3.6 OpenRISC 1000
|
1168 |
|
|
--------------------
|
1169 |
|
|
|
1170 |
342 |
jeremybenn |
Previous versions of GDB supported remote connection via a proprietary
|
1171 |
|
|
JTAG protocol using the `target jtag' command. Support for this has now
|
1172 |
|
|
been dropped.
|
1173 |
330 |
jeremybenn |
|
1174 |
342 |
jeremybenn |
`target remote'
|
1175 |
|
|
This is now the only way to connect to a remote OpenRISC 1000
|
1176 |
|
|
target. This is supported by "Or1ksim", the OpenRISC 1000
|
1177 |
|
|
architectural simulator, and Verilator and Icarus Verilog
|
1178 |
|
|
simulations. "Remote serial protocol" servers are also available
|
1179 |
|
|
to drive various hardware implementations via JTAG. Connects to
|
1180 |
|
|
remote JTAG server.
|
1181 |
330 |
jeremybenn |
|
1182 |
342 |
jeremybenn |
Example: `target remote :51000'
|
1183 |
330 |
jeremybenn |
|
1184 |
342 |
jeremybenn |
`target sim'
|
1185 |
|
|
"Or1ksim", the OpenRISC 1000 architectural simulator is now
|
1186 |
|
|
incorporated within GDB as a simulator target. It is started in
|
1187 |
|
|
quiet mode with 8M of memory starting at address 0. It is possible
|
1188 |
|
|
to pass arguments to extend this configuration using the `-f'
|
1189 |
|
|
option to `target sim'. However for more complex use, the user is
|
1190 |
|
|
advised to run "Or1ksim" separately, with its own configuration
|
1191 |
|
|
file, and connect using `target remote'
|
1192 |
330 |
jeremybenn |
|
1193 |
342 |
jeremybenn |
Example: `target sim'
|
1194 |
|
|
|
1195 |
330 |
jeremybenn |
`info or1k spr'
|
1196 |
342 |
jeremybenn |
Displays groups.
|
1197 |
330 |
jeremybenn |
|
1198 |
342 |
jeremybenn |
`info spr GROUP'
|
1199 |
|
|
`info spr GROUPNO'
|
1200 |
330 |
jeremybenn |
Displays register names in selected group.
|
1201 |
|
|
|
1202 |
342 |
jeremybenn |
`info spr GROUP REGISTER'
|
1203 |
|
|
`info spr REGISTER'
|
1204 |
|
|
`info spr GROUPNO REGISTERNO'
|
1205 |
|
|
`info spr REGISTERNO'
|
1206 |
330 |
jeremybenn |
Shows information about specified spr register.
|
1207 |
|
|
|
1208 |
342 |
jeremybenn |
Example: `info spr DRR'
|
1209 |
|
|
|
1210 |
|
|
`DEBUG.DRR = SPR6_21 = 0 (0x0)'
|
1211 |
|
|
|
1212 |
330 |
jeremybenn |
`spr GROUP REGISTER VALUE'
|
1213 |
|
|
`spr REGISTER VALUE'
|
1214 |
|
|
`spr GROUPNO REGISTERNO VALUE'
|
1215 |
|
|
`spr REGISTERNO VALUE'
|
1216 |
|
|
Writes VALUE to specified spr register.
|
1217 |
|
|
|
1218 |
342 |
jeremybenn |
Example: spr PICMR 0x24
|
1219 |
330 |
jeremybenn |
|
1220 |
342 |
jeremybenn |
The use of `info' and `spr' commands is anachronistic. At some time
|
1221 |
|
|
in the future they will be replaced by `show spr' and `set spr'.
|
1222 |
330 |
jeremybenn |
|
1223 |
342 |
jeremybenn |
There are some known problems with the current implementation
|
1224 |
330 |
jeremybenn |
|
1225 |
342 |
jeremybenn |
1. Some OpenRISC 1000 targets support hardware breakpoints and
|
1226 |
|
|
watchpoints. Consult the target documentation for details. GDB
|
1227 |
|
|
is not perfect in handling of watchpoints. It is possible to
|
1228 |
|
|
allocate hardware watchpoints and not discover until running that
|
1229 |
|
|
sufficient watchpoints are not available. It is also possible
|
1230 |
|
|
that GDB will report watchpoints being hit spuriously. This can
|
1231 |
|
|
be down to the assembly code having additional memory accesses
|
1232 |
|
|
that are not obviously reflected in the source code.
|
1233 |
330 |
jeremybenn |
|
1234 |
342 |
jeremybenn |
2. The OpenRISC 1000 architecture has evolved since the first port of
|
1235 |
|
|
GDB. In particular the structure of the Unit Present register has
|
1236 |
|
|
changed and the CPU Configuration register has been added. The
|
1237 |
512 |
jeremybenn |
port of GDB version 7.2-or32-1.0rc3 uses the _current_
|
1238 |
342 |
jeremybenn |
specification of the OpenRISC 1000.
|
1239 |
330 |
jeremybenn |
|
1240 |
|
|
|
1241 |
342 |
jeremybenn |
Reports of bugs are much welcomed. Please report problems through the
|
1242 |
|
|
OpenRISC tracker at downloads (http://opencores.org/openrisc).
|
1243 |
330 |
jeremybenn |
|
1244 |
|
|
|
1245 |
|
|
File: gdb.info, Node: PowerPC Embedded, Next: Sparclet, Prev: PA, Up: Embedded Processors
|
1246 |
|
|
|
1247 |
|
|
21.3.7 PowerPC Embedded
|
1248 |
|
|
-----------------------
|
1249 |
|
|
|
1250 |
|
|
GDB supports using the DVC (Data Value Compare) register to implement
|
1251 |
|
|
in hardware simple hardware watchpoint conditions of the form:
|
1252 |
|
|
|
1253 |
|
|
(gdb) watch ADDRESS|VARIABLE \
|
1254 |
|
|
if ADDRESS|VARIABLE == CONSTANT EXPRESSION
|
1255 |
|
|
|
1256 |
|
|
The DVC register will be automatically used whenever GDB detects
|
1257 |
|
|
such pattern in a condition expression. This feature is available in
|
1258 |
|
|
native GDB running on a Linux kernel version 2.6.34 or newer.
|
1259 |
|
|
|
1260 |
|
|
GDB provides the following PowerPC-specific commands:
|
1261 |
|
|
|
1262 |
|
|
`set powerpc soft-float'
|
1263 |
|
|
`show powerpc soft-float'
|
1264 |
|
|
Force GDB to use (or not use) a software floating point calling
|
1265 |
|
|
convention. By default, GDB selects the calling convention based
|
1266 |
|
|
on the selected architecture and the provided executable file.
|
1267 |
|
|
|
1268 |
|
|
`set powerpc vector-abi'
|
1269 |
|
|
`show powerpc vector-abi'
|
1270 |
|
|
Force GDB to use the specified calling convention for vector
|
1271 |
|
|
arguments and return values. The valid options are `auto';
|
1272 |
|
|
`generic', to avoid vector registers even if they are present;
|
1273 |
|
|
`altivec', to use AltiVec registers; and `spe' to use SPE
|
1274 |
|
|
registers. By default, GDB selects the calling convention based
|
1275 |
|
|
on the selected architecture and the provided executable file.
|
1276 |
|
|
|
1277 |
|
|
`target dink32 DEV'
|
1278 |
|
|
DINK32 ROM monitor.
|
1279 |
|
|
|
1280 |
|
|
`target ppcbug DEV'
|
1281 |
|
|
|
1282 |
|
|
`target ppcbug1 DEV'
|
1283 |
|
|
PPCBUG ROM monitor for PowerPC.
|
1284 |
|
|
|
1285 |
|
|
`target sds DEV'
|
1286 |
|
|
SDS monitor, running on a PowerPC board (such as Motorola's ADS).
|
1287 |
|
|
|
1288 |
|
|
The following commands specific to the SDS protocol are supported by
|
1289 |
|
|
GDB:
|
1290 |
|
|
|
1291 |
|
|
`set sdstimeout NSEC'
|
1292 |
|
|
Set the timeout for SDS protocol reads to be NSEC seconds. The
|
1293 |
|
|
default is 2 seconds.
|
1294 |
|
|
|
1295 |
|
|
`show sdstimeout'
|
1296 |
|
|
Show the current value of the SDS timeout.
|
1297 |
|
|
|
1298 |
|
|
`sds COMMAND'
|
1299 |
|
|
Send the specified COMMAND string to the SDS monitor.
|
1300 |
|
|
|
1301 |
|
|
|
1302 |
|
|
File: gdb.info, Node: PA, Next: PowerPC Embedded, Prev: OpenRISC 1000, Up: Embedded Processors
|
1303 |
|
|
|
1304 |
|
|
21.3.8 HP PA Embedded
|
1305 |
|
|
---------------------
|
1306 |
|
|
|
1307 |
|
|
`target op50n DEV'
|
1308 |
|
|
OP50N monitor, running on an OKI HPPA board.
|
1309 |
|
|
|
1310 |
|
|
`target w89k DEV'
|
1311 |
|
|
W89K monitor, running on a Winbond HPPA board.
|
1312 |
|
|
|
1313 |
|
|
|
1314 |
|
|
|
1315 |
|
|
File: gdb.info, Node: Sparclet, Next: Sparclite, Prev: PowerPC Embedded, Up: Embedded Processors
|
1316 |
|
|
|
1317 |
|
|
21.3.9 Tsqware Sparclet
|
1318 |
|
|
-----------------------
|
1319 |
|
|
|
1320 |
|
|
GDB enables developers to debug tasks running on Sparclet targets from
|
1321 |
|
|
a Unix host. GDB uses code that runs on both the Unix host and on the
|
1322 |
|
|
Sparclet target. The program `gdb' is installed and executed on the
|
1323 |
|
|
Unix host.
|
1324 |
|
|
|
1325 |
|
|
`remotetimeout ARGS'
|
1326 |
|
|
GDB supports the option `remotetimeout'. This option is set by
|
1327 |
|
|
the user, and ARGS represents the number of seconds GDB waits for
|
1328 |
|
|
responses.
|
1329 |
|
|
|
1330 |
|
|
When compiling for debugging, include the options `-g' to get debug
|
1331 |
|
|
information and `-Ttext' to relocate the program to where you wish to
|
1332 |
|
|
load it on the target. You may also want to add the options `-n' or
|
1333 |
|
|
`-N' in order to reduce the size of the sections. Example:
|
1334 |
|
|
|
1335 |
|
|
sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
|
1336 |
|
|
|
1337 |
|
|
You can use `objdump' to verify that the addresses are what you
|
1338 |
|
|
intended:
|
1339 |
|
|
|
1340 |
|
|
sparclet-aout-objdump --headers --syms prog
|
1341 |
|
|
|
1342 |
|
|
Once you have set your Unix execution search path to find GDB, you
|
1343 |
|
|
are ready to run GDB. From your Unix host, run `gdb' (or
|
1344 |
|
|
`sparclet-aout-gdb', depending on your installation).
|
1345 |
|
|
|
1346 |
|
|
GDB comes up showing the prompt:
|
1347 |
|
|
|
1348 |
|
|
(gdbslet)
|
1349 |
|
|
|
1350 |
|
|
* Menu:
|
1351 |
|
|
|
1352 |
|
|
* Sparclet File:: Setting the file to debug
|
1353 |
|
|
* Sparclet Connection:: Connecting to Sparclet
|
1354 |
|
|
* Sparclet Download:: Sparclet download
|
1355 |
|
|
* Sparclet Execution:: Running and debugging
|
1356 |
|
|
|
1357 |
|
|
|
1358 |
|
|
File: gdb.info, Node: Sparclet File, Next: Sparclet Connection, Up: Sparclet
|
1359 |
|
|
|
1360 |
|
|
21.3.9.1 Setting File to Debug
|
1361 |
|
|
..............................
|
1362 |
|
|
|
1363 |
|
|
The GDB command `file' lets you choose with program to debug.
|
1364 |
|
|
|
1365 |
|
|
(gdbslet) file prog
|
1366 |
|
|
|
1367 |
|
|
GDB then attempts to read the symbol table of `prog'. GDB locates
|
1368 |
|
|
the file by searching the directories listed in the command search path.
|
1369 |
|
|
If the file was compiled with debug information (option `-g'), source
|
1370 |
|
|
files will be searched as well. GDB locates the source files by
|
1371 |
|
|
searching the directories listed in the directory search path (*note
|
1372 |
|
|
Your Program's Environment: Environment.). If it fails to find a file,
|
1373 |
|
|
it displays a message such as:
|
1374 |
|
|
|
1375 |
|
|
prog: No such file or directory.
|
1376 |
|
|
|
1377 |
|
|
When this happens, add the appropriate directories to the search
|
1378 |
|
|
paths with the GDB commands `path' and `dir', and execute the `target'
|
1379 |
|
|
command again.
|
1380 |
|
|
|
1381 |
|
|
|
1382 |
|
|
File: gdb.info, Node: Sparclet Connection, Next: Sparclet Download, Prev: Sparclet File, Up: Sparclet
|
1383 |
|
|
|
1384 |
|
|
21.3.9.2 Connecting to Sparclet
|
1385 |
|
|
...............................
|
1386 |
|
|
|
1387 |
|
|
The GDB command `target' lets you connect to a Sparclet target. To
|
1388 |
|
|
connect to a target on serial port "`ttya'", type:
|
1389 |
|
|
|
1390 |
|
|
(gdbslet) target sparclet /dev/ttya
|
1391 |
|
|
Remote target sparclet connected to /dev/ttya
|
1392 |
|
|
main () at ../prog.c:3
|
1393 |
|
|
|
1394 |
|
|
GDB displays messages like these:
|
1395 |
|
|
|
1396 |
|
|
Connected to ttya.
|
1397 |
|
|
|
1398 |
|
|
|
1399 |
|
|
File: gdb.info, Node: Sparclet Download, Next: Sparclet Execution, Prev: Sparclet Connection, Up: Sparclet
|
1400 |
|
|
|
1401 |
|
|
21.3.9.3 Sparclet Download
|
1402 |
|
|
..........................
|
1403 |
|
|
|
1404 |
|
|
Once connected to the Sparclet target, you can use the GDB `load'
|
1405 |
|
|
command to download the file from the host to the target. The file
|
1406 |
|
|
name and load offset should be given as arguments to the `load' command.
|
1407 |
|
|
Since the file format is aout, the program must be loaded to the
|
1408 |
|
|
starting address. You can use `objdump' to find out what this value
|
1409 |
|
|
is. The load offset is an offset which is added to the VMA (virtual
|
1410 |
|
|
memory address) of each of the file's sections. For instance, if the
|
1411 |
|
|
program `prog' was linked to text address 0x1201000, with data at
|
1412 |
|
|
0x12010160 and bss at 0x12010170, in GDB, type:
|
1413 |
|
|
|
1414 |
|
|
(gdbslet) load prog 0x12010000
|
1415 |
|
|
Loading section .text, size 0xdb0 vma 0x12010000
|
1416 |
|
|
|
1417 |
|
|
If the code is loaded at a different address then what the program
|
1418 |
|
|
was linked to, you may need to use the `section' and `add-symbol-file'
|
1419 |
|
|
commands to tell GDB where to map the symbol table.
|
1420 |
|
|
|
1421 |
|
|
|
1422 |
|
|
File: gdb.info, Node: Sparclet Execution, Prev: Sparclet Download, Up: Sparclet
|
1423 |
|
|
|
1424 |
|
|
21.3.9.4 Running and Debugging
|
1425 |
|
|
..............................
|
1426 |
|
|
|
1427 |
|
|
You can now begin debugging the task using GDB's execution control
|
1428 |
|
|
commands, `b', `step', `run', etc. See the GDB manual for the list of
|
1429 |
|
|
commands.
|
1430 |
|
|
|
1431 |
|
|
(gdbslet) b main
|
1432 |
|
|
Breakpoint 1 at 0x12010000: file prog.c, line 3.
|
1433 |
|
|
(gdbslet) run
|
1434 |
|
|
Starting program: prog
|
1435 |
|
|
Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
|
1436 |
|
|
3 char *symarg = 0;
|
1437 |
|
|
(gdbslet) step
|
1438 |
|
|
4 char *execarg = "hello!";
|
1439 |
|
|
(gdbslet)
|
1440 |
|
|
|
1441 |
|
|
|
1442 |
|
|
File: gdb.info, Node: Sparclite, Next: Z8000, Prev: Sparclet, Up: Embedded Processors
|
1443 |
|
|
|
1444 |
|
|
21.3.10 Fujitsu Sparclite
|
1445 |
|
|
-------------------------
|
1446 |
|
|
|
1447 |
|
|
`target sparclite DEV'
|
1448 |
|
|
Fujitsu sparclite boards, used only for the purpose of loading.
|
1449 |
|
|
You must use an additional command to debug the program. For
|
1450 |
|
|
example: target remote DEV using GDB standard remote protocol.
|
1451 |
|
|
|
1452 |
|
|
|
1453 |
|
|
|
1454 |
|
|
File: gdb.info, Node: Z8000, Next: AVR, Prev: Sparclite, Up: Embedded Processors
|
1455 |
|
|
|
1456 |
|
|
21.3.11 Zilog Z8000
|
1457 |
|
|
-------------------
|
1458 |
|
|
|
1459 |
|
|
When configured for debugging Zilog Z8000 targets, GDB includes a Z8000
|
1460 |
|
|
simulator.
|
1461 |
|
|
|
1462 |
|
|
For the Z8000 family, `target sim' simulates either the Z8002 (the
|
1463 |
|
|
unsegmented variant of the Z8000 architecture) or the Z8001 (the
|
1464 |
|
|
segmented variant). The simulator recognizes which architecture is
|
1465 |
|
|
appropriate by inspecting the object code.
|
1466 |
|
|
|
1467 |
|
|
`target sim ARGS'
|
1468 |
|
|
Debug programs on a simulated CPU. If the simulator supports setup
|
1469 |
|
|
options, specify them via ARGS.
|
1470 |
|
|
|
1471 |
|
|
After specifying this target, you can debug programs for the simulated
|
1472 |
|
|
CPU in the same style as programs for your host computer; use the
|
1473 |
|
|
`file' command to load a new program image, the `run' command to run
|
1474 |
|
|
your program, and so on.
|
1475 |
|
|
|
1476 |
|
|
As well as making available all the usual machine registers (*note
|
1477 |
|
|
Registers: Registers.), the Z8000 simulator provides three additional
|
1478 |
|
|
items of information as specially named registers:
|
1479 |
|
|
|
1480 |
|
|
`cycles'
|
1481 |
|
|
Counts clock-ticks in the simulator.
|
1482 |
|
|
|
1483 |
|
|
`insts'
|
1484 |
|
|
Counts instructions run in the simulator.
|
1485 |
|
|
|
1486 |
|
|
`time'
|
1487 |
|
|
Execution time in 60ths of a second.
|
1488 |
|
|
|
1489 |
|
|
|
1490 |
|
|
You can refer to these values in GDB expressions with the usual
|
1491 |
|
|
conventions; for example, `b fputc if $cycles>5000' sets a conditional
|
1492 |
|
|
breakpoint that suspends only after at least 5000 simulated clock ticks.
|
1493 |
|
|
|
1494 |
|
|
|
1495 |
|
|
File: gdb.info, Node: AVR, Next: CRIS, Prev: Z8000, Up: Embedded Processors
|
1496 |
|
|
|
1497 |
|
|
21.3.12 Atmel AVR
|
1498 |
|
|
-----------------
|
1499 |
|
|
|
1500 |
|
|
When configured for debugging the Atmel AVR, GDB supports the following
|
1501 |
|
|
AVR-specific commands:
|
1502 |
|
|
|
1503 |
|
|
`info io_registers'
|
1504 |
|
|
This command displays information about the AVR I/O registers. For
|
1505 |
|
|
each register, GDB prints its number and value.
|
1506 |
|
|
|
1507 |
|
|
|
1508 |
|
|
File: gdb.info, Node: CRIS, Next: Super-H, Prev: AVR, Up: Embedded Processors
|
1509 |
|
|
|
1510 |
|
|
21.3.13 CRIS
|
1511 |
|
|
------------
|
1512 |
|
|
|
1513 |
|
|
When configured for debugging CRIS, GDB provides the following
|
1514 |
|
|
CRIS-specific commands:
|
1515 |
|
|
|
1516 |
|
|
`set cris-version VER'
|
1517 |
|
|
Set the current CRIS version to VER, either `10' or `32'. The
|
1518 |
|
|
CRIS version affects register names and sizes. This command is
|
1519 |
|
|
useful in case autodetection of the CRIS version fails.
|
1520 |
|
|
|
1521 |
|
|
`show cris-version'
|
1522 |
|
|
Show the current CRIS version.
|
1523 |
|
|
|
1524 |
|
|
`set cris-dwarf2-cfi'
|
1525 |
|
|
Set the usage of DWARF-2 CFI for CRIS debugging. The default is
|
1526 |
|
|
`on'. Change to `off' when using `gcc-cris' whose version is below
|
1527 |
|
|
`R59'.
|
1528 |
|
|
|
1529 |
|
|
`show cris-dwarf2-cfi'
|
1530 |
|
|
Show the current state of using DWARF-2 CFI.
|
1531 |
|
|
|
1532 |
|
|
`set cris-mode MODE'
|
1533 |
|
|
Set the current CRIS mode to MODE. It should only be changed when
|
1534 |
|
|
debugging in guru mode, in which case it should be set to `guru'
|
1535 |
|
|
(the default is `normal').
|
1536 |
|
|
|
1537 |
|
|
`show cris-mode'
|
1538 |
|
|
Show the current CRIS mode.
|
1539 |
|
|
|
1540 |
|
|
|
1541 |
|
|
File: gdb.info, Node: Super-H, Prev: CRIS, Up: Embedded Processors
|
1542 |
|
|
|
1543 |
|
|
21.3.14 Renesas Super-H
|
1544 |
|
|
-----------------------
|
1545 |
|
|
|
1546 |
|
|
For the Renesas Super-H processor, GDB provides these commands:
|
1547 |
|
|
|
1548 |
|
|
`regs'
|
1549 |
|
|
Show the values of all Super-H registers.
|
1550 |
|
|
|
1551 |
|
|
`set sh calling-convention CONVENTION'
|
1552 |
|
|
Set the calling-convention used when calling functions from GDB.
|
1553 |
|
|
Allowed values are `gcc', which is the default setting, and
|
1554 |
|
|
`renesas'. With the `gcc' setting, functions are called using the
|
1555 |
|
|
GCC calling convention. If the DWARF-2 information of the called
|
1556 |
|
|
function specifies that the function follows the Renesas calling
|
1557 |
|
|
convention, the function is called using the Renesas calling
|
1558 |
|
|
convention. If the calling convention is set to `renesas', the
|
1559 |
|
|
Renesas calling convention is always used, regardless of the
|
1560 |
|
|
DWARF-2 information. This can be used to override the default of
|
1561 |
|
|
`gcc' if debug information is missing, or the compiler does not
|
1562 |
|
|
emit the DWARF-2 calling convention entry for a function.
|
1563 |
|
|
|
1564 |
|
|
`show sh calling-convention'
|
1565 |
|
|
Show the current calling convention setting.
|
1566 |
|
|
|
1567 |
|
|
|
1568 |
|
|
|
1569 |
|
|
File: gdb.info, Node: Architectures, Prev: Embedded Processors, Up: Configurations
|
1570 |
|
|
|
1571 |
|
|
21.4 Architectures
|
1572 |
|
|
==================
|
1573 |
|
|
|
1574 |
|
|
This section describes characteristics of architectures that affect all
|
1575 |
|
|
uses of GDB with the architecture, both native and cross.
|
1576 |
|
|
|
1577 |
|
|
* Menu:
|
1578 |
|
|
|
1579 |
|
|
* i386::
|
1580 |
|
|
* A29K::
|
1581 |
|
|
* Alpha::
|
1582 |
|
|
* MIPS::
|
1583 |
|
|
* HPPA:: HP PA architecture
|
1584 |
|
|
* SPU:: Cell Broadband Engine SPU architecture
|
1585 |
|
|
* PowerPC::
|
1586 |
|
|
|
1587 |
|
|
|
1588 |
|
|
File: gdb.info, Node: i386, Next: A29K, Up: Architectures
|
1589 |
|
|
|
1590 |
|
|
21.4.1 x86 Architecture-specific Issues
|
1591 |
|
|
---------------------------------------
|
1592 |
|
|
|
1593 |
|
|
`set struct-convention MODE'
|
1594 |
|
|
Set the convention used by the inferior to return `struct's and
|
1595 |
|
|
`union's from functions to MODE. Possible values of MODE are
|
1596 |
|
|
`"pcc"', `"reg"', and `"default"' (the default). `"default"' or
|
1597 |
|
|
`"pcc"' means that `struct's are returned on the stack, while
|
1598 |
|
|
`"reg"' means that a `struct' or a `union' whose size is 1, 2, 4,
|
1599 |
|
|
or 8 bytes will be returned in a register.
|
1600 |
|
|
|
1601 |
|
|
`show struct-convention'
|
1602 |
|
|
Show the current setting of the convention to return `struct's
|
1603 |
|
|
from functions.
|
1604 |
|
|
|
1605 |
|
|
|
1606 |
|
|
File: gdb.info, Node: A29K, Next: Alpha, Prev: i386, Up: Architectures
|
1607 |
|
|
|
1608 |
|
|
21.4.2 A29K
|
1609 |
|
|
-----------
|
1610 |
|
|
|
1611 |
|
|
`set rstack_high_address ADDRESS'
|
1612 |
|
|
On AMD 29000 family processors, registers are saved in a separate
|
1613 |
|
|
"register stack". There is no way for GDB to determine the extent
|
1614 |
|
|
of this stack. Normally, GDB just assumes that the stack is
|
1615 |
|
|
"large enough". This may result in GDB referencing memory
|
1616 |
|
|
locations that do not exist. If necessary, you can get around
|
1617 |
|
|
this problem by specifying the ending address of the register
|
1618 |
|
|
stack with the `set rstack_high_address' command. The argument
|
1619 |
|
|
should be an address, which you probably want to precede with `0x'
|
1620 |
|
|
to specify in hexadecimal.
|
1621 |
|
|
|
1622 |
|
|
`show rstack_high_address'
|
1623 |
|
|
Display the current limit of the register stack, on AMD 29000
|
1624 |
|
|
family processors.
|
1625 |
|
|
|
1626 |
|
|
|
1627 |
|
|
|
1628 |
|
|
File: gdb.info, Node: Alpha, Next: MIPS, Prev: A29K, Up: Architectures
|
1629 |
|
|
|
1630 |
|
|
21.4.3 Alpha
|
1631 |
|
|
------------
|
1632 |
|
|
|
1633 |
|
|
See the following section.
|
1634 |
|
|
|
1635 |
|
|
|
1636 |
|
|
File: gdb.info, Node: MIPS, Next: HPPA, Prev: Alpha, Up: Architectures
|
1637 |
|
|
|
1638 |
|
|
21.4.4 MIPS
|
1639 |
|
|
-----------
|
1640 |
|
|
|
1641 |
|
|
Alpha- and MIPS-based computers use an unusual stack frame, which
|
1642 |
|
|
sometimes requires GDB to search backward in the object code to find
|
1643 |
|
|
the beginning of a function.
|
1644 |
|
|
|
1645 |
|
|
To improve response time (especially for embedded applications, where
|
1646 |
|
|
GDB may be restricted to a slow serial line for this search) you may
|
1647 |
|
|
want to limit the size of this search, using one of these commands:
|
1648 |
|
|
|
1649 |
|
|
`set heuristic-fence-post LIMIT'
|
1650 |
|
|
Restrict GDB to examining at most LIMIT bytes in its search for
|
1651 |
|
|
the beginning of a function. A value of 0 (the default) means
|
1652 |
|
|
there is no limit. However, except for 0, the larger the limit
|
1653 |
|
|
the more bytes `heuristic-fence-post' must search and therefore
|
1654 |
|
|
the longer it takes to run. You should only need to use this
|
1655 |
|
|
command when debugging a stripped executable.
|
1656 |
|
|
|
1657 |
|
|
`show heuristic-fence-post'
|
1658 |
|
|
Display the current limit.
|
1659 |
|
|
|
1660 |
|
|
These commands are available _only_ when GDB is configured for
|
1661 |
|
|
debugging programs on Alpha or MIPS processors.
|
1662 |
|
|
|
1663 |
|
|
Several MIPS-specific commands are available when debugging MIPS
|
1664 |
|
|
programs:
|
1665 |
|
|
|
1666 |
|
|
`set mips abi ARG'
|
1667 |
|
|
Tell GDB which MIPS ABI is used by the inferior. Possible values
|
1668 |
|
|
of ARG are:
|
1669 |
|
|
|
1670 |
|
|
`auto'
|
1671 |
|
|
The default ABI associated with the current binary (this is
|
1672 |
|
|
the default).
|
1673 |
|
|
|
1674 |
|
|
`o32'
|
1675 |
|
|
|
1676 |
|
|
`o64'
|
1677 |
|
|
|
1678 |
|
|
`n32'
|
1679 |
|
|
|
1680 |
|
|
`n64'
|
1681 |
|
|
|
1682 |
|
|
`eabi32'
|
1683 |
|
|
|
1684 |
|
|
`eabi64'
|
1685 |
|
|
|
1686 |
|
|
`auto'
|
1687 |
|
|
|
1688 |
|
|
`show mips abi'
|
1689 |
|
|
Show the MIPS ABI used by GDB to debug the inferior.
|
1690 |
|
|
|
1691 |
|
|
`set mipsfpu'
|
1692 |
|
|
`show mipsfpu'
|
1693 |
|
|
*Note set mipsfpu: MIPS Embedded.
|
1694 |
|
|
|
1695 |
|
|
`set mips mask-address ARG'
|
1696 |
|
|
This command determines whether the most-significant 32 bits of
|
1697 |
|
|
64-bit MIPS addresses are masked off. The argument ARG can be
|
1698 |
|
|
`on', `off', or `auto'. The latter is the default setting, which
|
1699 |
|
|
lets GDB determine the correct value.
|
1700 |
|
|
|
1701 |
|
|
`show mips mask-address'
|
1702 |
|
|
Show whether the upper 32 bits of MIPS addresses are masked off or
|
1703 |
|
|
not.
|
1704 |
|
|
|
1705 |
|
|
`set remote-mips64-transfers-32bit-regs'
|
1706 |
|
|
This command controls compatibility with 64-bit MIPS targets that
|
1707 |
|
|
transfer data in 32-bit quantities. If you have an old MIPS 64
|
1708 |
|
|
target that transfers 32 bits for some registers, like SR and FSR,
|
1709 |
|
|
and 64 bits for other registers, set this option to `on'.
|
1710 |
|
|
|
1711 |
|
|
`show remote-mips64-transfers-32bit-regs'
|
1712 |
|
|
Show the current setting of compatibility with older MIPS 64
|
1713 |
|
|
targets.
|
1714 |
|
|
|
1715 |
|
|
`set debug mips'
|
1716 |
|
|
This command turns on and off debugging messages for the
|
1717 |
|
|
MIPS-specific target code in GDB.
|
1718 |
|
|
|
1719 |
|
|
`show debug mips'
|
1720 |
|
|
Show the current setting of MIPS debugging messages.
|
1721 |
|
|
|
1722 |
|
|
|
1723 |
|
|
File: gdb.info, Node: HPPA, Next: SPU, Prev: MIPS, Up: Architectures
|
1724 |
|
|
|
1725 |
|
|
21.4.5 HPPA
|
1726 |
|
|
-----------
|
1727 |
|
|
|
1728 |
|
|
When GDB is debugging the HP PA architecture, it provides the following
|
1729 |
|
|
special commands:
|
1730 |
|
|
|
1731 |
|
|
`set debug hppa'
|
1732 |
|
|
This command determines whether HPPA architecture-specific
|
1733 |
|
|
debugging messages are to be displayed.
|
1734 |
|
|
|
1735 |
|
|
`show debug hppa'
|
1736 |
|
|
Show whether HPPA debugging messages are displayed.
|
1737 |
|
|
|
1738 |
|
|
`maint print unwind ADDRESS'
|
1739 |
|
|
This command displays the contents of the unwind table entry at the
|
1740 |
|
|
given ADDRESS.
|
1741 |
|
|
|
1742 |
|
|
|
1743 |
|
|
|
1744 |
|
|
File: gdb.info, Node: SPU, Next: PowerPC, Prev: HPPA, Up: Architectures
|
1745 |
|
|
|
1746 |
|
|
21.4.6 Cell Broadband Engine SPU architecture
|
1747 |
|
|
---------------------------------------------
|
1748 |
|
|
|
1749 |
|
|
When GDB is debugging the Cell Broadband Engine SPU architecture, it
|
1750 |
|
|
provides the following special commands:
|
1751 |
|
|
|
1752 |
|
|
`info spu event'
|
1753 |
|
|
Display SPU event facility status. Shows current event mask and
|
1754 |
|
|
pending event status.
|
1755 |
|
|
|
1756 |
|
|
`info spu signal'
|
1757 |
|
|
Display SPU signal notification facility status. Shows pending
|
1758 |
|
|
signal-control word and signal notification mode of both signal
|
1759 |
|
|
notification channels.
|
1760 |
|
|
|
1761 |
|
|
`info spu mailbox'
|
1762 |
|
|
Display SPU mailbox facility status. Shows all pending entries,
|
1763 |
|
|
in order of processing, in each of the SPU Write Outbound, SPU
|
1764 |
|
|
Write Outbound Interrupt, and SPU Read Inbound mailboxes.
|
1765 |
|
|
|
1766 |
|
|
`info spu dma'
|
1767 |
|
|
Display MFC DMA status. Shows all pending commands in the MFC DMA
|
1768 |
|
|
queue. For each entry, opcode, tag, class IDs, effective and
|
1769 |
|
|
local store addresses and transfer size are shown.
|
1770 |
|
|
|
1771 |
|
|
`info spu proxydma'
|
1772 |
|
|
Display MFC Proxy-DMA status. Shows all pending commands in the
|
1773 |
|
|
MFC Proxy-DMA queue. For each entry, opcode, tag, class IDs,
|
1774 |
|
|
effective and local store addresses and transfer size are shown.
|
1775 |
|
|
|
1776 |
|
|
|
1777 |
|
|
When GDB is debugging a combined PowerPC/SPU application on the Cell
|
1778 |
|
|
Broadband Engine, it provides in addition the following special
|
1779 |
|
|
commands:
|
1780 |
|
|
|
1781 |
|
|
`set spu stop-on-load ARG'
|
1782 |
|
|
Set whether to stop for new SPE threads. When set to `on', GDB
|
1783 |
|
|
will give control to the user when a new SPE thread enters its
|
1784 |
|
|
`main' function. The default is `off'.
|
1785 |
|
|
|
1786 |
|
|
`show spu stop-on-load'
|
1787 |
|
|
Show whether to stop for new SPE threads.
|
1788 |
|
|
|
1789 |
|
|
`set spu auto-flush-cache ARG'
|
1790 |
|
|
Set whether to automatically flush the software-managed cache.
|
1791 |
|
|
When set to `on', GDB will automatically cause the SPE
|
1792 |
|
|
software-managed cache to be flushed whenever SPE execution stops.
|
1793 |
342 |
jeremybenn |
This provides a consistent view of PowerPC memory that is accessed
|
1794 |
|
|
via the cache. If an application does not use the
|
1795 |
330 |
jeremybenn |
software-managed cache, this option has no effect.
|
1796 |
|
|
|
1797 |
|
|
`show spu auto-flush-cache'
|
1798 |
|
|
Show whether to automatically flush the software-managed cache.
|
1799 |
|
|
|
1800 |
|
|
|
1801 |
|
|
|
1802 |
|
|
File: gdb.info, Node: PowerPC, Prev: SPU, Up: Architectures
|
1803 |
|
|
|
1804 |
|
|
21.4.7 PowerPC
|
1805 |
|
|
--------------
|
1806 |
|
|
|
1807 |
|
|
When GDB is debugging the PowerPC architecture, it provides a set of
|
1808 |
|
|
pseudo-registers to enable inspection of 128-bit wide Decimal Floating
|
1809 |
|
|
Point numbers stored in the floating point registers. These values must
|
1810 |
|
|
be stored in two consecutive registers, always starting at an even
|
1811 |
|
|
register like `f0' or `f2'.
|
1812 |
|
|
|
1813 |
|
|
The pseudo-registers go from `$dl0' through `$dl15', and are formed
|
1814 |
|
|
by joining the even/odd register pairs `f0' and `f1' for `$dl0', `f2'
|
1815 |
|
|
and `f3' for `$dl1' and so on.
|
1816 |
|
|
|
1817 |
|
|
For POWER7 processors, GDB provides a set of pseudo-registers, the
|
1818 |
|
|
64-bit wide Extended Floating Point Registers (`f32' through `f63').
|
1819 |
|
|
|
1820 |
|
|
|
1821 |
|
|
File: gdb.info, Node: Controlling GDB, Next: Extending GDB, Prev: Configurations, Up: Top
|
1822 |
|
|
|
1823 |
|
|
22 Controlling GDB
|
1824 |
|
|
******************
|
1825 |
|
|
|
1826 |
|
|
You can alter the way GDB interacts with you by using the `set'
|
1827 |
342 |
jeremybenn |
command. For commands controlling how GDB displays data, see *note
|
1828 |
330 |
jeremybenn |
Print Settings: Print Settings. Other settings are described here.
|
1829 |
|
|
|
1830 |
|
|
* Menu:
|
1831 |
|
|
|
1832 |
|
|
* Prompt:: Prompt
|
1833 |
|
|
* Editing:: Command editing
|
1834 |
|
|
* Command History:: Command history
|
1835 |
|
|
* Screen Size:: Screen size
|
1836 |
|
|
* Numbers:: Numbers
|
1837 |
|
|
* ABI:: Configuring the current ABI
|
1838 |
|
|
* Messages/Warnings:: Optional warnings and messages
|
1839 |
|
|
* Debugging Output:: Optional messages about internal happenings
|
1840 |
|
|
* Other Misc Settings:: Other Miscellaneous Settings
|
1841 |
|
|
|
1842 |
|
|
|
1843 |
|
|
File: gdb.info, Node: Prompt, Next: Editing, Up: Controlling GDB
|
1844 |
|
|
|
1845 |
|
|
22.1 Prompt
|
1846 |
|
|
===========
|
1847 |
|
|
|
1848 |
|
|
GDB indicates its readiness to read a command by printing a string
|
1849 |
|
|
called the "prompt". This string is normally `(gdb)'. You can change
|
1850 |
|
|
the prompt string with the `set prompt' command. For instance, when
|
1851 |
|
|
debugging GDB with GDB, it is useful to change the prompt in one of the
|
1852 |
|
|
GDB sessions so that you can always tell which one you are talking to.
|
1853 |
|
|
|
1854 |
|
|
_Note:_ `set prompt' does not add a space for you after the prompt
|
1855 |
|
|
you set. This allows you to set a prompt which ends in a space or a
|
1856 |
|
|
prompt that does not.
|
1857 |
|
|
|
1858 |
|
|
`set prompt NEWPROMPT'
|
1859 |
|
|
Directs GDB to use NEWPROMPT as its prompt string henceforth.
|
1860 |
|
|
|
1861 |
|
|
`show prompt'
|
1862 |
|
|
Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
|
1863 |
|
|
|
1864 |
|
|
|
1865 |
|
|
File: gdb.info, Node: Editing, Next: Command History, Prev: Prompt, Up: Controlling GDB
|
1866 |
|
|
|
1867 |
|
|
22.2 Command Editing
|
1868 |
|
|
====================
|
1869 |
|
|
|
1870 |
|
|
GDB reads its input commands via the "Readline" interface. This GNU
|
1871 |
|
|
library provides consistent behavior for programs which provide a
|
1872 |
|
|
command line interface to the user. Advantages are GNU Emacs-style or
|
1873 |
|
|
"vi"-style inline editing of commands, `csh'-like history substitution,
|
1874 |
|
|
and a storage and recall of command history across debugging sessions.
|
1875 |
|
|
|
1876 |
|
|
You may control the behavior of command line editing in GDB with the
|
1877 |
|
|
command `set'.
|
1878 |
|
|
|
1879 |
|
|
`set editing'
|
1880 |
|
|
`set editing on'
|
1881 |
|
|
Enable command line editing (enabled by default).
|
1882 |
|
|
|
1883 |
|
|
`set editing off'
|
1884 |
|
|
Disable command line editing.
|
1885 |
|
|
|
1886 |
|
|
`show editing'
|
1887 |
|
|
Show whether command line editing is enabled.
|
1888 |
|
|
|
1889 |
|
|
*Note Command Line Editing::, for more details about the Readline
|
1890 |
|
|
interface. Users unfamiliar with GNU Emacs or `vi' are encouraged to
|
1891 |
|
|
read that chapter.
|
1892 |
|
|
|
1893 |
|
|
|
1894 |
|
|
File: gdb.info, Node: Command History, Next: Screen Size, Prev: Editing, Up: Controlling GDB
|
1895 |
|
|
|
1896 |
|
|
22.3 Command History
|
1897 |
|
|
====================
|
1898 |
|
|
|
1899 |
|
|
GDB can keep track of the commands you type during your debugging
|
1900 |
|
|
sessions, so that you can be certain of precisely what happened. Use
|
1901 |
|
|
these commands to manage the GDB command history facility.
|
1902 |
|
|
|
1903 |
|
|
GDB uses the GNU History library, a part of the Readline package, to
|
1904 |
|
|
provide the history facility. *Note Using History Interactively::, for
|
1905 |
|
|
the detailed description of the History library.
|
1906 |
|
|
|
1907 |
|
|
To issue a command to GDB without affecting certain aspects of the
|
1908 |
|
|
state which is seen by users, prefix it with `server ' (*note Server
|
1909 |
|
|
Prefix::). This means that this command will not affect the command
|
1910 |
|
|
history, nor will it affect GDB's notion of which command to repeat if
|
1911 |
|
|
is pressed on a line by itself.
|
1912 |
|
|
|
1913 |
|
|
The server prefix does not affect the recording of values into the
|
1914 |
|
|
value history; to print a value without recording it into the value
|
1915 |
|
|
history, use the `output' command instead of the `print' command.
|
1916 |
|
|
|
1917 |
|
|
Here is the description of GDB commands related to command history.
|
1918 |
|
|
|
1919 |
|
|
`set history filename FNAME'
|
1920 |
|
|
Set the name of the GDB command history file to FNAME. This is
|
1921 |
|
|
the file where GDB reads an initial command history list, and
|
1922 |
|
|
where it writes the command history from this session when it
|
1923 |
|
|
exits. You can access this list through history expansion or
|
1924 |
|
|
through the history command editing characters listed below. This
|
1925 |
|
|
file defaults to the value of the environment variable
|
1926 |
|
|
`GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS)
|
1927 |
|
|
if this variable is not set.
|
1928 |
|
|
|
1929 |
|
|
`set history save'
|
1930 |
|
|
`set history save on'
|
1931 |
|
|
Record command history in a file, whose name may be specified with
|
1932 |
|
|
the `set history filename' command. By default, this option is
|
1933 |
|
|
disabled.
|
1934 |
|
|
|
1935 |
|
|
`set history save off'
|
1936 |
|
|
Stop recording command history in a file.
|
1937 |
|
|
|
1938 |
|
|
`set history size SIZE'
|
1939 |
|
|
Set the number of commands which GDB keeps in its history list.
|
1940 |
|
|
This defaults to the value of the environment variable `HISTSIZE',
|
1941 |
|
|
or to 256 if this variable is not set.
|
1942 |
|
|
|
1943 |
|
|
History expansion assigns special meaning to the character `!'.
|
1944 |
|
|
*Note Event Designators::, for more details.
|
1945 |
|
|
|
1946 |
|
|
Since `!' is also the logical not operator in C, history expansion
|
1947 |
|
|
is off by default. If you decide to enable history expansion with the
|
1948 |
|
|
`set history expansion on' command, you may sometimes need to follow
|
1949 |
|
|
`!' (when it is used as logical not, in an expression) with a space or
|
1950 |
|
|
a tab to prevent it from being expanded. The readline history
|
1951 |
|
|
facilities do not attempt substitution on the strings `!=' and `!(',
|
1952 |
|
|
even when history expansion is enabled.
|
1953 |
|
|
|
1954 |
|
|
The commands to control history expansion are:
|
1955 |
|
|
|
1956 |
|
|
`set history expansion on'
|
1957 |
|
|
`set history expansion'
|
1958 |
|
|
Enable history expansion. History expansion is off by default.
|
1959 |
|
|
|
1960 |
|
|
`set history expansion off'
|
1961 |
|
|
Disable history expansion.
|
1962 |
|
|
|
1963 |
|
|
`show history'
|
1964 |
|
|
`show history filename'
|
1965 |
|
|
`show history save'
|
1966 |
|
|
`show history size'
|
1967 |
|
|
`show history expansion'
|
1968 |
|
|
These commands display the state of the GDB history parameters.
|
1969 |
|
|
`show history' by itself displays all four states.
|
1970 |
|
|
|
1971 |
|
|
`show commands'
|
1972 |
|
|
Display the last ten commands in the command history.
|
1973 |
|
|
|
1974 |
|
|
`show commands N'
|
1975 |
|
|
Print ten commands centered on command number N.
|
1976 |
|
|
|
1977 |
|
|
`show commands +'
|
1978 |
|
|
Print ten commands just after the commands last printed.
|
1979 |
|
|
|
1980 |
|
|
|
1981 |
|
|
File: gdb.info, Node: Screen Size, Next: Numbers, Prev: Command History, Up: Controlling GDB
|
1982 |
|
|
|
1983 |
|
|
22.4 Screen Size
|
1984 |
|
|
================
|
1985 |
|
|
|
1986 |
|
|
Certain commands to GDB may produce large amounts of information output
|
1987 |
|
|
to the screen. To help you read all of it, GDB pauses and asks you for
|
1988 |
|
|
input at the end of each page of output. Type when you want to
|
1989 |
|
|
continue the output, or `q' to discard the remaining output. Also, the
|
1990 |
|
|
screen width setting determines when to wrap lines of output.
|
1991 |
|
|
Depending on what is being printed, GDB tries to break the line at a
|
1992 |
|
|
readable place, rather than simply letting it overflow onto the
|
1993 |
|
|
following line.
|
1994 |
|
|
|
1995 |
|
|
Normally GDB knows the size of the screen from the terminal driver
|
1996 |
|
|
software. For example, on Unix GDB uses the termcap data base together
|
1997 |
|
|
with the value of the `TERM' environment variable and the `stty rows'
|
1998 |
|
|
and `stty cols' settings. If this is not correct, you can override it
|
1999 |
|
|
with the `set height' and `set width' commands:
|
2000 |
|
|
|
2001 |
|
|
`set height LPP'
|
2002 |
|
|
`show height'
|
2003 |
|
|
`set width CPL'
|
2004 |
|
|
`show width'
|
2005 |
|
|
These `set' commands specify a screen height of LPP lines and a
|
2006 |
|
|
screen width of CPL characters. The associated `show' commands
|
2007 |
|
|
display the current settings.
|
2008 |
|
|
|
2009 |
|
|
If you specify a height of zero lines, GDB does not pause during
|
2010 |
|
|
output no matter how long the output is. This is useful if output
|
2011 |
|
|
is to a file or to an editor buffer.
|
2012 |
|
|
|
2013 |
|
|
Likewise, you can specify `set width 0' to prevent GDB from
|
2014 |
|
|
wrapping its output.
|
2015 |
|
|
|
2016 |
|
|
`set pagination on'
|
2017 |
|
|
`set pagination off'
|
2018 |
|
|
Turn the output pagination on or off; the default is on. Turning
|
2019 |
|
|
pagination off is the alternative to `set height 0'. Note that
|
2020 |
|
|
running GDB with the `--batch' option (*note -batch: Mode
|
2021 |
|
|
Options.) also automatically disables pagination.
|
2022 |
|
|
|
2023 |
|
|
`show pagination'
|
2024 |
|
|
Show the current pagination mode.
|
2025 |
|
|
|
2026 |
|
|
|
2027 |
|
|
File: gdb.info, Node: Numbers, Next: ABI, Prev: Screen Size, Up: Controlling GDB
|
2028 |
|
|
|
2029 |
|
|
22.5 Numbers
|
2030 |
|
|
============
|
2031 |
|
|
|
2032 |
|
|
You can always enter numbers in octal, decimal, or hexadecimal in GDB
|
2033 |
|
|
by the usual conventions: octal numbers begin with `0', decimal numbers
|
2034 |
|
|
end with `.', and hexadecimal numbers begin with `0x'. Numbers that
|
2035 |
|
|
neither begin with `0' or `0x', nor end with a `.' are, by default,
|
2036 |
|
|
entered in base 10; likewise, the default display for numbers--when no
|
2037 |
|
|
particular format is specified--is base 10. You can change the default
|
2038 |
|
|
base for both input and output with the commands described below.
|
2039 |
|
|
|
2040 |
|
|
`set input-radix BASE'
|
2041 |
|
|
Set the default base for numeric input. Supported choices for
|
2042 |
|
|
BASE are decimal 8, 10, or 16. BASE must itself be specified
|
2043 |
|
|
either unambiguously or using the current input radix; for
|
2044 |
|
|
example, any of
|
2045 |
|
|
|
2046 |
|
|
set input-radix 012
|
2047 |
|
|
set input-radix 10.
|
2048 |
|
|
set input-radix 0xa
|
2049 |
|
|
|
2050 |
|
|
sets the input base to decimal. On the other hand, `set
|
2051 |
|
|
input-radix 10' leaves the input radix unchanged, no matter what
|
2052 |
|
|
it was, since `10', being without any leading or trailing signs of
|
2053 |
|
|
its base, is interpreted in the current radix. Thus, if the
|
2054 |
|
|
current radix is 16, `10' is interpreted in hex, i.e. as 16
|
2055 |
|
|
decimal, which doesn't change the radix.
|
2056 |
|
|
|
2057 |
|
|
`set output-radix BASE'
|
2058 |
|
|
Set the default base for numeric display. Supported choices for
|
2059 |
|
|
BASE are decimal 8, 10, or 16. BASE must itself be specified
|
2060 |
|
|
either unambiguously or using the current input radix.
|
2061 |
|
|
|
2062 |
|
|
`show input-radix'
|
2063 |
|
|
Display the current default base for numeric input.
|
2064 |
|
|
|
2065 |
|
|
`show output-radix'
|
2066 |
|
|
Display the current default base for numeric display.
|
2067 |
|
|
|
2068 |
|
|
`set radix [BASE]'
|
2069 |
|
|
`show radix'
|
2070 |
|
|
These commands set and show the default base for both input and
|
2071 |
|
|
output of numbers. `set radix' sets the radix of input and output
|
2072 |
|
|
to the same base; without an argument, it resets the radix back to
|
2073 |
|
|
its default value of 10.
|
2074 |
|
|
|
2075 |
|
|
|
2076 |
|
|
|
2077 |
|
|
File: gdb.info, Node: ABI, Next: Messages/Warnings, Prev: Numbers, Up: Controlling GDB
|
2078 |
|
|
|
2079 |
|
|
22.6 Configuring the Current ABI
|
2080 |
|
|
================================
|
2081 |
|
|
|
2082 |
|
|
GDB can determine the "ABI" (Application Binary Interface) of your
|
2083 |
|
|
application automatically. However, sometimes you need to override its
|
2084 |
|
|
conclusions. Use these commands to manage GDB's view of the current
|
2085 |
|
|
ABI.
|
2086 |
|
|
|
2087 |
|
|
One GDB configuration can debug binaries for multiple operating
|
2088 |
|
|
system targets, either via remote debugging or native emulation. GDB
|
2089 |
|
|
will autodetect the "OS ABI" (Operating System ABI) in use, but you can
|
2090 |
|
|
override its conclusion using the `set osabi' command. One example
|
2091 |
|
|
where this is useful is in debugging of binaries which use an alternate
|
2092 |
|
|
C library (e.g. UCLIBC for GNU/Linux) which does not have the same
|
2093 |
|
|
identifying marks that the standard C library for your platform
|
2094 |
|
|
provides.
|
2095 |
|
|
|
2096 |
|
|
`show osabi'
|
2097 |
|
|
Show the OS ABI currently in use.
|
2098 |
|
|
|
2099 |
|
|
`set osabi'
|
2100 |
|
|
With no argument, show the list of registered available OS ABI's.
|
2101 |
|
|
|
2102 |
|
|
`set osabi ABI'
|
2103 |
|
|
Set the current OS ABI to ABI.
|
2104 |
|
|
|
2105 |
|
|
Generally, the way that an argument of type `float' is passed to a
|
2106 |
|
|
function depends on whether the function is prototyped. For a
|
2107 |
|
|
prototyped (i.e. ANSI/ISO style) function, `float' arguments are passed
|
2108 |
|
|
unchanged, according to the architecture's convention for `float'. For
|
2109 |
|
|
unprototyped (i.e. K&R style) functions, `float' arguments are first
|
2110 |
|
|
promoted to type `double' and then passed.
|
2111 |
|
|
|
2112 |
|
|
Unfortunately, some forms of debug information do not reliably
|
2113 |
|
|
indicate whether a function is prototyped. If GDB calls a function
|
2114 |
|
|
that is not marked as prototyped, it consults `set
|
2115 |
|
|
coerce-float-to-double'.
|
2116 |
|
|
|
2117 |
|
|
`set coerce-float-to-double'
|
2118 |
|
|
`set coerce-float-to-double on'
|
2119 |
|
|
Arguments of type `float' will be promoted to `double' when passed
|
2120 |
|
|
to an unprototyped function. This is the default setting.
|
2121 |
|
|
|
2122 |
|
|
`set coerce-float-to-double off'
|
2123 |
|
|
Arguments of type `float' will be passed directly to unprototyped
|
2124 |
|
|
functions.
|
2125 |
|
|
|
2126 |
|
|
`show coerce-float-to-double'
|
2127 |
|
|
Show the current setting of promoting `float' to `double'.
|
2128 |
|
|
|
2129 |
|
|
GDB needs to know the ABI used for your program's C++ objects. The
|
2130 |
|
|
correct C++ ABI depends on which C++ compiler was used to build your
|
2131 |
|
|
application. GDB only fully supports programs with a single C++ ABI;
|
2132 |
|
|
if your program contains code using multiple C++ ABI's or if GDB can
|
2133 |
|
|
not identify your program's ABI correctly, you can tell GDB which ABI
|
2134 |
|
|
to use. Currently supported ABI's include "gnu-v2", for `g++' versions
|
2135 |
|
|
before 3.0, "gnu-v3", for `g++' versions 3.0 and later, and "hpaCC" for
|
2136 |
|
|
the HP ANSI C++ compiler. Other C++ compilers may use the "gnu-v2" or
|
2137 |
|
|
"gnu-v3" ABI's as well. The default setting is "auto".
|
2138 |
|
|
|
2139 |
|
|
`show cp-abi'
|
2140 |
|
|
Show the C++ ABI currently in use.
|
2141 |
|
|
|
2142 |
|
|
`set cp-abi'
|
2143 |
|
|
With no argument, show the list of supported C++ ABI's.
|
2144 |
|
|
|
2145 |
|
|
`set cp-abi ABI'
|
2146 |
|
|
`set cp-abi auto'
|
2147 |
|
|
Set the current C++ ABI to ABI, or return to automatic detection.
|
2148 |
|
|
|
2149 |
|
|
|
2150 |
|
|
File: gdb.info, Node: Messages/Warnings, Next: Debugging Output, Prev: ABI, Up: Controlling GDB
|
2151 |
|
|
|
2152 |
|
|
22.7 Optional Warnings and Messages
|
2153 |
|
|
===================================
|
2154 |
|
|
|
2155 |
|
|
By default, GDB is silent about its inner workings. If you are running
|
2156 |
|
|
on a slow machine, you may want to use the `set verbose' command. This
|
2157 |
|
|
makes GDB tell you when it does a lengthy internal operation, so you
|
2158 |
|
|
will not think it has crashed.
|
2159 |
|
|
|
2160 |
|
|
Currently, the messages controlled by `set verbose' are those which
|
2161 |
|
|
announce that the symbol table for a source file is being read; see
|
2162 |
342 |
jeremybenn |
`symbol-file' in *note Commands to Specify Files: Files.
|
2163 |
330 |
jeremybenn |
|
2164 |
|
|
`set verbose on'
|
2165 |
|
|
Enables GDB output of certain informational messages.
|
2166 |
|
|
|
2167 |
|
|
`set verbose off'
|
2168 |
|
|
Disables GDB output of certain informational messages.
|
2169 |
|
|
|
2170 |
|
|
`show verbose'
|
2171 |
|
|
Displays whether `set verbose' is on or off.
|
2172 |
|
|
|
2173 |
|
|
By default, if GDB encounters bugs in the symbol table of an object
|
2174 |
|
|
file, it is silent; but if you are debugging a compiler, you may find
|
2175 |
|
|
this information useful (*note Errors Reading Symbol Files: Symbol
|
2176 |
|
|
Errors.).
|
2177 |
|
|
|
2178 |
|
|
`set complaints LIMIT'
|
2179 |
|
|
Permits GDB to output LIMIT complaints about each type of unusual
|
2180 |
|
|
symbols before becoming silent about the problem. Set LIMIT to
|
2181 |
|
|
zero to suppress all complaints; set it to a large number to
|
2182 |
|
|
prevent complaints from being suppressed.
|
2183 |
|
|
|
2184 |
|
|
`show complaints'
|
2185 |
|
|
Displays how many symbol complaints GDB is permitted to produce.
|
2186 |
|
|
|
2187 |
|
|
|
2188 |
|
|
By default, GDB is cautious, and asks what sometimes seems to be a
|
2189 |
|
|
lot of stupid questions to confirm certain commands. For example, if
|
2190 |
|
|
you try to run a program which is already running:
|
2191 |
|
|
|
2192 |
|
|
(gdb) run
|
2193 |
|
|
The program being debugged has been started already.
|
2194 |
|
|
Start it from the beginning? (y or n)
|
2195 |
|
|
|
2196 |
|
|
If you are willing to unflinchingly face the consequences of your own
|
2197 |
|
|
commands, you can disable this "feature":
|
2198 |
|
|
|
2199 |
|
|
`set confirm off'
|
2200 |
|
|
Disables confirmation requests. Note that running GDB with the
|
2201 |
|
|
`--batch' option (*note -batch: Mode Options.) also automatically
|
2202 |
|
|
disables confirmation requests.
|
2203 |
|
|
|
2204 |
|
|
`set confirm on'
|
2205 |
|
|
Enables confirmation requests (the default).
|
2206 |
|
|
|
2207 |
|
|
`show confirm'
|
2208 |
|
|
Displays state of confirmation requests.
|
2209 |
|
|
|
2210 |
|
|
|
2211 |
|
|
If you need to debug user-defined commands or sourced files you may
|
2212 |
|
|
find it useful to enable "command tracing". In this mode each command
|
2213 |
|
|
will be printed as it is executed, prefixed with one or more `+'
|
2214 |
|
|
symbols, the quantity denoting the call depth of each command.
|
2215 |
|
|
|
2216 |
|
|
`set trace-commands on'
|
2217 |
|
|
Enable command tracing.
|
2218 |
|
|
|
2219 |
|
|
`set trace-commands off'
|
2220 |
|
|
Disable command tracing.
|
2221 |
|
|
|
2222 |
|
|
`show trace-commands'
|
2223 |
|
|
Display the current state of command tracing.
|
2224 |
|
|
|
2225 |
|
|
|
2226 |
|
|
File: gdb.info, Node: Debugging Output, Next: Other Misc Settings, Prev: Messages/Warnings, Up: Controlling GDB
|
2227 |
|
|
|
2228 |
|
|
22.8 Optional Messages about Internal Happenings
|
2229 |
|
|
================================================
|
2230 |
|
|
|
2231 |
|
|
GDB has commands that enable optional debugging messages from various
|
2232 |
|
|
GDB subsystems; normally these commands are of interest to GDB
|
2233 |
|
|
maintainers, or when reporting a bug. This section documents those
|
2234 |
|
|
commands.
|
2235 |
|
|
|
2236 |
|
|
`set exec-done-display'
|
2237 |
|
|
Turns on or off the notification of asynchronous commands'
|
2238 |
|
|
completion. When on, GDB will print a message when an
|
2239 |
|
|
asynchronous command finishes its execution. The default is off.
|
2240 |
|
|
|
2241 |
|
|
`show exec-done-display'
|
2242 |
|
|
Displays the current setting of asynchronous command completion
|
2243 |
|
|
notification.
|
2244 |
|
|
|
2245 |
|
|
`set debug arch'
|
2246 |
|
|
Turns on or off display of gdbarch debugging info. The default is
|
2247 |
|
|
off
|
2248 |
|
|
|
2249 |
|
|
`show debug arch'
|
2250 |
|
|
Displays the current state of displaying gdbarch debugging info.
|
2251 |
|
|
|
2252 |
|
|
`set debug aix-thread'
|
2253 |
|
|
Display debugging messages about inner workings of the AIX thread
|
2254 |
|
|
module.
|
2255 |
|
|
|
2256 |
|
|
`show debug aix-thread'
|
2257 |
|
|
Show the current state of AIX thread debugging info display.
|
2258 |
|
|
|
2259 |
|
|
`set debug dwarf2-die'
|
2260 |
|
|
Dump DWARF2 DIEs after they are read in. The value is the number
|
2261 |
|
|
of nesting levels to print. A value of zero turns off the display.
|
2262 |
|
|
|
2263 |
|
|
`show debug dwarf2-die'
|
2264 |
|
|
Show the current state of DWARF2 DIE debugging.
|
2265 |
|
|
|
2266 |
|
|
`set debug displaced'
|
2267 |
|
|
Turns on or off display of GDB debugging info for the displaced
|
2268 |
|
|
stepping support. The default is off.
|
2269 |
|
|
|
2270 |
|
|
`show debug displaced'
|
2271 |
|
|
Displays the current state of displaying GDB debugging info
|
2272 |
|
|
related to displaced stepping.
|
2273 |
|
|
|
2274 |
|
|
`set debug event'
|
2275 |
|
|
Turns on or off display of GDB event debugging info. The default
|
2276 |
|
|
is off.
|
2277 |
|
|
|
2278 |
|
|
`show debug event'
|
2279 |
|
|
Displays the current state of displaying GDB event debugging info.
|
2280 |
|
|
|
2281 |
|
|
`set debug expression'
|
2282 |
|
|
Turns on or off display of debugging info about GDB expression
|
2283 |
|
|
parsing. The default is off.
|
2284 |
|
|
|
2285 |
|
|
`show debug expression'
|
2286 |
|
|
Displays the current state of displaying debugging info about GDB
|
2287 |
|
|
expression parsing.
|
2288 |
|
|
|
2289 |
|
|
`set debug frame'
|
2290 |
|
|
Turns on or off display of GDB frame debugging info. The default
|
2291 |
|
|
is off.
|
2292 |
|
|
|
2293 |
|
|
`show debug frame'
|
2294 |
|
|
Displays the current state of displaying GDB frame debugging info.
|
2295 |
|
|
|
2296 |
|
|
`set debug gnu-nat'
|
2297 |
|
|
Turns on or off debugging messages from the GNU/Hurd debug support.
|
2298 |
|
|
|
2299 |
|
|
`show debug gnu-nat'
|
2300 |
|
|
Show the current state of GNU/Hurd debugging messages.
|
2301 |
|
|
|
2302 |
|
|
`set debug infrun'
|
2303 |
|
|
Turns on or off display of GDB debugging info for running the
|
2304 |
|
|
inferior. The default is off. `infrun.c' contains GDB's runtime
|
2305 |
|
|
state machine used for implementing operations such as
|
2306 |
|
|
single-stepping the inferior.
|
2307 |
|
|
|
2308 |
|
|
`show debug infrun'
|
2309 |
|
|
Displays the current state of GDB inferior debugging.
|
2310 |
|
|
|
2311 |
|
|
`set debug lin-lwp'
|
2312 |
|
|
Turns on or off debugging messages from the Linux LWP debug
|
2313 |
|
|
support.
|
2314 |
|
|
|
2315 |
|
|
`show debug lin-lwp'
|
2316 |
|
|
Show the current state of Linux LWP debugging messages.
|
2317 |
|
|
|
2318 |
|
|
`set debug lin-lwp-async'
|
2319 |
|
|
Turns on or off debugging messages from the Linux LWP async debug
|
2320 |
|
|
support.
|
2321 |
|
|
|
2322 |
|
|
`show debug lin-lwp-async'
|
2323 |
|
|
Show the current state of Linux LWP async debugging messages.
|
2324 |
|
|
|
2325 |
|
|
`set debug observer'
|
2326 |
|
|
Turns on or off display of GDB observer debugging. This includes
|
2327 |
|
|
info such as the notification of observable events.
|
2328 |
|
|
|
2329 |
|
|
`show debug observer'
|
2330 |
|
|
Displays the current state of observer debugging.
|
2331 |
|
|
|
2332 |
|
|
`set debug overload'
|
2333 |
|
|
Turns on or off display of GDB C++ overload debugging info. This
|
2334 |
|
|
includes info such as ranking of functions, etc. The default is
|
2335 |
|
|
off.
|
2336 |
|
|
|
2337 |
|
|
`show debug overload'
|
2338 |
|
|
Displays the current state of displaying GDB C++ overload
|
2339 |
|
|
debugging info.
|
2340 |
|
|
|
2341 |
|
|
`set debug parser'
|
2342 |
|
|
Turns on or off the display of expression parser debugging output.
|
2343 |
|
|
Internally, this sets the `yydebug' variable in the expression
|
2344 |
|
|
parser. *Note Tracing Your Parser: (bison)Tracing, for details.
|
2345 |
|
|
The default is off.
|
2346 |
|
|
|
2347 |
|
|
`show debug parser'
|
2348 |
|
|
Show the current state of expression parser debugging.
|
2349 |
|
|
|
2350 |
|
|
`set debug remote'
|
2351 |
|
|
Turns on or off display of reports on all packets sent back and
|
2352 |
|
|
forth across the serial line to the remote machine. The info is
|
2353 |
|
|
printed on the GDB standard output stream. The default is off.
|
2354 |
|
|
|
2355 |
|
|
`show debug remote'
|
2356 |
|
|
Displays the state of display of remote packets.
|
2357 |
|
|
|
2358 |
|
|
`set debug serial'
|
2359 |
|
|
Turns on or off display of GDB serial debugging info. The default
|
2360 |
|
|
is off.
|
2361 |
|
|
|
2362 |
|
|
`show debug serial'
|
2363 |
|
|
Displays the current state of displaying GDB serial debugging info.
|
2364 |
|
|
|
2365 |
|
|
`set debug solib-frv'
|
2366 |
|
|
Turns on or off debugging messages for FR-V shared-library code.
|
2367 |
|
|
|
2368 |
|
|
`show debug solib-frv'
|
2369 |
|
|
Display the current state of FR-V shared-library code debugging
|
2370 |
|
|
messages.
|
2371 |
|
|
|
2372 |
|
|
`set debug target'
|
2373 |
|
|
Turns on or off display of GDB target debugging info. This info
|
2374 |
|
|
includes what is going on at the target level of GDB, as it
|
2375 |
|
|
happens. The default is 0. Set it to 1 to track events, and to 2
|
2376 |
|
|
to also track the value of large memory transfers. Changes to
|
2377 |
|
|
this flag do not take effect until the next time you connect to a
|
2378 |
|
|
target or use the `run' command.
|
2379 |
|
|
|
2380 |
|
|
`show debug target'
|
2381 |
|
|
Displays the current state of displaying GDB target debugging info.
|
2382 |
|
|
|
2383 |
|
|
`set debug timestamp'
|
2384 |
|
|
Turns on or off display of timestamps with GDB debugging info.
|
2385 |
|
|
When enabled, seconds and microseconds are displayed before each
|
2386 |
|
|
debugging message.
|
2387 |
|
|
|
2388 |
|
|
`show debug timestamp'
|
2389 |
|
|
Displays the current state of displaying timestamps with GDB
|
2390 |
|
|
debugging info.
|
2391 |
|
|
|
2392 |
|
|
`set debugvarobj'
|
2393 |
|
|
Turns on or off display of GDB variable object debugging info. The
|
2394 |
|
|
default is off.
|
2395 |
|
|
|
2396 |
|
|
`show debugvarobj'
|
2397 |
|
|
Displays the current state of displaying GDB variable object
|
2398 |
|
|
debugging info.
|
2399 |
|
|
|
2400 |
|
|
`set debug xml'
|
2401 |
|
|
Turns on or off debugging messages for built-in XML parsers.
|
2402 |
|
|
|
2403 |
|
|
`show debug xml'
|
2404 |
|
|
Displays the current state of XML debugging messages.
|
2405 |
|
|
|
2406 |
|
|
|
2407 |
|
|
File: gdb.info, Node: Other Misc Settings, Prev: Debugging Output, Up: Controlling GDB
|
2408 |
|
|
|
2409 |
|
|
22.9 Other Miscellaneous Settings
|
2410 |
|
|
=================================
|
2411 |
|
|
|
2412 |
|
|
`set interactive-mode'
|
2413 |
|
|
If `on', forces GDB to operate interactively. If `off', forces
|
2414 |
|
|
GDB to operate non-interactively, If `auto' (the default), GDB
|
2415 |
|
|
guesses which mode to use, based on whether the debugger was
|
2416 |
|
|
started in a terminal or not.
|
2417 |
|
|
|
2418 |
|
|
In the vast majority of cases, the debugger should be able to guess
|
2419 |
|
|
correctly which mode should be used. But this setting can be
|
2420 |
|
|
useful in certain specific cases, such as running a MinGW GDB
|
2421 |
|
|
inside a cygwin window.
|
2422 |
|
|
|
2423 |
|
|
`show interactive-mode'
|
2424 |
|
|
Displays whether the debugger is operating in interactive mode or
|
2425 |
|
|
not.
|
2426 |
|
|
|
2427 |
|
|
|
2428 |
|
|
File: gdb.info, Node: Extending GDB, Next: Interpreters, Prev: Controlling GDB, Up: Top
|
2429 |
|
|
|
2430 |
|
|
23 Extending GDB
|
2431 |
|
|
****************
|
2432 |
|
|
|
2433 |
|
|
GDB provides two mechanisms for extension. The first is based on
|
2434 |
|
|
composition of GDB commands, and the second is based on the Python
|
2435 |
|
|
scripting language.
|
2436 |
|
|
|
2437 |
|
|
To facilitate the use of these extensions, GDB is capable of
|
2438 |
|
|
evaluating the contents of a file. When doing so, GDB can recognize
|
2439 |
|
|
which scripting language is being used by looking at the filename
|
2440 |
|
|
extension. Files with an unrecognized filename extension are always
|
2441 |
|
|
treated as a GDB Command Files. *Note Command files: Command Files.
|
2442 |
|
|
|
2443 |
|
|
You can control how GDB evaluates these files with the following
|
2444 |
|
|
setting:
|
2445 |
|
|
|
2446 |
|
|
`set script-extension off'
|
2447 |
|
|
All scripts are always evaluated as GDB Command Files.
|
2448 |
|
|
|
2449 |
|
|
`set script-extension soft'
|
2450 |
|
|
The debugger determines the scripting language based on filename
|
2451 |
|
|
extension. If this scripting language is supported, GDB evaluates
|
2452 |
|
|
the script using that language. Otherwise, it evaluates the file
|
2453 |
|
|
as a GDB Command File.
|
2454 |
|
|
|
2455 |
|
|
`set script-extension strict'
|
2456 |
|
|
The debugger determines the scripting language based on filename
|
2457 |
|
|
extension, and evaluates the script using that language. If the
|
2458 |
|
|
language is not supported, then the evaluation fails.
|
2459 |
|
|
|
2460 |
|
|
`show script-extension'
|
2461 |
|
|
Display the current value of the `script-extension' option.
|
2462 |
|
|
|
2463 |
|
|
|
2464 |
|
|
* Menu:
|
2465 |
|
|
|
2466 |
|
|
* Sequences:: Canned Sequences of Commands
|
2467 |
|
|
* Python:: Scripting GDB using Python
|
2468 |
|
|
|
2469 |
|
|
|
2470 |
|
|
File: gdb.info, Node: Sequences, Next: Python, Up: Extending GDB
|
2471 |
|
|
|
2472 |
|
|
23.1 Canned Sequences of Commands
|
2473 |
|
|
=================================
|
2474 |
|
|
|
2475 |
|
|
Aside from breakpoint commands (*note Breakpoint Command Lists: Break
|
2476 |
|
|
Commands.), GDB provides two ways to store sequences of commands for
|
2477 |
|
|
execution as a unit: user-defined commands and command files.
|
2478 |
|
|
|
2479 |
|
|
* Menu:
|
2480 |
|
|
|
2481 |
|
|
* Define:: How to define your own commands
|
2482 |
|
|
* Hooks:: Hooks for user-defined commands
|
2483 |
|
|
* Command Files:: How to write scripts of commands to be stored in a file
|
2484 |
|
|
* Output:: Commands for controlled output
|
2485 |
|
|
|
2486 |
|
|
|
2487 |
|
|
File: gdb.info, Node: Define, Next: Hooks, Up: Sequences
|
2488 |
|
|
|
2489 |
|
|
23.1.1 User-defined Commands
|
2490 |
|
|
----------------------------
|
2491 |
|
|
|
2492 |
|
|
A "user-defined command" is a sequence of GDB commands to which you
|
2493 |
|
|
assign a new name as a command. This is done with the `define'
|
2494 |
|
|
command. User commands may accept up to 10 arguments separated by
|
2495 |
|
|
whitespace. Arguments are accessed within the user command via
|
2496 |
|
|
`$arg0...$arg9'. A trivial example:
|
2497 |
|
|
|
2498 |
|
|
define adder
|
2499 |
|
|
print $arg0 + $arg1 + $arg2
|
2500 |
|
|
end
|
2501 |
|
|
|
2502 |
|
|
To execute the command use:
|
2503 |
|
|
|
2504 |
|
|
adder 1 2 3
|
2505 |
|
|
|
2506 |
|
|
This defines the command `adder', which prints the sum of its three
|
2507 |
|
|
arguments. Note the arguments are text substitutions, so they may
|
2508 |
|
|
reference variables, use complex expressions, or even perform inferior
|
2509 |
|
|
functions calls.
|
2510 |
|
|
|
2511 |
|
|
In addition, `$argc' may be used to find out how many arguments have
|
2512 |
|
|
been passed. This expands to a number in the range 0...10.
|
2513 |
|
|
|
2514 |
|
|
define adder
|
2515 |
|
|
if $argc == 2
|
2516 |
|
|
print $arg0 + $arg1
|
2517 |
|
|
end
|
2518 |
|
|
if $argc == 3
|
2519 |
|
|
print $arg0 + $arg1 + $arg2
|
2520 |
|
|
end
|
2521 |
|
|
end
|
2522 |
|
|
|
2523 |
|
|
`define COMMANDNAME'
|
2524 |
|
|
Define a command named COMMANDNAME. If there is already a command
|
2525 |
|
|
by that name, you are asked to confirm that you want to redefine
|
2526 |
|
|
it. COMMANDNAME may be a bare command name consisting of letters,
|
2527 |
|
|
numbers, dashes, and underscores. It may also start with any
|
2528 |
|
|
predefined prefix command. For example, `define target my-target'
|
2529 |
|
|
creates a user-defined `target my-target' command.
|
2530 |
|
|
|
2531 |
|
|
The definition of the command is made up of other GDB command
|
2532 |
|
|
lines, which are given following the `define' command. The end of
|
2533 |
|
|
these commands is marked by a line containing `end'.
|
2534 |
|
|
|
2535 |
|
|
`document COMMANDNAME'
|
2536 |
|
|
Document the user-defined command COMMANDNAME, so that it can be
|
2537 |
|
|
accessed by `help'. The command COMMANDNAME must already be
|
2538 |
|
|
defined. This command reads lines of documentation just as
|
2539 |
|
|
`define' reads the lines of the command definition, ending with
|
2540 |
|
|
`end'. After the `document' command is finished, `help' on command
|
2541 |
|
|
COMMANDNAME displays the documentation you have written.
|
2542 |
|
|
|
2543 |
|
|
You may use the `document' command again to change the
|
2544 |
|
|
documentation of a command. Redefining the command with `define'
|
2545 |
|
|
does not change the documentation.
|
2546 |
|
|
|
2547 |
|
|
`dont-repeat'
|
2548 |
|
|
Used inside a user-defined command, this tells GDB that this
|
2549 |
|
|
command should not be repeated when the user hits (*note
|
2550 |
|
|
repeat last command: Command Syntax.).
|
2551 |
|
|
|
2552 |
|
|
`help user-defined'
|
2553 |
|
|
List all user-defined commands, with the first line of the
|
2554 |
|
|
documentation (if any) for each.
|
2555 |
|
|
|
2556 |
|
|
`show user'
|
2557 |
|
|
`show user COMMANDNAME'
|
2558 |
|
|
Display the GDB commands used to define COMMANDNAME (but not its
|
2559 |
|
|
documentation). If no COMMANDNAME is given, display the
|
2560 |
|
|
definitions for all user-defined commands.
|
2561 |
|
|
|
2562 |
|
|
`show max-user-call-depth'
|
2563 |
|
|
`set max-user-call-depth'
|
2564 |
|
|
The value of `max-user-call-depth' controls how many recursion
|
2565 |
|
|
levels are allowed in user-defined commands before GDB suspects an
|
2566 |
|
|
infinite recursion and aborts the command.
|
2567 |
|
|
|
2568 |
|
|
In addition to the above commands, user-defined commands frequently
|
2569 |
342 |
jeremybenn |
use control flow commands, described in *note Command Files::.
|
2570 |
330 |
jeremybenn |
|
2571 |
|
|
When user-defined commands are executed, the commands of the
|
2572 |
|
|
definition are not printed. An error in any command stops execution of
|
2573 |
|
|
the user-defined command.
|
2574 |
|
|
|
2575 |
|
|
If used interactively, commands that would ask for confirmation
|
2576 |
|
|
proceed without asking when used inside a user-defined command. Many
|
2577 |
|
|
GDB commands that normally print messages to say what they are doing
|
2578 |
|
|
omit the messages when used in a user-defined command.
|
2579 |
|
|
|
2580 |
|
|
|
2581 |
|
|
File: gdb.info, Node: Hooks, Next: Command Files, Prev: Define, Up: Sequences
|
2582 |
|
|
|
2583 |
|
|
23.1.2 User-defined Command Hooks
|
2584 |
|
|
---------------------------------
|
2585 |
|
|
|
2586 |
|
|
You may define "hooks", which are a special kind of user-defined
|
2587 |
|
|
command. Whenever you run the command `foo', if the user-defined
|
2588 |
|
|
command `hook-foo' exists, it is executed (with no arguments) before
|
2589 |
|
|
that command.
|
2590 |
|
|
|
2591 |
|
|
A hook may also be defined which is run after the command you
|
2592 |
|
|
executed. Whenever you run the command `foo', if the user-defined
|
2593 |
|
|
command `hookpost-foo' exists, it is executed (with no arguments) after
|
2594 |
|
|
that command. Post-execution hooks may exist simultaneously with
|
2595 |
|
|
pre-execution hooks, for the same command.
|
2596 |
|
|
|
2597 |
|
|
It is valid for a hook to call the command which it hooks. If this
|
2598 |
|
|
occurs, the hook is not re-executed, thereby avoiding infinite
|
2599 |
|
|
recursion.
|
2600 |
|
|
|
2601 |
|
|
In addition, a pseudo-command, `stop' exists. Defining
|
2602 |
|
|
(`hook-stop') makes the associated commands execute every time
|
2603 |
|
|
execution stops in your program: before breakpoint commands are run,
|
2604 |
|
|
displays are printed, or the stack frame is printed.
|
2605 |
|
|
|
2606 |
|
|
For example, to ignore `SIGALRM' signals while single-stepping, but
|
2607 |
|
|
treat them normally during normal execution, you could define:
|
2608 |
|
|
|
2609 |
|
|
define hook-stop
|
2610 |
|
|
handle SIGALRM nopass
|
2611 |
|
|
end
|
2612 |
|
|
|
2613 |
|
|
define hook-run
|
2614 |
|
|
handle SIGALRM pass
|
2615 |
|
|
end
|
2616 |
|
|
|
2617 |
|
|
define hook-continue
|
2618 |
|
|
handle SIGALRM pass
|
2619 |
|
|
end
|
2620 |
|
|
|
2621 |
|
|
As a further example, to hook at the beginning and end of the `echo'
|
2622 |
|
|
command, and to add extra text to the beginning and end of the message,
|
2623 |
|
|
you could define:
|
2624 |
|
|
|
2625 |
|
|
define hook-echo
|
2626 |
|
|
echo <<<---
|
2627 |
|
|
end
|
2628 |
|
|
|
2629 |
|
|
define hookpost-echo
|
2630 |
|
|
echo --->>>\n
|
2631 |
|
|
end
|
2632 |
|
|
|
2633 |
|
|
(gdb) echo Hello World
|
2634 |
|
|
<<<---Hello World--->>>
|
2635 |
|
|
(gdb)
|
2636 |
|
|
|
2637 |
|
|
You can define a hook for any single-word command in GDB, but not
|
2638 |
|
|
for command aliases; you should define a hook for the basic command
|
2639 |
|
|
name, e.g. `backtrace' rather than `bt'. You can hook a multi-word
|
2640 |
|
|
command by adding `hook-' or `hookpost-' to the last word of the
|
2641 |
|
|
command, e.g. `define target hook-remote' to add a hook to `target
|
2642 |
|
|
remote'.
|
2643 |
|
|
|
2644 |
|
|
If an error occurs during the execution of your hook, execution of
|
2645 |
|
|
GDB commands stops and GDB issues a prompt (before the command that you
|
2646 |
|
|
actually typed had a chance to run).
|
2647 |
|
|
|
2648 |
|
|
If you try to define a hook which does not match any known command,
|
2649 |
|
|
you get a warning from the `define' command.
|
2650 |
|
|
|
2651 |
|
|
|
2652 |
|
|
File: gdb.info, Node: Command Files, Next: Output, Prev: Hooks, Up: Sequences
|
2653 |
|
|
|
2654 |
|
|
23.1.3 Command Files
|
2655 |
|
|
--------------------
|
2656 |
|
|
|
2657 |
|
|
A command file for GDB is a text file made of lines that are GDB
|
2658 |
|
|
commands. Comments (lines starting with `#') may also be included. An
|
2659 |
|
|
empty line in a command file does nothing; it does not mean to repeat
|
2660 |
|
|
the last command, as it would from the terminal.
|
2661 |
|
|
|
2662 |
|
|
You can request the execution of a command file with the `source'
|
2663 |
|
|
command. Note that the `source' command is also used to evaluate
|
2664 |
|
|
scripts that are not Command Files. The exact behavior can be
|
2665 |
|
|
configured using the `script-extension' setting. *Note Extending GDB:
|
2666 |
|
|
Extending GDB.
|
2667 |
|
|
|
2668 |
|
|
`source [-s] [-v] FILENAME'
|
2669 |
|
|
Execute the command file FILENAME.
|
2670 |
|
|
|
2671 |
|
|
The lines in a command file are generally executed sequentially,
|
2672 |
|
|
unless the order of execution is changed by one of the _flow-control
|
2673 |
|
|
commands_ described below. The commands are not printed as they are
|
2674 |
|
|
executed. An error in any command terminates execution of the command
|
2675 |
|
|
file and control is returned to the console.
|
2676 |
|
|
|
2677 |
|
|
GDB first searches for FILENAME in the current directory. If the
|
2678 |
|
|
file is not found there, and FILENAME does not specify a directory,
|
2679 |
|
|
then GDB also looks for the file on the source search path (specified
|
2680 |
|
|
with the `directory' command); except that `$cdir' is not searched
|
2681 |
|
|
because the compilation directory is not relevant to scripts.
|
2682 |
|
|
|
2683 |
|
|
If `-s' is specified, then GDB searches for FILENAME on the search
|
2684 |
|
|
path even if FILENAME specifies a directory. The search is done by
|
2685 |
|
|
appending FILENAME to each element of the search path. So, for
|
2686 |
|
|
example, if FILENAME is `mylib/myscript' and the search path contains
|
2687 |
|
|
`/home/user' then GDB will look for the script
|
2688 |
|
|
`/home/user/mylib/myscript'. The search is also done if FILENAME is an
|
2689 |
|
|
absolute path. For example, if FILENAME is `/tmp/myscript' and the
|
2690 |
|
|
search path contains `/home/user' then GDB will look for the script
|
2691 |
|
|
`/home/user/tmp/myscript'. For DOS-like systems, if FILENAME contains
|
2692 |
|
|
a drive specification, it is stripped before concatenation. For
|
2693 |
|
|
example, if FILENAME is `d:myscript' and the search path contains
|
2694 |
|
|
`c:/tmp' then GDB will look for the script `c:/tmp/myscript'.
|
2695 |
|
|
|
2696 |
|
|
If `-v', for verbose mode, is given then GDB displays each command
|
2697 |
|
|
as it is executed. The option must be given before FILENAME, and is
|
2698 |
|
|
interpreted as part of the filename anywhere else.
|
2699 |
|
|
|
2700 |
|
|
Commands that would ask for confirmation if used interactively
|
2701 |
|
|
proceed without asking when used in a command file. Many GDB commands
|
2702 |
|
|
that normally print messages to say what they are doing omit the
|
2703 |
|
|
messages when called from command files.
|
2704 |
|
|
|
2705 |
|
|
GDB also accepts command input from standard input. In this mode,
|
2706 |
|
|
normal output goes to standard output and error output goes to standard
|
2707 |
|
|
error. Errors in a command file supplied on standard input do not
|
2708 |
|
|
terminate execution of the command file--execution continues with the
|
2709 |
|
|
next command.
|
2710 |
|
|
|
2711 |
|
|
gdb < cmds > log 2>&1
|
2712 |
|
|
|
2713 |
|
|
(The syntax above will vary depending on the shell used.) This
|
2714 |
|
|
example will execute commands from the file `cmds'. All output and
|
2715 |
|
|
errors would be directed to `log'.
|
2716 |
|
|
|
2717 |
|
|
Since commands stored on command files tend to be more general than
|
2718 |
|
|
commands typed interactively, they frequently need to deal with
|
2719 |
|
|
complicated situations, such as different or unexpected values of
|
2720 |
|
|
variables and symbols, changes in how the program being debugged is
|
2721 |
|
|
built, etc. GDB provides a set of flow-control commands to deal with
|
2722 |
|
|
these complexities. Using these commands, you can write complex
|
2723 |
|
|
scripts that loop over data structures, execute commands conditionally,
|
2724 |
|
|
etc.
|
2725 |
|
|
|
2726 |
|
|
`if'
|
2727 |
|
|
`else'
|
2728 |
|
|
This command allows to include in your script conditionally
|
2729 |
|
|
executed commands. The `if' command takes a single argument, which
|
2730 |
|
|
is an expression to evaluate. It is followed by a series of
|
2731 |
|
|
commands that are executed only if the expression is true (its
|
2732 |
|
|
value is nonzero). There can then optionally be an `else' line,
|
2733 |
|
|
followed by a series of commands that are only executed if the
|
2734 |
|
|
expression was false. The end of the list is marked by a line
|
2735 |
|
|
containing `end'.
|
2736 |
|
|
|
2737 |
|
|
`while'
|
2738 |
|
|
This command allows to write loops. Its syntax is similar to
|
2739 |
|
|
`if': the command takes a single argument, which is an expression
|
2740 |
|
|
to evaluate, and must be followed by the commands to execute, one
|
2741 |
|
|
per line, terminated by an `end'. These commands are called the
|
2742 |
|
|
"body" of the loop. The commands in the body of `while' are
|
2743 |
|
|
executed repeatedly as long as the expression evaluates to true.
|
2744 |
|
|
|
2745 |
|
|
`loop_break'
|
2746 |
|
|
This command exits the `while' loop in whose body it is included.
|
2747 |
|
|
Execution of the script continues after that `while's `end' line.
|
2748 |
|
|
|
2749 |
|
|
`loop_continue'
|
2750 |
|
|
This command skips the execution of the rest of the body of
|
2751 |
|
|
commands in the `while' loop in whose body it is included.
|
2752 |
|
|
Execution branches to the beginning of the `while' loop, where it
|
2753 |
|
|
evaluates the controlling expression.
|
2754 |
|
|
|
2755 |
|
|
`end'
|
2756 |
|
|
Terminate the block of commands that are the body of `if', `else',
|
2757 |
|
|
or `while' flow-control commands.
|
2758 |
|
|
|
2759 |
|
|
|
2760 |
|
|
File: gdb.info, Node: Output, Prev: Command Files, Up: Sequences
|
2761 |
|
|
|
2762 |
|
|
23.1.4 Commands for Controlled Output
|
2763 |
|
|
-------------------------------------
|
2764 |
|
|
|
2765 |
|
|
During the execution of a command file or a user-defined command, normal
|
2766 |
|
|
GDB output is suppressed; the only output that appears is what is
|
2767 |
|
|
explicitly printed by the commands in the definition. This section
|
2768 |
|
|
describes three commands useful for generating exactly the output you
|
2769 |
|
|
want.
|
2770 |
|
|
|
2771 |
|
|
`echo TEXT'
|
2772 |
|
|
Print TEXT. Nonprinting characters can be included in TEXT using
|
2773 |
|
|
C escape sequences, such as `\n' to print a newline. *No newline
|
2774 |
|
|
is printed unless you specify one.* In addition to the standard C
|
2775 |
|
|
escape sequences, a backslash followed by a space stands for a
|
2776 |
|
|
space. This is useful for displaying a string with spaces at the
|
2777 |
|
|
beginning or the end, since leading and trailing spaces are
|
2778 |
|
|
otherwise trimmed from all arguments. To print ` and foo = ', use
|
2779 |
|
|
the command `echo \ and foo = \ '.
|
2780 |
|
|
|
2781 |
|
|
A backslash at the end of TEXT can be used, as in C, to continue
|
2782 |
|
|
the command onto subsequent lines. For example,
|
2783 |
|
|
|
2784 |
|
|
echo This is some text\n\
|
2785 |
|
|
which is continued\n\
|
2786 |
|
|
onto several lines.\n
|
2787 |
|
|
|
2788 |
|
|
produces the same output as
|
2789 |
|
|
|
2790 |
|
|
echo This is some text\n
|
2791 |
|
|
echo which is continued\n
|
2792 |
|
|
echo onto several lines.\n
|
2793 |
|
|
|
2794 |
|
|
`output EXPRESSION'
|
2795 |
|
|
Print the value of EXPRESSION and nothing but that value: no
|
2796 |
|
|
newlines, no `$NN = '. The value is not entered in the value
|
2797 |
|
|
history either. *Note Expressions: Expressions, for more
|
2798 |
|
|
information on expressions.
|
2799 |
|
|
|
2800 |
|
|
`output/FMT EXPRESSION'
|
2801 |
|
|
Print the value of EXPRESSION in format FMT. You can use the same
|
2802 |
|
|
formats as for `print'. *Note Output Formats: Output Formats, for
|
2803 |
|
|
more information.
|
2804 |
|
|
|
2805 |
|
|
`printf TEMPLATE, EXPRESSIONS...'
|
2806 |
|
|
Print the values of one or more EXPRESSIONS under the control of
|
2807 |
|
|
the string TEMPLATE. To print several values, make EXPRESSIONS be
|
2808 |
|
|
a comma-separated list of individual expressions, which may be
|
2809 |
|
|
either numbers or pointers. Their values are printed as specified
|
2810 |
|
|
by TEMPLATE, exactly as a C program would do by executing the code
|
2811 |
|
|
below:
|
2812 |
|
|
|
2813 |
|
|
printf (TEMPLATE, EXPRESSIONS...);
|
2814 |
|
|
|
2815 |
|
|
As in `C' `printf', ordinary characters in TEMPLATE are printed
|
2816 |
|
|
verbatim, while "conversion specification" introduced by the `%'
|
2817 |
|
|
character cause subsequent EXPRESSIONS to be evaluated, their
|
2818 |
|
|
values converted and formatted according to type and style
|
2819 |
|
|
information encoded in the conversion specifications, and then
|
2820 |
|
|
printed.
|
2821 |
|
|
|
2822 |
|
|
For example, you can print two values in hex like this:
|
2823 |
|
|
|
2824 |
|
|
printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
|
2825 |
|
|
|
2826 |
|
|
`printf' supports all the standard `C' conversion specifications,
|
2827 |
|
|
including the flags and modifiers between the `%' character and
|
2828 |
|
|
the conversion letter, with the following exceptions:
|
2829 |
|
|
|
2830 |
|
|
* The argument-ordering modifiers, such as `2$', are not
|
2831 |
|
|
supported.
|
2832 |
|
|
|
2833 |
|
|
* The modifier `*' is not supported for specifying precision or
|
2834 |
|
|
width.
|
2835 |
|
|
|
2836 |
|
|
* The `'' flag (for separation of digits into groups according
|
2837 |
|
|
to `LC_NUMERIC'') is not supported.
|
2838 |
|
|
|
2839 |
|
|
* The type modifiers `hh', `j', `t', and `z' are not supported.
|
2840 |
|
|
|
2841 |
|
|
* The conversion letter `n' (as in `%n') is not supported.
|
2842 |
|
|
|
2843 |
|
|
* The conversion letters `a' and `A' are not supported.
|
2844 |
|
|
|
2845 |
|
|
Note that the `ll' type modifier is supported only if the
|
2846 |
|
|
underlying `C' implementation used to build GDB supports the `long
|
2847 |
|
|
long int' type, and the `L' type modifier is supported only if
|
2848 |
|
|
`long double' type is available.
|
2849 |
|
|
|
2850 |
|
|
As in `C', `printf' supports simple backslash-escape sequences,
|
2851 |
|
|
such as `\n', `\t', `\\', `\"', `\a', and `\f', that consist of
|
2852 |
|
|
backslash followed by a single character. Octal and hexadecimal
|
2853 |
|
|
escape sequences are not supported.
|
2854 |
|
|
|
2855 |
|
|
Additionally, `printf' supports conversion specifications for DFP
|
2856 |
|
|
("Decimal Floating Point") types using the following length
|
2857 |
|
|
modifiers together with a floating point specifier. letters:
|
2858 |
|
|
|
2859 |
|
|
* `H' for printing `Decimal32' types.
|
2860 |
|
|
|
2861 |
|
|
* `D' for printing `Decimal64' types.
|
2862 |
|
|
|
2863 |
|
|
* `DD' for printing `Decimal128' types.
|
2864 |
|
|
|
2865 |
|
|
If the underlying `C' implementation used to build GDB has support
|
2866 |
|
|
for the three length modifiers for DFP types, other modifiers such
|
2867 |
|
|
as width and precision will also be available for GDB to use.
|
2868 |
|
|
|
2869 |
|
|
In case there is no such `C' support, no additional modifiers will
|
2870 |
|
|
be available and the value will be printed in the standard way.
|
2871 |
|
|
|
2872 |
|
|
Here's an example of printing DFP types using the above conversion
|
2873 |
|
|
letters:
|
2874 |
|
|
printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
|
2875 |
|
|
|
2876 |
|
|
`eval TEMPLATE, EXPRESSIONS...'
|
2877 |
|
|
Convert the values of one or more EXPRESSIONS under the control of
|
2878 |
|
|
the string TEMPLATE to a command line, and call it.
|
2879 |
|
|
|
2880 |
|
|
|
2881 |
|
|
|
2882 |
|
|
File: gdb.info, Node: Python, Prev: Sequences, Up: Extending GDB
|
2883 |
|
|
|
2884 |
|
|
23.2 Scripting GDB using Python
|
2885 |
|
|
===============================
|
2886 |
|
|
|
2887 |
|
|
You can script GDB using the Python programming language
|
2888 |
|
|
(http://www.python.org/). This feature is available only if GDB was
|
2889 |
|
|
configured using `--with-python'.
|
2890 |
|
|
|
2891 |
|
|
Python scripts used by GDB should be installed in
|
2892 |
|
|
`DATA-DIRECTORY/python', where DATA-DIRECTORY is the data directory as
|
2893 |
|
|
determined at GDB startup (*note Data Files::). This directory, known
|
2894 |
|
|
as the "python directory", is automatically added to the Python Search
|
2895 |
|
|
Path in order to allow the Python interpreter to locate all scripts
|
2896 |
|
|
installed at this location.
|
2897 |
|
|
|
2898 |
|
|
* Menu:
|
2899 |
|
|
|
2900 |
|
|
* Python Commands:: Accessing Python from GDB.
|
2901 |
|
|
* Python API:: Accessing GDB from Python.
|
2902 |
|
|
* Auto-loading:: Automatically loading Python code.
|
2903 |
|
|
|
2904 |
|
|
|
2905 |
|
|
File: gdb.info, Node: Python Commands, Next: Python API, Up: Python
|
2906 |
|
|
|
2907 |
|
|
23.2.1 Python Commands
|
2908 |
|
|
----------------------
|
2909 |
|
|
|
2910 |
|
|
GDB provides one command for accessing the Python interpreter, and one
|
2911 |
|
|
related setting:
|
2912 |
|
|
|
2913 |
|
|
`python [CODE]'
|
2914 |
|
|
The `python' command can be used to evaluate Python code.
|
2915 |
|
|
|
2916 |
|
|
If given an argument, the `python' command will evaluate the
|
2917 |
|
|
argument as a Python command. For example:
|
2918 |
|
|
|
2919 |
|
|
(gdb) python print 23
|
2920 |
|
|
23
|
2921 |
|
|
|
2922 |
|
|
If you do not provide an argument to `python', it will act as a
|
2923 |
|
|
multi-line command, like `define'. In this case, the Python
|
2924 |
|
|
script is made up of subsequent command lines, given after the
|
2925 |
|
|
`python' command. This command list is terminated using a line
|
2926 |
|
|
containing `end'. For example:
|
2927 |
|
|
|
2928 |
|
|
(gdb) python
|
2929 |
|
|
Type python script
|
2930 |
|
|
End with a line saying just "end".
|
2931 |
|
|
>print 23
|
2932 |
|
|
>end
|
2933 |
|
|
23
|
2934 |
|
|
|
2935 |
|
|
`maint set python print-stack'
|
2936 |
|
|
By default, GDB will print a stack trace when an error occurs in a
|
2937 |
|
|
Python script. This can be controlled using `maint set python
|
2938 |
|
|
print-stack': if `on', the default, then Python stack printing is
|
2939 |
|
|
enabled; if `off', then Python stack printing is disabled.
|
2940 |
|
|
|
2941 |
|
|
It is also possible to execute a Python script from the GDB
|
2942 |
|
|
interpreter:
|
2943 |
|
|
|
2944 |
|
|
`source `script-name''
|
2945 |
|
|
The script name must end with `.py' and GDB must be configured to
|
2946 |
|
|
recognize the script language based on filename extension using
|
2947 |
|
|
the `script-extension' setting. *Note Extending GDB: Extending
|
2948 |
|
|
GDB.
|
2949 |
|
|
|
2950 |
|
|
`python execfile ("script-name")'
|
2951 |
|
|
This method is based on the `execfile' Python built-in function,
|
2952 |
|
|
and thus is always available.
|
2953 |
|
|
|
2954 |
|
|
|
2955 |
|
|
File: gdb.info, Node: Python API, Next: Auto-loading, Prev: Python Commands, Up: Python
|
2956 |
|
|
|
2957 |
|
|
23.2.2 Python API
|
2958 |
|
|
-----------------
|
2959 |
|
|
|
2960 |
|
|
At startup, GDB overrides Python's `sys.stdout' and `sys.stderr' to
|
2961 |
|
|
print using GDB's output-paging streams. A Python program which
|
2962 |
|
|
outputs to one of these streams may have its output interrupted by the
|
2963 |
|
|
user (*note Screen Size::). In this situation, a Python
|
2964 |
|
|
`KeyboardInterrupt' exception is thrown.
|
2965 |
|
|
|
2966 |
|
|
* Menu:
|
2967 |
|
|
|
2968 |
|
|
* Basic Python:: Basic Python Functions.
|
2969 |
|
|
* Exception Handling::
|
2970 |
|
|
* Values From Inferior::
|
2971 |
|
|
* Types In Python:: Python representation of types.
|
2972 |
|
|
* Pretty Printing API:: Pretty-printing values.
|
2973 |
|
|
* Selecting Pretty-Printers:: How GDB chooses a pretty-printer.
|
2974 |
|
|
* Disabling Pretty-Printers:: Disabling broken printers.
|
2975 |
|
|
* Inferiors In Python:: Python representation of inferiors (processes)
|
2976 |
|
|
* Threads In Python:: Accessing inferior threads from Python.
|
2977 |
|
|
* Commands In Python:: Implementing new commands in Python.
|
2978 |
|
|
* Parameters In Python:: Adding new GDB parameters.
|
2979 |
|
|
* Functions In Python:: Writing new convenience functions.
|
2980 |
|
|
* Progspaces In Python:: Program spaces.
|
2981 |
|
|
* Objfiles In Python:: Object files.
|
2982 |
|
|
* Frames In Python:: Accessing inferior stack frames from Python.
|
2983 |
|
|
* Blocks In Python:: Accessing frame blocks from Python.
|
2984 |
|
|
* Symbols In Python:: Python representation of symbols.
|
2985 |
|
|
* Symbol Tables In Python:: Python representation of symbol tables.
|
2986 |
|
|
* Lazy Strings In Python:: Python representation of lazy strings.
|
2987 |
|
|
* Breakpoints In Python:: Manipulating breakpoints using Python.
|
2988 |
|
|
|
2989 |
|
|
|
2990 |
|
|
File: gdb.info, Node: Basic Python, Next: Exception Handling, Up: Python API
|
2991 |
|
|
|
2992 |
|
|
23.2.2.1 Basic Python
|
2993 |
|
|
.....................
|
2994 |
|
|
|
2995 |
|
|
GDB introduces a new Python module, named `gdb'. All methods and
|
2996 |
|
|
classes added by GDB are placed in this module. GDB automatically
|
2997 |
|
|
`import's the `gdb' module for use in all scripts evaluated by the
|
2998 |
|
|
`python' command.
|
2999 |
|
|
|
3000 |
|
|
-- Variable: PYTHONDIR
|
3001 |
|
|
A string containing the python directory (*note Python::).
|
3002 |
|
|
|
3003 |
|
|
-- Function: execute command [from_tty] [to_string]
|
3004 |
|
|
Evaluate COMMAND, a string, as a GDB CLI command. If a GDB
|
3005 |
|
|
exception happens while COMMAND runs, it is translated as
|
3006 |
342 |
jeremybenn |
described in *note Exception Handling: Exception Handling.
|
3007 |
330 |
jeremybenn |
|
3008 |
|
|
FROM_TTY specifies whether GDB ought to consider this command as
|
3009 |
|
|
having originated from the user invoking it interactively. It
|
3010 |
|
|
must be a boolean value. If omitted, it defaults to `False'.
|
3011 |
|
|
|
3012 |
|
|
By default, any output produced by COMMAND is sent to GDB's
|
3013 |
|
|
standard output. If the TO_STRING parameter is `True', then
|
3014 |
|
|
output will be collected by `gdb.execute' and returned as a
|
3015 |
|
|
string. The default is `False', in which case the return value is
|
3016 |
|
|
`None'. If TO_STRING is `True', the GDB virtual terminal will be
|
3017 |
|
|
temporarily set to unlimited width and height, and its pagination
|
3018 |
|
|
will be disabled; *note Screen Size::.
|
3019 |
|
|
|
3020 |
|
|
-- Function: breakpoints
|
3021 |
|
|
Return a sequence holding all of GDB's breakpoints. *Note
|
3022 |
|
|
Breakpoints In Python::, for more information.
|
3023 |
|
|
|
3024 |
|
|
-- Function: parameter parameter
|
3025 |
|
|
Return the value of a GDB parameter. PARAMETER is a string naming
|
3026 |
|
|
the parameter to look up; PARAMETER may contain spaces if the
|
3027 |
|
|
parameter has a multi-part name. For example, `print object' is a
|
3028 |
|
|
valid parameter name.
|
3029 |
|
|
|
3030 |
|
|
If the named parameter does not exist, this function throws a
|
3031 |
|
|
`RuntimeError'. Otherwise, the parameter's value is converted to
|
3032 |
|
|
a Python value of the appropriate type, and returned.
|
3033 |
|
|
|
3034 |
|
|
-- Function: history number
|
3035 |
|
|
Return a value from GDB's value history (*note Value History::).
|
3036 |
|
|
NUMBER indicates which history element to return. If NUMBER is
|
3037 |
|
|
negative, then GDB will take its absolute value and count backward
|
3038 |
|
|
from the last element (i.e., the most recent element) to find the
|
3039 |
|
|
value to return. If NUMBER is zero, then GDB will return the most
|
3040 |
|
|
recent element. If the element specified by NUMBER doesn't exist
|
3041 |
|
|
in the value history, a `RuntimeError' exception will be raised.
|
3042 |
|
|
|
3043 |
|
|
If no exception is raised, the return value is always an instance
|
3044 |
|
|
of `gdb.Value' (*note Values From Inferior::).
|
3045 |
|
|
|
3046 |
|
|
-- Function: parse_and_eval expression
|
3047 |
|
|
Parse EXPRESSION as an expression in the current language,
|
3048 |
|
|
evaluate it, and return the result as a `gdb.Value'. EXPRESSION
|
3049 |
|
|
must be a string.
|
3050 |
|
|
|
3051 |
|
|
This function can be useful when implementing a new command (*note
|
3052 |
|
|
Commands In Python::), as it provides a way to parse the command's
|
3053 |
|
|
argument as an expression. It is also useful simply to compute
|
3054 |
|
|
values, for example, it is the only way to get the value of a
|
3055 |
|
|
convenience variable (*note Convenience Vars::) as a `gdb.Value'.
|
3056 |
|
|
|
3057 |
|
|
-- Function: write string
|
3058 |
|
|
Print a string to GDB's paginated standard output stream. Writing
|
3059 |
|
|
to `sys.stdout' or `sys.stderr' will automatically call this
|
3060 |
|
|
function.
|
3061 |
|
|
|
3062 |
|
|
-- Function: flush
|
3063 |
|
|
Flush GDB's paginated standard output stream. Flushing
|
3064 |
|
|
`sys.stdout' or `sys.stderr' will automatically call this function.
|
3065 |
|
|
|
3066 |
|
|
-- Function: target_charset
|
3067 |
|
|
Return the name of the current target character set (*note
|
3068 |
|
|
Character Sets::). This differs from
|
3069 |
|
|
`gdb.parameter('target-charset')' in that `auto' is never returned.
|
3070 |
|
|
|
3071 |
|
|
-- Function: target_wide_charset
|
3072 |
|
|
Return the name of the current target wide character set (*note
|
3073 |
|
|
Character Sets::). This differs from
|
3074 |
|
|
`gdb.parameter('target-wide-charset')' in that `auto' is never
|
3075 |
|
|
returned.
|
3076 |
|
|
|
3077 |
|
|
|
3078 |
|
|
File: gdb.info, Node: Exception Handling, Next: Values From Inferior, Prev: Basic Python, Up: Python API
|
3079 |
|
|
|
3080 |
|
|
23.2.2.2 Exception Handling
|
3081 |
|
|
...........................
|
3082 |
|
|
|
3083 |
|
|
When executing the `python' command, Python exceptions uncaught within
|
3084 |
|
|
the Python code are translated to calls to GDB error-reporting
|
3085 |
|
|
mechanism. If the command that called `python' does not handle the
|
3086 |
|
|
error, GDB will terminate it and print an error message containing the
|
3087 |
|
|
Python exception name, the associated value, and the Python call stack
|
3088 |
|
|
backtrace at the point where the exception was raised. Example:
|
3089 |
|
|
|
3090 |
|
|
(gdb) python print foo
|
3091 |
|
|
Traceback (most recent call last):
|
3092 |
|
|
File "", line 1, in
|
3093 |
|
|
NameError: name 'foo' is not defined
|
3094 |
|
|
|
3095 |
|
|
GDB errors that happen in GDB commands invoked by Python code are
|
3096 |
|
|
converted to Python `RuntimeError' exceptions. User interrupt (via
|
3097 |
|
|
`C-c' or by typing `q' at a pagination prompt) is translated to a
|
3098 |
|
|
Python `KeyboardInterrupt' exception. If you catch these exceptions in
|
3099 |
|
|
your Python code, your exception handler will see `RuntimeError' or
|
3100 |
|
|
`KeyboardInterrupt' as the exception type, the GDB error message as its
|
3101 |
|
|
value, and the Python call stack backtrace at the Python statement
|
3102 |
|
|
closest to where the GDB error occured as the traceback.
|
3103 |
|
|
|
3104 |
|
|
When implementing GDB commands in Python via `gdb.Command', it is
|
3105 |
|
|
useful to be able to throw an exception that doesn't cause a traceback
|
3106 |
|
|
to be printed. For example, the user may have invoked the command
|
3107 |
|
|
incorrectly. Use the `gdb.GdbError' exception to handle this case.
|
3108 |
|
|
Example:
|
3109 |
|
|
|
3110 |
|
|
(gdb) python
|
3111 |
|
|
>class HelloWorld (gdb.Command):
|
3112 |
|
|
> """Greet the whole world."""
|
3113 |
|
|
> def __init__ (self):
|
3114 |
|
|
> super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE)
|
3115 |
|
|
> def invoke (self, args, from_tty):
|
3116 |
|
|
> argv = gdb.string_to_argv (args)
|
3117 |
|
|
> if len (argv) != 0:
|
3118 |
|
|
> raise gdb.GdbError ("hello-world takes no arguments")
|
3119 |
|
|
> print "Hello, World!"
|
3120 |
|
|
>HelloWorld ()
|
3121 |
|
|
>end
|
3122 |
|
|
(gdb) hello-world 42
|
3123 |
|
|
hello-world takes no arguments
|
3124 |
|
|
|
3125 |
|
|
|
3126 |
|
|
File: gdb.info, Node: Values From Inferior, Next: Types In Python, Prev: Exception Handling, Up: Python API
|
3127 |
|
|
|
3128 |
|
|
23.2.2.3 Values From Inferior
|
3129 |
|
|
.............................
|
3130 |
|
|
|
3131 |
|
|
GDB provides values it obtains from the inferior program in an object
|
3132 |
|
|
of type `gdb.Value'. GDB uses this object for its internal bookkeeping
|
3133 |
|
|
of the inferior's values, and for fetching values when necessary.
|
3134 |
|
|
|
3135 |
|
|
Inferior values that are simple scalars can be used directly in
|
3136 |
|
|
Python expressions that are valid for the value's data type. Here's an
|
3137 |
|
|
example for an integer or floating-point value `some_val':
|
3138 |
|
|
|
3139 |
|
|
bar = some_val + 2
|
3140 |
|
|
|
3141 |
|
|
As result of this, `bar' will also be a `gdb.Value' object whose values
|
3142 |
|
|
are of the same type as those of `some_val'.
|
3143 |
|
|
|
3144 |
|
|
Inferior values that are structures or instances of some class can
|
3145 |
|
|
be accessed using the Python "dictionary syntax". For example, if
|
3146 |
|
|
`some_val' is a `gdb.Value' instance holding a structure, you can
|
3147 |
|
|
access its `foo' element with:
|
3148 |
|
|
|
3149 |
|
|
bar = some_val['foo']
|
3150 |
|
|
|
3151 |
|
|
Again, `bar' will also be a `gdb.Value' object.
|
3152 |
|
|
|
3153 |
|
|
The following attributes are provided:
|
3154 |
|
|
|
3155 |
|
|
-- Instance Variable of Value: address
|
3156 |
|
|
If this object is addressable, this read-only attribute holds
|
3157 |
|
|
a `gdb.Value' object representing the address. Otherwise,
|
3158 |
|
|
this attribute holds `None'.
|
3159 |
|
|
|
3160 |
|
|
-- Instance Variable of Value: is_optimized_out
|
3161 |
|
|
This read-only boolean attribute is true if the compiler
|
3162 |
|
|
optimized out this value, thus it is not available for
|
3163 |
|
|
fetching from the inferior.
|
3164 |
|
|
|
3165 |
|
|
-- Instance Variable of Value: type
|
3166 |
|
|
The type of this `gdb.Value'. The value of this attribute is
|
3167 |
|
|
a `gdb.Type' object.
|
3168 |
|
|
|
3169 |
|
|
The following methods are provided:
|
3170 |
|
|
|
3171 |
|
|
-- Method on Value: cast type
|
3172 |
|
|
Return a new instance of `gdb.Value' that is the result of
|
3173 |
|
|
casting this instance to the type described by TYPE, which
|
3174 |
|
|
must be a `gdb.Type' object. If the cast cannot be performed
|
3175 |
|
|
for some reason, this method throws an exception.
|
3176 |
|
|
|
3177 |
|
|
-- Method on Value: dereference
|
3178 |
|
|
For pointer data types, this method returns a new `gdb.Value'
|
3179 |
|
|
object whose contents is the object pointed to by the
|
3180 |
|
|
pointer. For example, if `foo' is a C pointer to an `int',
|
3181 |
|
|
declared in your C program as
|
3182 |
|
|
|
3183 |
|
|
int *foo;
|
3184 |
|
|
|
3185 |
|
|
then you can use the corresponding `gdb.Value' to access what
|
3186 |
|
|
`foo' points to like this:
|
3187 |
|
|
|
3188 |
|
|
bar = foo.dereference ()
|
3189 |
|
|
|
3190 |
|
|
The result `bar' will be a `gdb.Value' object holding the
|
3191 |
|
|
value pointed to by `foo'.
|
3192 |
|
|
|
3193 |
|
|
-- Method on Value: string [encoding] [errors] [length]
|
3194 |
|
|
If this `gdb.Value' represents a string, then this method
|
3195 |
|
|
converts the contents to a Python string. Otherwise, this
|
3196 |
|
|
method will throw an exception.
|
3197 |
|
|
|
3198 |
|
|
Strings are recognized in a language-specific way; whether a
|
3199 |
|
|
given `gdb.Value' represents a string is determined by the
|
3200 |
|
|
current language.
|
3201 |
|
|
|
3202 |
|
|
For C-like languages, a value is a string if it is a pointer
|
3203 |
|
|
to or an array of characters or ints. The string is assumed
|
3204 |
|
|
to be terminated by a zero of the appropriate width. However
|
3205 |
|
|
if the optional length argument is given, the string will be
|
3206 |
|
|
converted to that given length, ignoring any embedded zeros
|
3207 |
|
|
that the string may contain.
|
3208 |
|
|
|
3209 |
|
|
If the optional ENCODING argument is given, it must be a
|
3210 |
|
|
string naming the encoding of the string in the `gdb.Value',
|
3211 |
|
|
such as `"ascii"', `"iso-8859-6"' or `"utf-8"'. It accepts
|
3212 |
|
|
the same encodings as the corresponding argument to Python's
|
3213 |
|
|
`string.decode' method, and the Python codec machinery will
|
3214 |
|
|
be used to convert the string. If ENCODING is not given, or
|
3215 |
|
|
if ENCODING is the empty string, then either the
|
3216 |
|
|
`target-charset' (*note Character Sets::) will be used, or a
|
3217 |
|
|
language-specific encoding will be used, if the current
|
3218 |
|
|
language is able to supply one.
|
3219 |
|
|
|
3220 |
|
|
The optional ERRORS argument is the same as the corresponding
|
3221 |
|
|
argument to Python's `string.decode' method.
|
3222 |
|
|
|
3223 |
|
|
If the optional LENGTH argument is given, the string will be
|
3224 |
|
|
fetched and converted to the given length.
|
3225 |
|
|
|
3226 |
|
|
-- Method on Value: lazy_string [encoding] [length]
|
3227 |
|
|
If this `gdb.Value' represents a string, then this method
|
3228 |
|
|
converts the contents to a `gdb.LazyString' (*note Lazy
|
3229 |
|
|
Strings In Python::). Otherwise, this method will throw an
|
3230 |
|
|
exception.
|
3231 |
|
|
|
3232 |
|
|
If the optional ENCODING argument is given, it must be a
|
3233 |
|
|
string naming the encoding of the `gdb.LazyString'. Some
|
3234 |
|
|
examples are: `ascii', `iso-8859-6' or `utf-8'. If the
|
3235 |
|
|
ENCODING argument is an encoding that GDB does recognize, GDB
|
3236 |
|
|
will raise an error.
|
3237 |
|
|
|
3238 |
|
|
When a lazy string is printed, the GDB encoding machinery is
|
3239 |
|
|
used to convert the string during printing. If the optional
|
3240 |
|
|
ENCODING argument is not provided, or is an empty string, GDB
|
3241 |
|
|
will automatically select the encoding most suitable for the
|
3242 |
|
|
string type. For further information on encoding in GDB
|
3243 |
342 |
jeremybenn |
please see *note Character Sets::.
|
3244 |
330 |
jeremybenn |
|
3245 |
|
|
If the optional LENGTH argument is given, the string will be
|
3246 |
|
|
fetched and encoded to the length of characters specified. If
|
3247 |
|
|
the LENGTH argument is not provided, the string will be
|
3248 |
|
|
fetched and encoded until a null of appropriate width is
|
3249 |
|
|
found.
|
3250 |
|
|
|
3251 |
|
|
|
3252 |
|
|
File: gdb.info, Node: Types In Python, Next: Pretty Printing API, Prev: Values From Inferior, Up: Python API
|
3253 |
|
|
|
3254 |
|
|
23.2.2.4 Types In Python
|
3255 |
|
|
........................
|
3256 |
|
|
|
3257 |
|
|
GDB represents types from the inferior using the class `gdb.Type'.
|
3258 |
|
|
|
3259 |
|
|
The following type-related functions are available in the `gdb'
|
3260 |
|
|
module:
|
3261 |
|
|
|
3262 |
|
|
-- Function: lookup_type name [block]
|
3263 |
|
|
This function looks up a type by name. NAME is the name of the
|
3264 |
|
|
type to look up. It must be a string.
|
3265 |
|
|
|
3266 |
|
|
If BLOCK is given, then NAME is looked up in that scope.
|
3267 |
|
|
Otherwise, it is searched for globally.
|
3268 |
|
|
|
3269 |
|
|
Ordinarily, this function will return an instance of `gdb.Type'.
|
3270 |
|
|
If the named type cannot be found, it will throw an exception.
|
3271 |
|
|
|
3272 |
|
|
An instance of `Type' has the following attributes:
|
3273 |
|
|
|
3274 |
|
|
-- Instance Variable of Type: code
|
3275 |
|
|
The type code for this type. The type code will be one of the
|
3276 |
|
|
`TYPE_CODE_' constants defined below.
|
3277 |
|
|
|
3278 |
|
|
-- Instance Variable of Type: sizeof
|
3279 |
|
|
The size of this type, in target `char' units. Usually, a
|
3280 |
|
|
target's `char' type will be an 8-bit byte. However, on some
|
3281 |
|
|
unusual platforms, this type may have a different size.
|
3282 |
|
|
|
3283 |
|
|
-- Instance Variable of Type: tag
|
3284 |
|
|
The tag name for this type. The tag name is the name after
|
3285 |
|
|
`struct', `union', or `enum' in C and C++; not all languages
|
3286 |
|
|
have this concept. If this type has no tag name, then `None'
|
3287 |
|
|
is returned.
|
3288 |
|
|
|
3289 |
|
|
The following methods are provided:
|
3290 |
|
|
|
3291 |
|
|
-- Method on Type: fields
|
3292 |
|
|
For structure and union types, this method returns the
|
3293 |
|
|
fields. Range types have two fields, the minimum and maximum
|
3294 |
|
|
values. Enum types have one field per enum constant.
|
3295 |
|
|
Function and method types have one field per parameter. The
|
3296 |
|
|
base types of C++ classes are also represented as fields. If
|
3297 |
|
|
the type has no fields, or does not fit into one of these
|
3298 |
|
|
categories, an empty sequence will be returned.
|
3299 |
|
|
|
3300 |
|
|
Each field is an object, with some pre-defined attributes:
|
3301 |
|
|
`bitpos'
|
3302 |
|
|
This attribute is not available for `static' fields (as
|
3303 |
|
|
in C++ or Java). For non-`static' fields, the value is
|
3304 |
|
|
the bit position of the field.
|
3305 |
|
|
|
3306 |
|
|
`name'
|
3307 |
|
|
The name of the field, or `None' for anonymous fields.
|
3308 |
|
|
|
3309 |
|
|
`artificial'
|
3310 |
|
|
This is `True' if the field is artificial, usually
|
3311 |
|
|
meaning that it was provided by the compiler and not the
|
3312 |
|
|
user. This attribute is always provided, and is `False'
|
3313 |
|
|
if the field is not artificial.
|
3314 |
|
|
|
3315 |
|
|
`is_base_class'
|
3316 |
|
|
This is `True' if the field represents a base class of a
|
3317 |
|
|
C++ structure. This attribute is always provided, and
|
3318 |
|
|
is `False' if the field is not a base class of the type
|
3319 |
|
|
that is the argument of `fields', or if that type was
|
3320 |
|
|
not a C++ class.
|
3321 |
|
|
|
3322 |
|
|
`bitsize'
|
3323 |
|
|
If the field is packed, or is a bitfield, then this will
|
3324 |
|
|
have a non-zero value, which is the size of the field in
|
3325 |
|
|
bits. Otherwise, this will be zero; in this case the
|
3326 |
|
|
field's size is given by its type.
|
3327 |
|
|
|
3328 |
|
|
`type'
|
3329 |
|
|
The type of the field. This is usually an instance of
|
3330 |
|
|
`Type', but it can be `None' in some situations.
|
3331 |
|
|
|
3332 |
|
|
-- Method on Type: const
|
3333 |
|
|
Return a new `gdb.Type' object which represents a
|
3334 |
|
|
`const'-qualified variant of this type.
|
3335 |
|
|
|
3336 |
|
|
-- Method on Type: volatile
|
3337 |
|
|
Return a new `gdb.Type' object which represents a
|
3338 |
|
|
`volatile'-qualified variant of this type.
|
3339 |
|
|
|
3340 |
|
|
-- Method on Type: unqualified
|
3341 |
|
|
Return a new `gdb.Type' object which represents an unqualified
|
3342 |
|
|
variant of this type. That is, the result is neither `const'
|
3343 |
|
|
nor `volatile'.
|
3344 |
|
|
|
3345 |
|
|
-- Method on Type: range
|
3346 |
|
|
Return a Python `Tuple' object that contains two elements: the
|
3347 |
|
|
low bound of the argument type and the high bound of that
|
3348 |
|
|
type. If the type does not have a range, GDB will raise a
|
3349 |
|
|
`RuntimeError' exception.
|
3350 |
|
|
|
3351 |
|
|
-- Method on Type: reference
|
3352 |
|
|
Return a new `gdb.Type' object which represents a reference
|
3353 |
|
|
to this type.
|
3354 |
|
|
|
3355 |
|
|
-- Method on Type: pointer
|
3356 |
|
|
Return a new `gdb.Type' object which represents a pointer to
|
3357 |
|
|
this type.
|
3358 |
|
|
|
3359 |
|
|
-- Method on Type: strip_typedefs
|
3360 |
|
|
Return a new `gdb.Type' that represents the real type, after
|
3361 |
|
|
removing all layers of typedefs.
|
3362 |
|
|
|
3363 |
|
|
-- Method on Type: target
|
3364 |
|
|
Return a new `gdb.Type' object which represents the target
|
3365 |
|
|
type of this type.
|
3366 |
|
|
|
3367 |
|
|
For a pointer type, the target type is the type of the
|
3368 |
|
|
pointed-to object. For an array type (meaning C-like
|
3369 |
|
|
arrays), the target type is the type of the elements of the
|
3370 |
|
|
array. For a function or method type, the target type is the
|
3371 |
|
|
type of the return value. For a complex type, the target
|
3372 |
|
|
type is the type of the elements. For a typedef, the target
|
3373 |
|
|
type is the aliased type.
|
3374 |
|
|
|
3375 |
|
|
If the type does not have a target, this method will throw an
|
3376 |
|
|
exception.
|
3377 |
|
|
|
3378 |
|
|
-- Method on Type: template_argument n [block]
|
3379 |
|
|
If this `gdb.Type' is an instantiation of a template, this
|
3380 |
|
|
will return a new `gdb.Type' which represents the type of the
|
3381 |
|
|
Nth template argument.
|
3382 |
|
|
|
3383 |
|
|
If this `gdb.Type' is not a template type, this will throw an
|
3384 |
|
|
exception. Ordinarily, only C++ code will have template
|
3385 |
|
|
types.
|
3386 |
|
|
|
3387 |
|
|
If BLOCK is given, then NAME is looked up in that scope.
|
3388 |
|
|
Otherwise, it is searched for globally.
|
3389 |
|
|
|
3390 |
|
|
Each type has a code, which indicates what category this type falls
|
3391 |
|
|
into. The available type categories are represented by constants
|
3392 |
|
|
defined in the `gdb' module:
|
3393 |
|
|
|
3394 |
|
|
`TYPE_CODE_PTR'
|
3395 |
|
|
The type is a pointer.
|
3396 |
|
|
|
3397 |
|
|
`TYPE_CODE_ARRAY'
|
3398 |
|
|
The type is an array.
|
3399 |
|
|
|
3400 |
|
|
`TYPE_CODE_STRUCT'
|
3401 |
|
|
The type is a structure.
|
3402 |
|
|
|
3403 |
|
|
`TYPE_CODE_UNION'
|
3404 |
|
|
The type is a union.
|
3405 |
|
|
|
3406 |
|
|
`TYPE_CODE_ENUM'
|
3407 |
|
|
The type is an enum.
|
3408 |
|
|
|
3409 |
|
|
`TYPE_CODE_FLAGS'
|
3410 |
|
|
A bit flags type, used for things such as status registers.
|
3411 |
|
|
|
3412 |
|
|
`TYPE_CODE_FUNC'
|
3413 |
|
|
The type is a function.
|
3414 |
|
|
|
3415 |
|
|
`TYPE_CODE_INT'
|
3416 |
|
|
The type is an integer type.
|
3417 |
|
|
|
3418 |
|
|
`TYPE_CODE_FLT'
|
3419 |
|
|
A floating point type.
|
3420 |
|
|
|
3421 |
|
|
`TYPE_CODE_VOID'
|
3422 |
|
|
The special type `void'.
|
3423 |
|
|
|
3424 |
|
|
`TYPE_CODE_SET'
|
3425 |
|
|
A Pascal set type.
|
3426 |
|
|
|
3427 |
|
|
`TYPE_CODE_RANGE'
|
3428 |
|
|
A range type, that is, an integer type with bounds.
|
3429 |
|
|
|
3430 |
|
|
`TYPE_CODE_STRING'
|
3431 |
|
|
A string type. Note that this is only used for certain languages
|
3432 |
|
|
with language-defined string types; C strings are not represented
|
3433 |
|
|
this way.
|
3434 |
|
|
|
3435 |
|
|
`TYPE_CODE_BITSTRING'
|
3436 |
|
|
A string of bits.
|
3437 |
|
|
|
3438 |
|
|
`TYPE_CODE_ERROR'
|
3439 |
|
|
An unknown or erroneous type.
|
3440 |
|
|
|
3441 |
|
|
`TYPE_CODE_METHOD'
|
3442 |
|
|
A method type, as found in C++ or Java.
|
3443 |
|
|
|
3444 |
|
|
`TYPE_CODE_METHODPTR'
|
3445 |
|
|
A pointer-to-member-function.
|
3446 |
|
|
|
3447 |
|
|
`TYPE_CODE_MEMBERPTR'
|
3448 |
|
|
A pointer-to-member.
|
3449 |
|
|
|
3450 |
|
|
`TYPE_CODE_REF'
|
3451 |
|
|
A reference type.
|
3452 |
|
|
|
3453 |
|
|
`TYPE_CODE_CHAR'
|
3454 |
|
|
A character type.
|
3455 |
|
|
|
3456 |
|
|
`TYPE_CODE_BOOL'
|
3457 |
|
|
A boolean type.
|
3458 |
|
|
|
3459 |
|
|
`TYPE_CODE_COMPLEX'
|
3460 |
|
|
A complex float type.
|
3461 |
|
|
|
3462 |
|
|
`TYPE_CODE_TYPEDEF'
|
3463 |
|
|
A typedef to some other type.
|
3464 |
|
|
|
3465 |
|
|
`TYPE_CODE_NAMESPACE'
|
3466 |
|
|
A C++ namespace.
|
3467 |
|
|
|
3468 |
|
|
`TYPE_CODE_DECFLOAT'
|
3469 |
|
|
A decimal floating point type.
|
3470 |
|
|
|
3471 |
|
|
`TYPE_CODE_INTERNAL_FUNCTION'
|
3472 |
|
|
A function internal to GDB. This is the type used to represent
|
3473 |
|
|
convenience functions.
|
3474 |
|
|
|
3475 |
|
|
|
3476 |
|
|
File: gdb.info, Node: Pretty Printing API, Next: Selecting Pretty-Printers, Prev: Types In Python, Up: Python API
|
3477 |
|
|
|
3478 |
|
|
23.2.2.5 Pretty Printing API
|
3479 |
|
|
............................
|
3480 |
|
|
|
3481 |
|
|
An example output is provided (*note Pretty Printing::).
|
3482 |
|
|
|
3483 |
|
|
A pretty-printer is just an object that holds a value and implements
|
3484 |
|
|
a specific interface, defined here.
|
3485 |
|
|
|
3486 |
|
|
-- Operation on pretty printer: children (self)
|
3487 |
|
|
GDB will call this method on a pretty-printer to compute the
|
3488 |
|
|
children of the pretty-printer's value.
|
3489 |
|
|
|
3490 |
|
|
This method must return an object conforming to the Python iterator
|
3491 |
|
|
protocol. Each item returned by the iterator must be a tuple
|
3492 |
|
|
holding two elements. The first element is the "name" of the
|
3493 |
|
|
child; the second element is the child's value. The value can be
|
3494 |
|
|
any Python object which is convertible to a GDB value.
|
3495 |
|
|
|
3496 |
|
|
This method is optional. If it does not exist, GDB will act as
|
3497 |
|
|
though the value has no children.
|
3498 |
|
|
|
3499 |
|
|
-- Operation on pretty printer: display_hint (self)
|
3500 |
|
|
The CLI may call this method and use its result to change the
|
3501 |
|
|
formatting of a value. The result will also be supplied to an MI
|
3502 |
|
|
consumer as a `displayhint' attribute of the variable being
|
3503 |
|
|
printed.
|
3504 |
|
|
|
3505 |
|
|
This method is optional. If it does exist, this method must
|
3506 |
|
|
return a string.
|
3507 |
|
|
|
3508 |
|
|
Some display hints are predefined by GDB:
|
3509 |
|
|
|
3510 |
|
|
`array'
|
3511 |
|
|
Indicate that the object being printed is "array-like". The
|
3512 |
|
|
CLI uses this to respect parameters such as `set print
|
3513 |
|
|
elements' and `set print array'.
|
3514 |
|
|
|
3515 |
|
|
`map'
|
3516 |
|
|
Indicate that the object being printed is "map-like", and
|
3517 |
|
|
that the children of this value can be assumed to alternate
|
3518 |
|
|
between keys and values.
|
3519 |
|
|
|
3520 |
|
|
`string'
|
3521 |
|
|
Indicate that the object being printed is "string-like". If
|
3522 |
|
|
the printer's `to_string' method returns a Python string of
|
3523 |
|
|
some kind, then GDB will call its internal language-specific
|
3524 |
|
|
string-printing function to format the string. For the CLI
|
3525 |
|
|
this means adding quotation marks, possibly escaping some
|
3526 |
|
|
characters, respecting `set print elements', and the like.
|
3527 |
|
|
|
3528 |
|
|
-- Operation on pretty printer: to_string (self)
|
3529 |
|
|
GDB will call this method to display the string representation of
|
3530 |
|
|
the value passed to the object's constructor.
|
3531 |
|
|
|
3532 |
|
|
When printing from the CLI, if the `to_string' method exists, then
|
3533 |
|
|
GDB will prepend its result to the values returned by `children'.
|
3534 |
|
|
Exactly how this formatting is done is dependent on the display
|
3535 |
|
|
hint, and may change as more hints are added. Also, depending on
|
3536 |
|
|
the print settings (*note Print Settings::), the CLI may print
|
3537 |
|
|
just the result of `to_string' in a stack trace, omitting the
|
3538 |
|
|
result of `children'.
|
3539 |
|
|
|
3540 |
|
|
If this method returns a string, it is printed verbatim.
|
3541 |
|
|
|
3542 |
|
|
Otherwise, if this method returns an instance of `gdb.Value', then
|
3543 |
|
|
GDB prints this value. This may result in a call to another
|
3544 |
|
|
pretty-printer.
|
3545 |
|
|
|
3546 |
|
|
If instead the method returns a Python value which is convertible
|
3547 |
|
|
to a `gdb.Value', then GDB performs the conversion and prints the
|
3548 |
|
|
resulting value. Again, this may result in a call to another
|
3549 |
|
|
pretty-printer. Python scalars (integers, floats, and booleans)
|
3550 |
|
|
and strings are convertible to `gdb.Value'; other types are not.
|
3551 |
|
|
|
3552 |
|
|
Finally, if this method returns `None' then no further operations
|
3553 |
|
|
are peformed in this method and nothing is printed.
|
3554 |
|
|
|
3555 |
|
|
If the result is not one of these types, an exception is raised.
|
3556 |
|
|
|
3557 |
|
|
GDB provides a function which can be used to look up the default
|
3558 |
|
|
pretty-printer for a `gdb.Value':
|
3559 |
|
|
|
3560 |
|
|
-- Function: default_visualizer value
|
3561 |
|
|
This function takes a `gdb.Value' object as an argument. If a
|
3562 |
|
|
pretty-printer for this value exists, then it is returned. If no
|
3563 |
|
|
such printer exists, then this returns `None'.
|
3564 |
|
|
|
3565 |
|
|
|
3566 |
|
|
File: gdb.info, Node: Selecting Pretty-Printers, Next: Disabling Pretty-Printers, Prev: Pretty Printing API, Up: Python API
|
3567 |
|
|
|
3568 |
|
|
23.2.2.6 Selecting Pretty-Printers
|
3569 |
|
|
..................................
|
3570 |
|
|
|
3571 |
|
|
The Python list `gdb.pretty_printers' contains an array of functions or
|
3572 |
|
|
callable objects that have been registered via addition as a
|
3573 |
|
|
pretty-printer. Each `gdb.Progspace' contains a `pretty_printers'
|
3574 |
|
|
attribute. Each `gdb.Objfile' also contains a `pretty_printers'
|
3575 |
|
|
attribute.
|
3576 |
|
|
|
3577 |
|
|
A function on one of these lists is passed a single `gdb.Value'
|
3578 |
|
|
argument and should return a pretty-printer object conforming to the
|
3579 |
|
|
interface definition above (*note Pretty Printing API::). If a function
|
3580 |
|
|
cannot create a pretty-printer for the value, it should return `None'.
|
3581 |
|
|
|
3582 |
|
|
GDB first checks the `pretty_printers' attribute of each
|
3583 |
|
|
`gdb.Objfile' in the current program space and iteratively calls each
|
3584 |
|
|
enabled function (*note Disabling Pretty-Printers::) in the list for
|
3585 |
|
|
that `gdb.Objfile' until it receives a pretty-printer object. If no
|
3586 |
|
|
pretty-printer is found in the objfile lists, GDB then searches the
|
3587 |
|
|
pretty-printer list of the current program space, calling each enabled
|
3588 |
|
|
function until an object is returned. After these lists have been
|
3589 |
|
|
exhausted, it tries the global `gdb.pretty_printers' list, again
|
3590 |
|
|
calling each enabled function until an object is returned.
|
3591 |
|
|
|
3592 |
|
|
The order in which the objfiles are searched is not specified. For a
|
3593 |
|
|
given list, functions are always invoked from the head of the list, and
|
3594 |
|
|
iterated over sequentially until the end of the list, or a printer
|
3595 |
|
|
object is returned.
|
3596 |
|
|
|
3597 |
|
|
Here is an example showing how a `std::string' printer might be
|
3598 |
|
|
written:
|
3599 |
|
|
|
3600 |
|
|
class StdStringPrinter:
|
3601 |
|
|
"Print a std::string"
|
3602 |
|
|
|
3603 |
|
|
def __init__ (self, val):
|
3604 |
|
|
self.val = val
|
3605 |
|
|
|
3606 |
|
|
def to_string (self):
|
3607 |
|
|
return self.val['_M_dataplus']['_M_p']
|
3608 |
|
|
|
3609 |
|
|
def display_hint (self):
|
3610 |
|
|
return 'string'
|
3611 |
|
|
|
3612 |
|
|
And here is an example showing how a lookup function for the printer
|
3613 |
|
|
example above might be written.
|
3614 |
|
|
|
3615 |
|
|
def str_lookup_function (val):
|
3616 |
|
|
|
3617 |
|
|
lookup_tag = val.type.tag
|
3618 |
|
|
regex = re.compile ("^std::basic_string$")
|
3619 |
|
|
if lookup_tag == None:
|
3620 |
|
|
return None
|
3621 |
|
|
if regex.match (lookup_tag):
|
3622 |
|
|
return StdStringPrinter (val)
|
3623 |
|
|
|
3624 |
|
|
return None
|
3625 |
|
|
|
3626 |
|
|
The example lookup function extracts the value's type, and attempts
|
3627 |
|
|
to match it to a type that it can pretty-print. If it is a type the
|
3628 |
|
|
printer can pretty-print, it will return a printer object. If not, it
|
3629 |
|
|
returns `None'.
|
3630 |
|
|
|
3631 |
|
|
We recommend that you put your core pretty-printers into a Python
|
3632 |
|
|
package. If your pretty-printers are for use with a library, we
|
3633 |
|
|
further recommend embedding a version number into the package name.
|
3634 |
|
|
This practice will enable GDB to load multiple versions of your
|
3635 |
|
|
pretty-printers at the same time, because they will have different
|
3636 |
|
|
names.
|
3637 |
|
|
|
3638 |
|
|
You should write auto-loaded code (*note Auto-loading::) such that it
|
3639 |
|
|
can be evaluated multiple times without changing its meaning. An ideal
|
3640 |
|
|
auto-load file will consist solely of `import's of your printer
|
3641 |
|
|
modules, followed by a call to a register pretty-printers with the
|
3642 |
|
|
current objfile.
|
3643 |
|
|
|
3644 |
|
|
Taken as a whole, this approach will scale nicely to multiple
|
3645 |
|
|
inferiors, each potentially using a different library version.
|
3646 |
|
|
Embedding a version number in the Python package name will ensure that
|
3647 |
|
|
GDB is able to load both sets of printers simultaneously. Then,
|
3648 |
|
|
because the search for pretty-printers is done by objfile, and because
|
3649 |
|
|
your auto-loaded code took care to register your library's printers
|
3650 |
|
|
with a specific objfile, GDB will find the correct printers for the
|
3651 |
|
|
specific version of the library used by each inferior.
|
3652 |
|
|
|
3653 |
|
|
To continue the `std::string' example (*note Pretty Printing API::),
|
3654 |
|
|
this code might appear in `gdb.libstdcxx.v6':
|
3655 |
|
|
|
3656 |
|
|
def register_printers (objfile):
|
3657 |
|
|
objfile.pretty_printers.add (str_lookup_function)
|
3658 |
|
|
|
3659 |
|
|
And then the corresponding contents of the auto-load file would be:
|
3660 |
|
|
|
3661 |
|
|
import gdb.libstdcxx.v6
|
3662 |
|
|
gdb.libstdcxx.v6.register_printers (gdb.current_objfile ())
|
3663 |
|
|
|
3664 |
|
|
|
3665 |
|
|
File: gdb.info, Node: Disabling Pretty-Printers, Next: Inferiors In Python, Prev: Selecting Pretty-Printers, Up: Python API
|
3666 |
|
|
|
3667 |
|
|
23.2.2.7 Disabling Pretty-Printers
|
3668 |
|
|
..................................
|
3669 |
|
|
|
3670 |
|
|
For various reasons a pretty-printer may not work. For example, the
|
3671 |
|
|
underlying data structure may have changed and the pretty-printer is
|
3672 |
|
|
out of date.
|
3673 |
|
|
|
3674 |
|
|
The consequences of a broken pretty-printer are severe enough that
|
3675 |
|
|
GDB provides support for enabling and disabling individual printers.
|
3676 |
|
|
For example, if `print frame-arguments' is on, a backtrace can become
|
3677 |
|
|
highly illegible if any argument is printed with a broken printer.
|
3678 |
|
|
|
3679 |
|
|
Pretty-printers are enabled and disabled by attaching an `enabled'
|
3680 |
|
|
attribute to the registered function or callable object. If this
|
3681 |
|
|
attribute is present and its value is `False', the printer is disabled,
|
3682 |
|
|
otherwise the printer is enabled.
|
3683 |
|
|
|
3684 |
|
|
|
3685 |
|
|
File: gdb.info, Node: Inferiors In Python, Next: Threads In Python, Prev: Disabling Pretty-Printers, Up: Python API
|
3686 |
|
|
|
3687 |
|
|
23.2.2.8 Inferiors In Python
|
3688 |
|
|
............................
|
3689 |
|
|
|
3690 |
|
|
Programs which are being run under GDB are called inferiors (*note
|
3691 |
|
|
Inferiors and Programs::). Python scripts can access information about
|
3692 |
|
|
and manipulate inferiors controlled by GDB via objects of the
|
3693 |
|
|
`gdb.Inferior' class.
|
3694 |
|
|
|
3695 |
|
|
The following inferior-related functions are available in the `gdb'
|
3696 |
|
|
module:
|
3697 |
|
|
|
3698 |
|
|
-- Function: inferiors
|
3699 |
|
|
Return a tuple containing all inferior objects.
|
3700 |
|
|
|
3701 |
|
|
A `gdb.Inferior' object has the following attributes:
|
3702 |
|
|
|
3703 |
|
|
-- Instance Variable of Inferior: num
|
3704 |
|
|
ID of inferior, as assigned by GDB.
|
3705 |
|
|
|
3706 |
|
|
-- Instance Variable of Inferior: pid
|
3707 |
|
|
Process ID of the inferior, as assigned by the underlying
|
3708 |
|
|
operating system.
|
3709 |
|
|
|
3710 |
|
|
-- Instance Variable of Inferior: was_attached
|
3711 |
|
|
Boolean signaling whether the inferior was created using
|
3712 |
|
|
`attach', or started by GDB itself.
|
3713 |
|
|
|
3714 |
|
|
A `gdb.Inferior' object has the following methods:
|
3715 |
|
|
|
3716 |
|
|
-- Method on Inferior: threads
|
3717 |
|
|
This method returns a tuple holding all the threads which are
|
3718 |
|
|
valid when it is called. If there are no valid threads, the
|
3719 |
|
|
method will return an empty tuple.
|
3720 |
|
|
|
3721 |
|
|
-- Method on Inferior: read_memory address length
|
3722 |
|
|
Read LENGTH bytes of memory from the inferior, starting at
|
3723 |
|
|
ADDRESS. Returns a buffer object, which behaves much like an
|
3724 |
|
|
array or a string. It can be modified and given to the
|
3725 |
|
|
`gdb.write_memory' function.
|
3726 |
|
|
|
3727 |
|
|
-- Method on Inferior: write_memory address buffer [length]
|
3728 |
|
|
Write the contents of BUFFER to the inferior, starting at
|
3729 |
|
|
ADDRESS. The BUFFER parameter must be a Python object which
|
3730 |
|
|
supports the buffer protocol, i.e., a string, an array or the
|
3731 |
|
|
object returned from `gdb.read_memory'. If given, LENGTH
|
3732 |
|
|
determines the number of bytes from BUFFER to be written.
|
3733 |
|
|
|
3734 |
|
|
-- Method on Inferior: search_memory address length pattern
|
3735 |
|
|
Search a region of the inferior memory starting at ADDRESS
|
3736 |
|
|
with the given LENGTH using the search pattern supplied in
|
3737 |
|
|
PATTERN. The PATTERN parameter must be a Python object which
|
3738 |
|
|
supports the buffer protocol, i.e., a string, an array or the
|
3739 |
|
|
object returned from `gdb.read_memory'. Returns a Python
|
3740 |
|
|
`Long' containing the address where the pattern was found, or
|
3741 |
|
|
`None' if the pattern could not be found.
|
3742 |
|
|
|
3743 |
|
|
|
3744 |
|
|
File: gdb.info, Node: Threads In Python, Next: Commands In Python, Prev: Inferiors In Python, Up: Python API
|
3745 |
|
|
|
3746 |
|
|
23.2.2.9 Threads In Python
|
3747 |
|
|
..........................
|
3748 |
|
|
|
3749 |
|
|
Python scripts can access information about, and manipulate inferior
|
3750 |
|
|
threads controlled by GDB, via objects of the `gdb.InferiorThread'
|
3751 |
|
|
class.
|
3752 |
|
|
|
3753 |
|
|
The following thread-related functions are available in the `gdb'
|
3754 |
|
|
module:
|
3755 |
|
|
|
3756 |
|
|
-- Function: selected_thread
|
3757 |
|
|
This function returns the thread object for the selected thread.
|
3758 |
|
|
If there is no selected thread, this will return `None'.
|
3759 |
|
|
|
3760 |
|
|
A `gdb.InferiorThread' object has the following attributes:
|
3761 |
|
|
|
3762 |
|
|
-- Instance Variable of InferiorThread: num
|
3763 |
|
|
ID of the thread, as assigned by GDB.
|
3764 |
|
|
|
3765 |
|
|
-- Instance Variable of InferiorThread: ptid
|
3766 |
|
|
ID of the thread, as assigned by the operating system. This
|
3767 |
|
|
attribute is a tuple containing three integers. The first is
|
3768 |
|
|
the Process ID (PID); the second is the Lightweight Process
|
3769 |
|
|
ID (LWPID), and the third is the Thread ID (TID). Either the
|
3770 |
|
|
LWPID or TID may be 0, which indicates that the operating
|
3771 |
|
|
system does not use that identifier.
|
3772 |
|
|
|
3773 |
|
|
A `gdb.InferiorThread' object has the following methods:
|
3774 |
|
|
|
3775 |
|
|
-- Method on InferiorThread: switch
|
3776 |
|
|
This changes GDB's currently selected thread to the one
|
3777 |
|
|
represented by this object.
|
3778 |
|
|
|
3779 |
|
|
-- Method on InferiorThread: is_stopped
|
3780 |
|
|
Return a Boolean indicating whether the thread is stopped.
|
3781 |
|
|
|
3782 |
|
|
-- Method on InferiorThread: is_running
|
3783 |
|
|
Return a Boolean indicating whether the thread is running.
|
3784 |
|
|
|
3785 |
|
|
-- Method on InferiorThread: is_exited
|
3786 |
|
|
Return a Boolean indicating whether the thread is exited.
|
3787 |
|
|
|
3788 |
|
|
|
3789 |
|
|
File: gdb.info, Node: Commands In Python, Next: Parameters In Python, Prev: Threads In Python, Up: Python API
|
3790 |
|
|
|
3791 |
|
|
23.2.2.10 Commands In Python
|
3792 |
|
|
............................
|
3793 |
|
|
|
3794 |
|
|
You can implement new GDB CLI commands in Python. A CLI command is
|
3795 |
|
|
implemented using an instance of the `gdb.Command' class, most commonly
|
3796 |
|
|
using a subclass.
|
3797 |
|
|
|
3798 |
|
|
-- Method on Command: __init__ name COMMAND_CLASS [COMPLETER_CLASS]
|
3799 |
|
|
[PREFIX]
|
3800 |
|
|
The object initializer for `Command' registers the new command
|
3801 |
|
|
with GDB. This initializer is normally invoked from the subclass'
|
3802 |
|
|
own `__init__' method.
|
3803 |
|
|
|
3804 |
|
|
NAME is the name of the command. If NAME consists of multiple
|
3805 |
|
|
words, then the initial words are looked for as prefix commands.
|
3806 |
|
|
In this case, if one of the prefix commands does not exist, an
|
3807 |
|
|
exception is raised.
|
3808 |
|
|
|
3809 |
|
|
There is no support for multi-line commands.
|
3810 |
|
|
|
3811 |
|
|
COMMAND_CLASS should be one of the `COMMAND_' constants defined
|
3812 |
|
|
below. This argument tells GDB how to categorize the new command
|
3813 |
|
|
in the help system.
|
3814 |
|
|
|
3815 |
|
|
COMPLETER_CLASS is an optional argument. If given, it should be
|
3816 |
|
|
one of the `COMPLETE_' constants defined below. This argument
|
3817 |
|
|
tells GDB how to perform completion for this command. If not
|
3818 |
|
|
given, GDB will attempt to complete using the object's `complete'
|
3819 |
|
|
method (see below); if no such method is found, an error will
|
3820 |
|
|
occur when completion is attempted.
|
3821 |
|
|
|
3822 |
|
|
PREFIX is an optional argument. If `True', then the new command
|
3823 |
|
|
is a prefix command; sub-commands of this command may be
|
3824 |
|
|
registered.
|
3825 |
|
|
|
3826 |
|
|
The help text for the new command is taken from the Python
|
3827 |
|
|
documentation string for the command's class, if there is one. If
|
3828 |
|
|
no documentation string is provided, the default value "This
|
3829 |
|
|
command is not documented." is used.
|
3830 |
|
|
|
3831 |
|
|
-- Method on Command: dont_repeat
|
3832 |
|
|
By default, a GDB command is repeated when the user enters a blank
|
3833 |
|
|
line at the command prompt. A command can suppress this behavior
|
3834 |
|
|
by invoking the `dont_repeat' method. This is similar to the user
|
3835 |
342 |
jeremybenn |
command `dont-repeat', see *note dont-repeat: Define.
|
3836 |
330 |
jeremybenn |
|
3837 |
|
|
-- Method on Command: invoke argument from_tty
|
3838 |
|
|
This method is called by GDB when this command is invoked.
|
3839 |
|
|
|
3840 |
|
|
ARGUMENT is a string. It is the argument to the command, after
|
3841 |
|
|
leading and trailing whitespace has been stripped.
|
3842 |
|
|
|
3843 |
|
|
FROM_TTY is a boolean argument. When true, this means that the
|
3844 |
|
|
command was entered by the user at the terminal; when false it
|
3845 |
|
|
means that the command came from elsewhere.
|
3846 |
|
|
|
3847 |
|
|
If this method throws an exception, it is turned into a GDB
|
3848 |
|
|
`error' call. Otherwise, the return value is ignored.
|
3849 |
|
|
|
3850 |
|
|
To break ARGUMENT up into an argv-like string use
|
3851 |
|
|
`gdb.string_to_argv'. This function behaves identically to GDB's
|
3852 |
|
|
internal argument lexer `buildargv'. It is recommended to use
|
3853 |
|
|
this for consistency. Arguments are separated by spaces and may
|
3854 |
|
|
be quoted. Example:
|
3855 |
|
|
|
3856 |
|
|
print gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"")
|
3857 |
|
|
['1', '2 "3', '4 "5', "6 '7"]
|
3858 |
|
|
|
3859 |
|
|
|
3860 |
|
|
-- Method on Command: complete text word
|
3861 |
|
|
This method is called by GDB when the user attempts completion on
|
3862 |
|
|
this command. All forms of completion are handled by this method,
|
3863 |
|
|
that is, the and key bindings (*note Completion::),
|
3864 |
|
|
and the `complete' command (*note complete: Help.).
|
3865 |
|
|
|
3866 |
|
|
The arguments TEXT and WORD are both strings. TEXT holds the
|
3867 |
|
|
complete command line up to the cursor's location. WORD holds the
|
3868 |
|
|
last word of the command line; this is computed using a
|
3869 |
|
|
word-breaking heuristic.
|
3870 |
|
|
|
3871 |
|
|
The `complete' method can return several values:
|
3872 |
|
|
* If the return value is a sequence, the contents of the
|
3873 |
|
|
sequence are used as the completions. It is up to `complete'
|
3874 |
|
|
to ensure that the contents actually do complete the word. A
|
3875 |
|
|
zero-length sequence is allowed, it means that there were no
|
3876 |
|
|
completions available. Only string elements of the sequence
|
3877 |
|
|
are used; other elements in the sequence are ignored.
|
3878 |
|
|
|
3879 |
|
|
* If the return value is one of the `COMPLETE_' constants
|
3880 |
|
|
defined below, then the corresponding GDB-internal completion
|
3881 |
|
|
function is invoked, and its result is used.
|
3882 |
|
|
|
3883 |
|
|
* All other results are treated as though there were no
|
3884 |
|
|
available completions.
|
3885 |
|
|
|
3886 |
|
|
When a new command is registered, it must be declared as a member of
|
3887 |
|
|
some general class of commands. This is used to classify top-level
|
3888 |
|
|
commands in the on-line help system; note that prefix commands are not
|
3889 |
|
|
listed under their own category but rather that of their top-level
|
3890 |
|
|
command. The available classifications are represented by constants
|
3891 |
|
|
defined in the `gdb' module:
|
3892 |
|
|
|
3893 |
|
|
`COMMAND_NONE'
|
3894 |
|
|
The command does not belong to any particular class. A command in
|
3895 |
|
|
this category will not be displayed in any of the help categories.
|
3896 |
|
|
|
3897 |
|
|
`COMMAND_RUNNING'
|
3898 |
|
|
The command is related to running the inferior. For example,
|
3899 |
|
|
`start', `step', and `continue' are in this category. Type `help
|
3900 |
|
|
running' at the GDB prompt to see a list of commands in this
|
3901 |
|
|
category.
|
3902 |
|
|
|
3903 |
|
|
`COMMAND_DATA'
|
3904 |
|
|
The command is related to data or variables. For example, `call',
|
3905 |
|
|
`find', and `print' are in this category. Type `help data' at the
|
3906 |
|
|
GDB prompt to see a list of commands in this category.
|
3907 |
|
|
|
3908 |
|
|
`COMMAND_STACK'
|
3909 |
|
|
The command has to do with manipulation of the stack. For example,
|
3910 |
|
|
`backtrace', `frame', and `return' are in this category. Type
|
3911 |
|
|
`help stack' at the GDB prompt to see a list of commands in this
|
3912 |
|
|
category.
|
3913 |
|
|
|
3914 |
|
|
`COMMAND_FILES'
|
3915 |
|
|
This class is used for file-related commands. For example,
|
3916 |
|
|
`file', `list' and `section' are in this category. Type `help
|
3917 |
|
|
files' at the GDB prompt to see a list of commands in this
|
3918 |
|
|
category.
|
3919 |
|
|
|
3920 |
|
|
`COMMAND_SUPPORT'
|
3921 |
|
|
This should be used for "support facilities", generally meaning
|
3922 |
|
|
things that are useful to the user when interacting with GDB, but
|
3923 |
|
|
not related to the state of the inferior. For example, `help',
|
3924 |
|
|
`make', and `shell' are in this category. Type `help support' at
|
3925 |
|
|
the GDB prompt to see a list of commands in this category.
|
3926 |
|
|
|
3927 |
|
|
`COMMAND_STATUS'
|
3928 |
|
|
The command is an `info'-related command, that is, related to the
|
3929 |
|
|
state of GDB itself. For example, `info', `macro', and `show' are
|
3930 |
|
|
in this category. Type `help status' at the GDB prompt to see a
|
3931 |
|
|
list of commands in this category.
|
3932 |
|
|
|
3933 |
|
|
`COMMAND_BREAKPOINTS'
|
3934 |
|
|
The command has to do with breakpoints. For example, `break',
|
3935 |
|
|
`clear', and `delete' are in this category. Type `help
|
3936 |
|
|
breakpoints' at the GDB prompt to see a list of commands in this
|
3937 |
|
|
category.
|
3938 |
|
|
|
3939 |
|
|
`COMMAND_TRACEPOINTS'
|
3940 |
|
|
The command has to do with tracepoints. For example, `trace',
|
3941 |
|
|
`actions', and `tfind' are in this category. Type `help
|
3942 |
|
|
tracepoints' at the GDB prompt to see a list of commands in this
|
3943 |
|
|
category.
|
3944 |
|
|
|
3945 |
|
|
`COMMAND_OBSCURE'
|
3946 |
|
|
The command is only used in unusual circumstances, or is not of
|
3947 |
|
|
general interest to users. For example, `checkpoint', `fork', and
|
3948 |
|
|
`stop' are in this category. Type `help obscure' at the GDB
|
3949 |
|
|
prompt to see a list of commands in this category.
|
3950 |
|
|
|
3951 |
|
|
`COMMAND_MAINTENANCE'
|
3952 |
|
|
The command is only useful to GDB maintainers. The `maintenance'
|
3953 |
|
|
and `flushregs' commands are in this category. Type `help
|
3954 |
|
|
internals' at the GDB prompt to see a list of commands in this
|
3955 |
|
|
category.
|
3956 |
|
|
|
3957 |
|
|
A new command can use a predefined completion function, either by
|
3958 |
|
|
specifying it via an argument at initialization, or by returning it
|
3959 |
|
|
from the `complete' method. These predefined completion constants are
|
3960 |
|
|
all defined in the `gdb' module:
|
3961 |
|
|
|
3962 |
|
|
`COMPLETE_NONE'
|
3963 |
|
|
This constant means that no completion should be done.
|
3964 |
|
|
|
3965 |
|
|
`COMPLETE_FILENAME'
|
3966 |
|
|
This constant means that filename completion should be performed.
|
3967 |
|
|
|
3968 |
|
|
`COMPLETE_LOCATION'
|
3969 |
|
|
This constant means that location completion should be done.
|
3970 |
|
|
*Note Specify Location::.
|
3971 |
|
|
|
3972 |
|
|
`COMPLETE_COMMAND'
|
3973 |
|
|
This constant means that completion should examine GDB command
|
3974 |
|
|
names.
|
3975 |
|
|
|
3976 |
|
|
`COMPLETE_SYMBOL'
|
3977 |
|
|
This constant means that completion should be done using symbol
|
3978 |
|
|
names as the source.
|
3979 |
|
|
|
3980 |
|
|
The following code snippet shows how a trivial CLI command can be
|
3981 |
|
|
implemented in Python:
|
3982 |
|
|
|
3983 |
|
|
class HelloWorld (gdb.Command):
|
3984 |
|
|
"""Greet the whole world."""
|
3985 |
|
|
|
3986 |
|
|
def __init__ (self):
|
3987 |
|
|
super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE)
|
3988 |
|
|
|
3989 |
|
|
def invoke (self, arg, from_tty):
|
3990 |
|
|
print "Hello, World!"
|
3991 |
|
|
|
3992 |
|
|
HelloWorld ()
|
3993 |
|
|
|
3994 |
|
|
The last line instantiates the class, and is necessary to trigger the
|
3995 |
|
|
registration of the command with GDB. Depending on how the Python code
|
3996 |
|
|
is read into GDB, you may need to import the `gdb' module explicitly.
|
3997 |
|
|
|
3998 |
|
|
|
3999 |
|
|
File: gdb.info, Node: Parameters In Python, Next: Functions In Python, Prev: Commands In Python, Up: Python API
|
4000 |
|
|
|
4001 |
|
|
23.2.2.11 Parameters In Python
|
4002 |
|
|
..............................
|
4003 |
|
|
|
4004 |
|
|
You can implement new GDB parameters using Python. A new parameter is
|
4005 |
|
|
implemented as an instance of the `gdb.Parameter' class.
|
4006 |
|
|
|
4007 |
|
|
Parameters are exposed to the user via the `set' and `show'
|
4008 |
|
|
commands. *Note Help::.
|
4009 |
|
|
|
4010 |
|
|
There are many parameters that already exist and can be set in GDB.
|
4011 |
|
|
Two examples are: `set follow fork' and `set charset'. Setting these
|
4012 |
|
|
parameters influences certain behavior in GDB. Similarly, you can
|
4013 |
|
|
define parameters that can be used to influence behavior in custom
|
4014 |
|
|
Python scripts and commands.
|
4015 |
|
|
|
4016 |
|
|
-- Method on Parameter: __init__ name COMMAND-CLASS PARAMETER-CLASS
|
4017 |
|
|
[ENUM-SEQUENCE]
|
4018 |
|
|
The object initializer for `Parameter' registers the new parameter
|
4019 |
|
|
with GDB. This initializer is normally invoked from the subclass'
|
4020 |
|
|
own `__init__' method.
|
4021 |
|
|
|
4022 |
|
|
NAME is the name of the new parameter. If NAME consists of
|
4023 |
|
|
multiple words, then the initial words are looked for as prefix
|
4024 |
|
|
parameters. An example of this can be illustrated with the `set
|
4025 |
|
|
print' set of parameters. If NAME is `print foo', then `print'
|
4026 |
|
|
will be searched as the prefix parameter. In this case the
|
4027 |
|
|
parameter can subsequently be accessed in GDB as `set print foo'.
|
4028 |
|
|
|
4029 |
|
|
If NAME consists of multiple words, and no prefix parameter group
|
4030 |
|
|
can be found, an exception is raised.
|
4031 |
|
|
|
4032 |
|
|
COMMAND-CLASS should be one of the `COMMAND_' constants (*note
|
4033 |
|
|
Commands In Python::). This argument tells GDB how to categorize
|
4034 |
|
|
the new parameter in the help system.
|
4035 |
|
|
|
4036 |
|
|
PARAMETER-CLASS should be one of the `PARAM_' constants defined
|
4037 |
|
|
below. This argument tells GDB the type of the new parameter;
|
4038 |
|
|
this information is used for input validation and completion.
|
4039 |
|
|
|
4040 |
|
|
If PARAMETER-CLASS is `PARAM_ENUM', then ENUM-SEQUENCE must be a
|
4041 |
|
|
sequence of strings. These strings represent the possible values
|
4042 |
|
|
for the parameter.
|
4043 |
|
|
|
4044 |
|
|
If PARAMETER-CLASS is not `PARAM_ENUM', then the presence of a
|
4045 |
|
|
fourth argument will cause an exception to be thrown.
|
4046 |
|
|
|
4047 |
|
|
The help text for the new parameter is taken from the Python
|
4048 |
|
|
documentation string for the parameter's class, if there is one.
|
4049 |
|
|
If there is no documentation string, a default value is used.
|
4050 |
|
|
|
4051 |
|
|
-- Instance Variable of Parameter: set_doc
|
4052 |
|
|
If this attribute exists, and is a string, then its value is used
|
4053 |
|
|
as the help text for this parameter's `set' command. The value is
|
4054 |
|
|
examined when `Parameter.__init__' is invoked; subsequent changes
|
4055 |
|
|
have no effect.
|
4056 |
|
|
|
4057 |
|
|
-- Instance Variable of Parameter: show_doc
|
4058 |
|
|
If this attribute exists, and is a string, then its value is used
|
4059 |
|
|
as the help text for this parameter's `show' command. The value is
|
4060 |
|
|
examined when `Parameter.__init__' is invoked; subsequent changes
|
4061 |
|
|
have no effect.
|
4062 |
|
|
|
4063 |
|
|
-- Instance Variable of Parameter: value
|
4064 |
|
|
The `value' attribute holds the underlying value of the parameter.
|
4065 |
|
|
It can be read and assigned to just as any other attribute. GDB
|
4066 |
|
|
does validation when assignments are made.
|
4067 |
|
|
|
4068 |
|
|
When a new parameter is defined, its type must be specified. The
|
4069 |
|
|
available types are represented by constants defined in the `gdb'
|
4070 |
|
|
module:
|
4071 |
|
|
|
4072 |
|
|
`PARAM_BOOLEAN'
|
4073 |
|
|
The value is a plain boolean. The Python boolean values, `True'
|
4074 |
|
|
and `False' are the only valid values.
|
4075 |
|
|
|
4076 |
|
|
`PARAM_AUTO_BOOLEAN'
|
4077 |
|
|
The value has three possible states: true, false, and `auto'. In
|
4078 |
|
|
Python, true and false are represented using boolean constants, and
|
4079 |
|
|
`auto' is represented using `None'.
|
4080 |
|
|
|
4081 |
|
|
`PARAM_UINTEGER'
|
4082 |
|
|
The value is an unsigned integer. The value of 0 should be
|
4083 |
|
|
interpreted to mean "unlimited".
|
4084 |
|
|
|
4085 |
|
|
`PARAM_INTEGER'
|
4086 |
|
|
The value is a signed integer. The value of 0 should be
|
4087 |
|
|
interpreted to mean "unlimited".
|
4088 |
|
|
|
4089 |
|
|
`PARAM_STRING'
|
4090 |
|
|
The value is a string. When the user modifies the string, any
|
4091 |
|
|
escape sequences, such as `\t', `\f', and octal escapes, are
|
4092 |
|
|
translated into corresponding characters and encoded into the
|
4093 |
|
|
current host charset.
|
4094 |
|
|
|
4095 |
|
|
`PARAM_STRING_NOESCAPE'
|
4096 |
|
|
The value is a string. When the user modifies the string, escapes
|
4097 |
|
|
are passed through untranslated.
|
4098 |
|
|
|
4099 |
|
|
`PARAM_OPTIONAL_FILENAME'
|
4100 |
|
|
The value is a either a filename (a string), or `None'.
|
4101 |
|
|
|
4102 |
|
|
`PARAM_FILENAME'
|
4103 |
|
|
The value is a filename. This is just like
|
4104 |
|
|
`PARAM_STRING_NOESCAPE', but uses file names for completion.
|
4105 |
|
|
|
4106 |
|
|
`PARAM_ZINTEGER'
|
4107 |
|
|
The value is an integer. This is like `PARAM_INTEGER', except 0
|
4108 |
|
|
is interpreted as itself.
|
4109 |
|
|
|
4110 |
|
|
`PARAM_ENUM'
|
4111 |
|
|
The value is a string, which must be one of a collection string
|
4112 |
|
|
constants provided when the parameter is created.
|
4113 |
|
|
|
4114 |
|
|
|
4115 |
|
|
File: gdb.info, Node: Functions In Python, Next: Progspaces In Python, Prev: Parameters In Python, Up: Python API
|
4116 |
|
|
|
4117 |
|
|
23.2.2.12 Writing new convenience functions
|
4118 |
|
|
...........................................
|
4119 |
|
|
|
4120 |
|
|
You can implement new convenience functions (*note Convenience Vars::)
|
4121 |
|
|
in Python. A convenience function is an instance of a subclass of the
|
4122 |
|
|
class `gdb.Function'.
|
4123 |
|
|
|
4124 |
|
|
-- Method on Function: __init__ name
|
4125 |
|
|
The initializer for `Function' registers the new function with
|
4126 |
|
|
GDB. The argument NAME is the name of the function, a string.
|
4127 |
|
|
The function will be visible to the user as a convenience variable
|
4128 |
|
|
of type `internal function', whose name is the same as the given
|
4129 |
|
|
NAME.
|
4130 |
|
|
|
4131 |
|
|
The documentation for the new function is taken from the
|
4132 |
|
|
documentation string for the new class.
|
4133 |
|
|
|
4134 |
|
|
-- Method on Function: invoke *ARGS
|
4135 |
|
|
When a convenience function is evaluated, its arguments are
|
4136 |
|
|
converted to instances of `gdb.Value', and then the function's
|
4137 |
|
|
`invoke' method is called. Note that GDB does not predetermine
|
4138 |
|
|
the arity of convenience functions. Instead, all available
|
4139 |
|
|
arguments are passed to `invoke', following the standard Python
|
4140 |
|
|
calling convention. In particular, a convenience function can
|
4141 |
|
|
have default values for parameters without ill effect.
|
4142 |
|
|
|
4143 |
|
|
The return value of this method is used as its value in the
|
4144 |
|
|
enclosing expression. If an ordinary Python value is returned, it
|
4145 |
|
|
is converted to a `gdb.Value' following the usual rules.
|
4146 |
|
|
|
4147 |
|
|
The following code snippet shows how a trivial convenience function
|
4148 |
|
|
can be implemented in Python:
|
4149 |
|
|
|
4150 |
|
|
class Greet (gdb.Function):
|
4151 |
|
|
"""Return string to greet someone.
|
4152 |
|
|
Takes a name as argument."""
|
4153 |
|
|
|
4154 |
|
|
def __init__ (self):
|
4155 |
|
|
super (Greet, self).__init__ ("greet")
|
4156 |
|
|
|
4157 |
|
|
def invoke (self, name):
|
4158 |
|
|
return "Hello, %s!" % name.string ()
|
4159 |
|
|
|
4160 |
|
|
Greet ()
|
4161 |
|
|
|
4162 |
|
|
The last line instantiates the class, and is necessary to trigger the
|
4163 |
|
|
registration of the function with GDB. Depending on how the Python
|
4164 |
|
|
code is read into GDB, you may need to import the `gdb' module
|
4165 |
|
|
explicitly.
|
4166 |
|
|
|
4167 |
|
|
|
4168 |
|
|
File: gdb.info, Node: Progspaces In Python, Next: Objfiles In Python, Prev: Functions In Python, Up: Python API
|
4169 |
|
|
|
4170 |
|
|
23.2.2.13 Program Spaces In Python
|
4171 |
|
|
..................................
|
4172 |
|
|
|
4173 |
|
|
A program space, or "progspace", represents a symbolic view of an
|
4174 |
|
|
address space. It consists of all of the objfiles of the program.
|
4175 |
|
|
*Note Objfiles In Python::. *Note program spaces: Inferiors and
|
4176 |
|
|
Programs, for more details about program spaces.
|
4177 |
|
|
|
4178 |
|
|
The following progspace-related functions are available in the `gdb'
|
4179 |
|
|
module:
|
4180 |
|
|
|
4181 |
|
|
-- Function: current_progspace
|
4182 |
|
|
This function returns the program space of the currently selected
|
4183 |
|
|
inferior. *Note Inferiors and Programs::.
|
4184 |
|
|
|
4185 |
|
|
-- Function: progspaces
|
4186 |
|
|
Return a sequence of all the progspaces currently known to GDB.
|
4187 |
|
|
|
4188 |
|
|
Each progspace is represented by an instance of the `gdb.Progspace'
|
4189 |
|
|
class.
|
4190 |
|
|
|
4191 |
|
|
-- Instance Variable of Progspace: filename
|
4192 |
|
|
The file name of the progspace as a string.
|
4193 |
|
|
|
4194 |
|
|
-- Instance Variable of Progspace: pretty_printers
|
4195 |
|
|
The `pretty_printers' attribute is a list of functions. It is
|
4196 |
|
|
used to look up pretty-printers. A `Value' is passed to each
|
4197 |
|
|
function in order; if the function returns `None', then the search
|
4198 |
|
|
continues. Otherwise, the return value should be an object which
|
4199 |
|
|
is used to format the value. *Note Pretty Printing API::, for more
|
4200 |
|
|
information.
|
4201 |
|
|
|
4202 |
|
|
|
4203 |
|
|
File: gdb.info, Node: Objfiles In Python, Next: Frames In Python, Prev: Progspaces In Python, Up: Python API
|
4204 |
|
|
|
4205 |
|
|
23.2.2.14 Objfiles In Python
|
4206 |
|
|
............................
|
4207 |
|
|
|
4208 |
|
|
GDB loads symbols for an inferior from various symbol-containing files
|
4209 |
|
|
(*note Files::). These include the primary executable file, any shared
|
4210 |
|
|
libraries used by the inferior, and any separate debug info files
|
4211 |
|
|
(*note Separate Debug Files::). GDB calls these symbol-containing
|
4212 |
|
|
files "objfiles".
|
4213 |
|
|
|
4214 |
|
|
The following objfile-related functions are available in the `gdb'
|
4215 |
|
|
module:
|
4216 |
|
|
|
4217 |
|
|
-- Function: current_objfile
|
4218 |
|
|
When auto-loading a Python script (*note Auto-loading::), GDB sets
|
4219 |
|
|
the "current objfile" to the corresponding objfile. This function
|
4220 |
|
|
returns the current objfile. If there is no current objfile, this
|
4221 |
|
|
function returns `None'.
|
4222 |
|
|
|
4223 |
|
|
-- Function: objfiles
|
4224 |
|
|
Return a sequence of all the objfiles current known to GDB. *Note
|
4225 |
|
|
Objfiles In Python::.
|
4226 |
|
|
|
4227 |
|
|
Each objfile is represented by an instance of the `gdb.Objfile'
|
4228 |
|
|
class.
|
4229 |
|
|
|
4230 |
|
|
-- Instance Variable of Objfile: filename
|
4231 |
|
|
The file name of the objfile as a string.
|
4232 |
|
|
|
4233 |
|
|
-- Instance Variable of Objfile: pretty_printers
|
4234 |
|
|
The `pretty_printers' attribute is a list of functions. It is
|
4235 |
|
|
used to look up pretty-printers. A `Value' is passed to each
|
4236 |
|
|
function in order; if the function returns `None', then the search
|
4237 |
|
|
continues. Otherwise, the return value should be an object which
|
4238 |
|
|
is used to format the value. *Note Pretty Printing API::, for more
|
4239 |
|
|
information.
|
4240 |
|
|
|
4241 |
|
|
|
4242 |
|
|
File: gdb.info, Node: Frames In Python, Next: Blocks In Python, Prev: Objfiles In Python, Up: Python API
|
4243 |
|
|
|
4244 |
|
|
23.2.2.15 Accessing inferior stack frames from Python.
|
4245 |
|
|
......................................................
|
4246 |
|
|
|
4247 |
|
|
When the debugged program stops, GDB is able to analyze its call stack
|
4248 |
|
|
(*note Stack frames: Frames.). The `gdb.Frame' class represents a
|
4249 |
|
|
frame in the stack. A `gdb.Frame' object is only valid while its
|
4250 |
|
|
corresponding frame exists in the inferior's stack. If you try to use
|
4251 |
|
|
an invalid frame object, GDB will throw a `RuntimeError' exception.
|
4252 |
|
|
|
4253 |
|
|
Two `gdb.Frame' objects can be compared for equality with the `=='
|
4254 |
|
|
operator, like:
|
4255 |
|
|
|
4256 |
|
|
(gdb) python print gdb.newest_frame() == gdb.selected_frame ()
|
4257 |
|
|
True
|
4258 |
|
|
|
4259 |
|
|
The following frame-related functions are available in the `gdb'
|
4260 |
|
|
module:
|
4261 |
|
|
|
4262 |
|
|
-- Function: selected_frame
|
4263 |
|
|
Return the selected frame object. (*note Selecting a Frame:
|
4264 |
|
|
Selection.).
|
4265 |
|
|
|
4266 |
|
|
-- Function: frame_stop_reason_string reason
|
4267 |
|
|
Return a string explaining the reason why GDB stopped unwinding
|
4268 |
|
|
frames, as expressed by the given REASON code (an integer, see the
|
4269 |
|
|
`unwind_stop_reason' method further down in this section).
|
4270 |
|
|
|
4271 |
|
|
A `gdb.Frame' object has the following methods:
|
4272 |
|
|
|
4273 |
|
|
-- Method on Frame: is_valid
|
4274 |
|
|
Returns true if the `gdb.Frame' object is valid, false if not.
|
4275 |
|
|
A frame object can become invalid if the frame it refers to
|
4276 |
|
|
doesn't exist anymore in the inferior. All `gdb.Frame'
|
4277 |
|
|
methods will throw an exception if it is invalid at the time
|
4278 |
|
|
the method is called.
|
4279 |
|
|
|
4280 |
|
|
-- Method on Frame: name
|
4281 |
|
|
Returns the function name of the frame, or `None' if it can't
|
4282 |
|
|
be obtained.
|
4283 |
|
|
|
4284 |
|
|
-- Method on Frame: type
|
4285 |
|
|
Returns the type of the frame. The value can be one of
|
4286 |
|
|
`gdb.NORMAL_FRAME', `gdb.DUMMY_FRAME', `gdb.SIGTRAMP_FRAME'
|
4287 |
|
|
or `gdb.SENTINEL_FRAME'.
|
4288 |
|
|
|
4289 |
|
|
-- Method on Frame: unwind_stop_reason
|
4290 |
|
|
Return an integer representing the reason why it's not
|
4291 |
|
|
possible to find more frames toward the outermost frame. Use
|
4292 |
|
|
`gdb.frame_stop_reason_string' to convert the value returned
|
4293 |
|
|
by this function to a string.
|
4294 |
|
|
|
4295 |
|
|
-- Method on Frame: pc
|
4296 |
|
|
Returns the frame's resume address.
|
4297 |
|
|
|
4298 |
|
|
-- Method on Frame: block
|
4299 |
|
|
Return the frame's code block. *Note Blocks In Python::.
|
4300 |
|
|
|
4301 |
|
|
-- Method on Frame: function
|
4302 |
|
|
Return the symbol for the function corresponding to this
|
4303 |
|
|
frame. *Note Symbols In Python::.
|
4304 |
|
|
|
4305 |
|
|
-- Method on Frame: older
|
4306 |
|
|
Return the frame that called this frame.
|
4307 |
|
|
|
4308 |
|
|
-- Method on Frame: newer
|
4309 |
|
|
Return the frame called by this frame.
|
4310 |
|
|
|
4311 |
|
|
-- Method on Frame: find_sal
|
4312 |
|
|
Return the frame's symtab and line object. *Note Symbol
|
4313 |
|
|
Tables In Python::.
|
4314 |
|
|
|
4315 |
|
|
-- Method on Frame: read_var variable [block]
|
4316 |
|
|
Return the value of VARIABLE in this frame. If the optional
|
4317 |
|
|
argument BLOCK is provided, search for the variable from that
|
4318 |
|
|
block; otherwise start at the frame's current block (which is
|
4319 |
|
|
determined by the frame's current program counter). VARIABLE
|
4320 |
|
|
must be a string or a `gdb.Symbol' object. BLOCK must be a
|
4321 |
|
|
`gdb.Block' object.
|
4322 |
|
|
|
4323 |
|
|
-- Method on Frame: select
|
4324 |
|
|
Set this frame to be the selected frame. *Note Examining the
|
4325 |
|
|
Stack: Stack.
|
4326 |
|
|
|
4327 |
|
|
|
4328 |
|
|
File: gdb.info, Node: Blocks In Python, Next: Symbols In Python, Prev: Frames In Python, Up: Python API
|
4329 |
|
|
|
4330 |
|
|
23.2.2.16 Accessing frame blocks from Python.
|
4331 |
|
|
.............................................
|
4332 |
|
|
|
4333 |
|
|
Within each frame, GDB maintains information on each block stored in
|
4334 |
|
|
that frame. These blocks are organized hierarchically, and are
|
4335 |
342 |
jeremybenn |
represented individually in Python as a `gdb.Block'. Please see *note
|
4336 |
330 |
jeremybenn |
Frames In Python::, for a more in-depth discussion on frames.
|
4337 |
342 |
jeremybenn |
Furthermore, see *note Examining the Stack: Stack, for more detailed
|
4338 |
330 |
jeremybenn |
technical information on GDB's book-keeping of the stack.
|
4339 |
|
|
|
4340 |
|
|
The following block-related functions are available in the `gdb'
|
4341 |
|
|
module:
|
4342 |
|
|
|
4343 |
|
|
-- Function: block_for_pc pc
|
4344 |
|
|
Return the `gdb.Block' containing the given PC value. If the
|
4345 |
|
|
block cannot be found for the PC value specified, the function
|
4346 |
|
|
will return `None'.
|
4347 |
|
|
|
4348 |
|
|
A `gdb.Block' object has the following attributes:
|
4349 |
|
|
|
4350 |
|
|
-- Instance Variable of Block: start
|
4351 |
|
|
The start address of the block. This attribute is not
|
4352 |
|
|
writable.
|
4353 |
|
|
|
4354 |
|
|
-- Instance Variable of Block: end
|
4355 |
|
|
The end address of the block. This attribute is not writable.
|
4356 |
|
|
|
4357 |
|
|
-- Instance Variable of Block: function
|
4358 |
|
|
The name of the block represented as a `gdb.Symbol'. If the
|
4359 |
|
|
block is not named, then this attribute holds `None'. This
|
4360 |
|
|
attribute is not writable.
|
4361 |
|
|
|
4362 |
|
|
-- Instance Variable of Block: superblock
|
4363 |
|
|
The block containing this block. If this parent block does
|
4364 |
|
|
not exist, this attribute holds `None'. This attribute is
|
4365 |
|
|
not writable.
|
4366 |
|
|
|
4367 |
|
|
|
4368 |
|
|
File: gdb.info, Node: Symbols In Python, Next: Symbol Tables In Python, Prev: Blocks In Python, Up: Python API
|
4369 |
|
|
|
4370 |
|
|
23.2.2.17 Python representation of Symbols.
|
4371 |
|
|
...........................................
|
4372 |
|
|
|
4373 |
|
|
GDB represents every variable, function and type as an entry in a
|
4374 |
|
|
symbol table. *Note Examining the Symbol Table: Symbols. Similarly,
|
4375 |
|
|
Python represents these symbols in GDB with the `gdb.Symbol' object.
|
4376 |
|
|
|
4377 |
|
|
The following symbol-related functions are available in the `gdb'
|
4378 |
|
|
module:
|
4379 |
|
|
|
4380 |
|
|
-- Function: lookup_symbol name [block] [domain]
|
4381 |
|
|
This function searches for a symbol by name. The search scope can
|
4382 |
|
|
be restricted to the parameters defined in the optional domain and
|
4383 |
|
|
block arguments.
|
4384 |
|
|
|
4385 |
|
|
NAME is the name of the symbol. It must be a string. The
|
4386 |
|
|
optional BLOCK argument restricts the search to symbols visible in
|
4387 |
|
|
that BLOCK. The BLOCK argument must be a `gdb.Block' object. The
|
4388 |
|
|
optional DOMAIN argument restricts the search to the domain type.
|
4389 |
|
|
The DOMAIN argument must be a domain constant defined in the `gdb'
|
4390 |
|
|
module and described later in this chapter.
|
4391 |
|
|
|
4392 |
|
|
A `gdb.Symbol' object has the following attributes:
|
4393 |
|
|
|
4394 |
|
|
-- Instance Variable of Symbol: symtab
|
4395 |
|
|
The symbol table in which the symbol appears. This attribute
|
4396 |
|
|
is represented as a `gdb.Symtab' object. *Note Symbol Tables
|
4397 |
|
|
In Python::. This attribute is not writable.
|
4398 |
|
|
|
4399 |
|
|
-- Instance Variable of Symbol: name
|
4400 |
|
|
The name of the symbol as a string. This attribute is not
|
4401 |
|
|
writable.
|
4402 |
|
|
|
4403 |
|
|
-- Instance Variable of Symbol: linkage_name
|
4404 |
|
|
The name of the symbol, as used by the linker (i.e., may be
|
4405 |
|
|
mangled). This attribute is not writable.
|
4406 |
|
|
|
4407 |
|
|
-- Instance Variable of Symbol: print_name
|
4408 |
|
|
The name of the symbol in a form suitable for output. This
|
4409 |
|
|
is either `name' or `linkage_name', depending on whether the
|
4410 |
|
|
user asked GDB to display demangled or mangled names.
|
4411 |
|
|
|
4412 |
|
|
-- Instance Variable of Symbol: addr_class
|
4413 |
|
|
The address class of the symbol. This classifies how to find
|
4414 |
|
|
the value of a symbol. Each address class is a constant
|
4415 |
|
|
defined in the `gdb' module and described later in this
|
4416 |
|
|
chapter.
|
4417 |
|
|
|
4418 |
|
|
-- Instance Variable of Symbol: is_argument
|
4419 |
|
|
`True' if the symbol is an argument of a function.
|
4420 |
|
|
|
4421 |
|
|
-- Instance Variable of Symbol: is_constant
|
4422 |
|
|
`True' if the symbol is a constant.
|
4423 |
|
|
|
4424 |
|
|
-- Instance Variable of Symbol: is_function
|
4425 |
|
|
`True' if the symbol is a function or a method.
|
4426 |
|
|
|
4427 |
|
|
-- Instance Variable of Symbol: is_variable
|
4428 |
|
|
`True' if the symbol is a variable.
|
4429 |
|
|
|
4430 |
|
|
The available domain categories in `gdb.Symbol' are represented as
|
4431 |
|
|
constants in the `gdb' module:
|
4432 |
|
|
|
4433 |
|
|
`SYMBOL_UNDEF_DOMAIN'
|
4434 |
|
|
This is used when a domain has not been discovered or none of the
|
4435 |
|
|
following domains apply. This usually indicates an error either
|
4436 |
|
|
in the symbol information or in GDB's handling of symbols.
|
4437 |
|
|
|
4438 |
|
|
`SYMBOL_VAR_DOMAIN'
|
4439 |
|
|
This domain contains variables, function names, typedef names and
|
4440 |
|
|
enum type values.
|
4441 |
|
|
|
4442 |
|
|
`SYMBOL_STRUCT_DOMAIN'
|
4443 |
|
|
This domain holds struct, union and enum type names.
|
4444 |
|
|
|
4445 |
|
|
`SYMBOL_LABEL_DOMAIN'
|
4446 |
|
|
This domain contains names of labels (for gotos).
|
4447 |
|
|
|
4448 |
|
|
`SYMBOL_VARIABLES_DOMAIN'
|
4449 |
|
|
This domain holds a subset of the `SYMBOLS_VAR_DOMAIN'; it
|
4450 |
|
|
contains everything minus functions and types.
|
4451 |
|
|
|
4452 |
|
|
`SYMBOL_FUNCTION_DOMAIN'
|
4453 |
|
|
This domain contains all functions.
|
4454 |
|
|
|
4455 |
|
|
`SYMBOL_TYPES_DOMAIN'
|
4456 |
|
|
This domain contains all types.
|
4457 |
|
|
|
4458 |
|
|
The available address class categories in `gdb.Symbol' are
|
4459 |
|
|
represented as constants in the `gdb' module:
|
4460 |
|
|
|
4461 |
|
|
`SYMBOL_LOC_UNDEF'
|
4462 |
|
|
If this is returned by address class, it indicates an error either
|
4463 |
|
|
in the symbol information or in GDB's handling of symbols.
|
4464 |
|
|
|
4465 |
|
|
`SYMBOL_LOC_CONST'
|
4466 |
|
|
Value is constant int.
|
4467 |
|
|
|
4468 |
|
|
`SYMBOL_LOC_STATIC'
|
4469 |
|
|
Value is at a fixed address.
|
4470 |
|
|
|
4471 |
|
|
`SYMBOL_LOC_REGISTER'
|
4472 |
|
|
Value is in a register.
|
4473 |
|
|
|
4474 |
|
|
`SYMBOL_LOC_ARG'
|
4475 |
|
|
Value is an argument. This value is at the offset stored within
|
4476 |
|
|
the symbol inside the frame's argument list.
|
4477 |
|
|
|
4478 |
|
|
`SYMBOL_LOC_REF_ARG'
|
4479 |
|
|
Value address is stored in the frame's argument list. Just like
|
4480 |
|
|
`LOC_ARG' except that the value's address is stored at the offset,
|
4481 |
|
|
not the value itself.
|
4482 |
|
|
|
4483 |
|
|
`SYMBOL_LOC_REGPARM_ADDR'
|
4484 |
|
|
Value is a specified register. Just like `LOC_REGISTER' except
|
4485 |
|
|
the register holds the address of the argument instead of the
|
4486 |
|
|
argument itself.
|
4487 |
|
|
|
4488 |
|
|
`SYMBOL_LOC_LOCAL'
|
4489 |
|
|
Value is a local variable.
|
4490 |
|
|
|
4491 |
|
|
`SYMBOL_LOC_TYPEDEF'
|
4492 |
|
|
Value not used. Symbols in the domain `SYMBOL_STRUCT_DOMAIN' all
|
4493 |
|
|
have this class.
|
4494 |
|
|
|
4495 |
|
|
`SYMBOL_LOC_BLOCK'
|
4496 |
|
|
Value is a block.
|
4497 |
|
|
|
4498 |
|
|
`SYMBOL_LOC_CONST_BYTES'
|
4499 |
|
|
Value is a byte-sequence.
|
4500 |
|
|
|
4501 |
|
|
`SYMBOL_LOC_UNRESOLVED'
|
4502 |
|
|
Value is at a fixed address, but the address of the variable has
|
4503 |
|
|
to be determined from the minimal symbol table whenever the
|
4504 |
|
|
variable is referenced.
|
4505 |
|
|
|
4506 |
|
|
`SYMBOL_LOC_OPTIMIZED_OUT'
|
4507 |
|
|
The value does not actually exist in the program.
|
4508 |
|
|
|
4509 |
|
|
`SYMBOL_LOC_COMPUTED'
|
4510 |
|
|
The value's address is a computed location.
|
4511 |
|
|
|
4512 |
|
|
|
4513 |
|
|
File: gdb.info, Node: Symbol Tables In Python, Next: Lazy Strings In Python, Prev: Symbols In Python, Up: Python API
|
4514 |
|
|
|
4515 |
|
|
23.2.2.18 Symbol table representation in Python.
|
4516 |
|
|
................................................
|
4517 |
|
|
|
4518 |
|
|
Access to symbol table data maintained by GDB on the inferior is
|
4519 |
|
|
exposed to Python via two objects: `gdb.Symtab_and_line' and
|
4520 |
|
|
`gdb.Symtab'. Symbol table and line data for a frame is returned from
|
4521 |
|
|
the `find_sal' method in `gdb.Frame' object. *Note Frames In Python::.
|
4522 |
|
|
|
4523 |
342 |
jeremybenn |
For more information on GDB's symbol table management, see *note
|
4524 |
330 |
jeremybenn |
Examining the Symbol Table: Symbols, for more information.
|
4525 |
|
|
|
4526 |
|
|
A `gdb.Symtab_and_line' object has the following attributes:
|
4527 |
|
|
|
4528 |
|
|
-- Instance Variable of Symtab_and_line: symtab
|
4529 |
|
|
The symbol table object (`gdb.Symtab') for this frame. This
|
4530 |
|
|
attribute is not writable.
|
4531 |
|
|
|
4532 |
|
|
-- Instance Variable of Symtab_and_line: pc
|
4533 |
|
|
Indicates the current program counter address. This
|
4534 |
|
|
attribute is not writable.
|
4535 |
|
|
|
4536 |
|
|
-- Instance Variable of Symtab_and_line: line
|
4537 |
|
|
Indicates the current line number for this object. This
|
4538 |
|
|
attribute is not writable.
|
4539 |
|
|
|
4540 |
|
|
A `gdb.Symtab' object has the following attributes:
|
4541 |
|
|
|
4542 |
|
|
-- Instance Variable of Symtab: filename
|
4543 |
|
|
The symbol table's source filename. This attribute is not
|
4544 |
|
|
writable.
|
4545 |
|
|
|
4546 |
|
|
-- Instance Variable of Symtab: objfile
|
4547 |
|
|
The symbol table's backing object file. *Note Objfiles In
|
4548 |
|
|
Python::. This attribute is not writable.
|
4549 |
|
|
|
4550 |
|
|
The following methods are provided:
|
4551 |
|
|
|
4552 |
|
|
-- Method on Symtab: fullname
|
4553 |
|
|
Return the symbol table's source absolute file name.
|
4554 |
|
|
|
4555 |
|
|
|
4556 |
|
|
File: gdb.info, Node: Breakpoints In Python, Prev: Lazy Strings In Python, Up: Python API
|
4557 |
|
|
|
4558 |
|
|
23.2.2.19 Manipulating breakpoints using Python
|
4559 |
|
|
...............................................
|
4560 |
|
|
|
4561 |
|
|
Python code can manipulate breakpoints via the `gdb.Breakpoint' class.
|
4562 |
|
|
|
4563 |
|
|
-- Method on Breakpoint: __init__ spec [type] [wp_class]
|
4564 |
|
|
Create a new breakpoint. SPEC is a string naming the location of
|
4565 |
|
|
the breakpoint, or an expression that defines a watchpoint. The
|
4566 |
|
|
contents can be any location recognized by the `break' command, or
|
4567 |
|
|
in the case of a watchpoint, by the `watch' command. The optional
|
4568 |
|
|
TYPE denotes the breakpoint to create from the types defined later
|
4569 |
|
|
in this chapter. This argument can be either: `BP_BREAKPOINT' or
|
4570 |
|
|
`BP_WATCHPOINT'. TYPE defaults to `BP_BREAKPOINT'. The optional
|
4571 |
|
|
WP_CLASS argument defines the class of watchpoint to create, if
|
4572 |
|
|
TYPE is defined as `BP_WATCHPOINT'. If a watchpoint class is not
|
4573 |
|
|
provided, it is assumed to be a WP_WRITE class.
|
4574 |
|
|
|
4575 |
|
|
The available watchpoint types represented by constants are defined
|
4576 |
|
|
in the `gdb' module:
|
4577 |
|
|
|
4578 |
|
|
`WP_READ'
|
4579 |
|
|
Read only watchpoint.
|
4580 |
|
|
|
4581 |
|
|
`WP_WRITE'
|
4582 |
|
|
Write only watchpoint.
|
4583 |
|
|
|
4584 |
|
|
`WP_ACCESS'
|
4585 |
|
|
Read/Write watchpoint.
|
4586 |
|
|
|
4587 |
|
|
-- Method on Breakpoint: is_valid
|
4588 |
|
|
Return `True' if this `Breakpoint' object is valid, `False'
|
4589 |
|
|
otherwise. A `Breakpoint' object can become invalid if the user
|
4590 |
|
|
deletes the breakpoint. In this case, the object still exists,
|
4591 |
|
|
but the underlying breakpoint does not. In the cases of
|
4592 |
|
|
watchpoint scope, the watchpoint remains valid even if execution
|
4593 |
|
|
of the inferior leaves the scope of that watchpoint.
|
4594 |
|
|
|
4595 |
|
|
-- Instance Variable of Breakpoint: enabled
|
4596 |
|
|
This attribute is `True' if the breakpoint is enabled, and `False'
|
4597 |
|
|
otherwise. This attribute is writable.
|
4598 |
|
|
|
4599 |
|
|
-- Instance Variable of Breakpoint: silent
|
4600 |
|
|
This attribute is `True' if the breakpoint is silent, and `False'
|
4601 |
|
|
otherwise. This attribute is writable.
|
4602 |
|
|
|
4603 |
|
|
Note that a breakpoint can also be silent if it has commands and
|
4604 |
|
|
the first command is `silent'. This is not reported by the
|
4605 |
|
|
`silent' attribute.
|
4606 |
|
|
|
4607 |
|
|
-- Instance Variable of Breakpoint: thread
|
4608 |
|
|
If the breakpoint is thread-specific, this attribute holds the
|
4609 |
|
|
thread id. If the breakpoint is not thread-specific, this
|
4610 |
|
|
attribute is `None'. This attribute is writable.
|
4611 |
|
|
|
4612 |
|
|
-- Instance Variable of Breakpoint: task
|
4613 |
|
|
If the breakpoint is Ada task-specific, this attribute holds the
|
4614 |
|
|
Ada task id. If the breakpoint is not task-specific (or the
|
4615 |
|
|
underlying language is not Ada), this attribute is `None'. This
|
4616 |
|
|
attribute is writable.
|
4617 |
|
|
|
4618 |
|
|
-- Instance Variable of Breakpoint: ignore_count
|
4619 |
|
|
This attribute holds the ignore count for the breakpoint, an
|
4620 |
|
|
integer. This attribute is writable.
|
4621 |
|
|
|
4622 |
|
|
-- Instance Variable of Breakpoint: number
|
4623 |
|
|
This attribute holds the breakpoint's number -- the identifier
|
4624 |
|
|
used by the user to manipulate the breakpoint. This attribute is
|
4625 |
|
|
not writable.
|
4626 |
|
|
|
4627 |
|
|
-- Instance Variable of Breakpoint: type
|
4628 |
|
|
This attribute holds the breakpoint's type -- the identifier used
|
4629 |
|
|
to determine the actual breakpoint type or use-case. This
|
4630 |
|
|
attribute is not writable.
|
4631 |
|
|
|
4632 |
|
|
The available types are represented by constants defined in the `gdb'
|
4633 |
|
|
module:
|
4634 |
|
|
|
4635 |
|
|
`BP_BREAKPOINT'
|
4636 |
|
|
Normal code breakpoint.
|
4637 |
|
|
|
4638 |
|
|
`BP_WATCHPOINT'
|
4639 |
|
|
Watchpoint breakpoint.
|
4640 |
|
|
|
4641 |
|
|
`BP_HARDWARE_WATCHPOINT'
|
4642 |
|
|
Hardware assisted watchpoint.
|
4643 |
|
|
|
4644 |
|
|
`BP_READ_WATCHPOINT'
|
4645 |
|
|
Hardware assisted read watchpoint.
|
4646 |
|
|
|
4647 |
|
|
`BP_ACCESS_WATCHPOINT'
|
4648 |
|
|
Hardware assisted access watchpoint.
|
4649 |
|
|
|
4650 |
|
|
-- Instance Variable of Breakpoint: hit_count
|
4651 |
|
|
This attribute holds the hit count for the breakpoint, an integer.
|
4652 |
|
|
This attribute is writable, but currently it can only be set to
|
4653 |
|
|
zero.
|
4654 |
|
|
|
4655 |
|
|
-- Instance Variable of Breakpoint: location
|
4656 |
|
|
This attribute holds the location of the breakpoint, as specified
|
4657 |
|
|
by the user. It is a string. If the breakpoint does not have a
|
4658 |
|
|
location (that is, it is a watchpoint) the attribute's value is
|
4659 |
|
|
`None'. This attribute is not writable.
|
4660 |
|
|
|
4661 |
|
|
-- Instance Variable of Breakpoint: expression
|
4662 |
|
|
This attribute holds a breakpoint expression, as specified by the
|
4663 |
|
|
user. It is a string. If the breakpoint does not have an
|
4664 |
|
|
expression (the breakpoint is not a watchpoint) the attribute's
|
4665 |
|
|
value is `None'. This attribute is not writable.
|
4666 |
|
|
|
4667 |
|
|
-- Instance Variable of Breakpoint: condition
|
4668 |
|
|
This attribute holds the condition of the breakpoint, as specified
|
4669 |
|
|
by the user. It is a string. If there is no condition, this
|
4670 |
|
|
attribute's value is `None'. This attribute is writable.
|
4671 |
|
|
|
4672 |
|
|
-- Instance Variable of Breakpoint: commands
|
4673 |
|
|
This attribute holds the commands attached to the breakpoint. If
|
4674 |
|
|
there are commands, this attribute's value is a string holding all
|
4675 |
|
|
the commands, separated by newlines. If there are no commands,
|
4676 |
|
|
this attribute is `None'. This attribute is not writable.
|
4677 |
|
|
|
4678 |
|
|
|
4679 |
|
|
File: gdb.info, Node: Lazy Strings In Python, Next: Breakpoints In Python, Prev: Symbol Tables In Python, Up: Python API
|
4680 |
|
|
|
4681 |
|
|
23.2.2.20 Python representation of lazy strings.
|
4682 |
|
|
................................................
|
4683 |
|
|
|
4684 |
|
|
A "lazy string" is a string whose contents is not retrieved or encoded
|
4685 |
|
|
until it is needed.
|
4686 |
|
|
|
4687 |
|
|
A `gdb.LazyString' is represented in GDB as an `address' that points
|
4688 |
|
|
to a region of memory, an `encoding' that will be used to encode that
|
4689 |
|
|
region of memory, and a `length' to delimit the region of memory that
|
4690 |
|
|
represents the string. The difference between a `gdb.LazyString' and a
|
4691 |
|
|
string wrapped within a `gdb.Value' is that a `gdb.LazyString' will be
|
4692 |
|
|
treated differently by GDB when printing. A `gdb.LazyString' is
|
4693 |
|
|
retrieved and encoded during printing, while a `gdb.Value' wrapping a
|
4694 |
|
|
string is immediately retrieved and encoded on creation.
|
4695 |
|
|
|
4696 |
|
|
A `gdb.LazyString' object has the following functions:
|
4697 |
|
|
|
4698 |
|
|
-- Method on LazyString: value
|
4699 |
|
|
Convert the `gdb.LazyString' to a `gdb.Value'. This value will
|
4700 |
|
|
point to the string in memory, but will lose all the delayed
|
4701 |
|
|
retrieval, encoding and handling that GDB applies to a
|
4702 |
|
|
`gdb.LazyString'.
|
4703 |
|
|
|
4704 |
|
|
-- Instance Variable of LazyString: address
|
4705 |
|
|
This attribute holds the address of the string. This attribute is
|
4706 |
|
|
not writable.
|
4707 |
|
|
|
4708 |
|
|
-- Instance Variable of LazyString: length
|
4709 |
|
|
This attribute holds the length of the string in characters. If
|
4710 |
|
|
the length is -1, then the string will be fetched and encoded up
|
4711 |
|
|
to the first null of appropriate width. This attribute is not
|
4712 |
|
|
writable.
|
4713 |
|
|
|
4714 |
|
|
-- Instance Variable of LazyString: encoding
|
4715 |
|
|
This attribute holds the encoding that will be applied to the
|
4716 |
|
|
string when the string is printed by GDB. If the encoding is not
|
4717 |
|
|
set, or contains an empty string, then GDB will select the most
|
4718 |
|
|
appropriate encoding when the string is printed. This attribute
|
4719 |
|
|
is not writable.
|
4720 |
|
|
|
4721 |
|
|
-- Instance Variable of LazyString: type
|
4722 |
|
|
This attribute holds the type that is represented by the lazy
|
4723 |
|
|
string's type. For a lazy string this will always be a pointer
|
4724 |
|
|
type. To resolve this to the lazy string's character type, use
|
4725 |
|
|
the type's `target' method. *Note Types In Python::. This
|
4726 |
|
|
attribute is not writable.
|
4727 |
|
|
|
4728 |
|
|
|
4729 |
|
|
File: gdb.info, Node: Auto-loading, Prev: Python API, Up: Python
|
4730 |
|
|
|
4731 |
|
|
23.2.3 Auto-loading
|
4732 |
|
|
-------------------
|
4733 |
|
|
|
4734 |
|
|
When a new object file is read (for example, due to the `file' command,
|
4735 |
|
|
or because the inferior has loaded a shared library), GDB will look for
|
4736 |
|
|
Python support scripts in several ways: `OBJFILE-gdb.py' and
|
4737 |
|
|
`.debug_gdb_scripts' section.
|
4738 |
|
|
|
4739 |
|
|
* Menu:
|
4740 |
|
|
|
4741 |
|
|
* objfile-gdb.py file:: The `OBJFILE-gdb.py' file
|
4742 |
|
|
* .debug_gdb_scripts section:: The `.debug_gdb_scripts' section
|
4743 |
|
|
* Which flavor to choose?::
|
4744 |
|
|
|
4745 |
|
|
The auto-loading feature is useful for supplying application-specific
|
4746 |
|
|
debugging commands and scripts.
|
4747 |
|
|
|
4748 |
|
|
Auto-loading can be enabled or disabled.
|
4749 |
|
|
|
4750 |
|
|
`maint set python auto-load [yes|no]'
|
4751 |
|
|
Enable or disable the Python auto-loading feature.
|
4752 |
|
|
|
4753 |
|
|
`maint show python auto-load'
|
4754 |
|
|
Show whether Python auto-loading is enabled or disabled.
|
4755 |
|
|
|
4756 |
|
|
When reading an auto-loaded file, GDB sets the "current objfile".
|
4757 |
|
|
This is available via the `gdb.current_objfile' function (*note
|
4758 |
|
|
Objfiles In Python::). This can be useful for registering
|
4759 |
|
|
objfile-specific pretty-printers.
|
4760 |
|
|
|
4761 |
|
|
|
4762 |
|
|
File: gdb.info, Node: objfile-gdb.py file, Next: .debug_gdb_scripts section, Up: Auto-loading
|
4763 |
|
|
|
4764 |
|
|
23.2.3.1 The `OBJFILE-gdb.py' file
|
4765 |
|
|
..................................
|
4766 |
|
|
|
4767 |
|
|
When a new object file is read, GDB looks for a file named
|
4768 |
|
|
`OBJFILE-gdb.py', where OBJFILE is the object file's real name, formed
|
4769 |
|
|
by ensuring that the file name is absolute, following all symlinks, and
|
4770 |
|
|
resolving `.' and `..' components. If this file exists and is
|
4771 |
|
|
readable, GDB will evaluate it as a Python script.
|
4772 |
|
|
|
4773 |
|
|
If this file does not exist, and if the parameter
|
4774 |
|
|
`debug-file-directory' is set (*note Separate Debug Files::), then GDB
|
4775 |
|
|
will look for REAL-NAME in all of the directories mentioned in the
|
4776 |
|
|
value of `debug-file-directory'.
|
4777 |
|
|
|
4778 |
|
|
Finally, if this file does not exist, then GDB will look for a file
|
4779 |
|
|
named `DATA-DIRECTORY/python/auto-load/REAL-NAME', where DATA-DIRECTORY
|
4780 |
|
|
is GDB's data directory (available via `show data-directory', *note
|
4781 |
|
|
Data Files::), and REAL-NAME is the object file's real name, as
|
4782 |
|
|
described above.
|
4783 |
|
|
|
4784 |
|
|
GDB does not track which files it has already auto-loaded this way.
|
4785 |
|
|
GDB will load the associated script every time the corresponding
|
4786 |
|
|
OBJFILE is opened. So your `-gdb.py' file should be careful to avoid
|
4787 |
|
|
errors if it is evaluated more than once.
|
4788 |
|
|
|
4789 |
|
|
|
4790 |
|
|
File: gdb.info, Node: .debug_gdb_scripts section, Next: Which flavor to choose?, Prev: objfile-gdb.py file, Up: Auto-loading
|
4791 |
|
|
|
4792 |
|
|
23.2.3.2 The `.debug_gdb_scripts' section
|
4793 |
|
|
.........................................
|
4794 |
|
|
|
4795 |
|
|
For systems using file formats like ELF and COFF, when GDB loads a new
|
4796 |
|
|
object file it will look for a special section named
|
4797 |
|
|
`.debug_gdb_scripts'. If this section exists, its contents is a list
|
4798 |
|
|
of names of scripts to load.
|
4799 |
|
|
|
4800 |
|
|
GDB will look for each specified script file first in the current
|
4801 |
|
|
directory and then along the source search path (*note Specifying
|
4802 |
|
|
Source Directories: Source Path.), except that `$cdir' is not searched,
|
4803 |
|
|
since the compilation directory is not relevant to scripts.
|
4804 |
|
|
|
4805 |
|
|
Entries can be placed in section `.debug_gdb_scripts' with, for
|
4806 |
|
|
example, this GCC macro:
|
4807 |
|
|
|
4808 |
|
|
/* Note: The "MS" section flags are to remove duplicates. */
|
4809 |
|
|
#define DEFINE_GDB_SCRIPT(script_name) \
|
4810 |
|
|
asm("\
|
4811 |
|
|
.pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\
|
4812 |
|
|
.byte 1\n\
|
4813 |
|
|
.asciz \"" script_name "\"\n\
|
4814 |
|
|
.popsection \n\
|
4815 |
|
|
");
|
4816 |
|
|
|
4817 |
|
|
Then one can reference the macro in a header or source file like this:
|
4818 |
|
|
|
4819 |
|
|
DEFINE_GDB_SCRIPT ("my-app-scripts.py")
|
4820 |
|
|
|
4821 |
|
|
The script name may include directories if desired.
|
4822 |
|
|
|
4823 |
|
|
If the macro is put in a header, any application or library using
|
4824 |
|
|
this header will get a reference to the specified script.
|
4825 |
|
|
|
4826 |
|
|
|
4827 |
|
|
File: gdb.info, Node: Which flavor to choose?, Prev: .debug_gdb_scripts section, Up: Auto-loading
|
4828 |
|
|
|
4829 |
|
|
23.2.3.3 Which flavor to choose?
|
4830 |
|
|
................................
|
4831 |
|
|
|
4832 |
|
|
Given the multiple ways of auto-loading Python scripts, it might not
|
4833 |
|
|
always be clear which one to choose. This section provides some
|
4834 |
|
|
guidance.
|
4835 |
|
|
|
4836 |
|
|
Benefits of the `-gdb.py' way:
|
4837 |
|
|
|
4838 |
|
|
* Can be used with file formats that don't support multiple sections.
|
4839 |
|
|
|
4840 |
|
|
* Ease of finding scripts for public libraries.
|
4841 |
|
|
|
4842 |
|
|
Scripts specified in the `.debug_gdb_scripts' section are searched
|
4843 |
|
|
for in the source search path. For publicly installed libraries,
|
4844 |
|
|
e.g., `libstdc++', there typically isn't a source directory in
|
4845 |
|
|
which to find the script.
|
4846 |
|
|
|
4847 |
|
|
* Doesn't require source code additions.
|
4848 |
|
|
|
4849 |
|
|
Benefits of the `.debug_gdb_scripts' way:
|
4850 |
|
|
|
4851 |
|
|
* Works with static linking.
|
4852 |
|
|
|
4853 |
|
|
Scripts for libraries done the `-gdb.py' way require an objfile to
|
4854 |
|
|
trigger their loading. When an application is statically linked
|
4855 |
|
|
the only objfile available is the executable, and it is cumbersome
|
4856 |
|
|
to attach all the scripts from all the input libraries to the
|
4857 |
|
|
executable's `-gdb.py' script.
|
4858 |
|
|
|
4859 |
|
|
* Works with classes that are entirely inlined.
|
4860 |
|
|
|
4861 |
|
|
Some classes can be entirely inlined, and thus there may not be an
|
4862 |
|
|
associated shared library to attach a `-gdb.py' script to.
|
4863 |
|
|
|
4864 |
|
|
* Scripts needn't be copied out of the source tree.
|
4865 |
|
|
|
4866 |
|
|
In some circumstances, apps can be built out of large collections
|
4867 |
|
|
of internal libraries, and the build infrastructure necessary to
|
4868 |
|
|
install the `-gdb.py' scripts in a place where GDB can find them is
|
4869 |
|
|
cumbersome. It may be easier to specify the scripts in the
|
4870 |
|
|
`.debug_gdb_scripts' section as relative paths, and add a path to
|
4871 |
|
|
the top of the source tree to the source search path.
|
4872 |
|
|
|
4873 |
|
|
|
4874 |
|
|
File: gdb.info, Node: Interpreters, Next: TUI, Prev: Extending GDB, Up: Top
|
4875 |
|
|
|
4876 |
|
|
24 Command Interpreters
|
4877 |
|
|
***********************
|
4878 |
|
|
|
4879 |
|
|
GDB supports multiple command interpreters, and some command
|
4880 |
|
|
infrastructure to allow users or user interface writers to switch
|
4881 |
|
|
between interpreters or run commands in other interpreters.
|
4882 |
|
|
|
4883 |
|
|
GDB currently supports two command interpreters, the console
|
4884 |
|
|
interpreter (sometimes called the command-line interpreter or CLI) and
|
4885 |
|
|
the machine interface interpreter (or GDB/MI). This manual describes
|
4886 |
|
|
both of these interfaces in great detail.
|
4887 |
|
|
|
4888 |
|
|
By default, GDB will start with the console interpreter. However,
|
4889 |
|
|
the user may choose to start GDB with another interpreter by specifying
|
4890 |
|
|
the `-i' or `--interpreter' startup options. Defined interpreters
|
4891 |
|
|
include:
|
4892 |
|
|
|
4893 |
|
|
`console'
|
4894 |
|
|
The traditional console or command-line interpreter. This is the
|
4895 |
|
|
most often used interpreter with GDB. With no interpreter
|
4896 |
|
|
specified at runtime, GDB will use this interpreter.
|
4897 |
|
|
|
4898 |
|
|
`mi'
|
4899 |
|
|
The newest GDB/MI interface (currently `mi2'). Used primarily by
|
4900 |
|
|
programs wishing to use GDB as a backend for a debugger GUI or an
|
4901 |
342 |
jeremybenn |
IDE. For more information, see *note The GDB/MI Interface: GDB/MI.
|
4902 |
330 |
jeremybenn |
|
4903 |
|
|
`mi2'
|
4904 |
|
|
The current GDB/MI interface.
|
4905 |
|
|
|
4906 |
|
|
`mi1'
|
4907 |
|
|
The GDB/MI interface included in GDB 5.1, 5.2, and 5.3.
|
4908 |
|
|
|
4909 |
|
|
|
4910 |
|
|
The interpreter being used by GDB may not be dynamically switched at
|
4911 |
|
|
runtime. Although possible, this could lead to a very precarious
|
4912 |
|
|
situation. Consider an IDE using GDB/MI. If a user enters the command
|
4913 |
|
|
"interpreter-set console" in a console view, GDB would switch to using
|
4914 |
|
|
the console interpreter, rendering the IDE inoperable!
|
4915 |
|
|
|
4916 |
|
|
Although you may only choose a single interpreter at startup, you
|
4917 |
|
|
may execute commands in any interpreter from the current interpreter
|
4918 |
|
|
using the appropriate command. If you are running the console
|
4919 |
|
|
interpreter, simply use the `interpreter-exec' command:
|
4920 |
|
|
|
4921 |
|
|
interpreter-exec mi "-data-list-register-names"
|
4922 |
|
|
|
4923 |
|
|
GDB/MI has a similar command, although it is only available in
|
4924 |
|
|
versions of GDB which support GDB/MI version 2 (or greater).
|
4925 |
|
|
|
4926 |
|
|
|
4927 |
|
|
File: gdb.info, Node: TUI, Next: Emacs, Prev: Interpreters, Up: Top
|
4928 |
|
|
|
4929 |
|
|
25 GDB Text User Interface
|
4930 |
|
|
**************************
|
4931 |
|
|
|
4932 |
|
|
* Menu:
|
4933 |
|
|
|
4934 |
|
|
* TUI Overview:: TUI overview
|
4935 |
|
|
* TUI Keys:: TUI key bindings
|
4936 |
|
|
* TUI Single Key Mode:: TUI single key mode
|
4937 |
|
|
* TUI Commands:: TUI-specific commands
|
4938 |
|
|
* TUI Configuration:: TUI configuration variables
|
4939 |
|
|
|
4940 |
|
|
The GDB Text User Interface (TUI) is a terminal interface which uses
|
4941 |
|
|
the `curses' library to show the source file, the assembly output, the
|
4942 |
|
|
program registers and GDB commands in separate text windows. The TUI
|
4943 |
|
|
mode is supported only on platforms where a suitable version of the
|
4944 |
|
|
`curses' library is available.
|
4945 |
|
|
|
4946 |
|
|
The TUI mode is enabled by default when you invoke GDB as either
|
4947 |
|
|
`gdbtui' or `gdb -tui'. You can also switch in and out of TUI mode
|
4948 |
|
|
while GDB runs by using various TUI commands and key bindings, such as
|
4949 |
|
|
`C-x C-a'. *Note TUI Key Bindings: TUI Keys.
|
4950 |
|
|
|
4951 |
|
|
|
4952 |
|
|
File: gdb.info, Node: TUI Overview, Next: TUI Keys, Up: TUI
|
4953 |
|
|
|
4954 |
|
|
25.1 TUI Overview
|
4955 |
|
|
=================
|
4956 |
|
|
|
4957 |
|
|
In TUI mode, GDB can display several text windows:
|
4958 |
|
|
|
4959 |
|
|
_command_
|
4960 |
|
|
This window is the GDB command window with the GDB prompt and the
|
4961 |
|
|
GDB output. The GDB input is still managed using readline.
|
4962 |
|
|
|
4963 |
|
|
_source_
|
4964 |
|
|
The source window shows the source file of the program. The
|
4965 |
|
|
current line and active breakpoints are displayed in this window.
|
4966 |
|
|
|
4967 |
|
|
_assembly_
|
4968 |
|
|
The assembly window shows the disassembly output of the program.
|
4969 |
|
|
|
4970 |
|
|
_register_
|
4971 |
|
|
This window shows the processor registers. Registers are
|
4972 |
|
|
highlighted when their values change.
|
4973 |
|
|
|
4974 |
|
|
The source and assembly windows show the current program position by
|
4975 |
|
|
highlighting the current line and marking it with a `>' marker.
|
4976 |
|
|
Breakpoints are indicated with two markers. The first marker indicates
|
4977 |
|
|
the breakpoint type:
|
4978 |
|
|
|
4979 |
|
|
`B'
|
4980 |
|
|
Breakpoint which was hit at least once.
|
4981 |
|
|
|
4982 |
|
|
`b'
|
4983 |
|
|
Breakpoint which was never hit.
|
4984 |
|
|
|
4985 |
|
|
`H'
|
4986 |
|
|
Hardware breakpoint which was hit at least once.
|
4987 |
|
|
|
4988 |
|
|
`h'
|
4989 |
|
|
Hardware breakpoint which was never hit.
|
4990 |
|
|
|
4991 |
|
|
The second marker indicates whether the breakpoint is enabled or not:
|
4992 |
|
|
|
4993 |
|
|
`+'
|
4994 |
|
|
Breakpoint is enabled.
|
4995 |
|
|
|
4996 |
|
|
`-'
|
4997 |
|
|
Breakpoint is disabled.
|
4998 |
|
|
|
4999 |
|
|
The source, assembly and register windows are updated when the
|
5000 |
|
|
current thread changes, when the frame changes, or when the program
|
5001 |
|
|
counter changes.
|
5002 |
|
|
|
5003 |
|
|
These windows are not all visible at the same time. The command
|
5004 |
|
|
window is always visible. The others can be arranged in several
|
5005 |
|
|
layouts:
|
5006 |
|
|
|
5007 |
|
|
* source only,
|
5008 |
|
|
|
5009 |
|
|
* assembly only,
|
5010 |
|
|
|
5011 |
|
|
* source and assembly,
|
5012 |
|
|
|
5013 |
|
|
* source and registers, or
|
5014 |
|
|
|
5015 |
|
|
* assembly and registers.
|
5016 |
|
|
|
5017 |
|
|
A status line above the command window shows the following
|
5018 |
|
|
information:
|
5019 |
|
|
|
5020 |
|
|
_target_
|
5021 |
|
|
Indicates the current GDB target. (*note Specifying a Debugging
|
5022 |
|
|
Target: Targets.).
|
5023 |
|
|
|
5024 |
|
|
_process_
|
5025 |
|
|
Gives the current process or thread number. When no process is
|
5026 |
|
|
being debugged, this field is set to `No process'.
|
5027 |
|
|
|
5028 |
|
|
_function_
|
5029 |
|
|
Gives the current function name for the selected frame. The name
|
5030 |
|
|
is demangled if demangling is turned on (*note Print Settings::).
|
5031 |
|
|
When there is no symbol corresponding to the current program
|
5032 |
|
|
counter, the string `??' is displayed.
|
5033 |
|
|
|
5034 |
|
|
_line_
|
5035 |
|
|
Indicates the current line number for the selected frame. When
|
5036 |
|
|
the current line number is not known, the string `??' is displayed.
|
5037 |
|
|
|
5038 |
|
|
_pc_
|
5039 |
|
|
Indicates the current program counter address.
|
5040 |
|
|
|
5041 |
|
|
|
5042 |
|
|
File: gdb.info, Node: TUI Keys, Next: TUI Single Key Mode, Prev: TUI Overview, Up: TUI
|
5043 |
|
|
|
5044 |
|
|
25.2 TUI Key Bindings
|
5045 |
|
|
=====================
|
5046 |
|
|
|
5047 |
|
|
The TUI installs several key bindings in the readline keymaps (*note
|
5048 |
|
|
Command Line Editing::). The following key bindings are installed for
|
5049 |
|
|
both TUI mode and the GDB standard mode.
|
5050 |
|
|
|
5051 |
|
|
`C-x C-a'
|
5052 |
|
|
`C-x a'
|
5053 |
|
|
`C-x A'
|
5054 |
|
|
Enter or leave the TUI mode. When leaving the TUI mode, the
|
5055 |
|
|
curses window management stops and GDB operates using its standard
|
5056 |
|
|
mode, writing on the terminal directly. When reentering the TUI
|
5057 |
|
|
mode, control is given back to the curses windows. The screen is
|
5058 |
|
|
then refreshed.
|
5059 |
|
|
|
5060 |
|
|
`C-x 1'
|
5061 |
|
|
Use a TUI layout with only one window. The layout will either be
|
5062 |
|
|
`source' or `assembly'. When the TUI mode is not active, it will
|
5063 |
|
|
switch to the TUI mode.
|
5064 |
|
|
|
5065 |
|
|
Think of this key binding as the Emacs `C-x 1' binding.
|
5066 |
|
|
|
5067 |
|
|
`C-x 2'
|
5068 |
|
|
Use a TUI layout with at least two windows. When the current
|
5069 |
|
|
layout already has two windows, the next layout with two windows
|
5070 |
|
|
is used. When a new layout is chosen, one window will always be
|
5071 |
|
|
common to the previous layout and the new one.
|
5072 |
|
|
|
5073 |
|
|
Think of it as the Emacs `C-x 2' binding.
|
5074 |
|
|
|
5075 |
|
|
`C-x o'
|
5076 |
|
|
Change the active window. The TUI associates several key bindings
|
5077 |
|
|
(like scrolling and arrow keys) with the active window. This
|
5078 |
|
|
command gives the focus to the next TUI window.
|
5079 |
|
|
|
5080 |
|
|
Think of it as the Emacs `C-x o' binding.
|
5081 |
|
|
|
5082 |
|
|
`C-x s'
|
5083 |
|
|
Switch in and out of the TUI SingleKey mode that binds single keys
|
5084 |
|
|
to GDB commands (*note TUI Single Key Mode::).
|
5085 |
|
|
|
5086 |
|
|
The following key bindings only work in the TUI mode:
|
5087 |
|
|
|
5088 |
|
|
|
5089 |
|
|
Scroll the active window one page up.
|
5090 |
|
|
|
5091 |
|
|
|
5092 |
|
|
Scroll the active window one page down.
|
5093 |
|
|
|
5094 |
|
|
|
5095 |
|
|
Scroll the active window one line up.
|
5096 |
|
|
|
5097 |
|
|
|
5098 |
|
|
Scroll the active window one line down.
|
5099 |
|
|
|
5100 |
|
|
|
5101 |
|
|
Scroll the active window one column left.
|
5102 |
|
|
|
5103 |
|
|
|
5104 |
|
|
Scroll the active window one column right.
|
5105 |
|
|
|
5106 |
|
|
`C-L'
|
5107 |
|
|
Refresh the screen.
|
5108 |
|
|
|
5109 |
|
|
Because the arrow keys scroll the active window in the TUI mode, they
|
5110 |
|
|
are not available for their normal use by readline unless the command
|
5111 |
|
|
window has the focus. When another window is active, you must use
|
5112 |
|
|
other readline key bindings such as `C-p', `C-n', `C-b' and `C-f' to
|
5113 |
|
|
control the command window.
|
5114 |
|
|
|
5115 |
|
|
|
5116 |
|
|
File: gdb.info, Node: TUI Single Key Mode, Next: TUI Commands, Prev: TUI Keys, Up: TUI
|
5117 |
|
|
|
5118 |
|
|
25.3 TUI Single Key Mode
|
5119 |
|
|
========================
|
5120 |
|
|
|
5121 |
|
|
The TUI also provides a "SingleKey" mode, which binds several
|
5122 |
|
|
frequently used GDB commands to single keys. Type `C-x s' to switch
|
5123 |
|
|
into this mode, where the following key bindings are used:
|
5124 |
|
|
|
5125 |
|
|
`c'
|
5126 |
|
|
continue
|
5127 |
|
|
|
5128 |
|
|
`d'
|
5129 |
|
|
down
|
5130 |
|
|
|
5131 |
|
|
`f'
|
5132 |
|
|
finish
|
5133 |
|
|
|
5134 |
|
|
`n'
|
5135 |
|
|
next
|
5136 |
|
|
|
5137 |
|
|
`q'
|
5138 |
|
|
exit the SingleKey mode.
|
5139 |
|
|
|
5140 |
|
|
`r'
|
5141 |
|
|
run
|
5142 |
|
|
|
5143 |
|
|
`s'
|
5144 |
|
|
step
|
5145 |
|
|
|
5146 |
|
|
`u'
|
5147 |
|
|
up
|
5148 |
|
|
|
5149 |
|
|
`v'
|
5150 |
|
|
info locals
|
5151 |
|
|
|
5152 |
|
|
`w'
|
5153 |
|
|
where
|
5154 |
|
|
|
5155 |
|
|
Other keys temporarily switch to the GDB command prompt. The key
|
5156 |
|
|
that was pressed is inserted in the editing buffer so that it is
|
5157 |
|
|
possible to type most GDB commands without interaction with the TUI
|
5158 |
|
|
SingleKey mode. Once the command is entered the TUI SingleKey mode is
|
5159 |
|
|
restored. The only way to permanently leave this mode is by typing `q'
|
5160 |
|
|
or `C-x s'.
|
5161 |
|
|
|
5162 |
|
|
|
5163 |
|
|
File: gdb.info, Node: TUI Commands, Next: TUI Configuration, Prev: TUI Single Key Mode, Up: TUI
|
5164 |
|
|
|
5165 |
|
|
25.4 TUI-specific Commands
|
5166 |
|
|
==========================
|
5167 |
|
|
|
5168 |
|
|
The TUI has specific commands to control the text windows. These
|
5169 |
|
|
commands are always available, even when GDB is not in the TUI mode.
|
5170 |
|
|
When GDB is in the standard mode, most of these commands will
|
5171 |
|
|
automatically switch to the TUI mode.
|
5172 |
|
|
|
5173 |
|
|
Note that if GDB's `stdout' is not connected to a terminal, or GDB
|
5174 |
|
|
has been started with the machine interface interpreter (*note The
|
5175 |
|
|
GDB/MI Interface: GDB/MI.), most of these commands will fail with an
|
5176 |
|
|
error, because it would not be possible or desirable to enable curses
|
5177 |
|
|
window management.
|
5178 |
|
|
|
5179 |
|
|
`info win'
|
5180 |
|
|
List and give the size of all displayed windows.
|
5181 |
|
|
|
5182 |
|
|
`layout next'
|
5183 |
|
|
Display the next layout.
|
5184 |
|
|
|
5185 |
|
|
`layout prev'
|
5186 |
|
|
Display the previous layout.
|
5187 |
|
|
|
5188 |
|
|
`layout src'
|
5189 |
|
|
Display the source window only.
|
5190 |
|
|
|
5191 |
|
|
`layout asm'
|
5192 |
|
|
Display the assembly window only.
|
5193 |
|
|
|
5194 |
|
|
`layout split'
|
5195 |
|
|
Display the source and assembly window.
|
5196 |
|
|
|
5197 |
|
|
`layout regs'
|
5198 |
|
|
Display the register window together with the source or assembly
|
5199 |
|
|
window.
|
5200 |
|
|
|
5201 |
|
|
`focus next'
|
5202 |
|
|
Make the next window active for scrolling.
|
5203 |
|
|
|
5204 |
|
|
`focus prev'
|
5205 |
|
|
Make the previous window active for scrolling.
|
5206 |
|
|
|
5207 |
|
|
`focus src'
|
5208 |
|
|
Make the source window active for scrolling.
|
5209 |
|
|
|
5210 |
|
|
`focus asm'
|
5211 |
|
|
Make the assembly window active for scrolling.
|
5212 |
|
|
|
5213 |
|
|
`focus regs'
|
5214 |
|
|
Make the register window active for scrolling.
|
5215 |
|
|
|
5216 |
|
|
`focus cmd'
|
5217 |
|
|
Make the command window active for scrolling.
|
5218 |
|
|
|
5219 |
|
|
`refresh'
|
5220 |
|
|
Refresh the screen. This is similar to typing `C-L'.
|
5221 |
|
|
|
5222 |
|
|
`tui reg float'
|
5223 |
|
|
Show the floating point registers in the register window.
|
5224 |
|
|
|
5225 |
|
|
`tui reg general'
|
5226 |
|
|
Show the general registers in the register window.
|
5227 |
|
|
|
5228 |
|
|
`tui reg next'
|
5229 |
|
|
Show the next register group. The list of register groups as well
|
5230 |
|
|
as their order is target specific. The predefined register groups
|
5231 |
|
|
are the following: `general', `float', `system', `vector', `all',
|
5232 |
|
|
`save', `restore'.
|
5233 |
|
|
|
5234 |
|
|
`tui reg system'
|
5235 |
|
|
Show the system registers in the register window.
|
5236 |
|
|
|
5237 |
|
|
`update'
|
5238 |
|
|
Update the source window and the current execution point.
|
5239 |
|
|
|
5240 |
|
|
`winheight NAME +COUNT'
|
5241 |
|
|
`winheight NAME -COUNT'
|
5242 |
|
|
Change the height of the window NAME by COUNT lines. Positive
|
5243 |
|
|
counts increase the height, while negative counts decrease it.
|
5244 |
|
|
|
5245 |
|
|
`tabset NCHARS'
|
5246 |
|
|
Set the width of tab stops to be NCHARS characters.
|
5247 |
|
|
|
5248 |
|
|
|
5249 |
|
|
File: gdb.info, Node: TUI Configuration, Prev: TUI Commands, Up: TUI
|
5250 |
|
|
|
5251 |
|
|
25.5 TUI Configuration Variables
|
5252 |
|
|
================================
|
5253 |
|
|
|
5254 |
|
|
Several configuration variables control the appearance of TUI windows.
|
5255 |
|
|
|
5256 |
|
|
`set tui border-kind KIND'
|
5257 |
|
|
Select the border appearance for the source, assembly and register
|
5258 |
|
|
windows. The possible values are the following:
|
5259 |
|
|
`space'
|
5260 |
|
|
Use a space character to draw the border.
|
5261 |
|
|
|
5262 |
|
|
`ascii'
|
5263 |
|
|
Use ASCII characters `+', `-' and `|' to draw the border.
|
5264 |
|
|
|
5265 |
|
|
`acs'
|
5266 |
|
|
Use the Alternate Character Set to draw the border. The
|
5267 |
|
|
border is drawn using character line graphics if the terminal
|
5268 |
|
|
supports them.
|
5269 |
|
|
|
5270 |
|
|
`set tui border-mode MODE'
|
5271 |
|
|
`set tui active-border-mode MODE'
|
5272 |
|
|
Select the display attributes for the borders of the inactive
|
5273 |
|
|
windows or the active window. The MODE can be one of the
|
5274 |
|
|
following:
|
5275 |
|
|
`normal'
|
5276 |
|
|
Use normal attributes to display the border.
|
5277 |
|
|
|
5278 |
|
|
`standout'
|
5279 |
|
|
Use standout mode.
|
5280 |
|
|
|
5281 |
|
|
`reverse'
|
5282 |
|
|
Use reverse video mode.
|
5283 |
|
|
|
5284 |
|
|
`half'
|
5285 |
|
|
Use half bright mode.
|
5286 |
|
|
|
5287 |
|
|
`half-standout'
|
5288 |
|
|
Use half bright and standout mode.
|
5289 |
|
|
|
5290 |
|
|
`bold'
|
5291 |
|
|
Use extra bright or bold mode.
|
5292 |
|
|
|
5293 |
|
|
`bold-standout'
|
5294 |
|
|
Use extra bright or bold and standout mode.
|
5295 |
|
|
|
5296 |
|
|
|
5297 |
|
|
File: gdb.info, Node: Emacs, Next: GDB/MI, Prev: TUI, Up: Top
|
5298 |
|
|
|
5299 |
|
|
26 Using GDB under GNU Emacs
|
5300 |
|
|
****************************
|
5301 |
|
|
|
5302 |
|
|
A special interface allows you to use GNU Emacs to view (and edit) the
|
5303 |
|
|
source files for the program you are debugging with GDB.
|
5304 |
|
|
|
5305 |
|
|
To use this interface, use the command `M-x gdb' in Emacs. Give the
|
5306 |
|
|
executable file you want to debug as an argument. This command starts
|
5307 |
|
|
GDB as a subprocess of Emacs, with input and output through a newly
|
5308 |
|
|
created Emacs buffer.
|
5309 |
|
|
|
5310 |
|
|
Running GDB under Emacs can be just like running GDB normally except
|
5311 |
|
|
for two things:
|
5312 |
|
|
|
5313 |
|
|
* All "terminal" input and output goes through an Emacs buffer,
|
5314 |
|
|
called the GUD buffer.
|
5315 |
|
|
|
5316 |
|
|
This applies both to GDB commands and their output, and to the
|
5317 |
|
|
input and output done by the program you are debugging.
|
5318 |
|
|
|
5319 |
|
|
This is useful because it means that you can copy the text of
|
5320 |
|
|
previous commands and input them again; you can even use parts of
|
5321 |
|
|
the output in this way.
|
5322 |
|
|
|
5323 |
|
|
All the facilities of Emacs' Shell mode are available for
|
5324 |
|
|
interacting with your program. In particular, you can send
|
5325 |
|
|
signals the usual way--for example, `C-c C-c' for an interrupt,
|
5326 |
|
|
`C-c C-z' for a stop.
|
5327 |
|
|
|
5328 |
|
|
* GDB displays source code through Emacs.
|
5329 |
|
|
|
5330 |
|
|
Each time GDB displays a stack frame, Emacs automatically finds the
|
5331 |
|
|
source file for that frame and puts an arrow (`=>') at the left
|
5332 |
|
|
margin of the current line. Emacs uses a separate buffer for
|
5333 |
|
|
source display, and splits the screen to show both your GDB session
|
5334 |
|
|
and the source.
|
5335 |
|
|
|
5336 |
|
|
Explicit GDB `list' or search commands still produce output as
|
5337 |
|
|
usual, but you probably have no reason to use them from Emacs.
|
5338 |
|
|
|
5339 |
|
|
We call this "text command mode". Emacs 22.1, and later, also uses
|
5340 |
|
|
a graphical mode, enabled by default, which provides further buffers
|
5341 |
|
|
that can control the execution and describe the state of your program.
|
5342 |
|
|
*Note GDB Graphical Interface: (Emacs)GDB Graphical Interface.
|
5343 |
|
|
|
5344 |
|
|
If you specify an absolute file name when prompted for the `M-x gdb'
|
5345 |
|
|
argument, then Emacs sets your current working directory to where your
|
5346 |
|
|
program resides. If you only specify the file name, then Emacs sets
|
5347 |
|
|
your current working directory to to the directory associated with the
|
5348 |
|
|
previous buffer. In this case, GDB may find your program by searching
|
5349 |
|
|
your environment's `PATH' variable, but on some operating systems it
|
5350 |
|
|
might not find the source. So, although the GDB input and output
|
5351 |
|
|
session proceeds normally, the auxiliary buffer does not display the
|
5352 |
|
|
current source and line of execution.
|
5353 |
|
|
|
5354 |
|
|
The initial working directory of GDB is printed on the top line of
|
5355 |
|
|
the GUD buffer and this serves as a default for the commands that
|
5356 |
|
|
specify files for GDB to operate on. *Note Commands to Specify Files:
|
5357 |
|
|
Files.
|
5358 |
|
|
|
5359 |
|
|
By default, `M-x gdb' calls the program called `gdb'. If you need
|
5360 |
|
|
to call GDB by a different name (for example, if you keep several
|
5361 |
|
|
configurations around, with different names) you can customize the
|
5362 |
|
|
Emacs variable `gud-gdb-command-name' to run the one you want.
|
5363 |
|
|
|
5364 |
|
|
In the GUD buffer, you can use these special Emacs commands in
|
5365 |
|
|
addition to the standard Shell mode commands:
|
5366 |
|
|
|
5367 |
|
|
`C-h m'
|
5368 |
|
|
Describe the features of Emacs' GUD Mode.
|
5369 |
|
|
|
5370 |
|
|
`C-c C-s'
|
5371 |
|
|
Execute to another source line, like the GDB `step' command; also
|
5372 |
|
|
update the display window to show the current file and location.
|
5373 |
|
|
|
5374 |
|
|
`C-c C-n'
|
5375 |
|
|
Execute to next source line in this function, skipping all function
|
5376 |
|
|
calls, like the GDB `next' command. Then update the display window
|
5377 |
|
|
to show the current file and location.
|
5378 |
|
|
|
5379 |
|
|
`C-c C-i'
|
5380 |
|
|
Execute one instruction, like the GDB `stepi' command; update
|
5381 |
|
|
display window accordingly.
|
5382 |
|
|
|
5383 |
|
|
`C-c C-f'
|
5384 |
|
|
Execute until exit from the selected stack frame, like the GDB
|
5385 |
|
|
`finish' command.
|
5386 |
|
|
|
5387 |
|
|
`C-c C-r'
|
5388 |
|
|
Continue execution of your program, like the GDB `continue'
|
5389 |
|
|
command.
|
5390 |
|
|
|
5391 |
|
|
`C-c <'
|
5392 |
|
|
Go up the number of frames indicated by the numeric argument
|
5393 |
|
|
(*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'
|
5394 |
|
|
command.
|
5395 |
|
|
|
5396 |
|
|
`C-c >'
|
5397 |
|
|
Go down the number of frames indicated by the numeric argument,
|
5398 |
|
|
like the GDB `down' command.
|
5399 |
|
|
|
5400 |
|
|
In any source file, the Emacs command `C-x ' (`gud-break')
|
5401 |
|
|
tells GDB to set a breakpoint on the source line point is on.
|
5402 |
|
|
|
5403 |
|
|
In text command mode, if you type `M-x speedbar', Emacs displays a
|
5404 |
|
|
separate frame which shows a backtrace when the GUD buffer is current.
|
5405 |
|
|
Move point to any frame in the stack and type to make it become
|
5406 |
|
|
the current frame and display the associated source in the source
|
5407 |
|
|
buffer. Alternatively, click `Mouse-2' to make the selected frame
|
5408 |
|
|
become the current one. In graphical mode, the speedbar displays watch
|
5409 |
|
|
expressions.
|
5410 |
|
|
|
5411 |
|
|
If you accidentally delete the source-display buffer, an easy way to
|
5412 |
|
|
get it back is to type the command `f' in the GDB buffer, to request a
|
5413 |
|
|
frame display; when you run under Emacs, this recreates the source
|
5414 |
|
|
buffer if necessary to show you the context of the current frame.
|
5415 |
|
|
|
5416 |
|
|
The source files displayed in Emacs are in ordinary Emacs buffers
|
5417 |
|
|
which are visiting the source files in the usual way. You can edit the
|
5418 |
|
|
files with these buffers if you wish; but keep in mind that GDB
|
5419 |
|
|
communicates with Emacs in terms of line numbers. If you add or delete
|
5420 |
|
|
lines from the text, the line numbers that GDB knows cease to
|
5421 |
|
|
correspond properly with the code.
|
5422 |
|
|
|
5423 |
|
|
A more detailed description of Emacs' interaction with GDB is given
|
5424 |
|
|
in the Emacs manual (*note Debuggers: (Emacs)Debuggers.).
|
5425 |
|
|
|
5426 |
|
|
|
5427 |
|
|
File: gdb.info, Node: GDB/MI, Next: Annotations, Prev: Emacs, Up: Top
|
5428 |
|
|
|
5429 |
|
|
27 The GDB/MI Interface
|
5430 |
|
|
***********************
|
5431 |
|
|
|
5432 |
|
|
Function and Purpose
|
5433 |
|
|
====================
|
5434 |
|
|
|
5435 |
|
|
GDB/MI is a line based machine oriented text interface to GDB and is
|
5436 |
|
|
activated by specifying using the `--interpreter' command line option
|
5437 |
|
|
(*note Mode Options::). It is specifically intended to support the
|
5438 |
|
|
development of systems which use the debugger as just one small
|
5439 |
|
|
component of a larger system.
|
5440 |
|
|
|
5441 |
|
|
This chapter is a specification of the GDB/MI interface. It is
|
5442 |
|
|
written in the form of a reference manual.
|
5443 |
|
|
|
5444 |
|
|
Note that GDB/MI is still under construction, so some of the
|
5445 |
|
|
features described below are incomplete and subject to change (*note
|
5446 |
|
|
GDB/MI Development and Front Ends: GDB/MI Development and Front Ends.).
|
5447 |
|
|
|
5448 |
|
|
Notation and Terminology
|
5449 |
|
|
========================
|
5450 |
|
|
|
5451 |
|
|
This chapter uses the following notation:
|
5452 |
|
|
|
5453 |
|
|
* `|' separates two alternatives.
|
5454 |
|
|
|
5455 |
|
|
* `[ SOMETHING ]' indicates that SOMETHING is optional: it may or
|
5456 |
|
|
may not be given.
|
5457 |
|
|
|
5458 |
|
|
* `( GROUP )*' means that GROUP inside the parentheses may repeat
|
5459 |
|
|
zero or more times.
|
5460 |
|
|
|
5461 |
|
|
* `( GROUP )+' means that GROUP inside the parentheses may repeat
|
5462 |
|
|
one or more times.
|
5463 |
|
|
|
5464 |
|
|
* `"STRING"' means a literal STRING.
|
5465 |
|
|
|
5466 |
|
|
* Menu:
|
5467 |
|
|
|
5468 |
|
|
* GDB/MI General Design::
|
5469 |
|
|
* GDB/MI Command Syntax::
|
5470 |
|
|
* GDB/MI Compatibility with CLI::
|
5471 |
|
|
* GDB/MI Development and Front Ends::
|
5472 |
|
|
* GDB/MI Output Records::
|
5473 |
|
|
* GDB/MI Simple Examples::
|
5474 |
|
|
* GDB/MI Command Description Format::
|
5475 |
|
|
* GDB/MI Breakpoint Commands::
|
5476 |
|
|
* GDB/MI Program Context::
|
5477 |
|
|
* GDB/MI Thread Commands::
|
5478 |
|
|
* GDB/MI Program Execution::
|
5479 |
|
|
* GDB/MI Stack Manipulation::
|
5480 |
|
|
* GDB/MI Variable Objects::
|
5481 |
|
|
* GDB/MI Data Manipulation::
|
5482 |
|
|
* GDB/MI Tracepoint Commands::
|
5483 |
|
|
* GDB/MI Symbol Query::
|
5484 |
|
|
* GDB/MI File Commands::
|
5485 |
|
|
* GDB/MI Target Manipulation::
|
5486 |
|
|
* GDB/MI File Transfer Commands::
|
5487 |
|
|
* GDB/MI Miscellaneous Commands::
|
5488 |
|
|
|
5489 |
|
|
|
5490 |
|
|
File: gdb.info, Node: GDB/MI General Design, Next: GDB/MI Command Syntax, Up: GDB/MI
|
5491 |
|
|
|
5492 |
|
|
27.1 GDB/MI General Design
|
5493 |
|
|
==========================
|
5494 |
|
|
|
5495 |
|
|
Interaction of a GDB/MI frontend with GDB involves three
|
5496 |
|
|
parts--commands sent to GDB, responses to those commands and
|
5497 |
|
|
notifications. Each command results in exactly one response,
|
5498 |
|
|
indicating either successful completion of the command, or an error.
|
5499 |
|
|
For the commands that do not resume the target, the response contains
|
5500 |
|
|
the requested information. For the commands that resume the target, the
|
5501 |
|
|
response only indicates whether the target was successfully resumed.
|
5502 |
|
|
Notifications is the mechanism for reporting changes in the state of the
|
5503 |
|
|
target, or in GDB state, that cannot conveniently be associated with a
|
5504 |
|
|
command and reported as part of that command response.
|
5505 |
|
|
|
5506 |
|
|
The important examples of notifications are:
|
5507 |
|
|
* Exec notifications. These are used to report changes in target
|
5508 |
|
|
state--when a target is resumed, or stopped. It would not be
|
5509 |
|
|
feasible to include this information in response of resuming
|
5510 |
|
|
commands, because one resume commands can result in multiple
|
5511 |
|
|
events in different threads. Also, quite some time may pass
|
5512 |
|
|
before any event happens in the target, while a frontend needs to
|
5513 |
|
|
know whether the resuming command itself was successfully executed.
|
5514 |
|
|
|
5515 |
|
|
* Console output, and status notifications. Console output
|
5516 |
|
|
notifications are used to report output of CLI commands, as well as
|
5517 |
|
|
diagnostics for other commands. Status notifications are used to
|
5518 |
|
|
report the progress of a long-running operation. Naturally,
|
5519 |
|
|
including this information in command response would mean no
|
5520 |
|
|
output is produced until the command is finished, which is
|
5521 |
|
|
undesirable.
|
5522 |
|
|
|
5523 |
|
|
* General notifications. Commands may have various side effects on
|
5524 |
|
|
the GDB or target state beyond their official purpose. For
|
5525 |
|
|
example, a command may change the selected thread. Although such
|
5526 |
|
|
changes can be included in command response, using notification
|
5527 |
|
|
allows for more orthogonal frontend design.
|
5528 |
|
|
|
5529 |
|
|
|
5530 |
|
|
There's no guarantee that whenever an MI command reports an error,
|
5531 |
|
|
GDB or the target are in any specific state, and especially, the state
|
5532 |
|
|
is not reverted to the state before the MI command was processed.
|
5533 |
|
|
Therefore, whenever an MI command results in an error, we recommend
|
5534 |
|
|
that the frontend refreshes all the information shown in the user
|
5535 |
|
|
interface.
|
5536 |
|
|
|
5537 |
|
|
* Menu:
|
5538 |
|
|
|
5539 |
|
|
* Context management::
|
5540 |
|
|
* Asynchronous and non-stop modes::
|
5541 |
|
|
* Thread groups::
|
5542 |
|
|
|
5543 |
|
|
|
5544 |
|
|
File: gdb.info, Node: Context management, Next: Asynchronous and non-stop modes, Up: GDB/MI General Design
|
5545 |
|
|
|
5546 |
|
|
27.1.1 Context management
|
5547 |
|
|
-------------------------
|
5548 |
|
|
|
5549 |
|
|
In most cases when GDB accesses the target, this access is done in
|
5550 |
|
|
context of a specific thread and frame (*note Frames::). Often, even
|
5551 |
|
|
when accessing global data, the target requires that a thread be
|
5552 |
|
|
specified. The CLI interface maintains the selected thread and frame,
|
5553 |
|
|
and supplies them to target on each command. This is convenient,
|
5554 |
|
|
because a command line user would not want to specify that information
|
5555 |
|
|
explicitly on each command, and because user interacts with GDB via a
|
5556 |
|
|
single terminal, so no confusion is possible as to what thread and
|
5557 |
|
|
frame are the current ones.
|
5558 |
|
|
|
5559 |
|
|
In the case of MI, the concept of selected thread and frame is less
|
5560 |
|
|
useful. First, a frontend can easily remember this information itself.
|
5561 |
|
|
Second, a graphical frontend can have more than one window, each one
|
5562 |
|
|
used for debugging a different thread, and the frontend might want to
|
5563 |
|
|
access additional threads for internal purposes. This increases the
|
5564 |
|
|
risk that by relying on implicitly selected thread, the frontend may be
|
5565 |
|
|
operating on a wrong one. Therefore, each MI command should explicitly
|
5566 |
|
|
specify which thread and frame to operate on. To make it possible,
|
5567 |
|
|
each MI command accepts the `--thread' and `--frame' options, the value
|
5568 |
|
|
to each is GDB identifier for thread and frame to operate on.
|
5569 |
|
|
|
5570 |
|
|
Usually, each top-level window in a frontend allows the user to
|
5571 |
|
|
select a thread and a frame, and remembers the user selection for
|
5572 |
|
|
further operations. However, in some cases GDB may suggest that the
|
5573 |
|
|
current thread be changed. For example, when stopping on a breakpoint
|
5574 |
|
|
it is reasonable to switch to the thread where breakpoint is hit. For
|
5575 |
|
|
another example, if the user issues the CLI `thread' command via the
|
5576 |
|
|
frontend, it is desirable to change the frontend's selected thread to
|
5577 |
|
|
the one specified by user. GDB communicates the suggestion to change
|
5578 |
|
|
current thread using the `=thread-selected' notification. No such
|
5579 |
|
|
notification is available for the selected frame at the moment.
|
5580 |
|
|
|
5581 |
|
|
Note that historically, MI shares the selected thread with CLI, so
|
5582 |
|
|
frontends used the `-thread-select' to execute commands in the right
|
5583 |
|
|
context. However, getting this to work right is cumbersome. The
|
5584 |
|
|
simplest way is for frontend to emit `-thread-select' command before
|
5585 |
|
|
every command. This doubles the number of commands that need to be
|
5586 |
|
|
sent. The alternative approach is to suppress `-thread-select' if the
|
5587 |
|
|
selected thread in GDB is supposed to be identical to the thread the
|
5588 |
|
|
frontend wants to operate on. However, getting this optimization right
|
5589 |
|
|
can be tricky. In particular, if the frontend sends several commands
|
5590 |
|
|
to GDB, and one of the commands changes the selected thread, then the
|
5591 |
|
|
behaviour of subsequent commands will change. So, a frontend should
|
5592 |
|
|
either wait for response from such problematic commands, or explicitly
|
5593 |
|
|
add `-thread-select' for all subsequent commands. No frontend is known
|
5594 |
|
|
to do this exactly right, so it is suggested to just always pass the
|
5595 |
|
|
`--thread' and `--frame' options.
|
5596 |
|
|
|
5597 |
|
|
|
5598 |
|
|
File: gdb.info, Node: Asynchronous and non-stop modes, Next: Thread groups, Prev: Context management, Up: GDB/MI General Design
|
5599 |
|
|
|
5600 |
|
|
27.1.2 Asynchronous command execution and non-stop mode
|
5601 |
|
|
-------------------------------------------------------
|
5602 |
|
|
|
5603 |
|
|
On some targets, GDB is capable of processing MI commands even while
|
5604 |
|
|
the target is running. This is called "asynchronous command execution"
|
5605 |
|
|
(*note Background Execution::). The frontend may specify a preferrence
|
5606 |
|
|
for asynchronous execution using the `-gdb-set target-async 1' command,
|
5607 |
|
|
which should be emitted before either running the executable or
|
5608 |
|
|
attaching to the target. After the frontend has started the executable
|
5609 |
|
|
or attached to the target, it can find if asynchronous execution is
|
5610 |
|
|
enabled using the `-list-target-features' command.
|
5611 |
|
|
|
5612 |
|
|
Even if GDB can accept a command while target is running, many
|
5613 |
|
|
commands that access the target do not work when the target is running.
|
5614 |
|
|
Therefore, asynchronous command execution is most useful when combined
|
5615 |
|
|
with non-stop mode (*note Non-Stop Mode::). Then, it is possible to
|
5616 |
|
|
examine the state of one thread, while other threads are running.
|
5617 |
|
|
|
5618 |
|
|
When a given thread is running, MI commands that try to access the
|
5619 |
|
|
target in the context of that thread may not work, or may work only on
|
5620 |
|
|
some targets. In particular, commands that try to operate on thread's
|
5621 |
|
|
stack will not work, on any target. Commands that read memory, or
|
5622 |
|
|
modify breakpoints, may work or not work, depending on the target. Note
|
5623 |
|
|
that even commands that operate on global state, such as `print',
|
5624 |
|
|
`set', and breakpoint commands, still access the target in the context
|
5625 |
|
|
of a specific thread, so frontend should try to find a stopped thread
|
5626 |
|
|
and perform the operation on that thread (using the `--thread' option).
|
5627 |
|
|
|
5628 |
|
|
Which commands will work in the context of a running thread is
|
5629 |
|
|
highly target dependent. However, the two commands `-exec-interrupt',
|
5630 |
|
|
to stop a thread, and `-thread-info', to find the state of a thread,
|
5631 |
|
|
will always work.
|
5632 |
|
|
|
5633 |
|
|
|
5634 |
|
|
File: gdb.info, Node: Thread groups, Prev: Asynchronous and non-stop modes, Up: GDB/MI General Design
|
5635 |
|
|
|
5636 |
|
|
27.1.3 Thread groups
|
5637 |
|
|
--------------------
|
5638 |
|
|
|
5639 |
|
|
GDB may be used to debug several processes at the same time. On some
|
5640 |
|
|
platfroms, GDB may support debugging of several hardware systems, each
|
5641 |
|
|
one having several cores with several different processes running on
|
5642 |
|
|
each core. This section describes the MI mechanism to support such
|
5643 |
|
|
debugging scenarios.
|
5644 |
|
|
|
5645 |
|
|
The key observation is that regardless of the structure of the
|
5646 |
|
|
target, MI can have a global list of threads, because most commands that
|
5647 |
|
|
accept the `--thread' option do not need to know what process that
|
5648 |
|
|
thread belongs to. Therefore, it is not necessary to introduce neither
|
5649 |
|
|
additional `--process' option, nor an notion of the current process in
|
5650 |
|
|
the MI interface. The only strictly new feature that is required is
|
5651 |
|
|
the ability to find how the threads are grouped into processes.
|
5652 |
|
|
|
5653 |
|
|
To allow the user to discover such grouping, and to support arbitrary
|
5654 |
|
|
hierarchy of machines/cores/processes, MI introduces the concept of a
|
5655 |
|
|
"thread group". Thread group is a collection of threads and other
|
5656 |
|
|
thread groups. A thread group always has a string identifier, a type,
|
5657 |
|
|
and may have additional attributes specific to the type. A new
|
5658 |
|
|
command, `-list-thread-groups', returns the list of top-level thread
|
5659 |
|
|
groups, which correspond to processes that GDB is debugging at the
|
5660 |
|
|
moment. By passing an identifier of a thread group to the
|
5661 |
|
|
`-list-thread-groups' command, it is possible to obtain the members of
|
5662 |
|
|
specific thread group.
|
5663 |
|
|
|
5664 |
|
|
To allow the user to easily discover processes, and other objects, he
|
5665 |
|
|
wishes to debug, a concept of "available thread group" is introduced.
|
5666 |
|
|
Available thread group is an thread group that GDB is not debugging,
|
5667 |
|
|
but that can be attached to, using the `-target-attach' command. The
|
5668 |
|
|
list of available top-level thread groups can be obtained using
|
5669 |
|
|
`-list-thread-groups --available'. In general, the content of a thread
|
5670 |
|
|
group may be only retrieved only after attaching to that thread group.
|
5671 |
|
|
|
5672 |
|
|
Thread groups are related to inferiors (*note Inferiors and
|
5673 |
|
|
Programs::). Each inferior corresponds to a thread group of a special
|
5674 |
|
|
type `process', and some additional operations are permitted on such
|
5675 |
|
|
thread groups.
|
5676 |
|
|
|
5677 |
|
|
|
5678 |
|
|
File: gdb.info, Node: GDB/MI Command Syntax, Next: GDB/MI Compatibility with CLI, Prev: GDB/MI General Design, Up: GDB/MI
|
5679 |
|
|
|
5680 |
|
|
27.2 GDB/MI Command Syntax
|
5681 |
|
|
==========================
|
5682 |
|
|
|
5683 |
|
|
* Menu:
|
5684 |
|
|
|
5685 |
|
|
* GDB/MI Input Syntax::
|
5686 |
|
|
* GDB/MI Output Syntax::
|
5687 |
|
|
|
5688 |
|
|
|
5689 |
|
|
File: gdb.info, Node: GDB/MI Input Syntax, Next: GDB/MI Output Syntax, Up: GDB/MI Command Syntax
|
5690 |
|
|
|
5691 |
|
|
27.2.1 GDB/MI Input Syntax
|
5692 |
|
|
--------------------------
|
5693 |
|
|
|
5694 |
|
|
`COMMAND ==>'
|
5695 |
|
|
`CLI-COMMAND | MI-COMMAND'
|
5696 |
|
|
|
5697 |
|
|
`CLI-COMMAND ==>'
|
5698 |
|
|
`[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDB
|
5699 |
|
|
CLI command.
|
5700 |
|
|
|
5701 |
|
|
`MI-COMMAND ==>'
|
5702 |
|
|
`[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " "
|
5703 |
|
|
PARAMETER )* NL'
|
5704 |
|
|
|
5705 |
|
|
`TOKEN ==>'
|
5706 |
|
|
"any sequence of digits"
|
5707 |
|
|
|
5708 |
|
|
`OPTION ==>'
|
5709 |
|
|
`"-" PARAMETER [ " " PARAMETER ]'
|
5710 |
|
|
|
5711 |
|
|
`PARAMETER ==>'
|
5712 |
|
|
`NON-BLANK-SEQUENCE | C-STRING'
|
5713 |
|
|
|
5714 |
|
|
`OPERATION ==>'
|
5715 |
|
|
_any of the operations described in this chapter_
|
5716 |
|
|
|
5717 |
|
|
`NON-BLANK-SEQUENCE ==>'
|
5718 |
|
|
_anything, provided it doesn't contain special characters such as
|
5719 |
|
|
"-", NL, """ and of course " "_
|
5720 |
|
|
|
5721 |
|
|
`C-STRING ==>'
|
5722 |
|
|
`""" SEVEN-BIT-ISO-C-STRING-CONTENT """'
|
5723 |
|
|
|
5724 |
|
|
`NL ==>'
|
5725 |
|
|
`CR | CR-LF'
|
5726 |
|
|
|
5727 |
|
|
Notes:
|
5728 |
|
|
|
5729 |
|
|
* The CLI commands are still handled by the MI interpreter; their
|
5730 |
|
|
output is described below.
|
5731 |
|
|
|
5732 |
|
|
* The `TOKEN', when present, is passed back when the command
|
5733 |
|
|
finishes.
|
5734 |
|
|
|
5735 |
|
|
* Some MI commands accept optional arguments as part of the parameter
|
5736 |
|
|
list. Each option is identified by a leading `-' (dash) and may be
|
5737 |
|
|
followed by an optional argument parameter. Options occur first
|
5738 |
|
|
in the parameter list and can be delimited from normal parameters
|
5739 |
|
|
using `--' (this is useful when some parameters begin with a dash).
|
5740 |
|
|
|
5741 |
|
|
Pragmatics:
|
5742 |
|
|
|
5743 |
|
|
* We want easy access to the existing CLI syntax (for debugging).
|
5744 |
|
|
|
5745 |
|
|
* We want it to be easy to spot a MI operation.
|
5746 |
|
|
|
5747 |
|
|
|
5748 |
|
|
File: gdb.info, Node: GDB/MI Output Syntax, Prev: GDB/MI Input Syntax, Up: GDB/MI Command Syntax
|
5749 |
|
|
|
5750 |
|
|
27.2.2 GDB/MI Output Syntax
|
5751 |
|
|
---------------------------
|
5752 |
|
|
|
5753 |
|
|
The output from GDB/MI consists of zero or more out-of-band records
|
5754 |
|
|
followed, optionally, by a single result record. This result record is
|
5755 |
|
|
for the most recent command. The sequence of output records is
|
5756 |
|
|
terminated by `(gdb)'.
|
5757 |
|
|
|
5758 |
|
|
If an input command was prefixed with a `TOKEN' then the
|
5759 |
|
|
corresponding output for that command will also be prefixed by that same
|
5760 |
|
|
TOKEN.
|
5761 |
|
|
|
5762 |
|
|
`OUTPUT ==>'
|
5763 |
|
|
`( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'
|
5764 |
|
|
|
5765 |
|
|
`RESULT-RECORD ==>'
|
5766 |
|
|
` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'
|
5767 |
|
|
|
5768 |
|
|
`OUT-OF-BAND-RECORD ==>'
|
5769 |
|
|
`ASYNC-RECORD | STREAM-RECORD'
|
5770 |
|
|
|
5771 |
|
|
`ASYNC-RECORD ==>'
|
5772 |
|
|
`EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'
|
5773 |
|
|
|
5774 |
|
|
`EXEC-ASYNC-OUTPUT ==>'
|
5775 |
|
|
`[ TOKEN ] "*" ASYNC-OUTPUT'
|
5776 |
|
|
|
5777 |
|
|
`STATUS-ASYNC-OUTPUT ==>'
|
5778 |
|
|
`[ TOKEN ] "+" ASYNC-OUTPUT'
|
5779 |
|
|
|
5780 |
|
|
`NOTIFY-ASYNC-OUTPUT ==>'
|
5781 |
|
|
`[ TOKEN ] "=" ASYNC-OUTPUT'
|
5782 |
|
|
|
5783 |
|
|
`ASYNC-OUTPUT ==>'
|
5784 |
|
|
`ASYNC-CLASS ( "," RESULT )* NL'
|
5785 |
|
|
|
5786 |
|
|
`RESULT-CLASS ==>'
|
5787 |
|
|
`"done" | "running" | "connected" | "error" | "exit"'
|
5788 |
|
|
|
5789 |
|
|
`ASYNC-CLASS ==>'
|
5790 |
|
|
`"stopped" | OTHERS' (where OTHERS will be added depending on the
|
5791 |
|
|
needs--this is still in development).
|
5792 |
|
|
|
5793 |
|
|
`RESULT ==>'
|
5794 |
|
|
` VARIABLE "=" VALUE'
|
5795 |
|
|
|
5796 |
|
|
`VARIABLE ==>'
|
5797 |
|
|
` STRING '
|
5798 |
|
|
|
5799 |
|
|
`VALUE ==>'
|
5800 |
|
|
` CONST | TUPLE | LIST '
|
5801 |
|
|
|
5802 |
|
|
`CONST ==>'
|
5803 |
|
|
`C-STRING'
|
5804 |
|
|
|
5805 |
|
|
`TUPLE ==>'
|
5806 |
|
|
` "{}" | "{" RESULT ( "," RESULT )* "}" '
|
5807 |
|
|
|
5808 |
|
|
`LIST ==>'
|
5809 |
|
|
` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*
|
5810 |
|
|
"]" '
|
5811 |
|
|
|
5812 |
|
|
`STREAM-RECORD ==>'
|
5813 |
|
|
`CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'
|
5814 |
|
|
|
5815 |
|
|
`CONSOLE-STREAM-OUTPUT ==>'
|
5816 |
|
|
`"~" C-STRING'
|
5817 |
|
|
|
5818 |
|
|
`TARGET-STREAM-OUTPUT ==>'
|
5819 |
|
|
`"@" C-STRING'
|
5820 |
|
|
|
5821 |
|
|
`LOG-STREAM-OUTPUT ==>'
|
5822 |
|
|
`"&" C-STRING'
|
5823 |
|
|
|
5824 |
|
|
`NL ==>'
|
5825 |
|
|
`CR | CR-LF'
|
5826 |
|
|
|
5827 |
|
|
`TOKEN ==>'
|
5828 |
|
|
_any sequence of digits_.
|
5829 |
|
|
|
5830 |
|
|
Notes:
|
5831 |
|
|
|
5832 |
|
|
* All output sequences end in a single line containing a period.
|
5833 |
|
|
|
5834 |
|
|
* The `TOKEN' is from the corresponding request. Note that for all
|
5835 |
|
|
async output, while the token is allowed by the grammar and may be
|
5836 |
|
|
output by future versions of GDB for select async output messages,
|
5837 |
|
|
it is generally omitted. Frontends should treat all async output
|
5838 |
|
|
as reporting general changes in the state of the target and there
|
5839 |
|
|
should be no need to associate async output to any prior command.
|
5840 |
|
|
|
5841 |
|
|
* STATUS-ASYNC-OUTPUT contains on-going status information about the
|
5842 |
|
|
progress of a slow operation. It can be discarded. All status
|
5843 |
|
|
output is prefixed by `+'.
|
5844 |
|
|
|
5845 |
|
|
* EXEC-ASYNC-OUTPUT contains asynchronous state change on the target
|
5846 |
|
|
(stopped, started, disappeared). All async output is prefixed by
|
5847 |
|
|
`*'.
|
5848 |
|
|
|
5849 |
|
|
* NOTIFY-ASYNC-OUTPUT contains supplementary information that the
|
5850 |
|
|
client should handle (e.g., a new breakpoint information). All
|
5851 |
|
|
notify output is prefixed by `='.
|
5852 |
|
|
|
5853 |
|
|
* CONSOLE-STREAM-OUTPUT is output that should be displayed as is in
|
5854 |
|
|
the console. It is the textual response to a CLI command. All
|
5855 |
|
|
the console output is prefixed by `~'.
|
5856 |
|
|
|
5857 |
|
|
* TARGET-STREAM-OUTPUT is the output produced by the target program.
|
5858 |
|
|
All the target output is prefixed by `@'.
|
5859 |
|
|
|
5860 |
|
|
* LOG-STREAM-OUTPUT is output text coming from GDB's internals, for
|
5861 |
|
|
instance messages that should be displayed as part of an error
|
5862 |
|
|
log. All the log output is prefixed by `&'.
|
5863 |
|
|
|
5864 |
|
|
* New GDB/MI commands should only output LISTS containing VALUES.
|
5865 |
|
|
|
5866 |
|
|
|
5867 |
|
|
*Note GDB/MI Stream Records: GDB/MI Stream Records, for more details
|
5868 |
|
|
about the various output records.
|
5869 |
|
|
|
5870 |
|
|
|
5871 |
|
|
File: gdb.info, Node: GDB/MI Compatibility with CLI, Next: GDB/MI Development and Front Ends, Prev: GDB/MI Command Syntax, Up: GDB/MI
|
5872 |
|
|
|
5873 |
|
|
27.3 GDB/MI Compatibility with CLI
|
5874 |
|
|
==================================
|
5875 |
|
|
|
5876 |
|
|
For the developers convenience CLI commands can be entered directly,
|
5877 |
|
|
but there may be some unexpected behaviour. For example, commands that
|
5878 |
|
|
query the user will behave as if the user replied yes, breakpoint
|
5879 |
|
|
command lists are not executed and some CLI commands, such as `if',
|
5880 |
|
|
`when' and `define', prompt for further input with `>', which is not
|
5881 |
|
|
valid MI output.
|
5882 |
|
|
|
5883 |
|
|
This feature may be removed at some stage in the future and it is
|
5884 |
|
|
recommended that front ends use the `-interpreter-exec' command (*note
|
5885 |
|
|
-interpreter-exec::).
|
5886 |
|
|
|
5887 |
|
|
|
5888 |
|
|
File: gdb.info, Node: GDB/MI Development and Front Ends, Next: GDB/MI Output Records, Prev: GDB/MI Compatibility with CLI, Up: GDB/MI
|
5889 |
|
|
|
5890 |
|
|
27.4 GDB/MI Development and Front Ends
|
5891 |
|
|
======================================
|
5892 |
|
|
|
5893 |
|
|
The application which takes the MI output and presents the state of the
|
5894 |
|
|
program being debugged to the user is called a "front end".
|
5895 |
|
|
|
5896 |
|
|
Although GDB/MI is still incomplete, it is currently being used by a
|
5897 |
|
|
variety of front ends to GDB. This makes it difficult to introduce new
|
5898 |
|
|
functionality without breaking existing usage. This section tries to
|
5899 |
|
|
minimize the problems by describing how the protocol might change.
|
5900 |
|
|
|
5901 |
|
|
Some changes in MI need not break a carefully designed front end, and
|
5902 |
|
|
for these the MI version will remain unchanged. The following is a
|
5903 |
|
|
list of changes that may occur within one level, so front ends should
|
5904 |
|
|
parse MI output in a way that can handle them:
|
5905 |
|
|
|
5906 |
|
|
* New MI commands may be added.
|
5907 |
|
|
|
5908 |
|
|
* New fields may be added to the output of any MI command.
|
5909 |
|
|
|
5910 |
|
|
* The range of values for fields with specified values, e.g.,
|
5911 |
|
|
`in_scope' (*note -var-update::) may be extended.
|
5912 |
|
|
|
5913 |
|
|
|
5914 |
|
|
If the changes are likely to break front ends, the MI version level
|
5915 |
|
|
will be increased by one. This will allow the front end to parse the
|
5916 |
|
|
output according to the MI version. Apart from mi0, new versions of
|
5917 |
|
|
GDB will not support old versions of MI and it will be the
|
5918 |
|
|
responsibility of the front end to work with the new one.
|
5919 |
|
|
|
5920 |
|
|
The best way to avoid unexpected changes in MI that might break your
|
5921 |
|
|
front end is to make your project known to GDB developers and follow
|
5922 |
|
|
development on and .
|
5923 |
|
|
|
5924 |
|
|
|
5925 |
|
|
File: gdb.info, Node: GDB/MI Output Records, Next: GDB/MI Simple Examples, Prev: GDB/MI Development and Front Ends, Up: GDB/MI
|
5926 |
|
|
|
5927 |
|
|
27.5 GDB/MI Output Records
|
5928 |
|
|
==========================
|
5929 |
|
|
|
5930 |
|
|
* Menu:
|
5931 |
|
|
|
5932 |
|
|
* GDB/MI Result Records::
|
5933 |
|
|
* GDB/MI Stream Records::
|
5934 |
|
|
* GDB/MI Async Records::
|
5935 |
|
|
* GDB/MI Frame Information::
|
5936 |
|
|
* GDB/MI Thread Information::
|
5937 |
|
|
|
5938 |
|
|
|
5939 |
|
|
File: gdb.info, Node: GDB/MI Result Records, Next: GDB/MI Stream Records, Up: GDB/MI Output Records
|
5940 |
|
|
|
5941 |
|
|
27.5.1 GDB/MI Result Records
|
5942 |
|
|
----------------------------
|
5943 |
|
|
|
5944 |
|
|
In addition to a number of out-of-band notifications, the response to a
|
5945 |
|
|
GDB/MI command includes one of the following result indications:
|
5946 |
|
|
|
5947 |
|
|
`"^done" [ "," RESULTS ]'
|
5948 |
|
|
The synchronous operation was successful, `RESULTS' are the return
|
5949 |
|
|
values.
|
5950 |
|
|
|
5951 |
|
|
`"^running"'
|
5952 |
|
|
This result record is equivalent to `^done'. Historically, it was
|
5953 |
|
|
output instead of `^done' if the command has resumed the target.
|
5954 |
|
|
This behaviour is maintained for backward compatibility, but all
|
5955 |
|
|
frontends should treat `^done' and `^running' identically and rely
|
5956 |
|
|
on the `*running' output record to determine which threads are
|
5957 |
|
|
resumed.
|
5958 |
|
|
|
5959 |
|
|
`"^connected"'
|
5960 |
|
|
GDB has connected to a remote target.
|
5961 |
|
|
|
5962 |
|
|
`"^error" "," C-STRING'
|
5963 |
|
|
The operation failed. The `C-STRING' contains the corresponding
|
5964 |
|
|
error message.
|
5965 |
|
|
|
5966 |
|
|
`"^exit"'
|
5967 |
|
|
GDB has terminated.
|
5968 |
|
|
|
5969 |
|
|
|
5970 |
|
|
|
5971 |
|
|
File: gdb.info, Node: GDB/MI Stream Records, Next: GDB/MI Async Records, Prev: GDB/MI Result Records, Up: GDB/MI Output Records
|
5972 |
|
|
|
5973 |
|
|
27.5.2 GDB/MI Stream Records
|
5974 |
|
|
----------------------------
|
5975 |
|
|
|
5976 |
|
|
GDB internally maintains a number of output streams: the console, the
|
5977 |
|
|
target, and the log. The output intended for each of these streams is
|
5978 |
|
|
funneled through the GDB/MI interface using "stream records".
|
5979 |
|
|
|
5980 |
|
|
Each stream record begins with a unique "prefix character" which
|
5981 |
|
|
identifies its stream (*note GDB/MI Output Syntax: GDB/MI Output
|
5982 |
|
|
Syntax.). In addition to the prefix, each stream record contains a
|
5983 |
|
|
`STRING-OUTPUT'. This is either raw text (with an implicit new line)
|
5984 |
|
|
or a quoted C string (which does not contain an implicit newline).
|
5985 |
|
|
|
5986 |
|
|
`"~" STRING-OUTPUT'
|
5987 |
|
|
The console output stream contains text that should be displayed
|
5988 |
|
|
in the CLI console window. It contains the textual responses to
|
5989 |
|
|
CLI commands.
|
5990 |
|
|
|
5991 |
|
|
`"@" STRING-OUTPUT'
|
5992 |
|
|
The target output stream contains any textual output from the
|
5993 |
|
|
running target. This is only present when GDB's event loop is
|
5994 |
|
|
truly asynchronous, which is currently only the case for remote
|
5995 |
|
|
targets.
|
5996 |
|
|
|
5997 |
|
|
`"&" STRING-OUTPUT'
|
5998 |
|
|
The log stream contains debugging messages being produced by GDB's
|
5999 |
|
|
internals.
|
6000 |
|
|
|
6001 |
|
|
|
6002 |
|
|
File: gdb.info, Node: GDB/MI Async Records, Next: GDB/MI Frame Information, Prev: GDB/MI Stream Records, Up: GDB/MI Output Records
|
6003 |
|
|
|
6004 |
|
|
27.5.3 GDB/MI Async Records
|
6005 |
|
|
---------------------------
|
6006 |
|
|
|
6007 |
|
|
"Async" records are used to notify the GDB/MI client of additional
|
6008 |
|
|
changes that have occurred. Those changes can either be a consequence
|
6009 |
|
|
of GDB/MI commands (e.g., a breakpoint modified) or a result of target
|
6010 |
|
|
activity (e.g., target stopped).
|
6011 |
|
|
|
6012 |
|
|
The following is the list of possible async records:
|
6013 |
|
|
|
6014 |
|
|
`*running,thread-id="THREAD"'
|
6015 |
|
|
The target is now running. The THREAD field tells which specific
|
6016 |
|
|
thread is now running, and can be `all' if all threads are
|
6017 |
|
|
running. The frontend should assume that no interaction with a
|
6018 |
|
|
running thread is possible after this notification is produced.
|
6019 |
|
|
The frontend should not assume that this notification is output
|
6020 |
|
|
only once for any command. GDB may emit this notification several
|
6021 |
|
|
times, either for different threads, because it cannot resume all
|
6022 |
|
|
threads together, or even for a single thread, if the thread must
|
6023 |
|
|
be stepped though some code before letting it run freely.
|
6024 |
|
|
|
6025 |
|
|
`*stopped,reason="REASON",thread-id="ID",stopped-threads="STOPPED",core="CORE"'
|
6026 |
|
|
The target has stopped. The REASON field can have one of the
|
6027 |
|
|
following values:
|
6028 |
|
|
|
6029 |
|
|
`breakpoint-hit'
|
6030 |
|
|
A breakpoint was reached.
|
6031 |
|
|
|
6032 |
|
|
`watchpoint-trigger'
|
6033 |
|
|
A watchpoint was triggered.
|
6034 |
|
|
|
6035 |
|
|
`read-watchpoint-trigger'
|
6036 |
|
|
A read watchpoint was triggered.
|
6037 |
|
|
|
6038 |
|
|
`access-watchpoint-trigger'
|
6039 |
|
|
An access watchpoint was triggered.
|
6040 |
|
|
|
6041 |
|
|
`function-finished'
|
6042 |
|
|
An -exec-finish or similar CLI command was accomplished.
|
6043 |
|
|
|
6044 |
|
|
`location-reached'
|
6045 |
|
|
An -exec-until or similar CLI command was accomplished.
|
6046 |
|
|
|
6047 |
|
|
`watchpoint-scope'
|
6048 |
|
|
A watchpoint has gone out of scope.
|
6049 |
|
|
|
6050 |
|
|
`end-stepping-range'
|
6051 |
|
|
An -exec-next, -exec-next-instruction, -exec-step,
|
6052 |
|
|
-exec-step-instruction or similar CLI command was
|
6053 |
|
|
accomplished.
|
6054 |
|
|
|
6055 |
|
|
`exited-signalled'
|
6056 |
|
|
The inferior exited because of a signal.
|
6057 |
|
|
|
6058 |
|
|
`exited'
|
6059 |
|
|
The inferior exited.
|
6060 |
|
|
|
6061 |
|
|
`exited-normally'
|
6062 |
|
|
The inferior exited normally.
|
6063 |
|
|
|
6064 |
|
|
`signal-received'
|
6065 |
|
|
A signal was received by the inferior.
|
6066 |
|
|
|
6067 |
|
|
The ID field identifies the thread that directly caused the stop -
|
6068 |
|
|
for example by hitting a breakpoint. Depending on whether all-stop
|
6069 |
|
|
mode is in effect (*note All-Stop Mode::), GDB may either stop all
|
6070 |
|
|
threads, or only the thread that directly triggered the stop. If
|
6071 |
|
|
all threads are stopped, the STOPPED field will have the value of
|
6072 |
|
|
`"all"'. Otherwise, the value of the STOPPED field will be a list
|
6073 |
|
|
of thread identifiers. Presently, this list will always include a
|
6074 |
|
|
single thread, but frontend should be prepared to see several
|
6075 |
|
|
threads in the list. The CORE field reports the processor core on
|
6076 |
|
|
which the stop event has happened. This field may be absent if
|
6077 |
|
|
such information is not available.
|
6078 |
|
|
|
6079 |
|
|
`=thread-group-added,id="ID"'
|
6080 |
|
|
`=thread-group-removed,id="ID"'
|
6081 |
|
|
A thread group was either added or removed. The ID field contains
|
6082 |
|
|
the GDB identifier of the thread group. When a thread group is
|
6083 |
|
|
added, it generally might not be associated with a running
|
6084 |
|
|
process. When a thread group is removed, its id becomes invalid
|
6085 |
|
|
and cannot be used in any way.
|
6086 |
|
|
|
6087 |
|
|
`=thread-group-started,id="ID",pid="PID"'
|
6088 |
|
|
A thread group became associated with a running program, either
|
6089 |
|
|
because the program was just started or the thread group was
|
6090 |
|
|
attached to a program. The ID field contains the GDB identifier
|
6091 |
|
|
of the thread group. The PID field contains process identifier,
|
6092 |
|
|
specific to the operating system.
|
6093 |
|
|
|
6094 |
|
|
`=thread-group-exited,id="ID"'
|
6095 |
|
|
A thread group is no longer associated with a running program,
|
6096 |
|
|
either because the program has exited, or because it was detached
|
6097 |
|
|
from. The ID field contains the GDB identifier of the thread
|
6098 |
|
|
group.
|
6099 |
|
|
|
6100 |
|
|
`=thread-created,id="ID",group-id="GID"'
|
6101 |
|
|
`=thread-exited,id="ID",group-id="GID"'
|
6102 |
|
|
A thread either was created, or has exited. The ID field contains
|
6103 |
|
|
the GDB identifier of the thread. The GID field identifies the
|
6104 |
|
|
thread group this thread belongs to.
|
6105 |
|
|
|
6106 |
|
|
`=thread-selected,id="ID"'
|
6107 |
|
|
Informs that the selected thread was changed as result of the last
|
6108 |
|
|
command. This notification is not emitted as result of
|
6109 |
|
|
`-thread-select' command but is emitted whenever an MI command
|
6110 |
|
|
that is not documented to change the selected thread actually
|
6111 |
|
|
changes it. In particular, invoking, directly or indirectly (via
|
6112 |
|
|
user-defined command), the CLI `thread' command, will generate
|
6113 |
|
|
this notification.
|
6114 |
|
|
|
6115 |
|
|
We suggest that in response to this notification, front ends
|
6116 |
|
|
highlight the selected thread and cause subsequent commands to
|
6117 |
|
|
apply to that thread.
|
6118 |
|
|
|
6119 |
|
|
`=library-loaded,...'
|
6120 |
|
|
Reports that a new library file was loaded by the program. This
|
6121 |
|
|
notification has 4 fields--ID, TARGET-NAME, HOST-NAME, and
|
6122 |
|
|
SYMBOLS-LOADED. The ID field is an opaque identifier of the
|
6123 |
|
|
library. For remote debugging case, TARGET-NAME and HOST-NAME
|
6124 |
|
|
fields give the name of the library file on the target, and on the
|
6125 |
|
|
host respectively. For native debugging, both those fields have
|
6126 |
|
|
the same value. The SYMBOLS-LOADED field reports if the debug
|
6127 |
|
|
symbols for this library are loaded. The THREAD-GROUP field, if
|
6128 |
|
|
present, specifies the id of the thread group in whose context the
|
6129 |
|
|
library was loaded. If the field is absent, it means the library
|
6130 |
|
|
was loaded in the context of all present thread groups.
|
6131 |
|
|
|
6132 |
|
|
`=library-unloaded,...'
|
6133 |
|
|
Reports that a library was unloaded by the program. This
|
6134 |
|
|
notification has 3 fields--ID, TARGET-NAME and HOST-NAME with the
|
6135 |
|
|
same meaning as for the `=library-loaded' notification. The
|
6136 |
|
|
THREAD-GROUP field, if present, specifies the id of the thread
|
6137 |
|
|
group in whose context the library was unloaded. If the field is
|
6138 |
|
|
absent, it means the library was unloaded in the context of all
|
6139 |
|
|
present thread groups.
|
6140 |
|
|
|
6141 |
|
|
|
6142 |
|
|
|
6143 |
|
|
File: gdb.info, Node: GDB/MI Frame Information, Next: GDB/MI Thread Information, Prev: GDB/MI Async Records, Up: GDB/MI Output Records
|
6144 |
|
|
|
6145 |
|
|
27.5.4 GDB/MI Frame Information
|
6146 |
|
|
-------------------------------
|
6147 |
|
|
|
6148 |
|
|
Response from many MI commands includes an information about stack
|
6149 |
|
|
frame. This information is a tuple that may have the following fields:
|
6150 |
|
|
|
6151 |
|
|
`level'
|
6152 |
|
|
The level of the stack frame. The innermost frame has the level of
|
6153 |
|
|
zero. This field is always present.
|
6154 |
|
|
|
6155 |
|
|
`func'
|
6156 |
|
|
The name of the function corresponding to the frame. This field
|
6157 |
|
|
may be absent if GDB is unable to determine the function name.
|
6158 |
|
|
|
6159 |
|
|
`addr'
|
6160 |
|
|
The code address for the frame. This field is always present.
|
6161 |
|
|
|
6162 |
|
|
`file'
|
6163 |
|
|
The name of the source files that correspond to the frame's code
|
6164 |
|
|
address. This field may be absent.
|
6165 |
|
|
|
6166 |
|
|
`line'
|
6167 |
|
|
The source line corresponding to the frames' code address. This
|
6168 |
|
|
field may be absent.
|
6169 |
|
|
|
6170 |
|
|
`from'
|
6171 |
|
|
The name of the binary file (either executable or shared library)
|
6172 |
|
|
the corresponds to the frame's code address. This field may be
|
6173 |
|
|
absent.
|
6174 |
|
|
|
6175 |
|
|
|
6176 |
|
|
|
6177 |
|
|
File: gdb.info, Node: GDB/MI Thread Information, Prev: GDB/MI Frame Information, Up: GDB/MI Output Records
|
6178 |
|
|
|
6179 |
|
|
27.5.5 GDB/MI Thread Information
|
6180 |
|
|
--------------------------------
|
6181 |
|
|
|
6182 |
|
|
Whenever GDB has to report an information about a thread, it uses a
|
6183 |
|
|
tuple with the following fields:
|
6184 |
|
|
|
6185 |
|
|
`id'
|
6186 |
|
|
The numeric id assigned to the thread by GDB. This field is
|
6187 |
|
|
always present.
|
6188 |
|
|
|
6189 |
|
|
`target-id'
|
6190 |
|
|
Target-specific string identifying the thread. This field is
|
6191 |
|
|
always present.
|
6192 |
|
|
|
6193 |
|
|
`details'
|
6194 |
|
|
Additional information about the thread provided by the target.
|
6195 |
|
|
It is supposed to be human-readable and not interpreted by the
|
6196 |
|
|
frontend. This field is optional.
|
6197 |
|
|
|
6198 |
|
|
`state'
|
6199 |
|
|
Either `stopped' or `running', depending on whether the thread is
|
6200 |
|
|
presently running. This field is always present.
|
6201 |
|
|
|
6202 |
|
|
`core'
|
6203 |
|
|
The value of this field is an integer number of the processor core
|
6204 |
|
|
the thread was last seen on. This field is optional.
|
6205 |
|
|
|
6206 |
|
|
|
6207 |
|
|
File: gdb.info, Node: GDB/MI Simple Examples, Next: GDB/MI Command Description Format, Prev: GDB/MI Output Records, Up: GDB/MI
|
6208 |
|
|
|
6209 |
|
|
27.6 Simple Examples of GDB/MI Interaction
|
6210 |
|
|
==========================================
|
6211 |
|
|
|
6212 |
|
|
This subsection presents several simple examples of interaction using
|
6213 |
|
|
the GDB/MI interface. In these examples, `->' means that the following
|
6214 |
|
|
line is passed to GDB/MI as input, while `<-' means the output received
|
6215 |
|
|
from GDB/MI.
|
6216 |
|
|
|
6217 |
|
|
Note the line breaks shown in the examples are here only for
|
6218 |
|
|
readability, they don't appear in the real output.
|
6219 |
|
|
|
6220 |
|
|
Setting a Breakpoint
|
6221 |
|
|
--------------------
|
6222 |
|
|
|
6223 |
|
|
Setting a breakpoint generates synchronous output which contains
|
6224 |
|
|
detailed information of the breakpoint.
|
6225 |
|
|
|
6226 |
|
|
-> -break-insert main
|
6227 |
|
|
<- ^done,bkpt={number="1",type="breakpoint",disp="keep",
|
6228 |
|
|
enabled="y",addr="0x08048564",func="main",file="myprog.c",
|
6229 |
|
|
fullname="/home/nickrob/myprog.c",line="68",times="0"}
|
6230 |
|
|
<- (gdb)
|
6231 |
|
|
|
6232 |
|
|
Program Execution
|
6233 |
|
|
-----------------
|
6234 |
|
|
|
6235 |
|
|
Program execution generates asynchronous records and MI gives the
|
6236 |
|
|
reason that execution stopped.
|
6237 |
|
|
|
6238 |
|
|
-> -exec-run
|
6239 |
|
|
<- ^running
|
6240 |
|
|
<- (gdb)
|
6241 |
|
|
<- *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
|
6242 |
|
|
frame={addr="0x08048564",func="main",
|
6243 |
|
|
args=[{name="argc",value="1"},{name="argv",value="0xbfc4d4d4"}],
|
6244 |
|
|
file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"}
|
6245 |
|
|
<- (gdb)
|
6246 |
|
|
-> -exec-continue
|
6247 |
|
|
<- ^running
|
6248 |
|
|
<- (gdb)
|
6249 |
|
|
<- *stopped,reason="exited-normally"
|
6250 |
|
|
<- (gdb)
|
6251 |
|
|
|
6252 |
|
|
Quitting GDB
|
6253 |
|
|
------------
|
6254 |
|
|
|
6255 |
|
|
Quitting GDB just prints the result class `^exit'.
|
6256 |
|
|
|
6257 |
|
|
-> (gdb)
|
6258 |
|
|
<- -gdb-exit
|
6259 |
|
|
<- ^exit
|
6260 |
|
|
|
6261 |
|
|
Please note that `^exit' is printed immediately, but it might take
|
6262 |
|
|
some time for GDB to actually exit. During that time, GDB performs
|
6263 |
|
|
necessary cleanups, including killing programs being debugged or
|
6264 |
|
|
disconnecting from debug hardware, so the frontend should wait till GDB
|
6265 |
|
|
exits and should only forcibly kill GDB if it fails to exit in
|
6266 |
|
|
reasonable time.
|
6267 |
|
|
|
6268 |
|
|
A Bad Command
|
6269 |
|
|
-------------
|
6270 |
|
|
|
6271 |
|
|
Here's what happens if you pass a non-existent command:
|
6272 |
|
|
|
6273 |
|
|
-> -rubbish
|
6274 |
|
|
<- ^error,msg="Undefined MI command: rubbish"
|
6275 |
|
|
<- (gdb)
|
6276 |
|
|
|
6277 |
|
|
|
6278 |
|
|
File: gdb.info, Node: GDB/MI Command Description Format, Next: GDB/MI Breakpoint Commands, Prev: GDB/MI Simple Examples, Up: GDB/MI
|
6279 |
|
|
|
6280 |
|
|
27.7 GDB/MI Command Description Format
|
6281 |
|
|
======================================
|
6282 |
|
|
|
6283 |
|
|
The remaining sections describe blocks of commands. Each block of
|
6284 |
|
|
commands is laid out in a fashion similar to this section.
|
6285 |
|
|
|
6286 |
|
|
Motivation
|
6287 |
|
|
----------
|
6288 |
|
|
|
6289 |
|
|
The motivation for this collection of commands.
|
6290 |
|
|
|
6291 |
|
|
Introduction
|
6292 |
|
|
------------
|
6293 |
|
|
|
6294 |
|
|
A brief introduction to this collection of commands as a whole.
|
6295 |
|
|
|
6296 |
|
|
Commands
|
6297 |
|
|
--------
|
6298 |
|
|
|
6299 |
|
|
For each command in the block, the following is described:
|
6300 |
|
|
|
6301 |
|
|
Synopsis
|
6302 |
|
|
........
|
6303 |
|
|
|
6304 |
|
|
-command ARGS...
|
6305 |
|
|
|
6306 |
|
|
Result
|
6307 |
|
|
......
|
6308 |
|
|
|
6309 |
|
|
GDB Command
|
6310 |
|
|
...........
|
6311 |
|
|
|
6312 |
|
|
The corresponding GDB CLI command(s), if any.
|
6313 |
|
|
|
6314 |
|
|
Example
|
6315 |
|
|
.......
|
6316 |
|
|
|
6317 |
|
|
Example(s) formatted for readability. Some of the described commands
|
6318 |
|
|
have not been implemented yet and these are labeled N.A. (not
|
6319 |
|
|
available).
|
6320 |
|
|
|
6321 |
|
|
|
6322 |
|
|
File: gdb.info, Node: GDB/MI Breakpoint Commands, Next: GDB/MI Program Context, Prev: GDB/MI Command Description Format, Up: GDB/MI
|
6323 |
|
|
|
6324 |
|
|
27.8 GDB/MI Breakpoint Commands
|
6325 |
|
|
===============================
|
6326 |
|
|
|
6327 |
|
|
This section documents GDB/MI commands for manipulating breakpoints.
|
6328 |
|
|
|
6329 |
|
|
The `-break-after' Command
|
6330 |
|
|
--------------------------
|
6331 |
|
|
|
6332 |
|
|
Synopsis
|
6333 |
|
|
........
|
6334 |
|
|
|
6335 |
|
|
-break-after NUMBER COUNT
|
6336 |
|
|
|
6337 |
|
|
The breakpoint number NUMBER is not in effect until it has been hit
|
6338 |
|
|
COUNT times. To see how this is reflected in the output of the
|
6339 |
|
|
`-break-list' command, see the description of the `-break-list' command
|
6340 |
|
|
below.
|
6341 |
|
|
|
6342 |
|
|
GDB Command
|
6343 |
|
|
...........
|
6344 |
|
|
|
6345 |
|
|
The corresponding GDB command is `ignore'.
|
6346 |
|
|
|
6347 |
|
|
Example
|
6348 |
|
|
.......
|
6349 |
|
|
|
6350 |
|
|
(gdb)
|
6351 |
|
|
-break-insert main
|
6352 |
|
|
^done,bkpt={number="1",type="breakpoint",disp="keep",
|
6353 |
|
|
enabled="y",addr="0x000100d0",func="main",file="hello.c",
|
6354 |
|
|
fullname="/home/foo/hello.c",line="5",times="0"}
|
6355 |
|
|
(gdb)
|
6356 |
|
|
-break-after 1 3
|
6357 |
|
|
~
|
6358 |
|
|
^done
|
6359 |
|
|
(gdb)
|
6360 |
|
|
-break-list
|
6361 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
6362 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6363 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6364 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6365 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6366 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6367 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6368 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
6369 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
6370 |
|
|
line="5",times="0",ignore="3"}]}
|
6371 |
|
|
(gdb)
|
6372 |
|
|
|
6373 |
|
|
The `-break-commands' Command
|
6374 |
|
|
-----------------------------
|
6375 |
|
|
|
6376 |
|
|
Synopsis
|
6377 |
|
|
........
|
6378 |
|
|
|
6379 |
|
|
-break-commands NUMBER [ COMMAND1 ... COMMANDN ]
|
6380 |
|
|
|
6381 |
|
|
Specifies the CLI commands that should be executed when breakpoint
|
6382 |
|
|
NUMBER is hit. The parameters COMMAND1 to COMMANDN are the commands.
|
6383 |
|
|
If no command is specified, any previously-set commands are cleared.
|
6384 |
|
|
*Note Break Commands::. Typical use of this functionality is tracing a
|
6385 |
|
|
program, that is, printing of values of some variables whenever
|
6386 |
|
|
breakpoint is hit and then continuing.
|
6387 |
|
|
|
6388 |
|
|
GDB Command
|
6389 |
|
|
...........
|
6390 |
|
|
|
6391 |
|
|
The corresponding GDB command is `commands'.
|
6392 |
|
|
|
6393 |
|
|
Example
|
6394 |
|
|
.......
|
6395 |
|
|
|
6396 |
|
|
(gdb)
|
6397 |
|
|
-break-insert main
|
6398 |
|
|
^done,bkpt={number="1",type="breakpoint",disp="keep",
|
6399 |
|
|
enabled="y",addr="0x000100d0",func="main",file="hello.c",
|
6400 |
|
|
fullname="/home/foo/hello.c",line="5",times="0"}
|
6401 |
|
|
(gdb)
|
6402 |
|
|
-break-commands 1 "print v" "continue"
|
6403 |
|
|
^done
|
6404 |
|
|
(gdb)
|
6405 |
|
|
|
6406 |
|
|
The `-break-condition' Command
|
6407 |
|
|
------------------------------
|
6408 |
|
|
|
6409 |
|
|
Synopsis
|
6410 |
|
|
........
|
6411 |
|
|
|
6412 |
|
|
-break-condition NUMBER EXPR
|
6413 |
|
|
|
6414 |
|
|
Breakpoint NUMBER will stop the program only if the condition in
|
6415 |
|
|
EXPR is true. The condition becomes part of the `-break-list' output
|
6416 |
|
|
(see the description of the `-break-list' command below).
|
6417 |
|
|
|
6418 |
|
|
GDB Command
|
6419 |
|
|
...........
|
6420 |
|
|
|
6421 |
|
|
The corresponding GDB command is `condition'.
|
6422 |
|
|
|
6423 |
|
|
Example
|
6424 |
|
|
.......
|
6425 |
|
|
|
6426 |
|
|
(gdb)
|
6427 |
|
|
-break-condition 1 1
|
6428 |
|
|
^done
|
6429 |
|
|
(gdb)
|
6430 |
|
|
-break-list
|
6431 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
6432 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6433 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6434 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6435 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6436 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6437 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6438 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
6439 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
6440 |
|
|
line="5",cond="1",times="0",ignore="3"}]}
|
6441 |
|
|
(gdb)
|
6442 |
|
|
|
6443 |
|
|
The `-break-delete' Command
|
6444 |
|
|
---------------------------
|
6445 |
|
|
|
6446 |
|
|
Synopsis
|
6447 |
|
|
........
|
6448 |
|
|
|
6449 |
|
|
-break-delete ( BREAKPOINT )+
|
6450 |
|
|
|
6451 |
|
|
Delete the breakpoint(s) whose number(s) are specified in the
|
6452 |
|
|
argument list. This is obviously reflected in the breakpoint list.
|
6453 |
|
|
|
6454 |
|
|
GDB Command
|
6455 |
|
|
...........
|
6456 |
|
|
|
6457 |
|
|
The corresponding GDB command is `delete'.
|
6458 |
|
|
|
6459 |
|
|
Example
|
6460 |
|
|
.......
|
6461 |
|
|
|
6462 |
|
|
(gdb)
|
6463 |
|
|
-break-delete 1
|
6464 |
|
|
^done
|
6465 |
|
|
(gdb)
|
6466 |
|
|
-break-list
|
6467 |
|
|
^done,BreakpointTable={nr_rows="0",nr_cols="6",
|
6468 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6469 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6470 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6471 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6472 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6473 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6474 |
|
|
body=[]}
|
6475 |
|
|
(gdb)
|
6476 |
|
|
|
6477 |
|
|
The `-break-disable' Command
|
6478 |
|
|
----------------------------
|
6479 |
|
|
|
6480 |
|
|
Synopsis
|
6481 |
|
|
........
|
6482 |
|
|
|
6483 |
|
|
-break-disable ( BREAKPOINT )+
|
6484 |
|
|
|
6485 |
|
|
Disable the named BREAKPOINT(s). The field `enabled' in the break
|
6486 |
|
|
list is now set to `n' for the named BREAKPOINT(s).
|
6487 |
|
|
|
6488 |
|
|
GDB Command
|
6489 |
|
|
...........
|
6490 |
|
|
|
6491 |
|
|
The corresponding GDB command is `disable'.
|
6492 |
|
|
|
6493 |
|
|
Example
|
6494 |
|
|
.......
|
6495 |
|
|
|
6496 |
|
|
(gdb)
|
6497 |
|
|
-break-disable 2
|
6498 |
|
|
^done
|
6499 |
|
|
(gdb)
|
6500 |
|
|
-break-list
|
6501 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
6502 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6503 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6504 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6505 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6506 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6507 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6508 |
|
|
body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="n",
|
6509 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
6510 |
|
|
line="5",times="0"}]}
|
6511 |
|
|
(gdb)
|
6512 |
|
|
|
6513 |
|
|
The `-break-enable' Command
|
6514 |
|
|
---------------------------
|
6515 |
|
|
|
6516 |
|
|
Synopsis
|
6517 |
|
|
........
|
6518 |
|
|
|
6519 |
|
|
-break-enable ( BREAKPOINT )+
|
6520 |
|
|
|
6521 |
|
|
Enable (previously disabled) BREAKPOINT(s).
|
6522 |
|
|
|
6523 |
|
|
GDB Command
|
6524 |
|
|
...........
|
6525 |
|
|
|
6526 |
|
|
The corresponding GDB command is `enable'.
|
6527 |
|
|
|
6528 |
|
|
Example
|
6529 |
|
|
.......
|
6530 |
|
|
|
6531 |
|
|
(gdb)
|
6532 |
|
|
-break-enable 2
|
6533 |
|
|
^done
|
6534 |
|
|
(gdb)
|
6535 |
|
|
-break-list
|
6536 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
6537 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6538 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6539 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6540 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6541 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6542 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6543 |
|
|
body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
|
6544 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
6545 |
|
|
line="5",times="0"}]}
|
6546 |
|
|
(gdb)
|
6547 |
|
|
|
6548 |
|
|
The `-break-info' Command
|
6549 |
|
|
-------------------------
|
6550 |
|
|
|
6551 |
|
|
Synopsis
|
6552 |
|
|
........
|
6553 |
|
|
|
6554 |
|
|
-break-info BREAKPOINT
|
6555 |
|
|
|
6556 |
|
|
Get information about a single breakpoint.
|
6557 |
|
|
|
6558 |
|
|
GDB Command
|
6559 |
|
|
...........
|
6560 |
|
|
|
6561 |
|
|
The corresponding GDB command is `info break BREAKPOINT'.
|
6562 |
|
|
|
6563 |
|
|
Example
|
6564 |
|
|
.......
|
6565 |
|
|
|
6566 |
|
|
N.A.
|
6567 |
|
|
|
6568 |
|
|
The `-break-insert' Command
|
6569 |
|
|
---------------------------
|
6570 |
|
|
|
6571 |
|
|
Synopsis
|
6572 |
|
|
........
|
6573 |
|
|
|
6574 |
|
|
-break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ]
|
6575 |
|
|
[ -c CONDITION ] [ -i IGNORE-COUNT ]
|
6576 |
|
|
[ -p THREAD ] [ LOCATION ]
|
6577 |
|
|
|
6578 |
|
|
If specified, LOCATION, can be one of:
|
6579 |
|
|
|
6580 |
|
|
* function
|
6581 |
|
|
|
6582 |
|
|
* filename:linenum
|
6583 |
|
|
|
6584 |
|
|
* filename:function
|
6585 |
|
|
|
6586 |
|
|
* *address
|
6587 |
|
|
|
6588 |
|
|
The possible optional parameters of this command are:
|
6589 |
|
|
|
6590 |
|
|
`-t'
|
6591 |
|
|
Insert a temporary breakpoint.
|
6592 |
|
|
|
6593 |
|
|
`-h'
|
6594 |
|
|
Insert a hardware breakpoint.
|
6595 |
|
|
|
6596 |
|
|
`-c CONDITION'
|
6597 |
|
|
Make the breakpoint conditional on CONDITION.
|
6598 |
|
|
|
6599 |
|
|
`-i IGNORE-COUNT'
|
6600 |
|
|
Initialize the IGNORE-COUNT.
|
6601 |
|
|
|
6602 |
|
|
`-f'
|
6603 |
|
|
If LOCATION cannot be parsed (for example if it refers to unknown
|
6604 |
|
|
files or functions), create a pending breakpoint. Without this
|
6605 |
|
|
flag, GDB will report an error, and won't create a breakpoint, if
|
6606 |
|
|
LOCATION cannot be parsed.
|
6607 |
|
|
|
6608 |
|
|
`-d'
|
6609 |
|
|
Create a disabled breakpoint.
|
6610 |
|
|
|
6611 |
|
|
`-a'
|
6612 |
|
|
Create a tracepoint. *Note Tracepoints::. When this parameter is
|
6613 |
|
|
used together with `-h', a fast tracepoint is created.
|
6614 |
|
|
|
6615 |
|
|
Result
|
6616 |
|
|
......
|
6617 |
|
|
|
6618 |
|
|
The result is in the form:
|
6619 |
|
|
|
6620 |
|
|
^done,bkpt={number="NUMBER",type="TYPE",disp="del"|"keep",
|
6621 |
|
|
enabled="y"|"n",addr="HEX",func="FUNCNAME",file="FILENAME",
|
6622 |
|
|
fullname="FULL_FILENAME",line="LINENO",[thread="THREADNO,]
|
6623 |
|
|
times="TIMES"}
|
6624 |
|
|
|
6625 |
|
|
where NUMBER is the GDB number for this breakpoint, FUNCNAME is the
|
6626 |
|
|
name of the function where the breakpoint was inserted, FILENAME is the
|
6627 |
|
|
name of the source file which contains this function, LINENO is the
|
6628 |
|
|
source line number within that file and TIMES the number of times that
|
6629 |
|
|
the breakpoint has been hit (always 0 for -break-insert but may be
|
6630 |
|
|
greater for -break-info or -break-list which use the same output).
|
6631 |
|
|
|
6632 |
|
|
Note: this format is open to change.
|
6633 |
|
|
|
6634 |
|
|
GDB Command
|
6635 |
|
|
...........
|
6636 |
|
|
|
6637 |
|
|
The corresponding GDB commands are `break', `tbreak', `hbreak',
|
6638 |
|
|
`thbreak', and `rbreak'.
|
6639 |
|
|
|
6640 |
|
|
Example
|
6641 |
|
|
.......
|
6642 |
|
|
|
6643 |
|
|
(gdb)
|
6644 |
|
|
-break-insert main
|
6645 |
|
|
^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",
|
6646 |
|
|
fullname="/home/foo/recursive2.c,line="4",times="0"}
|
6647 |
|
|
(gdb)
|
6648 |
|
|
-break-insert -t foo
|
6649 |
|
|
^done,bkpt={number="2",addr="0x00010774",file="recursive2.c",
|
6650 |
|
|
fullname="/home/foo/recursive2.c,line="11",times="0"}
|
6651 |
|
|
(gdb)
|
6652 |
|
|
-break-list
|
6653 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
6654 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6655 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6656 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6657 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6658 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6659 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6660 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
6661 |
|
|
addr="0x0001072c", func="main",file="recursive2.c",
|
6662 |
|
|
fullname="/home/foo/recursive2.c,"line="4",times="0"},
|
6663 |
|
|
bkpt={number="2",type="breakpoint",disp="del",enabled="y",
|
6664 |
|
|
addr="0x00010774",func="foo",file="recursive2.c",
|
6665 |
|
|
fullname="/home/foo/recursive2.c",line="11",times="0"}]}
|
6666 |
|
|
(gdb)
|
6667 |
|
|
-break-insert -r foo.*
|
6668 |
|
|
~int foo(int, int);
|
6669 |
|
|
^done,bkpt={number="3",addr="0x00010774",file="recursive2.c,
|
6670 |
|
|
"fullname="/home/foo/recursive2.c",line="11",times="0"}
|
6671 |
|
|
(gdb)
|
6672 |
|
|
|
6673 |
|
|
The `-break-list' Command
|
6674 |
|
|
-------------------------
|
6675 |
|
|
|
6676 |
|
|
Synopsis
|
6677 |
|
|
........
|
6678 |
|
|
|
6679 |
|
|
-break-list
|
6680 |
|
|
|
6681 |
|
|
Displays the list of inserted breakpoints, showing the following
|
6682 |
|
|
fields:
|
6683 |
|
|
|
6684 |
|
|
`Number'
|
6685 |
|
|
number of the breakpoint
|
6686 |
|
|
|
6687 |
|
|
`Type'
|
6688 |
|
|
type of the breakpoint: `breakpoint' or `watchpoint'
|
6689 |
|
|
|
6690 |
|
|
`Disposition'
|
6691 |
|
|
should the breakpoint be deleted or disabled when it is hit: `keep'
|
6692 |
|
|
or `nokeep'
|
6693 |
|
|
|
6694 |
|
|
`Enabled'
|
6695 |
|
|
is the breakpoint enabled or no: `y' or `n'
|
6696 |
|
|
|
6697 |
|
|
`Address'
|
6698 |
|
|
memory location at which the breakpoint is set
|
6699 |
|
|
|
6700 |
|
|
`What'
|
6701 |
|
|
logical location of the breakpoint, expressed by function name,
|
6702 |
|
|
file name, line number
|
6703 |
|
|
|
6704 |
|
|
`Times'
|
6705 |
|
|
number of times the breakpoint has been hit
|
6706 |
|
|
|
6707 |
|
|
If there are no breakpoints or watchpoints, the `BreakpointTable'
|
6708 |
|
|
`body' field is an empty list.
|
6709 |
|
|
|
6710 |
|
|
GDB Command
|
6711 |
|
|
...........
|
6712 |
|
|
|
6713 |
|
|
The corresponding GDB command is `info break'.
|
6714 |
|
|
|
6715 |
|
|
Example
|
6716 |
|
|
.......
|
6717 |
|
|
|
6718 |
|
|
(gdb)
|
6719 |
|
|
-break-list
|
6720 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
6721 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6722 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6723 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6724 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6725 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6726 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6727 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
6728 |
|
|
addr="0x000100d0",func="main",file="hello.c",line="5",times="0"},
|
6729 |
|
|
bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
|
6730 |
|
|
addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c",
|
6731 |
|
|
line="13",times="0"}]}
|
6732 |
|
|
(gdb)
|
6733 |
|
|
|
6734 |
|
|
Here's an example of the result when there are no breakpoints:
|
6735 |
|
|
|
6736 |
|
|
(gdb)
|
6737 |
|
|
-break-list
|
6738 |
|
|
^done,BreakpointTable={nr_rows="0",nr_cols="6",
|
6739 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6740 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6741 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6742 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6743 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6744 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6745 |
|
|
body=[]}
|
6746 |
|
|
(gdb)
|
6747 |
|
|
|
6748 |
|
|
The `-break-passcount' Command
|
6749 |
|
|
------------------------------
|
6750 |
|
|
|
6751 |
|
|
Synopsis
|
6752 |
|
|
........
|
6753 |
|
|
|
6754 |
|
|
-break-passcount TRACEPOINT-NUMBER PASSCOUNT
|
6755 |
|
|
|
6756 |
|
|
Set the passcount for tracepoint TRACEPOINT-NUMBER to PASSCOUNT. If
|
6757 |
|
|
the breakpoint referred to by TRACEPOINT-NUMBER is not a tracepoint,
|
6758 |
|
|
error is emitted. This corresponds to CLI command `passcount'.
|
6759 |
|
|
|
6760 |
|
|
The `-break-watch' Command
|
6761 |
|
|
--------------------------
|
6762 |
|
|
|
6763 |
|
|
Synopsis
|
6764 |
|
|
........
|
6765 |
|
|
|
6766 |
|
|
-break-watch [ -a | -r ]
|
6767 |
|
|
|
6768 |
|
|
Create a watchpoint. With the `-a' option it will create an
|
6769 |
|
|
"access" watchpoint, i.e., a watchpoint that triggers either on a read
|
6770 |
|
|
from or on a write to the memory location. With the `-r' option, the
|
6771 |
|
|
watchpoint created is a "read" watchpoint, i.e., it will trigger only
|
6772 |
|
|
when the memory location is accessed for reading. Without either of
|
6773 |
|
|
the options, the watchpoint created is a regular watchpoint, i.e., it
|
6774 |
|
|
will trigger when the memory location is accessed for writing. *Note
|
6775 |
|
|
Setting Watchpoints: Set Watchpoints.
|
6776 |
|
|
|
6777 |
|
|
Note that `-break-list' will report a single list of watchpoints and
|
6778 |
|
|
breakpoints inserted.
|
6779 |
|
|
|
6780 |
|
|
GDB Command
|
6781 |
|
|
...........
|
6782 |
|
|
|
6783 |
|
|
The corresponding GDB commands are `watch', `awatch', and `rwatch'.
|
6784 |
|
|
|
6785 |
|
|
Example
|
6786 |
|
|
.......
|
6787 |
|
|
|
6788 |
|
|
Setting a watchpoint on a variable in the `main' function:
|
6789 |
|
|
|
6790 |
|
|
(gdb)
|
6791 |
|
|
-break-watch x
|
6792 |
|
|
^done,wpt={number="2",exp="x"}
|
6793 |
|
|
(gdb)
|
6794 |
|
|
-exec-continue
|
6795 |
|
|
^running
|
6796 |
|
|
(gdb)
|
6797 |
|
|
*stopped,reason="watchpoint-trigger",wpt={number="2",exp="x"},
|
6798 |
|
|
value={old="-268439212",new="55"},
|
6799 |
|
|
frame={func="main",args=[],file="recursive2.c",
|
6800 |
|
|
fullname="/home/foo/bar/recursive2.c",line="5"}
|
6801 |
|
|
(gdb)
|
6802 |
|
|
|
6803 |
|
|
Setting a watchpoint on a variable local to a function. GDB will
|
6804 |
|
|
stop the program execution twice: first for the variable changing
|
6805 |
|
|
value, then for the watchpoint going out of scope.
|
6806 |
|
|
|
6807 |
|
|
(gdb)
|
6808 |
|
|
-break-watch C
|
6809 |
|
|
^done,wpt={number="5",exp="C"}
|
6810 |
|
|
(gdb)
|
6811 |
|
|
-exec-continue
|
6812 |
|
|
^running
|
6813 |
|
|
(gdb)
|
6814 |
|
|
*stopped,reason="watchpoint-trigger",
|
6815 |
|
|
wpt={number="5",exp="C"},value={old="-276895068",new="3"},
|
6816 |
|
|
frame={func="callee4",args=[],
|
6817 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
6818 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
|
6819 |
|
|
(gdb)
|
6820 |
|
|
-exec-continue
|
6821 |
|
|
^running
|
6822 |
|
|
(gdb)
|
6823 |
|
|
*stopped,reason="watchpoint-scope",wpnum="5",
|
6824 |
|
|
frame={func="callee3",args=[{name="strarg",
|
6825 |
|
|
value="0x11940 \"A string argument.\""}],
|
6826 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
6827 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
|
6828 |
|
|
(gdb)
|
6829 |
|
|
|
6830 |
|
|
Listing breakpoints and watchpoints, at different points in the
|
6831 |
|
|
program execution. Note that once the watchpoint goes out of scope, it
|
6832 |
|
|
is deleted.
|
6833 |
|
|
|
6834 |
|
|
(gdb)
|
6835 |
|
|
-break-watch C
|
6836 |
|
|
^done,wpt={number="2",exp="C"}
|
6837 |
|
|
(gdb)
|
6838 |
|
|
-break-list
|
6839 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
6840 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6841 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6842 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6843 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6844 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6845 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6846 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
6847 |
|
|
addr="0x00010734",func="callee4",
|
6848 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
6849 |
|
|
fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",times="1"},
|
6850 |
|
|
bkpt={number="2",type="watchpoint",disp="keep",
|
6851 |
|
|
enabled="y",addr="",what="C",times="0"}]}
|
6852 |
|
|
(gdb)
|
6853 |
|
|
-exec-continue
|
6854 |
|
|
^running
|
6855 |
|
|
(gdb)
|
6856 |
|
|
*stopped,reason="watchpoint-trigger",wpt={number="2",exp="C"},
|
6857 |
|
|
value={old="-276895068",new="3"},
|
6858 |
|
|
frame={func="callee4",args=[],
|
6859 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
6860 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
|
6861 |
|
|
(gdb)
|
6862 |
|
|
-break-list
|
6863 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
6864 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6865 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6866 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6867 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6868 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6869 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6870 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
6871 |
|
|
addr="0x00010734",func="callee4",
|
6872 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
6873 |
|
|
fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"},
|
6874 |
|
|
bkpt={number="2",type="watchpoint",disp="keep",
|
6875 |
|
|
enabled="y",addr="",what="C",times="-5"}]}
|
6876 |
|
|
(gdb)
|
6877 |
|
|
-exec-continue
|
6878 |
|
|
^running
|
6879 |
|
|
^done,reason="watchpoint-scope",wpnum="2",
|
6880 |
|
|
frame={func="callee3",args=[{name="strarg",
|
6881 |
|
|
value="0x11940 \"A string argument.\""}],
|
6882 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
6883 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
|
6884 |
|
|
(gdb)
|
6885 |
|
|
-break-list
|
6886 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
6887 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
6888 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
6889 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
6890 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
6891 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
6892 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
6893 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
6894 |
|
|
addr="0x00010734",func="callee4",
|
6895 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
6896 |
|
|
fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
|
6897 |
|
|
times="1"}]}
|
6898 |
|
|
(gdb)
|
6899 |
|
|
|
6900 |
|
|
|
6901 |
|
|
File: gdb.info, Node: GDB/MI Program Context, Next: GDB/MI Thread Commands, Prev: GDB/MI Breakpoint Commands, Up: GDB/MI
|
6902 |
|
|
|
6903 |
|
|
27.9 GDB/MI Program Context
|
6904 |
|
|
============================
|
6905 |
|
|
|
6906 |
|
|
The `-exec-arguments' Command
|
6907 |
|
|
-----------------------------
|
6908 |
|
|
|
6909 |
|
|
Synopsis
|
6910 |
|
|
........
|
6911 |
|
|
|
6912 |
|
|
-exec-arguments ARGS
|
6913 |
|
|
|
6914 |
|
|
Set the inferior program arguments, to be used in the next
|
6915 |
|
|
`-exec-run'.
|
6916 |
|
|
|
6917 |
|
|
GDB Command
|
6918 |
|
|
...........
|
6919 |
|
|
|
6920 |
|
|
The corresponding GDB command is `set args'.
|
6921 |
|
|
|
6922 |
|
|
Example
|
6923 |
|
|
.......
|
6924 |
|
|
|
6925 |
|
|
(gdb)
|
6926 |
|
|
-exec-arguments -v word
|
6927 |
|
|
^done
|
6928 |
|
|
(gdb)
|
6929 |
|
|
|
6930 |
|
|
The `-environment-cd' Command
|
6931 |
|
|
-----------------------------
|
6932 |
|
|
|
6933 |
|
|
Synopsis
|
6934 |
|
|
........
|
6935 |
|
|
|
6936 |
|
|
-environment-cd PATHDIR
|
6937 |
|
|
|
6938 |
|
|
Set GDB's working directory.
|
6939 |
|
|
|
6940 |
|
|
GDB Command
|
6941 |
|
|
...........
|
6942 |
|
|
|
6943 |
|
|
The corresponding GDB command is `cd'.
|
6944 |
|
|
|
6945 |
|
|
Example
|
6946 |
|
|
.......
|
6947 |
|
|
|
6948 |
|
|
(gdb)
|
6949 |
|
|
-environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
|
6950 |
|
|
^done
|
6951 |
|
|
(gdb)
|
6952 |
|
|
|
6953 |
|
|
The `-environment-directory' Command
|
6954 |
|
|
------------------------------------
|
6955 |
|
|
|
6956 |
|
|
Synopsis
|
6957 |
|
|
........
|
6958 |
|
|
|
6959 |
|
|
-environment-directory [ -r ] [ PATHDIR ]+
|
6960 |
|
|
|
6961 |
|
|
Add directories PATHDIR to beginning of search path for source files.
|
6962 |
|
|
If the `-r' option is used, the search path is reset to the default
|
6963 |
|
|
search path. If directories PATHDIR are supplied in addition to the
|
6964 |
|
|
`-r' option, the search path is first reset and then addition occurs as
|
6965 |
|
|
normal. Multiple directories may be specified, separated by blanks.
|
6966 |
|
|
Specifying multiple directories in a single command results in the
|
6967 |
|
|
directories added to the beginning of the search path in the same order
|
6968 |
|
|
they were presented in the command. If blanks are needed as part of a
|
6969 |
|
|
directory name, double-quotes should be used around the name. In the
|
6970 |
|
|
command output, the path will show up separated by the system
|
6971 |
|
|
directory-separator character. The directory-separator character must
|
6972 |
|
|
not be used in any directory name. If no directories are specified,
|
6973 |
|
|
the current search path is displayed.
|
6974 |
|
|
|
6975 |
|
|
GDB Command
|
6976 |
|
|
...........
|
6977 |
|
|
|
6978 |
|
|
The corresponding GDB command is `dir'.
|
6979 |
|
|
|
6980 |
|
|
Example
|
6981 |
|
|
.......
|
6982 |
|
|
|
6983 |
|
|
(gdb)
|
6984 |
|
|
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
|
6985 |
|
|
^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
|
6986 |
|
|
(gdb)
|
6987 |
|
|
-environment-directory ""
|
6988 |
|
|
^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
|
6989 |
|
|
(gdb)
|
6990 |
|
|
-environment-directory -r /home/jjohnstn/src/gdb /usr/src
|
6991 |
|
|
^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
|
6992 |
|
|
(gdb)
|
6993 |
|
|
-environment-directory -r
|
6994 |
|
|
^done,source-path="$cdir:$cwd"
|
6995 |
|
|
(gdb)
|
6996 |
|
|
|
6997 |
|
|
The `-environment-path' Command
|
6998 |
|
|
-------------------------------
|
6999 |
|
|
|
7000 |
|
|
Synopsis
|
7001 |
|
|
........
|
7002 |
|
|
|
7003 |
|
|
-environment-path [ -r ] [ PATHDIR ]+
|
7004 |
|
|
|
7005 |
|
|
Add directories PATHDIR to beginning of search path for object files.
|
7006 |
|
|
If the `-r' option is used, the search path is reset to the original
|
7007 |
|
|
search path that existed at gdb start-up. If directories PATHDIR are
|
7008 |
|
|
supplied in addition to the `-r' option, the search path is first reset
|
7009 |
|
|
and then addition occurs as normal. Multiple directories may be
|
7010 |
|
|
specified, separated by blanks. Specifying multiple directories in a
|
7011 |
|
|
single command results in the directories added to the beginning of the
|
7012 |
|
|
search path in the same order they were presented in the command. If
|
7013 |
|
|
blanks are needed as part of a directory name, double-quotes should be
|
7014 |
|
|
used around the name. In the command output, the path will show up
|
7015 |
|
|
separated by the system directory-separator character. The
|
7016 |
|
|
directory-separator character must not be used in any directory name.
|
7017 |
|
|
If no directories are specified, the current path is displayed.
|
7018 |
|
|
|
7019 |
|
|
GDB Command
|
7020 |
|
|
...........
|
7021 |
|
|
|
7022 |
|
|
The corresponding GDB command is `path'.
|
7023 |
|
|
|
7024 |
|
|
Example
|
7025 |
|
|
.......
|
7026 |
|
|
|
7027 |
|
|
(gdb)
|
7028 |
|
|
-environment-path
|
7029 |
|
|
^done,path="/usr/bin"
|
7030 |
|
|
(gdb)
|
7031 |
|
|
-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
|
7032 |
|
|
^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
|
7033 |
|
|
(gdb)
|
7034 |
|
|
-environment-path -r /usr/local/bin
|
7035 |
|
|
^done,path="/usr/local/bin:/usr/bin"
|
7036 |
|
|
(gdb)
|
7037 |
|
|
|
7038 |
|
|
The `-environment-pwd' Command
|
7039 |
|
|
------------------------------
|
7040 |
|
|
|
7041 |
|
|
Synopsis
|
7042 |
|
|
........
|
7043 |
|
|
|
7044 |
|
|
-environment-pwd
|
7045 |
|
|
|
7046 |
|
|
Show the current working directory.
|
7047 |
|
|
|
7048 |
|
|
GDB Command
|
7049 |
|
|
...........
|
7050 |
|
|
|
7051 |
|
|
The corresponding GDB command is `pwd'.
|
7052 |
|
|
|
7053 |
|
|
Example
|
7054 |
|
|
.......
|
7055 |
|
|
|
7056 |
|
|
(gdb)
|
7057 |
|
|
-environment-pwd
|
7058 |
|
|
^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
|
7059 |
|
|
(gdb)
|
7060 |
|
|
|
7061 |
|
|
|
7062 |
|
|
File: gdb.info, Node: GDB/MI Thread Commands, Next: GDB/MI Program Execution, Prev: GDB/MI Program Context, Up: GDB/MI
|
7063 |
|
|
|
7064 |
|
|
27.10 GDB/MI Thread Commands
|
7065 |
|
|
============================
|
7066 |
|
|
|
7067 |
|
|
The `-thread-info' Command
|
7068 |
|
|
--------------------------
|
7069 |
|
|
|
7070 |
|
|
Synopsis
|
7071 |
|
|
........
|
7072 |
|
|
|
7073 |
|
|
-thread-info [ THREAD-ID ]
|
7074 |
|
|
|
7075 |
|
|
Reports information about either a specific thread, if the THREAD-ID
|
7076 |
|
|
parameter is present, or about all threads. When printing information
|
7077 |
|
|
about all threads, also reports the current thread.
|
7078 |
|
|
|
7079 |
|
|
GDB Command
|
7080 |
|
|
...........
|
7081 |
|
|
|
7082 |
|
|
The `info thread' command prints the same information about all threads.
|
7083 |
|
|
|
7084 |
|
|
Example
|
7085 |
|
|
.......
|
7086 |
|
|
|
7087 |
|
|
-thread-info
|
7088 |
|
|
^done,threads=[
|
7089 |
|
|
{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
|
7090 |
|
|
frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]},state="running"},
|
7091 |
|
|
{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
|
7092 |
|
|
frame={level="0",addr="0x0804891f",func="foo",args=[{name="i",value="10"}],
|
7093 |
|
|
file="/tmp/a.c",fullname="/tmp/a.c",line="158"},state="running"}],
|
7094 |
|
|
current-thread-id="1"
|
7095 |
|
|
(gdb)
|
7096 |
|
|
|
7097 |
|
|
The `state' field may have the following values:
|
7098 |
|
|
|
7099 |
|
|
`stopped'
|
7100 |
|
|
The thread is stopped. Frame information is available for stopped
|
7101 |
|
|
threads.
|
7102 |
|
|
|
7103 |
|
|
`running'
|
7104 |
|
|
The thread is running. There's no frame information for running
|
7105 |
|
|
threads.
|
7106 |
|
|
|
7107 |
|
|
|
7108 |
|
|
The `-thread-list-ids' Command
|
7109 |
|
|
------------------------------
|
7110 |
|
|
|
7111 |
|
|
Synopsis
|
7112 |
|
|
........
|
7113 |
|
|
|
7114 |
|
|
-thread-list-ids
|
7115 |
|
|
|
7116 |
|
|
Produces a list of the currently known GDB thread ids. At the end
|
7117 |
|
|
of the list it also prints the total number of such threads.
|
7118 |
|
|
|
7119 |
|
|
This command is retained for historical reasons, the `-thread-info'
|
7120 |
|
|
command should be used instead.
|
7121 |
|
|
|
7122 |
|
|
GDB Command
|
7123 |
|
|
...........
|
7124 |
|
|
|
7125 |
|
|
Part of `info threads' supplies the same information.
|
7126 |
|
|
|
7127 |
|
|
Example
|
7128 |
|
|
.......
|
7129 |
|
|
|
7130 |
|
|
(gdb)
|
7131 |
|
|
-thread-list-ids
|
7132 |
|
|
^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"},
|
7133 |
|
|
current-thread-id="1",number-of-threads="3"
|
7134 |
|
|
(gdb)
|
7135 |
|
|
|
7136 |
|
|
The `-thread-select' Command
|
7137 |
|
|
----------------------------
|
7138 |
|
|
|
7139 |
|
|
Synopsis
|
7140 |
|
|
........
|
7141 |
|
|
|
7142 |
|
|
-thread-select THREADNUM
|
7143 |
|
|
|
7144 |
|
|
Make THREADNUM the current thread. It prints the number of the new
|
7145 |
|
|
current thread, and the topmost frame for that thread.
|
7146 |
|
|
|
7147 |
|
|
This command is deprecated in favor of explicitly using the
|
7148 |
|
|
`--thread' option to each command.
|
7149 |
|
|
|
7150 |
|
|
GDB Command
|
7151 |
|
|
...........
|
7152 |
|
|
|
7153 |
|
|
The corresponding GDB command is `thread'.
|
7154 |
|
|
|
7155 |
|
|
Example
|
7156 |
|
|
.......
|
7157 |
|
|
|
7158 |
|
|
(gdb)
|
7159 |
|
|
-exec-next
|
7160 |
|
|
^running
|
7161 |
|
|
(gdb)
|
7162 |
|
|
*stopped,reason="end-stepping-range",thread-id="2",line="187",
|
7163 |
|
|
file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
|
7164 |
|
|
(gdb)
|
7165 |
|
|
-thread-list-ids
|
7166 |
|
|
^done,
|
7167 |
|
|
thread-ids={thread-id="3",thread-id="2",thread-id="1"},
|
7168 |
|
|
number-of-threads="3"
|
7169 |
|
|
(gdb)
|
7170 |
|
|
-thread-select 3
|
7171 |
|
|
^done,new-thread-id="3",
|
7172 |
|
|
frame={level="0",func="vprintf",
|
7173 |
|
|
args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""},
|
7174 |
|
|
{name="arg",value="0x2"}],file="vprintf.c",line="31"}
|
7175 |
|
|
(gdb)
|
7176 |
|
|
|
7177 |
|
|
|
7178 |
|
|
File: gdb.info, Node: GDB/MI Program Execution, Next: GDB/MI Stack Manipulation, Prev: GDB/MI Thread Commands, Up: GDB/MI
|
7179 |
|
|
|
7180 |
|
|
27.11 GDB/MI Program Execution
|
7181 |
|
|
==============================
|
7182 |
|
|
|
7183 |
|
|
These are the asynchronous commands which generate the out-of-band
|
7184 |
|
|
record `*stopped'. Currently GDB only really executes asynchronously
|
7185 |
|
|
with remote targets and this interaction is mimicked in other cases.
|
7186 |
|
|
|
7187 |
|
|
The `-exec-continue' Command
|
7188 |
|
|
----------------------------
|
7189 |
|
|
|
7190 |
|
|
Synopsis
|
7191 |
|
|
........
|
7192 |
|
|
|
7193 |
|
|
-exec-continue [--reverse] [--all|--thread-group N]
|
7194 |
|
|
|
7195 |
|
|
Resumes the execution of the inferior program, which will continue
|
7196 |
|
|
to execute until it reaches a debugger stop event. If the `--reverse'
|
7197 |
|
|
option is specified, execution resumes in reverse until it reaches a
|
7198 |
|
|
stop event. Stop events may include
|
7199 |
|
|
* breakpoints or watchpoints
|
7200 |
|
|
|
7201 |
|
|
* signals or exceptions
|
7202 |
|
|
|
7203 |
|
|
* the end of the process (or its beginning under `--reverse')
|
7204 |
|
|
|
7205 |
|
|
* the end or beginning of a replay log if one is being used.
|
7206 |
|
|
In all-stop mode (*note All-Stop Mode::), may resume only one
|
7207 |
|
|
thread, or all threads, depending on the value of the
|
7208 |
|
|
`scheduler-locking' variable. If `--all' is specified, all threads (in
|
7209 |
|
|
all inferiors) will be resumed. The `--all' option is ignored in
|
7210 |
|
|
all-stop mode. If the `--thread-group' options is specified, then all
|
7211 |
|
|
threads in that thread group are resumed.
|
7212 |
|
|
|
7213 |
|
|
GDB Command
|
7214 |
|
|
...........
|
7215 |
|
|
|
7216 |
|
|
The corresponding GDB corresponding is `continue'.
|
7217 |
|
|
|
7218 |
|
|
Example
|
7219 |
|
|
.......
|
7220 |
|
|
|
7221 |
|
|
-exec-continue
|
7222 |
|
|
^running
|
7223 |
|
|
(gdb)
|
7224 |
|
|
@Hello world
|
7225 |
|
|
*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={
|
7226 |
|
|
func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c",
|
7227 |
|
|
line="13"}
|
7228 |
|
|
(gdb)
|
7229 |
|
|
|
7230 |
|
|
The `-exec-finish' Command
|
7231 |
|
|
--------------------------
|
7232 |
|
|
|
7233 |
|
|
Synopsis
|
7234 |
|
|
........
|
7235 |
|
|
|
7236 |
|
|
-exec-finish [--reverse]
|
7237 |
|
|
|
7238 |
|
|
Resumes the execution of the inferior program until the current
|
7239 |
|
|
function is exited. Displays the results returned by the function. If
|
7240 |
|
|
the `--reverse' option is specified, resumes the reverse execution of
|
7241 |
|
|
the inferior program until the point where current function was called.
|
7242 |
|
|
|
7243 |
|
|
GDB Command
|
7244 |
|
|
...........
|
7245 |
|
|
|
7246 |
|
|
The corresponding GDB command is `finish'.
|
7247 |
|
|
|
7248 |
|
|
Example
|
7249 |
|
|
.......
|
7250 |
|
|
|
7251 |
|
|
Function returning `void'.
|
7252 |
|
|
|
7253 |
|
|
-exec-finish
|
7254 |
|
|
^running
|
7255 |
|
|
(gdb)
|
7256 |
|
|
@hello from foo
|
7257 |
|
|
*stopped,reason="function-finished",frame={func="main",args=[],
|
7258 |
|
|
file="hello.c",fullname="/home/foo/bar/hello.c",line="7"}
|
7259 |
|
|
(gdb)
|
7260 |
|
|
|
7261 |
|
|
Function returning other than `void'. The name of the internal GDB
|
7262 |
|
|
variable storing the result is printed, together with the value itself.
|
7263 |
|
|
|
7264 |
|
|
-exec-finish
|
7265 |
|
|
^running
|
7266 |
|
|
(gdb)
|
7267 |
|
|
*stopped,reason="function-finished",frame={addr="0x000107b0",func="foo",
|
7268 |
|
|
args=[{name="a",value="1"],{name="b",value="9"}},
|
7269 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7270 |
|
|
gdb-result-var="$1",return-value="0"
|
7271 |
|
|
(gdb)
|
7272 |
|
|
|
7273 |
|
|
The `-exec-interrupt' Command
|
7274 |
|
|
-----------------------------
|
7275 |
|
|
|
7276 |
|
|
Synopsis
|
7277 |
|
|
........
|
7278 |
|
|
|
7279 |
|
|
-exec-interrupt [--all|--thread-group N]
|
7280 |
|
|
|
7281 |
|
|
Interrupts the background execution of the target. Note how the
|
7282 |
|
|
token associated with the stop message is the one for the execution
|
7283 |
|
|
command that has been interrupted. The token for the interrupt itself
|
7284 |
|
|
only appears in the `^done' output. If the user is trying to interrupt
|
7285 |
|
|
a non-running program, an error message will be printed.
|
7286 |
|
|
|
7287 |
|
|
Note that when asynchronous execution is enabled, this command is
|
7288 |
|
|
asynchronous just like other execution commands. That is, first the
|
7289 |
|
|
`^done' response will be printed, and the target stop will be reported
|
7290 |
|
|
after that using the `*stopped' notification.
|
7291 |
|
|
|
7292 |
|
|
In non-stop mode, only the context thread is interrupted by default.
|
7293 |
|
|
All threads (in all inferiors) will be interrupted if the `--all'
|
7294 |
|
|
option is specified. If the `--thread-group' option is specified, all
|
7295 |
|
|
threads in that group will be interrupted.
|
7296 |
|
|
|
7297 |
|
|
GDB Command
|
7298 |
|
|
...........
|
7299 |
|
|
|
7300 |
|
|
The corresponding GDB command is `interrupt'.
|
7301 |
|
|
|
7302 |
|
|
Example
|
7303 |
|
|
.......
|
7304 |
|
|
|
7305 |
|
|
(gdb)
|
7306 |
|
|
111-exec-continue
|
7307 |
|
|
111^running
|
7308 |
|
|
|
7309 |
|
|
(gdb)
|
7310 |
|
|
222-exec-interrupt
|
7311 |
|
|
222^done
|
7312 |
|
|
(gdb)
|
7313 |
|
|
111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
|
7314 |
|
|
frame={addr="0x00010140",func="foo",args=[],file="try.c",
|
7315 |
|
|
fullname="/home/foo/bar/try.c",line="13"}
|
7316 |
|
|
(gdb)
|
7317 |
|
|
|
7318 |
|
|
(gdb)
|
7319 |
|
|
-exec-interrupt
|
7320 |
|
|
^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
|
7321 |
|
|
(gdb)
|
7322 |
|
|
|
7323 |
|
|
The `-exec-jump' Command
|
7324 |
|
|
------------------------
|
7325 |
|
|
|
7326 |
|
|
Synopsis
|
7327 |
|
|
........
|
7328 |
|
|
|
7329 |
|
|
-exec-jump LOCATION
|
7330 |
|
|
|
7331 |
|
|
Resumes execution of the inferior program at the location specified
|
7332 |
|
|
by parameter. *Note Specify Location::, for a description of the
|
7333 |
|
|
different forms of LOCATION.
|
7334 |
|
|
|
7335 |
|
|
GDB Command
|
7336 |
|
|
...........
|
7337 |
|
|
|
7338 |
|
|
The corresponding GDB command is `jump'.
|
7339 |
|
|
|
7340 |
|
|
Example
|
7341 |
|
|
.......
|
7342 |
|
|
|
7343 |
|
|
-exec-jump foo.c:10
|
7344 |
|
|
*running,thread-id="all"
|
7345 |
|
|
^running
|
7346 |
|
|
|
7347 |
|
|
The `-exec-next' Command
|
7348 |
|
|
------------------------
|
7349 |
|
|
|
7350 |
|
|
Synopsis
|
7351 |
|
|
........
|
7352 |
|
|
|
7353 |
|
|
-exec-next [--reverse]
|
7354 |
|
|
|
7355 |
|
|
Resumes execution of the inferior program, stopping when the
|
7356 |
|
|
beginning of the next source line is reached.
|
7357 |
|
|
|
7358 |
|
|
If the `--reverse' option is specified, resumes reverse execution of
|
7359 |
|
|
the inferior program, stopping at the beginning of the previous source
|
7360 |
|
|
line. If you issue this command on the first line of a function, it
|
7361 |
|
|
will take you back to the caller of that function, to the source line
|
7362 |
|
|
where the function was called.
|
7363 |
|
|
|
7364 |
|
|
GDB Command
|
7365 |
|
|
...........
|
7366 |
|
|
|
7367 |
|
|
The corresponding GDB command is `next'.
|
7368 |
|
|
|
7369 |
|
|
Example
|
7370 |
|
|
.......
|
7371 |
|
|
|
7372 |
|
|
-exec-next
|
7373 |
|
|
^running
|
7374 |
|
|
(gdb)
|
7375 |
|
|
*stopped,reason="end-stepping-range",line="8",file="hello.c"
|
7376 |
|
|
(gdb)
|
7377 |
|
|
|
7378 |
|
|
The `-exec-next-instruction' Command
|
7379 |
|
|
------------------------------------
|
7380 |
|
|
|
7381 |
|
|
Synopsis
|
7382 |
|
|
........
|
7383 |
|
|
|
7384 |
|
|
-exec-next-instruction [--reverse]
|
7385 |
|
|
|
7386 |
|
|
Executes one machine instruction. If the instruction is a function
|
7387 |
|
|
call, continues until the function returns. If the program stops at an
|
7388 |
|
|
instruction in the middle of a source line, the address will be printed
|
7389 |
|
|
as well.
|
7390 |
|
|
|
7391 |
|
|
If the `--reverse' option is specified, resumes reverse execution of
|
7392 |
|
|
the inferior program, stopping at the previous instruction. If the
|
7393 |
|
|
previously executed instruction was a return from another function, it
|
7394 |
|
|
will continue to execute in reverse until the call to that function
|
7395 |
|
|
(from the current stack frame) is reached.
|
7396 |
|
|
|
7397 |
|
|
GDB Command
|
7398 |
|
|
...........
|
7399 |
|
|
|
7400 |
|
|
The corresponding GDB command is `nexti'.
|
7401 |
|
|
|
7402 |
|
|
Example
|
7403 |
|
|
.......
|
7404 |
|
|
|
7405 |
|
|
(gdb)
|
7406 |
|
|
-exec-next-instruction
|
7407 |
|
|
^running
|
7408 |
|
|
|
7409 |
|
|
(gdb)
|
7410 |
|
|
*stopped,reason="end-stepping-range",
|
7411 |
|
|
addr="0x000100d4",line="5",file="hello.c"
|
7412 |
|
|
(gdb)
|
7413 |
|
|
|
7414 |
|
|
The `-exec-return' Command
|
7415 |
|
|
--------------------------
|
7416 |
|
|
|
7417 |
|
|
Synopsis
|
7418 |
|
|
........
|
7419 |
|
|
|
7420 |
|
|
-exec-return
|
7421 |
|
|
|
7422 |
|
|
Makes current function return immediately. Doesn't execute the
|
7423 |
|
|
inferior. Displays the new current frame.
|
7424 |
|
|
|
7425 |
|
|
GDB Command
|
7426 |
|
|
...........
|
7427 |
|
|
|
7428 |
|
|
The corresponding GDB command is `return'.
|
7429 |
|
|
|
7430 |
|
|
Example
|
7431 |
|
|
.......
|
7432 |
|
|
|
7433 |
|
|
(gdb)
|
7434 |
|
|
200-break-insert callee4
|
7435 |
|
|
200^done,bkpt={number="1",addr="0x00010734",
|
7436 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
|
7437 |
|
|
(gdb)
|
7438 |
|
|
000-exec-run
|
7439 |
|
|
000^running
|
7440 |
|
|
(gdb)
|
7441 |
|
|
000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
|
7442 |
|
|
frame={func="callee4",args=[],
|
7443 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7444 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
|
7445 |
|
|
(gdb)
|
7446 |
|
|
205-break-delete
|
7447 |
|
|
205^done
|
7448 |
|
|
(gdb)
|
7449 |
|
|
111-exec-return
|
7450 |
|
|
111^done,frame={level="0",func="callee3",
|
7451 |
|
|
args=[{name="strarg",
|
7452 |
|
|
value="0x11940 \"A string argument.\""}],
|
7453 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7454 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
|
7455 |
|
|
(gdb)
|
7456 |
|
|
|
7457 |
|
|
The `-exec-run' Command
|
7458 |
|
|
-----------------------
|
7459 |
|
|
|
7460 |
|
|
Synopsis
|
7461 |
|
|
........
|
7462 |
|
|
|
7463 |
|
|
-exec-run [--all | --thread-group N]
|
7464 |
|
|
|
7465 |
|
|
Starts execution of the inferior from the beginning. The inferior
|
7466 |
|
|
executes until either a breakpoint is encountered or the program exits.
|
7467 |
342 |
jeremybenn |
In the latter case the output will include an exit code, if the program
|
7468 |
|
|
has exited exceptionally.
|
7469 |
330 |
jeremybenn |
|
7470 |
|
|
When no option is specified, the current inferior is started. If the
|
7471 |
|
|
`--thread-group' option is specified, it should refer to a thread group
|
7472 |
|
|
of type `process', and that thread group will be started. If the
|
7473 |
|
|
`--all' option is specified, then all inferiors will be started.
|
7474 |
|
|
|
7475 |
|
|
GDB Command
|
7476 |
|
|
...........
|
7477 |
|
|
|
7478 |
|
|
The corresponding GDB command is `run'.
|
7479 |
|
|
|
7480 |
|
|
Examples
|
7481 |
|
|
........
|
7482 |
|
|
|
7483 |
|
|
(gdb)
|
7484 |
|
|
-break-insert main
|
7485 |
|
|
^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"}
|
7486 |
|
|
(gdb)
|
7487 |
|
|
-exec-run
|
7488 |
|
|
^running
|
7489 |
|
|
(gdb)
|
7490 |
|
|
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
|
7491 |
|
|
frame={func="main",args=[],file="recursive2.c",
|
7492 |
|
|
fullname="/home/foo/bar/recursive2.c",line="4"}
|
7493 |
|
|
(gdb)
|
7494 |
|
|
|
7495 |
|
|
Program exited normally:
|
7496 |
|
|
|
7497 |
|
|
(gdb)
|
7498 |
|
|
-exec-run
|
7499 |
|
|
^running
|
7500 |
|
|
(gdb)
|
7501 |
|
|
x = 55
|
7502 |
|
|
*stopped,reason="exited-normally"
|
7503 |
|
|
(gdb)
|
7504 |
|
|
|
7505 |
|
|
Program exited exceptionally:
|
7506 |
|
|
|
7507 |
|
|
(gdb)
|
7508 |
|
|
-exec-run
|
7509 |
|
|
^running
|
7510 |
|
|
(gdb)
|
7511 |
|
|
x = 55
|
7512 |
|
|
*stopped,reason="exited",exit-code="01"
|
7513 |
|
|
(gdb)
|
7514 |
|
|
|
7515 |
|
|
Another way the program can terminate is if it receives a signal
|
7516 |
|
|
such as `SIGINT'. In this case, GDB/MI displays this:
|
7517 |
|
|
|
7518 |
|
|
(gdb)
|
7519 |
|
|
*stopped,reason="exited-signalled",signal-name="SIGINT",
|
7520 |
|
|
signal-meaning="Interrupt"
|
7521 |
|
|
|
7522 |
|
|
The `-exec-step' Command
|
7523 |
|
|
------------------------
|
7524 |
|
|
|
7525 |
|
|
Synopsis
|
7526 |
|
|
........
|
7527 |
|
|
|
7528 |
|
|
-exec-step [--reverse]
|
7529 |
|
|
|
7530 |
|
|
Resumes execution of the inferior program, stopping when the
|
7531 |
|
|
beginning of the next source line is reached, if the next source line
|
7532 |
|
|
is not a function call. If it is, stop at the first instruction of the
|
7533 |
|
|
called function. If the `--reverse' option is specified, resumes
|
7534 |
|
|
reverse execution of the inferior program, stopping at the beginning of
|
7535 |
|
|
the previously executed source line.
|
7536 |
|
|
|
7537 |
|
|
GDB Command
|
7538 |
|
|
...........
|
7539 |
|
|
|
7540 |
|
|
The corresponding GDB command is `step'.
|
7541 |
|
|
|
7542 |
|
|
Example
|
7543 |
|
|
.......
|
7544 |
|
|
|
7545 |
|
|
Stepping into a function:
|
7546 |
|
|
|
7547 |
|
|
-exec-step
|
7548 |
|
|
^running
|
7549 |
|
|
(gdb)
|
7550 |
|
|
*stopped,reason="end-stepping-range",
|
7551 |
|
|
frame={func="foo",args=[{name="a",value="10"},
|
7552 |
|
|
{name="b",value="0"}],file="recursive2.c",
|
7553 |
|
|
fullname="/home/foo/bar/recursive2.c",line="11"}
|
7554 |
|
|
(gdb)
|
7555 |
|
|
|
7556 |
|
|
Regular stepping:
|
7557 |
|
|
|
7558 |
|
|
-exec-step
|
7559 |
|
|
^running
|
7560 |
|
|
(gdb)
|
7561 |
|
|
*stopped,reason="end-stepping-range",line="14",file="recursive2.c"
|
7562 |
|
|
(gdb)
|
7563 |
|
|
|
7564 |
|
|
The `-exec-step-instruction' Command
|
7565 |
|
|
------------------------------------
|
7566 |
|
|
|
7567 |
|
|
Synopsis
|
7568 |
|
|
........
|
7569 |
|
|
|
7570 |
|
|
-exec-step-instruction [--reverse]
|
7571 |
|
|
|
7572 |
|
|
Resumes the inferior which executes one machine instruction. If the
|
7573 |
|
|
`--reverse' option is specified, resumes reverse execution of the
|
7574 |
|
|
inferior program, stopping at the previously executed instruction. The
|
7575 |
|
|
output, once GDB has stopped, will vary depending on whether we have
|
7576 |
|
|
stopped in the middle of a source line or not. In the former case, the
|
7577 |
|
|
address at which the program stopped will be printed as well.
|
7578 |
|
|
|
7579 |
|
|
GDB Command
|
7580 |
|
|
...........
|
7581 |
|
|
|
7582 |
|
|
The corresponding GDB command is `stepi'.
|
7583 |
|
|
|
7584 |
|
|
Example
|
7585 |
|
|
.......
|
7586 |
|
|
|
7587 |
|
|
(gdb)
|
7588 |
|
|
-exec-step-instruction
|
7589 |
|
|
^running
|
7590 |
|
|
|
7591 |
|
|
(gdb)
|
7592 |
|
|
*stopped,reason="end-stepping-range",
|
7593 |
|
|
frame={func="foo",args=[],file="try.c",
|
7594 |
|
|
fullname="/home/foo/bar/try.c",line="10"}
|
7595 |
|
|
(gdb)
|
7596 |
|
|
-exec-step-instruction
|
7597 |
|
|
^running
|
7598 |
|
|
|
7599 |
|
|
(gdb)
|
7600 |
|
|
*stopped,reason="end-stepping-range",
|
7601 |
|
|
frame={addr="0x000100f4",func="foo",args=[],file="try.c",
|
7602 |
|
|
fullname="/home/foo/bar/try.c",line="10"}
|
7603 |
|
|
(gdb)
|
7604 |
|
|
|
7605 |
|
|
The `-exec-until' Command
|
7606 |
|
|
-------------------------
|
7607 |
|
|
|
7608 |
|
|
Synopsis
|
7609 |
|
|
........
|
7610 |
|
|
|
7611 |
|
|
-exec-until [ LOCATION ]
|
7612 |
|
|
|
7613 |
|
|
Executes the inferior until the LOCATION specified in the argument
|
7614 |
|
|
is reached. If there is no argument, the inferior executes until a
|
7615 |
|
|
source line greater than the current one is reached. The reason for
|
7616 |
|
|
stopping in this case will be `location-reached'.
|
7617 |
|
|
|
7618 |
|
|
GDB Command
|
7619 |
|
|
...........
|
7620 |
|
|
|
7621 |
|
|
The corresponding GDB command is `until'.
|
7622 |
|
|
|
7623 |
|
|
Example
|
7624 |
|
|
.......
|
7625 |
|
|
|
7626 |
|
|
(gdb)
|
7627 |
|
|
-exec-until recursive2.c:6
|
7628 |
|
|
^running
|
7629 |
|
|
(gdb)
|
7630 |
|
|
x = 55
|
7631 |
|
|
*stopped,reason="location-reached",frame={func="main",args=[],
|
7632 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6"}
|
7633 |
|
|
(gdb)
|
7634 |
|
|
|
7635 |
|
|
|
7636 |
|
|
File: gdb.info, Node: GDB/MI Stack Manipulation, Next: GDB/MI Variable Objects, Prev: GDB/MI Program Execution, Up: GDB/MI
|
7637 |
|
|
|
7638 |
|
|
27.12 GDB/MI Stack Manipulation Commands
|
7639 |
|
|
========================================
|
7640 |
|
|
|
7641 |
|
|
The `-stack-info-frame' Command
|
7642 |
|
|
-------------------------------
|
7643 |
|
|
|
7644 |
|
|
Synopsis
|
7645 |
|
|
........
|
7646 |
|
|
|
7647 |
|
|
-stack-info-frame
|
7648 |
|
|
|
7649 |
|
|
Get info on the selected frame.
|
7650 |
|
|
|
7651 |
|
|
GDB Command
|
7652 |
|
|
...........
|
7653 |
|
|
|
7654 |
|
|
The corresponding GDB command is `info frame' or `frame' (without
|
7655 |
|
|
arguments).
|
7656 |
|
|
|
7657 |
|
|
Example
|
7658 |
|
|
.......
|
7659 |
|
|
|
7660 |
|
|
(gdb)
|
7661 |
|
|
-stack-info-frame
|
7662 |
|
|
^done,frame={level="1",addr="0x0001076c",func="callee3",
|
7663 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7664 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"}
|
7665 |
|
|
(gdb)
|
7666 |
|
|
|
7667 |
|
|
The `-stack-info-depth' Command
|
7668 |
|
|
-------------------------------
|
7669 |
|
|
|
7670 |
|
|
Synopsis
|
7671 |
|
|
........
|
7672 |
|
|
|
7673 |
|
|
-stack-info-depth [ MAX-DEPTH ]
|
7674 |
|
|
|
7675 |
|
|
Return the depth of the stack. If the integer argument MAX-DEPTH is
|
7676 |
|
|
specified, do not count beyond MAX-DEPTH frames.
|
7677 |
|
|
|
7678 |
|
|
GDB Command
|
7679 |
|
|
...........
|
7680 |
|
|
|
7681 |
|
|
There's no equivalent GDB command.
|
7682 |
|
|
|
7683 |
|
|
Example
|
7684 |
|
|
.......
|
7685 |
|
|
|
7686 |
|
|
For a stack with frame levels 0 through 11:
|
7687 |
|
|
|
7688 |
|
|
(gdb)
|
7689 |
|
|
-stack-info-depth
|
7690 |
|
|
^done,depth="12"
|
7691 |
|
|
(gdb)
|
7692 |
|
|
-stack-info-depth 4
|
7693 |
|
|
^done,depth="4"
|
7694 |
|
|
(gdb)
|
7695 |
|
|
-stack-info-depth 12
|
7696 |
|
|
^done,depth="12"
|
7697 |
|
|
(gdb)
|
7698 |
|
|
-stack-info-depth 11
|
7699 |
|
|
^done,depth="11"
|
7700 |
|
|
(gdb)
|
7701 |
|
|
-stack-info-depth 13
|
7702 |
|
|
^done,depth="12"
|
7703 |
|
|
(gdb)
|
7704 |
|
|
|
7705 |
|
|
The `-stack-list-arguments' Command
|
7706 |
|
|
-----------------------------------
|
7707 |
|
|
|
7708 |
|
|
Synopsis
|
7709 |
|
|
........
|
7710 |
|
|
|
7711 |
|
|
-stack-list-arguments PRINT-VALUES
|
7712 |
|
|
[ LOW-FRAME HIGH-FRAME ]
|
7713 |
|
|
|
7714 |
|
|
Display a list of the arguments for the frames between LOW-FRAME and
|
7715 |
|
|
HIGH-FRAME (inclusive). If LOW-FRAME and HIGH-FRAME are not provided,
|
7716 |
|
|
list the arguments for the whole call stack. If the two arguments are
|
7717 |
|
|
equal, show the single frame at the corresponding level. It is an
|
7718 |
|
|
error if LOW-FRAME is larger than the actual number of frames. On the
|
7719 |
|
|
other hand, HIGH-FRAME may be larger than the actual number of frames,
|
7720 |
|
|
in which case only existing frames will be returned.
|
7721 |
|
|
|
7722 |
|
|
If PRINT-VALUES is 0 or `--no-values', print only the names of the
|
7723 |
|
|
variables; if it is 1 or `--all-values', print also their values; and
|
7724 |
|
|
if it is 2 or `--simple-values', print the name, type and value for
|
7725 |
|
|
simple data types, and the name and type for arrays, structures and
|
7726 |
|
|
unions.
|
7727 |
|
|
|
7728 |
|
|
Use of this command to obtain arguments in a single frame is
|
7729 |
|
|
deprecated in favor of the `-stack-list-variables' command.
|
7730 |
|
|
|
7731 |
|
|
GDB Command
|
7732 |
|
|
...........
|
7733 |
|
|
|
7734 |
|
|
GDB does not have an equivalent command. `gdbtk' has a `gdb_get_args'
|
7735 |
|
|
command which partially overlaps with the functionality of
|
7736 |
|
|
`-stack-list-arguments'.
|
7737 |
|
|
|
7738 |
|
|
Example
|
7739 |
|
|
.......
|
7740 |
|
|
|
7741 |
|
|
(gdb)
|
7742 |
|
|
-stack-list-frames
|
7743 |
|
|
^done,
|
7744 |
|
|
stack=[
|
7745 |
|
|
frame={level="0",addr="0x00010734",func="callee4",
|
7746 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7747 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"},
|
7748 |
|
|
frame={level="1",addr="0x0001076c",func="callee3",
|
7749 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7750 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"},
|
7751 |
|
|
frame={level="2",addr="0x0001078c",func="callee2",
|
7752 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7753 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"},
|
7754 |
|
|
frame={level="3",addr="0x000107b4",func="callee1",
|
7755 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7756 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"},
|
7757 |
|
|
frame={level="4",addr="0x000107e0",func="main",
|
7758 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
7759 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"}]
|
7760 |
|
|
(gdb)
|
7761 |
|
|
-stack-list-arguments 0
|
7762 |
|
|
^done,
|
7763 |
|
|
stack-args=[
|
7764 |
|
|
frame={level="0",args=[]},
|
7765 |
|
|
frame={level="1",args=[name="strarg"]},
|
7766 |
|
|
frame={level="2",args=[name="intarg",name="strarg"]},
|
7767 |
|
|
frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]},
|
7768 |
|
|
frame={level="4",args=[]}]
|
7769 |
|
|
(gdb)
|
7770 |
|
|
-stack-list-arguments 1
|
7771 |
|
|
^done,
|
7772 |
|
|
stack-args=[
|
7773 |
|
|
frame={level="0",args=[]},
|
7774 |
|
|
frame={level="1",
|
7775 |
|
|
args=[{name="strarg",value="0x11940 \"A string argument.\""}]},
|
7776 |
|
|
frame={level="2",args=[
|
7777 |
|
|
{name="intarg",value="2"},
|
7778 |
|
|
{name="strarg",value="0x11940 \"A string argument.\""}]},
|
7779 |
|
|
{frame={level="3",args=[
|
7780 |
|
|
{name="intarg",value="2"},
|
7781 |
|
|
{name="strarg",value="0x11940 \"A string argument.\""},
|
7782 |
|
|
{name="fltarg",value="3.5"}]},
|
7783 |
|
|
frame={level="4",args=[]}]
|
7784 |
|
|
(gdb)
|
7785 |
|
|
-stack-list-arguments 0 2 2
|
7786 |
|
|
^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}]
|
7787 |
|
|
(gdb)
|
7788 |
|
|
-stack-list-arguments 1 2 2
|
7789 |
|
|
^done,stack-args=[frame={level="2",
|
7790 |
|
|
args=[{name="intarg",value="2"},
|
7791 |
|
|
{name="strarg",value="0x11940 \"A string argument.\""}]}]
|
7792 |
|
|
(gdb)
|
7793 |
|
|
|
7794 |
|
|
The `-stack-list-frames' Command
|
7795 |
|
|
--------------------------------
|
7796 |
|
|
|
7797 |
|
|
Synopsis
|
7798 |
|
|
........
|
7799 |
|
|
|
7800 |
|
|
-stack-list-frames [ LOW-FRAME HIGH-FRAME ]
|
7801 |
|
|
|
7802 |
|
|
List the frames currently on the stack. For each frame it displays
|
7803 |
|
|
the following info:
|
7804 |
|
|
|
7805 |
|
|
`LEVEL'
|
7806 |
|
|
The frame number, 0 being the topmost frame, i.e., the innermost
|
7807 |
|
|
function.
|
7808 |
|
|
|
7809 |
|
|
`ADDR'
|
7810 |
|
|
The `$pc' value for that frame.
|
7811 |
|
|
|
7812 |
|
|
`FUNC'
|
7813 |
|
|
Function name.
|
7814 |
|
|
|
7815 |
|
|
`FILE'
|
7816 |
|
|
File name of the source file where the function lives.
|
7817 |
|
|
|
7818 |
|
|
`LINE'
|
7819 |
|
|
Line number corresponding to the `$pc'.
|
7820 |
|
|
|
7821 |
|
|
If invoked without arguments, this command prints a backtrace for the
|
7822 |
|
|
whole stack. If given two integer arguments, it shows the frames whose
|
7823 |
|
|
levels are between the two arguments (inclusive). If the two arguments
|
7824 |
|
|
are equal, it shows the single frame at the corresponding level. It is
|
7825 |
|
|
an error if LOW-FRAME is larger than the actual number of frames. On
|
7826 |
|
|
the other hand, HIGH-FRAME may be larger than the actual number of
|
7827 |
|
|
frames, in which case only existing frames will be returned.
|
7828 |
|
|
|
7829 |
|
|
GDB Command
|
7830 |
|
|
...........
|
7831 |
|
|
|
7832 |
|
|
The corresponding GDB commands are `backtrace' and `where'.
|
7833 |
|
|
|
7834 |
|
|
Example
|
7835 |
|
|
.......
|
7836 |
|
|
|
7837 |
|
|
Full stack backtrace:
|
7838 |
|
|
|
7839 |
|
|
(gdb)
|
7840 |
|
|
-stack-list-frames
|
7841 |
|
|
^done,stack=
|
7842 |
|
|
[frame={level="0",addr="0x0001076c",func="foo",
|
7843 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11"},
|
7844 |
|
|
frame={level="1",addr="0x000107a4",func="foo",
|
7845 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7846 |
|
|
frame={level="2",addr="0x000107a4",func="foo",
|
7847 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7848 |
|
|
frame={level="3",addr="0x000107a4",func="foo",
|
7849 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7850 |
|
|
frame={level="4",addr="0x000107a4",func="foo",
|
7851 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7852 |
|
|
frame={level="5",addr="0x000107a4",func="foo",
|
7853 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7854 |
|
|
frame={level="6",addr="0x000107a4",func="foo",
|
7855 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7856 |
|
|
frame={level="7",addr="0x000107a4",func="foo",
|
7857 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7858 |
|
|
frame={level="8",addr="0x000107a4",func="foo",
|
7859 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7860 |
|
|
frame={level="9",addr="0x000107a4",func="foo",
|
7861 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7862 |
|
|
frame={level="10",addr="0x000107a4",func="foo",
|
7863 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7864 |
|
|
frame={level="11",addr="0x00010738",func="main",
|
7865 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4"}]
|
7866 |
|
|
(gdb)
|
7867 |
|
|
|
7868 |
|
|
Show frames between LOW_FRAME and HIGH_FRAME:
|
7869 |
|
|
|
7870 |
|
|
(gdb)
|
7871 |
|
|
-stack-list-frames 3 5
|
7872 |
|
|
^done,stack=
|
7873 |
|
|
[frame={level="3",addr="0x000107a4",func="foo",
|
7874 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7875 |
|
|
frame={level="4",addr="0x000107a4",func="foo",
|
7876 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
7877 |
|
|
frame={level="5",addr="0x000107a4",func="foo",
|
7878 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
|
7879 |
|
|
(gdb)
|
7880 |
|
|
|
7881 |
|
|
Show a single frame:
|
7882 |
|
|
|
7883 |
|
|
(gdb)
|
7884 |
|
|
-stack-list-frames 3 3
|
7885 |
|
|
^done,stack=
|
7886 |
|
|
[frame={level="3",addr="0x000107a4",func="foo",
|
7887 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
|
7888 |
|
|
(gdb)
|
7889 |
|
|
|
7890 |
|
|
The `-stack-list-locals' Command
|
7891 |
|
|
--------------------------------
|
7892 |
|
|
|
7893 |
|
|
Synopsis
|
7894 |
|
|
........
|
7895 |
|
|
|
7896 |
|
|
-stack-list-locals PRINT-VALUES
|
7897 |
|
|
|
7898 |
|
|
Display the local variable names for the selected frame. If
|
7899 |
|
|
PRINT-VALUES is 0 or `--no-values', print only the names of the
|
7900 |
|
|
variables; if it is 1 or `--all-values', print also their values; and
|
7901 |
|
|
if it is 2 or `--simple-values', print the name, type and value for
|
7902 |
|
|
simple data types, and the name and type for arrays, structures and
|
7903 |
|
|
unions. In this last case, a frontend can immediately display the
|
7904 |
|
|
value of simple data types and create variable objects for other data
|
7905 |
|
|
types when the user wishes to explore their values in more detail.
|
7906 |
|
|
|
7907 |
|
|
This command is deprecated in favor of the `-stack-list-variables'
|
7908 |
|
|
command.
|
7909 |
|
|
|
7910 |
|
|
GDB Command
|
7911 |
|
|
...........
|
7912 |
|
|
|
7913 |
|
|
`info locals' in GDB, `gdb_get_locals' in `gdbtk'.
|
7914 |
|
|
|
7915 |
|
|
Example
|
7916 |
|
|
.......
|
7917 |
|
|
|
7918 |
|
|
(gdb)
|
7919 |
|
|
-stack-list-locals 0
|
7920 |
|
|
^done,locals=[name="A",name="B",name="C"]
|
7921 |
|
|
(gdb)
|
7922 |
|
|
-stack-list-locals --all-values
|
7923 |
|
|
^done,locals=[{name="A",value="1"},{name="B",value="2"},
|
7924 |
|
|
{name="C",value="{1, 2, 3}"}]
|
7925 |
|
|
-stack-list-locals --simple-values
|
7926 |
|
|
^done,locals=[{name="A",type="int",value="1"},
|
7927 |
|
|
{name="B",type="int",value="2"},{name="C",type="int [3]"}]
|
7928 |
|
|
(gdb)
|
7929 |
|
|
|
7930 |
|
|
The `-stack-list-variables' Command
|
7931 |
|
|
-----------------------------------
|
7932 |
|
|
|
7933 |
|
|
Synopsis
|
7934 |
|
|
........
|
7935 |
|
|
|
7936 |
|
|
-stack-list-variables PRINT-VALUES
|
7937 |
|
|
|
7938 |
|
|
Display the names of local variables and function arguments for the
|
7939 |
|
|
selected frame. If PRINT-VALUES is 0 or `--no-values', print only the
|
7940 |
|
|
names of the variables; if it is 1 or `--all-values', print also their
|
7941 |
|
|
values; and if it is 2 or `--simple-values', print the name, type and
|
7942 |
|
|
value for simple data types, and the name and type for arrays,
|
7943 |
|
|
structures and unions.
|
7944 |
|
|
|
7945 |
|
|
Example
|
7946 |
|
|
.......
|
7947 |
|
|
|
7948 |
|
|
(gdb)
|
7949 |
|
|
-stack-list-variables --thread 1 --frame 0 --all-values
|
7950 |
|
|
^done,variables=[{name="x",value="11"},{name="s",value="{a = 1, b = 2}"}]
|
7951 |
|
|
(gdb)
|
7952 |
|
|
|
7953 |
|
|
The `-stack-select-frame' Command
|
7954 |
|
|
---------------------------------
|
7955 |
|
|
|
7956 |
|
|
Synopsis
|
7957 |
|
|
........
|
7958 |
|
|
|
7959 |
|
|
-stack-select-frame FRAMENUM
|
7960 |
|
|
|
7961 |
|
|
Change the selected frame. Select a different frame FRAMENUM on the
|
7962 |
|
|
stack.
|
7963 |
|
|
|
7964 |
|
|
This command in deprecated in favor of passing the `--frame' option
|
7965 |
|
|
to every command.
|
7966 |
|
|
|
7967 |
|
|
GDB Command
|
7968 |
|
|
...........
|
7969 |
|
|
|
7970 |
|
|
The corresponding GDB commands are `frame', `up', `down',
|
7971 |
|
|
`select-frame', `up-silent', and `down-silent'.
|
7972 |
|
|
|
7973 |
|
|
Example
|
7974 |
|
|
.......
|
7975 |
|
|
|
7976 |
|
|
(gdb)
|
7977 |
|
|
-stack-select-frame 2
|
7978 |
|
|
^done
|
7979 |
|
|
(gdb)
|
7980 |
|
|
|
7981 |
|
|
|
7982 |
|
|
File: gdb.info, Node: GDB/MI Variable Objects, Next: GDB/MI Data Manipulation, Prev: GDB/MI Stack Manipulation, Up: GDB/MI
|
7983 |
|
|
|
7984 |
|
|
27.13 GDB/MI Variable Objects
|
7985 |
|
|
=============================
|
7986 |
|
|
|
7987 |
|
|
Introduction to Variable Objects
|
7988 |
|
|
--------------------------------
|
7989 |
|
|
|
7990 |
|
|
Variable objects are "object-oriented" MI interface for examining and
|
7991 |
|
|
changing values of expressions. Unlike some other MI interfaces that
|
7992 |
|
|
work with expressions, variable objects are specifically designed for
|
7993 |
|
|
simple and efficient presentation in the frontend. A variable object
|
7994 |
|
|
is identified by string name. When a variable object is created, the
|
7995 |
|
|
frontend specifies the expression for that variable object. The
|
7996 |
|
|
expression can be a simple variable, or it can be an arbitrary complex
|
7997 |
|
|
expression, and can even involve CPU registers. After creating a
|
7998 |
|
|
variable object, the frontend can invoke other variable object
|
7999 |
|
|
operations--for example to obtain or change the value of a variable
|
8000 |
|
|
object, or to change display format.
|
8001 |
|
|
|
8002 |
|
|
Variable objects have hierarchical tree structure. Any variable
|
8003 |
|
|
object that corresponds to a composite type, such as structure in C, has
|
8004 |
|
|
a number of child variable objects, for example corresponding to each
|
8005 |
|
|
element of a structure. A child variable object can itself have
|
8006 |
|
|
children, recursively. Recursion ends when we reach leaf variable
|
8007 |
|
|
objects, which always have built-in types. Child variable objects are
|
8008 |
|
|
created only by explicit request, so if a frontend is not interested in
|
8009 |
|
|
the children of a particular variable object, no child will be created.
|
8010 |
|
|
|
8011 |
|
|
For a leaf variable object it is possible to obtain its value as a
|
8012 |
|
|
string, or set the value from a string. String value can be also
|
8013 |
|
|
obtained for a non-leaf variable object, but it's generally a string
|
8014 |
|
|
that only indicates the type of the object, and does not list its
|
8015 |
|
|
contents. Assignment to a non-leaf variable object is not allowed.
|
8016 |
|
|
|
8017 |
|
|
A frontend does not need to read the values of all variable objects
|
8018 |
|
|
each time the program stops. Instead, MI provides an update command
|
8019 |
|
|
that lists all variable objects whose values has changed since the last
|
8020 |
|
|
update operation. This considerably reduces the amount of data that
|
8021 |
|
|
must be transferred to the frontend. As noted above, children variable
|
8022 |
|
|
objects are created on demand, and only leaf variable objects have a
|
8023 |
|
|
real value. As result, gdb will read target memory only for leaf
|
8024 |
|
|
variables that frontend has created.
|
8025 |
|
|
|
8026 |
|
|
The automatic update is not always desirable. For example, a
|
8027 |
|
|
frontend might want to keep a value of some expression for future
|
8028 |
|
|
reference, and never update it. For another example, fetching memory
|
8029 |
|
|
is relatively slow for embedded targets, so a frontend might want to
|
8030 |
|
|
disable automatic update for the variables that are either not visible
|
8031 |
|
|
on the screen, or "closed". This is possible using so called "frozen
|
8032 |
|
|
variable objects". Such variable objects are never implicitly updated.
|
8033 |
|
|
|
8034 |
|
|
Variable objects can be either "fixed" or "floating". For the fixed
|
8035 |
|
|
variable object, the expression is parsed when the variable object is
|
8036 |
|
|
created, including associating identifiers to specific variables. The
|
8037 |
|
|
meaning of expression never changes. For a floating variable object
|
8038 |
|
|
the values of variables whose names appear in the expressions are
|
8039 |
|
|
re-evaluated every time in the context of the current frame. Consider
|
8040 |
|
|
this example:
|
8041 |
|
|
|
8042 |
|
|
void do_work(...)
|
8043 |
|
|
{
|
8044 |
|
|
struct work_state state;
|
8045 |
|
|
|
8046 |
|
|
if (...)
|
8047 |
|
|
do_work(...);
|
8048 |
|
|
}
|
8049 |
|
|
|
8050 |
|
|
If a fixed variable object for the `state' variable is created in
|
8051 |
|
|
this function, and we enter the recursive call, the the variable object
|
8052 |
|
|
will report the value of `state' in the top-level `do_work' invocation.
|
8053 |
|
|
On the other hand, a floating variable object will report the value of
|
8054 |
|
|
`state' in the current frame.
|
8055 |
|
|
|
8056 |
|
|
If an expression specified when creating a fixed variable object
|
8057 |
|
|
refers to a local variable, the variable object becomes bound to the
|
8058 |
|
|
thread and frame in which the variable object is created. When such
|
8059 |
|
|
variable object is updated, GDB makes sure that the thread/frame
|
8060 |
|
|
combination the variable object is bound to still exists, and
|
8061 |
|
|
re-evaluates the variable object in context of that thread/frame.
|
8062 |
|
|
|
8063 |
|
|
The following is the complete set of GDB/MI operations defined to
|
8064 |
|
|
access this functionality:
|
8065 |
|
|
|
8066 |
|
|
*Operation* *Description*
|
8067 |
|
|
`-enable-pretty-printing' enable Python-based pretty-printing
|
8068 |
|
|
`-var-create' create a variable object
|
8069 |
|
|
`-var-delete' delete the variable object and/or its
|
8070 |
|
|
children
|
8071 |
|
|
`-var-set-format' set the display format of this variable
|
8072 |
|
|
`-var-show-format' show the display format of this variable
|
8073 |
|
|
`-var-info-num-children' tells how many children this object has
|
8074 |
|
|
`-var-list-children' return a list of the object's children
|
8075 |
|
|
`-var-info-type' show the type of this variable object
|
8076 |
|
|
`-var-info-expression' print parent-relative expression that this
|
8077 |
|
|
variable object represents
|
8078 |
|
|
`-var-info-path-expression' print full expression that this variable
|
8079 |
|
|
object represents
|
8080 |
|
|
`-var-show-attributes' is this variable editable? does it exist
|
8081 |
|
|
here?
|
8082 |
|
|
`-var-evaluate-expression' get the value of this variable
|
8083 |
|
|
`-var-assign' set the value of this variable
|
8084 |
|
|
`-var-update' update the variable and its children
|
8085 |
|
|
`-var-set-frozen' set frozeness attribute
|
8086 |
|
|
`-var-set-update-range' set range of children to display on update
|
8087 |
|
|
|
8088 |
|
|
In the next subsection we describe each operation in detail and
|
8089 |
|
|
suggest how it can be used.
|
8090 |
|
|
|
8091 |
|
|
Description And Use of Operations on Variable Objects
|
8092 |
|
|
-----------------------------------------------------
|
8093 |
|
|
|
8094 |
|
|
The `-enable-pretty-printing' Command
|
8095 |
|
|
-------------------------------------
|
8096 |
|
|
|
8097 |
|
|
-enable-pretty-printing
|
8098 |
|
|
|
8099 |
|
|
GDB allows Python-based visualizers to affect the output of the MI
|
8100 |
|
|
variable object commands. However, because there was no way to
|
8101 |
|
|
implement this in a fully backward-compatible way, a front end must
|
8102 |
|
|
request that this functionality be enabled.
|
8103 |
|
|
|
8104 |
|
|
Once enabled, this feature cannot be disabled.
|
8105 |
|
|
|
8106 |
|
|
Note that if Python support has not been compiled into GDB, this
|
8107 |
|
|
command will still succeed (and do nothing).
|
8108 |
|
|
|
8109 |
|
|
This feature is currently (as of GDB 7.0) experimental, and may work
|
8110 |
|
|
differently in future versions of GDB.
|
8111 |
|
|
|
8112 |
|
|
The `-var-create' Command
|
8113 |
|
|
-------------------------
|
8114 |
|
|
|
8115 |
|
|
Synopsis
|
8116 |
|
|
........
|
8117 |
|
|
|
8118 |
|
|
-var-create {NAME | "-"}
|
8119 |
|
|
{FRAME-ADDR | "*" | "@"} EXPRESSION
|
8120 |
|
|
|
8121 |
|
|
This operation creates a variable object, which allows the
|
8122 |
|
|
monitoring of a variable, the result of an expression, a memory cell or
|
8123 |
|
|
a CPU register.
|
8124 |
|
|
|
8125 |
|
|
The NAME parameter is the string by which the object can be
|
8126 |
|
|
referenced. It must be unique. If `-' is specified, the varobj system
|
8127 |
|
|
will generate a string "varNNNNNN" automatically. It will be unique
|
8128 |
|
|
provided that one does not specify NAME of that format. The command
|
8129 |
|
|
fails if a duplicate name is found.
|
8130 |
|
|
|
8131 |
|
|
The frame under which the expression should be evaluated can be
|
8132 |
|
|
specified by FRAME-ADDR. A `*' indicates that the current frame should
|
8133 |
|
|
be used. A `@' indicates that a floating variable object must be
|
8134 |
|
|
created.
|
8135 |
|
|
|
8136 |
|
|
EXPRESSION is any expression valid on the current language set (must
|
8137 |
|
|
not begin with a `*'), or one of the following:
|
8138 |
|
|
|
8139 |
|
|
* `*ADDR', where ADDR is the address of a memory cell
|
8140 |
|
|
|
8141 |
|
|
* `*ADDR-ADDR' -- a memory address range (TBD)
|
8142 |
|
|
|
8143 |
|
|
* `$REGNAME' -- a CPU register name
|
8144 |
|
|
|
8145 |
|
|
A varobj's contents may be provided by a Python-based
|
8146 |
|
|
pretty-printer. In this case the varobj is known as a "dynamic
|
8147 |
|
|
varobj". Dynamic varobjs have slightly different semantics in some
|
8148 |
|
|
cases. If the `-enable-pretty-printing' command is not sent, then GDB
|
8149 |
|
|
will never create a dynamic varobj. This ensures backward
|
8150 |
|
|
compatibility for existing clients.
|
8151 |
|
|
|
8152 |
|
|
Result
|
8153 |
|
|
......
|
8154 |
|
|
|
8155 |
|
|
This operation returns attributes of the newly-created varobj. These
|
8156 |
|
|
are:
|
8157 |
|
|
|
8158 |
|
|
`name'
|
8159 |
|
|
The name of the varobj.
|
8160 |
|
|
|
8161 |
|
|
`numchild'
|
8162 |
|
|
The number of children of the varobj. This number is not
|
8163 |
|
|
necessarily reliable for a dynamic varobj. Instead, you must
|
8164 |
|
|
examine the `has_more' attribute.
|
8165 |
|
|
|
8166 |
|
|
`value'
|
8167 |
|
|
The varobj's scalar value. For a varobj whose type is some sort of
|
8168 |
|
|
aggregate (e.g., a `struct'), or for a dynamic varobj, this value
|
8169 |
|
|
will not be interesting.
|
8170 |
|
|
|
8171 |
|
|
`type'
|
8172 |
|
|
The varobj's type. This is a string representation of the type, as
|
8173 |
|
|
would be printed by the GDB CLI.
|
8174 |
|
|
|
8175 |
|
|
`thread-id'
|
8176 |
|
|
If a variable object is bound to a specific thread, then this is
|
8177 |
|
|
the thread's identifier.
|
8178 |
|
|
|
8179 |
|
|
`has_more'
|
8180 |
|
|
For a dynamic varobj, this indicates whether there appear to be any
|
8181 |
|
|
children available. For a non-dynamic varobj, this will be 0.
|
8182 |
|
|
|
8183 |
|
|
`dynamic'
|
8184 |
|
|
This attribute will be present and have the value `1' if the
|
8185 |
|
|
varobj is a dynamic varobj. If the varobj is not a dynamic varobj,
|
8186 |
|
|
then this attribute will not be present.
|
8187 |
|
|
|
8188 |
|
|
`displayhint'
|
8189 |
|
|
A dynamic varobj can supply a display hint to the front end. The
|
8190 |
|
|
value comes directly from the Python pretty-printer object's
|
8191 |
|
|
`display_hint' method. *Note Pretty Printing API::.
|
8192 |
|
|
|
8193 |
|
|
Typical output will look like this:
|
8194 |
|
|
|
8195 |
|
|
name="NAME",numchild="N",type="TYPE",thread-id="M",
|
8196 |
|
|
has_more="HAS_MORE"
|
8197 |
|
|
|
8198 |
|
|
The `-var-delete' Command
|
8199 |
|
|
-------------------------
|
8200 |
|
|
|
8201 |
|
|
Synopsis
|
8202 |
|
|
........
|
8203 |
|
|
|
8204 |
|
|
-var-delete [ -c ] NAME
|
8205 |
|
|
|
8206 |
|
|
Deletes a previously created variable object and all of its children.
|
8207 |
|
|
With the `-c' option, just deletes the children.
|
8208 |
|
|
|
8209 |
|
|
Returns an error if the object NAME is not found.
|
8210 |
|
|
|
8211 |
|
|
The `-var-set-format' Command
|
8212 |
|
|
-----------------------------
|
8213 |
|
|
|
8214 |
|
|
Synopsis
|
8215 |
|
|
........
|
8216 |
|
|
|
8217 |
|
|
-var-set-format NAME FORMAT-SPEC
|
8218 |
|
|
|
8219 |
|
|
Sets the output format for the value of the object NAME to be
|
8220 |
|
|
FORMAT-SPEC.
|
8221 |
|
|
|
8222 |
|
|
The syntax for the FORMAT-SPEC is as follows:
|
8223 |
|
|
|
8224 |
|
|
FORMAT-SPEC ==>
|
8225 |
|
|
{binary | decimal | hexadecimal | octal | natural}
|
8226 |
|
|
|
8227 |
|
|
The natural format is the default format choosen automatically based
|
8228 |
|
|
on the variable type (like decimal for an `int', hex for pointers,
|
8229 |
|
|
etc.).
|
8230 |
|
|
|
8231 |
|
|
For a variable with children, the format is set only on the variable
|
8232 |
|
|
itself, and the children are not affected.
|
8233 |
|
|
|
8234 |
|
|
The `-var-show-format' Command
|
8235 |
|
|
------------------------------
|
8236 |
|
|
|
8237 |
|
|
Synopsis
|
8238 |
|
|
........
|
8239 |
|
|
|
8240 |
|
|
-var-show-format NAME
|
8241 |
|
|
|
8242 |
|
|
Returns the format used to display the value of the object NAME.
|
8243 |
|
|
|
8244 |
|
|
FORMAT ==>
|
8245 |
|
|
FORMAT-SPEC
|
8246 |
|
|
|
8247 |
|
|
The `-var-info-num-children' Command
|
8248 |
|
|
------------------------------------
|
8249 |
|
|
|
8250 |
|
|
Synopsis
|
8251 |
|
|
........
|
8252 |
|
|
|
8253 |
|
|
-var-info-num-children NAME
|
8254 |
|
|
|
8255 |
|
|
Returns the number of children of a variable object NAME:
|
8256 |
|
|
|
8257 |
|
|
numchild=N
|
8258 |
|
|
|
8259 |
|
|
Note that this number is not completely reliable for a dynamic
|
8260 |
|
|
varobj. It will return the current number of children, but more
|
8261 |
|
|
children may be available.
|
8262 |
|
|
|
8263 |
|
|
The `-var-list-children' Command
|
8264 |
|
|
--------------------------------
|
8265 |
|
|
|
8266 |
|
|
Synopsis
|
8267 |
|
|
........
|
8268 |
|
|
|
8269 |
|
|
-var-list-children [PRINT-VALUES] NAME [FROM TO]
|
8270 |
342 |
jeremybenn |
Return a list of the children of the specified variable object and
|
8271 |
330 |
jeremybenn |
create variable objects for them, if they do not already exist. With a
|
8272 |
|
|
single argument or if PRINT-VALUES has a value of 0 or `--no-values',
|
8273 |
|
|
print only the names of the variables; if PRINT-VALUES is 1 or
|
8274 |
|
|
`--all-values', also print their values; and if it is 2 or
|
8275 |
|
|
`--simple-values' print the name and value for simple data types and
|
8276 |
|
|
just the name for arrays, structures and unions.
|
8277 |
|
|
|
8278 |
|
|
FROM and TO, if specified, indicate the range of children to report.
|
8279 |
|
|
If FROM or TO is less than zero, the range is reset and all children
|
8280 |
|
|
will be reported. Otherwise, children starting at FROM (zero-based)
|
8281 |
|
|
and up to and excluding TO will be reported.
|
8282 |
|
|
|
8283 |
|
|
If a child range is requested, it will only affect the current call
|
8284 |
|
|
to `-var-list-children', but not future calls to `-var-update'. For
|
8285 |
|
|
this, you must instead use `-var-set-update-range'. The intent of this
|
8286 |
|
|
approach is to enable a front end to implement any update approach it
|
8287 |
|
|
likes; for example, scrolling a view may cause the front end to request
|
8288 |
|
|
more children with `-var-list-children', and then the front end could
|
8289 |
|
|
call `-var-set-update-range' with a different range to ensure that
|
8290 |
|
|
future updates are restricted to just the visible items.
|
8291 |
|
|
|
8292 |
|
|
For each child the following results are returned:
|
8293 |
|
|
|
8294 |
|
|
NAME
|
8295 |
|
|
Name of the variable object created for this child.
|
8296 |
|
|
|
8297 |
|
|
EXP
|
8298 |
|
|
The expression to be shown to the user by the front end to
|
8299 |
|
|
designate this child. For example this may be the name of a
|
8300 |
|
|
structure member.
|
8301 |
|
|
|
8302 |
|
|
For a dynamic varobj, this value cannot be used to form an
|
8303 |
|
|
expression. There is no way to do this at all with a dynamic
|
8304 |
|
|
varobj.
|
8305 |
|
|
|
8306 |
|
|
For C/C++ structures there are several pseudo children returned to
|
8307 |
|
|
designate access qualifiers. For these pseudo children EXP is
|
8308 |
|
|
`public', `private', or `protected'. In this case the type and
|
8309 |
|
|
value are not present.
|
8310 |
|
|
|
8311 |
|
|
A dynamic varobj will not report the access qualifying
|
8312 |
|
|
pseudo-children, regardless of the language. This information is
|
8313 |
|
|
not available at all with a dynamic varobj.
|
8314 |
|
|
|
8315 |
|
|
NUMCHILD
|
8316 |
|
|
Number of children this child has. For a dynamic varobj, this
|
8317 |
|
|
will be 0.
|
8318 |
|
|
|
8319 |
|
|
TYPE
|
8320 |
|
|
The type of the child.
|
8321 |
|
|
|
8322 |
|
|
VALUE
|
8323 |
|
|
If values were requested, this is the value.
|
8324 |
|
|
|
8325 |
|
|
THREAD-ID
|
8326 |
|
|
If this variable object is associated with a thread, this is the
|
8327 |
|
|
thread id. Otherwise this result is not present.
|
8328 |
|
|
|
8329 |
|
|
FROZEN
|
8330 |
|
|
If the variable object is frozen, this variable will be present
|
8331 |
|
|
with a value of 1.
|
8332 |
|
|
|
8333 |
|
|
The result may have its own attributes:
|
8334 |
|
|
|
8335 |
|
|
`displayhint'
|
8336 |
|
|
A dynamic varobj can supply a display hint to the front end. The
|
8337 |
|
|
value comes directly from the Python pretty-printer object's
|
8338 |
|
|
`display_hint' method. *Note Pretty Printing API::.
|
8339 |
|
|
|
8340 |
|
|
`has_more'
|
8341 |
|
|
This is an integer attribute which is nonzero if there are children
|
8342 |
|
|
remaining after the end of the selected range.
|
8343 |
|
|
|
8344 |
|
|
Example
|
8345 |
|
|
.......
|
8346 |
|
|
|
8347 |
|
|
(gdb)
|
8348 |
|
|
-var-list-children n
|
8349 |
|
|
^done,numchild=N,children=[child={name=NAME,exp=EXP,
|
8350 |
|
|
numchild=N,type=TYPE},(repeats N times)]
|
8351 |
|
|
(gdb)
|
8352 |
|
|
-var-list-children --all-values n
|
8353 |
|
|
^done,numchild=N,children=[child={name=NAME,exp=EXP,
|
8354 |
|
|
numchild=N,value=VALUE,type=TYPE},(repeats N times)]
|
8355 |
|
|
|
8356 |
|
|
The `-var-info-type' Command
|
8357 |
|
|
----------------------------
|
8358 |
|
|
|
8359 |
|
|
Synopsis
|
8360 |
|
|
........
|
8361 |
|
|
|
8362 |
|
|
-var-info-type NAME
|
8363 |
|
|
|
8364 |
|
|
Returns the type of the specified variable NAME. The type is
|
8365 |
|
|
returned as a string in the same format as it is output by the GDB CLI:
|
8366 |
|
|
|
8367 |
|
|
type=TYPENAME
|
8368 |
|
|
|
8369 |
|
|
The `-var-info-expression' Command
|
8370 |
|
|
----------------------------------
|
8371 |
|
|
|
8372 |
|
|
Synopsis
|
8373 |
|
|
........
|
8374 |
|
|
|
8375 |
|
|
-var-info-expression NAME
|
8376 |
|
|
|
8377 |
|
|
Returns a string that is suitable for presenting this variable
|
8378 |
|
|
object in user interface. The string is generally not valid expression
|
8379 |
|
|
in the current language, and cannot be evaluated.
|
8380 |
|
|
|
8381 |
|
|
For example, if `a' is an array, and variable object `A' was created
|
8382 |
|
|
for `a', then we'll get this output:
|
8383 |
|
|
|
8384 |
|
|
(gdb) -var-info-expression A.1
|
8385 |
|
|
^done,lang="C",exp="1"
|
8386 |
|
|
|
8387 |
|
|
Here, the values of `lang' can be `{"C" | "C++" | "Java"}'.
|
8388 |
|
|
|
8389 |
|
|
Note that the output of the `-var-list-children' command also
|
8390 |
|
|
includes those expressions, so the `-var-info-expression' command is of
|
8391 |
|
|
limited use.
|
8392 |
|
|
|
8393 |
|
|
The `-var-info-path-expression' Command
|
8394 |
|
|
---------------------------------------
|
8395 |
|
|
|
8396 |
|
|
Synopsis
|
8397 |
|
|
........
|
8398 |
|
|
|
8399 |
|
|
-var-info-path-expression NAME
|
8400 |
|
|
|
8401 |
|
|
Returns an expression that can be evaluated in the current context
|
8402 |
|
|
and will yield the same value that a variable object has. Compare this
|
8403 |
|
|
with the `-var-info-expression' command, which result can be used only
|
8404 |
|
|
for UI presentation. Typical use of the `-var-info-path-expression'
|
8405 |
|
|
command is creating a watchpoint from a variable object.
|
8406 |
|
|
|
8407 |
|
|
This command is currently not valid for children of a dynamic varobj,
|
8408 |
|
|
and will give an error when invoked on one.
|
8409 |
|
|
|
8410 |
|
|
For example, suppose `C' is a C++ class, derived from class `Base',
|
8411 |
|
|
and that the `Base' class has a member called `m_size'. Assume a
|
8412 |
|
|
variable `c' is has the type of `C' and a variable object `C' was
|
8413 |
|
|
created for variable `c'. Then, we'll get this output:
|
8414 |
|
|
(gdb) -var-info-path-expression C.Base.public.m_size
|
8415 |
|
|
^done,path_expr=((Base)c).m_size)
|
8416 |
|
|
|
8417 |
|
|
The `-var-show-attributes' Command
|
8418 |
|
|
----------------------------------
|
8419 |
|
|
|
8420 |
|
|
Synopsis
|
8421 |
|
|
........
|
8422 |
|
|
|
8423 |
|
|
-var-show-attributes NAME
|
8424 |
|
|
|
8425 |
|
|
List attributes of the specified variable object NAME:
|
8426 |
|
|
|
8427 |
|
|
status=ATTR [ ( ,ATTR )* ]
|
8428 |
|
|
|
8429 |
|
|
where ATTR is `{ { editable | noneditable } | TBD }'.
|
8430 |
|
|
|
8431 |
|
|
The `-var-evaluate-expression' Command
|
8432 |
|
|
--------------------------------------
|
8433 |
|
|
|
8434 |
|
|
Synopsis
|
8435 |
|
|
........
|
8436 |
|
|
|
8437 |
|
|
-var-evaluate-expression [-f FORMAT-SPEC] NAME
|
8438 |
|
|
|
8439 |
|
|
Evaluates the expression that is represented by the specified
|
8440 |
|
|
variable object and returns its value as a string. The format of the
|
8441 |
|
|
string can be specified with the `-f' option. The possible values of
|
8442 |
|
|
this option are the same as for `-var-set-format' (*note
|
8443 |
|
|
-var-set-format::). If the `-f' option is not specified, the current
|
8444 |
|
|
display format will be used. The current display format can be changed
|
8445 |
|
|
using the `-var-set-format' command.
|
8446 |
|
|
|
8447 |
|
|
value=VALUE
|
8448 |
|
|
|
8449 |
|
|
Note that one must invoke `-var-list-children' for a variable before
|
8450 |
|
|
the value of a child variable can be evaluated.
|
8451 |
|
|
|
8452 |
|
|
The `-var-assign' Command
|
8453 |
|
|
-------------------------
|
8454 |
|
|
|
8455 |
|
|
Synopsis
|
8456 |
|
|
........
|
8457 |
|
|
|
8458 |
|
|
-var-assign NAME EXPRESSION
|
8459 |
|
|
|
8460 |
|
|
Assigns the value of EXPRESSION to the variable object specified by
|
8461 |
|
|
NAME. The object must be `editable'. If the variable's value is
|
8462 |
|
|
altered by the assign, the variable will show up in any subsequent
|
8463 |
|
|
`-var-update' list.
|
8464 |
|
|
|
8465 |
|
|
Example
|
8466 |
|
|
.......
|
8467 |
|
|
|
8468 |
|
|
(gdb)
|
8469 |
|
|
-var-assign var1 3
|
8470 |
|
|
^done,value="3"
|
8471 |
|
|
(gdb)
|
8472 |
|
|
-var-update *
|
8473 |
|
|
^done,changelist=[{name="var1",in_scope="true",type_changed="false"}]
|
8474 |
|
|
(gdb)
|
8475 |
|
|
|
8476 |
|
|
The `-var-update' Command
|
8477 |
|
|
-------------------------
|
8478 |
|
|
|
8479 |
|
|
Synopsis
|
8480 |
|
|
........
|
8481 |
|
|
|
8482 |
|
|
-var-update [PRINT-VALUES] {NAME | "*"}
|
8483 |
|
|
|
8484 |
|
|
Reevaluate the expressions corresponding to the variable object NAME
|
8485 |
|
|
and all its direct and indirect children, and return the list of
|
8486 |
|
|
variable objects whose values have changed; NAME must be a root
|
8487 |
|
|
variable object. Here, "changed" means that the result of
|
8488 |
|
|
`-var-evaluate-expression' before and after the `-var-update' is
|
8489 |
|
|
different. If `*' is used as the variable object names, all existing
|
8490 |
|
|
variable objects are updated, except for frozen ones (*note
|
8491 |
|
|
-var-set-frozen::). The option PRINT-VALUES determines whether both
|
8492 |
|
|
names and values, or just names are printed. The possible values of
|
8493 |
|
|
this option are the same as for `-var-list-children' (*note
|
8494 |
|
|
-var-list-children::). It is recommended to use the `--all-values'
|
8495 |
|
|
option, to reduce the number of MI commands needed on each program stop.
|
8496 |
|
|
|
8497 |
|
|
With the `*' parameter, if a variable object is bound to a currently
|
8498 |
|
|
running thread, it will not be updated, without any diagnostic.
|
8499 |
|
|
|
8500 |
|
|
If `-var-set-update-range' was previously used on a varobj, then
|
8501 |
|
|
only the selected range of children will be reported.
|
8502 |
|
|
|
8503 |
|
|
`-var-update' reports all the changed varobjs in a tuple named
|
8504 |
|
|
`changelist'.
|
8505 |
|
|
|
8506 |
|
|
Each item in the change list is itself a tuple holding:
|
8507 |
|
|
|
8508 |
|
|
`name'
|
8509 |
|
|
The name of the varobj.
|
8510 |
|
|
|
8511 |
|
|
`value'
|
8512 |
|
|
If values were requested for this update, then this field will be
|
8513 |
|
|
present and will hold the value of the varobj.
|
8514 |
|
|
|
8515 |
|
|
`in_scope'
|
8516 |
|
|
This field is a string which may take one of three values:
|
8517 |
|
|
|
8518 |
|
|
`"true"'
|
8519 |
|
|
The variable object's current value is valid.
|
8520 |
|
|
|
8521 |
|
|
`"false"'
|
8522 |
|
|
The variable object does not currently hold a valid value but
|
8523 |
|
|
it may hold one in the future if its associated expression
|
8524 |
|
|
comes back into scope.
|
8525 |
|
|
|
8526 |
|
|
`"invalid"'
|
8527 |
|
|
The variable object no longer holds a valid value. This can
|
8528 |
|
|
occur when the executable file being debugged has changed,
|
8529 |
|
|
either through recompilation or by using the GDB `file'
|
8530 |
|
|
command. The front end should normally choose to delete
|
8531 |
|
|
these variable objects.
|
8532 |
|
|
|
8533 |
|
|
In the future new values may be added to this list so the front
|
8534 |
|
|
should be prepared for this possibility. *Note GDB/MI Development
|
8535 |
|
|
and Front Ends: GDB/MI Development and Front Ends.
|
8536 |
|
|
|
8537 |
|
|
`type_changed'
|
8538 |
|
|
This is only present if the varobj is still valid. If the type
|
8539 |
|
|
changed, then this will be the string `true'; otherwise it will be
|
8540 |
|
|
`false'.
|
8541 |
|
|
|
8542 |
|
|
`new_type'
|
8543 |
|
|
If the varobj's type changed, then this field will be present and
|
8544 |
|
|
will hold the new type.
|
8545 |
|
|
|
8546 |
|
|
`new_num_children'
|
8547 |
|
|
For a dynamic varobj, if the number of children changed, or if the
|
8548 |
|
|
type changed, this will be the new number of children.
|
8549 |
|
|
|
8550 |
|
|
The `numchild' field in other varobj responses is generally not
|
8551 |
|
|
valid for a dynamic varobj - it will show the number of children
|
8552 |
|
|
that GDB knows about, but because dynamic varobjs lazily
|
8553 |
|
|
instantiate their children, this will not reflect the number of
|
8554 |
|
|
children which may be available.
|
8555 |
|
|
|
8556 |
|
|
The `new_num_children' attribute only reports changes to the
|
8557 |
|
|
number of children known by GDB. This is the only way to detect
|
8558 |
|
|
whether an update has removed children (which necessarily can only
|
8559 |
|
|
happen at the end of the update range).
|
8560 |
|
|
|
8561 |
|
|
`displayhint'
|
8562 |
|
|
The display hint, if any.
|
8563 |
|
|
|
8564 |
|
|
`has_more'
|
8565 |
|
|
This is an integer value, which will be 1 if there are more
|
8566 |
|
|
children available outside the varobj's update range.
|
8567 |
|
|
|
8568 |
|
|
`dynamic'
|
8569 |
|
|
This attribute will be present and have the value `1' if the
|
8570 |
|
|
varobj is a dynamic varobj. If the varobj is not a dynamic varobj,
|
8571 |
|
|
then this attribute will not be present.
|
8572 |
|
|
|
8573 |
|
|
`new_children'
|
8574 |
|
|
If new children were added to a dynamic varobj within the selected
|
8575 |
|
|
update range (as set by `-var-set-update-range'), then they will
|
8576 |
|
|
be listed in this attribute.
|
8577 |
|
|
|
8578 |
|
|
Example
|
8579 |
|
|
.......
|
8580 |
|
|
|
8581 |
|
|
(gdb)
|
8582 |
|
|
-var-assign var1 3
|
8583 |
|
|
^done,value="3"
|
8584 |
|
|
(gdb)
|
8585 |
|
|
-var-update --all-values var1
|
8586 |
|
|
^done,changelist=[{name="var1",value="3",in_scope="true",
|
8587 |
|
|
type_changed="false"}]
|
8588 |
|
|
(gdb)
|
8589 |
|
|
|
8590 |
|
|
The `-var-set-frozen' Command
|
8591 |
|
|
-----------------------------
|
8592 |
|
|
|
8593 |
|
|
Synopsis
|
8594 |
|
|
........
|
8595 |
|
|
|
8596 |
|
|
-var-set-frozen NAME FLAG
|
8597 |
|
|
|
8598 |
|
|
Set the frozenness flag on the variable object NAME. The FLAG
|
8599 |
|
|
parameter should be either `1' to make the variable frozen or `0' to
|
8600 |
|
|
make it unfrozen. If a variable object is frozen, then neither itself,
|
8601 |
|
|
nor any of its children, are implicitly updated by `-var-update' of a
|
8602 |
|
|
parent variable or by `-var-update *'. Only `-var-update' of the
|
8603 |
|
|
variable itself will update its value and values of its children.
|
8604 |
|
|
After a variable object is unfrozen, it is implicitly updated by all
|
8605 |
|
|
subsequent `-var-update' operations. Unfreezing a variable does not
|
8606 |
|
|
update it, only subsequent `-var-update' does.
|
8607 |
|
|
|
8608 |
|
|
Example
|
8609 |
|
|
.......
|
8610 |
|
|
|
8611 |
|
|
(gdb)
|
8612 |
|
|
-var-set-frozen V 1
|
8613 |
|
|
^done
|
8614 |
|
|
(gdb)
|
8615 |
|
|
|
8616 |
|
|
The `-var-set-update-range' command
|
8617 |
|
|
-----------------------------------
|
8618 |
|
|
|
8619 |
|
|
Synopsis
|
8620 |
|
|
........
|
8621 |
|
|
|
8622 |
|
|
-var-set-update-range NAME FROM TO
|
8623 |
|
|
|
8624 |
|
|
Set the range of children to be returned by future invocations of
|
8625 |
|
|
`-var-update'.
|
8626 |
|
|
|
8627 |
|
|
FROM and TO indicate the range of children to report. If FROM or TO
|
8628 |
|
|
is less than zero, the range is reset and all children will be
|
8629 |
|
|
reported. Otherwise, children starting at FROM (zero-based) and up to
|
8630 |
|
|
and excluding TO will be reported.
|
8631 |
|
|
|
8632 |
|
|
Example
|
8633 |
|
|
.......
|
8634 |
|
|
|
8635 |
|
|
(gdb)
|
8636 |
|
|
-var-set-update-range V 1 2
|
8637 |
|
|
^done
|
8638 |
|
|
|
8639 |
|
|
The `-var-set-visualizer' command
|
8640 |
|
|
---------------------------------
|
8641 |
|
|
|
8642 |
|
|
Synopsis
|
8643 |
|
|
........
|
8644 |
|
|
|
8645 |
|
|
-var-set-visualizer NAME VISUALIZER
|
8646 |
|
|
|
8647 |
|
|
Set a visualizer for the variable object NAME.
|
8648 |
|
|
|
8649 |
|
|
VISUALIZER is the visualizer to use. The special value `None' means
|
8650 |
|
|
to disable any visualizer in use.
|
8651 |
|
|
|
8652 |
|
|
If not `None', VISUALIZER must be a Python expression. This
|
8653 |
|
|
expression must evaluate to a callable object which accepts a single
|
8654 |
|
|
argument. GDB will call this object with the value of the varobj NAME
|
8655 |
|
|
as an argument (this is done so that the same Python pretty-printing
|
8656 |
|
|
code can be used for both the CLI and MI). When called, this object
|
8657 |
|
|
must return an object which conforms to the pretty-printing interface
|
8658 |
|
|
(*note Pretty Printing API::).
|
8659 |
|
|
|
8660 |
|
|
The pre-defined function `gdb.default_visualizer' may be used to
|
8661 |
|
|
select a visualizer by following the built-in process (*note Selecting
|
8662 |
|
|
Pretty-Printers::). This is done automatically when a varobj is
|
8663 |
|
|
created, and so ordinarily is not needed.
|
8664 |
|
|
|
8665 |
|
|
This feature is only available if Python support is enabled. The MI
|
8666 |
|
|
command `-list-features' (*note GDB/MI Miscellaneous Commands::) can be
|
8667 |
|
|
used to check this.
|
8668 |
|
|
|
8669 |
|
|
Example
|
8670 |
|
|
.......
|
8671 |
|
|
|
8672 |
|
|
Resetting the visualizer:
|
8673 |
|
|
|
8674 |
|
|
(gdb)
|
8675 |
|
|
-var-set-visualizer V None
|
8676 |
|
|
^done
|
8677 |
|
|
|
8678 |
|
|
Reselecting the default (type-based) visualizer:
|
8679 |
|
|
|
8680 |
|
|
(gdb)
|
8681 |
|
|
-var-set-visualizer V gdb.default_visualizer
|
8682 |
|
|
^done
|
8683 |
|
|
|
8684 |
|
|
Suppose `SomeClass' is a visualizer class. A lambda expression can
|
8685 |
|
|
be used to instantiate this class for a varobj:
|
8686 |
|
|
|
8687 |
|
|
(gdb)
|
8688 |
|
|
-var-set-visualizer V "lambda val: SomeClass()"
|
8689 |
|
|
^done
|
8690 |
|
|
|