| 1 |
330 |
jeremybenn |
This is gdb.info, produced by makeinfo version 4.8 from ./gdb.texinfo.
|
| 2 |
|
|
|
| 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 |
|
|
Source-Level Debugger' for GDB (GDB) Version 7.2.
|
| 27 |
|
|
|
| 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 |
|
|
described in *Note Non-debug DLL Symbols::.
|
| 208 |
|
|
|
| 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 |
|
|
library information in *Note Files::, or the `dll-symbols' command in
|
| 311 |
|
|
*Note Cygwin Native::. Currently, explicitly loading symbols from a
|
| 312 |
|
|
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 |
|
|
See OR1k Architecture document (`www.opencores.org') for more
|
| 1171 |
|
|
information about platform and commands.
|
| 1172 |
|
|
|
| 1173 |
|
|
`target jtag jtag://HOST:PORT'
|
| 1174 |
|
|
Connects to remote JTAG server. JTAG remote server can be either
|
| 1175 |
|
|
an or1ksim or JTAG server, connected via parallel port to the
|
| 1176 |
|
|
board.
|
| 1177 |
|
|
|
| 1178 |
|
|
Example: `target jtag jtag://localhost:9999'
|
| 1179 |
|
|
|
| 1180 |
|
|
`or1ksim COMMAND'
|
| 1181 |
|
|
If connected to `or1ksim' OpenRISC 1000 Architectural Simulator,
|
| 1182 |
|
|
proprietary commands can be executed.
|
| 1183 |
|
|
|
| 1184 |
|
|
`info or1k spr'
|
| 1185 |
|
|
Displays spr groups.
|
| 1186 |
|
|
|
| 1187 |
|
|
`info or1k spr GROUP'
|
| 1188 |
|
|
`info or1k spr GROUPNO'
|
| 1189 |
|
|
Displays register names in selected group.
|
| 1190 |
|
|
|
| 1191 |
|
|
`info or1k spr GROUP REGISTER'
|
| 1192 |
|
|
`info or1k spr REGISTER'
|
| 1193 |
|
|
`info or1k spr GROUPNO REGISTERNO'
|
| 1194 |
|
|
`info or1k spr REGISTERNO'
|
| 1195 |
|
|
Shows information about specified spr register.
|
| 1196 |
|
|
|
| 1197 |
|
|
`spr GROUP REGISTER VALUE'
|
| 1198 |
|
|
`spr REGISTER VALUE'
|
| 1199 |
|
|
`spr GROUPNO REGISTERNO VALUE'
|
| 1200 |
|
|
`spr REGISTERNO VALUE'
|
| 1201 |
|
|
Writes VALUE to specified spr register.
|
| 1202 |
|
|
|
| 1203 |
|
|
Some implementations of OpenRISC 1000 Architecture also have
|
| 1204 |
|
|
hardware trace. It is very similar to GDB trace, except it does not
|
| 1205 |
|
|
interfere with normal program execution and is thus much faster.
|
| 1206 |
|
|
Hardware breakpoints/watchpoint triggers can be set using:
|
| 1207 |
|
|
`$LEA/$LDATA'
|
| 1208 |
|
|
Load effective address/data
|
| 1209 |
|
|
|
| 1210 |
|
|
`$SEA/$SDATA'
|
| 1211 |
|
|
Store effective address/data
|
| 1212 |
|
|
|
| 1213 |
|
|
`$AEA/$ADATA'
|
| 1214 |
|
|
Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA)
|
| 1215 |
|
|
|
| 1216 |
|
|
`$FETCH'
|
| 1217 |
|
|
Fetch data
|
| 1218 |
|
|
|
| 1219 |
|
|
When triggered, it can capture low level data, like: `PC', `LSEA',
|
| 1220 |
|
|
`LDATA', `SDATA', `READSPR', `WRITESPR', `INSTR'.
|
| 1221 |
|
|
|
| 1222 |
|
|
`htrace' commands:
|
| 1223 |
|
|
`hwatch CONDITIONAL'
|
| 1224 |
|
|
Set hardware watchpoint on combination of Load/Store Effective
|
| 1225 |
|
|
Address(es) or Data. For example:
|
| 1226 |
|
|
|
| 1227 |
|
|
`hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
|
| 1228 |
|
|
($SDATA >= 50)'
|
| 1229 |
|
|
|
| 1230 |
|
|
`hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
|
| 1231 |
|
|
($SDATA >= 50)'
|
| 1232 |
|
|
|
| 1233 |
|
|
`htrace info'
|
| 1234 |
|
|
Display information about current HW trace configuration.
|
| 1235 |
|
|
|
| 1236 |
|
|
`htrace trigger CONDITIONAL'
|
| 1237 |
|
|
Set starting criteria for HW trace.
|
| 1238 |
|
|
|
| 1239 |
|
|
`htrace qualifier CONDITIONAL'
|
| 1240 |
|
|
Set acquisition qualifier for HW trace.
|
| 1241 |
|
|
|
| 1242 |
|
|
`htrace stop CONDITIONAL'
|
| 1243 |
|
|
Set HW trace stopping criteria.
|
| 1244 |
|
|
|
| 1245 |
|
|
`htrace record [DATA]*'
|
| 1246 |
|
|
Selects the data to be recorded, when qualifier is met and HW
|
| 1247 |
|
|
trace was triggered.
|
| 1248 |
|
|
|
| 1249 |
|
|
`htrace enable'
|
| 1250 |
|
|
`htrace disable'
|
| 1251 |
|
|
Enables/disables the HW trace.
|
| 1252 |
|
|
|
| 1253 |
|
|
`htrace rewind [FILENAME]'
|
| 1254 |
|
|
Clears currently recorded trace data.
|
| 1255 |
|
|
|
| 1256 |
|
|
If filename is specified, new trace file is made and any newly
|
| 1257 |
|
|
collected data will be written there.
|
| 1258 |
|
|
|
| 1259 |
|
|
`htrace print [START [LEN]]'
|
| 1260 |
|
|
Prints trace buffer, using current record configuration.
|
| 1261 |
|
|
|
| 1262 |
|
|
`htrace mode continuous'
|
| 1263 |
|
|
Set continuous trace mode.
|
| 1264 |
|
|
|
| 1265 |
|
|
`htrace mode suspend'
|
| 1266 |
|
|
Set suspend trace mode.
|
| 1267 |
|
|
|
| 1268 |
|
|
|
| 1269 |
|
|
|
| 1270 |
|
|
File: gdb.info, Node: PowerPC Embedded, Next: Sparclet, Prev: PA, Up: Embedded Processors
|
| 1271 |
|
|
|
| 1272 |
|
|
21.3.7 PowerPC Embedded
|
| 1273 |
|
|
-----------------------
|
| 1274 |
|
|
|
| 1275 |
|
|
GDB supports using the DVC (Data Value Compare) register to implement
|
| 1276 |
|
|
in hardware simple hardware watchpoint conditions of the form:
|
| 1277 |
|
|
|
| 1278 |
|
|
(gdb) watch ADDRESS|VARIABLE \
|
| 1279 |
|
|
if ADDRESS|VARIABLE == CONSTANT EXPRESSION
|
| 1280 |
|
|
|
| 1281 |
|
|
The DVC register will be automatically used whenever GDB detects
|
| 1282 |
|
|
such pattern in a condition expression. This feature is available in
|
| 1283 |
|
|
native GDB running on a Linux kernel version 2.6.34 or newer.
|
| 1284 |
|
|
|
| 1285 |
|
|
GDB provides the following PowerPC-specific commands:
|
| 1286 |
|
|
|
| 1287 |
|
|
`set powerpc soft-float'
|
| 1288 |
|
|
`show powerpc soft-float'
|
| 1289 |
|
|
Force GDB to use (or not use) a software floating point calling
|
| 1290 |
|
|
convention. By default, GDB selects the calling convention based
|
| 1291 |
|
|
on the selected architecture and the provided executable file.
|
| 1292 |
|
|
|
| 1293 |
|
|
`set powerpc vector-abi'
|
| 1294 |
|
|
`show powerpc vector-abi'
|
| 1295 |
|
|
Force GDB to use the specified calling convention for vector
|
| 1296 |
|
|
arguments and return values. The valid options are `auto';
|
| 1297 |
|
|
`generic', to avoid vector registers even if they are present;
|
| 1298 |
|
|
`altivec', to use AltiVec registers; and `spe' to use SPE
|
| 1299 |
|
|
registers. By default, GDB selects the calling convention based
|
| 1300 |
|
|
on the selected architecture and the provided executable file.
|
| 1301 |
|
|
|
| 1302 |
|
|
`target dink32 DEV'
|
| 1303 |
|
|
DINK32 ROM monitor.
|
| 1304 |
|
|
|
| 1305 |
|
|
`target ppcbug DEV'
|
| 1306 |
|
|
|
| 1307 |
|
|
`target ppcbug1 DEV'
|
| 1308 |
|
|
PPCBUG ROM monitor for PowerPC.
|
| 1309 |
|
|
|
| 1310 |
|
|
`target sds DEV'
|
| 1311 |
|
|
SDS monitor, running on a PowerPC board (such as Motorola's ADS).
|
| 1312 |
|
|
|
| 1313 |
|
|
The following commands specific to the SDS protocol are supported by
|
| 1314 |
|
|
GDB:
|
| 1315 |
|
|
|
| 1316 |
|
|
`set sdstimeout NSEC'
|
| 1317 |
|
|
Set the timeout for SDS protocol reads to be NSEC seconds. The
|
| 1318 |
|
|
default is 2 seconds.
|
| 1319 |
|
|
|
| 1320 |
|
|
`show sdstimeout'
|
| 1321 |
|
|
Show the current value of the SDS timeout.
|
| 1322 |
|
|
|
| 1323 |
|
|
`sds COMMAND'
|
| 1324 |
|
|
Send the specified COMMAND string to the SDS monitor.
|
| 1325 |
|
|
|
| 1326 |
|
|
|
| 1327 |
|
|
File: gdb.info, Node: PA, Next: PowerPC Embedded, Prev: OpenRISC 1000, Up: Embedded Processors
|
| 1328 |
|
|
|
| 1329 |
|
|
21.3.8 HP PA Embedded
|
| 1330 |
|
|
---------------------
|
| 1331 |
|
|
|
| 1332 |
|
|
`target op50n DEV'
|
| 1333 |
|
|
OP50N monitor, running on an OKI HPPA board.
|
| 1334 |
|
|
|
| 1335 |
|
|
`target w89k DEV'
|
| 1336 |
|
|
W89K monitor, running on a Winbond HPPA board.
|
| 1337 |
|
|
|
| 1338 |
|
|
|
| 1339 |
|
|
|
| 1340 |
|
|
File: gdb.info, Node: Sparclet, Next: Sparclite, Prev: PowerPC Embedded, Up: Embedded Processors
|
| 1341 |
|
|
|
| 1342 |
|
|
21.3.9 Tsqware Sparclet
|
| 1343 |
|
|
-----------------------
|
| 1344 |
|
|
|
| 1345 |
|
|
GDB enables developers to debug tasks running on Sparclet targets from
|
| 1346 |
|
|
a Unix host. GDB uses code that runs on both the Unix host and on the
|
| 1347 |
|
|
Sparclet target. The program `gdb' is installed and executed on the
|
| 1348 |
|
|
Unix host.
|
| 1349 |
|
|
|
| 1350 |
|
|
`remotetimeout ARGS'
|
| 1351 |
|
|
GDB supports the option `remotetimeout'. This option is set by
|
| 1352 |
|
|
the user, and ARGS represents the number of seconds GDB waits for
|
| 1353 |
|
|
responses.
|
| 1354 |
|
|
|
| 1355 |
|
|
When compiling for debugging, include the options `-g' to get debug
|
| 1356 |
|
|
information and `-Ttext' to relocate the program to where you wish to
|
| 1357 |
|
|
load it on the target. You may also want to add the options `-n' or
|
| 1358 |
|
|
`-N' in order to reduce the size of the sections. Example:
|
| 1359 |
|
|
|
| 1360 |
|
|
sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
|
| 1361 |
|
|
|
| 1362 |
|
|
You can use `objdump' to verify that the addresses are what you
|
| 1363 |
|
|
intended:
|
| 1364 |
|
|
|
| 1365 |
|
|
sparclet-aout-objdump --headers --syms prog
|
| 1366 |
|
|
|
| 1367 |
|
|
Once you have set your Unix execution search path to find GDB, you
|
| 1368 |
|
|
are ready to run GDB. From your Unix host, run `gdb' (or
|
| 1369 |
|
|
`sparclet-aout-gdb', depending on your installation).
|
| 1370 |
|
|
|
| 1371 |
|
|
GDB comes up showing the prompt:
|
| 1372 |
|
|
|
| 1373 |
|
|
(gdbslet)
|
| 1374 |
|
|
|
| 1375 |
|
|
* Menu:
|
| 1376 |
|
|
|
| 1377 |
|
|
* Sparclet File:: Setting the file to debug
|
| 1378 |
|
|
* Sparclet Connection:: Connecting to Sparclet
|
| 1379 |
|
|
* Sparclet Download:: Sparclet download
|
| 1380 |
|
|
* Sparclet Execution:: Running and debugging
|
| 1381 |
|
|
|
| 1382 |
|
|
|
| 1383 |
|
|
File: gdb.info, Node: Sparclet File, Next: Sparclet Connection, Up: Sparclet
|
| 1384 |
|
|
|
| 1385 |
|
|
21.3.9.1 Setting File to Debug
|
| 1386 |
|
|
..............................
|
| 1387 |
|
|
|
| 1388 |
|
|
The GDB command `file' lets you choose with program to debug.
|
| 1389 |
|
|
|
| 1390 |
|
|
(gdbslet) file prog
|
| 1391 |
|
|
|
| 1392 |
|
|
GDB then attempts to read the symbol table of `prog'. GDB locates
|
| 1393 |
|
|
the file by searching the directories listed in the command search path.
|
| 1394 |
|
|
If the file was compiled with debug information (option `-g'), source
|
| 1395 |
|
|
files will be searched as well. GDB locates the source files by
|
| 1396 |
|
|
searching the directories listed in the directory search path (*note
|
| 1397 |
|
|
Your Program's Environment: Environment.). If it fails to find a file,
|
| 1398 |
|
|
it displays a message such as:
|
| 1399 |
|
|
|
| 1400 |
|
|
prog: No such file or directory.
|
| 1401 |
|
|
|
| 1402 |
|
|
When this happens, add the appropriate directories to the search
|
| 1403 |
|
|
paths with the GDB commands `path' and `dir', and execute the `target'
|
| 1404 |
|
|
command again.
|
| 1405 |
|
|
|
| 1406 |
|
|
|
| 1407 |
|
|
File: gdb.info, Node: Sparclet Connection, Next: Sparclet Download, Prev: Sparclet File, Up: Sparclet
|
| 1408 |
|
|
|
| 1409 |
|
|
21.3.9.2 Connecting to Sparclet
|
| 1410 |
|
|
...............................
|
| 1411 |
|
|
|
| 1412 |
|
|
The GDB command `target' lets you connect to a Sparclet target. To
|
| 1413 |
|
|
connect to a target on serial port "`ttya'", type:
|
| 1414 |
|
|
|
| 1415 |
|
|
(gdbslet) target sparclet /dev/ttya
|
| 1416 |
|
|
Remote target sparclet connected to /dev/ttya
|
| 1417 |
|
|
main () at ../prog.c:3
|
| 1418 |
|
|
|
| 1419 |
|
|
GDB displays messages like these:
|
| 1420 |
|
|
|
| 1421 |
|
|
Connected to ttya.
|
| 1422 |
|
|
|
| 1423 |
|
|
|
| 1424 |
|
|
File: gdb.info, Node: Sparclet Download, Next: Sparclet Execution, Prev: Sparclet Connection, Up: Sparclet
|
| 1425 |
|
|
|
| 1426 |
|
|
21.3.9.3 Sparclet Download
|
| 1427 |
|
|
..........................
|
| 1428 |
|
|
|
| 1429 |
|
|
Once connected to the Sparclet target, you can use the GDB `load'
|
| 1430 |
|
|
command to download the file from the host to the target. The file
|
| 1431 |
|
|
name and load offset should be given as arguments to the `load' command.
|
| 1432 |
|
|
Since the file format is aout, the program must be loaded to the
|
| 1433 |
|
|
starting address. You can use `objdump' to find out what this value
|
| 1434 |
|
|
is. The load offset is an offset which is added to the VMA (virtual
|
| 1435 |
|
|
memory address) of each of the file's sections. For instance, if the
|
| 1436 |
|
|
program `prog' was linked to text address 0x1201000, with data at
|
| 1437 |
|
|
0x12010160 and bss at 0x12010170, in GDB, type:
|
| 1438 |
|
|
|
| 1439 |
|
|
(gdbslet) load prog 0x12010000
|
| 1440 |
|
|
Loading section .text, size 0xdb0 vma 0x12010000
|
| 1441 |
|
|
|
| 1442 |
|
|
If the code is loaded at a different address then what the program
|
| 1443 |
|
|
was linked to, you may need to use the `section' and `add-symbol-file'
|
| 1444 |
|
|
commands to tell GDB where to map the symbol table.
|
| 1445 |
|
|
|
| 1446 |
|
|
|
| 1447 |
|
|
File: gdb.info, Node: Sparclet Execution, Prev: Sparclet Download, Up: Sparclet
|
| 1448 |
|
|
|
| 1449 |
|
|
21.3.9.4 Running and Debugging
|
| 1450 |
|
|
..............................
|
| 1451 |
|
|
|
| 1452 |
|
|
You can now begin debugging the task using GDB's execution control
|
| 1453 |
|
|
commands, `b', `step', `run', etc. See the GDB manual for the list of
|
| 1454 |
|
|
commands.
|
| 1455 |
|
|
|
| 1456 |
|
|
(gdbslet) b main
|
| 1457 |
|
|
Breakpoint 1 at 0x12010000: file prog.c, line 3.
|
| 1458 |
|
|
(gdbslet) run
|
| 1459 |
|
|
Starting program: prog
|
| 1460 |
|
|
Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
|
| 1461 |
|
|
3 char *symarg = 0;
|
| 1462 |
|
|
(gdbslet) step
|
| 1463 |
|
|
4 char *execarg = "hello!";
|
| 1464 |
|
|
(gdbslet)
|
| 1465 |
|
|
|
| 1466 |
|
|
|
| 1467 |
|
|
File: gdb.info, Node: Sparclite, Next: Z8000, Prev: Sparclet, Up: Embedded Processors
|
| 1468 |
|
|
|
| 1469 |
|
|
21.3.10 Fujitsu Sparclite
|
| 1470 |
|
|
-------------------------
|
| 1471 |
|
|
|
| 1472 |
|
|
`target sparclite DEV'
|
| 1473 |
|
|
Fujitsu sparclite boards, used only for the purpose of loading.
|
| 1474 |
|
|
You must use an additional command to debug the program. For
|
| 1475 |
|
|
example: target remote DEV using GDB standard remote protocol.
|
| 1476 |
|
|
|
| 1477 |
|
|
|
| 1478 |
|
|
|
| 1479 |
|
|
File: gdb.info, Node: Z8000, Next: AVR, Prev: Sparclite, Up: Embedded Processors
|
| 1480 |
|
|
|
| 1481 |
|
|
21.3.11 Zilog Z8000
|
| 1482 |
|
|
-------------------
|
| 1483 |
|
|
|
| 1484 |
|
|
When configured for debugging Zilog Z8000 targets, GDB includes a Z8000
|
| 1485 |
|
|
simulator.
|
| 1486 |
|
|
|
| 1487 |
|
|
For the Z8000 family, `target sim' simulates either the Z8002 (the
|
| 1488 |
|
|
unsegmented variant of the Z8000 architecture) or the Z8001 (the
|
| 1489 |
|
|
segmented variant). The simulator recognizes which architecture is
|
| 1490 |
|
|
appropriate by inspecting the object code.
|
| 1491 |
|
|
|
| 1492 |
|
|
`target sim ARGS'
|
| 1493 |
|
|
Debug programs on a simulated CPU. If the simulator supports setup
|
| 1494 |
|
|
options, specify them via ARGS.
|
| 1495 |
|
|
|
| 1496 |
|
|
After specifying this target, you can debug programs for the simulated
|
| 1497 |
|
|
CPU in the same style as programs for your host computer; use the
|
| 1498 |
|
|
`file' command to load a new program image, the `run' command to run
|
| 1499 |
|
|
your program, and so on.
|
| 1500 |
|
|
|
| 1501 |
|
|
As well as making available all the usual machine registers (*note
|
| 1502 |
|
|
Registers: Registers.), the Z8000 simulator provides three additional
|
| 1503 |
|
|
items of information as specially named registers:
|
| 1504 |
|
|
|
| 1505 |
|
|
`cycles'
|
| 1506 |
|
|
Counts clock-ticks in the simulator.
|
| 1507 |
|
|
|
| 1508 |
|
|
`insts'
|
| 1509 |
|
|
Counts instructions run in the simulator.
|
| 1510 |
|
|
|
| 1511 |
|
|
`time'
|
| 1512 |
|
|
Execution time in 60ths of a second.
|
| 1513 |
|
|
|
| 1514 |
|
|
|
| 1515 |
|
|
You can refer to these values in GDB expressions with the usual
|
| 1516 |
|
|
conventions; for example, `b fputc if $cycles>5000' sets a conditional
|
| 1517 |
|
|
breakpoint that suspends only after at least 5000 simulated clock ticks.
|
| 1518 |
|
|
|
| 1519 |
|
|
|
| 1520 |
|
|
File: gdb.info, Node: AVR, Next: CRIS, Prev: Z8000, Up: Embedded Processors
|
| 1521 |
|
|
|
| 1522 |
|
|
21.3.12 Atmel AVR
|
| 1523 |
|
|
-----------------
|
| 1524 |
|
|
|
| 1525 |
|
|
When configured for debugging the Atmel AVR, GDB supports the following
|
| 1526 |
|
|
AVR-specific commands:
|
| 1527 |
|
|
|
| 1528 |
|
|
`info io_registers'
|
| 1529 |
|
|
This command displays information about the AVR I/O registers. For
|
| 1530 |
|
|
each register, GDB prints its number and value.
|
| 1531 |
|
|
|
| 1532 |
|
|
|
| 1533 |
|
|
File: gdb.info, Node: CRIS, Next: Super-H, Prev: AVR, Up: Embedded Processors
|
| 1534 |
|
|
|
| 1535 |
|
|
21.3.13 CRIS
|
| 1536 |
|
|
------------
|
| 1537 |
|
|
|
| 1538 |
|
|
When configured for debugging CRIS, GDB provides the following
|
| 1539 |
|
|
CRIS-specific commands:
|
| 1540 |
|
|
|
| 1541 |
|
|
`set cris-version VER'
|
| 1542 |
|
|
Set the current CRIS version to VER, either `10' or `32'. The
|
| 1543 |
|
|
CRIS version affects register names and sizes. This command is
|
| 1544 |
|
|
useful in case autodetection of the CRIS version fails.
|
| 1545 |
|
|
|
| 1546 |
|
|
`show cris-version'
|
| 1547 |
|
|
Show the current CRIS version.
|
| 1548 |
|
|
|
| 1549 |
|
|
`set cris-dwarf2-cfi'
|
| 1550 |
|
|
Set the usage of DWARF-2 CFI for CRIS debugging. The default is
|
| 1551 |
|
|
`on'. Change to `off' when using `gcc-cris' whose version is below
|
| 1552 |
|
|
`R59'.
|
| 1553 |
|
|
|
| 1554 |
|
|
`show cris-dwarf2-cfi'
|
| 1555 |
|
|
Show the current state of using DWARF-2 CFI.
|
| 1556 |
|
|
|
| 1557 |
|
|
`set cris-mode MODE'
|
| 1558 |
|
|
Set the current CRIS mode to MODE. It should only be changed when
|
| 1559 |
|
|
debugging in guru mode, in which case it should be set to `guru'
|
| 1560 |
|
|
(the default is `normal').
|
| 1561 |
|
|
|
| 1562 |
|
|
`show cris-mode'
|
| 1563 |
|
|
Show the current CRIS mode.
|
| 1564 |
|
|
|
| 1565 |
|
|
|
| 1566 |
|
|
File: gdb.info, Node: Super-H, Prev: CRIS, Up: Embedded Processors
|
| 1567 |
|
|
|
| 1568 |
|
|
21.3.14 Renesas Super-H
|
| 1569 |
|
|
-----------------------
|
| 1570 |
|
|
|
| 1571 |
|
|
For the Renesas Super-H processor, GDB provides these commands:
|
| 1572 |
|
|
|
| 1573 |
|
|
`regs'
|
| 1574 |
|
|
Show the values of all Super-H registers.
|
| 1575 |
|
|
|
| 1576 |
|
|
`set sh calling-convention CONVENTION'
|
| 1577 |
|
|
Set the calling-convention used when calling functions from GDB.
|
| 1578 |
|
|
Allowed values are `gcc', which is the default setting, and
|
| 1579 |
|
|
`renesas'. With the `gcc' setting, functions are called using the
|
| 1580 |
|
|
GCC calling convention. If the DWARF-2 information of the called
|
| 1581 |
|
|
function specifies that the function follows the Renesas calling
|
| 1582 |
|
|
convention, the function is called using the Renesas calling
|
| 1583 |
|
|
convention. If the calling convention is set to `renesas', the
|
| 1584 |
|
|
Renesas calling convention is always used, regardless of the
|
| 1585 |
|
|
DWARF-2 information. This can be used to override the default of
|
| 1586 |
|
|
`gcc' if debug information is missing, or the compiler does not
|
| 1587 |
|
|
emit the DWARF-2 calling convention entry for a function.
|
| 1588 |
|
|
|
| 1589 |
|
|
`show sh calling-convention'
|
| 1590 |
|
|
Show the current calling convention setting.
|
| 1591 |
|
|
|
| 1592 |
|
|
|
| 1593 |
|
|
|
| 1594 |
|
|
File: gdb.info, Node: Architectures, Prev: Embedded Processors, Up: Configurations
|
| 1595 |
|
|
|
| 1596 |
|
|
21.4 Architectures
|
| 1597 |
|
|
==================
|
| 1598 |
|
|
|
| 1599 |
|
|
This section describes characteristics of architectures that affect all
|
| 1600 |
|
|
uses of GDB with the architecture, both native and cross.
|
| 1601 |
|
|
|
| 1602 |
|
|
* Menu:
|
| 1603 |
|
|
|
| 1604 |
|
|
* i386::
|
| 1605 |
|
|
* A29K::
|
| 1606 |
|
|
* Alpha::
|
| 1607 |
|
|
* MIPS::
|
| 1608 |
|
|
* HPPA:: HP PA architecture
|
| 1609 |
|
|
* SPU:: Cell Broadband Engine SPU architecture
|
| 1610 |
|
|
* PowerPC::
|
| 1611 |
|
|
|
| 1612 |
|
|
|
| 1613 |
|
|
File: gdb.info, Node: i386, Next: A29K, Up: Architectures
|
| 1614 |
|
|
|
| 1615 |
|
|
21.4.1 x86 Architecture-specific Issues
|
| 1616 |
|
|
---------------------------------------
|
| 1617 |
|
|
|
| 1618 |
|
|
`set struct-convention MODE'
|
| 1619 |
|
|
Set the convention used by the inferior to return `struct's and
|
| 1620 |
|
|
`union's from functions to MODE. Possible values of MODE are
|
| 1621 |
|
|
`"pcc"', `"reg"', and `"default"' (the default). `"default"' or
|
| 1622 |
|
|
`"pcc"' means that `struct's are returned on the stack, while
|
| 1623 |
|
|
`"reg"' means that a `struct' or a `union' whose size is 1, 2, 4,
|
| 1624 |
|
|
or 8 bytes will be returned in a register.
|
| 1625 |
|
|
|
| 1626 |
|
|
`show struct-convention'
|
| 1627 |
|
|
Show the current setting of the convention to return `struct's
|
| 1628 |
|
|
from functions.
|
| 1629 |
|
|
|
| 1630 |
|
|
|
| 1631 |
|
|
File: gdb.info, Node: A29K, Next: Alpha, Prev: i386, Up: Architectures
|
| 1632 |
|
|
|
| 1633 |
|
|
21.4.2 A29K
|
| 1634 |
|
|
-----------
|
| 1635 |
|
|
|
| 1636 |
|
|
`set rstack_high_address ADDRESS'
|
| 1637 |
|
|
On AMD 29000 family processors, registers are saved in a separate
|
| 1638 |
|
|
"register stack". There is no way for GDB to determine the extent
|
| 1639 |
|
|
of this stack. Normally, GDB just assumes that the stack is
|
| 1640 |
|
|
"large enough". This may result in GDB referencing memory
|
| 1641 |
|
|
locations that do not exist. If necessary, you can get around
|
| 1642 |
|
|
this problem by specifying the ending address of the register
|
| 1643 |
|
|
stack with the `set rstack_high_address' command. The argument
|
| 1644 |
|
|
should be an address, which you probably want to precede with `0x'
|
| 1645 |
|
|
to specify in hexadecimal.
|
| 1646 |
|
|
|
| 1647 |
|
|
`show rstack_high_address'
|
| 1648 |
|
|
Display the current limit of the register stack, on AMD 29000
|
| 1649 |
|
|
family processors.
|
| 1650 |
|
|
|
| 1651 |
|
|
|
| 1652 |
|
|
|
| 1653 |
|
|
File: gdb.info, Node: Alpha, Next: MIPS, Prev: A29K, Up: Architectures
|
| 1654 |
|
|
|
| 1655 |
|
|
21.4.3 Alpha
|
| 1656 |
|
|
------------
|
| 1657 |
|
|
|
| 1658 |
|
|
See the following section.
|
| 1659 |
|
|
|
| 1660 |
|
|
|
| 1661 |
|
|
File: gdb.info, Node: MIPS, Next: HPPA, Prev: Alpha, Up: Architectures
|
| 1662 |
|
|
|
| 1663 |
|
|
21.4.4 MIPS
|
| 1664 |
|
|
-----------
|
| 1665 |
|
|
|
| 1666 |
|
|
Alpha- and MIPS-based computers use an unusual stack frame, which
|
| 1667 |
|
|
sometimes requires GDB to search backward in the object code to find
|
| 1668 |
|
|
the beginning of a function.
|
| 1669 |
|
|
|
| 1670 |
|
|
To improve response time (especially for embedded applications, where
|
| 1671 |
|
|
GDB may be restricted to a slow serial line for this search) you may
|
| 1672 |
|
|
want to limit the size of this search, using one of these commands:
|
| 1673 |
|
|
|
| 1674 |
|
|
`set heuristic-fence-post LIMIT'
|
| 1675 |
|
|
Restrict GDB to examining at most LIMIT bytes in its search for
|
| 1676 |
|
|
the beginning of a function. A value of 0 (the default) means
|
| 1677 |
|
|
there is no limit. However, except for 0, the larger the limit
|
| 1678 |
|
|
the more bytes `heuristic-fence-post' must search and therefore
|
| 1679 |
|
|
the longer it takes to run. You should only need to use this
|
| 1680 |
|
|
command when debugging a stripped executable.
|
| 1681 |
|
|
|
| 1682 |
|
|
`show heuristic-fence-post'
|
| 1683 |
|
|
Display the current limit.
|
| 1684 |
|
|
|
| 1685 |
|
|
These commands are available _only_ when GDB is configured for
|
| 1686 |
|
|
debugging programs on Alpha or MIPS processors.
|
| 1687 |
|
|
|
| 1688 |
|
|
Several MIPS-specific commands are available when debugging MIPS
|
| 1689 |
|
|
programs:
|
| 1690 |
|
|
|
| 1691 |
|
|
`set mips abi ARG'
|
| 1692 |
|
|
Tell GDB which MIPS ABI is used by the inferior. Possible values
|
| 1693 |
|
|
of ARG are:
|
| 1694 |
|
|
|
| 1695 |
|
|
`auto'
|
| 1696 |
|
|
The default ABI associated with the current binary (this is
|
| 1697 |
|
|
the default).
|
| 1698 |
|
|
|
| 1699 |
|
|
`o32'
|
| 1700 |
|
|
|
| 1701 |
|
|
`o64'
|
| 1702 |
|
|
|
| 1703 |
|
|
`n32'
|
| 1704 |
|
|
|
| 1705 |
|
|
`n64'
|
| 1706 |
|
|
|
| 1707 |
|
|
`eabi32'
|
| 1708 |
|
|
|
| 1709 |
|
|
`eabi64'
|
| 1710 |
|
|
|
| 1711 |
|
|
`auto'
|
| 1712 |
|
|
|
| 1713 |
|
|
`show mips abi'
|
| 1714 |
|
|
Show the MIPS ABI used by GDB to debug the inferior.
|
| 1715 |
|
|
|
| 1716 |
|
|
`set mipsfpu'
|
| 1717 |
|
|
`show mipsfpu'
|
| 1718 |
|
|
*Note set mipsfpu: MIPS Embedded.
|
| 1719 |
|
|
|
| 1720 |
|
|
`set mips mask-address ARG'
|
| 1721 |
|
|
This command determines whether the most-significant 32 bits of
|
| 1722 |
|
|
64-bit MIPS addresses are masked off. The argument ARG can be
|
| 1723 |
|
|
`on', `off', or `auto'. The latter is the default setting, which
|
| 1724 |
|
|
lets GDB determine the correct value.
|
| 1725 |
|
|
|
| 1726 |
|
|
`show mips mask-address'
|
| 1727 |
|
|
Show whether the upper 32 bits of MIPS addresses are masked off or
|
| 1728 |
|
|
not.
|
| 1729 |
|
|
|
| 1730 |
|
|
`set remote-mips64-transfers-32bit-regs'
|
| 1731 |
|
|
This command controls compatibility with 64-bit MIPS targets that
|
| 1732 |
|
|
transfer data in 32-bit quantities. If you have an old MIPS 64
|
| 1733 |
|
|
target that transfers 32 bits for some registers, like SR and FSR,
|
| 1734 |
|
|
and 64 bits for other registers, set this option to `on'.
|
| 1735 |
|
|
|
| 1736 |
|
|
`show remote-mips64-transfers-32bit-regs'
|
| 1737 |
|
|
Show the current setting of compatibility with older MIPS 64
|
| 1738 |
|
|
targets.
|
| 1739 |
|
|
|
| 1740 |
|
|
`set debug mips'
|
| 1741 |
|
|
This command turns on and off debugging messages for the
|
| 1742 |
|
|
MIPS-specific target code in GDB.
|
| 1743 |
|
|
|
| 1744 |
|
|
`show debug mips'
|
| 1745 |
|
|
Show the current setting of MIPS debugging messages.
|
| 1746 |
|
|
|
| 1747 |
|
|
|
| 1748 |
|
|
File: gdb.info, Node: HPPA, Next: SPU, Prev: MIPS, Up: Architectures
|
| 1749 |
|
|
|
| 1750 |
|
|
21.4.5 HPPA
|
| 1751 |
|
|
-----------
|
| 1752 |
|
|
|
| 1753 |
|
|
When GDB is debugging the HP PA architecture, it provides the following
|
| 1754 |
|
|
special commands:
|
| 1755 |
|
|
|
| 1756 |
|
|
`set debug hppa'
|
| 1757 |
|
|
This command determines whether HPPA architecture-specific
|
| 1758 |
|
|
debugging messages are to be displayed.
|
| 1759 |
|
|
|
| 1760 |
|
|
`show debug hppa'
|
| 1761 |
|
|
Show whether HPPA debugging messages are displayed.
|
| 1762 |
|
|
|
| 1763 |
|
|
`maint print unwind ADDRESS'
|
| 1764 |
|
|
This command displays the contents of the unwind table entry at the
|
| 1765 |
|
|
given ADDRESS.
|
| 1766 |
|
|
|
| 1767 |
|
|
|
| 1768 |
|
|
|
| 1769 |
|
|
File: gdb.info, Node: SPU, Next: PowerPC, Prev: HPPA, Up: Architectures
|
| 1770 |
|
|
|
| 1771 |
|
|
21.4.6 Cell Broadband Engine SPU architecture
|
| 1772 |
|
|
---------------------------------------------
|
| 1773 |
|
|
|
| 1774 |
|
|
When GDB is debugging the Cell Broadband Engine SPU architecture, it
|
| 1775 |
|
|
provides the following special commands:
|
| 1776 |
|
|
|
| 1777 |
|
|
`info spu event'
|
| 1778 |
|
|
Display SPU event facility status. Shows current event mask and
|
| 1779 |
|
|
pending event status.
|
| 1780 |
|
|
|
| 1781 |
|
|
`info spu signal'
|
| 1782 |
|
|
Display SPU signal notification facility status. Shows pending
|
| 1783 |
|
|
signal-control word and signal notification mode of both signal
|
| 1784 |
|
|
notification channels.
|
| 1785 |
|
|
|
| 1786 |
|
|
`info spu mailbox'
|
| 1787 |
|
|
Display SPU mailbox facility status. Shows all pending entries,
|
| 1788 |
|
|
in order of processing, in each of the SPU Write Outbound, SPU
|
| 1789 |
|
|
Write Outbound Interrupt, and SPU Read Inbound mailboxes.
|
| 1790 |
|
|
|
| 1791 |
|
|
`info spu dma'
|
| 1792 |
|
|
Display MFC DMA status. Shows all pending commands in the MFC DMA
|
| 1793 |
|
|
queue. For each entry, opcode, tag, class IDs, effective and
|
| 1794 |
|
|
local store addresses and transfer size are shown.
|
| 1795 |
|
|
|
| 1796 |
|
|
`info spu proxydma'
|
| 1797 |
|
|
Display MFC Proxy-DMA status. Shows all pending commands in the
|
| 1798 |
|
|
MFC Proxy-DMA queue. For each entry, opcode, tag, class IDs,
|
| 1799 |
|
|
effective and local store addresses and transfer size are shown.
|
| 1800 |
|
|
|
| 1801 |
|
|
|
| 1802 |
|
|
When GDB is debugging a combined PowerPC/SPU application on the Cell
|
| 1803 |
|
|
Broadband Engine, it provides in addition the following special
|
| 1804 |
|
|
commands:
|
| 1805 |
|
|
|
| 1806 |
|
|
`set spu stop-on-load ARG'
|
| 1807 |
|
|
Set whether to stop for new SPE threads. When set to `on', GDB
|
| 1808 |
|
|
will give control to the user when a new SPE thread enters its
|
| 1809 |
|
|
`main' function. The default is `off'.
|
| 1810 |
|
|
|
| 1811 |
|
|
`show spu stop-on-load'
|
| 1812 |
|
|
Show whether to stop for new SPE threads.
|
| 1813 |
|
|
|
| 1814 |
|
|
`set spu auto-flush-cache ARG'
|
| 1815 |
|
|
Set whether to automatically flush the software-managed cache.
|
| 1816 |
|
|
When set to `on', GDB will automatically cause the SPE
|
| 1817 |
|
|
software-managed cache to be flushed whenever SPE execution stops.
|
| 1818 |
|
|
This provides a consistent view of PowerPC memory that is
|
| 1819 |
|
|
accessed via the cache. If an application does not use the
|
| 1820 |
|
|
software-managed cache, this option has no effect.
|
| 1821 |
|
|
|
| 1822 |
|
|
`show spu auto-flush-cache'
|
| 1823 |
|
|
Show whether to automatically flush the software-managed cache.
|
| 1824 |
|
|
|
| 1825 |
|
|
|
| 1826 |
|
|
|
| 1827 |
|
|
File: gdb.info, Node: PowerPC, Prev: SPU, Up: Architectures
|
| 1828 |
|
|
|
| 1829 |
|
|
21.4.7 PowerPC
|
| 1830 |
|
|
--------------
|
| 1831 |
|
|
|
| 1832 |
|
|
When GDB is debugging the PowerPC architecture, it provides a set of
|
| 1833 |
|
|
pseudo-registers to enable inspection of 128-bit wide Decimal Floating
|
| 1834 |
|
|
Point numbers stored in the floating point registers. These values must
|
| 1835 |
|
|
be stored in two consecutive registers, always starting at an even
|
| 1836 |
|
|
register like `f0' or `f2'.
|
| 1837 |
|
|
|
| 1838 |
|
|
The pseudo-registers go from `$dl0' through `$dl15', and are formed
|
| 1839 |
|
|
by joining the even/odd register pairs `f0' and `f1' for `$dl0', `f2'
|
| 1840 |
|
|
and `f3' for `$dl1' and so on.
|
| 1841 |
|
|
|
| 1842 |
|
|
For POWER7 processors, GDB provides a set of pseudo-registers, the
|
| 1843 |
|
|
64-bit wide Extended Floating Point Registers (`f32' through `f63').
|
| 1844 |
|
|
|
| 1845 |
|
|
|
| 1846 |
|
|
File: gdb.info, Node: Controlling GDB, Next: Extending GDB, Prev: Configurations, Up: Top
|
| 1847 |
|
|
|
| 1848 |
|
|
22 Controlling GDB
|
| 1849 |
|
|
******************
|
| 1850 |
|
|
|
| 1851 |
|
|
You can alter the way GDB interacts with you by using the `set'
|
| 1852 |
|
|
command. For commands controlling how GDB displays data, see *Note
|
| 1853 |
|
|
Print Settings: Print Settings. Other settings are described here.
|
| 1854 |
|
|
|
| 1855 |
|
|
* Menu:
|
| 1856 |
|
|
|
| 1857 |
|
|
* Prompt:: Prompt
|
| 1858 |
|
|
* Editing:: Command editing
|
| 1859 |
|
|
* Command History:: Command history
|
| 1860 |
|
|
* Screen Size:: Screen size
|
| 1861 |
|
|
* Numbers:: Numbers
|
| 1862 |
|
|
* ABI:: Configuring the current ABI
|
| 1863 |
|
|
* Messages/Warnings:: Optional warnings and messages
|
| 1864 |
|
|
* Debugging Output:: Optional messages about internal happenings
|
| 1865 |
|
|
* Other Misc Settings:: Other Miscellaneous Settings
|
| 1866 |
|
|
|
| 1867 |
|
|
|
| 1868 |
|
|
File: gdb.info, Node: Prompt, Next: Editing, Up: Controlling GDB
|
| 1869 |
|
|
|
| 1870 |
|
|
22.1 Prompt
|
| 1871 |
|
|
===========
|
| 1872 |
|
|
|
| 1873 |
|
|
GDB indicates its readiness to read a command by printing a string
|
| 1874 |
|
|
called the "prompt". This string is normally `(gdb)'. You can change
|
| 1875 |
|
|
the prompt string with the `set prompt' command. For instance, when
|
| 1876 |
|
|
debugging GDB with GDB, it is useful to change the prompt in one of the
|
| 1877 |
|
|
GDB sessions so that you can always tell which one you are talking to.
|
| 1878 |
|
|
|
| 1879 |
|
|
_Note:_ `set prompt' does not add a space for you after the prompt
|
| 1880 |
|
|
you set. This allows you to set a prompt which ends in a space or a
|
| 1881 |
|
|
prompt that does not.
|
| 1882 |
|
|
|
| 1883 |
|
|
`set prompt NEWPROMPT'
|
| 1884 |
|
|
Directs GDB to use NEWPROMPT as its prompt string henceforth.
|
| 1885 |
|
|
|
| 1886 |
|
|
`show prompt'
|
| 1887 |
|
|
Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
|
| 1888 |
|
|
|
| 1889 |
|
|
|
| 1890 |
|
|
File: gdb.info, Node: Editing, Next: Command History, Prev: Prompt, Up: Controlling GDB
|
| 1891 |
|
|
|
| 1892 |
|
|
22.2 Command Editing
|
| 1893 |
|
|
====================
|
| 1894 |
|
|
|
| 1895 |
|
|
GDB reads its input commands via the "Readline" interface. This GNU
|
| 1896 |
|
|
library provides consistent behavior for programs which provide a
|
| 1897 |
|
|
command line interface to the user. Advantages are GNU Emacs-style or
|
| 1898 |
|
|
"vi"-style inline editing of commands, `csh'-like history substitution,
|
| 1899 |
|
|
and a storage and recall of command history across debugging sessions.
|
| 1900 |
|
|
|
| 1901 |
|
|
You may control the behavior of command line editing in GDB with the
|
| 1902 |
|
|
command `set'.
|
| 1903 |
|
|
|
| 1904 |
|
|
`set editing'
|
| 1905 |
|
|
`set editing on'
|
| 1906 |
|
|
Enable command line editing (enabled by default).
|
| 1907 |
|
|
|
| 1908 |
|
|
`set editing off'
|
| 1909 |
|
|
Disable command line editing.
|
| 1910 |
|
|
|
| 1911 |
|
|
`show editing'
|
| 1912 |
|
|
Show whether command line editing is enabled.
|
| 1913 |
|
|
|
| 1914 |
|
|
*Note Command Line Editing::, for more details about the Readline
|
| 1915 |
|
|
interface. Users unfamiliar with GNU Emacs or `vi' are encouraged to
|
| 1916 |
|
|
read that chapter.
|
| 1917 |
|
|
|
| 1918 |
|
|
|
| 1919 |
|
|
File: gdb.info, Node: Command History, Next: Screen Size, Prev: Editing, Up: Controlling GDB
|
| 1920 |
|
|
|
| 1921 |
|
|
22.3 Command History
|
| 1922 |
|
|
====================
|
| 1923 |
|
|
|
| 1924 |
|
|
GDB can keep track of the commands you type during your debugging
|
| 1925 |
|
|
sessions, so that you can be certain of precisely what happened. Use
|
| 1926 |
|
|
these commands to manage the GDB command history facility.
|
| 1927 |
|
|
|
| 1928 |
|
|
GDB uses the GNU History library, a part of the Readline package, to
|
| 1929 |
|
|
provide the history facility. *Note Using History Interactively::, for
|
| 1930 |
|
|
the detailed description of the History library.
|
| 1931 |
|
|
|
| 1932 |
|
|
To issue a command to GDB without affecting certain aspects of the
|
| 1933 |
|
|
state which is seen by users, prefix it with `server ' (*note Server
|
| 1934 |
|
|
Prefix::). This means that this command will not affect the command
|
| 1935 |
|
|
history, nor will it affect GDB's notion of which command to repeat if
|
| 1936 |
|
|
is pressed on a line by itself.
|
| 1937 |
|
|
|
| 1938 |
|
|
The server prefix does not affect the recording of values into the
|
| 1939 |
|
|
value history; to print a value without recording it into the value
|
| 1940 |
|
|
history, use the `output' command instead of the `print' command.
|
| 1941 |
|
|
|
| 1942 |
|
|
Here is the description of GDB commands related to command history.
|
| 1943 |
|
|
|
| 1944 |
|
|
`set history filename FNAME'
|
| 1945 |
|
|
Set the name of the GDB command history file to FNAME. This is
|
| 1946 |
|
|
the file where GDB reads an initial command history list, and
|
| 1947 |
|
|
where it writes the command history from this session when it
|
| 1948 |
|
|
exits. You can access this list through history expansion or
|
| 1949 |
|
|
through the history command editing characters listed below. This
|
| 1950 |
|
|
file defaults to the value of the environment variable
|
| 1951 |
|
|
`GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS)
|
| 1952 |
|
|
if this variable is not set.
|
| 1953 |
|
|
|
| 1954 |
|
|
`set history save'
|
| 1955 |
|
|
`set history save on'
|
| 1956 |
|
|
Record command history in a file, whose name may be specified with
|
| 1957 |
|
|
the `set history filename' command. By default, this option is
|
| 1958 |
|
|
disabled.
|
| 1959 |
|
|
|
| 1960 |
|
|
`set history save off'
|
| 1961 |
|
|
Stop recording command history in a file.
|
| 1962 |
|
|
|
| 1963 |
|
|
`set history size SIZE'
|
| 1964 |
|
|
Set the number of commands which GDB keeps in its history list.
|
| 1965 |
|
|
This defaults to the value of the environment variable `HISTSIZE',
|
| 1966 |
|
|
or to 256 if this variable is not set.
|
| 1967 |
|
|
|
| 1968 |
|
|
History expansion assigns special meaning to the character `!'.
|
| 1969 |
|
|
*Note Event Designators::, for more details.
|
| 1970 |
|
|
|
| 1971 |
|
|
Since `!' is also the logical not operator in C, history expansion
|
| 1972 |
|
|
is off by default. If you decide to enable history expansion with the
|
| 1973 |
|
|
`set history expansion on' command, you may sometimes need to follow
|
| 1974 |
|
|
`!' (when it is used as logical not, in an expression) with a space or
|
| 1975 |
|
|
a tab to prevent it from being expanded. The readline history
|
| 1976 |
|
|
facilities do not attempt substitution on the strings `!=' and `!(',
|
| 1977 |
|
|
even when history expansion is enabled.
|
| 1978 |
|
|
|
| 1979 |
|
|
The commands to control history expansion are:
|
| 1980 |
|
|
|
| 1981 |
|
|
`set history expansion on'
|
| 1982 |
|
|
`set history expansion'
|
| 1983 |
|
|
Enable history expansion. History expansion is off by default.
|
| 1984 |
|
|
|
| 1985 |
|
|
`set history expansion off'
|
| 1986 |
|
|
Disable history expansion.
|
| 1987 |
|
|
|
| 1988 |
|
|
`show history'
|
| 1989 |
|
|
`show history filename'
|
| 1990 |
|
|
`show history save'
|
| 1991 |
|
|
`show history size'
|
| 1992 |
|
|
`show history expansion'
|
| 1993 |
|
|
These commands display the state of the GDB history parameters.
|
| 1994 |
|
|
`show history' by itself displays all four states.
|
| 1995 |
|
|
|
| 1996 |
|
|
`show commands'
|
| 1997 |
|
|
Display the last ten commands in the command history.
|
| 1998 |
|
|
|
| 1999 |
|
|
`show commands N'
|
| 2000 |
|
|
Print ten commands centered on command number N.
|
| 2001 |
|
|
|
| 2002 |
|
|
`show commands +'
|
| 2003 |
|
|
Print ten commands just after the commands last printed.
|
| 2004 |
|
|
|
| 2005 |
|
|
|
| 2006 |
|
|
File: gdb.info, Node: Screen Size, Next: Numbers, Prev: Command History, Up: Controlling GDB
|
| 2007 |
|
|
|
| 2008 |
|
|
22.4 Screen Size
|
| 2009 |
|
|
================
|
| 2010 |
|
|
|
| 2011 |
|
|
Certain commands to GDB may produce large amounts of information output
|
| 2012 |
|
|
to the screen. To help you read all of it, GDB pauses and asks you for
|
| 2013 |
|
|
input at the end of each page of output. Type when you want to
|
| 2014 |
|
|
continue the output, or `q' to discard the remaining output. Also, the
|
| 2015 |
|
|
screen width setting determines when to wrap lines of output.
|
| 2016 |
|
|
Depending on what is being printed, GDB tries to break the line at a
|
| 2017 |
|
|
readable place, rather than simply letting it overflow onto the
|
| 2018 |
|
|
following line.
|
| 2019 |
|
|
|
| 2020 |
|
|
Normally GDB knows the size of the screen from the terminal driver
|
| 2021 |
|
|
software. For example, on Unix GDB uses the termcap data base together
|
| 2022 |
|
|
with the value of the `TERM' environment variable and the `stty rows'
|
| 2023 |
|
|
and `stty cols' settings. If this is not correct, you can override it
|
| 2024 |
|
|
with the `set height' and `set width' commands:
|
| 2025 |
|
|
|
| 2026 |
|
|
`set height LPP'
|
| 2027 |
|
|
`show height'
|
| 2028 |
|
|
`set width CPL'
|
| 2029 |
|
|
`show width'
|
| 2030 |
|
|
These `set' commands specify a screen height of LPP lines and a
|
| 2031 |
|
|
screen width of CPL characters. The associated `show' commands
|
| 2032 |
|
|
display the current settings.
|
| 2033 |
|
|
|
| 2034 |
|
|
If you specify a height of zero lines, GDB does not pause during
|
| 2035 |
|
|
output no matter how long the output is. This is useful if output
|
| 2036 |
|
|
is to a file or to an editor buffer.
|
| 2037 |
|
|
|
| 2038 |
|
|
Likewise, you can specify `set width 0' to prevent GDB from
|
| 2039 |
|
|
wrapping its output.
|
| 2040 |
|
|
|
| 2041 |
|
|
`set pagination on'
|
| 2042 |
|
|
`set pagination off'
|
| 2043 |
|
|
Turn the output pagination on or off; the default is on. Turning
|
| 2044 |
|
|
pagination off is the alternative to `set height 0'. Note that
|
| 2045 |
|
|
running GDB with the `--batch' option (*note -batch: Mode
|
| 2046 |
|
|
Options.) also automatically disables pagination.
|
| 2047 |
|
|
|
| 2048 |
|
|
`show pagination'
|
| 2049 |
|
|
Show the current pagination mode.
|
| 2050 |
|
|
|
| 2051 |
|
|
|
| 2052 |
|
|
File: gdb.info, Node: Numbers, Next: ABI, Prev: Screen Size, Up: Controlling GDB
|
| 2053 |
|
|
|
| 2054 |
|
|
22.5 Numbers
|
| 2055 |
|
|
============
|
| 2056 |
|
|
|
| 2057 |
|
|
You can always enter numbers in octal, decimal, or hexadecimal in GDB
|
| 2058 |
|
|
by the usual conventions: octal numbers begin with `0', decimal numbers
|
| 2059 |
|
|
end with `.', and hexadecimal numbers begin with `0x'. Numbers that
|
| 2060 |
|
|
neither begin with `0' or `0x', nor end with a `.' are, by default,
|
| 2061 |
|
|
entered in base 10; likewise, the default display for numbers--when no
|
| 2062 |
|
|
particular format is specified--is base 10. You can change the default
|
| 2063 |
|
|
base for both input and output with the commands described below.
|
| 2064 |
|
|
|
| 2065 |
|
|
`set input-radix BASE'
|
| 2066 |
|
|
Set the default base for numeric input. Supported choices for
|
| 2067 |
|
|
BASE are decimal 8, 10, or 16. BASE must itself be specified
|
| 2068 |
|
|
either unambiguously or using the current input radix; for
|
| 2069 |
|
|
example, any of
|
| 2070 |
|
|
|
| 2071 |
|
|
set input-radix 012
|
| 2072 |
|
|
set input-radix 10.
|
| 2073 |
|
|
set input-radix 0xa
|
| 2074 |
|
|
|
| 2075 |
|
|
sets the input base to decimal. On the other hand, `set
|
| 2076 |
|
|
input-radix 10' leaves the input radix unchanged, no matter what
|
| 2077 |
|
|
it was, since `10', being without any leading or trailing signs of
|
| 2078 |
|
|
its base, is interpreted in the current radix. Thus, if the
|
| 2079 |
|
|
current radix is 16, `10' is interpreted in hex, i.e. as 16
|
| 2080 |
|
|
decimal, which doesn't change the radix.
|
| 2081 |
|
|
|
| 2082 |
|
|
`set output-radix BASE'
|
| 2083 |
|
|
Set the default base for numeric display. Supported choices for
|
| 2084 |
|
|
BASE are decimal 8, 10, or 16. BASE must itself be specified
|
| 2085 |
|
|
either unambiguously or using the current input radix.
|
| 2086 |
|
|
|
| 2087 |
|
|
`show input-radix'
|
| 2088 |
|
|
Display the current default base for numeric input.
|
| 2089 |
|
|
|
| 2090 |
|
|
`show output-radix'
|
| 2091 |
|
|
Display the current default base for numeric display.
|
| 2092 |
|
|
|
| 2093 |
|
|
`set radix [BASE]'
|
| 2094 |
|
|
`show radix'
|
| 2095 |
|
|
These commands set and show the default base for both input and
|
| 2096 |
|
|
output of numbers. `set radix' sets the radix of input and output
|
| 2097 |
|
|
to the same base; without an argument, it resets the radix back to
|
| 2098 |
|
|
its default value of 10.
|
| 2099 |
|
|
|
| 2100 |
|
|
|
| 2101 |
|
|
|
| 2102 |
|
|
File: gdb.info, Node: ABI, Next: Messages/Warnings, Prev: Numbers, Up: Controlling GDB
|
| 2103 |
|
|
|
| 2104 |
|
|
22.6 Configuring the Current ABI
|
| 2105 |
|
|
================================
|
| 2106 |
|
|
|
| 2107 |
|
|
GDB can determine the "ABI" (Application Binary Interface) of your
|
| 2108 |
|
|
application automatically. However, sometimes you need to override its
|
| 2109 |
|
|
conclusions. Use these commands to manage GDB's view of the current
|
| 2110 |
|
|
ABI.
|
| 2111 |
|
|
|
| 2112 |
|
|
One GDB configuration can debug binaries for multiple operating
|
| 2113 |
|
|
system targets, either via remote debugging or native emulation. GDB
|
| 2114 |
|
|
will autodetect the "OS ABI" (Operating System ABI) in use, but you can
|
| 2115 |
|
|
override its conclusion using the `set osabi' command. One example
|
| 2116 |
|
|
where this is useful is in debugging of binaries which use an alternate
|
| 2117 |
|
|
C library (e.g. UCLIBC for GNU/Linux) which does not have the same
|
| 2118 |
|
|
identifying marks that the standard C library for your platform
|
| 2119 |
|
|
provides.
|
| 2120 |
|
|
|
| 2121 |
|
|
`show osabi'
|
| 2122 |
|
|
Show the OS ABI currently in use.
|
| 2123 |
|
|
|
| 2124 |
|
|
`set osabi'
|
| 2125 |
|
|
With no argument, show the list of registered available OS ABI's.
|
| 2126 |
|
|
|
| 2127 |
|
|
`set osabi ABI'
|
| 2128 |
|
|
Set the current OS ABI to ABI.
|
| 2129 |
|
|
|
| 2130 |
|
|
Generally, the way that an argument of type `float' is passed to a
|
| 2131 |
|
|
function depends on whether the function is prototyped. For a
|
| 2132 |
|
|
prototyped (i.e. ANSI/ISO style) function, `float' arguments are passed
|
| 2133 |
|
|
unchanged, according to the architecture's convention for `float'. For
|
| 2134 |
|
|
unprototyped (i.e. K&R style) functions, `float' arguments are first
|
| 2135 |
|
|
promoted to type `double' and then passed.
|
| 2136 |
|
|
|
| 2137 |
|
|
Unfortunately, some forms of debug information do not reliably
|
| 2138 |
|
|
indicate whether a function is prototyped. If GDB calls a function
|
| 2139 |
|
|
that is not marked as prototyped, it consults `set
|
| 2140 |
|
|
coerce-float-to-double'.
|
| 2141 |
|
|
|
| 2142 |
|
|
`set coerce-float-to-double'
|
| 2143 |
|
|
`set coerce-float-to-double on'
|
| 2144 |
|
|
Arguments of type `float' will be promoted to `double' when passed
|
| 2145 |
|
|
to an unprototyped function. This is the default setting.
|
| 2146 |
|
|
|
| 2147 |
|
|
`set coerce-float-to-double off'
|
| 2148 |
|
|
Arguments of type `float' will be passed directly to unprototyped
|
| 2149 |
|
|
functions.
|
| 2150 |
|
|
|
| 2151 |
|
|
`show coerce-float-to-double'
|
| 2152 |
|
|
Show the current setting of promoting `float' to `double'.
|
| 2153 |
|
|
|
| 2154 |
|
|
GDB needs to know the ABI used for your program's C++ objects. The
|
| 2155 |
|
|
correct C++ ABI depends on which C++ compiler was used to build your
|
| 2156 |
|
|
application. GDB only fully supports programs with a single C++ ABI;
|
| 2157 |
|
|
if your program contains code using multiple C++ ABI's or if GDB can
|
| 2158 |
|
|
not identify your program's ABI correctly, you can tell GDB which ABI
|
| 2159 |
|
|
to use. Currently supported ABI's include "gnu-v2", for `g++' versions
|
| 2160 |
|
|
before 3.0, "gnu-v3", for `g++' versions 3.0 and later, and "hpaCC" for
|
| 2161 |
|
|
the HP ANSI C++ compiler. Other C++ compilers may use the "gnu-v2" or
|
| 2162 |
|
|
"gnu-v3" ABI's as well. The default setting is "auto".
|
| 2163 |
|
|
|
| 2164 |
|
|
`show cp-abi'
|
| 2165 |
|
|
Show the C++ ABI currently in use.
|
| 2166 |
|
|
|
| 2167 |
|
|
`set cp-abi'
|
| 2168 |
|
|
With no argument, show the list of supported C++ ABI's.
|
| 2169 |
|
|
|
| 2170 |
|
|
`set cp-abi ABI'
|
| 2171 |
|
|
`set cp-abi auto'
|
| 2172 |
|
|
Set the current C++ ABI to ABI, or return to automatic detection.
|
| 2173 |
|
|
|
| 2174 |
|
|
|
| 2175 |
|
|
File: gdb.info, Node: Messages/Warnings, Next: Debugging Output, Prev: ABI, Up: Controlling GDB
|
| 2176 |
|
|
|
| 2177 |
|
|
22.7 Optional Warnings and Messages
|
| 2178 |
|
|
===================================
|
| 2179 |
|
|
|
| 2180 |
|
|
By default, GDB is silent about its inner workings. If you are running
|
| 2181 |
|
|
on a slow machine, you may want to use the `set verbose' command. This
|
| 2182 |
|
|
makes GDB tell you when it does a lengthy internal operation, so you
|
| 2183 |
|
|
will not think it has crashed.
|
| 2184 |
|
|
|
| 2185 |
|
|
Currently, the messages controlled by `set verbose' are those which
|
| 2186 |
|
|
announce that the symbol table for a source file is being read; see
|
| 2187 |
|
|
`symbol-file' in *Note Commands to Specify Files: Files.
|
| 2188 |
|
|
|
| 2189 |
|
|
`set verbose on'
|
| 2190 |
|
|
Enables GDB output of certain informational messages.
|
| 2191 |
|
|
|
| 2192 |
|
|
`set verbose off'
|
| 2193 |
|
|
Disables GDB output of certain informational messages.
|
| 2194 |
|
|
|
| 2195 |
|
|
`show verbose'
|
| 2196 |
|
|
Displays whether `set verbose' is on or off.
|
| 2197 |
|
|
|
| 2198 |
|
|
By default, if GDB encounters bugs in the symbol table of an object
|
| 2199 |
|
|
file, it is silent; but if you are debugging a compiler, you may find
|
| 2200 |
|
|
this information useful (*note Errors Reading Symbol Files: Symbol
|
| 2201 |
|
|
Errors.).
|
| 2202 |
|
|
|
| 2203 |
|
|
`set complaints LIMIT'
|
| 2204 |
|
|
Permits GDB to output LIMIT complaints about each type of unusual
|
| 2205 |
|
|
symbols before becoming silent about the problem. Set LIMIT to
|
| 2206 |
|
|
zero to suppress all complaints; set it to a large number to
|
| 2207 |
|
|
prevent complaints from being suppressed.
|
| 2208 |
|
|
|
| 2209 |
|
|
`show complaints'
|
| 2210 |
|
|
Displays how many symbol complaints GDB is permitted to produce.
|
| 2211 |
|
|
|
| 2212 |
|
|
|
| 2213 |
|
|
By default, GDB is cautious, and asks what sometimes seems to be a
|
| 2214 |
|
|
lot of stupid questions to confirm certain commands. For example, if
|
| 2215 |
|
|
you try to run a program which is already running:
|
| 2216 |
|
|
|
| 2217 |
|
|
(gdb) run
|
| 2218 |
|
|
The program being debugged has been started already.
|
| 2219 |
|
|
Start it from the beginning? (y or n)
|
| 2220 |
|
|
|
| 2221 |
|
|
If you are willing to unflinchingly face the consequences of your own
|
| 2222 |
|
|
commands, you can disable this "feature":
|
| 2223 |
|
|
|
| 2224 |
|
|
`set confirm off'
|
| 2225 |
|
|
Disables confirmation requests. Note that running GDB with the
|
| 2226 |
|
|
`--batch' option (*note -batch: Mode Options.) also automatically
|
| 2227 |
|
|
disables confirmation requests.
|
| 2228 |
|
|
|
| 2229 |
|
|
`set confirm on'
|
| 2230 |
|
|
Enables confirmation requests (the default).
|
| 2231 |
|
|
|
| 2232 |
|
|
`show confirm'
|
| 2233 |
|
|
Displays state of confirmation requests.
|
| 2234 |
|
|
|
| 2235 |
|
|
|
| 2236 |
|
|
If you need to debug user-defined commands or sourced files you may
|
| 2237 |
|
|
find it useful to enable "command tracing". In this mode each command
|
| 2238 |
|
|
will be printed as it is executed, prefixed with one or more `+'
|
| 2239 |
|
|
symbols, the quantity denoting the call depth of each command.
|
| 2240 |
|
|
|
| 2241 |
|
|
`set trace-commands on'
|
| 2242 |
|
|
Enable command tracing.
|
| 2243 |
|
|
|
| 2244 |
|
|
`set trace-commands off'
|
| 2245 |
|
|
Disable command tracing.
|
| 2246 |
|
|
|
| 2247 |
|
|
`show trace-commands'
|
| 2248 |
|
|
Display the current state of command tracing.
|
| 2249 |
|
|
|
| 2250 |
|
|
|
| 2251 |
|
|
File: gdb.info, Node: Debugging Output, Next: Other Misc Settings, Prev: Messages/Warnings, Up: Controlling GDB
|
| 2252 |
|
|
|
| 2253 |
|
|
22.8 Optional Messages about Internal Happenings
|
| 2254 |
|
|
================================================
|
| 2255 |
|
|
|
| 2256 |
|
|
GDB has commands that enable optional debugging messages from various
|
| 2257 |
|
|
GDB subsystems; normally these commands are of interest to GDB
|
| 2258 |
|
|
maintainers, or when reporting a bug. This section documents those
|
| 2259 |
|
|
commands.
|
| 2260 |
|
|
|
| 2261 |
|
|
`set exec-done-display'
|
| 2262 |
|
|
Turns on or off the notification of asynchronous commands'
|
| 2263 |
|
|
completion. When on, GDB will print a message when an
|
| 2264 |
|
|
asynchronous command finishes its execution. The default is off.
|
| 2265 |
|
|
|
| 2266 |
|
|
`show exec-done-display'
|
| 2267 |
|
|
Displays the current setting of asynchronous command completion
|
| 2268 |
|
|
notification.
|
| 2269 |
|
|
|
| 2270 |
|
|
`set debug arch'
|
| 2271 |
|
|
Turns on or off display of gdbarch debugging info. The default is
|
| 2272 |
|
|
off
|
| 2273 |
|
|
|
| 2274 |
|
|
`show debug arch'
|
| 2275 |
|
|
Displays the current state of displaying gdbarch debugging info.
|
| 2276 |
|
|
|
| 2277 |
|
|
`set debug aix-thread'
|
| 2278 |
|
|
Display debugging messages about inner workings of the AIX thread
|
| 2279 |
|
|
module.
|
| 2280 |
|
|
|
| 2281 |
|
|
`show debug aix-thread'
|
| 2282 |
|
|
Show the current state of AIX thread debugging info display.
|
| 2283 |
|
|
|
| 2284 |
|
|
`set debug dwarf2-die'
|
| 2285 |
|
|
Dump DWARF2 DIEs after they are read in. The value is the number
|
| 2286 |
|
|
of nesting levels to print. A value of zero turns off the display.
|
| 2287 |
|
|
|
| 2288 |
|
|
`show debug dwarf2-die'
|
| 2289 |
|
|
Show the current state of DWARF2 DIE debugging.
|
| 2290 |
|
|
|
| 2291 |
|
|
`set debug displaced'
|
| 2292 |
|
|
Turns on or off display of GDB debugging info for the displaced
|
| 2293 |
|
|
stepping support. The default is off.
|
| 2294 |
|
|
|
| 2295 |
|
|
`show debug displaced'
|
| 2296 |
|
|
Displays the current state of displaying GDB debugging info
|
| 2297 |
|
|
related to displaced stepping.
|
| 2298 |
|
|
|
| 2299 |
|
|
`set debug event'
|
| 2300 |
|
|
Turns on or off display of GDB event debugging info. The default
|
| 2301 |
|
|
is off.
|
| 2302 |
|
|
|
| 2303 |
|
|
`show debug event'
|
| 2304 |
|
|
Displays the current state of displaying GDB event debugging info.
|
| 2305 |
|
|
|
| 2306 |
|
|
`set debug expression'
|
| 2307 |
|
|
Turns on or off display of debugging info about GDB expression
|
| 2308 |
|
|
parsing. The default is off.
|
| 2309 |
|
|
|
| 2310 |
|
|
`show debug expression'
|
| 2311 |
|
|
Displays the current state of displaying debugging info about GDB
|
| 2312 |
|
|
expression parsing.
|
| 2313 |
|
|
|
| 2314 |
|
|
`set debug frame'
|
| 2315 |
|
|
Turns on or off display of GDB frame debugging info. The default
|
| 2316 |
|
|
is off.
|
| 2317 |
|
|
|
| 2318 |
|
|
`show debug frame'
|
| 2319 |
|
|
Displays the current state of displaying GDB frame debugging info.
|
| 2320 |
|
|
|
| 2321 |
|
|
`set debug gnu-nat'
|
| 2322 |
|
|
Turns on or off debugging messages from the GNU/Hurd debug support.
|
| 2323 |
|
|
|
| 2324 |
|
|
`show debug gnu-nat'
|
| 2325 |
|
|
Show the current state of GNU/Hurd debugging messages.
|
| 2326 |
|
|
|
| 2327 |
|
|
`set debug infrun'
|
| 2328 |
|
|
Turns on or off display of GDB debugging info for running the
|
| 2329 |
|
|
inferior. The default is off. `infrun.c' contains GDB's runtime
|
| 2330 |
|
|
state machine used for implementing operations such as
|
| 2331 |
|
|
single-stepping the inferior.
|
| 2332 |
|
|
|
| 2333 |
|
|
`show debug infrun'
|
| 2334 |
|
|
Displays the current state of GDB inferior debugging.
|
| 2335 |
|
|
|
| 2336 |
|
|
`set debug lin-lwp'
|
| 2337 |
|
|
Turns on or off debugging messages from the Linux LWP debug
|
| 2338 |
|
|
support.
|
| 2339 |
|
|
|
| 2340 |
|
|
`show debug lin-lwp'
|
| 2341 |
|
|
Show the current state of Linux LWP debugging messages.
|
| 2342 |
|
|
|
| 2343 |
|
|
`set debug lin-lwp-async'
|
| 2344 |
|
|
Turns on or off debugging messages from the Linux LWP async debug
|
| 2345 |
|
|
support.
|
| 2346 |
|
|
|
| 2347 |
|
|
`show debug lin-lwp-async'
|
| 2348 |
|
|
Show the current state of Linux LWP async debugging messages.
|
| 2349 |
|
|
|
| 2350 |
|
|
`set debug observer'
|
| 2351 |
|
|
Turns on or off display of GDB observer debugging. This includes
|
| 2352 |
|
|
info such as the notification of observable events.
|
| 2353 |
|
|
|
| 2354 |
|
|
`show debug observer'
|
| 2355 |
|
|
Displays the current state of observer debugging.
|
| 2356 |
|
|
|
| 2357 |
|
|
`set debug overload'
|
| 2358 |
|
|
Turns on or off display of GDB C++ overload debugging info. This
|
| 2359 |
|
|
includes info such as ranking of functions, etc. The default is
|
| 2360 |
|
|
off.
|
| 2361 |
|
|
|
| 2362 |
|
|
`show debug overload'
|
| 2363 |
|
|
Displays the current state of displaying GDB C++ overload
|
| 2364 |
|
|
debugging info.
|
| 2365 |
|
|
|
| 2366 |
|
|
`set debug parser'
|
| 2367 |
|
|
Turns on or off the display of expression parser debugging output.
|
| 2368 |
|
|
Internally, this sets the `yydebug' variable in the expression
|
| 2369 |
|
|
parser. *Note Tracing Your Parser: (bison)Tracing, for details.
|
| 2370 |
|
|
The default is off.
|
| 2371 |
|
|
|
| 2372 |
|
|
`show debug parser'
|
| 2373 |
|
|
Show the current state of expression parser debugging.
|
| 2374 |
|
|
|
| 2375 |
|
|
`set debug remote'
|
| 2376 |
|
|
Turns on or off display of reports on all packets sent back and
|
| 2377 |
|
|
forth across the serial line to the remote machine. The info is
|
| 2378 |
|
|
printed on the GDB standard output stream. The default is off.
|
| 2379 |
|
|
|
| 2380 |
|
|
`show debug remote'
|
| 2381 |
|
|
Displays the state of display of remote packets.
|
| 2382 |
|
|
|
| 2383 |
|
|
`set debug serial'
|
| 2384 |
|
|
Turns on or off display of GDB serial debugging info. The default
|
| 2385 |
|
|
is off.
|
| 2386 |
|
|
|
| 2387 |
|
|
`show debug serial'
|
| 2388 |
|
|
Displays the current state of displaying GDB serial debugging info.
|
| 2389 |
|
|
|
| 2390 |
|
|
`set debug solib-frv'
|
| 2391 |
|
|
Turns on or off debugging messages for FR-V shared-library code.
|
| 2392 |
|
|
|
| 2393 |
|
|
`show debug solib-frv'
|
| 2394 |
|
|
Display the current state of FR-V shared-library code debugging
|
| 2395 |
|
|
messages.
|
| 2396 |
|
|
|
| 2397 |
|
|
`set debug target'
|
| 2398 |
|
|
Turns on or off display of GDB target debugging info. This info
|
| 2399 |
|
|
includes what is going on at the target level of GDB, as it
|
| 2400 |
|
|
happens. The default is 0. Set it to 1 to track events, and to 2
|
| 2401 |
|
|
to also track the value of large memory transfers. Changes to
|
| 2402 |
|
|
this flag do not take effect until the next time you connect to a
|
| 2403 |
|
|
target or use the `run' command.
|
| 2404 |
|
|
|
| 2405 |
|
|
`show debug target'
|
| 2406 |
|
|
Displays the current state of displaying GDB target debugging info.
|
| 2407 |
|
|
|
| 2408 |
|
|
`set debug timestamp'
|
| 2409 |
|
|
Turns on or off display of timestamps with GDB debugging info.
|
| 2410 |
|
|
When enabled, seconds and microseconds are displayed before each
|
| 2411 |
|
|
debugging message.
|
| 2412 |
|
|
|
| 2413 |
|
|
`show debug timestamp'
|
| 2414 |
|
|
Displays the current state of displaying timestamps with GDB
|
| 2415 |
|
|
debugging info.
|
| 2416 |
|
|
|
| 2417 |
|
|
`set debugvarobj'
|
| 2418 |
|
|
Turns on or off display of GDB variable object debugging info. The
|
| 2419 |
|
|
default is off.
|
| 2420 |
|
|
|
| 2421 |
|
|
`show debugvarobj'
|
| 2422 |
|
|
Displays the current state of displaying GDB variable object
|
| 2423 |
|
|
debugging info.
|
| 2424 |
|
|
|
| 2425 |
|
|
`set debug xml'
|
| 2426 |
|
|
Turns on or off debugging messages for built-in XML parsers.
|
| 2427 |
|
|
|
| 2428 |
|
|
`show debug xml'
|
| 2429 |
|
|
Displays the current state of XML debugging messages.
|
| 2430 |
|
|
|
| 2431 |
|
|
|
| 2432 |
|
|
File: gdb.info, Node: Other Misc Settings, Prev: Debugging Output, Up: Controlling GDB
|
| 2433 |
|
|
|
| 2434 |
|
|
22.9 Other Miscellaneous Settings
|
| 2435 |
|
|
=================================
|
| 2436 |
|
|
|
| 2437 |
|
|
`set interactive-mode'
|
| 2438 |
|
|
If `on', forces GDB to operate interactively. If `off', forces
|
| 2439 |
|
|
GDB to operate non-interactively, If `auto' (the default), GDB
|
| 2440 |
|
|
guesses which mode to use, based on whether the debugger was
|
| 2441 |
|
|
started in a terminal or not.
|
| 2442 |
|
|
|
| 2443 |
|
|
In the vast majority of cases, the debugger should be able to guess
|
| 2444 |
|
|
correctly which mode should be used. But this setting can be
|
| 2445 |
|
|
useful in certain specific cases, such as running a MinGW GDB
|
| 2446 |
|
|
inside a cygwin window.
|
| 2447 |
|
|
|
| 2448 |
|
|
`show interactive-mode'
|
| 2449 |
|
|
Displays whether the debugger is operating in interactive mode or
|
| 2450 |
|
|
not.
|
| 2451 |
|
|
|
| 2452 |
|
|
|
| 2453 |
|
|
File: gdb.info, Node: Extending GDB, Next: Interpreters, Prev: Controlling GDB, Up: Top
|
| 2454 |
|
|
|
| 2455 |
|
|
23 Extending GDB
|
| 2456 |
|
|
****************
|
| 2457 |
|
|
|
| 2458 |
|
|
GDB provides two mechanisms for extension. The first is based on
|
| 2459 |
|
|
composition of GDB commands, and the second is based on the Python
|
| 2460 |
|
|
scripting language.
|
| 2461 |
|
|
|
| 2462 |
|
|
To facilitate the use of these extensions, GDB is capable of
|
| 2463 |
|
|
evaluating the contents of a file. When doing so, GDB can recognize
|
| 2464 |
|
|
which scripting language is being used by looking at the filename
|
| 2465 |
|
|
extension. Files with an unrecognized filename extension are always
|
| 2466 |
|
|
treated as a GDB Command Files. *Note Command files: Command Files.
|
| 2467 |
|
|
|
| 2468 |
|
|
You can control how GDB evaluates these files with the following
|
| 2469 |
|
|
setting:
|
| 2470 |
|
|
|
| 2471 |
|
|
`set script-extension off'
|
| 2472 |
|
|
All scripts are always evaluated as GDB Command Files.
|
| 2473 |
|
|
|
| 2474 |
|
|
`set script-extension soft'
|
| 2475 |
|
|
The debugger determines the scripting language based on filename
|
| 2476 |
|
|
extension. If this scripting language is supported, GDB evaluates
|
| 2477 |
|
|
the script using that language. Otherwise, it evaluates the file
|
| 2478 |
|
|
as a GDB Command File.
|
| 2479 |
|
|
|
| 2480 |
|
|
`set script-extension strict'
|
| 2481 |
|
|
The debugger determines the scripting language based on filename
|
| 2482 |
|
|
extension, and evaluates the script using that language. If the
|
| 2483 |
|
|
language is not supported, then the evaluation fails.
|
| 2484 |
|
|
|
| 2485 |
|
|
`show script-extension'
|
| 2486 |
|
|
Display the current value of the `script-extension' option.
|
| 2487 |
|
|
|
| 2488 |
|
|
|
| 2489 |
|
|
* Menu:
|
| 2490 |
|
|
|
| 2491 |
|
|
* Sequences:: Canned Sequences of Commands
|
| 2492 |
|
|
* Python:: Scripting GDB using Python
|
| 2493 |
|
|
|
| 2494 |
|
|
|
| 2495 |
|
|
File: gdb.info, Node: Sequences, Next: Python, Up: Extending GDB
|
| 2496 |
|
|
|
| 2497 |
|
|
23.1 Canned Sequences of Commands
|
| 2498 |
|
|
=================================
|
| 2499 |
|
|
|
| 2500 |
|
|
Aside from breakpoint commands (*note Breakpoint Command Lists: Break
|
| 2501 |
|
|
Commands.), GDB provides two ways to store sequences of commands for
|
| 2502 |
|
|
execution as a unit: user-defined commands and command files.
|
| 2503 |
|
|
|
| 2504 |
|
|
* Menu:
|
| 2505 |
|
|
|
| 2506 |
|
|
* Define:: How to define your own commands
|
| 2507 |
|
|
* Hooks:: Hooks for user-defined commands
|
| 2508 |
|
|
* Command Files:: How to write scripts of commands to be stored in a file
|
| 2509 |
|
|
* Output:: Commands for controlled output
|
| 2510 |
|
|
|
| 2511 |
|
|
|
| 2512 |
|
|
File: gdb.info, Node: Define, Next: Hooks, Up: Sequences
|
| 2513 |
|
|
|
| 2514 |
|
|
23.1.1 User-defined Commands
|
| 2515 |
|
|
----------------------------
|
| 2516 |
|
|
|
| 2517 |
|
|
A "user-defined command" is a sequence of GDB commands to which you
|
| 2518 |
|
|
assign a new name as a command. This is done with the `define'
|
| 2519 |
|
|
command. User commands may accept up to 10 arguments separated by
|
| 2520 |
|
|
whitespace. Arguments are accessed within the user command via
|
| 2521 |
|
|
`$arg0...$arg9'. A trivial example:
|
| 2522 |
|
|
|
| 2523 |
|
|
define adder
|
| 2524 |
|
|
print $arg0 + $arg1 + $arg2
|
| 2525 |
|
|
end
|
| 2526 |
|
|
|
| 2527 |
|
|
To execute the command use:
|
| 2528 |
|
|
|
| 2529 |
|
|
adder 1 2 3
|
| 2530 |
|
|
|
| 2531 |
|
|
This defines the command `adder', which prints the sum of its three
|
| 2532 |
|
|
arguments. Note the arguments are text substitutions, so they may
|
| 2533 |
|
|
reference variables, use complex expressions, or even perform inferior
|
| 2534 |
|
|
functions calls.
|
| 2535 |
|
|
|
| 2536 |
|
|
In addition, `$argc' may be used to find out how many arguments have
|
| 2537 |
|
|
been passed. This expands to a number in the range 0...10.
|
| 2538 |
|
|
|
| 2539 |
|
|
define adder
|
| 2540 |
|
|
if $argc == 2
|
| 2541 |
|
|
print $arg0 + $arg1
|
| 2542 |
|
|
end
|
| 2543 |
|
|
if $argc == 3
|
| 2544 |
|
|
print $arg0 + $arg1 + $arg2
|
| 2545 |
|
|
end
|
| 2546 |
|
|
end
|
| 2547 |
|
|
|
| 2548 |
|
|
`define COMMANDNAME'
|
| 2549 |
|
|
Define a command named COMMANDNAME. If there is already a command
|
| 2550 |
|
|
by that name, you are asked to confirm that you want to redefine
|
| 2551 |
|
|
it. COMMANDNAME may be a bare command name consisting of letters,
|
| 2552 |
|
|
numbers, dashes, and underscores. It may also start with any
|
| 2553 |
|
|
predefined prefix command. For example, `define target my-target'
|
| 2554 |
|
|
creates a user-defined `target my-target' command.
|
| 2555 |
|
|
|
| 2556 |
|
|
The definition of the command is made up of other GDB command
|
| 2557 |
|
|
lines, which are given following the `define' command. The end of
|
| 2558 |
|
|
these commands is marked by a line containing `end'.
|
| 2559 |
|
|
|
| 2560 |
|
|
`document COMMANDNAME'
|
| 2561 |
|
|
Document the user-defined command COMMANDNAME, so that it can be
|
| 2562 |
|
|
accessed by `help'. The command COMMANDNAME must already be
|
| 2563 |
|
|
defined. This command reads lines of documentation just as
|
| 2564 |
|
|
`define' reads the lines of the command definition, ending with
|
| 2565 |
|
|
`end'. After the `document' command is finished, `help' on command
|
| 2566 |
|
|
COMMANDNAME displays the documentation you have written.
|
| 2567 |
|
|
|
| 2568 |
|
|
You may use the `document' command again to change the
|
| 2569 |
|
|
documentation of a command. Redefining the command with `define'
|
| 2570 |
|
|
does not change the documentation.
|
| 2571 |
|
|
|
| 2572 |
|
|
`dont-repeat'
|
| 2573 |
|
|
Used inside a user-defined command, this tells GDB that this
|
| 2574 |
|
|
command should not be repeated when the user hits (*note
|
| 2575 |
|
|
repeat last command: Command Syntax.).
|
| 2576 |
|
|
|
| 2577 |
|
|
`help user-defined'
|
| 2578 |
|
|
List all user-defined commands, with the first line of the
|
| 2579 |
|
|
documentation (if any) for each.
|
| 2580 |
|
|
|
| 2581 |
|
|
`show user'
|
| 2582 |
|
|
`show user COMMANDNAME'
|
| 2583 |
|
|
Display the GDB commands used to define COMMANDNAME (but not its
|
| 2584 |
|
|
documentation). If no COMMANDNAME is given, display the
|
| 2585 |
|
|
definitions for all user-defined commands.
|
| 2586 |
|
|
|
| 2587 |
|
|
`show max-user-call-depth'
|
| 2588 |
|
|
`set max-user-call-depth'
|
| 2589 |
|
|
The value of `max-user-call-depth' controls how many recursion
|
| 2590 |
|
|
levels are allowed in user-defined commands before GDB suspects an
|
| 2591 |
|
|
infinite recursion and aborts the command.
|
| 2592 |
|
|
|
| 2593 |
|
|
In addition to the above commands, user-defined commands frequently
|
| 2594 |
|
|
use control flow commands, described in *Note Command Files::.
|
| 2595 |
|
|
|
| 2596 |
|
|
When user-defined commands are executed, the commands of the
|
| 2597 |
|
|
definition are not printed. An error in any command stops execution of
|
| 2598 |
|
|
the user-defined command.
|
| 2599 |
|
|
|
| 2600 |
|
|
If used interactively, commands that would ask for confirmation
|
| 2601 |
|
|
proceed without asking when used inside a user-defined command. Many
|
| 2602 |
|
|
GDB commands that normally print messages to say what they are doing
|
| 2603 |
|
|
omit the messages when used in a user-defined command.
|
| 2604 |
|
|
|
| 2605 |
|
|
|
| 2606 |
|
|
File: gdb.info, Node: Hooks, Next: Command Files, Prev: Define, Up: Sequences
|
| 2607 |
|
|
|
| 2608 |
|
|
23.1.2 User-defined Command Hooks
|
| 2609 |
|
|
---------------------------------
|
| 2610 |
|
|
|
| 2611 |
|
|
You may define "hooks", which are a special kind of user-defined
|
| 2612 |
|
|
command. Whenever you run the command `foo', if the user-defined
|
| 2613 |
|
|
command `hook-foo' exists, it is executed (with no arguments) before
|
| 2614 |
|
|
that command.
|
| 2615 |
|
|
|
| 2616 |
|
|
A hook may also be defined which is run after the command you
|
| 2617 |
|
|
executed. Whenever you run the command `foo', if the user-defined
|
| 2618 |
|
|
command `hookpost-foo' exists, it is executed (with no arguments) after
|
| 2619 |
|
|
that command. Post-execution hooks may exist simultaneously with
|
| 2620 |
|
|
pre-execution hooks, for the same command.
|
| 2621 |
|
|
|
| 2622 |
|
|
It is valid for a hook to call the command which it hooks. If this
|
| 2623 |
|
|
occurs, the hook is not re-executed, thereby avoiding infinite
|
| 2624 |
|
|
recursion.
|
| 2625 |
|
|
|
| 2626 |
|
|
In addition, a pseudo-command, `stop' exists. Defining
|
| 2627 |
|
|
(`hook-stop') makes the associated commands execute every time
|
| 2628 |
|
|
execution stops in your program: before breakpoint commands are run,
|
| 2629 |
|
|
displays are printed, or the stack frame is printed.
|
| 2630 |
|
|
|
| 2631 |
|
|
For example, to ignore `SIGALRM' signals while single-stepping, but
|
| 2632 |
|
|
treat them normally during normal execution, you could define:
|
| 2633 |
|
|
|
| 2634 |
|
|
define hook-stop
|
| 2635 |
|
|
handle SIGALRM nopass
|
| 2636 |
|
|
end
|
| 2637 |
|
|
|
| 2638 |
|
|
define hook-run
|
| 2639 |
|
|
handle SIGALRM pass
|
| 2640 |
|
|
end
|
| 2641 |
|
|
|
| 2642 |
|
|
define hook-continue
|
| 2643 |
|
|
handle SIGALRM pass
|
| 2644 |
|
|
end
|
| 2645 |
|
|
|
| 2646 |
|
|
As a further example, to hook at the beginning and end of the `echo'
|
| 2647 |
|
|
command, and to add extra text to the beginning and end of the message,
|
| 2648 |
|
|
you could define:
|
| 2649 |
|
|
|
| 2650 |
|
|
define hook-echo
|
| 2651 |
|
|
echo <<<---
|
| 2652 |
|
|
end
|
| 2653 |
|
|
|
| 2654 |
|
|
define hookpost-echo
|
| 2655 |
|
|
echo --->>>\n
|
| 2656 |
|
|
end
|
| 2657 |
|
|
|
| 2658 |
|
|
(gdb) echo Hello World
|
| 2659 |
|
|
<<<---Hello World--->>>
|
| 2660 |
|
|
(gdb)
|
| 2661 |
|
|
|
| 2662 |
|
|
You can define a hook for any single-word command in GDB, but not
|
| 2663 |
|
|
for command aliases; you should define a hook for the basic command
|
| 2664 |
|
|
name, e.g. `backtrace' rather than `bt'. You can hook a multi-word
|
| 2665 |
|
|
command by adding `hook-' or `hookpost-' to the last word of the
|
| 2666 |
|
|
command, e.g. `define target hook-remote' to add a hook to `target
|
| 2667 |
|
|
remote'.
|
| 2668 |
|
|
|
| 2669 |
|
|
If an error occurs during the execution of your hook, execution of
|
| 2670 |
|
|
GDB commands stops and GDB issues a prompt (before the command that you
|
| 2671 |
|
|
actually typed had a chance to run).
|
| 2672 |
|
|
|
| 2673 |
|
|
If you try to define a hook which does not match any known command,
|
| 2674 |
|
|
you get a warning from the `define' command.
|
| 2675 |
|
|
|
| 2676 |
|
|
|
| 2677 |
|
|
File: gdb.info, Node: Command Files, Next: Output, Prev: Hooks, Up: Sequences
|
| 2678 |
|
|
|
| 2679 |
|
|
23.1.3 Command Files
|
| 2680 |
|
|
--------------------
|
| 2681 |
|
|
|
| 2682 |
|
|
A command file for GDB is a text file made of lines that are GDB
|
| 2683 |
|
|
commands. Comments (lines starting with `#') may also be included. An
|
| 2684 |
|
|
empty line in a command file does nothing; it does not mean to repeat
|
| 2685 |
|
|
the last command, as it would from the terminal.
|
| 2686 |
|
|
|
| 2687 |
|
|
You can request the execution of a command file with the `source'
|
| 2688 |
|
|
command. Note that the `source' command is also used to evaluate
|
| 2689 |
|
|
scripts that are not Command Files. The exact behavior can be
|
| 2690 |
|
|
configured using the `script-extension' setting. *Note Extending GDB:
|
| 2691 |
|
|
Extending GDB.
|
| 2692 |
|
|
|
| 2693 |
|
|
`source [-s] [-v] FILENAME'
|
| 2694 |
|
|
Execute the command file FILENAME.
|
| 2695 |
|
|
|
| 2696 |
|
|
The lines in a command file are generally executed sequentially,
|
| 2697 |
|
|
unless the order of execution is changed by one of the _flow-control
|
| 2698 |
|
|
commands_ described below. The commands are not printed as they are
|
| 2699 |
|
|
executed. An error in any command terminates execution of the command
|
| 2700 |
|
|
file and control is returned to the console.
|
| 2701 |
|
|
|
| 2702 |
|
|
GDB first searches for FILENAME in the current directory. If the
|
| 2703 |
|
|
file is not found there, and FILENAME does not specify a directory,
|
| 2704 |
|
|
then GDB also looks for the file on the source search path (specified
|
| 2705 |
|
|
with the `directory' command); except that `$cdir' is not searched
|
| 2706 |
|
|
because the compilation directory is not relevant to scripts.
|
| 2707 |
|
|
|
| 2708 |
|
|
If `-s' is specified, then GDB searches for FILENAME on the search
|
| 2709 |
|
|
path even if FILENAME specifies a directory. The search is done by
|
| 2710 |
|
|
appending FILENAME to each element of the search path. So, for
|
| 2711 |
|
|
example, if FILENAME is `mylib/myscript' and the search path contains
|
| 2712 |
|
|
`/home/user' then GDB will look for the script
|
| 2713 |
|
|
`/home/user/mylib/myscript'. The search is also done if FILENAME is an
|
| 2714 |
|
|
absolute path. For example, if FILENAME is `/tmp/myscript' and the
|
| 2715 |
|
|
search path contains `/home/user' then GDB will look for the script
|
| 2716 |
|
|
`/home/user/tmp/myscript'. For DOS-like systems, if FILENAME contains
|
| 2717 |
|
|
a drive specification, it is stripped before concatenation. For
|
| 2718 |
|
|
example, if FILENAME is `d:myscript' and the search path contains
|
| 2719 |
|
|
`c:/tmp' then GDB will look for the script `c:/tmp/myscript'.
|
| 2720 |
|
|
|
| 2721 |
|
|
If `-v', for verbose mode, is given then GDB displays each command
|
| 2722 |
|
|
as it is executed. The option must be given before FILENAME, and is
|
| 2723 |
|
|
interpreted as part of the filename anywhere else.
|
| 2724 |
|
|
|
| 2725 |
|
|
Commands that would ask for confirmation if used interactively
|
| 2726 |
|
|
proceed without asking when used in a command file. Many GDB commands
|
| 2727 |
|
|
that normally print messages to say what they are doing omit the
|
| 2728 |
|
|
messages when called from command files.
|
| 2729 |
|
|
|
| 2730 |
|
|
GDB also accepts command input from standard input. In this mode,
|
| 2731 |
|
|
normal output goes to standard output and error output goes to standard
|
| 2732 |
|
|
error. Errors in a command file supplied on standard input do not
|
| 2733 |
|
|
terminate execution of the command file--execution continues with the
|
| 2734 |
|
|
next command.
|
| 2735 |
|
|
|
| 2736 |
|
|
gdb < cmds > log 2>&1
|
| 2737 |
|
|
|
| 2738 |
|
|
(The syntax above will vary depending on the shell used.) This
|
| 2739 |
|
|
example will execute commands from the file `cmds'. All output and
|
| 2740 |
|
|
errors would be directed to `log'.
|
| 2741 |
|
|
|
| 2742 |
|
|
Since commands stored on command files tend to be more general than
|
| 2743 |
|
|
commands typed interactively, they frequently need to deal with
|
| 2744 |
|
|
complicated situations, such as different or unexpected values of
|
| 2745 |
|
|
variables and symbols, changes in how the program being debugged is
|
| 2746 |
|
|
built, etc. GDB provides a set of flow-control commands to deal with
|
| 2747 |
|
|
these complexities. Using these commands, you can write complex
|
| 2748 |
|
|
scripts that loop over data structures, execute commands conditionally,
|
| 2749 |
|
|
etc.
|
| 2750 |
|
|
|
| 2751 |
|
|
`if'
|
| 2752 |
|
|
`else'
|
| 2753 |
|
|
This command allows to include in your script conditionally
|
| 2754 |
|
|
executed commands. The `if' command takes a single argument, which
|
| 2755 |
|
|
is an expression to evaluate. It is followed by a series of
|
| 2756 |
|
|
commands that are executed only if the expression is true (its
|
| 2757 |
|
|
value is nonzero). There can then optionally be an `else' line,
|
| 2758 |
|
|
followed by a series of commands that are only executed if the
|
| 2759 |
|
|
expression was false. The end of the list is marked by a line
|
| 2760 |
|
|
containing `end'.
|
| 2761 |
|
|
|
| 2762 |
|
|
`while'
|
| 2763 |
|
|
This command allows to write loops. Its syntax is similar to
|
| 2764 |
|
|
`if': the command takes a single argument, which is an expression
|
| 2765 |
|
|
to evaluate, and must be followed by the commands to execute, one
|
| 2766 |
|
|
per line, terminated by an `end'. These commands are called the
|
| 2767 |
|
|
"body" of the loop. The commands in the body of `while' are
|
| 2768 |
|
|
executed repeatedly as long as the expression evaluates to true.
|
| 2769 |
|
|
|
| 2770 |
|
|
`loop_break'
|
| 2771 |
|
|
This command exits the `while' loop in whose body it is included.
|
| 2772 |
|
|
Execution of the script continues after that `while's `end' line.
|
| 2773 |
|
|
|
| 2774 |
|
|
`loop_continue'
|
| 2775 |
|
|
This command skips the execution of the rest of the body of
|
| 2776 |
|
|
commands in the `while' loop in whose body it is included.
|
| 2777 |
|
|
Execution branches to the beginning of the `while' loop, where it
|
| 2778 |
|
|
evaluates the controlling expression.
|
| 2779 |
|
|
|
| 2780 |
|
|
`end'
|
| 2781 |
|
|
Terminate the block of commands that are the body of `if', `else',
|
| 2782 |
|
|
or `while' flow-control commands.
|
| 2783 |
|
|
|
| 2784 |
|
|
|
| 2785 |
|
|
File: gdb.info, Node: Output, Prev: Command Files, Up: Sequences
|
| 2786 |
|
|
|
| 2787 |
|
|
23.1.4 Commands for Controlled Output
|
| 2788 |
|
|
-------------------------------------
|
| 2789 |
|
|
|
| 2790 |
|
|
During the execution of a command file or a user-defined command, normal
|
| 2791 |
|
|
GDB output is suppressed; the only output that appears is what is
|
| 2792 |
|
|
explicitly printed by the commands in the definition. This section
|
| 2793 |
|
|
describes three commands useful for generating exactly the output you
|
| 2794 |
|
|
want.
|
| 2795 |
|
|
|
| 2796 |
|
|
`echo TEXT'
|
| 2797 |
|
|
Print TEXT. Nonprinting characters can be included in TEXT using
|
| 2798 |
|
|
C escape sequences, such as `\n' to print a newline. *No newline
|
| 2799 |
|
|
is printed unless you specify one.* In addition to the standard C
|
| 2800 |
|
|
escape sequences, a backslash followed by a space stands for a
|
| 2801 |
|
|
space. This is useful for displaying a string with spaces at the
|
| 2802 |
|
|
beginning or the end, since leading and trailing spaces are
|
| 2803 |
|
|
otherwise trimmed from all arguments. To print ` and foo = ', use
|
| 2804 |
|
|
the command `echo \ and foo = \ '.
|
| 2805 |
|
|
|
| 2806 |
|
|
A backslash at the end of TEXT can be used, as in C, to continue
|
| 2807 |
|
|
the command onto subsequent lines. For example,
|
| 2808 |
|
|
|
| 2809 |
|
|
echo This is some text\n\
|
| 2810 |
|
|
which is continued\n\
|
| 2811 |
|
|
onto several lines.\n
|
| 2812 |
|
|
|
| 2813 |
|
|
produces the same output as
|
| 2814 |
|
|
|
| 2815 |
|
|
echo This is some text\n
|
| 2816 |
|
|
echo which is continued\n
|
| 2817 |
|
|
echo onto several lines.\n
|
| 2818 |
|
|
|
| 2819 |
|
|
`output EXPRESSION'
|
| 2820 |
|
|
Print the value of EXPRESSION and nothing but that value: no
|
| 2821 |
|
|
newlines, no `$NN = '. The value is not entered in the value
|
| 2822 |
|
|
history either. *Note Expressions: Expressions, for more
|
| 2823 |
|
|
information on expressions.
|
| 2824 |
|
|
|
| 2825 |
|
|
`output/FMT EXPRESSION'
|
| 2826 |
|
|
Print the value of EXPRESSION in format FMT. You can use the same
|
| 2827 |
|
|
formats as for `print'. *Note Output Formats: Output Formats, for
|
| 2828 |
|
|
more information.
|
| 2829 |
|
|
|
| 2830 |
|
|
`printf TEMPLATE, EXPRESSIONS...'
|
| 2831 |
|
|
Print the values of one or more EXPRESSIONS under the control of
|
| 2832 |
|
|
the string TEMPLATE. To print several values, make EXPRESSIONS be
|
| 2833 |
|
|
a comma-separated list of individual expressions, which may be
|
| 2834 |
|
|
either numbers or pointers. Their values are printed as specified
|
| 2835 |
|
|
by TEMPLATE, exactly as a C program would do by executing the code
|
| 2836 |
|
|
below:
|
| 2837 |
|
|
|
| 2838 |
|
|
printf (TEMPLATE, EXPRESSIONS...);
|
| 2839 |
|
|
|
| 2840 |
|
|
As in `C' `printf', ordinary characters in TEMPLATE are printed
|
| 2841 |
|
|
verbatim, while "conversion specification" introduced by the `%'
|
| 2842 |
|
|
character cause subsequent EXPRESSIONS to be evaluated, their
|
| 2843 |
|
|
values converted and formatted according to type and style
|
| 2844 |
|
|
information encoded in the conversion specifications, and then
|
| 2845 |
|
|
printed.
|
| 2846 |
|
|
|
| 2847 |
|
|
For example, you can print two values in hex like this:
|
| 2848 |
|
|
|
| 2849 |
|
|
printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
|
| 2850 |
|
|
|
| 2851 |
|
|
`printf' supports all the standard `C' conversion specifications,
|
| 2852 |
|
|
including the flags and modifiers between the `%' character and
|
| 2853 |
|
|
the conversion letter, with the following exceptions:
|
| 2854 |
|
|
|
| 2855 |
|
|
* The argument-ordering modifiers, such as `2$', are not
|
| 2856 |
|
|
supported.
|
| 2857 |
|
|
|
| 2858 |
|
|
* The modifier `*' is not supported for specifying precision or
|
| 2859 |
|
|
width.
|
| 2860 |
|
|
|
| 2861 |
|
|
* The `'' flag (for separation of digits into groups according
|
| 2862 |
|
|
to `LC_NUMERIC'') is not supported.
|
| 2863 |
|
|
|
| 2864 |
|
|
* The type modifiers `hh', `j', `t', and `z' are not supported.
|
| 2865 |
|
|
|
| 2866 |
|
|
* The conversion letter `n' (as in `%n') is not supported.
|
| 2867 |
|
|
|
| 2868 |
|
|
* The conversion letters `a' and `A' are not supported.
|
| 2869 |
|
|
|
| 2870 |
|
|
Note that the `ll' type modifier is supported only if the
|
| 2871 |
|
|
underlying `C' implementation used to build GDB supports the `long
|
| 2872 |
|
|
long int' type, and the `L' type modifier is supported only if
|
| 2873 |
|
|
`long double' type is available.
|
| 2874 |
|
|
|
| 2875 |
|
|
As in `C', `printf' supports simple backslash-escape sequences,
|
| 2876 |
|
|
such as `\n', `\t', `\\', `\"', `\a', and `\f', that consist of
|
| 2877 |
|
|
backslash followed by a single character. Octal and hexadecimal
|
| 2878 |
|
|
escape sequences are not supported.
|
| 2879 |
|
|
|
| 2880 |
|
|
Additionally, `printf' supports conversion specifications for DFP
|
| 2881 |
|
|
("Decimal Floating Point") types using the following length
|
| 2882 |
|
|
modifiers together with a floating point specifier. letters:
|
| 2883 |
|
|
|
| 2884 |
|
|
* `H' for printing `Decimal32' types.
|
| 2885 |
|
|
|
| 2886 |
|
|
* `D' for printing `Decimal64' types.
|
| 2887 |
|
|
|
| 2888 |
|
|
* `DD' for printing `Decimal128' types.
|
| 2889 |
|
|
|
| 2890 |
|
|
If the underlying `C' implementation used to build GDB has support
|
| 2891 |
|
|
for the three length modifiers for DFP types, other modifiers such
|
| 2892 |
|
|
as width and precision will also be available for GDB to use.
|
| 2893 |
|
|
|
| 2894 |
|
|
In case there is no such `C' support, no additional modifiers will
|
| 2895 |
|
|
be available and the value will be printed in the standard way.
|
| 2896 |
|
|
|
| 2897 |
|
|
Here's an example of printing DFP types using the above conversion
|
| 2898 |
|
|
letters:
|
| 2899 |
|
|
printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
|
| 2900 |
|
|
|
| 2901 |
|
|
`eval TEMPLATE, EXPRESSIONS...'
|
| 2902 |
|
|
Convert the values of one or more EXPRESSIONS under the control of
|
| 2903 |
|
|
the string TEMPLATE to a command line, and call it.
|
| 2904 |
|
|
|
| 2905 |
|
|
|
| 2906 |
|
|
|
| 2907 |
|
|
File: gdb.info, Node: Python, Prev: Sequences, Up: Extending GDB
|
| 2908 |
|
|
|
| 2909 |
|
|
23.2 Scripting GDB using Python
|
| 2910 |
|
|
===============================
|
| 2911 |
|
|
|
| 2912 |
|
|
You can script GDB using the Python programming language
|
| 2913 |
|
|
(http://www.python.org/). This feature is available only if GDB was
|
| 2914 |
|
|
configured using `--with-python'.
|
| 2915 |
|
|
|
| 2916 |
|
|
Python scripts used by GDB should be installed in
|
| 2917 |
|
|
`DATA-DIRECTORY/python', where DATA-DIRECTORY is the data directory as
|
| 2918 |
|
|
determined at GDB startup (*note Data Files::). This directory, known
|
| 2919 |
|
|
as the "python directory", is automatically added to the Python Search
|
| 2920 |
|
|
Path in order to allow the Python interpreter to locate all scripts
|
| 2921 |
|
|
installed at this location.
|
| 2922 |
|
|
|
| 2923 |
|
|
* Menu:
|
| 2924 |
|
|
|
| 2925 |
|
|
* Python Commands:: Accessing Python from GDB.
|
| 2926 |
|
|
* Python API:: Accessing GDB from Python.
|
| 2927 |
|
|
* Auto-loading:: Automatically loading Python code.
|
| 2928 |
|
|
|
| 2929 |
|
|
|
| 2930 |
|
|
File: gdb.info, Node: Python Commands, Next: Python API, Up: Python
|
| 2931 |
|
|
|
| 2932 |
|
|
23.2.1 Python Commands
|
| 2933 |
|
|
----------------------
|
| 2934 |
|
|
|
| 2935 |
|
|
GDB provides one command for accessing the Python interpreter, and one
|
| 2936 |
|
|
related setting:
|
| 2937 |
|
|
|
| 2938 |
|
|
`python [CODE]'
|
| 2939 |
|
|
The `python' command can be used to evaluate Python code.
|
| 2940 |
|
|
|
| 2941 |
|
|
If given an argument, the `python' command will evaluate the
|
| 2942 |
|
|
argument as a Python command. For example:
|
| 2943 |
|
|
|
| 2944 |
|
|
(gdb) python print 23
|
| 2945 |
|
|
23
|
| 2946 |
|
|
|
| 2947 |
|
|
If you do not provide an argument to `python', it will act as a
|
| 2948 |
|
|
multi-line command, like `define'. In this case, the Python
|
| 2949 |
|
|
script is made up of subsequent command lines, given after the
|
| 2950 |
|
|
`python' command. This command list is terminated using a line
|
| 2951 |
|
|
containing `end'. For example:
|
| 2952 |
|
|
|
| 2953 |
|
|
(gdb) python
|
| 2954 |
|
|
Type python script
|
| 2955 |
|
|
End with a line saying just "end".
|
| 2956 |
|
|
>print 23
|
| 2957 |
|
|
>end
|
| 2958 |
|
|
23
|
| 2959 |
|
|
|
| 2960 |
|
|
`maint set python print-stack'
|
| 2961 |
|
|
By default, GDB will print a stack trace when an error occurs in a
|
| 2962 |
|
|
Python script. This can be controlled using `maint set python
|
| 2963 |
|
|
print-stack': if `on', the default, then Python stack printing is
|
| 2964 |
|
|
enabled; if `off', then Python stack printing is disabled.
|
| 2965 |
|
|
|
| 2966 |
|
|
It is also possible to execute a Python script from the GDB
|
| 2967 |
|
|
interpreter:
|
| 2968 |
|
|
|
| 2969 |
|
|
`source `script-name''
|
| 2970 |
|
|
The script name must end with `.py' and GDB must be configured to
|
| 2971 |
|
|
recognize the script language based on filename extension using
|
| 2972 |
|
|
the `script-extension' setting. *Note Extending GDB: Extending
|
| 2973 |
|
|
GDB.
|
| 2974 |
|
|
|
| 2975 |
|
|
`python execfile ("script-name")'
|
| 2976 |
|
|
This method is based on the `execfile' Python built-in function,
|
| 2977 |
|
|
and thus is always available.
|
| 2978 |
|
|
|
| 2979 |
|
|
|
| 2980 |
|
|
File: gdb.info, Node: Python API, Next: Auto-loading, Prev: Python Commands, Up: Python
|
| 2981 |
|
|
|
| 2982 |
|
|
23.2.2 Python API
|
| 2983 |
|
|
-----------------
|
| 2984 |
|
|
|
| 2985 |
|
|
At startup, GDB overrides Python's `sys.stdout' and `sys.stderr' to
|
| 2986 |
|
|
print using GDB's output-paging streams. A Python program which
|
| 2987 |
|
|
outputs to one of these streams may have its output interrupted by the
|
| 2988 |
|
|
user (*note Screen Size::). In this situation, a Python
|
| 2989 |
|
|
`KeyboardInterrupt' exception is thrown.
|
| 2990 |
|
|
|
| 2991 |
|
|
* Menu:
|
| 2992 |
|
|
|
| 2993 |
|
|
* Basic Python:: Basic Python Functions.
|
| 2994 |
|
|
* Exception Handling::
|
| 2995 |
|
|
* Values From Inferior::
|
| 2996 |
|
|
* Types In Python:: Python representation of types.
|
| 2997 |
|
|
* Pretty Printing API:: Pretty-printing values.
|
| 2998 |
|
|
* Selecting Pretty-Printers:: How GDB chooses a pretty-printer.
|
| 2999 |
|
|
* Disabling Pretty-Printers:: Disabling broken printers.
|
| 3000 |
|
|
* Inferiors In Python:: Python representation of inferiors (processes)
|
| 3001 |
|
|
* Threads In Python:: Accessing inferior threads from Python.
|
| 3002 |
|
|
* Commands In Python:: Implementing new commands in Python.
|
| 3003 |
|
|
* Parameters In Python:: Adding new GDB parameters.
|
| 3004 |
|
|
* Functions In Python:: Writing new convenience functions.
|
| 3005 |
|
|
* Progspaces In Python:: Program spaces.
|
| 3006 |
|
|
* Objfiles In Python:: Object files.
|
| 3007 |
|
|
* Frames In Python:: Accessing inferior stack frames from Python.
|
| 3008 |
|
|
* Blocks In Python:: Accessing frame blocks from Python.
|
| 3009 |
|
|
* Symbols In Python:: Python representation of symbols.
|
| 3010 |
|
|
* Symbol Tables In Python:: Python representation of symbol tables.
|
| 3011 |
|
|
* Lazy Strings In Python:: Python representation of lazy strings.
|
| 3012 |
|
|
* Breakpoints In Python:: Manipulating breakpoints using Python.
|
| 3013 |
|
|
|
| 3014 |
|
|
|
| 3015 |
|
|
File: gdb.info, Node: Basic Python, Next: Exception Handling, Up: Python API
|
| 3016 |
|
|
|
| 3017 |
|
|
23.2.2.1 Basic Python
|
| 3018 |
|
|
.....................
|
| 3019 |
|
|
|
| 3020 |
|
|
GDB introduces a new Python module, named `gdb'. All methods and
|
| 3021 |
|
|
classes added by GDB are placed in this module. GDB automatically
|
| 3022 |
|
|
`import's the `gdb' module for use in all scripts evaluated by the
|
| 3023 |
|
|
`python' command.
|
| 3024 |
|
|
|
| 3025 |
|
|
-- Variable: PYTHONDIR
|
| 3026 |
|
|
A string containing the python directory (*note Python::).
|
| 3027 |
|
|
|
| 3028 |
|
|
-- Function: execute command [from_tty] [to_string]
|
| 3029 |
|
|
Evaluate COMMAND, a string, as a GDB CLI command. If a GDB
|
| 3030 |
|
|
exception happens while COMMAND runs, it is translated as
|
| 3031 |
|
|
described in *Note Exception Handling: Exception Handling.
|
| 3032 |
|
|
|
| 3033 |
|
|
FROM_TTY specifies whether GDB ought to consider this command as
|
| 3034 |
|
|
having originated from the user invoking it interactively. It
|
| 3035 |
|
|
must be a boolean value. If omitted, it defaults to `False'.
|
| 3036 |
|
|
|
| 3037 |
|
|
By default, any output produced by COMMAND is sent to GDB's
|
| 3038 |
|
|
standard output. If the TO_STRING parameter is `True', then
|
| 3039 |
|
|
output will be collected by `gdb.execute' and returned as a
|
| 3040 |
|
|
string. The default is `False', in which case the return value is
|
| 3041 |
|
|
`None'. If TO_STRING is `True', the GDB virtual terminal will be
|
| 3042 |
|
|
temporarily set to unlimited width and height, and its pagination
|
| 3043 |
|
|
will be disabled; *note Screen Size::.
|
| 3044 |
|
|
|
| 3045 |
|
|
-- Function: breakpoints
|
| 3046 |
|
|
Return a sequence holding all of GDB's breakpoints. *Note
|
| 3047 |
|
|
Breakpoints In Python::, for more information.
|
| 3048 |
|
|
|
| 3049 |
|
|
-- Function: parameter parameter
|
| 3050 |
|
|
Return the value of a GDB parameter. PARAMETER is a string naming
|
| 3051 |
|
|
the parameter to look up; PARAMETER may contain spaces if the
|
| 3052 |
|
|
parameter has a multi-part name. For example, `print object' is a
|
| 3053 |
|
|
valid parameter name.
|
| 3054 |
|
|
|
| 3055 |
|
|
If the named parameter does not exist, this function throws a
|
| 3056 |
|
|
`RuntimeError'. Otherwise, the parameter's value is converted to
|
| 3057 |
|
|
a Python value of the appropriate type, and returned.
|
| 3058 |
|
|
|
| 3059 |
|
|
-- Function: history number
|
| 3060 |
|
|
Return a value from GDB's value history (*note Value History::).
|
| 3061 |
|
|
NUMBER indicates which history element to return. If NUMBER is
|
| 3062 |
|
|
negative, then GDB will take its absolute value and count backward
|
| 3063 |
|
|
from the last element (i.e., the most recent element) to find the
|
| 3064 |
|
|
value to return. If NUMBER is zero, then GDB will return the most
|
| 3065 |
|
|
recent element. If the element specified by NUMBER doesn't exist
|
| 3066 |
|
|
in the value history, a `RuntimeError' exception will be raised.
|
| 3067 |
|
|
|
| 3068 |
|
|
If no exception is raised, the return value is always an instance
|
| 3069 |
|
|
of `gdb.Value' (*note Values From Inferior::).
|
| 3070 |
|
|
|
| 3071 |
|
|
-- Function: parse_and_eval expression
|
| 3072 |
|
|
Parse EXPRESSION as an expression in the current language,
|
| 3073 |
|
|
evaluate it, and return the result as a `gdb.Value'. EXPRESSION
|
| 3074 |
|
|
must be a string.
|
| 3075 |
|
|
|
| 3076 |
|
|
This function can be useful when implementing a new command (*note
|
| 3077 |
|
|
Commands In Python::), as it provides a way to parse the command's
|
| 3078 |
|
|
argument as an expression. It is also useful simply to compute
|
| 3079 |
|
|
values, for example, it is the only way to get the value of a
|
| 3080 |
|
|
convenience variable (*note Convenience Vars::) as a `gdb.Value'.
|
| 3081 |
|
|
|
| 3082 |
|
|
-- Function: write string
|
| 3083 |
|
|
Print a string to GDB's paginated standard output stream. Writing
|
| 3084 |
|
|
to `sys.stdout' or `sys.stderr' will automatically call this
|
| 3085 |
|
|
function.
|
| 3086 |
|
|
|
| 3087 |
|
|
-- Function: flush
|
| 3088 |
|
|
Flush GDB's paginated standard output stream. Flushing
|
| 3089 |
|
|
`sys.stdout' or `sys.stderr' will automatically call this function.
|
| 3090 |
|
|
|
| 3091 |
|
|
-- Function: target_charset
|
| 3092 |
|
|
Return the name of the current target character set (*note
|
| 3093 |
|
|
Character Sets::). This differs from
|
| 3094 |
|
|
`gdb.parameter('target-charset')' in that `auto' is never returned.
|
| 3095 |
|
|
|
| 3096 |
|
|
-- Function: target_wide_charset
|
| 3097 |
|
|
Return the name of the current target wide character set (*note
|
| 3098 |
|
|
Character Sets::). This differs from
|
| 3099 |
|
|
`gdb.parameter('target-wide-charset')' in that `auto' is never
|
| 3100 |
|
|
returned.
|
| 3101 |
|
|
|
| 3102 |
|
|
|
| 3103 |
|
|
File: gdb.info, Node: Exception Handling, Next: Values From Inferior, Prev: Basic Python, Up: Python API
|
| 3104 |
|
|
|
| 3105 |
|
|
23.2.2.2 Exception Handling
|
| 3106 |
|
|
...........................
|
| 3107 |
|
|
|
| 3108 |
|
|
When executing the `python' command, Python exceptions uncaught within
|
| 3109 |
|
|
the Python code are translated to calls to GDB error-reporting
|
| 3110 |
|
|
mechanism. If the command that called `python' does not handle the
|
| 3111 |
|
|
error, GDB will terminate it and print an error message containing the
|
| 3112 |
|
|
Python exception name, the associated value, and the Python call stack
|
| 3113 |
|
|
backtrace at the point where the exception was raised. Example:
|
| 3114 |
|
|
|
| 3115 |
|
|
(gdb) python print foo
|
| 3116 |
|
|
Traceback (most recent call last):
|
| 3117 |
|
|
File "", line 1, in
|
| 3118 |
|
|
NameError: name 'foo' is not defined
|
| 3119 |
|
|
|
| 3120 |
|
|
GDB errors that happen in GDB commands invoked by Python code are
|
| 3121 |
|
|
converted to Python `RuntimeError' exceptions. User interrupt (via
|
| 3122 |
|
|
`C-c' or by typing `q' at a pagination prompt) is translated to a
|
| 3123 |
|
|
Python `KeyboardInterrupt' exception. If you catch these exceptions in
|
| 3124 |
|
|
your Python code, your exception handler will see `RuntimeError' or
|
| 3125 |
|
|
`KeyboardInterrupt' as the exception type, the GDB error message as its
|
| 3126 |
|
|
value, and the Python call stack backtrace at the Python statement
|
| 3127 |
|
|
closest to where the GDB error occured as the traceback.
|
| 3128 |
|
|
|
| 3129 |
|
|
When implementing GDB commands in Python via `gdb.Command', it is
|
| 3130 |
|
|
useful to be able to throw an exception that doesn't cause a traceback
|
| 3131 |
|
|
to be printed. For example, the user may have invoked the command
|
| 3132 |
|
|
incorrectly. Use the `gdb.GdbError' exception to handle this case.
|
| 3133 |
|
|
Example:
|
| 3134 |
|
|
|
| 3135 |
|
|
(gdb) python
|
| 3136 |
|
|
>class HelloWorld (gdb.Command):
|
| 3137 |
|
|
> """Greet the whole world."""
|
| 3138 |
|
|
> def __init__ (self):
|
| 3139 |
|
|
> super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE)
|
| 3140 |
|
|
> def invoke (self, args, from_tty):
|
| 3141 |
|
|
> argv = gdb.string_to_argv (args)
|
| 3142 |
|
|
> if len (argv) != 0:
|
| 3143 |
|
|
> raise gdb.GdbError ("hello-world takes no arguments")
|
| 3144 |
|
|
> print "Hello, World!"
|
| 3145 |
|
|
>HelloWorld ()
|
| 3146 |
|
|
>end
|
| 3147 |
|
|
(gdb) hello-world 42
|
| 3148 |
|
|
hello-world takes no arguments
|
| 3149 |
|
|
|
| 3150 |
|
|
|
| 3151 |
|
|
File: gdb.info, Node: Values From Inferior, Next: Types In Python, Prev: Exception Handling, Up: Python API
|
| 3152 |
|
|
|
| 3153 |
|
|
23.2.2.3 Values From Inferior
|
| 3154 |
|
|
.............................
|
| 3155 |
|
|
|
| 3156 |
|
|
GDB provides values it obtains from the inferior program in an object
|
| 3157 |
|
|
of type `gdb.Value'. GDB uses this object for its internal bookkeeping
|
| 3158 |
|
|
of the inferior's values, and for fetching values when necessary.
|
| 3159 |
|
|
|
| 3160 |
|
|
Inferior values that are simple scalars can be used directly in
|
| 3161 |
|
|
Python expressions that are valid for the value's data type. Here's an
|
| 3162 |
|
|
example for an integer or floating-point value `some_val':
|
| 3163 |
|
|
|
| 3164 |
|
|
bar = some_val + 2
|
| 3165 |
|
|
|
| 3166 |
|
|
As result of this, `bar' will also be a `gdb.Value' object whose values
|
| 3167 |
|
|
are of the same type as those of `some_val'.
|
| 3168 |
|
|
|
| 3169 |
|
|
Inferior values that are structures or instances of some class can
|
| 3170 |
|
|
be accessed using the Python "dictionary syntax". For example, if
|
| 3171 |
|
|
`some_val' is a `gdb.Value' instance holding a structure, you can
|
| 3172 |
|
|
access its `foo' element with:
|
| 3173 |
|
|
|
| 3174 |
|
|
bar = some_val['foo']
|
| 3175 |
|
|
|
| 3176 |
|
|
Again, `bar' will also be a `gdb.Value' object.
|
| 3177 |
|
|
|
| 3178 |
|
|
The following attributes are provided:
|
| 3179 |
|
|
|
| 3180 |
|
|
-- Instance Variable of Value: address
|
| 3181 |
|
|
If this object is addressable, this read-only attribute holds
|
| 3182 |
|
|
a `gdb.Value' object representing the address. Otherwise,
|
| 3183 |
|
|
this attribute holds `None'.
|
| 3184 |
|
|
|
| 3185 |
|
|
-- Instance Variable of Value: is_optimized_out
|
| 3186 |
|
|
This read-only boolean attribute is true if the compiler
|
| 3187 |
|
|
optimized out this value, thus it is not available for
|
| 3188 |
|
|
fetching from the inferior.
|
| 3189 |
|
|
|
| 3190 |
|
|
-- Instance Variable of Value: type
|
| 3191 |
|
|
The type of this `gdb.Value'. The value of this attribute is
|
| 3192 |
|
|
a `gdb.Type' object.
|
| 3193 |
|
|
|
| 3194 |
|
|
The following methods are provided:
|
| 3195 |
|
|
|
| 3196 |
|
|
-- Method on Value: cast type
|
| 3197 |
|
|
Return a new instance of `gdb.Value' that is the result of
|
| 3198 |
|
|
casting this instance to the type described by TYPE, which
|
| 3199 |
|
|
must be a `gdb.Type' object. If the cast cannot be performed
|
| 3200 |
|
|
for some reason, this method throws an exception.
|
| 3201 |
|
|
|
| 3202 |
|
|
-- Method on Value: dereference
|
| 3203 |
|
|
For pointer data types, this method returns a new `gdb.Value'
|
| 3204 |
|
|
object whose contents is the object pointed to by the
|
| 3205 |
|
|
pointer. For example, if `foo' is a C pointer to an `int',
|
| 3206 |
|
|
declared in your C program as
|
| 3207 |
|
|
|
| 3208 |
|
|
int *foo;
|
| 3209 |
|
|
|
| 3210 |
|
|
then you can use the corresponding `gdb.Value' to access what
|
| 3211 |
|
|
`foo' points to like this:
|
| 3212 |
|
|
|
| 3213 |
|
|
bar = foo.dereference ()
|
| 3214 |
|
|
|
| 3215 |
|
|
The result `bar' will be a `gdb.Value' object holding the
|
| 3216 |
|
|
value pointed to by `foo'.
|
| 3217 |
|
|
|
| 3218 |
|
|
-- Method on Value: string [encoding] [errors] [length]
|
| 3219 |
|
|
If this `gdb.Value' represents a string, then this method
|
| 3220 |
|
|
converts the contents to a Python string. Otherwise, this
|
| 3221 |
|
|
method will throw an exception.
|
| 3222 |
|
|
|
| 3223 |
|
|
Strings are recognized in a language-specific way; whether a
|
| 3224 |
|
|
given `gdb.Value' represents a string is determined by the
|
| 3225 |
|
|
current language.
|
| 3226 |
|
|
|
| 3227 |
|
|
For C-like languages, a value is a string if it is a pointer
|
| 3228 |
|
|
to or an array of characters or ints. The string is assumed
|
| 3229 |
|
|
to be terminated by a zero of the appropriate width. However
|
| 3230 |
|
|
if the optional length argument is given, the string will be
|
| 3231 |
|
|
converted to that given length, ignoring any embedded zeros
|
| 3232 |
|
|
that the string may contain.
|
| 3233 |
|
|
|
| 3234 |
|
|
If the optional ENCODING argument is given, it must be a
|
| 3235 |
|
|
string naming the encoding of the string in the `gdb.Value',
|
| 3236 |
|
|
such as `"ascii"', `"iso-8859-6"' or `"utf-8"'. It accepts
|
| 3237 |
|
|
the same encodings as the corresponding argument to Python's
|
| 3238 |
|
|
`string.decode' method, and the Python codec machinery will
|
| 3239 |
|
|
be used to convert the string. If ENCODING is not given, or
|
| 3240 |
|
|
if ENCODING is the empty string, then either the
|
| 3241 |
|
|
`target-charset' (*note Character Sets::) will be used, or a
|
| 3242 |
|
|
language-specific encoding will be used, if the current
|
| 3243 |
|
|
language is able to supply one.
|
| 3244 |
|
|
|
| 3245 |
|
|
The optional ERRORS argument is the same as the corresponding
|
| 3246 |
|
|
argument to Python's `string.decode' method.
|
| 3247 |
|
|
|
| 3248 |
|
|
If the optional LENGTH argument is given, the string will be
|
| 3249 |
|
|
fetched and converted to the given length.
|
| 3250 |
|
|
|
| 3251 |
|
|
-- Method on Value: lazy_string [encoding] [length]
|
| 3252 |
|
|
If this `gdb.Value' represents a string, then this method
|
| 3253 |
|
|
converts the contents to a `gdb.LazyString' (*note Lazy
|
| 3254 |
|
|
Strings In Python::). Otherwise, this method will throw an
|
| 3255 |
|
|
exception.
|
| 3256 |
|
|
|
| 3257 |
|
|
If the optional ENCODING argument is given, it must be a
|
| 3258 |
|
|
string naming the encoding of the `gdb.LazyString'. Some
|
| 3259 |
|
|
examples are: `ascii', `iso-8859-6' or `utf-8'. If the
|
| 3260 |
|
|
ENCODING argument is an encoding that GDB does recognize, GDB
|
| 3261 |
|
|
will raise an error.
|
| 3262 |
|
|
|
| 3263 |
|
|
When a lazy string is printed, the GDB encoding machinery is
|
| 3264 |
|
|
used to convert the string during printing. If the optional
|
| 3265 |
|
|
ENCODING argument is not provided, or is an empty string, GDB
|
| 3266 |
|
|
will automatically select the encoding most suitable for the
|
| 3267 |
|
|
string type. For further information on encoding in GDB
|
| 3268 |
|
|
please see *Note Character Sets::.
|
| 3269 |
|
|
|
| 3270 |
|
|
If the optional LENGTH argument is given, the string will be
|
| 3271 |
|
|
fetched and encoded to the length of characters specified. If
|
| 3272 |
|
|
the LENGTH argument is not provided, the string will be
|
| 3273 |
|
|
fetched and encoded until a null of appropriate width is
|
| 3274 |
|
|
found.
|
| 3275 |
|
|
|
| 3276 |
|
|
|
| 3277 |
|
|
File: gdb.info, Node: Types In Python, Next: Pretty Printing API, Prev: Values From Inferior, Up: Python API
|
| 3278 |
|
|
|
| 3279 |
|
|
23.2.2.4 Types In Python
|
| 3280 |
|
|
........................
|
| 3281 |
|
|
|
| 3282 |
|
|
GDB represents types from the inferior using the class `gdb.Type'.
|
| 3283 |
|
|
|
| 3284 |
|
|
The following type-related functions are available in the `gdb'
|
| 3285 |
|
|
module:
|
| 3286 |
|
|
|
| 3287 |
|
|
-- Function: lookup_type name [block]
|
| 3288 |
|
|
This function looks up a type by name. NAME is the name of the
|
| 3289 |
|
|
type to look up. It must be a string.
|
| 3290 |
|
|
|
| 3291 |
|
|
If BLOCK is given, then NAME is looked up in that scope.
|
| 3292 |
|
|
Otherwise, it is searched for globally.
|
| 3293 |
|
|
|
| 3294 |
|
|
Ordinarily, this function will return an instance of `gdb.Type'.
|
| 3295 |
|
|
If the named type cannot be found, it will throw an exception.
|
| 3296 |
|
|
|
| 3297 |
|
|
An instance of `Type' has the following attributes:
|
| 3298 |
|
|
|
| 3299 |
|
|
-- Instance Variable of Type: code
|
| 3300 |
|
|
The type code for this type. The type code will be one of the
|
| 3301 |
|
|
`TYPE_CODE_' constants defined below.
|
| 3302 |
|
|
|
| 3303 |
|
|
-- Instance Variable of Type: sizeof
|
| 3304 |
|
|
The size of this type, in target `char' units. Usually, a
|
| 3305 |
|
|
target's `char' type will be an 8-bit byte. However, on some
|
| 3306 |
|
|
unusual platforms, this type may have a different size.
|
| 3307 |
|
|
|
| 3308 |
|
|
-- Instance Variable of Type: tag
|
| 3309 |
|
|
The tag name for this type. The tag name is the name after
|
| 3310 |
|
|
`struct', `union', or `enum' in C and C++; not all languages
|
| 3311 |
|
|
have this concept. If this type has no tag name, then `None'
|
| 3312 |
|
|
is returned.
|
| 3313 |
|
|
|
| 3314 |
|
|
The following methods are provided:
|
| 3315 |
|
|
|
| 3316 |
|
|
-- Method on Type: fields
|
| 3317 |
|
|
For structure and union types, this method returns the
|
| 3318 |
|
|
fields. Range types have two fields, the minimum and maximum
|
| 3319 |
|
|
values. Enum types have one field per enum constant.
|
| 3320 |
|
|
Function and method types have one field per parameter. The
|
| 3321 |
|
|
base types of C++ classes are also represented as fields. If
|
| 3322 |
|
|
the type has no fields, or does not fit into one of these
|
| 3323 |
|
|
categories, an empty sequence will be returned.
|
| 3324 |
|
|
|
| 3325 |
|
|
Each field is an object, with some pre-defined attributes:
|
| 3326 |
|
|
`bitpos'
|
| 3327 |
|
|
This attribute is not available for `static' fields (as
|
| 3328 |
|
|
in C++ or Java). For non-`static' fields, the value is
|
| 3329 |
|
|
the bit position of the field.
|
| 3330 |
|
|
|
| 3331 |
|
|
`name'
|
| 3332 |
|
|
The name of the field, or `None' for anonymous fields.
|
| 3333 |
|
|
|
| 3334 |
|
|
`artificial'
|
| 3335 |
|
|
This is `True' if the field is artificial, usually
|
| 3336 |
|
|
meaning that it was provided by the compiler and not the
|
| 3337 |
|
|
user. This attribute is always provided, and is `False'
|
| 3338 |
|
|
if the field is not artificial.
|
| 3339 |
|
|
|
| 3340 |
|
|
`is_base_class'
|
| 3341 |
|
|
This is `True' if the field represents a base class of a
|
| 3342 |
|
|
C++ structure. This attribute is always provided, and
|
| 3343 |
|
|
is `False' if the field is not a base class of the type
|
| 3344 |
|
|
that is the argument of `fields', or if that type was
|
| 3345 |
|
|
not a C++ class.
|
| 3346 |
|
|
|
| 3347 |
|
|
`bitsize'
|
| 3348 |
|
|
If the field is packed, or is a bitfield, then this will
|
| 3349 |
|
|
have a non-zero value, which is the size of the field in
|
| 3350 |
|
|
bits. Otherwise, this will be zero; in this case the
|
| 3351 |
|
|
field's size is given by its type.
|
| 3352 |
|
|
|
| 3353 |
|
|
`type'
|
| 3354 |
|
|
The type of the field. This is usually an instance of
|
| 3355 |
|
|
`Type', but it can be `None' in some situations.
|
| 3356 |
|
|
|
| 3357 |
|
|
-- Method on Type: const
|
| 3358 |
|
|
Return a new `gdb.Type' object which represents a
|
| 3359 |
|
|
`const'-qualified variant of this type.
|
| 3360 |
|
|
|
| 3361 |
|
|
-- Method on Type: volatile
|
| 3362 |
|
|
Return a new `gdb.Type' object which represents a
|
| 3363 |
|
|
`volatile'-qualified variant of this type.
|
| 3364 |
|
|
|
| 3365 |
|
|
-- Method on Type: unqualified
|
| 3366 |
|
|
Return a new `gdb.Type' object which represents an unqualified
|
| 3367 |
|
|
variant of this type. That is, the result is neither `const'
|
| 3368 |
|
|
nor `volatile'.
|
| 3369 |
|
|
|
| 3370 |
|
|
-- Method on Type: range
|
| 3371 |
|
|
Return a Python `Tuple' object that contains two elements: the
|
| 3372 |
|
|
low bound of the argument type and the high bound of that
|
| 3373 |
|
|
type. If the type does not have a range, GDB will raise a
|
| 3374 |
|
|
`RuntimeError' exception.
|
| 3375 |
|
|
|
| 3376 |
|
|
-- Method on Type: reference
|
| 3377 |
|
|
Return a new `gdb.Type' object which represents a reference
|
| 3378 |
|
|
to this type.
|
| 3379 |
|
|
|
| 3380 |
|
|
-- Method on Type: pointer
|
| 3381 |
|
|
Return a new `gdb.Type' object which represents a pointer to
|
| 3382 |
|
|
this type.
|
| 3383 |
|
|
|
| 3384 |
|
|
-- Method on Type: strip_typedefs
|
| 3385 |
|
|
Return a new `gdb.Type' that represents the real type, after
|
| 3386 |
|
|
removing all layers of typedefs.
|
| 3387 |
|
|
|
| 3388 |
|
|
-- Method on Type: target
|
| 3389 |
|
|
Return a new `gdb.Type' object which represents the target
|
| 3390 |
|
|
type of this type.
|
| 3391 |
|
|
|
| 3392 |
|
|
For a pointer type, the target type is the type of the
|
| 3393 |
|
|
pointed-to object. For an array type (meaning C-like
|
| 3394 |
|
|
arrays), the target type is the type of the elements of the
|
| 3395 |
|
|
array. For a function or method type, the target type is the
|
| 3396 |
|
|
type of the return value. For a complex type, the target
|
| 3397 |
|
|
type is the type of the elements. For a typedef, the target
|
| 3398 |
|
|
type is the aliased type.
|
| 3399 |
|
|
|
| 3400 |
|
|
If the type does not have a target, this method will throw an
|
| 3401 |
|
|
exception.
|
| 3402 |
|
|
|
| 3403 |
|
|
-- Method on Type: template_argument n [block]
|
| 3404 |
|
|
If this `gdb.Type' is an instantiation of a template, this
|
| 3405 |
|
|
will return a new `gdb.Type' which represents the type of the
|
| 3406 |
|
|
Nth template argument.
|
| 3407 |
|
|
|
| 3408 |
|
|
If this `gdb.Type' is not a template type, this will throw an
|
| 3409 |
|
|
exception. Ordinarily, only C++ code will have template
|
| 3410 |
|
|
types.
|
| 3411 |
|
|
|
| 3412 |
|
|
If BLOCK is given, then NAME is looked up in that scope.
|
| 3413 |
|
|
Otherwise, it is searched for globally.
|
| 3414 |
|
|
|
| 3415 |
|
|
Each type has a code, which indicates what category this type falls
|
| 3416 |
|
|
into. The available type categories are represented by constants
|
| 3417 |
|
|
defined in the `gdb' module:
|
| 3418 |
|
|
|
| 3419 |
|
|
`TYPE_CODE_PTR'
|
| 3420 |
|
|
The type is a pointer.
|
| 3421 |
|
|
|
| 3422 |
|
|
`TYPE_CODE_ARRAY'
|
| 3423 |
|
|
The type is an array.
|
| 3424 |
|
|
|
| 3425 |
|
|
`TYPE_CODE_STRUCT'
|
| 3426 |
|
|
The type is a structure.
|
| 3427 |
|
|
|
| 3428 |
|
|
`TYPE_CODE_UNION'
|
| 3429 |
|
|
The type is a union.
|
| 3430 |
|
|
|
| 3431 |
|
|
`TYPE_CODE_ENUM'
|
| 3432 |
|
|
The type is an enum.
|
| 3433 |
|
|
|
| 3434 |
|
|
`TYPE_CODE_FLAGS'
|
| 3435 |
|
|
A bit flags type, used for things such as status registers.
|
| 3436 |
|
|
|
| 3437 |
|
|
`TYPE_CODE_FUNC'
|
| 3438 |
|
|
The type is a function.
|
| 3439 |
|
|
|
| 3440 |
|
|
`TYPE_CODE_INT'
|
| 3441 |
|
|
The type is an integer type.
|
| 3442 |
|
|
|
| 3443 |
|
|
`TYPE_CODE_FLT'
|
| 3444 |
|
|
A floating point type.
|
| 3445 |
|
|
|
| 3446 |
|
|
`TYPE_CODE_VOID'
|
| 3447 |
|
|
The special type `void'.
|
| 3448 |
|
|
|
| 3449 |
|
|
`TYPE_CODE_SET'
|
| 3450 |
|
|
A Pascal set type.
|
| 3451 |
|
|
|
| 3452 |
|
|
`TYPE_CODE_RANGE'
|
| 3453 |
|
|
A range type, that is, an integer type with bounds.
|
| 3454 |
|
|
|
| 3455 |
|
|
`TYPE_CODE_STRING'
|
| 3456 |
|
|
A string type. Note that this is only used for certain languages
|
| 3457 |
|
|
with language-defined string types; C strings are not represented
|
| 3458 |
|
|
this way.
|
| 3459 |
|
|
|
| 3460 |
|
|
`TYPE_CODE_BITSTRING'
|
| 3461 |
|
|
A string of bits.
|
| 3462 |
|
|
|
| 3463 |
|
|
`TYPE_CODE_ERROR'
|
| 3464 |
|
|
An unknown or erroneous type.
|
| 3465 |
|
|
|
| 3466 |
|
|
`TYPE_CODE_METHOD'
|
| 3467 |
|
|
A method type, as found in C++ or Java.
|
| 3468 |
|
|
|
| 3469 |
|
|
`TYPE_CODE_METHODPTR'
|
| 3470 |
|
|
A pointer-to-member-function.
|
| 3471 |
|
|
|
| 3472 |
|
|
`TYPE_CODE_MEMBERPTR'
|
| 3473 |
|
|
A pointer-to-member.
|
| 3474 |
|
|
|
| 3475 |
|
|
`TYPE_CODE_REF'
|
| 3476 |
|
|
A reference type.
|
| 3477 |
|
|
|
| 3478 |
|
|
`TYPE_CODE_CHAR'
|
| 3479 |
|
|
A character type.
|
| 3480 |
|
|
|
| 3481 |
|
|
`TYPE_CODE_BOOL'
|
| 3482 |
|
|
A boolean type.
|
| 3483 |
|
|
|
| 3484 |
|
|
`TYPE_CODE_COMPLEX'
|
| 3485 |
|
|
A complex float type.
|
| 3486 |
|
|
|
| 3487 |
|
|
`TYPE_CODE_TYPEDEF'
|
| 3488 |
|
|
A typedef to some other type.
|
| 3489 |
|
|
|
| 3490 |
|
|
`TYPE_CODE_NAMESPACE'
|
| 3491 |
|
|
A C++ namespace.
|
| 3492 |
|
|
|
| 3493 |
|
|
`TYPE_CODE_DECFLOAT'
|
| 3494 |
|
|
A decimal floating point type.
|
| 3495 |
|
|
|
| 3496 |
|
|
`TYPE_CODE_INTERNAL_FUNCTION'
|
| 3497 |
|
|
A function internal to GDB. This is the type used to represent
|
| 3498 |
|
|
convenience functions.
|
| 3499 |
|
|
|
| 3500 |
|
|
|
| 3501 |
|
|
File: gdb.info, Node: Pretty Printing API, Next: Selecting Pretty-Printers, Prev: Types In Python, Up: Python API
|
| 3502 |
|
|
|
| 3503 |
|
|
23.2.2.5 Pretty Printing API
|
| 3504 |
|
|
............................
|
| 3505 |
|
|
|
| 3506 |
|
|
An example output is provided (*note Pretty Printing::).
|
| 3507 |
|
|
|
| 3508 |
|
|
A pretty-printer is just an object that holds a value and implements
|
| 3509 |
|
|
a specific interface, defined here.
|
| 3510 |
|
|
|
| 3511 |
|
|
-- Operation on pretty printer: children (self)
|
| 3512 |
|
|
GDB will call this method on a pretty-printer to compute the
|
| 3513 |
|
|
children of the pretty-printer's value.
|
| 3514 |
|
|
|
| 3515 |
|
|
This method must return an object conforming to the Python iterator
|
| 3516 |
|
|
protocol. Each item returned by the iterator must be a tuple
|
| 3517 |
|
|
holding two elements. The first element is the "name" of the
|
| 3518 |
|
|
child; the second element is the child's value. The value can be
|
| 3519 |
|
|
any Python object which is convertible to a GDB value.
|
| 3520 |
|
|
|
| 3521 |
|
|
This method is optional. If it does not exist, GDB will act as
|
| 3522 |
|
|
though the value has no children.
|
| 3523 |
|
|
|
| 3524 |
|
|
-- Operation on pretty printer: display_hint (self)
|
| 3525 |
|
|
The CLI may call this method and use its result to change the
|
| 3526 |
|
|
formatting of a value. The result will also be supplied to an MI
|
| 3527 |
|
|
consumer as a `displayhint' attribute of the variable being
|
| 3528 |
|
|
printed.
|
| 3529 |
|
|
|
| 3530 |
|
|
This method is optional. If it does exist, this method must
|
| 3531 |
|
|
return a string.
|
| 3532 |
|
|
|
| 3533 |
|
|
Some display hints are predefined by GDB:
|
| 3534 |
|
|
|
| 3535 |
|
|
`array'
|
| 3536 |
|
|
Indicate that the object being printed is "array-like". The
|
| 3537 |
|
|
CLI uses this to respect parameters such as `set print
|
| 3538 |
|
|
elements' and `set print array'.
|
| 3539 |
|
|
|
| 3540 |
|
|
`map'
|
| 3541 |
|
|
Indicate that the object being printed is "map-like", and
|
| 3542 |
|
|
that the children of this value can be assumed to alternate
|
| 3543 |
|
|
between keys and values.
|
| 3544 |
|
|
|
| 3545 |
|
|
`string'
|
| 3546 |
|
|
Indicate that the object being printed is "string-like". If
|
| 3547 |
|
|
the printer's `to_string' method returns a Python string of
|
| 3548 |
|
|
some kind, then GDB will call its internal language-specific
|
| 3549 |
|
|
string-printing function to format the string. For the CLI
|
| 3550 |
|
|
this means adding quotation marks, possibly escaping some
|
| 3551 |
|
|
characters, respecting `set print elements', and the like.
|
| 3552 |
|
|
|
| 3553 |
|
|
-- Operation on pretty printer: to_string (self)
|
| 3554 |
|
|
GDB will call this method to display the string representation of
|
| 3555 |
|
|
the value passed to the object's constructor.
|
| 3556 |
|
|
|
| 3557 |
|
|
When printing from the CLI, if the `to_string' method exists, then
|
| 3558 |
|
|
GDB will prepend its result to the values returned by `children'.
|
| 3559 |
|
|
Exactly how this formatting is done is dependent on the display
|
| 3560 |
|
|
hint, and may change as more hints are added. Also, depending on
|
| 3561 |
|
|
the print settings (*note Print Settings::), the CLI may print
|
| 3562 |
|
|
just the result of `to_string' in a stack trace, omitting the
|
| 3563 |
|
|
result of `children'.
|
| 3564 |
|
|
|
| 3565 |
|
|
If this method returns a string, it is printed verbatim.
|
| 3566 |
|
|
|
| 3567 |
|
|
Otherwise, if this method returns an instance of `gdb.Value', then
|
| 3568 |
|
|
GDB prints this value. This may result in a call to another
|
| 3569 |
|
|
pretty-printer.
|
| 3570 |
|
|
|
| 3571 |
|
|
If instead the method returns a Python value which is convertible
|
| 3572 |
|
|
to a `gdb.Value', then GDB performs the conversion and prints the
|
| 3573 |
|
|
resulting value. Again, this may result in a call to another
|
| 3574 |
|
|
pretty-printer. Python scalars (integers, floats, and booleans)
|
| 3575 |
|
|
and strings are convertible to `gdb.Value'; other types are not.
|
| 3576 |
|
|
|
| 3577 |
|
|
Finally, if this method returns `None' then no further operations
|
| 3578 |
|
|
are peformed in this method and nothing is printed.
|
| 3579 |
|
|
|
| 3580 |
|
|
If the result is not one of these types, an exception is raised.
|
| 3581 |
|
|
|
| 3582 |
|
|
GDB provides a function which can be used to look up the default
|
| 3583 |
|
|
pretty-printer for a `gdb.Value':
|
| 3584 |
|
|
|
| 3585 |
|
|
-- Function: default_visualizer value
|
| 3586 |
|
|
This function takes a `gdb.Value' object as an argument. If a
|
| 3587 |
|
|
pretty-printer for this value exists, then it is returned. If no
|
| 3588 |
|
|
such printer exists, then this returns `None'.
|
| 3589 |
|
|
|
| 3590 |
|
|
|
| 3591 |
|
|
File: gdb.info, Node: Selecting Pretty-Printers, Next: Disabling Pretty-Printers, Prev: Pretty Printing API, Up: Python API
|
| 3592 |
|
|
|
| 3593 |
|
|
23.2.2.6 Selecting Pretty-Printers
|
| 3594 |
|
|
..................................
|
| 3595 |
|
|
|
| 3596 |
|
|
The Python list `gdb.pretty_printers' contains an array of functions or
|
| 3597 |
|
|
callable objects that have been registered via addition as a
|
| 3598 |
|
|
pretty-printer. Each `gdb.Progspace' contains a `pretty_printers'
|
| 3599 |
|
|
attribute. Each `gdb.Objfile' also contains a `pretty_printers'
|
| 3600 |
|
|
attribute.
|
| 3601 |
|
|
|
| 3602 |
|
|
A function on one of these lists is passed a single `gdb.Value'
|
| 3603 |
|
|
argument and should return a pretty-printer object conforming to the
|
| 3604 |
|
|
interface definition above (*note Pretty Printing API::). If a function
|
| 3605 |
|
|
cannot create a pretty-printer for the value, it should return `None'.
|
| 3606 |
|
|
|
| 3607 |
|
|
GDB first checks the `pretty_printers' attribute of each
|
| 3608 |
|
|
`gdb.Objfile' in the current program space and iteratively calls each
|
| 3609 |
|
|
enabled function (*note Disabling Pretty-Printers::) in the list for
|
| 3610 |
|
|
that `gdb.Objfile' until it receives a pretty-printer object. If no
|
| 3611 |
|
|
pretty-printer is found in the objfile lists, GDB then searches the
|
| 3612 |
|
|
pretty-printer list of the current program space, calling each enabled
|
| 3613 |
|
|
function until an object is returned. After these lists have been
|
| 3614 |
|
|
exhausted, it tries the global `gdb.pretty_printers' list, again
|
| 3615 |
|
|
calling each enabled function until an object is returned.
|
| 3616 |
|
|
|
| 3617 |
|
|
The order in which the objfiles are searched is not specified. For a
|
| 3618 |
|
|
given list, functions are always invoked from the head of the list, and
|
| 3619 |
|
|
iterated over sequentially until the end of the list, or a printer
|
| 3620 |
|
|
object is returned.
|
| 3621 |
|
|
|
| 3622 |
|
|
Here is an example showing how a `std::string' printer might be
|
| 3623 |
|
|
written:
|
| 3624 |
|
|
|
| 3625 |
|
|
class StdStringPrinter:
|
| 3626 |
|
|
"Print a std::string"
|
| 3627 |
|
|
|
| 3628 |
|
|
def __init__ (self, val):
|
| 3629 |
|
|
self.val = val
|
| 3630 |
|
|
|
| 3631 |
|
|
def to_string (self):
|
| 3632 |
|
|
return self.val['_M_dataplus']['_M_p']
|
| 3633 |
|
|
|
| 3634 |
|
|
def display_hint (self):
|
| 3635 |
|
|
return 'string'
|
| 3636 |
|
|
|
| 3637 |
|
|
And here is an example showing how a lookup function for the printer
|
| 3638 |
|
|
example above might be written.
|
| 3639 |
|
|
|
| 3640 |
|
|
def str_lookup_function (val):
|
| 3641 |
|
|
|
| 3642 |
|
|
lookup_tag = val.type.tag
|
| 3643 |
|
|
regex = re.compile ("^std::basic_string$")
|
| 3644 |
|
|
if lookup_tag == None:
|
| 3645 |
|
|
return None
|
| 3646 |
|
|
if regex.match (lookup_tag):
|
| 3647 |
|
|
return StdStringPrinter (val)
|
| 3648 |
|
|
|
| 3649 |
|
|
return None
|
| 3650 |
|
|
|
| 3651 |
|
|
The example lookup function extracts the value's type, and attempts
|
| 3652 |
|
|
to match it to a type that it can pretty-print. If it is a type the
|
| 3653 |
|
|
printer can pretty-print, it will return a printer object. If not, it
|
| 3654 |
|
|
returns `None'.
|
| 3655 |
|
|
|
| 3656 |
|
|
We recommend that you put your core pretty-printers into a Python
|
| 3657 |
|
|
package. If your pretty-printers are for use with a library, we
|
| 3658 |
|
|
further recommend embedding a version number into the package name.
|
| 3659 |
|
|
This practice will enable GDB to load multiple versions of your
|
| 3660 |
|
|
pretty-printers at the same time, because they will have different
|
| 3661 |
|
|
names.
|
| 3662 |
|
|
|
| 3663 |
|
|
You should write auto-loaded code (*note Auto-loading::) such that it
|
| 3664 |
|
|
can be evaluated multiple times without changing its meaning. An ideal
|
| 3665 |
|
|
auto-load file will consist solely of `import's of your printer
|
| 3666 |
|
|
modules, followed by a call to a register pretty-printers with the
|
| 3667 |
|
|
current objfile.
|
| 3668 |
|
|
|
| 3669 |
|
|
Taken as a whole, this approach will scale nicely to multiple
|
| 3670 |
|
|
inferiors, each potentially using a different library version.
|
| 3671 |
|
|
Embedding a version number in the Python package name will ensure that
|
| 3672 |
|
|
GDB is able to load both sets of printers simultaneously. Then,
|
| 3673 |
|
|
because the search for pretty-printers is done by objfile, and because
|
| 3674 |
|
|
your auto-loaded code took care to register your library's printers
|
| 3675 |
|
|
with a specific objfile, GDB will find the correct printers for the
|
| 3676 |
|
|
specific version of the library used by each inferior.
|
| 3677 |
|
|
|
| 3678 |
|
|
To continue the `std::string' example (*note Pretty Printing API::),
|
| 3679 |
|
|
this code might appear in `gdb.libstdcxx.v6':
|
| 3680 |
|
|
|
| 3681 |
|
|
def register_printers (objfile):
|
| 3682 |
|
|
objfile.pretty_printers.add (str_lookup_function)
|
| 3683 |
|
|
|
| 3684 |
|
|
And then the corresponding contents of the auto-load file would be:
|
| 3685 |
|
|
|
| 3686 |
|
|
import gdb.libstdcxx.v6
|
| 3687 |
|
|
gdb.libstdcxx.v6.register_printers (gdb.current_objfile ())
|
| 3688 |
|
|
|
| 3689 |
|
|
|
| 3690 |
|
|
File: gdb.info, Node: Disabling Pretty-Printers, Next: Inferiors In Python, Prev: Selecting Pretty-Printers, Up: Python API
|
| 3691 |
|
|
|
| 3692 |
|
|
23.2.2.7 Disabling Pretty-Printers
|
| 3693 |
|
|
..................................
|
| 3694 |
|
|
|
| 3695 |
|
|
For various reasons a pretty-printer may not work. For example, the
|
| 3696 |
|
|
underlying data structure may have changed and the pretty-printer is
|
| 3697 |
|
|
out of date.
|
| 3698 |
|
|
|
| 3699 |
|
|
The consequences of a broken pretty-printer are severe enough that
|
| 3700 |
|
|
GDB provides support for enabling and disabling individual printers.
|
| 3701 |
|
|
For example, if `print frame-arguments' is on, a backtrace can become
|
| 3702 |
|
|
highly illegible if any argument is printed with a broken printer.
|
| 3703 |
|
|
|
| 3704 |
|
|
Pretty-printers are enabled and disabled by attaching an `enabled'
|
| 3705 |
|
|
attribute to the registered function or callable object. If this
|
| 3706 |
|
|
attribute is present and its value is `False', the printer is disabled,
|
| 3707 |
|
|
otherwise the printer is enabled.
|
| 3708 |
|
|
|
| 3709 |
|
|
|
| 3710 |
|
|
File: gdb.info, Node: Inferiors In Python, Next: Threads In Python, Prev: Disabling Pretty-Printers, Up: Python API
|
| 3711 |
|
|
|
| 3712 |
|
|
23.2.2.8 Inferiors In Python
|
| 3713 |
|
|
............................
|
| 3714 |
|
|
|
| 3715 |
|
|
Programs which are being run under GDB are called inferiors (*note
|
| 3716 |
|
|
Inferiors and Programs::). Python scripts can access information about
|
| 3717 |
|
|
and manipulate inferiors controlled by GDB via objects of the
|
| 3718 |
|
|
`gdb.Inferior' class.
|
| 3719 |
|
|
|
| 3720 |
|
|
The following inferior-related functions are available in the `gdb'
|
| 3721 |
|
|
module:
|
| 3722 |
|
|
|
| 3723 |
|
|
-- Function: inferiors
|
| 3724 |
|
|
Return a tuple containing all inferior objects.
|
| 3725 |
|
|
|
| 3726 |
|
|
A `gdb.Inferior' object has the following attributes:
|
| 3727 |
|
|
|
| 3728 |
|
|
-- Instance Variable of Inferior: num
|
| 3729 |
|
|
ID of inferior, as assigned by GDB.
|
| 3730 |
|
|
|
| 3731 |
|
|
-- Instance Variable of Inferior: pid
|
| 3732 |
|
|
Process ID of the inferior, as assigned by the underlying
|
| 3733 |
|
|
operating system.
|
| 3734 |
|
|
|
| 3735 |
|
|
-- Instance Variable of Inferior: was_attached
|
| 3736 |
|
|
Boolean signaling whether the inferior was created using
|
| 3737 |
|
|
`attach', or started by GDB itself.
|
| 3738 |
|
|
|
| 3739 |
|
|
A `gdb.Inferior' object has the following methods:
|
| 3740 |
|
|
|
| 3741 |
|
|
-- Method on Inferior: threads
|
| 3742 |
|
|
This method returns a tuple holding all the threads which are
|
| 3743 |
|
|
valid when it is called. If there are no valid threads, the
|
| 3744 |
|
|
method will return an empty tuple.
|
| 3745 |
|
|
|
| 3746 |
|
|
-- Method on Inferior: read_memory address length
|
| 3747 |
|
|
Read LENGTH bytes of memory from the inferior, starting at
|
| 3748 |
|
|
ADDRESS. Returns a buffer object, which behaves much like an
|
| 3749 |
|
|
array or a string. It can be modified and given to the
|
| 3750 |
|
|
`gdb.write_memory' function.
|
| 3751 |
|
|
|
| 3752 |
|
|
-- Method on Inferior: write_memory address buffer [length]
|
| 3753 |
|
|
Write the contents of BUFFER to the inferior, starting at
|
| 3754 |
|
|
ADDRESS. The BUFFER parameter must be a Python object which
|
| 3755 |
|
|
supports the buffer protocol, i.e., a string, an array or the
|
| 3756 |
|
|
object returned from `gdb.read_memory'. If given, LENGTH
|
| 3757 |
|
|
determines the number of bytes from BUFFER to be written.
|
| 3758 |
|
|
|
| 3759 |
|
|
-- Method on Inferior: search_memory address length pattern
|
| 3760 |
|
|
Search a region of the inferior memory starting at ADDRESS
|
| 3761 |
|
|
with the given LENGTH using the search pattern supplied in
|
| 3762 |
|
|
PATTERN. The PATTERN parameter must be a Python object which
|
| 3763 |
|
|
supports the buffer protocol, i.e., a string, an array or the
|
| 3764 |
|
|
object returned from `gdb.read_memory'. Returns a Python
|
| 3765 |
|
|
`Long' containing the address where the pattern was found, or
|
| 3766 |
|
|
`None' if the pattern could not be found.
|
| 3767 |
|
|
|
| 3768 |
|
|
|
| 3769 |
|
|
File: gdb.info, Node: Threads In Python, Next: Commands In Python, Prev: Inferiors In Python, Up: Python API
|
| 3770 |
|
|
|
| 3771 |
|
|
23.2.2.9 Threads In Python
|
| 3772 |
|
|
..........................
|
| 3773 |
|
|
|
| 3774 |
|
|
Python scripts can access information about, and manipulate inferior
|
| 3775 |
|
|
threads controlled by GDB, via objects of the `gdb.InferiorThread'
|
| 3776 |
|
|
class.
|
| 3777 |
|
|
|
| 3778 |
|
|
The following thread-related functions are available in the `gdb'
|
| 3779 |
|
|
module:
|
| 3780 |
|
|
|
| 3781 |
|
|
-- Function: selected_thread
|
| 3782 |
|
|
This function returns the thread object for the selected thread.
|
| 3783 |
|
|
If there is no selected thread, this will return `None'.
|
| 3784 |
|
|
|
| 3785 |
|
|
A `gdb.InferiorThread' object has the following attributes:
|
| 3786 |
|
|
|
| 3787 |
|
|
-- Instance Variable of InferiorThread: num
|
| 3788 |
|
|
ID of the thread, as assigned by GDB.
|
| 3789 |
|
|
|
| 3790 |
|
|
-- Instance Variable of InferiorThread: ptid
|
| 3791 |
|
|
ID of the thread, as assigned by the operating system. This
|
| 3792 |
|
|
attribute is a tuple containing three integers. The first is
|
| 3793 |
|
|
the Process ID (PID); the second is the Lightweight Process
|
| 3794 |
|
|
ID (LWPID), and the third is the Thread ID (TID). Either the
|
| 3795 |
|
|
LWPID or TID may be 0, which indicates that the operating
|
| 3796 |
|
|
system does not use that identifier.
|
| 3797 |
|
|
|
| 3798 |
|
|
A `gdb.InferiorThread' object has the following methods:
|
| 3799 |
|
|
|
| 3800 |
|
|
-- Method on InferiorThread: switch
|
| 3801 |
|
|
This changes GDB's currently selected thread to the one
|
| 3802 |
|
|
represented by this object.
|
| 3803 |
|
|
|
| 3804 |
|
|
-- Method on InferiorThread: is_stopped
|
| 3805 |
|
|
Return a Boolean indicating whether the thread is stopped.
|
| 3806 |
|
|
|
| 3807 |
|
|
-- Method on InferiorThread: is_running
|
| 3808 |
|
|
Return a Boolean indicating whether the thread is running.
|
| 3809 |
|
|
|
| 3810 |
|
|
-- Method on InferiorThread: is_exited
|
| 3811 |
|
|
Return a Boolean indicating whether the thread is exited.
|
| 3812 |
|
|
|
| 3813 |
|
|
|
| 3814 |
|
|
File: gdb.info, Node: Commands In Python, Next: Parameters In Python, Prev: Threads In Python, Up: Python API
|
| 3815 |
|
|
|
| 3816 |
|
|
23.2.2.10 Commands In Python
|
| 3817 |
|
|
............................
|
| 3818 |
|
|
|
| 3819 |
|
|
You can implement new GDB CLI commands in Python. A CLI command is
|
| 3820 |
|
|
implemented using an instance of the `gdb.Command' class, most commonly
|
| 3821 |
|
|
using a subclass.
|
| 3822 |
|
|
|
| 3823 |
|
|
-- Method on Command: __init__ name COMMAND_CLASS [COMPLETER_CLASS]
|
| 3824 |
|
|
[PREFIX]
|
| 3825 |
|
|
The object initializer for `Command' registers the new command
|
| 3826 |
|
|
with GDB. This initializer is normally invoked from the subclass'
|
| 3827 |
|
|
own `__init__' method.
|
| 3828 |
|
|
|
| 3829 |
|
|
NAME is the name of the command. If NAME consists of multiple
|
| 3830 |
|
|
words, then the initial words are looked for as prefix commands.
|
| 3831 |
|
|
In this case, if one of the prefix commands does not exist, an
|
| 3832 |
|
|
exception is raised.
|
| 3833 |
|
|
|
| 3834 |
|
|
There is no support for multi-line commands.
|
| 3835 |
|
|
|
| 3836 |
|
|
COMMAND_CLASS should be one of the `COMMAND_' constants defined
|
| 3837 |
|
|
below. This argument tells GDB how to categorize the new command
|
| 3838 |
|
|
in the help system.
|
| 3839 |
|
|
|
| 3840 |
|
|
COMPLETER_CLASS is an optional argument. If given, it should be
|
| 3841 |
|
|
one of the `COMPLETE_' constants defined below. This argument
|
| 3842 |
|
|
tells GDB how to perform completion for this command. If not
|
| 3843 |
|
|
given, GDB will attempt to complete using the object's `complete'
|
| 3844 |
|
|
method (see below); if no such method is found, an error will
|
| 3845 |
|
|
occur when completion is attempted.
|
| 3846 |
|
|
|
| 3847 |
|
|
PREFIX is an optional argument. If `True', then the new command
|
| 3848 |
|
|
is a prefix command; sub-commands of this command may be
|
| 3849 |
|
|
registered.
|
| 3850 |
|
|
|
| 3851 |
|
|
The help text for the new command is taken from the Python
|
| 3852 |
|
|
documentation string for the command's class, if there is one. If
|
| 3853 |
|
|
no documentation string is provided, the default value "This
|
| 3854 |
|
|
command is not documented." is used.
|
| 3855 |
|
|
|
| 3856 |
|
|
-- Method on Command: dont_repeat
|
| 3857 |
|
|
By default, a GDB command is repeated when the user enters a blank
|
| 3858 |
|
|
line at the command prompt. A command can suppress this behavior
|
| 3859 |
|
|
by invoking the `dont_repeat' method. This is similar to the user
|
| 3860 |
|
|
command `dont-repeat', see *Note dont-repeat: Define.
|
| 3861 |
|
|
|
| 3862 |
|
|
-- Method on Command: invoke argument from_tty
|
| 3863 |
|
|
This method is called by GDB when this command is invoked.
|
| 3864 |
|
|
|
| 3865 |
|
|
ARGUMENT is a string. It is the argument to the command, after
|
| 3866 |
|
|
leading and trailing whitespace has been stripped.
|
| 3867 |
|
|
|
| 3868 |
|
|
FROM_TTY is a boolean argument. When true, this means that the
|
| 3869 |
|
|
command was entered by the user at the terminal; when false it
|
| 3870 |
|
|
means that the command came from elsewhere.
|
| 3871 |
|
|
|
| 3872 |
|
|
If this method throws an exception, it is turned into a GDB
|
| 3873 |
|
|
`error' call. Otherwise, the return value is ignored.
|
| 3874 |
|
|
|
| 3875 |
|
|
To break ARGUMENT up into an argv-like string use
|
| 3876 |
|
|
`gdb.string_to_argv'. This function behaves identically to GDB's
|
| 3877 |
|
|
internal argument lexer `buildargv'. It is recommended to use
|
| 3878 |
|
|
this for consistency. Arguments are separated by spaces and may
|
| 3879 |
|
|
be quoted. Example:
|
| 3880 |
|
|
|
| 3881 |
|
|
print gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"")
|
| 3882 |
|
|
['1', '2 "3', '4 "5', "6 '7"]
|
| 3883 |
|
|
|
| 3884 |
|
|
|
| 3885 |
|
|
-- Method on Command: complete text word
|
| 3886 |
|
|
This method is called by GDB when the user attempts completion on
|
| 3887 |
|
|
this command. All forms of completion are handled by this method,
|
| 3888 |
|
|
that is, the and key bindings (*note Completion::),
|
| 3889 |
|
|
and the `complete' command (*note complete: Help.).
|
| 3890 |
|
|
|
| 3891 |
|
|
The arguments TEXT and WORD are both strings. TEXT holds the
|
| 3892 |
|
|
complete command line up to the cursor's location. WORD holds the
|
| 3893 |
|
|
last word of the command line; this is computed using a
|
| 3894 |
|
|
word-breaking heuristic.
|
| 3895 |
|
|
|
| 3896 |
|
|
The `complete' method can return several values:
|
| 3897 |
|
|
* If the return value is a sequence, the contents of the
|
| 3898 |
|
|
sequence are used as the completions. It is up to `complete'
|
| 3899 |
|
|
to ensure that the contents actually do complete the word. A
|
| 3900 |
|
|
zero-length sequence is allowed, it means that there were no
|
| 3901 |
|
|
completions available. Only string elements of the sequence
|
| 3902 |
|
|
are used; other elements in the sequence are ignored.
|
| 3903 |
|
|
|
| 3904 |
|
|
* If the return value is one of the `COMPLETE_' constants
|
| 3905 |
|
|
defined below, then the corresponding GDB-internal completion
|
| 3906 |
|
|
function is invoked, and its result is used.
|
| 3907 |
|
|
|
| 3908 |
|
|
* All other results are treated as though there were no
|
| 3909 |
|
|
available completions.
|
| 3910 |
|
|
|
| 3911 |
|
|
When a new command is registered, it must be declared as a member of
|
| 3912 |
|
|
some general class of commands. This is used to classify top-level
|
| 3913 |
|
|
commands in the on-line help system; note that prefix commands are not
|
| 3914 |
|
|
listed under their own category but rather that of their top-level
|
| 3915 |
|
|
command. The available classifications are represented by constants
|
| 3916 |
|
|
defined in the `gdb' module:
|
| 3917 |
|
|
|
| 3918 |
|
|
`COMMAND_NONE'
|
| 3919 |
|
|
The command does not belong to any particular class. A command in
|
| 3920 |
|
|
this category will not be displayed in any of the help categories.
|
| 3921 |
|
|
|
| 3922 |
|
|
`COMMAND_RUNNING'
|
| 3923 |
|
|
The command is related to running the inferior. For example,
|
| 3924 |
|
|
`start', `step', and `continue' are in this category. Type `help
|
| 3925 |
|
|
running' at the GDB prompt to see a list of commands in this
|
| 3926 |
|
|
category.
|
| 3927 |
|
|
|
| 3928 |
|
|
`COMMAND_DATA'
|
| 3929 |
|
|
The command is related to data or variables. For example, `call',
|
| 3930 |
|
|
`find', and `print' are in this category. Type `help data' at the
|
| 3931 |
|
|
GDB prompt to see a list of commands in this category.
|
| 3932 |
|
|
|
| 3933 |
|
|
`COMMAND_STACK'
|
| 3934 |
|
|
The command has to do with manipulation of the stack. For example,
|
| 3935 |
|
|
`backtrace', `frame', and `return' are in this category. Type
|
| 3936 |
|
|
`help stack' at the GDB prompt to see a list of commands in this
|
| 3937 |
|
|
category.
|
| 3938 |
|
|
|
| 3939 |
|
|
`COMMAND_FILES'
|
| 3940 |
|
|
This class is used for file-related commands. For example,
|
| 3941 |
|
|
`file', `list' and `section' are in this category. Type `help
|
| 3942 |
|
|
files' at the GDB prompt to see a list of commands in this
|
| 3943 |
|
|
category.
|
| 3944 |
|
|
|
| 3945 |
|
|
`COMMAND_SUPPORT'
|
| 3946 |
|
|
This should be used for "support facilities", generally meaning
|
| 3947 |
|
|
things that are useful to the user when interacting with GDB, but
|
| 3948 |
|
|
not related to the state of the inferior. For example, `help',
|
| 3949 |
|
|
`make', and `shell' are in this category. Type `help support' at
|
| 3950 |
|
|
the GDB prompt to see a list of commands in this category.
|
| 3951 |
|
|
|
| 3952 |
|
|
`COMMAND_STATUS'
|
| 3953 |
|
|
The command is an `info'-related command, that is, related to the
|
| 3954 |
|
|
state of GDB itself. For example, `info', `macro', and `show' are
|
| 3955 |
|
|
in this category. Type `help status' at the GDB prompt to see a
|
| 3956 |
|
|
list of commands in this category.
|
| 3957 |
|
|
|
| 3958 |
|
|
`COMMAND_BREAKPOINTS'
|
| 3959 |
|
|
The command has to do with breakpoints. For example, `break',
|
| 3960 |
|
|
`clear', and `delete' are in this category. Type `help
|
| 3961 |
|
|
breakpoints' at the GDB prompt to see a list of commands in this
|
| 3962 |
|
|
category.
|
| 3963 |
|
|
|
| 3964 |
|
|
`COMMAND_TRACEPOINTS'
|
| 3965 |
|
|
The command has to do with tracepoints. For example, `trace',
|
| 3966 |
|
|
`actions', and `tfind' are in this category. Type `help
|
| 3967 |
|
|
tracepoints' at the GDB prompt to see a list of commands in this
|
| 3968 |
|
|
category.
|
| 3969 |
|
|
|
| 3970 |
|
|
`COMMAND_OBSCURE'
|
| 3971 |
|
|
The command is only used in unusual circumstances, or is not of
|
| 3972 |
|
|
general interest to users. For example, `checkpoint', `fork', and
|
| 3973 |
|
|
`stop' are in this category. Type `help obscure' at the GDB
|
| 3974 |
|
|
prompt to see a list of commands in this category.
|
| 3975 |
|
|
|
| 3976 |
|
|
`COMMAND_MAINTENANCE'
|
| 3977 |
|
|
The command is only useful to GDB maintainers. The `maintenance'
|
| 3978 |
|
|
and `flushregs' commands are in this category. Type `help
|
| 3979 |
|
|
internals' at the GDB prompt to see a list of commands in this
|
| 3980 |
|
|
category.
|
| 3981 |
|
|
|
| 3982 |
|
|
A new command can use a predefined completion function, either by
|
| 3983 |
|
|
specifying it via an argument at initialization, or by returning it
|
| 3984 |
|
|
from the `complete' method. These predefined completion constants are
|
| 3985 |
|
|
all defined in the `gdb' module:
|
| 3986 |
|
|
|
| 3987 |
|
|
`COMPLETE_NONE'
|
| 3988 |
|
|
This constant means that no completion should be done.
|
| 3989 |
|
|
|
| 3990 |
|
|
`COMPLETE_FILENAME'
|
| 3991 |
|
|
This constant means that filename completion should be performed.
|
| 3992 |
|
|
|
| 3993 |
|
|
`COMPLETE_LOCATION'
|
| 3994 |
|
|
This constant means that location completion should be done.
|
| 3995 |
|
|
*Note Specify Location::.
|
| 3996 |
|
|
|
| 3997 |
|
|
`COMPLETE_COMMAND'
|
| 3998 |
|
|
This constant means that completion should examine GDB command
|
| 3999 |
|
|
names.
|
| 4000 |
|
|
|
| 4001 |
|
|
`COMPLETE_SYMBOL'
|
| 4002 |
|
|
This constant means that completion should be done using symbol
|
| 4003 |
|
|
names as the source.
|
| 4004 |
|
|
|
| 4005 |
|
|
The following code snippet shows how a trivial CLI command can be
|
| 4006 |
|
|
implemented in Python:
|
| 4007 |
|
|
|
| 4008 |
|
|
class HelloWorld (gdb.Command):
|
| 4009 |
|
|
"""Greet the whole world."""
|
| 4010 |
|
|
|
| 4011 |
|
|
def __init__ (self):
|
| 4012 |
|
|
super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE)
|
| 4013 |
|
|
|
| 4014 |
|
|
def invoke (self, arg, from_tty):
|
| 4015 |
|
|
print "Hello, World!"
|
| 4016 |
|
|
|
| 4017 |
|
|
HelloWorld ()
|
| 4018 |
|
|
|
| 4019 |
|
|
The last line instantiates the class, and is necessary to trigger the
|
| 4020 |
|
|
registration of the command with GDB. Depending on how the Python code
|
| 4021 |
|
|
is read into GDB, you may need to import the `gdb' module explicitly.
|
| 4022 |
|
|
|
| 4023 |
|
|
|
| 4024 |
|
|
File: gdb.info, Node: Parameters In Python, Next: Functions In Python, Prev: Commands In Python, Up: Python API
|
| 4025 |
|
|
|
| 4026 |
|
|
23.2.2.11 Parameters In Python
|
| 4027 |
|
|
..............................
|
| 4028 |
|
|
|
| 4029 |
|
|
You can implement new GDB parameters using Python. A new parameter is
|
| 4030 |
|
|
implemented as an instance of the `gdb.Parameter' class.
|
| 4031 |
|
|
|
| 4032 |
|
|
Parameters are exposed to the user via the `set' and `show'
|
| 4033 |
|
|
commands. *Note Help::.
|
| 4034 |
|
|
|
| 4035 |
|
|
There are many parameters that already exist and can be set in GDB.
|
| 4036 |
|
|
Two examples are: `set follow fork' and `set charset'. Setting these
|
| 4037 |
|
|
parameters influences certain behavior in GDB. Similarly, you can
|
| 4038 |
|
|
define parameters that can be used to influence behavior in custom
|
| 4039 |
|
|
Python scripts and commands.
|
| 4040 |
|
|
|
| 4041 |
|
|
-- Method on Parameter: __init__ name COMMAND-CLASS PARAMETER-CLASS
|
| 4042 |
|
|
[ENUM-SEQUENCE]
|
| 4043 |
|
|
The object initializer for `Parameter' registers the new parameter
|
| 4044 |
|
|
with GDB. This initializer is normally invoked from the subclass'
|
| 4045 |
|
|
own `__init__' method.
|
| 4046 |
|
|
|
| 4047 |
|
|
NAME is the name of the new parameter. If NAME consists of
|
| 4048 |
|
|
multiple words, then the initial words are looked for as prefix
|
| 4049 |
|
|
parameters. An example of this can be illustrated with the `set
|
| 4050 |
|
|
print' set of parameters. If NAME is `print foo', then `print'
|
| 4051 |
|
|
will be searched as the prefix parameter. In this case the
|
| 4052 |
|
|
parameter can subsequently be accessed in GDB as `set print foo'.
|
| 4053 |
|
|
|
| 4054 |
|
|
If NAME consists of multiple words, and no prefix parameter group
|
| 4055 |
|
|
can be found, an exception is raised.
|
| 4056 |
|
|
|
| 4057 |
|
|
COMMAND-CLASS should be one of the `COMMAND_' constants (*note
|
| 4058 |
|
|
Commands In Python::). This argument tells GDB how to categorize
|
| 4059 |
|
|
the new parameter in the help system.
|
| 4060 |
|
|
|
| 4061 |
|
|
PARAMETER-CLASS should be one of the `PARAM_' constants defined
|
| 4062 |
|
|
below. This argument tells GDB the type of the new parameter;
|
| 4063 |
|
|
this information is used for input validation and completion.
|
| 4064 |
|
|
|
| 4065 |
|
|
If PARAMETER-CLASS is `PARAM_ENUM', then ENUM-SEQUENCE must be a
|
| 4066 |
|
|
sequence of strings. These strings represent the possible values
|
| 4067 |
|
|
for the parameter.
|
| 4068 |
|
|
|
| 4069 |
|
|
If PARAMETER-CLASS is not `PARAM_ENUM', then the presence of a
|
| 4070 |
|
|
fourth argument will cause an exception to be thrown.
|
| 4071 |
|
|
|
| 4072 |
|
|
The help text for the new parameter is taken from the Python
|
| 4073 |
|
|
documentation string for the parameter's class, if there is one.
|
| 4074 |
|
|
If there is no documentation string, a default value is used.
|
| 4075 |
|
|
|
| 4076 |
|
|
-- Instance Variable of Parameter: set_doc
|
| 4077 |
|
|
If this attribute exists, and is a string, then its value is used
|
| 4078 |
|
|
as the help text for this parameter's `set' command. The value is
|
| 4079 |
|
|
examined when `Parameter.__init__' is invoked; subsequent changes
|
| 4080 |
|
|
have no effect.
|
| 4081 |
|
|
|
| 4082 |
|
|
-- Instance Variable of Parameter: show_doc
|
| 4083 |
|
|
If this attribute exists, and is a string, then its value is used
|
| 4084 |
|
|
as the help text for this parameter's `show' command. The value is
|
| 4085 |
|
|
examined when `Parameter.__init__' is invoked; subsequent changes
|
| 4086 |
|
|
have no effect.
|
| 4087 |
|
|
|
| 4088 |
|
|
-- Instance Variable of Parameter: value
|
| 4089 |
|
|
The `value' attribute holds the underlying value of the parameter.
|
| 4090 |
|
|
It can be read and assigned to just as any other attribute. GDB
|
| 4091 |
|
|
does validation when assignments are made.
|
| 4092 |
|
|
|
| 4093 |
|
|
When a new parameter is defined, its type must be specified. The
|
| 4094 |
|
|
available types are represented by constants defined in the `gdb'
|
| 4095 |
|
|
module:
|
| 4096 |
|
|
|
| 4097 |
|
|
`PARAM_BOOLEAN'
|
| 4098 |
|
|
The value is a plain boolean. The Python boolean values, `True'
|
| 4099 |
|
|
and `False' are the only valid values.
|
| 4100 |
|
|
|
| 4101 |
|
|
`PARAM_AUTO_BOOLEAN'
|
| 4102 |
|
|
The value has three possible states: true, false, and `auto'. In
|
| 4103 |
|
|
Python, true and false are represented using boolean constants, and
|
| 4104 |
|
|
`auto' is represented using `None'.
|
| 4105 |
|
|
|
| 4106 |
|
|
`PARAM_UINTEGER'
|
| 4107 |
|
|
The value is an unsigned integer. The value of 0 should be
|
| 4108 |
|
|
interpreted to mean "unlimited".
|
| 4109 |
|
|
|
| 4110 |
|
|
`PARAM_INTEGER'
|
| 4111 |
|
|
The value is a signed integer. The value of 0 should be
|
| 4112 |
|
|
interpreted to mean "unlimited".
|
| 4113 |
|
|
|
| 4114 |
|
|
`PARAM_STRING'
|
| 4115 |
|
|
The value is a string. When the user modifies the string, any
|
| 4116 |
|
|
escape sequences, such as `\t', `\f', and octal escapes, are
|
| 4117 |
|
|
translated into corresponding characters and encoded into the
|
| 4118 |
|
|
current host charset.
|
| 4119 |
|
|
|
| 4120 |
|
|
`PARAM_STRING_NOESCAPE'
|
| 4121 |
|
|
The value is a string. When the user modifies the string, escapes
|
| 4122 |
|
|
are passed through untranslated.
|
| 4123 |
|
|
|
| 4124 |
|
|
`PARAM_OPTIONAL_FILENAME'
|
| 4125 |
|
|
The value is a either a filename (a string), or `None'.
|
| 4126 |
|
|
|
| 4127 |
|
|
`PARAM_FILENAME'
|
| 4128 |
|
|
The value is a filename. This is just like
|
| 4129 |
|
|
`PARAM_STRING_NOESCAPE', but uses file names for completion.
|
| 4130 |
|
|
|
| 4131 |
|
|
`PARAM_ZINTEGER'
|
| 4132 |
|
|
The value is an integer. This is like `PARAM_INTEGER', except 0
|
| 4133 |
|
|
is interpreted as itself.
|
| 4134 |
|
|
|
| 4135 |
|
|
`PARAM_ENUM'
|
| 4136 |
|
|
The value is a string, which must be one of a collection string
|
| 4137 |
|
|
constants provided when the parameter is created.
|
| 4138 |
|
|
|
| 4139 |
|
|
|
| 4140 |
|
|
File: gdb.info, Node: Functions In Python, Next: Progspaces In Python, Prev: Parameters In Python, Up: Python API
|
| 4141 |
|
|
|
| 4142 |
|
|
23.2.2.12 Writing new convenience functions
|
| 4143 |
|
|
...........................................
|
| 4144 |
|
|
|
| 4145 |
|
|
You can implement new convenience functions (*note Convenience Vars::)
|
| 4146 |
|
|
in Python. A convenience function is an instance of a subclass of the
|
| 4147 |
|
|
class `gdb.Function'.
|
| 4148 |
|
|
|
| 4149 |
|
|
-- Method on Function: __init__ name
|
| 4150 |
|
|
The initializer for `Function' registers the new function with
|
| 4151 |
|
|
GDB. The argument NAME is the name of the function, a string.
|
| 4152 |
|
|
The function will be visible to the user as a convenience variable
|
| 4153 |
|
|
of type `internal function', whose name is the same as the given
|
| 4154 |
|
|
NAME.
|
| 4155 |
|
|
|
| 4156 |
|
|
The documentation for the new function is taken from the
|
| 4157 |
|
|
documentation string for the new class.
|
| 4158 |
|
|
|
| 4159 |
|
|
-- Method on Function: invoke *ARGS
|
| 4160 |
|
|
When a convenience function is evaluated, its arguments are
|
| 4161 |
|
|
converted to instances of `gdb.Value', and then the function's
|
| 4162 |
|
|
`invoke' method is called. Note that GDB does not predetermine
|
| 4163 |
|
|
the arity of convenience functions. Instead, all available
|
| 4164 |
|
|
arguments are passed to `invoke', following the standard Python
|
| 4165 |
|
|
calling convention. In particular, a convenience function can
|
| 4166 |
|
|
have default values for parameters without ill effect.
|
| 4167 |
|
|
|
| 4168 |
|
|
The return value of this method is used as its value in the
|
| 4169 |
|
|
enclosing expression. If an ordinary Python value is returned, it
|
| 4170 |
|
|
is converted to a `gdb.Value' following the usual rules.
|
| 4171 |
|
|
|
| 4172 |
|
|
The following code snippet shows how a trivial convenience function
|
| 4173 |
|
|
can be implemented in Python:
|
| 4174 |
|
|
|
| 4175 |
|
|
class Greet (gdb.Function):
|
| 4176 |
|
|
"""Return string to greet someone.
|
| 4177 |
|
|
Takes a name as argument."""
|
| 4178 |
|
|
|
| 4179 |
|
|
def __init__ (self):
|
| 4180 |
|
|
super (Greet, self).__init__ ("greet")
|
| 4181 |
|
|
|
| 4182 |
|
|
def invoke (self, name):
|
| 4183 |
|
|
return "Hello, %s!" % name.string ()
|
| 4184 |
|
|
|
| 4185 |
|
|
Greet ()
|
| 4186 |
|
|
|
| 4187 |
|
|
The last line instantiates the class, and is necessary to trigger the
|
| 4188 |
|
|
registration of the function with GDB. Depending on how the Python
|
| 4189 |
|
|
code is read into GDB, you may need to import the `gdb' module
|
| 4190 |
|
|
explicitly.
|
| 4191 |
|
|
|
| 4192 |
|
|
|
| 4193 |
|
|
File: gdb.info, Node: Progspaces In Python, Next: Objfiles In Python, Prev: Functions In Python, Up: Python API
|
| 4194 |
|
|
|
| 4195 |
|
|
23.2.2.13 Program Spaces In Python
|
| 4196 |
|
|
..................................
|
| 4197 |
|
|
|
| 4198 |
|
|
A program space, or "progspace", represents a symbolic view of an
|
| 4199 |
|
|
address space. It consists of all of the objfiles of the program.
|
| 4200 |
|
|
*Note Objfiles In Python::. *Note program spaces: Inferiors and
|
| 4201 |
|
|
Programs, for more details about program spaces.
|
| 4202 |
|
|
|
| 4203 |
|
|
The following progspace-related functions are available in the `gdb'
|
| 4204 |
|
|
module:
|
| 4205 |
|
|
|
| 4206 |
|
|
-- Function: current_progspace
|
| 4207 |
|
|
This function returns the program space of the currently selected
|
| 4208 |
|
|
inferior. *Note Inferiors and Programs::.
|
| 4209 |
|
|
|
| 4210 |
|
|
-- Function: progspaces
|
| 4211 |
|
|
Return a sequence of all the progspaces currently known to GDB.
|
| 4212 |
|
|
|
| 4213 |
|
|
Each progspace is represented by an instance of the `gdb.Progspace'
|
| 4214 |
|
|
class.
|
| 4215 |
|
|
|
| 4216 |
|
|
-- Instance Variable of Progspace: filename
|
| 4217 |
|
|
The file name of the progspace as a string.
|
| 4218 |
|
|
|
| 4219 |
|
|
-- Instance Variable of Progspace: pretty_printers
|
| 4220 |
|
|
The `pretty_printers' attribute is a list of functions. It is
|
| 4221 |
|
|
used to look up pretty-printers. A `Value' is passed to each
|
| 4222 |
|
|
function in order; if the function returns `None', then the search
|
| 4223 |
|
|
continues. Otherwise, the return value should be an object which
|
| 4224 |
|
|
is used to format the value. *Note Pretty Printing API::, for more
|
| 4225 |
|
|
information.
|
| 4226 |
|
|
|
| 4227 |
|
|
|
| 4228 |
|
|
File: gdb.info, Node: Objfiles In Python, Next: Frames In Python, Prev: Progspaces In Python, Up: Python API
|
| 4229 |
|
|
|
| 4230 |
|
|
23.2.2.14 Objfiles In Python
|
| 4231 |
|
|
............................
|
| 4232 |
|
|
|
| 4233 |
|
|
GDB loads symbols for an inferior from various symbol-containing files
|
| 4234 |
|
|
(*note Files::). These include the primary executable file, any shared
|
| 4235 |
|
|
libraries used by the inferior, and any separate debug info files
|
| 4236 |
|
|
(*note Separate Debug Files::). GDB calls these symbol-containing
|
| 4237 |
|
|
files "objfiles".
|
| 4238 |
|
|
|
| 4239 |
|
|
The following objfile-related functions are available in the `gdb'
|
| 4240 |
|
|
module:
|
| 4241 |
|
|
|
| 4242 |
|
|
-- Function: current_objfile
|
| 4243 |
|
|
When auto-loading a Python script (*note Auto-loading::), GDB sets
|
| 4244 |
|
|
the "current objfile" to the corresponding objfile. This function
|
| 4245 |
|
|
returns the current objfile. If there is no current objfile, this
|
| 4246 |
|
|
function returns `None'.
|
| 4247 |
|
|
|
| 4248 |
|
|
-- Function: objfiles
|
| 4249 |
|
|
Return a sequence of all the objfiles current known to GDB. *Note
|
| 4250 |
|
|
Objfiles In Python::.
|
| 4251 |
|
|
|
| 4252 |
|
|
Each objfile is represented by an instance of the `gdb.Objfile'
|
| 4253 |
|
|
class.
|
| 4254 |
|
|
|
| 4255 |
|
|
-- Instance Variable of Objfile: filename
|
| 4256 |
|
|
The file name of the objfile as a string.
|
| 4257 |
|
|
|
| 4258 |
|
|
-- Instance Variable of Objfile: pretty_printers
|
| 4259 |
|
|
The `pretty_printers' attribute is a list of functions. It is
|
| 4260 |
|
|
used to look up pretty-printers. A `Value' is passed to each
|
| 4261 |
|
|
function in order; if the function returns `None', then the search
|
| 4262 |
|
|
continues. Otherwise, the return value should be an object which
|
| 4263 |
|
|
is used to format the value. *Note Pretty Printing API::, for more
|
| 4264 |
|
|
information.
|
| 4265 |
|
|
|
| 4266 |
|
|
|
| 4267 |
|
|
File: gdb.info, Node: Frames In Python, Next: Blocks In Python, Prev: Objfiles In Python, Up: Python API
|
| 4268 |
|
|
|
| 4269 |
|
|
23.2.2.15 Accessing inferior stack frames from Python.
|
| 4270 |
|
|
......................................................
|
| 4271 |
|
|
|
| 4272 |
|
|
When the debugged program stops, GDB is able to analyze its call stack
|
| 4273 |
|
|
(*note Stack frames: Frames.). The `gdb.Frame' class represents a
|
| 4274 |
|
|
frame in the stack. A `gdb.Frame' object is only valid while its
|
| 4275 |
|
|
corresponding frame exists in the inferior's stack. If you try to use
|
| 4276 |
|
|
an invalid frame object, GDB will throw a `RuntimeError' exception.
|
| 4277 |
|
|
|
| 4278 |
|
|
Two `gdb.Frame' objects can be compared for equality with the `=='
|
| 4279 |
|
|
operator, like:
|
| 4280 |
|
|
|
| 4281 |
|
|
(gdb) python print gdb.newest_frame() == gdb.selected_frame ()
|
| 4282 |
|
|
True
|
| 4283 |
|
|
|
| 4284 |
|
|
The following frame-related functions are available in the `gdb'
|
| 4285 |
|
|
module:
|
| 4286 |
|
|
|
| 4287 |
|
|
-- Function: selected_frame
|
| 4288 |
|
|
Return the selected frame object. (*note Selecting a Frame:
|
| 4289 |
|
|
Selection.).
|
| 4290 |
|
|
|
| 4291 |
|
|
-- Function: frame_stop_reason_string reason
|
| 4292 |
|
|
Return a string explaining the reason why GDB stopped unwinding
|
| 4293 |
|
|
frames, as expressed by the given REASON code (an integer, see the
|
| 4294 |
|
|
`unwind_stop_reason' method further down in this section).
|
| 4295 |
|
|
|
| 4296 |
|
|
A `gdb.Frame' object has the following methods:
|
| 4297 |
|
|
|
| 4298 |
|
|
-- Method on Frame: is_valid
|
| 4299 |
|
|
Returns true if the `gdb.Frame' object is valid, false if not.
|
| 4300 |
|
|
A frame object can become invalid if the frame it refers to
|
| 4301 |
|
|
doesn't exist anymore in the inferior. All `gdb.Frame'
|
| 4302 |
|
|
methods will throw an exception if it is invalid at the time
|
| 4303 |
|
|
the method is called.
|
| 4304 |
|
|
|
| 4305 |
|
|
-- Method on Frame: name
|
| 4306 |
|
|
Returns the function name of the frame, or `None' if it can't
|
| 4307 |
|
|
be obtained.
|
| 4308 |
|
|
|
| 4309 |
|
|
-- Method on Frame: type
|
| 4310 |
|
|
Returns the type of the frame. The value can be one of
|
| 4311 |
|
|
`gdb.NORMAL_FRAME', `gdb.DUMMY_FRAME', `gdb.SIGTRAMP_FRAME'
|
| 4312 |
|
|
or `gdb.SENTINEL_FRAME'.
|
| 4313 |
|
|
|
| 4314 |
|
|
-- Method on Frame: unwind_stop_reason
|
| 4315 |
|
|
Return an integer representing the reason why it's not
|
| 4316 |
|
|
possible to find more frames toward the outermost frame. Use
|
| 4317 |
|
|
`gdb.frame_stop_reason_string' to convert the value returned
|
| 4318 |
|
|
by this function to a string.
|
| 4319 |
|
|
|
| 4320 |
|
|
-- Method on Frame: pc
|
| 4321 |
|
|
Returns the frame's resume address.
|
| 4322 |
|
|
|
| 4323 |
|
|
-- Method on Frame: block
|
| 4324 |
|
|
Return the frame's code block. *Note Blocks In Python::.
|
| 4325 |
|
|
|
| 4326 |
|
|
-- Method on Frame: function
|
| 4327 |
|
|
Return the symbol for the function corresponding to this
|
| 4328 |
|
|
frame. *Note Symbols In Python::.
|
| 4329 |
|
|
|
| 4330 |
|
|
-- Method on Frame: older
|
| 4331 |
|
|
Return the frame that called this frame.
|
| 4332 |
|
|
|
| 4333 |
|
|
-- Method on Frame: newer
|
| 4334 |
|
|
Return the frame called by this frame.
|
| 4335 |
|
|
|
| 4336 |
|
|
-- Method on Frame: find_sal
|
| 4337 |
|
|
Return the frame's symtab and line object. *Note Symbol
|
| 4338 |
|
|
Tables In Python::.
|
| 4339 |
|
|
|
| 4340 |
|
|
-- Method on Frame: read_var variable [block]
|
| 4341 |
|
|
Return the value of VARIABLE in this frame. If the optional
|
| 4342 |
|
|
argument BLOCK is provided, search for the variable from that
|
| 4343 |
|
|
block; otherwise start at the frame's current block (which is
|
| 4344 |
|
|
determined by the frame's current program counter). VARIABLE
|
| 4345 |
|
|
must be a string or a `gdb.Symbol' object. BLOCK must be a
|
| 4346 |
|
|
`gdb.Block' object.
|
| 4347 |
|
|
|
| 4348 |
|
|
-- Method on Frame: select
|
| 4349 |
|
|
Set this frame to be the selected frame. *Note Examining the
|
| 4350 |
|
|
Stack: Stack.
|
| 4351 |
|
|
|
| 4352 |
|
|
|
| 4353 |
|
|
File: gdb.info, Node: Blocks In Python, Next: Symbols In Python, Prev: Frames In Python, Up: Python API
|
| 4354 |
|
|
|
| 4355 |
|
|
23.2.2.16 Accessing frame blocks from Python.
|
| 4356 |
|
|
.............................................
|
| 4357 |
|
|
|
| 4358 |
|
|
Within each frame, GDB maintains information on each block stored in
|
| 4359 |
|
|
that frame. These blocks are organized hierarchically, and are
|
| 4360 |
|
|
represented individually in Python as a `gdb.Block'. Please see *Note
|
| 4361 |
|
|
Frames In Python::, for a more in-depth discussion on frames.
|
| 4362 |
|
|
Furthermore, see *Note Examining the Stack: Stack, for more detailed
|
| 4363 |
|
|
technical information on GDB's book-keeping of the stack.
|
| 4364 |
|
|
|
| 4365 |
|
|
The following block-related functions are available in the `gdb'
|
| 4366 |
|
|
module:
|
| 4367 |
|
|
|
| 4368 |
|
|
-- Function: block_for_pc pc
|
| 4369 |
|
|
Return the `gdb.Block' containing the given PC value. If the
|
| 4370 |
|
|
block cannot be found for the PC value specified, the function
|
| 4371 |
|
|
will return `None'.
|
| 4372 |
|
|
|
| 4373 |
|
|
A `gdb.Block' object has the following attributes:
|
| 4374 |
|
|
|
| 4375 |
|
|
-- Instance Variable of Block: start
|
| 4376 |
|
|
The start address of the block. This attribute is not
|
| 4377 |
|
|
writable.
|
| 4378 |
|
|
|
| 4379 |
|
|
-- Instance Variable of Block: end
|
| 4380 |
|
|
The end address of the block. This attribute is not writable.
|
| 4381 |
|
|
|
| 4382 |
|
|
-- Instance Variable of Block: function
|
| 4383 |
|
|
The name of the block represented as a `gdb.Symbol'. If the
|
| 4384 |
|
|
block is not named, then this attribute holds `None'. This
|
| 4385 |
|
|
attribute is not writable.
|
| 4386 |
|
|
|
| 4387 |
|
|
-- Instance Variable of Block: superblock
|
| 4388 |
|
|
The block containing this block. If this parent block does
|
| 4389 |
|
|
not exist, this attribute holds `None'. This attribute is
|
| 4390 |
|
|
not writable.
|
| 4391 |
|
|
|
| 4392 |
|
|
|
| 4393 |
|
|
File: gdb.info, Node: Symbols In Python, Next: Symbol Tables In Python, Prev: Blocks In Python, Up: Python API
|
| 4394 |
|
|
|
| 4395 |
|
|
23.2.2.17 Python representation of Symbols.
|
| 4396 |
|
|
...........................................
|
| 4397 |
|
|
|
| 4398 |
|
|
GDB represents every variable, function and type as an entry in a
|
| 4399 |
|
|
symbol table. *Note Examining the Symbol Table: Symbols. Similarly,
|
| 4400 |
|
|
Python represents these symbols in GDB with the `gdb.Symbol' object.
|
| 4401 |
|
|
|
| 4402 |
|
|
The following symbol-related functions are available in the `gdb'
|
| 4403 |
|
|
module:
|
| 4404 |
|
|
|
| 4405 |
|
|
-- Function: lookup_symbol name [block] [domain]
|
| 4406 |
|
|
This function searches for a symbol by name. The search scope can
|
| 4407 |
|
|
be restricted to the parameters defined in the optional domain and
|
| 4408 |
|
|
block arguments.
|
| 4409 |
|
|
|
| 4410 |
|
|
NAME is the name of the symbol. It must be a string. The
|
| 4411 |
|
|
optional BLOCK argument restricts the search to symbols visible in
|
| 4412 |
|
|
that BLOCK. The BLOCK argument must be a `gdb.Block' object. The
|
| 4413 |
|
|
optional DOMAIN argument restricts the search to the domain type.
|
| 4414 |
|
|
The DOMAIN argument must be a domain constant defined in the `gdb'
|
| 4415 |
|
|
module and described later in this chapter.
|
| 4416 |
|
|
|
| 4417 |
|
|
A `gdb.Symbol' object has the following attributes:
|
| 4418 |
|
|
|
| 4419 |
|
|
-- Instance Variable of Symbol: symtab
|
| 4420 |
|
|
The symbol table in which the symbol appears. This attribute
|
| 4421 |
|
|
is represented as a `gdb.Symtab' object. *Note Symbol Tables
|
| 4422 |
|
|
In Python::. This attribute is not writable.
|
| 4423 |
|
|
|
| 4424 |
|
|
-- Instance Variable of Symbol: name
|
| 4425 |
|
|
The name of the symbol as a string. This attribute is not
|
| 4426 |
|
|
writable.
|
| 4427 |
|
|
|
| 4428 |
|
|
-- Instance Variable of Symbol: linkage_name
|
| 4429 |
|
|
The name of the symbol, as used by the linker (i.e., may be
|
| 4430 |
|
|
mangled). This attribute is not writable.
|
| 4431 |
|
|
|
| 4432 |
|
|
-- Instance Variable of Symbol: print_name
|
| 4433 |
|
|
The name of the symbol in a form suitable for output. This
|
| 4434 |
|
|
is either `name' or `linkage_name', depending on whether the
|
| 4435 |
|
|
user asked GDB to display demangled or mangled names.
|
| 4436 |
|
|
|
| 4437 |
|
|
-- Instance Variable of Symbol: addr_class
|
| 4438 |
|
|
The address class of the symbol. This classifies how to find
|
| 4439 |
|
|
the value of a symbol. Each address class is a constant
|
| 4440 |
|
|
defined in the `gdb' module and described later in this
|
| 4441 |
|
|
chapter.
|
| 4442 |
|
|
|
| 4443 |
|
|
-- Instance Variable of Symbol: is_argument
|
| 4444 |
|
|
`True' if the symbol is an argument of a function.
|
| 4445 |
|
|
|
| 4446 |
|
|
-- Instance Variable of Symbol: is_constant
|
| 4447 |
|
|
`True' if the symbol is a constant.
|
| 4448 |
|
|
|
| 4449 |
|
|
-- Instance Variable of Symbol: is_function
|
| 4450 |
|
|
`True' if the symbol is a function or a method.
|
| 4451 |
|
|
|
| 4452 |
|
|
-- Instance Variable of Symbol: is_variable
|
| 4453 |
|
|
`True' if the symbol is a variable.
|
| 4454 |
|
|
|
| 4455 |
|
|
The available domain categories in `gdb.Symbol' are represented as
|
| 4456 |
|
|
constants in the `gdb' module:
|
| 4457 |
|
|
|
| 4458 |
|
|
`SYMBOL_UNDEF_DOMAIN'
|
| 4459 |
|
|
This is used when a domain has not been discovered or none of the
|
| 4460 |
|
|
following domains apply. This usually indicates an error either
|
| 4461 |
|
|
in the symbol information or in GDB's handling of symbols.
|
| 4462 |
|
|
|
| 4463 |
|
|
`SYMBOL_VAR_DOMAIN'
|
| 4464 |
|
|
This domain contains variables, function names, typedef names and
|
| 4465 |
|
|
enum type values.
|
| 4466 |
|
|
|
| 4467 |
|
|
`SYMBOL_STRUCT_DOMAIN'
|
| 4468 |
|
|
This domain holds struct, union and enum type names.
|
| 4469 |
|
|
|
| 4470 |
|
|
`SYMBOL_LABEL_DOMAIN'
|
| 4471 |
|
|
This domain contains names of labels (for gotos).
|
| 4472 |
|
|
|
| 4473 |
|
|
`SYMBOL_VARIABLES_DOMAIN'
|
| 4474 |
|
|
This domain holds a subset of the `SYMBOLS_VAR_DOMAIN'; it
|
| 4475 |
|
|
contains everything minus functions and types.
|
| 4476 |
|
|
|
| 4477 |
|
|
`SYMBOL_FUNCTION_DOMAIN'
|
| 4478 |
|
|
This domain contains all functions.
|
| 4479 |
|
|
|
| 4480 |
|
|
`SYMBOL_TYPES_DOMAIN'
|
| 4481 |
|
|
This domain contains all types.
|
| 4482 |
|
|
|
| 4483 |
|
|
The available address class categories in `gdb.Symbol' are
|
| 4484 |
|
|
represented as constants in the `gdb' module:
|
| 4485 |
|
|
|
| 4486 |
|
|
`SYMBOL_LOC_UNDEF'
|
| 4487 |
|
|
If this is returned by address class, it indicates an error either
|
| 4488 |
|
|
in the symbol information or in GDB's handling of symbols.
|
| 4489 |
|
|
|
| 4490 |
|
|
`SYMBOL_LOC_CONST'
|
| 4491 |
|
|
Value is constant int.
|
| 4492 |
|
|
|
| 4493 |
|
|
`SYMBOL_LOC_STATIC'
|
| 4494 |
|
|
Value is at a fixed address.
|
| 4495 |
|
|
|
| 4496 |
|
|
`SYMBOL_LOC_REGISTER'
|
| 4497 |
|
|
Value is in a register.
|
| 4498 |
|
|
|
| 4499 |
|
|
`SYMBOL_LOC_ARG'
|
| 4500 |
|
|
Value is an argument. This value is at the offset stored within
|
| 4501 |
|
|
the symbol inside the frame's argument list.
|
| 4502 |
|
|
|
| 4503 |
|
|
`SYMBOL_LOC_REF_ARG'
|
| 4504 |
|
|
Value address is stored in the frame's argument list. Just like
|
| 4505 |
|
|
`LOC_ARG' except that the value's address is stored at the offset,
|
| 4506 |
|
|
not the value itself.
|
| 4507 |
|
|
|
| 4508 |
|
|
`SYMBOL_LOC_REGPARM_ADDR'
|
| 4509 |
|
|
Value is a specified register. Just like `LOC_REGISTER' except
|
| 4510 |
|
|
the register holds the address of the argument instead of the
|
| 4511 |
|
|
argument itself.
|
| 4512 |
|
|
|
| 4513 |
|
|
`SYMBOL_LOC_LOCAL'
|
| 4514 |
|
|
Value is a local variable.
|
| 4515 |
|
|
|
| 4516 |
|
|
`SYMBOL_LOC_TYPEDEF'
|
| 4517 |
|
|
Value not used. Symbols in the domain `SYMBOL_STRUCT_DOMAIN' all
|
| 4518 |
|
|
have this class.
|
| 4519 |
|
|
|
| 4520 |
|
|
`SYMBOL_LOC_BLOCK'
|
| 4521 |
|
|
Value is a block.
|
| 4522 |
|
|
|
| 4523 |
|
|
`SYMBOL_LOC_CONST_BYTES'
|
| 4524 |
|
|
Value is a byte-sequence.
|
| 4525 |
|
|
|
| 4526 |
|
|
`SYMBOL_LOC_UNRESOLVED'
|
| 4527 |
|
|
Value is at a fixed address, but the address of the variable has
|
| 4528 |
|
|
to be determined from the minimal symbol table whenever the
|
| 4529 |
|
|
variable is referenced.
|
| 4530 |
|
|
|
| 4531 |
|
|
`SYMBOL_LOC_OPTIMIZED_OUT'
|
| 4532 |
|
|
The value does not actually exist in the program.
|
| 4533 |
|
|
|
| 4534 |
|
|
`SYMBOL_LOC_COMPUTED'
|
| 4535 |
|
|
The value's address is a computed location.
|
| 4536 |
|
|
|
| 4537 |
|
|
|
| 4538 |
|
|
File: gdb.info, Node: Symbol Tables In Python, Next: Lazy Strings In Python, Prev: Symbols In Python, Up: Python API
|
| 4539 |
|
|
|
| 4540 |
|
|
23.2.2.18 Symbol table representation in Python.
|
| 4541 |
|
|
................................................
|
| 4542 |
|
|
|
| 4543 |
|
|
Access to symbol table data maintained by GDB on the inferior is
|
| 4544 |
|
|
exposed to Python via two objects: `gdb.Symtab_and_line' and
|
| 4545 |
|
|
`gdb.Symtab'. Symbol table and line data for a frame is returned from
|
| 4546 |
|
|
the `find_sal' method in `gdb.Frame' object. *Note Frames In Python::.
|
| 4547 |
|
|
|
| 4548 |
|
|
For more information on GDB's symbol table management, see *Note
|
| 4549 |
|
|
Examining the Symbol Table: Symbols, for more information.
|
| 4550 |
|
|
|
| 4551 |
|
|
A `gdb.Symtab_and_line' object has the following attributes:
|
| 4552 |
|
|
|
| 4553 |
|
|
-- Instance Variable of Symtab_and_line: symtab
|
| 4554 |
|
|
The symbol table object (`gdb.Symtab') for this frame. This
|
| 4555 |
|
|
attribute is not writable.
|
| 4556 |
|
|
|
| 4557 |
|
|
-- Instance Variable of Symtab_and_line: pc
|
| 4558 |
|
|
Indicates the current program counter address. This
|
| 4559 |
|
|
attribute is not writable.
|
| 4560 |
|
|
|
| 4561 |
|
|
-- Instance Variable of Symtab_and_line: line
|
| 4562 |
|
|
Indicates the current line number for this object. This
|
| 4563 |
|
|
attribute is not writable.
|
| 4564 |
|
|
|
| 4565 |
|
|
A `gdb.Symtab' object has the following attributes:
|
| 4566 |
|
|
|
| 4567 |
|
|
-- Instance Variable of Symtab: filename
|
| 4568 |
|
|
The symbol table's source filename. This attribute is not
|
| 4569 |
|
|
writable.
|
| 4570 |
|
|
|
| 4571 |
|
|
-- Instance Variable of Symtab: objfile
|
| 4572 |
|
|
The symbol table's backing object file. *Note Objfiles In
|
| 4573 |
|
|
Python::. This attribute is not writable.
|
| 4574 |
|
|
|
| 4575 |
|
|
The following methods are provided:
|
| 4576 |
|
|
|
| 4577 |
|
|
-- Method on Symtab: fullname
|
| 4578 |
|
|
Return the symbol table's source absolute file name.
|
| 4579 |
|
|
|
| 4580 |
|
|
|
| 4581 |
|
|
File: gdb.info, Node: Breakpoints In Python, Prev: Lazy Strings In Python, Up: Python API
|
| 4582 |
|
|
|
| 4583 |
|
|
23.2.2.19 Manipulating breakpoints using Python
|
| 4584 |
|
|
...............................................
|
| 4585 |
|
|
|
| 4586 |
|
|
Python code can manipulate breakpoints via the `gdb.Breakpoint' class.
|
| 4587 |
|
|
|
| 4588 |
|
|
-- Method on Breakpoint: __init__ spec [type] [wp_class]
|
| 4589 |
|
|
Create a new breakpoint. SPEC is a string naming the location of
|
| 4590 |
|
|
the breakpoint, or an expression that defines a watchpoint. The
|
| 4591 |
|
|
contents can be any location recognized by the `break' command, or
|
| 4592 |
|
|
in the case of a watchpoint, by the `watch' command. The optional
|
| 4593 |
|
|
TYPE denotes the breakpoint to create from the types defined later
|
| 4594 |
|
|
in this chapter. This argument can be either: `BP_BREAKPOINT' or
|
| 4595 |
|
|
`BP_WATCHPOINT'. TYPE defaults to `BP_BREAKPOINT'. The optional
|
| 4596 |
|
|
WP_CLASS argument defines the class of watchpoint to create, if
|
| 4597 |
|
|
TYPE is defined as `BP_WATCHPOINT'. If a watchpoint class is not
|
| 4598 |
|
|
provided, it is assumed to be a WP_WRITE class.
|
| 4599 |
|
|
|
| 4600 |
|
|
The available watchpoint types represented by constants are defined
|
| 4601 |
|
|
in the `gdb' module:
|
| 4602 |
|
|
|
| 4603 |
|
|
`WP_READ'
|
| 4604 |
|
|
Read only watchpoint.
|
| 4605 |
|
|
|
| 4606 |
|
|
`WP_WRITE'
|
| 4607 |
|
|
Write only watchpoint.
|
| 4608 |
|
|
|
| 4609 |
|
|
`WP_ACCESS'
|
| 4610 |
|
|
Read/Write watchpoint.
|
| 4611 |
|
|
|
| 4612 |
|
|
-- Method on Breakpoint: is_valid
|
| 4613 |
|
|
Return `True' if this `Breakpoint' object is valid, `False'
|
| 4614 |
|
|
otherwise. A `Breakpoint' object can become invalid if the user
|
| 4615 |
|
|
deletes the breakpoint. In this case, the object still exists,
|
| 4616 |
|
|
but the underlying breakpoint does not. In the cases of
|
| 4617 |
|
|
watchpoint scope, the watchpoint remains valid even if execution
|
| 4618 |
|
|
of the inferior leaves the scope of that watchpoint.
|
| 4619 |
|
|
|
| 4620 |
|
|
-- Instance Variable of Breakpoint: enabled
|
| 4621 |
|
|
This attribute is `True' if the breakpoint is enabled, and `False'
|
| 4622 |
|
|
otherwise. This attribute is writable.
|
| 4623 |
|
|
|
| 4624 |
|
|
-- Instance Variable of Breakpoint: silent
|
| 4625 |
|
|
This attribute is `True' if the breakpoint is silent, and `False'
|
| 4626 |
|
|
otherwise. This attribute is writable.
|
| 4627 |
|
|
|
| 4628 |
|
|
Note that a breakpoint can also be silent if it has commands and
|
| 4629 |
|
|
the first command is `silent'. This is not reported by the
|
| 4630 |
|
|
`silent' attribute.
|
| 4631 |
|
|
|
| 4632 |
|
|
-- Instance Variable of Breakpoint: thread
|
| 4633 |
|
|
If the breakpoint is thread-specific, this attribute holds the
|
| 4634 |
|
|
thread id. If the breakpoint is not thread-specific, this
|
| 4635 |
|
|
attribute is `None'. This attribute is writable.
|
| 4636 |
|
|
|
| 4637 |
|
|
-- Instance Variable of Breakpoint: task
|
| 4638 |
|
|
If the breakpoint is Ada task-specific, this attribute holds the
|
| 4639 |
|
|
Ada task id. If the breakpoint is not task-specific (or the
|
| 4640 |
|
|
underlying language is not Ada), this attribute is `None'. This
|
| 4641 |
|
|
attribute is writable.
|
| 4642 |
|
|
|
| 4643 |
|
|
-- Instance Variable of Breakpoint: ignore_count
|
| 4644 |
|
|
This attribute holds the ignore count for the breakpoint, an
|
| 4645 |
|
|
integer. This attribute is writable.
|
| 4646 |
|
|
|
| 4647 |
|
|
-- Instance Variable of Breakpoint: number
|
| 4648 |
|
|
This attribute holds the breakpoint's number -- the identifier
|
| 4649 |
|
|
used by the user to manipulate the breakpoint. This attribute is
|
| 4650 |
|
|
not writable.
|
| 4651 |
|
|
|
| 4652 |
|
|
-- Instance Variable of Breakpoint: type
|
| 4653 |
|
|
This attribute holds the breakpoint's type -- the identifier used
|
| 4654 |
|
|
to determine the actual breakpoint type or use-case. This
|
| 4655 |
|
|
attribute is not writable.
|
| 4656 |
|
|
|
| 4657 |
|
|
The available types are represented by constants defined in the `gdb'
|
| 4658 |
|
|
module:
|
| 4659 |
|
|
|
| 4660 |
|
|
`BP_BREAKPOINT'
|
| 4661 |
|
|
Normal code breakpoint.
|
| 4662 |
|
|
|
| 4663 |
|
|
`BP_WATCHPOINT'
|
| 4664 |
|
|
Watchpoint breakpoint.
|
| 4665 |
|
|
|
| 4666 |
|
|
`BP_HARDWARE_WATCHPOINT'
|
| 4667 |
|
|
Hardware assisted watchpoint.
|
| 4668 |
|
|
|
| 4669 |
|
|
`BP_READ_WATCHPOINT'
|
| 4670 |
|
|
Hardware assisted read watchpoint.
|
| 4671 |
|
|
|
| 4672 |
|
|
`BP_ACCESS_WATCHPOINT'
|
| 4673 |
|
|
Hardware assisted access watchpoint.
|
| 4674 |
|
|
|
| 4675 |
|
|
-- Instance Variable of Breakpoint: hit_count
|
| 4676 |
|
|
This attribute holds the hit count for the breakpoint, an integer.
|
| 4677 |
|
|
This attribute is writable, but currently it can only be set to
|
| 4678 |
|
|
zero.
|
| 4679 |
|
|
|
| 4680 |
|
|
-- Instance Variable of Breakpoint: location
|
| 4681 |
|
|
This attribute holds the location of the breakpoint, as specified
|
| 4682 |
|
|
by the user. It is a string. If the breakpoint does not have a
|
| 4683 |
|
|
location (that is, it is a watchpoint) the attribute's value is
|
| 4684 |
|
|
`None'. This attribute is not writable.
|
| 4685 |
|
|
|
| 4686 |
|
|
-- Instance Variable of Breakpoint: expression
|
| 4687 |
|
|
This attribute holds a breakpoint expression, as specified by the
|
| 4688 |
|
|
user. It is a string. If the breakpoint does not have an
|
| 4689 |
|
|
expression (the breakpoint is not a watchpoint) the attribute's
|
| 4690 |
|
|
value is `None'. This attribute is not writable.
|
| 4691 |
|
|
|
| 4692 |
|
|
-- Instance Variable of Breakpoint: condition
|
| 4693 |
|
|
This attribute holds the condition of the breakpoint, as specified
|
| 4694 |
|
|
by the user. It is a string. If there is no condition, this
|
| 4695 |
|
|
attribute's value is `None'. This attribute is writable.
|
| 4696 |
|
|
|
| 4697 |
|
|
-- Instance Variable of Breakpoint: commands
|
| 4698 |
|
|
This attribute holds the commands attached to the breakpoint. If
|
| 4699 |
|
|
there are commands, this attribute's value is a string holding all
|
| 4700 |
|
|
the commands, separated by newlines. If there are no commands,
|
| 4701 |
|
|
this attribute is `None'. This attribute is not writable.
|
| 4702 |
|
|
|
| 4703 |
|
|
|
| 4704 |
|
|
File: gdb.info, Node: Lazy Strings In Python, Next: Breakpoints In Python, Prev: Symbol Tables In Python, Up: Python API
|
| 4705 |
|
|
|
| 4706 |
|
|
23.2.2.20 Python representation of lazy strings.
|
| 4707 |
|
|
................................................
|
| 4708 |
|
|
|
| 4709 |
|
|
A "lazy string" is a string whose contents is not retrieved or encoded
|
| 4710 |
|
|
until it is needed.
|
| 4711 |
|
|
|
| 4712 |
|
|
A `gdb.LazyString' is represented in GDB as an `address' that points
|
| 4713 |
|
|
to a region of memory, an `encoding' that will be used to encode that
|
| 4714 |
|
|
region of memory, and a `length' to delimit the region of memory that
|
| 4715 |
|
|
represents the string. The difference between a `gdb.LazyString' and a
|
| 4716 |
|
|
string wrapped within a `gdb.Value' is that a `gdb.LazyString' will be
|
| 4717 |
|
|
treated differently by GDB when printing. A `gdb.LazyString' is
|
| 4718 |
|
|
retrieved and encoded during printing, while a `gdb.Value' wrapping a
|
| 4719 |
|
|
string is immediately retrieved and encoded on creation.
|
| 4720 |
|
|
|
| 4721 |
|
|
A `gdb.LazyString' object has the following functions:
|
| 4722 |
|
|
|
| 4723 |
|
|
-- Method on LazyString: value
|
| 4724 |
|
|
Convert the `gdb.LazyString' to a `gdb.Value'. This value will
|
| 4725 |
|
|
point to the string in memory, but will lose all the delayed
|
| 4726 |
|
|
retrieval, encoding and handling that GDB applies to a
|
| 4727 |
|
|
`gdb.LazyString'.
|
| 4728 |
|
|
|
| 4729 |
|
|
-- Instance Variable of LazyString: address
|
| 4730 |
|
|
This attribute holds the address of the string. This attribute is
|
| 4731 |
|
|
not writable.
|
| 4732 |
|
|
|
| 4733 |
|
|
-- Instance Variable of LazyString: length
|
| 4734 |
|
|
This attribute holds the length of the string in characters. If
|
| 4735 |
|
|
the length is -1, then the string will be fetched and encoded up
|
| 4736 |
|
|
to the first null of appropriate width. This attribute is not
|
| 4737 |
|
|
writable.
|
| 4738 |
|
|
|
| 4739 |
|
|
-- Instance Variable of LazyString: encoding
|
| 4740 |
|
|
This attribute holds the encoding that will be applied to the
|
| 4741 |
|
|
string when the string is printed by GDB. If the encoding is not
|
| 4742 |
|
|
set, or contains an empty string, then GDB will select the most
|
| 4743 |
|
|
appropriate encoding when the string is printed. This attribute
|
| 4744 |
|
|
is not writable.
|
| 4745 |
|
|
|
| 4746 |
|
|
-- Instance Variable of LazyString: type
|
| 4747 |
|
|
This attribute holds the type that is represented by the lazy
|
| 4748 |
|
|
string's type. For a lazy string this will always be a pointer
|
| 4749 |
|
|
type. To resolve this to the lazy string's character type, use
|
| 4750 |
|
|
the type's `target' method. *Note Types In Python::. This
|
| 4751 |
|
|
attribute is not writable.
|
| 4752 |
|
|
|
| 4753 |
|
|
|
| 4754 |
|
|
File: gdb.info, Node: Auto-loading, Prev: Python API, Up: Python
|
| 4755 |
|
|
|
| 4756 |
|
|
23.2.3 Auto-loading
|
| 4757 |
|
|
-------------------
|
| 4758 |
|
|
|
| 4759 |
|
|
When a new object file is read (for example, due to the `file' command,
|
| 4760 |
|
|
or because the inferior has loaded a shared library), GDB will look for
|
| 4761 |
|
|
Python support scripts in several ways: `OBJFILE-gdb.py' and
|
| 4762 |
|
|
`.debug_gdb_scripts' section.
|
| 4763 |
|
|
|
| 4764 |
|
|
* Menu:
|
| 4765 |
|
|
|
| 4766 |
|
|
* objfile-gdb.py file:: The `OBJFILE-gdb.py' file
|
| 4767 |
|
|
* .debug_gdb_scripts section:: The `.debug_gdb_scripts' section
|
| 4768 |
|
|
* Which flavor to choose?::
|
| 4769 |
|
|
|
| 4770 |
|
|
The auto-loading feature is useful for supplying application-specific
|
| 4771 |
|
|
debugging commands and scripts.
|
| 4772 |
|
|
|
| 4773 |
|
|
Auto-loading can be enabled or disabled.
|
| 4774 |
|
|
|
| 4775 |
|
|
`maint set python auto-load [yes|no]'
|
| 4776 |
|
|
Enable or disable the Python auto-loading feature.
|
| 4777 |
|
|
|
| 4778 |
|
|
`maint show python auto-load'
|
| 4779 |
|
|
Show whether Python auto-loading is enabled or disabled.
|
| 4780 |
|
|
|
| 4781 |
|
|
When reading an auto-loaded file, GDB sets the "current objfile".
|
| 4782 |
|
|
This is available via the `gdb.current_objfile' function (*note
|
| 4783 |
|
|
Objfiles In Python::). This can be useful for registering
|
| 4784 |
|
|
objfile-specific pretty-printers.
|
| 4785 |
|
|
|
| 4786 |
|
|
|
| 4787 |
|
|
File: gdb.info, Node: objfile-gdb.py file, Next: .debug_gdb_scripts section, Up: Auto-loading
|
| 4788 |
|
|
|
| 4789 |
|
|
23.2.3.1 The `OBJFILE-gdb.py' file
|
| 4790 |
|
|
..................................
|
| 4791 |
|
|
|
| 4792 |
|
|
When a new object file is read, GDB looks for a file named
|
| 4793 |
|
|
`OBJFILE-gdb.py', where OBJFILE is the object file's real name, formed
|
| 4794 |
|
|
by ensuring that the file name is absolute, following all symlinks, and
|
| 4795 |
|
|
resolving `.' and `..' components. If this file exists and is
|
| 4796 |
|
|
readable, GDB will evaluate it as a Python script.
|
| 4797 |
|
|
|
| 4798 |
|
|
If this file does not exist, and if the parameter
|
| 4799 |
|
|
`debug-file-directory' is set (*note Separate Debug Files::), then GDB
|
| 4800 |
|
|
will look for REAL-NAME in all of the directories mentioned in the
|
| 4801 |
|
|
value of `debug-file-directory'.
|
| 4802 |
|
|
|
| 4803 |
|
|
Finally, if this file does not exist, then GDB will look for a file
|
| 4804 |
|
|
named `DATA-DIRECTORY/python/auto-load/REAL-NAME', where DATA-DIRECTORY
|
| 4805 |
|
|
is GDB's data directory (available via `show data-directory', *note
|
| 4806 |
|
|
Data Files::), and REAL-NAME is the object file's real name, as
|
| 4807 |
|
|
described above.
|
| 4808 |
|
|
|
| 4809 |
|
|
GDB does not track which files it has already auto-loaded this way.
|
| 4810 |
|
|
GDB will load the associated script every time the corresponding
|
| 4811 |
|
|
OBJFILE is opened. So your `-gdb.py' file should be careful to avoid
|
| 4812 |
|
|
errors if it is evaluated more than once.
|
| 4813 |
|
|
|
| 4814 |
|
|
|
| 4815 |
|
|
File: gdb.info, Node: .debug_gdb_scripts section, Next: Which flavor to choose?, Prev: objfile-gdb.py file, Up: Auto-loading
|
| 4816 |
|
|
|
| 4817 |
|
|
23.2.3.2 The `.debug_gdb_scripts' section
|
| 4818 |
|
|
.........................................
|
| 4819 |
|
|
|
| 4820 |
|
|
For systems using file formats like ELF and COFF, when GDB loads a new
|
| 4821 |
|
|
object file it will look for a special section named
|
| 4822 |
|
|
`.debug_gdb_scripts'. If this section exists, its contents is a list
|
| 4823 |
|
|
of names of scripts to load.
|
| 4824 |
|
|
|
| 4825 |
|
|
GDB will look for each specified script file first in the current
|
| 4826 |
|
|
directory and then along the source search path (*note Specifying
|
| 4827 |
|
|
Source Directories: Source Path.), except that `$cdir' is not searched,
|
| 4828 |
|
|
since the compilation directory is not relevant to scripts.
|
| 4829 |
|
|
|
| 4830 |
|
|
Entries can be placed in section `.debug_gdb_scripts' with, for
|
| 4831 |
|
|
example, this GCC macro:
|
| 4832 |
|
|
|
| 4833 |
|
|
/* Note: The "MS" section flags are to remove duplicates. */
|
| 4834 |
|
|
#define DEFINE_GDB_SCRIPT(script_name) \
|
| 4835 |
|
|
asm("\
|
| 4836 |
|
|
.pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\
|
| 4837 |
|
|
.byte 1\n\
|
| 4838 |
|
|
.asciz \"" script_name "\"\n\
|
| 4839 |
|
|
.popsection \n\
|
| 4840 |
|
|
");
|
| 4841 |
|
|
|
| 4842 |
|
|
Then one can reference the macro in a header or source file like this:
|
| 4843 |
|
|
|
| 4844 |
|
|
DEFINE_GDB_SCRIPT ("my-app-scripts.py")
|
| 4845 |
|
|
|
| 4846 |
|
|
The script name may include directories if desired.
|
| 4847 |
|
|
|
| 4848 |
|
|
If the macro is put in a header, any application or library using
|
| 4849 |
|
|
this header will get a reference to the specified script.
|
| 4850 |
|
|
|
| 4851 |
|
|
|
| 4852 |
|
|
File: gdb.info, Node: Which flavor to choose?, Prev: .debug_gdb_scripts section, Up: Auto-loading
|
| 4853 |
|
|
|
| 4854 |
|
|
23.2.3.3 Which flavor to choose?
|
| 4855 |
|
|
................................
|
| 4856 |
|
|
|
| 4857 |
|
|
Given the multiple ways of auto-loading Python scripts, it might not
|
| 4858 |
|
|
always be clear which one to choose. This section provides some
|
| 4859 |
|
|
guidance.
|
| 4860 |
|
|
|
| 4861 |
|
|
Benefits of the `-gdb.py' way:
|
| 4862 |
|
|
|
| 4863 |
|
|
* Can be used with file formats that don't support multiple sections.
|
| 4864 |
|
|
|
| 4865 |
|
|
* Ease of finding scripts for public libraries.
|
| 4866 |
|
|
|
| 4867 |
|
|
Scripts specified in the `.debug_gdb_scripts' section are searched
|
| 4868 |
|
|
for in the source search path. For publicly installed libraries,
|
| 4869 |
|
|
e.g., `libstdc++', there typically isn't a source directory in
|
| 4870 |
|
|
which to find the script.
|
| 4871 |
|
|
|
| 4872 |
|
|
* Doesn't require source code additions.
|
| 4873 |
|
|
|
| 4874 |
|
|
Benefits of the `.debug_gdb_scripts' way:
|
| 4875 |
|
|
|
| 4876 |
|
|
* Works with static linking.
|
| 4877 |
|
|
|
| 4878 |
|
|
Scripts for libraries done the `-gdb.py' way require an objfile to
|
| 4879 |
|
|
trigger their loading. When an application is statically linked
|
| 4880 |
|
|
the only objfile available is the executable, and it is cumbersome
|
| 4881 |
|
|
to attach all the scripts from all the input libraries to the
|
| 4882 |
|
|
executable's `-gdb.py' script.
|
| 4883 |
|
|
|
| 4884 |
|
|
* Works with classes that are entirely inlined.
|
| 4885 |
|
|
|
| 4886 |
|
|
Some classes can be entirely inlined, and thus there may not be an
|
| 4887 |
|
|
associated shared library to attach a `-gdb.py' script to.
|
| 4888 |
|
|
|
| 4889 |
|
|
* Scripts needn't be copied out of the source tree.
|
| 4890 |
|
|
|
| 4891 |
|
|
In some circumstances, apps can be built out of large collections
|
| 4892 |
|
|
of internal libraries, and the build infrastructure necessary to
|
| 4893 |
|
|
install the `-gdb.py' scripts in a place where GDB can find them is
|
| 4894 |
|
|
cumbersome. It may be easier to specify the scripts in the
|
| 4895 |
|
|
`.debug_gdb_scripts' section as relative paths, and add a path to
|
| 4896 |
|
|
the top of the source tree to the source search path.
|
| 4897 |
|
|
|
| 4898 |
|
|
|
| 4899 |
|
|
File: gdb.info, Node: Interpreters, Next: TUI, Prev: Extending GDB, Up: Top
|
| 4900 |
|
|
|
| 4901 |
|
|
24 Command Interpreters
|
| 4902 |
|
|
***********************
|
| 4903 |
|
|
|
| 4904 |
|
|
GDB supports multiple command interpreters, and some command
|
| 4905 |
|
|
infrastructure to allow users or user interface writers to switch
|
| 4906 |
|
|
between interpreters or run commands in other interpreters.
|
| 4907 |
|
|
|
| 4908 |
|
|
GDB currently supports two command interpreters, the console
|
| 4909 |
|
|
interpreter (sometimes called the command-line interpreter or CLI) and
|
| 4910 |
|
|
the machine interface interpreter (or GDB/MI). This manual describes
|
| 4911 |
|
|
both of these interfaces in great detail.
|
| 4912 |
|
|
|
| 4913 |
|
|
By default, GDB will start with the console interpreter. However,
|
| 4914 |
|
|
the user may choose to start GDB with another interpreter by specifying
|
| 4915 |
|
|
the `-i' or `--interpreter' startup options. Defined interpreters
|
| 4916 |
|
|
include:
|
| 4917 |
|
|
|
| 4918 |
|
|
`console'
|
| 4919 |
|
|
The traditional console or command-line interpreter. This is the
|
| 4920 |
|
|
most often used interpreter with GDB. With no interpreter
|
| 4921 |
|
|
specified at runtime, GDB will use this interpreter.
|
| 4922 |
|
|
|
| 4923 |
|
|
`mi'
|
| 4924 |
|
|
The newest GDB/MI interface (currently `mi2'). Used primarily by
|
| 4925 |
|
|
programs wishing to use GDB as a backend for a debugger GUI or an
|
| 4926 |
|
|
IDE. For more information, see *Note The GDB/MI Interface: GDB/MI.
|
| 4927 |
|
|
|
| 4928 |
|
|
`mi2'
|
| 4929 |
|
|
The current GDB/MI interface.
|
| 4930 |
|
|
|
| 4931 |
|
|
`mi1'
|
| 4932 |
|
|
The GDB/MI interface included in GDB 5.1, 5.2, and 5.3.
|
| 4933 |
|
|
|
| 4934 |
|
|
|
| 4935 |
|
|
The interpreter being used by GDB may not be dynamically switched at
|
| 4936 |
|
|
runtime. Although possible, this could lead to a very precarious
|
| 4937 |
|
|
situation. Consider an IDE using GDB/MI. If a user enters the command
|
| 4938 |
|
|
"interpreter-set console" in a console view, GDB would switch to using
|
| 4939 |
|
|
the console interpreter, rendering the IDE inoperable!
|
| 4940 |
|
|
|
| 4941 |
|
|
Although you may only choose a single interpreter at startup, you
|
| 4942 |
|
|
may execute commands in any interpreter from the current interpreter
|
| 4943 |
|
|
using the appropriate command. If you are running the console
|
| 4944 |
|
|
interpreter, simply use the `interpreter-exec' command:
|
| 4945 |
|
|
|
| 4946 |
|
|
interpreter-exec mi "-data-list-register-names"
|
| 4947 |
|
|
|
| 4948 |
|
|
GDB/MI has a similar command, although it is only available in
|
| 4949 |
|
|
versions of GDB which support GDB/MI version 2 (or greater).
|
| 4950 |
|
|
|
| 4951 |
|
|
|
| 4952 |
|
|
File: gdb.info, Node: TUI, Next: Emacs, Prev: Interpreters, Up: Top
|
| 4953 |
|
|
|
| 4954 |
|
|
25 GDB Text User Interface
|
| 4955 |
|
|
**************************
|
| 4956 |
|
|
|
| 4957 |
|
|
* Menu:
|
| 4958 |
|
|
|
| 4959 |
|
|
* TUI Overview:: TUI overview
|
| 4960 |
|
|
* TUI Keys:: TUI key bindings
|
| 4961 |
|
|
* TUI Single Key Mode:: TUI single key mode
|
| 4962 |
|
|
* TUI Commands:: TUI-specific commands
|
| 4963 |
|
|
* TUI Configuration:: TUI configuration variables
|
| 4964 |
|
|
|
| 4965 |
|
|
The GDB Text User Interface (TUI) is a terminal interface which uses
|
| 4966 |
|
|
the `curses' library to show the source file, the assembly output, the
|
| 4967 |
|
|
program registers and GDB commands in separate text windows. The TUI
|
| 4968 |
|
|
mode is supported only on platforms where a suitable version of the
|
| 4969 |
|
|
`curses' library is available.
|
| 4970 |
|
|
|
| 4971 |
|
|
The TUI mode is enabled by default when you invoke GDB as either
|
| 4972 |
|
|
`gdbtui' or `gdb -tui'. You can also switch in and out of TUI mode
|
| 4973 |
|
|
while GDB runs by using various TUI commands and key bindings, such as
|
| 4974 |
|
|
`C-x C-a'. *Note TUI Key Bindings: TUI Keys.
|
| 4975 |
|
|
|
| 4976 |
|
|
|
| 4977 |
|
|
File: gdb.info, Node: TUI Overview, Next: TUI Keys, Up: TUI
|
| 4978 |
|
|
|
| 4979 |
|
|
25.1 TUI Overview
|
| 4980 |
|
|
=================
|
| 4981 |
|
|
|
| 4982 |
|
|
In TUI mode, GDB can display several text windows:
|
| 4983 |
|
|
|
| 4984 |
|
|
_command_
|
| 4985 |
|
|
This window is the GDB command window with the GDB prompt and the
|
| 4986 |
|
|
GDB output. The GDB input is still managed using readline.
|
| 4987 |
|
|
|
| 4988 |
|
|
_source_
|
| 4989 |
|
|
The source window shows the source file of the program. The
|
| 4990 |
|
|
current line and active breakpoints are displayed in this window.
|
| 4991 |
|
|
|
| 4992 |
|
|
_assembly_
|
| 4993 |
|
|
The assembly window shows the disassembly output of the program.
|
| 4994 |
|
|
|
| 4995 |
|
|
_register_
|
| 4996 |
|
|
This window shows the processor registers. Registers are
|
| 4997 |
|
|
highlighted when their values change.
|
| 4998 |
|
|
|
| 4999 |
|
|
The source and assembly windows show the current program position by
|
| 5000 |
|
|
highlighting the current line and marking it with a `>' marker.
|
| 5001 |
|
|
Breakpoints are indicated with two markers. The first marker indicates
|
| 5002 |
|
|
the breakpoint type:
|
| 5003 |
|
|
|
| 5004 |
|
|
`B'
|
| 5005 |
|
|
Breakpoint which was hit at least once.
|
| 5006 |
|
|
|
| 5007 |
|
|
`b'
|
| 5008 |
|
|
Breakpoint which was never hit.
|
| 5009 |
|
|
|
| 5010 |
|
|
`H'
|
| 5011 |
|
|
Hardware breakpoint which was hit at least once.
|
| 5012 |
|
|
|
| 5013 |
|
|
`h'
|
| 5014 |
|
|
Hardware breakpoint which was never hit.
|
| 5015 |
|
|
|
| 5016 |
|
|
The second marker indicates whether the breakpoint is enabled or not:
|
| 5017 |
|
|
|
| 5018 |
|
|
`+'
|
| 5019 |
|
|
Breakpoint is enabled.
|
| 5020 |
|
|
|
| 5021 |
|
|
`-'
|
| 5022 |
|
|
Breakpoint is disabled.
|
| 5023 |
|
|
|
| 5024 |
|
|
The source, assembly and register windows are updated when the
|
| 5025 |
|
|
current thread changes, when the frame changes, or when the program
|
| 5026 |
|
|
counter changes.
|
| 5027 |
|
|
|
| 5028 |
|
|
These windows are not all visible at the same time. The command
|
| 5029 |
|
|
window is always visible. The others can be arranged in several
|
| 5030 |
|
|
layouts:
|
| 5031 |
|
|
|
| 5032 |
|
|
* source only,
|
| 5033 |
|
|
|
| 5034 |
|
|
* assembly only,
|
| 5035 |
|
|
|
| 5036 |
|
|
* source and assembly,
|
| 5037 |
|
|
|
| 5038 |
|
|
* source and registers, or
|
| 5039 |
|
|
|
| 5040 |
|
|
* assembly and registers.
|
| 5041 |
|
|
|
| 5042 |
|
|
A status line above the command window shows the following
|
| 5043 |
|
|
information:
|
| 5044 |
|
|
|
| 5045 |
|
|
_target_
|
| 5046 |
|
|
Indicates the current GDB target. (*note Specifying a Debugging
|
| 5047 |
|
|
Target: Targets.).
|
| 5048 |
|
|
|
| 5049 |
|
|
_process_
|
| 5050 |
|
|
Gives the current process or thread number. When no process is
|
| 5051 |
|
|
being debugged, this field is set to `No process'.
|
| 5052 |
|
|
|
| 5053 |
|
|
_function_
|
| 5054 |
|
|
Gives the current function name for the selected frame. The name
|
| 5055 |
|
|
is demangled if demangling is turned on (*note Print Settings::).
|
| 5056 |
|
|
When there is no symbol corresponding to the current program
|
| 5057 |
|
|
counter, the string `??' is displayed.
|
| 5058 |
|
|
|
| 5059 |
|
|
_line_
|
| 5060 |
|
|
Indicates the current line number for the selected frame. When
|
| 5061 |
|
|
the current line number is not known, the string `??' is displayed.
|
| 5062 |
|
|
|
| 5063 |
|
|
_pc_
|
| 5064 |
|
|
Indicates the current program counter address.
|
| 5065 |
|
|
|
| 5066 |
|
|
|
| 5067 |
|
|
File: gdb.info, Node: TUI Keys, Next: TUI Single Key Mode, Prev: TUI Overview, Up: TUI
|
| 5068 |
|
|
|
| 5069 |
|
|
25.2 TUI Key Bindings
|
| 5070 |
|
|
=====================
|
| 5071 |
|
|
|
| 5072 |
|
|
The TUI installs several key bindings in the readline keymaps (*note
|
| 5073 |
|
|
Command Line Editing::). The following key bindings are installed for
|
| 5074 |
|
|
both TUI mode and the GDB standard mode.
|
| 5075 |
|
|
|
| 5076 |
|
|
`C-x C-a'
|
| 5077 |
|
|
`C-x a'
|
| 5078 |
|
|
`C-x A'
|
| 5079 |
|
|
Enter or leave the TUI mode. When leaving the TUI mode, the
|
| 5080 |
|
|
curses window management stops and GDB operates using its standard
|
| 5081 |
|
|
mode, writing on the terminal directly. When reentering the TUI
|
| 5082 |
|
|
mode, control is given back to the curses windows. The screen is
|
| 5083 |
|
|
then refreshed.
|
| 5084 |
|
|
|
| 5085 |
|
|
`C-x 1'
|
| 5086 |
|
|
Use a TUI layout with only one window. The layout will either be
|
| 5087 |
|
|
`source' or `assembly'. When the TUI mode is not active, it will
|
| 5088 |
|
|
switch to the TUI mode.
|
| 5089 |
|
|
|
| 5090 |
|
|
Think of this key binding as the Emacs `C-x 1' binding.
|
| 5091 |
|
|
|
| 5092 |
|
|
`C-x 2'
|
| 5093 |
|
|
Use a TUI layout with at least two windows. When the current
|
| 5094 |
|
|
layout already has two windows, the next layout with two windows
|
| 5095 |
|
|
is used. When a new layout is chosen, one window will always be
|
| 5096 |
|
|
common to the previous layout and the new one.
|
| 5097 |
|
|
|
| 5098 |
|
|
Think of it as the Emacs `C-x 2' binding.
|
| 5099 |
|
|
|
| 5100 |
|
|
`C-x o'
|
| 5101 |
|
|
Change the active window. The TUI associates several key bindings
|
| 5102 |
|
|
(like scrolling and arrow keys) with the active window. This
|
| 5103 |
|
|
command gives the focus to the next TUI window.
|
| 5104 |
|
|
|
| 5105 |
|
|
Think of it as the Emacs `C-x o' binding.
|
| 5106 |
|
|
|
| 5107 |
|
|
`C-x s'
|
| 5108 |
|
|
Switch in and out of the TUI SingleKey mode that binds single keys
|
| 5109 |
|
|
to GDB commands (*note TUI Single Key Mode::).
|
| 5110 |
|
|
|
| 5111 |
|
|
The following key bindings only work in the TUI mode:
|
| 5112 |
|
|
|
| 5113 |
|
|
|
| 5114 |
|
|
Scroll the active window one page up.
|
| 5115 |
|
|
|
| 5116 |
|
|
|
| 5117 |
|
|
Scroll the active window one page down.
|
| 5118 |
|
|
|
| 5119 |
|
|
|
| 5120 |
|
|
Scroll the active window one line up.
|
| 5121 |
|
|
|
| 5122 |
|
|
|
| 5123 |
|
|
Scroll the active window one line down.
|
| 5124 |
|
|
|
| 5125 |
|
|
|
| 5126 |
|
|
Scroll the active window one column left.
|
| 5127 |
|
|
|
| 5128 |
|
|
|
| 5129 |
|
|
Scroll the active window one column right.
|
| 5130 |
|
|
|
| 5131 |
|
|
`C-L'
|
| 5132 |
|
|
Refresh the screen.
|
| 5133 |
|
|
|
| 5134 |
|
|
Because the arrow keys scroll the active window in the TUI mode, they
|
| 5135 |
|
|
are not available for their normal use by readline unless the command
|
| 5136 |
|
|
window has the focus. When another window is active, you must use
|
| 5137 |
|
|
other readline key bindings such as `C-p', `C-n', `C-b' and `C-f' to
|
| 5138 |
|
|
control the command window.
|
| 5139 |
|
|
|
| 5140 |
|
|
|
| 5141 |
|
|
File: gdb.info, Node: TUI Single Key Mode, Next: TUI Commands, Prev: TUI Keys, Up: TUI
|
| 5142 |
|
|
|
| 5143 |
|
|
25.3 TUI Single Key Mode
|
| 5144 |
|
|
========================
|
| 5145 |
|
|
|
| 5146 |
|
|
The TUI also provides a "SingleKey" mode, which binds several
|
| 5147 |
|
|
frequently used GDB commands to single keys. Type `C-x s' to switch
|
| 5148 |
|
|
into this mode, where the following key bindings are used:
|
| 5149 |
|
|
|
| 5150 |
|
|
`c'
|
| 5151 |
|
|
continue
|
| 5152 |
|
|
|
| 5153 |
|
|
`d'
|
| 5154 |
|
|
down
|
| 5155 |
|
|
|
| 5156 |
|
|
`f'
|
| 5157 |
|
|
finish
|
| 5158 |
|
|
|
| 5159 |
|
|
`n'
|
| 5160 |
|
|
next
|
| 5161 |
|
|
|
| 5162 |
|
|
`q'
|
| 5163 |
|
|
exit the SingleKey mode.
|
| 5164 |
|
|
|
| 5165 |
|
|
`r'
|
| 5166 |
|
|
run
|
| 5167 |
|
|
|
| 5168 |
|
|
`s'
|
| 5169 |
|
|
step
|
| 5170 |
|
|
|
| 5171 |
|
|
`u'
|
| 5172 |
|
|
up
|
| 5173 |
|
|
|
| 5174 |
|
|
`v'
|
| 5175 |
|
|
info locals
|
| 5176 |
|
|
|
| 5177 |
|
|
`w'
|
| 5178 |
|
|
where
|
| 5179 |
|
|
|
| 5180 |
|
|
Other keys temporarily switch to the GDB command prompt. The key
|
| 5181 |
|
|
that was pressed is inserted in the editing buffer so that it is
|
| 5182 |
|
|
possible to type most GDB commands without interaction with the TUI
|
| 5183 |
|
|
SingleKey mode. Once the command is entered the TUI SingleKey mode is
|
| 5184 |
|
|
restored. The only way to permanently leave this mode is by typing `q'
|
| 5185 |
|
|
or `C-x s'.
|
| 5186 |
|
|
|
| 5187 |
|
|
|
| 5188 |
|
|
File: gdb.info, Node: TUI Commands, Next: TUI Configuration, Prev: TUI Single Key Mode, Up: TUI
|
| 5189 |
|
|
|
| 5190 |
|
|
25.4 TUI-specific Commands
|
| 5191 |
|
|
==========================
|
| 5192 |
|
|
|
| 5193 |
|
|
The TUI has specific commands to control the text windows. These
|
| 5194 |
|
|
commands are always available, even when GDB is not in the TUI mode.
|
| 5195 |
|
|
When GDB is in the standard mode, most of these commands will
|
| 5196 |
|
|
automatically switch to the TUI mode.
|
| 5197 |
|
|
|
| 5198 |
|
|
Note that if GDB's `stdout' is not connected to a terminal, or GDB
|
| 5199 |
|
|
has been started with the machine interface interpreter (*note The
|
| 5200 |
|
|
GDB/MI Interface: GDB/MI.), most of these commands will fail with an
|
| 5201 |
|
|
error, because it would not be possible or desirable to enable curses
|
| 5202 |
|
|
window management.
|
| 5203 |
|
|
|
| 5204 |
|
|
`info win'
|
| 5205 |
|
|
List and give the size of all displayed windows.
|
| 5206 |
|
|
|
| 5207 |
|
|
`layout next'
|
| 5208 |
|
|
Display the next layout.
|
| 5209 |
|
|
|
| 5210 |
|
|
`layout prev'
|
| 5211 |
|
|
Display the previous layout.
|
| 5212 |
|
|
|
| 5213 |
|
|
`layout src'
|
| 5214 |
|
|
Display the source window only.
|
| 5215 |
|
|
|
| 5216 |
|
|
`layout asm'
|
| 5217 |
|
|
Display the assembly window only.
|
| 5218 |
|
|
|
| 5219 |
|
|
`layout split'
|
| 5220 |
|
|
Display the source and assembly window.
|
| 5221 |
|
|
|
| 5222 |
|
|
`layout regs'
|
| 5223 |
|
|
Display the register window together with the source or assembly
|
| 5224 |
|
|
window.
|
| 5225 |
|
|
|
| 5226 |
|
|
`focus next'
|
| 5227 |
|
|
Make the next window active for scrolling.
|
| 5228 |
|
|
|
| 5229 |
|
|
`focus prev'
|
| 5230 |
|
|
Make the previous window active for scrolling.
|
| 5231 |
|
|
|
| 5232 |
|
|
`focus src'
|
| 5233 |
|
|
Make the source window active for scrolling.
|
| 5234 |
|
|
|
| 5235 |
|
|
`focus asm'
|
| 5236 |
|
|
Make the assembly window active for scrolling.
|
| 5237 |
|
|
|
| 5238 |
|
|
`focus regs'
|
| 5239 |
|
|
Make the register window active for scrolling.
|
| 5240 |
|
|
|
| 5241 |
|
|
`focus cmd'
|
| 5242 |
|
|
Make the command window active for scrolling.
|
| 5243 |
|
|
|
| 5244 |
|
|
`refresh'
|
| 5245 |
|
|
Refresh the screen. This is similar to typing `C-L'.
|
| 5246 |
|
|
|
| 5247 |
|
|
`tui reg float'
|
| 5248 |
|
|
Show the floating point registers in the register window.
|
| 5249 |
|
|
|
| 5250 |
|
|
`tui reg general'
|
| 5251 |
|
|
Show the general registers in the register window.
|
| 5252 |
|
|
|
| 5253 |
|
|
`tui reg next'
|
| 5254 |
|
|
Show the next register group. The list of register groups as well
|
| 5255 |
|
|
as their order is target specific. The predefined register groups
|
| 5256 |
|
|
are the following: `general', `float', `system', `vector', `all',
|
| 5257 |
|
|
`save', `restore'.
|
| 5258 |
|
|
|
| 5259 |
|
|
`tui reg system'
|
| 5260 |
|
|
Show the system registers in the register window.
|
| 5261 |
|
|
|
| 5262 |
|
|
`update'
|
| 5263 |
|
|
Update the source window and the current execution point.
|
| 5264 |
|
|
|
| 5265 |
|
|
`winheight NAME +COUNT'
|
| 5266 |
|
|
`winheight NAME -COUNT'
|
| 5267 |
|
|
Change the height of the window NAME by COUNT lines. Positive
|
| 5268 |
|
|
counts increase the height, while negative counts decrease it.
|
| 5269 |
|
|
|
| 5270 |
|
|
`tabset NCHARS'
|
| 5271 |
|
|
Set the width of tab stops to be NCHARS characters.
|
| 5272 |
|
|
|
| 5273 |
|
|
|
| 5274 |
|
|
File: gdb.info, Node: TUI Configuration, Prev: TUI Commands, Up: TUI
|
| 5275 |
|
|
|
| 5276 |
|
|
25.5 TUI Configuration Variables
|
| 5277 |
|
|
================================
|
| 5278 |
|
|
|
| 5279 |
|
|
Several configuration variables control the appearance of TUI windows.
|
| 5280 |
|
|
|
| 5281 |
|
|
`set tui border-kind KIND'
|
| 5282 |
|
|
Select the border appearance for the source, assembly and register
|
| 5283 |
|
|
windows. The possible values are the following:
|
| 5284 |
|
|
`space'
|
| 5285 |
|
|
Use a space character to draw the border.
|
| 5286 |
|
|
|
| 5287 |
|
|
`ascii'
|
| 5288 |
|
|
Use ASCII characters `+', `-' and `|' to draw the border.
|
| 5289 |
|
|
|
| 5290 |
|
|
`acs'
|
| 5291 |
|
|
Use the Alternate Character Set to draw the border. The
|
| 5292 |
|
|
border is drawn using character line graphics if the terminal
|
| 5293 |
|
|
supports them.
|
| 5294 |
|
|
|
| 5295 |
|
|
`set tui border-mode MODE'
|
| 5296 |
|
|
`set tui active-border-mode MODE'
|
| 5297 |
|
|
Select the display attributes for the borders of the inactive
|
| 5298 |
|
|
windows or the active window. The MODE can be one of the
|
| 5299 |
|
|
following:
|
| 5300 |
|
|
`normal'
|
| 5301 |
|
|
Use normal attributes to display the border.
|
| 5302 |
|
|
|
| 5303 |
|
|
`standout'
|
| 5304 |
|
|
Use standout mode.
|
| 5305 |
|
|
|
| 5306 |
|
|
`reverse'
|
| 5307 |
|
|
Use reverse video mode.
|
| 5308 |
|
|
|
| 5309 |
|
|
`half'
|
| 5310 |
|
|
Use half bright mode.
|
| 5311 |
|
|
|
| 5312 |
|
|
`half-standout'
|
| 5313 |
|
|
Use half bright and standout mode.
|
| 5314 |
|
|
|
| 5315 |
|
|
`bold'
|
| 5316 |
|
|
Use extra bright or bold mode.
|
| 5317 |
|
|
|
| 5318 |
|
|
`bold-standout'
|
| 5319 |
|
|
Use extra bright or bold and standout mode.
|
| 5320 |
|
|
|
| 5321 |
|
|
|
| 5322 |
|
|
File: gdb.info, Node: Emacs, Next: GDB/MI, Prev: TUI, Up: Top
|
| 5323 |
|
|
|
| 5324 |
|
|
26 Using GDB under GNU Emacs
|
| 5325 |
|
|
****************************
|
| 5326 |
|
|
|
| 5327 |
|
|
A special interface allows you to use GNU Emacs to view (and edit) the
|
| 5328 |
|
|
source files for the program you are debugging with GDB.
|
| 5329 |
|
|
|
| 5330 |
|
|
To use this interface, use the command `M-x gdb' in Emacs. Give the
|
| 5331 |
|
|
executable file you want to debug as an argument. This command starts
|
| 5332 |
|
|
GDB as a subprocess of Emacs, with input and output through a newly
|
| 5333 |
|
|
created Emacs buffer.
|
| 5334 |
|
|
|
| 5335 |
|
|
Running GDB under Emacs can be just like running GDB normally except
|
| 5336 |
|
|
for two things:
|
| 5337 |
|
|
|
| 5338 |
|
|
* All "terminal" input and output goes through an Emacs buffer,
|
| 5339 |
|
|
called the GUD buffer.
|
| 5340 |
|
|
|
| 5341 |
|
|
This applies both to GDB commands and their output, and to the
|
| 5342 |
|
|
input and output done by the program you are debugging.
|
| 5343 |
|
|
|
| 5344 |
|
|
This is useful because it means that you can copy the text of
|
| 5345 |
|
|
previous commands and input them again; you can even use parts of
|
| 5346 |
|
|
the output in this way.
|
| 5347 |
|
|
|
| 5348 |
|
|
All the facilities of Emacs' Shell mode are available for
|
| 5349 |
|
|
interacting with your program. In particular, you can send
|
| 5350 |
|
|
signals the usual way--for example, `C-c C-c' for an interrupt,
|
| 5351 |
|
|
`C-c C-z' for a stop.
|
| 5352 |
|
|
|
| 5353 |
|
|
* GDB displays source code through Emacs.
|
| 5354 |
|
|
|
| 5355 |
|
|
Each time GDB displays a stack frame, Emacs automatically finds the
|
| 5356 |
|
|
source file for that frame and puts an arrow (`=>') at the left
|
| 5357 |
|
|
margin of the current line. Emacs uses a separate buffer for
|
| 5358 |
|
|
source display, and splits the screen to show both your GDB session
|
| 5359 |
|
|
and the source.
|
| 5360 |
|
|
|
| 5361 |
|
|
Explicit GDB `list' or search commands still produce output as
|
| 5362 |
|
|
usual, but you probably have no reason to use them from Emacs.
|
| 5363 |
|
|
|
| 5364 |
|
|
We call this "text command mode". Emacs 22.1, and later, also uses
|
| 5365 |
|
|
a graphical mode, enabled by default, which provides further buffers
|
| 5366 |
|
|
that can control the execution and describe the state of your program.
|
| 5367 |
|
|
*Note GDB Graphical Interface: (Emacs)GDB Graphical Interface.
|
| 5368 |
|
|
|
| 5369 |
|
|
If you specify an absolute file name when prompted for the `M-x gdb'
|
| 5370 |
|
|
argument, then Emacs sets your current working directory to where your
|
| 5371 |
|
|
program resides. If you only specify the file name, then Emacs sets
|
| 5372 |
|
|
your current working directory to to the directory associated with the
|
| 5373 |
|
|
previous buffer. In this case, GDB may find your program by searching
|
| 5374 |
|
|
your environment's `PATH' variable, but on some operating systems it
|
| 5375 |
|
|
might not find the source. So, although the GDB input and output
|
| 5376 |
|
|
session proceeds normally, the auxiliary buffer does not display the
|
| 5377 |
|
|
current source and line of execution.
|
| 5378 |
|
|
|
| 5379 |
|
|
The initial working directory of GDB is printed on the top line of
|
| 5380 |
|
|
the GUD buffer and this serves as a default for the commands that
|
| 5381 |
|
|
specify files for GDB to operate on. *Note Commands to Specify Files:
|
| 5382 |
|
|
Files.
|
| 5383 |
|
|
|
| 5384 |
|
|
By default, `M-x gdb' calls the program called `gdb'. If you need
|
| 5385 |
|
|
to call GDB by a different name (for example, if you keep several
|
| 5386 |
|
|
configurations around, with different names) you can customize the
|
| 5387 |
|
|
Emacs variable `gud-gdb-command-name' to run the one you want.
|
| 5388 |
|
|
|
| 5389 |
|
|
In the GUD buffer, you can use these special Emacs commands in
|
| 5390 |
|
|
addition to the standard Shell mode commands:
|
| 5391 |
|
|
|
| 5392 |
|
|
`C-h m'
|
| 5393 |
|
|
Describe the features of Emacs' GUD Mode.
|
| 5394 |
|
|
|
| 5395 |
|
|
`C-c C-s'
|
| 5396 |
|
|
Execute to another source line, like the GDB `step' command; also
|
| 5397 |
|
|
update the display window to show the current file and location.
|
| 5398 |
|
|
|
| 5399 |
|
|
`C-c C-n'
|
| 5400 |
|
|
Execute to next source line in this function, skipping all function
|
| 5401 |
|
|
calls, like the GDB `next' command. Then update the display window
|
| 5402 |
|
|
to show the current file and location.
|
| 5403 |
|
|
|
| 5404 |
|
|
`C-c C-i'
|
| 5405 |
|
|
Execute one instruction, like the GDB `stepi' command; update
|
| 5406 |
|
|
display window accordingly.
|
| 5407 |
|
|
|
| 5408 |
|
|
`C-c C-f'
|
| 5409 |
|
|
Execute until exit from the selected stack frame, like the GDB
|
| 5410 |
|
|
`finish' command.
|
| 5411 |
|
|
|
| 5412 |
|
|
`C-c C-r'
|
| 5413 |
|
|
Continue execution of your program, like the GDB `continue'
|
| 5414 |
|
|
command.
|
| 5415 |
|
|
|
| 5416 |
|
|
`C-c <'
|
| 5417 |
|
|
Go up the number of frames indicated by the numeric argument
|
| 5418 |
|
|
(*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'
|
| 5419 |
|
|
command.
|
| 5420 |
|
|
|
| 5421 |
|
|
`C-c >'
|
| 5422 |
|
|
Go down the number of frames indicated by the numeric argument,
|
| 5423 |
|
|
like the GDB `down' command.
|
| 5424 |
|
|
|
| 5425 |
|
|
In any source file, the Emacs command `C-x ' (`gud-break')
|
| 5426 |
|
|
tells GDB to set a breakpoint on the source line point is on.
|
| 5427 |
|
|
|
| 5428 |
|
|
In text command mode, if you type `M-x speedbar', Emacs displays a
|
| 5429 |
|
|
separate frame which shows a backtrace when the GUD buffer is current.
|
| 5430 |
|
|
Move point to any frame in the stack and type to make it become
|
| 5431 |
|
|
the current frame and display the associated source in the source
|
| 5432 |
|
|
buffer. Alternatively, click `Mouse-2' to make the selected frame
|
| 5433 |
|
|
become the current one. In graphical mode, the speedbar displays watch
|
| 5434 |
|
|
expressions.
|
| 5435 |
|
|
|
| 5436 |
|
|
If you accidentally delete the source-display buffer, an easy way to
|
| 5437 |
|
|
get it back is to type the command `f' in the GDB buffer, to request a
|
| 5438 |
|
|
frame display; when you run under Emacs, this recreates the source
|
| 5439 |
|
|
buffer if necessary to show you the context of the current frame.
|
| 5440 |
|
|
|
| 5441 |
|
|
The source files displayed in Emacs are in ordinary Emacs buffers
|
| 5442 |
|
|
which are visiting the source files in the usual way. You can edit the
|
| 5443 |
|
|
files with these buffers if you wish; but keep in mind that GDB
|
| 5444 |
|
|
communicates with Emacs in terms of line numbers. If you add or delete
|
| 5445 |
|
|
lines from the text, the line numbers that GDB knows cease to
|
| 5446 |
|
|
correspond properly with the code.
|
| 5447 |
|
|
|
| 5448 |
|
|
A more detailed description of Emacs' interaction with GDB is given
|
| 5449 |
|
|
in the Emacs manual (*note Debuggers: (Emacs)Debuggers.).
|
| 5450 |
|
|
|
| 5451 |
|
|
|
| 5452 |
|
|
File: gdb.info, Node: GDB/MI, Next: Annotations, Prev: Emacs, Up: Top
|
| 5453 |
|
|
|
| 5454 |
|
|
27 The GDB/MI Interface
|
| 5455 |
|
|
***********************
|
| 5456 |
|
|
|
| 5457 |
|
|
Function and Purpose
|
| 5458 |
|
|
====================
|
| 5459 |
|
|
|
| 5460 |
|
|
GDB/MI is a line based machine oriented text interface to GDB and is
|
| 5461 |
|
|
activated by specifying using the `--interpreter' command line option
|
| 5462 |
|
|
(*note Mode Options::). It is specifically intended to support the
|
| 5463 |
|
|
development of systems which use the debugger as just one small
|
| 5464 |
|
|
component of a larger system.
|
| 5465 |
|
|
|
| 5466 |
|
|
This chapter is a specification of the GDB/MI interface. It is
|
| 5467 |
|
|
written in the form of a reference manual.
|
| 5468 |
|
|
|
| 5469 |
|
|
Note that GDB/MI is still under construction, so some of the
|
| 5470 |
|
|
features described below are incomplete and subject to change (*note
|
| 5471 |
|
|
GDB/MI Development and Front Ends: GDB/MI Development and Front Ends.).
|
| 5472 |
|
|
|
| 5473 |
|
|
Notation and Terminology
|
| 5474 |
|
|
========================
|
| 5475 |
|
|
|
| 5476 |
|
|
This chapter uses the following notation:
|
| 5477 |
|
|
|
| 5478 |
|
|
* `|' separates two alternatives.
|
| 5479 |
|
|
|
| 5480 |
|
|
* `[ SOMETHING ]' indicates that SOMETHING is optional: it may or
|
| 5481 |
|
|
may not be given.
|
| 5482 |
|
|
|
| 5483 |
|
|
* `( GROUP )*' means that GROUP inside the parentheses may repeat
|
| 5484 |
|
|
zero or more times.
|
| 5485 |
|
|
|
| 5486 |
|
|
* `( GROUP )+' means that GROUP inside the parentheses may repeat
|
| 5487 |
|
|
one or more times.
|
| 5488 |
|
|
|
| 5489 |
|
|
* `"STRING"' means a literal STRING.
|
| 5490 |
|
|
|
| 5491 |
|
|
* Menu:
|
| 5492 |
|
|
|
| 5493 |
|
|
* GDB/MI General Design::
|
| 5494 |
|
|
* GDB/MI Command Syntax::
|
| 5495 |
|
|
* GDB/MI Compatibility with CLI::
|
| 5496 |
|
|
* GDB/MI Development and Front Ends::
|
| 5497 |
|
|
* GDB/MI Output Records::
|
| 5498 |
|
|
* GDB/MI Simple Examples::
|
| 5499 |
|
|
* GDB/MI Command Description Format::
|
| 5500 |
|
|
* GDB/MI Breakpoint Commands::
|
| 5501 |
|
|
* GDB/MI Program Context::
|
| 5502 |
|
|
* GDB/MI Thread Commands::
|
| 5503 |
|
|
* GDB/MI Program Execution::
|
| 5504 |
|
|
* GDB/MI Stack Manipulation::
|
| 5505 |
|
|
* GDB/MI Variable Objects::
|
| 5506 |
|
|
* GDB/MI Data Manipulation::
|
| 5507 |
|
|
* GDB/MI Tracepoint Commands::
|
| 5508 |
|
|
* GDB/MI Symbol Query::
|
| 5509 |
|
|
* GDB/MI File Commands::
|
| 5510 |
|
|
* GDB/MI Target Manipulation::
|
| 5511 |
|
|
* GDB/MI File Transfer Commands::
|
| 5512 |
|
|
* GDB/MI Miscellaneous Commands::
|
| 5513 |
|
|
|
| 5514 |
|
|
|
| 5515 |
|
|
File: gdb.info, Node: GDB/MI General Design, Next: GDB/MI Command Syntax, Up: GDB/MI
|
| 5516 |
|
|
|
| 5517 |
|
|
27.1 GDB/MI General Design
|
| 5518 |
|
|
==========================
|
| 5519 |
|
|
|
| 5520 |
|
|
Interaction of a GDB/MI frontend with GDB involves three
|
| 5521 |
|
|
parts--commands sent to GDB, responses to those commands and
|
| 5522 |
|
|
notifications. Each command results in exactly one response,
|
| 5523 |
|
|
indicating either successful completion of the command, or an error.
|
| 5524 |
|
|
For the commands that do not resume the target, the response contains
|
| 5525 |
|
|
the requested information. For the commands that resume the target, the
|
| 5526 |
|
|
response only indicates whether the target was successfully resumed.
|
| 5527 |
|
|
Notifications is the mechanism for reporting changes in the state of the
|
| 5528 |
|
|
target, or in GDB state, that cannot conveniently be associated with a
|
| 5529 |
|
|
command and reported as part of that command response.
|
| 5530 |
|
|
|
| 5531 |
|
|
The important examples of notifications are:
|
| 5532 |
|
|
* Exec notifications. These are used to report changes in target
|
| 5533 |
|
|
state--when a target is resumed, or stopped. It would not be
|
| 5534 |
|
|
feasible to include this information in response of resuming
|
| 5535 |
|
|
commands, because one resume commands can result in multiple
|
| 5536 |
|
|
events in different threads. Also, quite some time may pass
|
| 5537 |
|
|
before any event happens in the target, while a frontend needs to
|
| 5538 |
|
|
know whether the resuming command itself was successfully executed.
|
| 5539 |
|
|
|
| 5540 |
|
|
* Console output, and status notifications. Console output
|
| 5541 |
|
|
notifications are used to report output of CLI commands, as well as
|
| 5542 |
|
|
diagnostics for other commands. Status notifications are used to
|
| 5543 |
|
|
report the progress of a long-running operation. Naturally,
|
| 5544 |
|
|
including this information in command response would mean no
|
| 5545 |
|
|
output is produced until the command is finished, which is
|
| 5546 |
|
|
undesirable.
|
| 5547 |
|
|
|
| 5548 |
|
|
* General notifications. Commands may have various side effects on
|
| 5549 |
|
|
the GDB or target state beyond their official purpose. For
|
| 5550 |
|
|
example, a command may change the selected thread. Although such
|
| 5551 |
|
|
changes can be included in command response, using notification
|
| 5552 |
|
|
allows for more orthogonal frontend design.
|
| 5553 |
|
|
|
| 5554 |
|
|
|
| 5555 |
|
|
There's no guarantee that whenever an MI command reports an error,
|
| 5556 |
|
|
GDB or the target are in any specific state, and especially, the state
|
| 5557 |
|
|
is not reverted to the state before the MI command was processed.
|
| 5558 |
|
|
Therefore, whenever an MI command results in an error, we recommend
|
| 5559 |
|
|
that the frontend refreshes all the information shown in the user
|
| 5560 |
|
|
interface.
|
| 5561 |
|
|
|
| 5562 |
|
|
* Menu:
|
| 5563 |
|
|
|
| 5564 |
|
|
* Context management::
|
| 5565 |
|
|
* Asynchronous and non-stop modes::
|
| 5566 |
|
|
* Thread groups::
|
| 5567 |
|
|
|
| 5568 |
|
|
|
| 5569 |
|
|
File: gdb.info, Node: Context management, Next: Asynchronous and non-stop modes, Up: GDB/MI General Design
|
| 5570 |
|
|
|
| 5571 |
|
|
27.1.1 Context management
|
| 5572 |
|
|
-------------------------
|
| 5573 |
|
|
|
| 5574 |
|
|
In most cases when GDB accesses the target, this access is done in
|
| 5575 |
|
|
context of a specific thread and frame (*note Frames::). Often, even
|
| 5576 |
|
|
when accessing global data, the target requires that a thread be
|
| 5577 |
|
|
specified. The CLI interface maintains the selected thread and frame,
|
| 5578 |
|
|
and supplies them to target on each command. This is convenient,
|
| 5579 |
|
|
because a command line user would not want to specify that information
|
| 5580 |
|
|
explicitly on each command, and because user interacts with GDB via a
|
| 5581 |
|
|
single terminal, so no confusion is possible as to what thread and
|
| 5582 |
|
|
frame are the current ones.
|
| 5583 |
|
|
|
| 5584 |
|
|
In the case of MI, the concept of selected thread and frame is less
|
| 5585 |
|
|
useful. First, a frontend can easily remember this information itself.
|
| 5586 |
|
|
Second, a graphical frontend can have more than one window, each one
|
| 5587 |
|
|
used for debugging a different thread, and the frontend might want to
|
| 5588 |
|
|
access additional threads for internal purposes. This increases the
|
| 5589 |
|
|
risk that by relying on implicitly selected thread, the frontend may be
|
| 5590 |
|
|
operating on a wrong one. Therefore, each MI command should explicitly
|
| 5591 |
|
|
specify which thread and frame to operate on. To make it possible,
|
| 5592 |
|
|
each MI command accepts the `--thread' and `--frame' options, the value
|
| 5593 |
|
|
to each is GDB identifier for thread and frame to operate on.
|
| 5594 |
|
|
|
| 5595 |
|
|
Usually, each top-level window in a frontend allows the user to
|
| 5596 |
|
|
select a thread and a frame, and remembers the user selection for
|
| 5597 |
|
|
further operations. However, in some cases GDB may suggest that the
|
| 5598 |
|
|
current thread be changed. For example, when stopping on a breakpoint
|
| 5599 |
|
|
it is reasonable to switch to the thread where breakpoint is hit. For
|
| 5600 |
|
|
another example, if the user issues the CLI `thread' command via the
|
| 5601 |
|
|
frontend, it is desirable to change the frontend's selected thread to
|
| 5602 |
|
|
the one specified by user. GDB communicates the suggestion to change
|
| 5603 |
|
|
current thread using the `=thread-selected' notification. No such
|
| 5604 |
|
|
notification is available for the selected frame at the moment.
|
| 5605 |
|
|
|
| 5606 |
|
|
Note that historically, MI shares the selected thread with CLI, so
|
| 5607 |
|
|
frontends used the `-thread-select' to execute commands in the right
|
| 5608 |
|
|
context. However, getting this to work right is cumbersome. The
|
| 5609 |
|
|
simplest way is for frontend to emit `-thread-select' command before
|
| 5610 |
|
|
every command. This doubles the number of commands that need to be
|
| 5611 |
|
|
sent. The alternative approach is to suppress `-thread-select' if the
|
| 5612 |
|
|
selected thread in GDB is supposed to be identical to the thread the
|
| 5613 |
|
|
frontend wants to operate on. However, getting this optimization right
|
| 5614 |
|
|
can be tricky. In particular, if the frontend sends several commands
|
| 5615 |
|
|
to GDB, and one of the commands changes the selected thread, then the
|
| 5616 |
|
|
behaviour of subsequent commands will change. So, a frontend should
|
| 5617 |
|
|
either wait for response from such problematic commands, or explicitly
|
| 5618 |
|
|
add `-thread-select' for all subsequent commands. No frontend is known
|
| 5619 |
|
|
to do this exactly right, so it is suggested to just always pass the
|
| 5620 |
|
|
`--thread' and `--frame' options.
|
| 5621 |
|
|
|
| 5622 |
|
|
|
| 5623 |
|
|
File: gdb.info, Node: Asynchronous and non-stop modes, Next: Thread groups, Prev: Context management, Up: GDB/MI General Design
|
| 5624 |
|
|
|
| 5625 |
|
|
27.1.2 Asynchronous command execution and non-stop mode
|
| 5626 |
|
|
-------------------------------------------------------
|
| 5627 |
|
|
|
| 5628 |
|
|
On some targets, GDB is capable of processing MI commands even while
|
| 5629 |
|
|
the target is running. This is called "asynchronous command execution"
|
| 5630 |
|
|
(*note Background Execution::). The frontend may specify a preferrence
|
| 5631 |
|
|
for asynchronous execution using the `-gdb-set target-async 1' command,
|
| 5632 |
|
|
which should be emitted before either running the executable or
|
| 5633 |
|
|
attaching to the target. After the frontend has started the executable
|
| 5634 |
|
|
or attached to the target, it can find if asynchronous execution is
|
| 5635 |
|
|
enabled using the `-list-target-features' command.
|
| 5636 |
|
|
|
| 5637 |
|
|
Even if GDB can accept a command while target is running, many
|
| 5638 |
|
|
commands that access the target do not work when the target is running.
|
| 5639 |
|
|
Therefore, asynchronous command execution is most useful when combined
|
| 5640 |
|
|
with non-stop mode (*note Non-Stop Mode::). Then, it is possible to
|
| 5641 |
|
|
examine the state of one thread, while other threads are running.
|
| 5642 |
|
|
|
| 5643 |
|
|
When a given thread is running, MI commands that try to access the
|
| 5644 |
|
|
target in the context of that thread may not work, or may work only on
|
| 5645 |
|
|
some targets. In particular, commands that try to operate on thread's
|
| 5646 |
|
|
stack will not work, on any target. Commands that read memory, or
|
| 5647 |
|
|
modify breakpoints, may work or not work, depending on the target. Note
|
| 5648 |
|
|
that even commands that operate on global state, such as `print',
|
| 5649 |
|
|
`set', and breakpoint commands, still access the target in the context
|
| 5650 |
|
|
of a specific thread, so frontend should try to find a stopped thread
|
| 5651 |
|
|
and perform the operation on that thread (using the `--thread' option).
|
| 5652 |
|
|
|
| 5653 |
|
|
Which commands will work in the context of a running thread is
|
| 5654 |
|
|
highly target dependent. However, the two commands `-exec-interrupt',
|
| 5655 |
|
|
to stop a thread, and `-thread-info', to find the state of a thread,
|
| 5656 |
|
|
will always work.
|
| 5657 |
|
|
|
| 5658 |
|
|
|
| 5659 |
|
|
File: gdb.info, Node: Thread groups, Prev: Asynchronous and non-stop modes, Up: GDB/MI General Design
|
| 5660 |
|
|
|
| 5661 |
|
|
27.1.3 Thread groups
|
| 5662 |
|
|
--------------------
|
| 5663 |
|
|
|
| 5664 |
|
|
GDB may be used to debug several processes at the same time. On some
|
| 5665 |
|
|
platfroms, GDB may support debugging of several hardware systems, each
|
| 5666 |
|
|
one having several cores with several different processes running on
|
| 5667 |
|
|
each core. This section describes the MI mechanism to support such
|
| 5668 |
|
|
debugging scenarios.
|
| 5669 |
|
|
|
| 5670 |
|
|
The key observation is that regardless of the structure of the
|
| 5671 |
|
|
target, MI can have a global list of threads, because most commands that
|
| 5672 |
|
|
accept the `--thread' option do not need to know what process that
|
| 5673 |
|
|
thread belongs to. Therefore, it is not necessary to introduce neither
|
| 5674 |
|
|
additional `--process' option, nor an notion of the current process in
|
| 5675 |
|
|
the MI interface. The only strictly new feature that is required is
|
| 5676 |
|
|
the ability to find how the threads are grouped into processes.
|
| 5677 |
|
|
|
| 5678 |
|
|
To allow the user to discover such grouping, and to support arbitrary
|
| 5679 |
|
|
hierarchy of machines/cores/processes, MI introduces the concept of a
|
| 5680 |
|
|
"thread group". Thread group is a collection of threads and other
|
| 5681 |
|
|
thread groups. A thread group always has a string identifier, a type,
|
| 5682 |
|
|
and may have additional attributes specific to the type. A new
|
| 5683 |
|
|
command, `-list-thread-groups', returns the list of top-level thread
|
| 5684 |
|
|
groups, which correspond to processes that GDB is debugging at the
|
| 5685 |
|
|
moment. By passing an identifier of a thread group to the
|
| 5686 |
|
|
`-list-thread-groups' command, it is possible to obtain the members of
|
| 5687 |
|
|
specific thread group.
|
| 5688 |
|
|
|
| 5689 |
|
|
To allow the user to easily discover processes, and other objects, he
|
| 5690 |
|
|
wishes to debug, a concept of "available thread group" is introduced.
|
| 5691 |
|
|
Available thread group is an thread group that GDB is not debugging,
|
| 5692 |
|
|
but that can be attached to, using the `-target-attach' command. The
|
| 5693 |
|
|
list of available top-level thread groups can be obtained using
|
| 5694 |
|
|
`-list-thread-groups --available'. In general, the content of a thread
|
| 5695 |
|
|
group may be only retrieved only after attaching to that thread group.
|
| 5696 |
|
|
|
| 5697 |
|
|
Thread groups are related to inferiors (*note Inferiors and
|
| 5698 |
|
|
Programs::). Each inferior corresponds to a thread group of a special
|
| 5699 |
|
|
type `process', and some additional operations are permitted on such
|
| 5700 |
|
|
thread groups.
|
| 5701 |
|
|
|
| 5702 |
|
|
|
| 5703 |
|
|
File: gdb.info, Node: GDB/MI Command Syntax, Next: GDB/MI Compatibility with CLI, Prev: GDB/MI General Design, Up: GDB/MI
|
| 5704 |
|
|
|
| 5705 |
|
|
27.2 GDB/MI Command Syntax
|
| 5706 |
|
|
==========================
|
| 5707 |
|
|
|
| 5708 |
|
|
* Menu:
|
| 5709 |
|
|
|
| 5710 |
|
|
* GDB/MI Input Syntax::
|
| 5711 |
|
|
* GDB/MI Output Syntax::
|
| 5712 |
|
|
|
| 5713 |
|
|
|
| 5714 |
|
|
File: gdb.info, Node: GDB/MI Input Syntax, Next: GDB/MI Output Syntax, Up: GDB/MI Command Syntax
|
| 5715 |
|
|
|
| 5716 |
|
|
27.2.1 GDB/MI Input Syntax
|
| 5717 |
|
|
--------------------------
|
| 5718 |
|
|
|
| 5719 |
|
|
`COMMAND ==>'
|
| 5720 |
|
|
`CLI-COMMAND | MI-COMMAND'
|
| 5721 |
|
|
|
| 5722 |
|
|
`CLI-COMMAND ==>'
|
| 5723 |
|
|
`[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDB
|
| 5724 |
|
|
CLI command.
|
| 5725 |
|
|
|
| 5726 |
|
|
`MI-COMMAND ==>'
|
| 5727 |
|
|
`[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " "
|
| 5728 |
|
|
PARAMETER )* NL'
|
| 5729 |
|
|
|
| 5730 |
|
|
`TOKEN ==>'
|
| 5731 |
|
|
"any sequence of digits"
|
| 5732 |
|
|
|
| 5733 |
|
|
`OPTION ==>'
|
| 5734 |
|
|
`"-" PARAMETER [ " " PARAMETER ]'
|
| 5735 |
|
|
|
| 5736 |
|
|
`PARAMETER ==>'
|
| 5737 |
|
|
`NON-BLANK-SEQUENCE | C-STRING'
|
| 5738 |
|
|
|
| 5739 |
|
|
`OPERATION ==>'
|
| 5740 |
|
|
_any of the operations described in this chapter_
|
| 5741 |
|
|
|
| 5742 |
|
|
`NON-BLANK-SEQUENCE ==>'
|
| 5743 |
|
|
_anything, provided it doesn't contain special characters such as
|
| 5744 |
|
|
"-", NL, """ and of course " "_
|
| 5745 |
|
|
|
| 5746 |
|
|
`C-STRING ==>'
|
| 5747 |
|
|
`""" SEVEN-BIT-ISO-C-STRING-CONTENT """'
|
| 5748 |
|
|
|
| 5749 |
|
|
`NL ==>'
|
| 5750 |
|
|
`CR | CR-LF'
|
| 5751 |
|
|
|
| 5752 |
|
|
Notes:
|
| 5753 |
|
|
|
| 5754 |
|
|
* The CLI commands are still handled by the MI interpreter; their
|
| 5755 |
|
|
output is described below.
|
| 5756 |
|
|
|
| 5757 |
|
|
* The `TOKEN', when present, is passed back when the command
|
| 5758 |
|
|
finishes.
|
| 5759 |
|
|
|
| 5760 |
|
|
* Some MI commands accept optional arguments as part of the parameter
|
| 5761 |
|
|
list. Each option is identified by a leading `-' (dash) and may be
|
| 5762 |
|
|
followed by an optional argument parameter. Options occur first
|
| 5763 |
|
|
in the parameter list and can be delimited from normal parameters
|
| 5764 |
|
|
using `--' (this is useful when some parameters begin with a dash).
|
| 5765 |
|
|
|
| 5766 |
|
|
Pragmatics:
|
| 5767 |
|
|
|
| 5768 |
|
|
* We want easy access to the existing CLI syntax (for debugging).
|
| 5769 |
|
|
|
| 5770 |
|
|
* We want it to be easy to spot a MI operation.
|
| 5771 |
|
|
|
| 5772 |
|
|
|
| 5773 |
|
|
File: gdb.info, Node: GDB/MI Output Syntax, Prev: GDB/MI Input Syntax, Up: GDB/MI Command Syntax
|
| 5774 |
|
|
|
| 5775 |
|
|
27.2.2 GDB/MI Output Syntax
|
| 5776 |
|
|
---------------------------
|
| 5777 |
|
|
|
| 5778 |
|
|
The output from GDB/MI consists of zero or more out-of-band records
|
| 5779 |
|
|
followed, optionally, by a single result record. This result record is
|
| 5780 |
|
|
for the most recent command. The sequence of output records is
|
| 5781 |
|
|
terminated by `(gdb)'.
|
| 5782 |
|
|
|
| 5783 |
|
|
If an input command was prefixed with a `TOKEN' then the
|
| 5784 |
|
|
corresponding output for that command will also be prefixed by that same
|
| 5785 |
|
|
TOKEN.
|
| 5786 |
|
|
|
| 5787 |
|
|
`OUTPUT ==>'
|
| 5788 |
|
|
`( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'
|
| 5789 |
|
|
|
| 5790 |
|
|
`RESULT-RECORD ==>'
|
| 5791 |
|
|
` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'
|
| 5792 |
|
|
|
| 5793 |
|
|
`OUT-OF-BAND-RECORD ==>'
|
| 5794 |
|
|
`ASYNC-RECORD | STREAM-RECORD'
|
| 5795 |
|
|
|
| 5796 |
|
|
`ASYNC-RECORD ==>'
|
| 5797 |
|
|
`EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'
|
| 5798 |
|
|
|
| 5799 |
|
|
`EXEC-ASYNC-OUTPUT ==>'
|
| 5800 |
|
|
`[ TOKEN ] "*" ASYNC-OUTPUT'
|
| 5801 |
|
|
|
| 5802 |
|
|
`STATUS-ASYNC-OUTPUT ==>'
|
| 5803 |
|
|
`[ TOKEN ] "+" ASYNC-OUTPUT'
|
| 5804 |
|
|
|
| 5805 |
|
|
`NOTIFY-ASYNC-OUTPUT ==>'
|
| 5806 |
|
|
`[ TOKEN ] "=" ASYNC-OUTPUT'
|
| 5807 |
|
|
|
| 5808 |
|
|
`ASYNC-OUTPUT ==>'
|
| 5809 |
|
|
`ASYNC-CLASS ( "," RESULT )* NL'
|
| 5810 |
|
|
|
| 5811 |
|
|
`RESULT-CLASS ==>'
|
| 5812 |
|
|
`"done" | "running" | "connected" | "error" | "exit"'
|
| 5813 |
|
|
|
| 5814 |
|
|
`ASYNC-CLASS ==>'
|
| 5815 |
|
|
`"stopped" | OTHERS' (where OTHERS will be added depending on the
|
| 5816 |
|
|
needs--this is still in development).
|
| 5817 |
|
|
|
| 5818 |
|
|
`RESULT ==>'
|
| 5819 |
|
|
` VARIABLE "=" VALUE'
|
| 5820 |
|
|
|
| 5821 |
|
|
`VARIABLE ==>'
|
| 5822 |
|
|
` STRING '
|
| 5823 |
|
|
|
| 5824 |
|
|
`VALUE ==>'
|
| 5825 |
|
|
` CONST | TUPLE | LIST '
|
| 5826 |
|
|
|
| 5827 |
|
|
`CONST ==>'
|
| 5828 |
|
|
`C-STRING'
|
| 5829 |
|
|
|
| 5830 |
|
|
`TUPLE ==>'
|
| 5831 |
|
|
` "{}" | "{" RESULT ( "," RESULT )* "}" '
|
| 5832 |
|
|
|
| 5833 |
|
|
`LIST ==>'
|
| 5834 |
|
|
` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*
|
| 5835 |
|
|
"]" '
|
| 5836 |
|
|
|
| 5837 |
|
|
`STREAM-RECORD ==>'
|
| 5838 |
|
|
`CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'
|
| 5839 |
|
|
|
| 5840 |
|
|
`CONSOLE-STREAM-OUTPUT ==>'
|
| 5841 |
|
|
`"~" C-STRING'
|
| 5842 |
|
|
|
| 5843 |
|
|
`TARGET-STREAM-OUTPUT ==>'
|
| 5844 |
|
|
`"@" C-STRING'
|
| 5845 |
|
|
|
| 5846 |
|
|
`LOG-STREAM-OUTPUT ==>'
|
| 5847 |
|
|
`"&" C-STRING'
|
| 5848 |
|
|
|
| 5849 |
|
|
`NL ==>'
|
| 5850 |
|
|
`CR | CR-LF'
|
| 5851 |
|
|
|
| 5852 |
|
|
`TOKEN ==>'
|
| 5853 |
|
|
_any sequence of digits_.
|
| 5854 |
|
|
|
| 5855 |
|
|
Notes:
|
| 5856 |
|
|
|
| 5857 |
|
|
* All output sequences end in a single line containing a period.
|
| 5858 |
|
|
|
| 5859 |
|
|
* The `TOKEN' is from the corresponding request. Note that for all
|
| 5860 |
|
|
async output, while the token is allowed by the grammar and may be
|
| 5861 |
|
|
output by future versions of GDB for select async output messages,
|
| 5862 |
|
|
it is generally omitted. Frontends should treat all async output
|
| 5863 |
|
|
as reporting general changes in the state of the target and there
|
| 5864 |
|
|
should be no need to associate async output to any prior command.
|
| 5865 |
|
|
|
| 5866 |
|
|
* STATUS-ASYNC-OUTPUT contains on-going status information about the
|
| 5867 |
|
|
progress of a slow operation. It can be discarded. All status
|
| 5868 |
|
|
output is prefixed by `+'.
|
| 5869 |
|
|
|
| 5870 |
|
|
* EXEC-ASYNC-OUTPUT contains asynchronous state change on the target
|
| 5871 |
|
|
(stopped, started, disappeared). All async output is prefixed by
|
| 5872 |
|
|
`*'.
|
| 5873 |
|
|
|
| 5874 |
|
|
* NOTIFY-ASYNC-OUTPUT contains supplementary information that the
|
| 5875 |
|
|
client should handle (e.g., a new breakpoint information). All
|
| 5876 |
|
|
notify output is prefixed by `='.
|
| 5877 |
|
|
|
| 5878 |
|
|
* CONSOLE-STREAM-OUTPUT is output that should be displayed as is in
|
| 5879 |
|
|
the console. It is the textual response to a CLI command. All
|
| 5880 |
|
|
the console output is prefixed by `~'.
|
| 5881 |
|
|
|
| 5882 |
|
|
* TARGET-STREAM-OUTPUT is the output produced by the target program.
|
| 5883 |
|
|
All the target output is prefixed by `@'.
|
| 5884 |
|
|
|
| 5885 |
|
|
* LOG-STREAM-OUTPUT is output text coming from GDB's internals, for
|
| 5886 |
|
|
instance messages that should be displayed as part of an error
|
| 5887 |
|
|
log. All the log output is prefixed by `&'.
|
| 5888 |
|
|
|
| 5889 |
|
|
* New GDB/MI commands should only output LISTS containing VALUES.
|
| 5890 |
|
|
|
| 5891 |
|
|
|
| 5892 |
|
|
*Note GDB/MI Stream Records: GDB/MI Stream Records, for more details
|
| 5893 |
|
|
about the various output records.
|
| 5894 |
|
|
|
| 5895 |
|
|
|
| 5896 |
|
|
File: gdb.info, Node: GDB/MI Compatibility with CLI, Next: GDB/MI Development and Front Ends, Prev: GDB/MI Command Syntax, Up: GDB/MI
|
| 5897 |
|
|
|
| 5898 |
|
|
27.3 GDB/MI Compatibility with CLI
|
| 5899 |
|
|
==================================
|
| 5900 |
|
|
|
| 5901 |
|
|
For the developers convenience CLI commands can be entered directly,
|
| 5902 |
|
|
but there may be some unexpected behaviour. For example, commands that
|
| 5903 |
|
|
query the user will behave as if the user replied yes, breakpoint
|
| 5904 |
|
|
command lists are not executed and some CLI commands, such as `if',
|
| 5905 |
|
|
`when' and `define', prompt for further input with `>', which is not
|
| 5906 |
|
|
valid MI output.
|
| 5907 |
|
|
|
| 5908 |
|
|
This feature may be removed at some stage in the future and it is
|
| 5909 |
|
|
recommended that front ends use the `-interpreter-exec' command (*note
|
| 5910 |
|
|
-interpreter-exec::).
|
| 5911 |
|
|
|
| 5912 |
|
|
|
| 5913 |
|
|
File: gdb.info, Node: GDB/MI Development and Front Ends, Next: GDB/MI Output Records, Prev: GDB/MI Compatibility with CLI, Up: GDB/MI
|
| 5914 |
|
|
|
| 5915 |
|
|
27.4 GDB/MI Development and Front Ends
|
| 5916 |
|
|
======================================
|
| 5917 |
|
|
|
| 5918 |
|
|
The application which takes the MI output and presents the state of the
|
| 5919 |
|
|
program being debugged to the user is called a "front end".
|
| 5920 |
|
|
|
| 5921 |
|
|
Although GDB/MI is still incomplete, it is currently being used by a
|
| 5922 |
|
|
variety of front ends to GDB. This makes it difficult to introduce new
|
| 5923 |
|
|
functionality without breaking existing usage. This section tries to
|
| 5924 |
|
|
minimize the problems by describing how the protocol might change.
|
| 5925 |
|
|
|
| 5926 |
|
|
Some changes in MI need not break a carefully designed front end, and
|
| 5927 |
|
|
for these the MI version will remain unchanged. The following is a
|
| 5928 |
|
|
list of changes that may occur within one level, so front ends should
|
| 5929 |
|
|
parse MI output in a way that can handle them:
|
| 5930 |
|
|
|
| 5931 |
|
|
* New MI commands may be added.
|
| 5932 |
|
|
|
| 5933 |
|
|
* New fields may be added to the output of any MI command.
|
| 5934 |
|
|
|
| 5935 |
|
|
* The range of values for fields with specified values, e.g.,
|
| 5936 |
|
|
`in_scope' (*note -var-update::) may be extended.
|
| 5937 |
|
|
|
| 5938 |
|
|
|
| 5939 |
|
|
If the changes are likely to break front ends, the MI version level
|
| 5940 |
|
|
will be increased by one. This will allow the front end to parse the
|
| 5941 |
|
|
output according to the MI version. Apart from mi0, new versions of
|
| 5942 |
|
|
GDB will not support old versions of MI and it will be the
|
| 5943 |
|
|
responsibility of the front end to work with the new one.
|
| 5944 |
|
|
|
| 5945 |
|
|
The best way to avoid unexpected changes in MI that might break your
|
| 5946 |
|
|
front end is to make your project known to GDB developers and follow
|
| 5947 |
|
|
development on and .
|
| 5948 |
|
|
|
| 5949 |
|
|
|
| 5950 |
|
|
File: gdb.info, Node: GDB/MI Output Records, Next: GDB/MI Simple Examples, Prev: GDB/MI Development and Front Ends, Up: GDB/MI
|
| 5951 |
|
|
|
| 5952 |
|
|
27.5 GDB/MI Output Records
|
| 5953 |
|
|
==========================
|
| 5954 |
|
|
|
| 5955 |
|
|
* Menu:
|
| 5956 |
|
|
|
| 5957 |
|
|
* GDB/MI Result Records::
|
| 5958 |
|
|
* GDB/MI Stream Records::
|
| 5959 |
|
|
* GDB/MI Async Records::
|
| 5960 |
|
|
* GDB/MI Frame Information::
|
| 5961 |
|
|
* GDB/MI Thread Information::
|
| 5962 |
|
|
|
| 5963 |
|
|
|
| 5964 |
|
|
File: gdb.info, Node: GDB/MI Result Records, Next: GDB/MI Stream Records, Up: GDB/MI Output Records
|
| 5965 |
|
|
|
| 5966 |
|
|
27.5.1 GDB/MI Result Records
|
| 5967 |
|
|
----------------------------
|
| 5968 |
|
|
|
| 5969 |
|
|
In addition to a number of out-of-band notifications, the response to a
|
| 5970 |
|
|
GDB/MI command includes one of the following result indications:
|
| 5971 |
|
|
|
| 5972 |
|
|
`"^done" [ "," RESULTS ]'
|
| 5973 |
|
|
The synchronous operation was successful, `RESULTS' are the return
|
| 5974 |
|
|
values.
|
| 5975 |
|
|
|
| 5976 |
|
|
`"^running"'
|
| 5977 |
|
|
This result record is equivalent to `^done'. Historically, it was
|
| 5978 |
|
|
output instead of `^done' if the command has resumed the target.
|
| 5979 |
|
|
This behaviour is maintained for backward compatibility, but all
|
| 5980 |
|
|
frontends should treat `^done' and `^running' identically and rely
|
| 5981 |
|
|
on the `*running' output record to determine which threads are
|
| 5982 |
|
|
resumed.
|
| 5983 |
|
|
|
| 5984 |
|
|
`"^connected"'
|
| 5985 |
|
|
GDB has connected to a remote target.
|
| 5986 |
|
|
|
| 5987 |
|
|
`"^error" "," C-STRING'
|
| 5988 |
|
|
The operation failed. The `C-STRING' contains the corresponding
|
| 5989 |
|
|
error message.
|
| 5990 |
|
|
|
| 5991 |
|
|
`"^exit"'
|
| 5992 |
|
|
GDB has terminated.
|
| 5993 |
|
|
|
| 5994 |
|
|
|
| 5995 |
|
|
|
| 5996 |
|
|
File: gdb.info, Node: GDB/MI Stream Records, Next: GDB/MI Async Records, Prev: GDB/MI Result Records, Up: GDB/MI Output Records
|
| 5997 |
|
|
|
| 5998 |
|
|
27.5.2 GDB/MI Stream Records
|
| 5999 |
|
|
----------------------------
|
| 6000 |
|
|
|
| 6001 |
|
|
GDB internally maintains a number of output streams: the console, the
|
| 6002 |
|
|
target, and the log. The output intended for each of these streams is
|
| 6003 |
|
|
funneled through the GDB/MI interface using "stream records".
|
| 6004 |
|
|
|
| 6005 |
|
|
Each stream record begins with a unique "prefix character" which
|
| 6006 |
|
|
identifies its stream (*note GDB/MI Output Syntax: GDB/MI Output
|
| 6007 |
|
|
Syntax.). In addition to the prefix, each stream record contains a
|
| 6008 |
|
|
`STRING-OUTPUT'. This is either raw text (with an implicit new line)
|
| 6009 |
|
|
or a quoted C string (which does not contain an implicit newline).
|
| 6010 |
|
|
|
| 6011 |
|
|
`"~" STRING-OUTPUT'
|
| 6012 |
|
|
The console output stream contains text that should be displayed
|
| 6013 |
|
|
in the CLI console window. It contains the textual responses to
|
| 6014 |
|
|
CLI commands.
|
| 6015 |
|
|
|
| 6016 |
|
|
`"@" STRING-OUTPUT'
|
| 6017 |
|
|
The target output stream contains any textual output from the
|
| 6018 |
|
|
running target. This is only present when GDB's event loop is
|
| 6019 |
|
|
truly asynchronous, which is currently only the case for remote
|
| 6020 |
|
|
targets.
|
| 6021 |
|
|
|
| 6022 |
|
|
`"&" STRING-OUTPUT'
|
| 6023 |
|
|
The log stream contains debugging messages being produced by GDB's
|
| 6024 |
|
|
internals.
|
| 6025 |
|
|
|
| 6026 |
|
|
|
| 6027 |
|
|
File: gdb.info, Node: GDB/MI Async Records, Next: GDB/MI Frame Information, Prev: GDB/MI Stream Records, Up: GDB/MI Output Records
|
| 6028 |
|
|
|
| 6029 |
|
|
27.5.3 GDB/MI Async Records
|
| 6030 |
|
|
---------------------------
|
| 6031 |
|
|
|
| 6032 |
|
|
"Async" records are used to notify the GDB/MI client of additional
|
| 6033 |
|
|
changes that have occurred. Those changes can either be a consequence
|
| 6034 |
|
|
of GDB/MI commands (e.g., a breakpoint modified) or a result of target
|
| 6035 |
|
|
activity (e.g., target stopped).
|
| 6036 |
|
|
|
| 6037 |
|
|
The following is the list of possible async records:
|
| 6038 |
|
|
|
| 6039 |
|
|
`*running,thread-id="THREAD"'
|
| 6040 |
|
|
The target is now running. The THREAD field tells which specific
|
| 6041 |
|
|
thread is now running, and can be `all' if all threads are
|
| 6042 |
|
|
running. The frontend should assume that no interaction with a
|
| 6043 |
|
|
running thread is possible after this notification is produced.
|
| 6044 |
|
|
The frontend should not assume that this notification is output
|
| 6045 |
|
|
only once for any command. GDB may emit this notification several
|
| 6046 |
|
|
times, either for different threads, because it cannot resume all
|
| 6047 |
|
|
threads together, or even for a single thread, if the thread must
|
| 6048 |
|
|
be stepped though some code before letting it run freely.
|
| 6049 |
|
|
|
| 6050 |
|
|
`*stopped,reason="REASON",thread-id="ID",stopped-threads="STOPPED",core="CORE"'
|
| 6051 |
|
|
The target has stopped. The REASON field can have one of the
|
| 6052 |
|
|
following values:
|
| 6053 |
|
|
|
| 6054 |
|
|
`breakpoint-hit'
|
| 6055 |
|
|
A breakpoint was reached.
|
| 6056 |
|
|
|
| 6057 |
|
|
`watchpoint-trigger'
|
| 6058 |
|
|
A watchpoint was triggered.
|
| 6059 |
|
|
|
| 6060 |
|
|
`read-watchpoint-trigger'
|
| 6061 |
|
|
A read watchpoint was triggered.
|
| 6062 |
|
|
|
| 6063 |
|
|
`access-watchpoint-trigger'
|
| 6064 |
|
|
An access watchpoint was triggered.
|
| 6065 |
|
|
|
| 6066 |
|
|
`function-finished'
|
| 6067 |
|
|
An -exec-finish or similar CLI command was accomplished.
|
| 6068 |
|
|
|
| 6069 |
|
|
`location-reached'
|
| 6070 |
|
|
An -exec-until or similar CLI command was accomplished.
|
| 6071 |
|
|
|
| 6072 |
|
|
`watchpoint-scope'
|
| 6073 |
|
|
A watchpoint has gone out of scope.
|
| 6074 |
|
|
|
| 6075 |
|
|
`end-stepping-range'
|
| 6076 |
|
|
An -exec-next, -exec-next-instruction, -exec-step,
|
| 6077 |
|
|
-exec-step-instruction or similar CLI command was
|
| 6078 |
|
|
accomplished.
|
| 6079 |
|
|
|
| 6080 |
|
|
`exited-signalled'
|
| 6081 |
|
|
The inferior exited because of a signal.
|
| 6082 |
|
|
|
| 6083 |
|
|
`exited'
|
| 6084 |
|
|
The inferior exited.
|
| 6085 |
|
|
|
| 6086 |
|
|
`exited-normally'
|
| 6087 |
|
|
The inferior exited normally.
|
| 6088 |
|
|
|
| 6089 |
|
|
`signal-received'
|
| 6090 |
|
|
A signal was received by the inferior.
|
| 6091 |
|
|
|
| 6092 |
|
|
The ID field identifies the thread that directly caused the stop -
|
| 6093 |
|
|
for example by hitting a breakpoint. Depending on whether all-stop
|
| 6094 |
|
|
mode is in effect (*note All-Stop Mode::), GDB may either stop all
|
| 6095 |
|
|
threads, or only the thread that directly triggered the stop. If
|
| 6096 |
|
|
all threads are stopped, the STOPPED field will have the value of
|
| 6097 |
|
|
`"all"'. Otherwise, the value of the STOPPED field will be a list
|
| 6098 |
|
|
of thread identifiers. Presently, this list will always include a
|
| 6099 |
|
|
single thread, but frontend should be prepared to see several
|
| 6100 |
|
|
threads in the list. The CORE field reports the processor core on
|
| 6101 |
|
|
which the stop event has happened. This field may be absent if
|
| 6102 |
|
|
such information is not available.
|
| 6103 |
|
|
|
| 6104 |
|
|
`=thread-group-added,id="ID"'
|
| 6105 |
|
|
`=thread-group-removed,id="ID"'
|
| 6106 |
|
|
A thread group was either added or removed. The ID field contains
|
| 6107 |
|
|
the GDB identifier of the thread group. When a thread group is
|
| 6108 |
|
|
added, it generally might not be associated with a running
|
| 6109 |
|
|
process. When a thread group is removed, its id becomes invalid
|
| 6110 |
|
|
and cannot be used in any way.
|
| 6111 |
|
|
|
| 6112 |
|
|
`=thread-group-started,id="ID",pid="PID"'
|
| 6113 |
|
|
A thread group became associated with a running program, either
|
| 6114 |
|
|
because the program was just started or the thread group was
|
| 6115 |
|
|
attached to a program. The ID field contains the GDB identifier
|
| 6116 |
|
|
of the thread group. The PID field contains process identifier,
|
| 6117 |
|
|
specific to the operating system.
|
| 6118 |
|
|
|
| 6119 |
|
|
`=thread-group-exited,id="ID"'
|
| 6120 |
|
|
A thread group is no longer associated with a running program,
|
| 6121 |
|
|
either because the program has exited, or because it was detached
|
| 6122 |
|
|
from. The ID field contains the GDB identifier of the thread
|
| 6123 |
|
|
group.
|
| 6124 |
|
|
|
| 6125 |
|
|
`=thread-created,id="ID",group-id="GID"'
|
| 6126 |
|
|
`=thread-exited,id="ID",group-id="GID"'
|
| 6127 |
|
|
A thread either was created, or has exited. The ID field contains
|
| 6128 |
|
|
the GDB identifier of the thread. The GID field identifies the
|
| 6129 |
|
|
thread group this thread belongs to.
|
| 6130 |
|
|
|
| 6131 |
|
|
`=thread-selected,id="ID"'
|
| 6132 |
|
|
Informs that the selected thread was changed as result of the last
|
| 6133 |
|
|
command. This notification is not emitted as result of
|
| 6134 |
|
|
`-thread-select' command but is emitted whenever an MI command
|
| 6135 |
|
|
that is not documented to change the selected thread actually
|
| 6136 |
|
|
changes it. In particular, invoking, directly or indirectly (via
|
| 6137 |
|
|
user-defined command), the CLI `thread' command, will generate
|
| 6138 |
|
|
this notification.
|
| 6139 |
|
|
|
| 6140 |
|
|
We suggest that in response to this notification, front ends
|
| 6141 |
|
|
highlight the selected thread and cause subsequent commands to
|
| 6142 |
|
|
apply to that thread.
|
| 6143 |
|
|
|
| 6144 |
|
|
`=library-loaded,...'
|
| 6145 |
|
|
Reports that a new library file was loaded by the program. This
|
| 6146 |
|
|
notification has 4 fields--ID, TARGET-NAME, HOST-NAME, and
|
| 6147 |
|
|
SYMBOLS-LOADED. The ID field is an opaque identifier of the
|
| 6148 |
|
|
library. For remote debugging case, TARGET-NAME and HOST-NAME
|
| 6149 |
|
|
fields give the name of the library file on the target, and on the
|
| 6150 |
|
|
host respectively. For native debugging, both those fields have
|
| 6151 |
|
|
the same value. The SYMBOLS-LOADED field reports if the debug
|
| 6152 |
|
|
symbols for this library are loaded. The THREAD-GROUP field, if
|
| 6153 |
|
|
present, specifies the id of the thread group in whose context the
|
| 6154 |
|
|
library was loaded. If the field is absent, it means the library
|
| 6155 |
|
|
was loaded in the context of all present thread groups.
|
| 6156 |
|
|
|
| 6157 |
|
|
`=library-unloaded,...'
|
| 6158 |
|
|
Reports that a library was unloaded by the program. This
|
| 6159 |
|
|
notification has 3 fields--ID, TARGET-NAME and HOST-NAME with the
|
| 6160 |
|
|
same meaning as for the `=library-loaded' notification. The
|
| 6161 |
|
|
THREAD-GROUP field, if present, specifies the id of the thread
|
| 6162 |
|
|
group in whose context the library was unloaded. If the field is
|
| 6163 |
|
|
absent, it means the library was unloaded in the context of all
|
| 6164 |
|
|
present thread groups.
|
| 6165 |
|
|
|
| 6166 |
|
|
|
| 6167 |
|
|
|
| 6168 |
|
|
File: gdb.info, Node: GDB/MI Frame Information, Next: GDB/MI Thread Information, Prev: GDB/MI Async Records, Up: GDB/MI Output Records
|
| 6169 |
|
|
|
| 6170 |
|
|
27.5.4 GDB/MI Frame Information
|
| 6171 |
|
|
-------------------------------
|
| 6172 |
|
|
|
| 6173 |
|
|
Response from many MI commands includes an information about stack
|
| 6174 |
|
|
frame. This information is a tuple that may have the following fields:
|
| 6175 |
|
|
|
| 6176 |
|
|
`level'
|
| 6177 |
|
|
The level of the stack frame. The innermost frame has the level of
|
| 6178 |
|
|
zero. This field is always present.
|
| 6179 |
|
|
|
| 6180 |
|
|
`func'
|
| 6181 |
|
|
The name of the function corresponding to the frame. This field
|
| 6182 |
|
|
may be absent if GDB is unable to determine the function name.
|
| 6183 |
|
|
|
| 6184 |
|
|
`addr'
|
| 6185 |
|
|
The code address for the frame. This field is always present.
|
| 6186 |
|
|
|
| 6187 |
|
|
`file'
|
| 6188 |
|
|
The name of the source files that correspond to the frame's code
|
| 6189 |
|
|
address. This field may be absent.
|
| 6190 |
|
|
|
| 6191 |
|
|
`line'
|
| 6192 |
|
|
The source line corresponding to the frames' code address. This
|
| 6193 |
|
|
field may be absent.
|
| 6194 |
|
|
|
| 6195 |
|
|
`from'
|
| 6196 |
|
|
The name of the binary file (either executable or shared library)
|
| 6197 |
|
|
the corresponds to the frame's code address. This field may be
|
| 6198 |
|
|
absent.
|
| 6199 |
|
|
|
| 6200 |
|
|
|
| 6201 |
|
|
|
| 6202 |
|
|
File: gdb.info, Node: GDB/MI Thread Information, Prev: GDB/MI Frame Information, Up: GDB/MI Output Records
|
| 6203 |
|
|
|
| 6204 |
|
|
27.5.5 GDB/MI Thread Information
|
| 6205 |
|
|
--------------------------------
|
| 6206 |
|
|
|
| 6207 |
|
|
Whenever GDB has to report an information about a thread, it uses a
|
| 6208 |
|
|
tuple with the following fields:
|
| 6209 |
|
|
|
| 6210 |
|
|
`id'
|
| 6211 |
|
|
The numeric id assigned to the thread by GDB. This field is
|
| 6212 |
|
|
always present.
|
| 6213 |
|
|
|
| 6214 |
|
|
`target-id'
|
| 6215 |
|
|
Target-specific string identifying the thread. This field is
|
| 6216 |
|
|
always present.
|
| 6217 |
|
|
|
| 6218 |
|
|
`details'
|
| 6219 |
|
|
Additional information about the thread provided by the target.
|
| 6220 |
|
|
It is supposed to be human-readable and not interpreted by the
|
| 6221 |
|
|
frontend. This field is optional.
|
| 6222 |
|
|
|
| 6223 |
|
|
`state'
|
| 6224 |
|
|
Either `stopped' or `running', depending on whether the thread is
|
| 6225 |
|
|
presently running. This field is always present.
|
| 6226 |
|
|
|
| 6227 |
|
|
`core'
|
| 6228 |
|
|
The value of this field is an integer number of the processor core
|
| 6229 |
|
|
the thread was last seen on. This field is optional.
|
| 6230 |
|
|
|
| 6231 |
|
|
|
| 6232 |
|
|
File: gdb.info, Node: GDB/MI Simple Examples, Next: GDB/MI Command Description Format, Prev: GDB/MI Output Records, Up: GDB/MI
|
| 6233 |
|
|
|
| 6234 |
|
|
27.6 Simple Examples of GDB/MI Interaction
|
| 6235 |
|
|
==========================================
|
| 6236 |
|
|
|
| 6237 |
|
|
This subsection presents several simple examples of interaction using
|
| 6238 |
|
|
the GDB/MI interface. In these examples, `->' means that the following
|
| 6239 |
|
|
line is passed to GDB/MI as input, while `<-' means the output received
|
| 6240 |
|
|
from GDB/MI.
|
| 6241 |
|
|
|
| 6242 |
|
|
Note the line breaks shown in the examples are here only for
|
| 6243 |
|
|
readability, they don't appear in the real output.
|
| 6244 |
|
|
|
| 6245 |
|
|
Setting a Breakpoint
|
| 6246 |
|
|
--------------------
|
| 6247 |
|
|
|
| 6248 |
|
|
Setting a breakpoint generates synchronous output which contains
|
| 6249 |
|
|
detailed information of the breakpoint.
|
| 6250 |
|
|
|
| 6251 |
|
|
-> -break-insert main
|
| 6252 |
|
|
<- ^done,bkpt={number="1",type="breakpoint",disp="keep",
|
| 6253 |
|
|
enabled="y",addr="0x08048564",func="main",file="myprog.c",
|
| 6254 |
|
|
fullname="/home/nickrob/myprog.c",line="68",times="0"}
|
| 6255 |
|
|
<- (gdb)
|
| 6256 |
|
|
|
| 6257 |
|
|
Program Execution
|
| 6258 |
|
|
-----------------
|
| 6259 |
|
|
|
| 6260 |
|
|
Program execution generates asynchronous records and MI gives the
|
| 6261 |
|
|
reason that execution stopped.
|
| 6262 |
|
|
|
| 6263 |
|
|
-> -exec-run
|
| 6264 |
|
|
<- ^running
|
| 6265 |
|
|
<- (gdb)
|
| 6266 |
|
|
<- *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
|
| 6267 |
|
|
frame={addr="0x08048564",func="main",
|
| 6268 |
|
|
args=[{name="argc",value="1"},{name="argv",value="0xbfc4d4d4"}],
|
| 6269 |
|
|
file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"}
|
| 6270 |
|
|
<- (gdb)
|
| 6271 |
|
|
-> -exec-continue
|
| 6272 |
|
|
<- ^running
|
| 6273 |
|
|
<- (gdb)
|
| 6274 |
|
|
<- *stopped,reason="exited-normally"
|
| 6275 |
|
|
<- (gdb)
|
| 6276 |
|
|
|
| 6277 |
|
|
Quitting GDB
|
| 6278 |
|
|
------------
|
| 6279 |
|
|
|
| 6280 |
|
|
Quitting GDB just prints the result class `^exit'.
|
| 6281 |
|
|
|
| 6282 |
|
|
-> (gdb)
|
| 6283 |
|
|
<- -gdb-exit
|
| 6284 |
|
|
<- ^exit
|
| 6285 |
|
|
|
| 6286 |
|
|
Please note that `^exit' is printed immediately, but it might take
|
| 6287 |
|
|
some time for GDB to actually exit. During that time, GDB performs
|
| 6288 |
|
|
necessary cleanups, including killing programs being debugged or
|
| 6289 |
|
|
disconnecting from debug hardware, so the frontend should wait till GDB
|
| 6290 |
|
|
exits and should only forcibly kill GDB if it fails to exit in
|
| 6291 |
|
|
reasonable time.
|
| 6292 |
|
|
|
| 6293 |
|
|
A Bad Command
|
| 6294 |
|
|
-------------
|
| 6295 |
|
|
|
| 6296 |
|
|
Here's what happens if you pass a non-existent command:
|
| 6297 |
|
|
|
| 6298 |
|
|
-> -rubbish
|
| 6299 |
|
|
<- ^error,msg="Undefined MI command: rubbish"
|
| 6300 |
|
|
<- (gdb)
|
| 6301 |
|
|
|
| 6302 |
|
|
|
| 6303 |
|
|
File: gdb.info, Node: GDB/MI Command Description Format, Next: GDB/MI Breakpoint Commands, Prev: GDB/MI Simple Examples, Up: GDB/MI
|
| 6304 |
|
|
|
| 6305 |
|
|
27.7 GDB/MI Command Description Format
|
| 6306 |
|
|
======================================
|
| 6307 |
|
|
|
| 6308 |
|
|
The remaining sections describe blocks of commands. Each block of
|
| 6309 |
|
|
commands is laid out in a fashion similar to this section.
|
| 6310 |
|
|
|
| 6311 |
|
|
Motivation
|
| 6312 |
|
|
----------
|
| 6313 |
|
|
|
| 6314 |
|
|
The motivation for this collection of commands.
|
| 6315 |
|
|
|
| 6316 |
|
|
Introduction
|
| 6317 |
|
|
------------
|
| 6318 |
|
|
|
| 6319 |
|
|
A brief introduction to this collection of commands as a whole.
|
| 6320 |
|
|
|
| 6321 |
|
|
Commands
|
| 6322 |
|
|
--------
|
| 6323 |
|
|
|
| 6324 |
|
|
For each command in the block, the following is described:
|
| 6325 |
|
|
|
| 6326 |
|
|
Synopsis
|
| 6327 |
|
|
........
|
| 6328 |
|
|
|
| 6329 |
|
|
-command ARGS...
|
| 6330 |
|
|
|
| 6331 |
|
|
Result
|
| 6332 |
|
|
......
|
| 6333 |
|
|
|
| 6334 |
|
|
GDB Command
|
| 6335 |
|
|
...........
|
| 6336 |
|
|
|
| 6337 |
|
|
The corresponding GDB CLI command(s), if any.
|
| 6338 |
|
|
|
| 6339 |
|
|
Example
|
| 6340 |
|
|
.......
|
| 6341 |
|
|
|
| 6342 |
|
|
Example(s) formatted for readability. Some of the described commands
|
| 6343 |
|
|
have not been implemented yet and these are labeled N.A. (not
|
| 6344 |
|
|
available).
|
| 6345 |
|
|
|
| 6346 |
|
|
|
| 6347 |
|
|
File: gdb.info, Node: GDB/MI Breakpoint Commands, Next: GDB/MI Program Context, Prev: GDB/MI Command Description Format, Up: GDB/MI
|
| 6348 |
|
|
|
| 6349 |
|
|
27.8 GDB/MI Breakpoint Commands
|
| 6350 |
|
|
===============================
|
| 6351 |
|
|
|
| 6352 |
|
|
This section documents GDB/MI commands for manipulating breakpoints.
|
| 6353 |
|
|
|
| 6354 |
|
|
The `-break-after' Command
|
| 6355 |
|
|
--------------------------
|
| 6356 |
|
|
|
| 6357 |
|
|
Synopsis
|
| 6358 |
|
|
........
|
| 6359 |
|
|
|
| 6360 |
|
|
-break-after NUMBER COUNT
|
| 6361 |
|
|
|
| 6362 |
|
|
The breakpoint number NUMBER is not in effect until it has been hit
|
| 6363 |
|
|
COUNT times. To see how this is reflected in the output of the
|
| 6364 |
|
|
`-break-list' command, see the description of the `-break-list' command
|
| 6365 |
|
|
below.
|
| 6366 |
|
|
|
| 6367 |
|
|
GDB Command
|
| 6368 |
|
|
...........
|
| 6369 |
|
|
|
| 6370 |
|
|
The corresponding GDB command is `ignore'.
|
| 6371 |
|
|
|
| 6372 |
|
|
Example
|
| 6373 |
|
|
.......
|
| 6374 |
|
|
|
| 6375 |
|
|
(gdb)
|
| 6376 |
|
|
-break-insert main
|
| 6377 |
|
|
^done,bkpt={number="1",type="breakpoint",disp="keep",
|
| 6378 |
|
|
enabled="y",addr="0x000100d0",func="main",file="hello.c",
|
| 6379 |
|
|
fullname="/home/foo/hello.c",line="5",times="0"}
|
| 6380 |
|
|
(gdb)
|
| 6381 |
|
|
-break-after 1 3
|
| 6382 |
|
|
~
|
| 6383 |
|
|
^done
|
| 6384 |
|
|
(gdb)
|
| 6385 |
|
|
-break-list
|
| 6386 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
| 6387 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6388 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6389 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6390 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6391 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6392 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6393 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
| 6394 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
| 6395 |
|
|
line="5",times="0",ignore="3"}]}
|
| 6396 |
|
|
(gdb)
|
| 6397 |
|
|
|
| 6398 |
|
|
The `-break-commands' Command
|
| 6399 |
|
|
-----------------------------
|
| 6400 |
|
|
|
| 6401 |
|
|
Synopsis
|
| 6402 |
|
|
........
|
| 6403 |
|
|
|
| 6404 |
|
|
-break-commands NUMBER [ COMMAND1 ... COMMANDN ]
|
| 6405 |
|
|
|
| 6406 |
|
|
Specifies the CLI commands that should be executed when breakpoint
|
| 6407 |
|
|
NUMBER is hit. The parameters COMMAND1 to COMMANDN are the commands.
|
| 6408 |
|
|
If no command is specified, any previously-set commands are cleared.
|
| 6409 |
|
|
*Note Break Commands::. Typical use of this functionality is tracing a
|
| 6410 |
|
|
program, that is, printing of values of some variables whenever
|
| 6411 |
|
|
breakpoint is hit and then continuing.
|
| 6412 |
|
|
|
| 6413 |
|
|
GDB Command
|
| 6414 |
|
|
...........
|
| 6415 |
|
|
|
| 6416 |
|
|
The corresponding GDB command is `commands'.
|
| 6417 |
|
|
|
| 6418 |
|
|
Example
|
| 6419 |
|
|
.......
|
| 6420 |
|
|
|
| 6421 |
|
|
(gdb)
|
| 6422 |
|
|
-break-insert main
|
| 6423 |
|
|
^done,bkpt={number="1",type="breakpoint",disp="keep",
|
| 6424 |
|
|
enabled="y",addr="0x000100d0",func="main",file="hello.c",
|
| 6425 |
|
|
fullname="/home/foo/hello.c",line="5",times="0"}
|
| 6426 |
|
|
(gdb)
|
| 6427 |
|
|
-break-commands 1 "print v" "continue"
|
| 6428 |
|
|
^done
|
| 6429 |
|
|
(gdb)
|
| 6430 |
|
|
|
| 6431 |
|
|
The `-break-condition' Command
|
| 6432 |
|
|
------------------------------
|
| 6433 |
|
|
|
| 6434 |
|
|
Synopsis
|
| 6435 |
|
|
........
|
| 6436 |
|
|
|
| 6437 |
|
|
-break-condition NUMBER EXPR
|
| 6438 |
|
|
|
| 6439 |
|
|
Breakpoint NUMBER will stop the program only if the condition in
|
| 6440 |
|
|
EXPR is true. The condition becomes part of the `-break-list' output
|
| 6441 |
|
|
(see the description of the `-break-list' command below).
|
| 6442 |
|
|
|
| 6443 |
|
|
GDB Command
|
| 6444 |
|
|
...........
|
| 6445 |
|
|
|
| 6446 |
|
|
The corresponding GDB command is `condition'.
|
| 6447 |
|
|
|
| 6448 |
|
|
Example
|
| 6449 |
|
|
.......
|
| 6450 |
|
|
|
| 6451 |
|
|
(gdb)
|
| 6452 |
|
|
-break-condition 1 1
|
| 6453 |
|
|
^done
|
| 6454 |
|
|
(gdb)
|
| 6455 |
|
|
-break-list
|
| 6456 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
| 6457 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6458 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6459 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6460 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6461 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6462 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6463 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
| 6464 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
| 6465 |
|
|
line="5",cond="1",times="0",ignore="3"}]}
|
| 6466 |
|
|
(gdb)
|
| 6467 |
|
|
|
| 6468 |
|
|
The `-break-delete' Command
|
| 6469 |
|
|
---------------------------
|
| 6470 |
|
|
|
| 6471 |
|
|
Synopsis
|
| 6472 |
|
|
........
|
| 6473 |
|
|
|
| 6474 |
|
|
-break-delete ( BREAKPOINT )+
|
| 6475 |
|
|
|
| 6476 |
|
|
Delete the breakpoint(s) whose number(s) are specified in the
|
| 6477 |
|
|
argument list. This is obviously reflected in the breakpoint list.
|
| 6478 |
|
|
|
| 6479 |
|
|
GDB Command
|
| 6480 |
|
|
...........
|
| 6481 |
|
|
|
| 6482 |
|
|
The corresponding GDB command is `delete'.
|
| 6483 |
|
|
|
| 6484 |
|
|
Example
|
| 6485 |
|
|
.......
|
| 6486 |
|
|
|
| 6487 |
|
|
(gdb)
|
| 6488 |
|
|
-break-delete 1
|
| 6489 |
|
|
^done
|
| 6490 |
|
|
(gdb)
|
| 6491 |
|
|
-break-list
|
| 6492 |
|
|
^done,BreakpointTable={nr_rows="0",nr_cols="6",
|
| 6493 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6494 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6495 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6496 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6497 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6498 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6499 |
|
|
body=[]}
|
| 6500 |
|
|
(gdb)
|
| 6501 |
|
|
|
| 6502 |
|
|
The `-break-disable' Command
|
| 6503 |
|
|
----------------------------
|
| 6504 |
|
|
|
| 6505 |
|
|
Synopsis
|
| 6506 |
|
|
........
|
| 6507 |
|
|
|
| 6508 |
|
|
-break-disable ( BREAKPOINT )+
|
| 6509 |
|
|
|
| 6510 |
|
|
Disable the named BREAKPOINT(s). The field `enabled' in the break
|
| 6511 |
|
|
list is now set to `n' for the named BREAKPOINT(s).
|
| 6512 |
|
|
|
| 6513 |
|
|
GDB Command
|
| 6514 |
|
|
...........
|
| 6515 |
|
|
|
| 6516 |
|
|
The corresponding GDB command is `disable'.
|
| 6517 |
|
|
|
| 6518 |
|
|
Example
|
| 6519 |
|
|
.......
|
| 6520 |
|
|
|
| 6521 |
|
|
(gdb)
|
| 6522 |
|
|
-break-disable 2
|
| 6523 |
|
|
^done
|
| 6524 |
|
|
(gdb)
|
| 6525 |
|
|
-break-list
|
| 6526 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
| 6527 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6528 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6529 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6530 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6531 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6532 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6533 |
|
|
body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="n",
|
| 6534 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
| 6535 |
|
|
line="5",times="0"}]}
|
| 6536 |
|
|
(gdb)
|
| 6537 |
|
|
|
| 6538 |
|
|
The `-break-enable' Command
|
| 6539 |
|
|
---------------------------
|
| 6540 |
|
|
|
| 6541 |
|
|
Synopsis
|
| 6542 |
|
|
........
|
| 6543 |
|
|
|
| 6544 |
|
|
-break-enable ( BREAKPOINT )+
|
| 6545 |
|
|
|
| 6546 |
|
|
Enable (previously disabled) BREAKPOINT(s).
|
| 6547 |
|
|
|
| 6548 |
|
|
GDB Command
|
| 6549 |
|
|
...........
|
| 6550 |
|
|
|
| 6551 |
|
|
The corresponding GDB command is `enable'.
|
| 6552 |
|
|
|
| 6553 |
|
|
Example
|
| 6554 |
|
|
.......
|
| 6555 |
|
|
|
| 6556 |
|
|
(gdb)
|
| 6557 |
|
|
-break-enable 2
|
| 6558 |
|
|
^done
|
| 6559 |
|
|
(gdb)
|
| 6560 |
|
|
-break-list
|
| 6561 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
| 6562 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6563 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6564 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6565 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6566 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6567 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6568 |
|
|
body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
|
| 6569 |
|
|
addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
|
| 6570 |
|
|
line="5",times="0"}]}
|
| 6571 |
|
|
(gdb)
|
| 6572 |
|
|
|
| 6573 |
|
|
The `-break-info' Command
|
| 6574 |
|
|
-------------------------
|
| 6575 |
|
|
|
| 6576 |
|
|
Synopsis
|
| 6577 |
|
|
........
|
| 6578 |
|
|
|
| 6579 |
|
|
-break-info BREAKPOINT
|
| 6580 |
|
|
|
| 6581 |
|
|
Get information about a single breakpoint.
|
| 6582 |
|
|
|
| 6583 |
|
|
GDB Command
|
| 6584 |
|
|
...........
|
| 6585 |
|
|
|
| 6586 |
|
|
The corresponding GDB command is `info break BREAKPOINT'.
|
| 6587 |
|
|
|
| 6588 |
|
|
Example
|
| 6589 |
|
|
.......
|
| 6590 |
|
|
|
| 6591 |
|
|
N.A.
|
| 6592 |
|
|
|
| 6593 |
|
|
The `-break-insert' Command
|
| 6594 |
|
|
---------------------------
|
| 6595 |
|
|
|
| 6596 |
|
|
Synopsis
|
| 6597 |
|
|
........
|
| 6598 |
|
|
|
| 6599 |
|
|
-break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ]
|
| 6600 |
|
|
[ -c CONDITION ] [ -i IGNORE-COUNT ]
|
| 6601 |
|
|
[ -p THREAD ] [ LOCATION ]
|
| 6602 |
|
|
|
| 6603 |
|
|
If specified, LOCATION, can be one of:
|
| 6604 |
|
|
|
| 6605 |
|
|
* function
|
| 6606 |
|
|
|
| 6607 |
|
|
* filename:linenum
|
| 6608 |
|
|
|
| 6609 |
|
|
* filename:function
|
| 6610 |
|
|
|
| 6611 |
|
|
* *address
|
| 6612 |
|
|
|
| 6613 |
|
|
The possible optional parameters of this command are:
|
| 6614 |
|
|
|
| 6615 |
|
|
`-t'
|
| 6616 |
|
|
Insert a temporary breakpoint.
|
| 6617 |
|
|
|
| 6618 |
|
|
`-h'
|
| 6619 |
|
|
Insert a hardware breakpoint.
|
| 6620 |
|
|
|
| 6621 |
|
|
`-c CONDITION'
|
| 6622 |
|
|
Make the breakpoint conditional on CONDITION.
|
| 6623 |
|
|
|
| 6624 |
|
|
`-i IGNORE-COUNT'
|
| 6625 |
|
|
Initialize the IGNORE-COUNT.
|
| 6626 |
|
|
|
| 6627 |
|
|
`-f'
|
| 6628 |
|
|
If LOCATION cannot be parsed (for example if it refers to unknown
|
| 6629 |
|
|
files or functions), create a pending breakpoint. Without this
|
| 6630 |
|
|
flag, GDB will report an error, and won't create a breakpoint, if
|
| 6631 |
|
|
LOCATION cannot be parsed.
|
| 6632 |
|
|
|
| 6633 |
|
|
`-d'
|
| 6634 |
|
|
Create a disabled breakpoint.
|
| 6635 |
|
|
|
| 6636 |
|
|
`-a'
|
| 6637 |
|
|
Create a tracepoint. *Note Tracepoints::. When this parameter is
|
| 6638 |
|
|
used together with `-h', a fast tracepoint is created.
|
| 6639 |
|
|
|
| 6640 |
|
|
Result
|
| 6641 |
|
|
......
|
| 6642 |
|
|
|
| 6643 |
|
|
The result is in the form:
|
| 6644 |
|
|
|
| 6645 |
|
|
^done,bkpt={number="NUMBER",type="TYPE",disp="del"|"keep",
|
| 6646 |
|
|
enabled="y"|"n",addr="HEX",func="FUNCNAME",file="FILENAME",
|
| 6647 |
|
|
fullname="FULL_FILENAME",line="LINENO",[thread="THREADNO,]
|
| 6648 |
|
|
times="TIMES"}
|
| 6649 |
|
|
|
| 6650 |
|
|
where NUMBER is the GDB number for this breakpoint, FUNCNAME is the
|
| 6651 |
|
|
name of the function where the breakpoint was inserted, FILENAME is the
|
| 6652 |
|
|
name of the source file which contains this function, LINENO is the
|
| 6653 |
|
|
source line number within that file and TIMES the number of times that
|
| 6654 |
|
|
the breakpoint has been hit (always 0 for -break-insert but may be
|
| 6655 |
|
|
greater for -break-info or -break-list which use the same output).
|
| 6656 |
|
|
|
| 6657 |
|
|
Note: this format is open to change.
|
| 6658 |
|
|
|
| 6659 |
|
|
GDB Command
|
| 6660 |
|
|
...........
|
| 6661 |
|
|
|
| 6662 |
|
|
The corresponding GDB commands are `break', `tbreak', `hbreak',
|
| 6663 |
|
|
`thbreak', and `rbreak'.
|
| 6664 |
|
|
|
| 6665 |
|
|
Example
|
| 6666 |
|
|
.......
|
| 6667 |
|
|
|
| 6668 |
|
|
(gdb)
|
| 6669 |
|
|
-break-insert main
|
| 6670 |
|
|
^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",
|
| 6671 |
|
|
fullname="/home/foo/recursive2.c,line="4",times="0"}
|
| 6672 |
|
|
(gdb)
|
| 6673 |
|
|
-break-insert -t foo
|
| 6674 |
|
|
^done,bkpt={number="2",addr="0x00010774",file="recursive2.c",
|
| 6675 |
|
|
fullname="/home/foo/recursive2.c,line="11",times="0"}
|
| 6676 |
|
|
(gdb)
|
| 6677 |
|
|
-break-list
|
| 6678 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
| 6679 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6680 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6681 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6682 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6683 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6684 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6685 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
| 6686 |
|
|
addr="0x0001072c", func="main",file="recursive2.c",
|
| 6687 |
|
|
fullname="/home/foo/recursive2.c,"line="4",times="0"},
|
| 6688 |
|
|
bkpt={number="2",type="breakpoint",disp="del",enabled="y",
|
| 6689 |
|
|
addr="0x00010774",func="foo",file="recursive2.c",
|
| 6690 |
|
|
fullname="/home/foo/recursive2.c",line="11",times="0"}]}
|
| 6691 |
|
|
(gdb)
|
| 6692 |
|
|
-break-insert -r foo.*
|
| 6693 |
|
|
~int foo(int, int);
|
| 6694 |
|
|
^done,bkpt={number="3",addr="0x00010774",file="recursive2.c,
|
| 6695 |
|
|
"fullname="/home/foo/recursive2.c",line="11",times="0"}
|
| 6696 |
|
|
(gdb)
|
| 6697 |
|
|
|
| 6698 |
|
|
The `-break-list' Command
|
| 6699 |
|
|
-------------------------
|
| 6700 |
|
|
|
| 6701 |
|
|
Synopsis
|
| 6702 |
|
|
........
|
| 6703 |
|
|
|
| 6704 |
|
|
-break-list
|
| 6705 |
|
|
|
| 6706 |
|
|
Displays the list of inserted breakpoints, showing the following
|
| 6707 |
|
|
fields:
|
| 6708 |
|
|
|
| 6709 |
|
|
`Number'
|
| 6710 |
|
|
number of the breakpoint
|
| 6711 |
|
|
|
| 6712 |
|
|
`Type'
|
| 6713 |
|
|
type of the breakpoint: `breakpoint' or `watchpoint'
|
| 6714 |
|
|
|
| 6715 |
|
|
`Disposition'
|
| 6716 |
|
|
should the breakpoint be deleted or disabled when it is hit: `keep'
|
| 6717 |
|
|
or `nokeep'
|
| 6718 |
|
|
|
| 6719 |
|
|
`Enabled'
|
| 6720 |
|
|
is the breakpoint enabled or no: `y' or `n'
|
| 6721 |
|
|
|
| 6722 |
|
|
`Address'
|
| 6723 |
|
|
memory location at which the breakpoint is set
|
| 6724 |
|
|
|
| 6725 |
|
|
`What'
|
| 6726 |
|
|
logical location of the breakpoint, expressed by function name,
|
| 6727 |
|
|
file name, line number
|
| 6728 |
|
|
|
| 6729 |
|
|
`Times'
|
| 6730 |
|
|
number of times the breakpoint has been hit
|
| 6731 |
|
|
|
| 6732 |
|
|
If there are no breakpoints or watchpoints, the `BreakpointTable'
|
| 6733 |
|
|
`body' field is an empty list.
|
| 6734 |
|
|
|
| 6735 |
|
|
GDB Command
|
| 6736 |
|
|
...........
|
| 6737 |
|
|
|
| 6738 |
|
|
The corresponding GDB command is `info break'.
|
| 6739 |
|
|
|
| 6740 |
|
|
Example
|
| 6741 |
|
|
.......
|
| 6742 |
|
|
|
| 6743 |
|
|
(gdb)
|
| 6744 |
|
|
-break-list
|
| 6745 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
| 6746 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6747 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6748 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6749 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6750 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6751 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6752 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
| 6753 |
|
|
addr="0x000100d0",func="main",file="hello.c",line="5",times="0"},
|
| 6754 |
|
|
bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
|
| 6755 |
|
|
addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c",
|
| 6756 |
|
|
line="13",times="0"}]}
|
| 6757 |
|
|
(gdb)
|
| 6758 |
|
|
|
| 6759 |
|
|
Here's an example of the result when there are no breakpoints:
|
| 6760 |
|
|
|
| 6761 |
|
|
(gdb)
|
| 6762 |
|
|
-break-list
|
| 6763 |
|
|
^done,BreakpointTable={nr_rows="0",nr_cols="6",
|
| 6764 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6765 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6766 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6767 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6768 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6769 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6770 |
|
|
body=[]}
|
| 6771 |
|
|
(gdb)
|
| 6772 |
|
|
|
| 6773 |
|
|
The `-break-passcount' Command
|
| 6774 |
|
|
------------------------------
|
| 6775 |
|
|
|
| 6776 |
|
|
Synopsis
|
| 6777 |
|
|
........
|
| 6778 |
|
|
|
| 6779 |
|
|
-break-passcount TRACEPOINT-NUMBER PASSCOUNT
|
| 6780 |
|
|
|
| 6781 |
|
|
Set the passcount for tracepoint TRACEPOINT-NUMBER to PASSCOUNT. If
|
| 6782 |
|
|
the breakpoint referred to by TRACEPOINT-NUMBER is not a tracepoint,
|
| 6783 |
|
|
error is emitted. This corresponds to CLI command `passcount'.
|
| 6784 |
|
|
|
| 6785 |
|
|
The `-break-watch' Command
|
| 6786 |
|
|
--------------------------
|
| 6787 |
|
|
|
| 6788 |
|
|
Synopsis
|
| 6789 |
|
|
........
|
| 6790 |
|
|
|
| 6791 |
|
|
-break-watch [ -a | -r ]
|
| 6792 |
|
|
|
| 6793 |
|
|
Create a watchpoint. With the `-a' option it will create an
|
| 6794 |
|
|
"access" watchpoint, i.e., a watchpoint that triggers either on a read
|
| 6795 |
|
|
from or on a write to the memory location. With the `-r' option, the
|
| 6796 |
|
|
watchpoint created is a "read" watchpoint, i.e., it will trigger only
|
| 6797 |
|
|
when the memory location is accessed for reading. Without either of
|
| 6798 |
|
|
the options, the watchpoint created is a regular watchpoint, i.e., it
|
| 6799 |
|
|
will trigger when the memory location is accessed for writing. *Note
|
| 6800 |
|
|
Setting Watchpoints: Set Watchpoints.
|
| 6801 |
|
|
|
| 6802 |
|
|
Note that `-break-list' will report a single list of watchpoints and
|
| 6803 |
|
|
breakpoints inserted.
|
| 6804 |
|
|
|
| 6805 |
|
|
GDB Command
|
| 6806 |
|
|
...........
|
| 6807 |
|
|
|
| 6808 |
|
|
The corresponding GDB commands are `watch', `awatch', and `rwatch'.
|
| 6809 |
|
|
|
| 6810 |
|
|
Example
|
| 6811 |
|
|
.......
|
| 6812 |
|
|
|
| 6813 |
|
|
Setting a watchpoint on a variable in the `main' function:
|
| 6814 |
|
|
|
| 6815 |
|
|
(gdb)
|
| 6816 |
|
|
-break-watch x
|
| 6817 |
|
|
^done,wpt={number="2",exp="x"}
|
| 6818 |
|
|
(gdb)
|
| 6819 |
|
|
-exec-continue
|
| 6820 |
|
|
^running
|
| 6821 |
|
|
(gdb)
|
| 6822 |
|
|
*stopped,reason="watchpoint-trigger",wpt={number="2",exp="x"},
|
| 6823 |
|
|
value={old="-268439212",new="55"},
|
| 6824 |
|
|
frame={func="main",args=[],file="recursive2.c",
|
| 6825 |
|
|
fullname="/home/foo/bar/recursive2.c",line="5"}
|
| 6826 |
|
|
(gdb)
|
| 6827 |
|
|
|
| 6828 |
|
|
Setting a watchpoint on a variable local to a function. GDB will
|
| 6829 |
|
|
stop the program execution twice: first for the variable changing
|
| 6830 |
|
|
value, then for the watchpoint going out of scope.
|
| 6831 |
|
|
|
| 6832 |
|
|
(gdb)
|
| 6833 |
|
|
-break-watch C
|
| 6834 |
|
|
^done,wpt={number="5",exp="C"}
|
| 6835 |
|
|
(gdb)
|
| 6836 |
|
|
-exec-continue
|
| 6837 |
|
|
^running
|
| 6838 |
|
|
(gdb)
|
| 6839 |
|
|
*stopped,reason="watchpoint-trigger",
|
| 6840 |
|
|
wpt={number="5",exp="C"},value={old="-276895068",new="3"},
|
| 6841 |
|
|
frame={func="callee4",args=[],
|
| 6842 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 6843 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
|
| 6844 |
|
|
(gdb)
|
| 6845 |
|
|
-exec-continue
|
| 6846 |
|
|
^running
|
| 6847 |
|
|
(gdb)
|
| 6848 |
|
|
*stopped,reason="watchpoint-scope",wpnum="5",
|
| 6849 |
|
|
frame={func="callee3",args=[{name="strarg",
|
| 6850 |
|
|
value="0x11940 \"A string argument.\""}],
|
| 6851 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 6852 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
|
| 6853 |
|
|
(gdb)
|
| 6854 |
|
|
|
| 6855 |
|
|
Listing breakpoints and watchpoints, at different points in the
|
| 6856 |
|
|
program execution. Note that once the watchpoint goes out of scope, it
|
| 6857 |
|
|
is deleted.
|
| 6858 |
|
|
|
| 6859 |
|
|
(gdb)
|
| 6860 |
|
|
-break-watch C
|
| 6861 |
|
|
^done,wpt={number="2",exp="C"}
|
| 6862 |
|
|
(gdb)
|
| 6863 |
|
|
-break-list
|
| 6864 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
| 6865 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6866 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6867 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6868 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6869 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6870 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6871 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
| 6872 |
|
|
addr="0x00010734",func="callee4",
|
| 6873 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 6874 |
|
|
fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",times="1"},
|
| 6875 |
|
|
bkpt={number="2",type="watchpoint",disp="keep",
|
| 6876 |
|
|
enabled="y",addr="",what="C",times="0"}]}
|
| 6877 |
|
|
(gdb)
|
| 6878 |
|
|
-exec-continue
|
| 6879 |
|
|
^running
|
| 6880 |
|
|
(gdb)
|
| 6881 |
|
|
*stopped,reason="watchpoint-trigger",wpt={number="2",exp="C"},
|
| 6882 |
|
|
value={old="-276895068",new="3"},
|
| 6883 |
|
|
frame={func="callee4",args=[],
|
| 6884 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 6885 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
|
| 6886 |
|
|
(gdb)
|
| 6887 |
|
|
-break-list
|
| 6888 |
|
|
^done,BreakpointTable={nr_rows="2",nr_cols="6",
|
| 6889 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6890 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6891 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6892 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6893 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6894 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6895 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
| 6896 |
|
|
addr="0x00010734",func="callee4",
|
| 6897 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 6898 |
|
|
fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"},
|
| 6899 |
|
|
bkpt={number="2",type="watchpoint",disp="keep",
|
| 6900 |
|
|
enabled="y",addr="",what="C",times="-5"}]}
|
| 6901 |
|
|
(gdb)
|
| 6902 |
|
|
-exec-continue
|
| 6903 |
|
|
^running
|
| 6904 |
|
|
^done,reason="watchpoint-scope",wpnum="2",
|
| 6905 |
|
|
frame={func="callee3",args=[{name="strarg",
|
| 6906 |
|
|
value="0x11940 \"A string argument.\""}],
|
| 6907 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 6908 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
|
| 6909 |
|
|
(gdb)
|
| 6910 |
|
|
-break-list
|
| 6911 |
|
|
^done,BreakpointTable={nr_rows="1",nr_cols="6",
|
| 6912 |
|
|
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
|
| 6913 |
|
|
{width="14",alignment="-1",col_name="type",colhdr="Type"},
|
| 6914 |
|
|
{width="4",alignment="-1",col_name="disp",colhdr="Disp"},
|
| 6915 |
|
|
{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
|
| 6916 |
|
|
{width="10",alignment="-1",col_name="addr",colhdr="Address"},
|
| 6917 |
|
|
{width="40",alignment="2",col_name="what",colhdr="What"}],
|
| 6918 |
|
|
body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
|
| 6919 |
|
|
addr="0x00010734",func="callee4",
|
| 6920 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 6921 |
|
|
fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
|
| 6922 |
|
|
times="1"}]}
|
| 6923 |
|
|
(gdb)
|
| 6924 |
|
|
|
| 6925 |
|
|
|
| 6926 |
|
|
File: gdb.info, Node: GDB/MI Program Context, Next: GDB/MI Thread Commands, Prev: GDB/MI Breakpoint Commands, Up: GDB/MI
|
| 6927 |
|
|
|
| 6928 |
|
|
27.9 GDB/MI Program Context
|
| 6929 |
|
|
============================
|
| 6930 |
|
|
|
| 6931 |
|
|
The `-exec-arguments' Command
|
| 6932 |
|
|
-----------------------------
|
| 6933 |
|
|
|
| 6934 |
|
|
Synopsis
|
| 6935 |
|
|
........
|
| 6936 |
|
|
|
| 6937 |
|
|
-exec-arguments ARGS
|
| 6938 |
|
|
|
| 6939 |
|
|
Set the inferior program arguments, to be used in the next
|
| 6940 |
|
|
`-exec-run'.
|
| 6941 |
|
|
|
| 6942 |
|
|
GDB Command
|
| 6943 |
|
|
...........
|
| 6944 |
|
|
|
| 6945 |
|
|
The corresponding GDB command is `set args'.
|
| 6946 |
|
|
|
| 6947 |
|
|
Example
|
| 6948 |
|
|
.......
|
| 6949 |
|
|
|
| 6950 |
|
|
(gdb)
|
| 6951 |
|
|
-exec-arguments -v word
|
| 6952 |
|
|
^done
|
| 6953 |
|
|
(gdb)
|
| 6954 |
|
|
|
| 6955 |
|
|
The `-environment-cd' Command
|
| 6956 |
|
|
-----------------------------
|
| 6957 |
|
|
|
| 6958 |
|
|
Synopsis
|
| 6959 |
|
|
........
|
| 6960 |
|
|
|
| 6961 |
|
|
-environment-cd PATHDIR
|
| 6962 |
|
|
|
| 6963 |
|
|
Set GDB's working directory.
|
| 6964 |
|
|
|
| 6965 |
|
|
GDB Command
|
| 6966 |
|
|
...........
|
| 6967 |
|
|
|
| 6968 |
|
|
The corresponding GDB command is `cd'.
|
| 6969 |
|
|
|
| 6970 |
|
|
Example
|
| 6971 |
|
|
.......
|
| 6972 |
|
|
|
| 6973 |
|
|
(gdb)
|
| 6974 |
|
|
-environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
|
| 6975 |
|
|
^done
|
| 6976 |
|
|
(gdb)
|
| 6977 |
|
|
|
| 6978 |
|
|
The `-environment-directory' Command
|
| 6979 |
|
|
------------------------------------
|
| 6980 |
|
|
|
| 6981 |
|
|
Synopsis
|
| 6982 |
|
|
........
|
| 6983 |
|
|
|
| 6984 |
|
|
-environment-directory [ -r ] [ PATHDIR ]+
|
| 6985 |
|
|
|
| 6986 |
|
|
Add directories PATHDIR to beginning of search path for source files.
|
| 6987 |
|
|
If the `-r' option is used, the search path is reset to the default
|
| 6988 |
|
|
search path. If directories PATHDIR are supplied in addition to the
|
| 6989 |
|
|
`-r' option, the search path is first reset and then addition occurs as
|
| 6990 |
|
|
normal. Multiple directories may be specified, separated by blanks.
|
| 6991 |
|
|
Specifying multiple directories in a single command results in the
|
| 6992 |
|
|
directories added to the beginning of the search path in the same order
|
| 6993 |
|
|
they were presented in the command. If blanks are needed as part of a
|
| 6994 |
|
|
directory name, double-quotes should be used around the name. In the
|
| 6995 |
|
|
command output, the path will show up separated by the system
|
| 6996 |
|
|
directory-separator character. The directory-separator character must
|
| 6997 |
|
|
not be used in any directory name. If no directories are specified,
|
| 6998 |
|
|
the current search path is displayed.
|
| 6999 |
|
|
|
| 7000 |
|
|
GDB Command
|
| 7001 |
|
|
...........
|
| 7002 |
|
|
|
| 7003 |
|
|
The corresponding GDB command is `dir'.
|
| 7004 |
|
|
|
| 7005 |
|
|
Example
|
| 7006 |
|
|
.......
|
| 7007 |
|
|
|
| 7008 |
|
|
(gdb)
|
| 7009 |
|
|
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
|
| 7010 |
|
|
^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
|
| 7011 |
|
|
(gdb)
|
| 7012 |
|
|
-environment-directory ""
|
| 7013 |
|
|
^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
|
| 7014 |
|
|
(gdb)
|
| 7015 |
|
|
-environment-directory -r /home/jjohnstn/src/gdb /usr/src
|
| 7016 |
|
|
^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
|
| 7017 |
|
|
(gdb)
|
| 7018 |
|
|
-environment-directory -r
|
| 7019 |
|
|
^done,source-path="$cdir:$cwd"
|
| 7020 |
|
|
(gdb)
|
| 7021 |
|
|
|
| 7022 |
|
|
The `-environment-path' Command
|
| 7023 |
|
|
-------------------------------
|
| 7024 |
|
|
|
| 7025 |
|
|
Synopsis
|
| 7026 |
|
|
........
|
| 7027 |
|
|
|
| 7028 |
|
|
-environment-path [ -r ] [ PATHDIR ]+
|
| 7029 |
|
|
|
| 7030 |
|
|
Add directories PATHDIR to beginning of search path for object files.
|
| 7031 |
|
|
If the `-r' option is used, the search path is reset to the original
|
| 7032 |
|
|
search path that existed at gdb start-up. If directories PATHDIR are
|
| 7033 |
|
|
supplied in addition to the `-r' option, the search path is first reset
|
| 7034 |
|
|
and then addition occurs as normal. Multiple directories may be
|
| 7035 |
|
|
specified, separated by blanks. Specifying multiple directories in a
|
| 7036 |
|
|
single command results in the directories added to the beginning of the
|
| 7037 |
|
|
search path in the same order they were presented in the command. If
|
| 7038 |
|
|
blanks are needed as part of a directory name, double-quotes should be
|
| 7039 |
|
|
used around the name. In the command output, the path will show up
|
| 7040 |
|
|
separated by the system directory-separator character. The
|
| 7041 |
|
|
directory-separator character must not be used in any directory name.
|
| 7042 |
|
|
If no directories are specified, the current path is displayed.
|
| 7043 |
|
|
|
| 7044 |
|
|
GDB Command
|
| 7045 |
|
|
...........
|
| 7046 |
|
|
|
| 7047 |
|
|
The corresponding GDB command is `path'.
|
| 7048 |
|
|
|
| 7049 |
|
|
Example
|
| 7050 |
|
|
.......
|
| 7051 |
|
|
|
| 7052 |
|
|
(gdb)
|
| 7053 |
|
|
-environment-path
|
| 7054 |
|
|
^done,path="/usr/bin"
|
| 7055 |
|
|
(gdb)
|
| 7056 |
|
|
-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
|
| 7057 |
|
|
^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
|
| 7058 |
|
|
(gdb)
|
| 7059 |
|
|
-environment-path -r /usr/local/bin
|
| 7060 |
|
|
^done,path="/usr/local/bin:/usr/bin"
|
| 7061 |
|
|
(gdb)
|
| 7062 |
|
|
|
| 7063 |
|
|
The `-environment-pwd' Command
|
| 7064 |
|
|
------------------------------
|
| 7065 |
|
|
|
| 7066 |
|
|
Synopsis
|
| 7067 |
|
|
........
|
| 7068 |
|
|
|
| 7069 |
|
|
-environment-pwd
|
| 7070 |
|
|
|
| 7071 |
|
|
Show the current working directory.
|
| 7072 |
|
|
|
| 7073 |
|
|
GDB Command
|
| 7074 |
|
|
...........
|
| 7075 |
|
|
|
| 7076 |
|
|
The corresponding GDB command is `pwd'.
|
| 7077 |
|
|
|
| 7078 |
|
|
Example
|
| 7079 |
|
|
.......
|
| 7080 |
|
|
|
| 7081 |
|
|
(gdb)
|
| 7082 |
|
|
-environment-pwd
|
| 7083 |
|
|
^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
|
| 7084 |
|
|
(gdb)
|
| 7085 |
|
|
|
| 7086 |
|
|
|
| 7087 |
|
|
File: gdb.info, Node: GDB/MI Thread Commands, Next: GDB/MI Program Execution, Prev: GDB/MI Program Context, Up: GDB/MI
|
| 7088 |
|
|
|
| 7089 |
|
|
27.10 GDB/MI Thread Commands
|
| 7090 |
|
|
============================
|
| 7091 |
|
|
|
| 7092 |
|
|
The `-thread-info' Command
|
| 7093 |
|
|
--------------------------
|
| 7094 |
|
|
|
| 7095 |
|
|
Synopsis
|
| 7096 |
|
|
........
|
| 7097 |
|
|
|
| 7098 |
|
|
-thread-info [ THREAD-ID ]
|
| 7099 |
|
|
|
| 7100 |
|
|
Reports information about either a specific thread, if the THREAD-ID
|
| 7101 |
|
|
parameter is present, or about all threads. When printing information
|
| 7102 |
|
|
about all threads, also reports the current thread.
|
| 7103 |
|
|
|
| 7104 |
|
|
GDB Command
|
| 7105 |
|
|
...........
|
| 7106 |
|
|
|
| 7107 |
|
|
The `info thread' command prints the same information about all threads.
|
| 7108 |
|
|
|
| 7109 |
|
|
Example
|
| 7110 |
|
|
.......
|
| 7111 |
|
|
|
| 7112 |
|
|
-thread-info
|
| 7113 |
|
|
^done,threads=[
|
| 7114 |
|
|
{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
|
| 7115 |
|
|
frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]},state="running"},
|
| 7116 |
|
|
{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
|
| 7117 |
|
|
frame={level="0",addr="0x0804891f",func="foo",args=[{name="i",value="10"}],
|
| 7118 |
|
|
file="/tmp/a.c",fullname="/tmp/a.c",line="158"},state="running"}],
|
| 7119 |
|
|
current-thread-id="1"
|
| 7120 |
|
|
(gdb)
|
| 7121 |
|
|
|
| 7122 |
|
|
The `state' field may have the following values:
|
| 7123 |
|
|
|
| 7124 |
|
|
`stopped'
|
| 7125 |
|
|
The thread is stopped. Frame information is available for stopped
|
| 7126 |
|
|
threads.
|
| 7127 |
|
|
|
| 7128 |
|
|
`running'
|
| 7129 |
|
|
The thread is running. There's no frame information for running
|
| 7130 |
|
|
threads.
|
| 7131 |
|
|
|
| 7132 |
|
|
|
| 7133 |
|
|
The `-thread-list-ids' Command
|
| 7134 |
|
|
------------------------------
|
| 7135 |
|
|
|
| 7136 |
|
|
Synopsis
|
| 7137 |
|
|
........
|
| 7138 |
|
|
|
| 7139 |
|
|
-thread-list-ids
|
| 7140 |
|
|
|
| 7141 |
|
|
Produces a list of the currently known GDB thread ids. At the end
|
| 7142 |
|
|
of the list it also prints the total number of such threads.
|
| 7143 |
|
|
|
| 7144 |
|
|
This command is retained for historical reasons, the `-thread-info'
|
| 7145 |
|
|
command should be used instead.
|
| 7146 |
|
|
|
| 7147 |
|
|
GDB Command
|
| 7148 |
|
|
...........
|
| 7149 |
|
|
|
| 7150 |
|
|
Part of `info threads' supplies the same information.
|
| 7151 |
|
|
|
| 7152 |
|
|
Example
|
| 7153 |
|
|
.......
|
| 7154 |
|
|
|
| 7155 |
|
|
(gdb)
|
| 7156 |
|
|
-thread-list-ids
|
| 7157 |
|
|
^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"},
|
| 7158 |
|
|
current-thread-id="1",number-of-threads="3"
|
| 7159 |
|
|
(gdb)
|
| 7160 |
|
|
|
| 7161 |
|
|
The `-thread-select' Command
|
| 7162 |
|
|
----------------------------
|
| 7163 |
|
|
|
| 7164 |
|
|
Synopsis
|
| 7165 |
|
|
........
|
| 7166 |
|
|
|
| 7167 |
|
|
-thread-select THREADNUM
|
| 7168 |
|
|
|
| 7169 |
|
|
Make THREADNUM the current thread. It prints the number of the new
|
| 7170 |
|
|
current thread, and the topmost frame for that thread.
|
| 7171 |
|
|
|
| 7172 |
|
|
This command is deprecated in favor of explicitly using the
|
| 7173 |
|
|
`--thread' option to each command.
|
| 7174 |
|
|
|
| 7175 |
|
|
GDB Command
|
| 7176 |
|
|
...........
|
| 7177 |
|
|
|
| 7178 |
|
|
The corresponding GDB command is `thread'.
|
| 7179 |
|
|
|
| 7180 |
|
|
Example
|
| 7181 |
|
|
.......
|
| 7182 |
|
|
|
| 7183 |
|
|
(gdb)
|
| 7184 |
|
|
-exec-next
|
| 7185 |
|
|
^running
|
| 7186 |
|
|
(gdb)
|
| 7187 |
|
|
*stopped,reason="end-stepping-range",thread-id="2",line="187",
|
| 7188 |
|
|
file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
|
| 7189 |
|
|
(gdb)
|
| 7190 |
|
|
-thread-list-ids
|
| 7191 |
|
|
^done,
|
| 7192 |
|
|
thread-ids={thread-id="3",thread-id="2",thread-id="1"},
|
| 7193 |
|
|
number-of-threads="3"
|
| 7194 |
|
|
(gdb)
|
| 7195 |
|
|
-thread-select 3
|
| 7196 |
|
|
^done,new-thread-id="3",
|
| 7197 |
|
|
frame={level="0",func="vprintf",
|
| 7198 |
|
|
args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""},
|
| 7199 |
|
|
{name="arg",value="0x2"}],file="vprintf.c",line="31"}
|
| 7200 |
|
|
(gdb)
|
| 7201 |
|
|
|
| 7202 |
|
|
|
| 7203 |
|
|
File: gdb.info, Node: GDB/MI Program Execution, Next: GDB/MI Stack Manipulation, Prev: GDB/MI Thread Commands, Up: GDB/MI
|
| 7204 |
|
|
|
| 7205 |
|
|
27.11 GDB/MI Program Execution
|
| 7206 |
|
|
==============================
|
| 7207 |
|
|
|
| 7208 |
|
|
These are the asynchronous commands which generate the out-of-band
|
| 7209 |
|
|
record `*stopped'. Currently GDB only really executes asynchronously
|
| 7210 |
|
|
with remote targets and this interaction is mimicked in other cases.
|
| 7211 |
|
|
|
| 7212 |
|
|
The `-exec-continue' Command
|
| 7213 |
|
|
----------------------------
|
| 7214 |
|
|
|
| 7215 |
|
|
Synopsis
|
| 7216 |
|
|
........
|
| 7217 |
|
|
|
| 7218 |
|
|
-exec-continue [--reverse] [--all|--thread-group N]
|
| 7219 |
|
|
|
| 7220 |
|
|
Resumes the execution of the inferior program, which will continue
|
| 7221 |
|
|
to execute until it reaches a debugger stop event. If the `--reverse'
|
| 7222 |
|
|
option is specified, execution resumes in reverse until it reaches a
|
| 7223 |
|
|
stop event. Stop events may include
|
| 7224 |
|
|
* breakpoints or watchpoints
|
| 7225 |
|
|
|
| 7226 |
|
|
* signals or exceptions
|
| 7227 |
|
|
|
| 7228 |
|
|
* the end of the process (or its beginning under `--reverse')
|
| 7229 |
|
|
|
| 7230 |
|
|
* the end or beginning of a replay log if one is being used.
|
| 7231 |
|
|
In all-stop mode (*note All-Stop Mode::), may resume only one
|
| 7232 |
|
|
thread, or all threads, depending on the value of the
|
| 7233 |
|
|
`scheduler-locking' variable. If `--all' is specified, all threads (in
|
| 7234 |
|
|
all inferiors) will be resumed. The `--all' option is ignored in
|
| 7235 |
|
|
all-stop mode. If the `--thread-group' options is specified, then all
|
| 7236 |
|
|
threads in that thread group are resumed.
|
| 7237 |
|
|
|
| 7238 |
|
|
GDB Command
|
| 7239 |
|
|
...........
|
| 7240 |
|
|
|
| 7241 |
|
|
The corresponding GDB corresponding is `continue'.
|
| 7242 |
|
|
|
| 7243 |
|
|
Example
|
| 7244 |
|
|
.......
|
| 7245 |
|
|
|
| 7246 |
|
|
-exec-continue
|
| 7247 |
|
|
^running
|
| 7248 |
|
|
(gdb)
|
| 7249 |
|
|
@Hello world
|
| 7250 |
|
|
*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={
|
| 7251 |
|
|
func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c",
|
| 7252 |
|
|
line="13"}
|
| 7253 |
|
|
(gdb)
|
| 7254 |
|
|
|
| 7255 |
|
|
The `-exec-finish' Command
|
| 7256 |
|
|
--------------------------
|
| 7257 |
|
|
|
| 7258 |
|
|
Synopsis
|
| 7259 |
|
|
........
|
| 7260 |
|
|
|
| 7261 |
|
|
-exec-finish [--reverse]
|
| 7262 |
|
|
|
| 7263 |
|
|
Resumes the execution of the inferior program until the current
|
| 7264 |
|
|
function is exited. Displays the results returned by the function. If
|
| 7265 |
|
|
the `--reverse' option is specified, resumes the reverse execution of
|
| 7266 |
|
|
the inferior program until the point where current function was called.
|
| 7267 |
|
|
|
| 7268 |
|
|
GDB Command
|
| 7269 |
|
|
...........
|
| 7270 |
|
|
|
| 7271 |
|
|
The corresponding GDB command is `finish'.
|
| 7272 |
|
|
|
| 7273 |
|
|
Example
|
| 7274 |
|
|
.......
|
| 7275 |
|
|
|
| 7276 |
|
|
Function returning `void'.
|
| 7277 |
|
|
|
| 7278 |
|
|
-exec-finish
|
| 7279 |
|
|
^running
|
| 7280 |
|
|
(gdb)
|
| 7281 |
|
|
@hello from foo
|
| 7282 |
|
|
*stopped,reason="function-finished",frame={func="main",args=[],
|
| 7283 |
|
|
file="hello.c",fullname="/home/foo/bar/hello.c",line="7"}
|
| 7284 |
|
|
(gdb)
|
| 7285 |
|
|
|
| 7286 |
|
|
Function returning other than `void'. The name of the internal GDB
|
| 7287 |
|
|
variable storing the result is printed, together with the value itself.
|
| 7288 |
|
|
|
| 7289 |
|
|
-exec-finish
|
| 7290 |
|
|
^running
|
| 7291 |
|
|
(gdb)
|
| 7292 |
|
|
*stopped,reason="function-finished",frame={addr="0x000107b0",func="foo",
|
| 7293 |
|
|
args=[{name="a",value="1"],{name="b",value="9"}},
|
| 7294 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7295 |
|
|
gdb-result-var="$1",return-value="0"
|
| 7296 |
|
|
(gdb)
|
| 7297 |
|
|
|
| 7298 |
|
|
The `-exec-interrupt' Command
|
| 7299 |
|
|
-----------------------------
|
| 7300 |
|
|
|
| 7301 |
|
|
Synopsis
|
| 7302 |
|
|
........
|
| 7303 |
|
|
|
| 7304 |
|
|
-exec-interrupt [--all|--thread-group N]
|
| 7305 |
|
|
|
| 7306 |
|
|
Interrupts the background execution of the target. Note how the
|
| 7307 |
|
|
token associated with the stop message is the one for the execution
|
| 7308 |
|
|
command that has been interrupted. The token for the interrupt itself
|
| 7309 |
|
|
only appears in the `^done' output. If the user is trying to interrupt
|
| 7310 |
|
|
a non-running program, an error message will be printed.
|
| 7311 |
|
|
|
| 7312 |
|
|
Note that when asynchronous execution is enabled, this command is
|
| 7313 |
|
|
asynchronous just like other execution commands. That is, first the
|
| 7314 |
|
|
`^done' response will be printed, and the target stop will be reported
|
| 7315 |
|
|
after that using the `*stopped' notification.
|
| 7316 |
|
|
|
| 7317 |
|
|
In non-stop mode, only the context thread is interrupted by default.
|
| 7318 |
|
|
All threads (in all inferiors) will be interrupted if the `--all'
|
| 7319 |
|
|
option is specified. If the `--thread-group' option is specified, all
|
| 7320 |
|
|
threads in that group will be interrupted.
|
| 7321 |
|
|
|
| 7322 |
|
|
GDB Command
|
| 7323 |
|
|
...........
|
| 7324 |
|
|
|
| 7325 |
|
|
The corresponding GDB command is `interrupt'.
|
| 7326 |
|
|
|
| 7327 |
|
|
Example
|
| 7328 |
|
|
.......
|
| 7329 |
|
|
|
| 7330 |
|
|
(gdb)
|
| 7331 |
|
|
111-exec-continue
|
| 7332 |
|
|
111^running
|
| 7333 |
|
|
|
| 7334 |
|
|
(gdb)
|
| 7335 |
|
|
222-exec-interrupt
|
| 7336 |
|
|
222^done
|
| 7337 |
|
|
(gdb)
|
| 7338 |
|
|
111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
|
| 7339 |
|
|
frame={addr="0x00010140",func="foo",args=[],file="try.c",
|
| 7340 |
|
|
fullname="/home/foo/bar/try.c",line="13"}
|
| 7341 |
|
|
(gdb)
|
| 7342 |
|
|
|
| 7343 |
|
|
(gdb)
|
| 7344 |
|
|
-exec-interrupt
|
| 7345 |
|
|
^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
|
| 7346 |
|
|
(gdb)
|
| 7347 |
|
|
|
| 7348 |
|
|
The `-exec-jump' Command
|
| 7349 |
|
|
------------------------
|
| 7350 |
|
|
|
| 7351 |
|
|
Synopsis
|
| 7352 |
|
|
........
|
| 7353 |
|
|
|
| 7354 |
|
|
-exec-jump LOCATION
|
| 7355 |
|
|
|
| 7356 |
|
|
Resumes execution of the inferior program at the location specified
|
| 7357 |
|
|
by parameter. *Note Specify Location::, for a description of the
|
| 7358 |
|
|
different forms of LOCATION.
|
| 7359 |
|
|
|
| 7360 |
|
|
GDB Command
|
| 7361 |
|
|
...........
|
| 7362 |
|
|
|
| 7363 |
|
|
The corresponding GDB command is `jump'.
|
| 7364 |
|
|
|
| 7365 |
|
|
Example
|
| 7366 |
|
|
.......
|
| 7367 |
|
|
|
| 7368 |
|
|
-exec-jump foo.c:10
|
| 7369 |
|
|
*running,thread-id="all"
|
| 7370 |
|
|
^running
|
| 7371 |
|
|
|
| 7372 |
|
|
The `-exec-next' Command
|
| 7373 |
|
|
------------------------
|
| 7374 |
|
|
|
| 7375 |
|
|
Synopsis
|
| 7376 |
|
|
........
|
| 7377 |
|
|
|
| 7378 |
|
|
-exec-next [--reverse]
|
| 7379 |
|
|
|
| 7380 |
|
|
Resumes execution of the inferior program, stopping when the
|
| 7381 |
|
|
beginning of the next source line is reached.
|
| 7382 |
|
|
|
| 7383 |
|
|
If the `--reverse' option is specified, resumes reverse execution of
|
| 7384 |
|
|
the inferior program, stopping at the beginning of the previous source
|
| 7385 |
|
|
line. If you issue this command on the first line of a function, it
|
| 7386 |
|
|
will take you back to the caller of that function, to the source line
|
| 7387 |
|
|
where the function was called.
|
| 7388 |
|
|
|
| 7389 |
|
|
GDB Command
|
| 7390 |
|
|
...........
|
| 7391 |
|
|
|
| 7392 |
|
|
The corresponding GDB command is `next'.
|
| 7393 |
|
|
|
| 7394 |
|
|
Example
|
| 7395 |
|
|
.......
|
| 7396 |
|
|
|
| 7397 |
|
|
-exec-next
|
| 7398 |
|
|
^running
|
| 7399 |
|
|
(gdb)
|
| 7400 |
|
|
*stopped,reason="end-stepping-range",line="8",file="hello.c"
|
| 7401 |
|
|
(gdb)
|
| 7402 |
|
|
|
| 7403 |
|
|
The `-exec-next-instruction' Command
|
| 7404 |
|
|
------------------------------------
|
| 7405 |
|
|
|
| 7406 |
|
|
Synopsis
|
| 7407 |
|
|
........
|
| 7408 |
|
|
|
| 7409 |
|
|
-exec-next-instruction [--reverse]
|
| 7410 |
|
|
|
| 7411 |
|
|
Executes one machine instruction. If the instruction is a function
|
| 7412 |
|
|
call, continues until the function returns. If the program stops at an
|
| 7413 |
|
|
instruction in the middle of a source line, the address will be printed
|
| 7414 |
|
|
as well.
|
| 7415 |
|
|
|
| 7416 |
|
|
If the `--reverse' option is specified, resumes reverse execution of
|
| 7417 |
|
|
the inferior program, stopping at the previous instruction. If the
|
| 7418 |
|
|
previously executed instruction was a return from another function, it
|
| 7419 |
|
|
will continue to execute in reverse until the call to that function
|
| 7420 |
|
|
(from the current stack frame) is reached.
|
| 7421 |
|
|
|
| 7422 |
|
|
GDB Command
|
| 7423 |
|
|
...........
|
| 7424 |
|
|
|
| 7425 |
|
|
The corresponding GDB command is `nexti'.
|
| 7426 |
|
|
|
| 7427 |
|
|
Example
|
| 7428 |
|
|
.......
|
| 7429 |
|
|
|
| 7430 |
|
|
(gdb)
|
| 7431 |
|
|
-exec-next-instruction
|
| 7432 |
|
|
^running
|
| 7433 |
|
|
|
| 7434 |
|
|
(gdb)
|
| 7435 |
|
|
*stopped,reason="end-stepping-range",
|
| 7436 |
|
|
addr="0x000100d4",line="5",file="hello.c"
|
| 7437 |
|
|
(gdb)
|
| 7438 |
|
|
|
| 7439 |
|
|
The `-exec-return' Command
|
| 7440 |
|
|
--------------------------
|
| 7441 |
|
|
|
| 7442 |
|
|
Synopsis
|
| 7443 |
|
|
........
|
| 7444 |
|
|
|
| 7445 |
|
|
-exec-return
|
| 7446 |
|
|
|
| 7447 |
|
|
Makes current function return immediately. Doesn't execute the
|
| 7448 |
|
|
inferior. Displays the new current frame.
|
| 7449 |
|
|
|
| 7450 |
|
|
GDB Command
|
| 7451 |
|
|
...........
|
| 7452 |
|
|
|
| 7453 |
|
|
The corresponding GDB command is `return'.
|
| 7454 |
|
|
|
| 7455 |
|
|
Example
|
| 7456 |
|
|
.......
|
| 7457 |
|
|
|
| 7458 |
|
|
(gdb)
|
| 7459 |
|
|
200-break-insert callee4
|
| 7460 |
|
|
200^done,bkpt={number="1",addr="0x00010734",
|
| 7461 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
|
| 7462 |
|
|
(gdb)
|
| 7463 |
|
|
000-exec-run
|
| 7464 |
|
|
000^running
|
| 7465 |
|
|
(gdb)
|
| 7466 |
|
|
000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
|
| 7467 |
|
|
frame={func="callee4",args=[],
|
| 7468 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7469 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
|
| 7470 |
|
|
(gdb)
|
| 7471 |
|
|
205-break-delete
|
| 7472 |
|
|
205^done
|
| 7473 |
|
|
(gdb)
|
| 7474 |
|
|
111-exec-return
|
| 7475 |
|
|
111^done,frame={level="0",func="callee3",
|
| 7476 |
|
|
args=[{name="strarg",
|
| 7477 |
|
|
value="0x11940 \"A string argument.\""}],
|
| 7478 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7479 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
|
| 7480 |
|
|
(gdb)
|
| 7481 |
|
|
|
| 7482 |
|
|
The `-exec-run' Command
|
| 7483 |
|
|
-----------------------
|
| 7484 |
|
|
|
| 7485 |
|
|
Synopsis
|
| 7486 |
|
|
........
|
| 7487 |
|
|
|
| 7488 |
|
|
-exec-run [--all | --thread-group N]
|
| 7489 |
|
|
|
| 7490 |
|
|
Starts execution of the inferior from the beginning. The inferior
|
| 7491 |
|
|
executes until either a breakpoint is encountered or the program exits.
|
| 7492 |
|
|
In the latter case the output will include an exit code, if the
|
| 7493 |
|
|
program has exited exceptionally.
|
| 7494 |
|
|
|
| 7495 |
|
|
When no option is specified, the current inferior is started. If the
|
| 7496 |
|
|
`--thread-group' option is specified, it should refer to a thread group
|
| 7497 |
|
|
of type `process', and that thread group will be started. If the
|
| 7498 |
|
|
`--all' option is specified, then all inferiors will be started.
|
| 7499 |
|
|
|
| 7500 |
|
|
GDB Command
|
| 7501 |
|
|
...........
|
| 7502 |
|
|
|
| 7503 |
|
|
The corresponding GDB command is `run'.
|
| 7504 |
|
|
|
| 7505 |
|
|
Examples
|
| 7506 |
|
|
........
|
| 7507 |
|
|
|
| 7508 |
|
|
(gdb)
|
| 7509 |
|
|
-break-insert main
|
| 7510 |
|
|
^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"}
|
| 7511 |
|
|
(gdb)
|
| 7512 |
|
|
-exec-run
|
| 7513 |
|
|
^running
|
| 7514 |
|
|
(gdb)
|
| 7515 |
|
|
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
|
| 7516 |
|
|
frame={func="main",args=[],file="recursive2.c",
|
| 7517 |
|
|
fullname="/home/foo/bar/recursive2.c",line="4"}
|
| 7518 |
|
|
(gdb)
|
| 7519 |
|
|
|
| 7520 |
|
|
Program exited normally:
|
| 7521 |
|
|
|
| 7522 |
|
|
(gdb)
|
| 7523 |
|
|
-exec-run
|
| 7524 |
|
|
^running
|
| 7525 |
|
|
(gdb)
|
| 7526 |
|
|
x = 55
|
| 7527 |
|
|
*stopped,reason="exited-normally"
|
| 7528 |
|
|
(gdb)
|
| 7529 |
|
|
|
| 7530 |
|
|
Program exited exceptionally:
|
| 7531 |
|
|
|
| 7532 |
|
|
(gdb)
|
| 7533 |
|
|
-exec-run
|
| 7534 |
|
|
^running
|
| 7535 |
|
|
(gdb)
|
| 7536 |
|
|
x = 55
|
| 7537 |
|
|
*stopped,reason="exited",exit-code="01"
|
| 7538 |
|
|
(gdb)
|
| 7539 |
|
|
|
| 7540 |
|
|
Another way the program can terminate is if it receives a signal
|
| 7541 |
|
|
such as `SIGINT'. In this case, GDB/MI displays this:
|
| 7542 |
|
|
|
| 7543 |
|
|
(gdb)
|
| 7544 |
|
|
*stopped,reason="exited-signalled",signal-name="SIGINT",
|
| 7545 |
|
|
signal-meaning="Interrupt"
|
| 7546 |
|
|
|
| 7547 |
|
|
The `-exec-step' Command
|
| 7548 |
|
|
------------------------
|
| 7549 |
|
|
|
| 7550 |
|
|
Synopsis
|
| 7551 |
|
|
........
|
| 7552 |
|
|
|
| 7553 |
|
|
-exec-step [--reverse]
|
| 7554 |
|
|
|
| 7555 |
|
|
Resumes execution of the inferior program, stopping when the
|
| 7556 |
|
|
beginning of the next source line is reached, if the next source line
|
| 7557 |
|
|
is not a function call. If it is, stop at the first instruction of the
|
| 7558 |
|
|
called function. If the `--reverse' option is specified, resumes
|
| 7559 |
|
|
reverse execution of the inferior program, stopping at the beginning of
|
| 7560 |
|
|
the previously executed source line.
|
| 7561 |
|
|
|
| 7562 |
|
|
GDB Command
|
| 7563 |
|
|
...........
|
| 7564 |
|
|
|
| 7565 |
|
|
The corresponding GDB command is `step'.
|
| 7566 |
|
|
|
| 7567 |
|
|
Example
|
| 7568 |
|
|
.......
|
| 7569 |
|
|
|
| 7570 |
|
|
Stepping into a function:
|
| 7571 |
|
|
|
| 7572 |
|
|
-exec-step
|
| 7573 |
|
|
^running
|
| 7574 |
|
|
(gdb)
|
| 7575 |
|
|
*stopped,reason="end-stepping-range",
|
| 7576 |
|
|
frame={func="foo",args=[{name="a",value="10"},
|
| 7577 |
|
|
{name="b",value="0"}],file="recursive2.c",
|
| 7578 |
|
|
fullname="/home/foo/bar/recursive2.c",line="11"}
|
| 7579 |
|
|
(gdb)
|
| 7580 |
|
|
|
| 7581 |
|
|
Regular stepping:
|
| 7582 |
|
|
|
| 7583 |
|
|
-exec-step
|
| 7584 |
|
|
^running
|
| 7585 |
|
|
(gdb)
|
| 7586 |
|
|
*stopped,reason="end-stepping-range",line="14",file="recursive2.c"
|
| 7587 |
|
|
(gdb)
|
| 7588 |
|
|
|
| 7589 |
|
|
The `-exec-step-instruction' Command
|
| 7590 |
|
|
------------------------------------
|
| 7591 |
|
|
|
| 7592 |
|
|
Synopsis
|
| 7593 |
|
|
........
|
| 7594 |
|
|
|
| 7595 |
|
|
-exec-step-instruction [--reverse]
|
| 7596 |
|
|
|
| 7597 |
|
|
Resumes the inferior which executes one machine instruction. If the
|
| 7598 |
|
|
`--reverse' option is specified, resumes reverse execution of the
|
| 7599 |
|
|
inferior program, stopping at the previously executed instruction. The
|
| 7600 |
|
|
output, once GDB has stopped, will vary depending on whether we have
|
| 7601 |
|
|
stopped in the middle of a source line or not. In the former case, the
|
| 7602 |
|
|
address at which the program stopped will be printed as well.
|
| 7603 |
|
|
|
| 7604 |
|
|
GDB Command
|
| 7605 |
|
|
...........
|
| 7606 |
|
|
|
| 7607 |
|
|
The corresponding GDB command is `stepi'.
|
| 7608 |
|
|
|
| 7609 |
|
|
Example
|
| 7610 |
|
|
.......
|
| 7611 |
|
|
|
| 7612 |
|
|
(gdb)
|
| 7613 |
|
|
-exec-step-instruction
|
| 7614 |
|
|
^running
|
| 7615 |
|
|
|
| 7616 |
|
|
(gdb)
|
| 7617 |
|
|
*stopped,reason="end-stepping-range",
|
| 7618 |
|
|
frame={func="foo",args=[],file="try.c",
|
| 7619 |
|
|
fullname="/home/foo/bar/try.c",line="10"}
|
| 7620 |
|
|
(gdb)
|
| 7621 |
|
|
-exec-step-instruction
|
| 7622 |
|
|
^running
|
| 7623 |
|
|
|
| 7624 |
|
|
(gdb)
|
| 7625 |
|
|
*stopped,reason="end-stepping-range",
|
| 7626 |
|
|
frame={addr="0x000100f4",func="foo",args=[],file="try.c",
|
| 7627 |
|
|
fullname="/home/foo/bar/try.c",line="10"}
|
| 7628 |
|
|
(gdb)
|
| 7629 |
|
|
|
| 7630 |
|
|
The `-exec-until' Command
|
| 7631 |
|
|
-------------------------
|
| 7632 |
|
|
|
| 7633 |
|
|
Synopsis
|
| 7634 |
|
|
........
|
| 7635 |
|
|
|
| 7636 |
|
|
-exec-until [ LOCATION ]
|
| 7637 |
|
|
|
| 7638 |
|
|
Executes the inferior until the LOCATION specified in the argument
|
| 7639 |
|
|
is reached. If there is no argument, the inferior executes until a
|
| 7640 |
|
|
source line greater than the current one is reached. The reason for
|
| 7641 |
|
|
stopping in this case will be `location-reached'.
|
| 7642 |
|
|
|
| 7643 |
|
|
GDB Command
|
| 7644 |
|
|
...........
|
| 7645 |
|
|
|
| 7646 |
|
|
The corresponding GDB command is `until'.
|
| 7647 |
|
|
|
| 7648 |
|
|
Example
|
| 7649 |
|
|
.......
|
| 7650 |
|
|
|
| 7651 |
|
|
(gdb)
|
| 7652 |
|
|
-exec-until recursive2.c:6
|
| 7653 |
|
|
^running
|
| 7654 |
|
|
(gdb)
|
| 7655 |
|
|
x = 55
|
| 7656 |
|
|
*stopped,reason="location-reached",frame={func="main",args=[],
|
| 7657 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6"}
|
| 7658 |
|
|
(gdb)
|
| 7659 |
|
|
|
| 7660 |
|
|
|
| 7661 |
|
|
File: gdb.info, Node: GDB/MI Stack Manipulation, Next: GDB/MI Variable Objects, Prev: GDB/MI Program Execution, Up: GDB/MI
|
| 7662 |
|
|
|
| 7663 |
|
|
27.12 GDB/MI Stack Manipulation Commands
|
| 7664 |
|
|
========================================
|
| 7665 |
|
|
|
| 7666 |
|
|
The `-stack-info-frame' Command
|
| 7667 |
|
|
-------------------------------
|
| 7668 |
|
|
|
| 7669 |
|
|
Synopsis
|
| 7670 |
|
|
........
|
| 7671 |
|
|
|
| 7672 |
|
|
-stack-info-frame
|
| 7673 |
|
|
|
| 7674 |
|
|
Get info on the selected frame.
|
| 7675 |
|
|
|
| 7676 |
|
|
GDB Command
|
| 7677 |
|
|
...........
|
| 7678 |
|
|
|
| 7679 |
|
|
The corresponding GDB command is `info frame' or `frame' (without
|
| 7680 |
|
|
arguments).
|
| 7681 |
|
|
|
| 7682 |
|
|
Example
|
| 7683 |
|
|
.......
|
| 7684 |
|
|
|
| 7685 |
|
|
(gdb)
|
| 7686 |
|
|
-stack-info-frame
|
| 7687 |
|
|
^done,frame={level="1",addr="0x0001076c",func="callee3",
|
| 7688 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7689 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"}
|
| 7690 |
|
|
(gdb)
|
| 7691 |
|
|
|
| 7692 |
|
|
The `-stack-info-depth' Command
|
| 7693 |
|
|
-------------------------------
|
| 7694 |
|
|
|
| 7695 |
|
|
Synopsis
|
| 7696 |
|
|
........
|
| 7697 |
|
|
|
| 7698 |
|
|
-stack-info-depth [ MAX-DEPTH ]
|
| 7699 |
|
|
|
| 7700 |
|
|
Return the depth of the stack. If the integer argument MAX-DEPTH is
|
| 7701 |
|
|
specified, do not count beyond MAX-DEPTH frames.
|
| 7702 |
|
|
|
| 7703 |
|
|
GDB Command
|
| 7704 |
|
|
...........
|
| 7705 |
|
|
|
| 7706 |
|
|
There's no equivalent GDB command.
|
| 7707 |
|
|
|
| 7708 |
|
|
Example
|
| 7709 |
|
|
.......
|
| 7710 |
|
|
|
| 7711 |
|
|
For a stack with frame levels 0 through 11:
|
| 7712 |
|
|
|
| 7713 |
|
|
(gdb)
|
| 7714 |
|
|
-stack-info-depth
|
| 7715 |
|
|
^done,depth="12"
|
| 7716 |
|
|
(gdb)
|
| 7717 |
|
|
-stack-info-depth 4
|
| 7718 |
|
|
^done,depth="4"
|
| 7719 |
|
|
(gdb)
|
| 7720 |
|
|
-stack-info-depth 12
|
| 7721 |
|
|
^done,depth="12"
|
| 7722 |
|
|
(gdb)
|
| 7723 |
|
|
-stack-info-depth 11
|
| 7724 |
|
|
^done,depth="11"
|
| 7725 |
|
|
(gdb)
|
| 7726 |
|
|
-stack-info-depth 13
|
| 7727 |
|
|
^done,depth="12"
|
| 7728 |
|
|
(gdb)
|
| 7729 |
|
|
|
| 7730 |
|
|
The `-stack-list-arguments' Command
|
| 7731 |
|
|
-----------------------------------
|
| 7732 |
|
|
|
| 7733 |
|
|
Synopsis
|
| 7734 |
|
|
........
|
| 7735 |
|
|
|
| 7736 |
|
|
-stack-list-arguments PRINT-VALUES
|
| 7737 |
|
|
[ LOW-FRAME HIGH-FRAME ]
|
| 7738 |
|
|
|
| 7739 |
|
|
Display a list of the arguments for the frames between LOW-FRAME and
|
| 7740 |
|
|
HIGH-FRAME (inclusive). If LOW-FRAME and HIGH-FRAME are not provided,
|
| 7741 |
|
|
list the arguments for the whole call stack. If the two arguments are
|
| 7742 |
|
|
equal, show the single frame at the corresponding level. It is an
|
| 7743 |
|
|
error if LOW-FRAME is larger than the actual number of frames. On the
|
| 7744 |
|
|
other hand, HIGH-FRAME may be larger than the actual number of frames,
|
| 7745 |
|
|
in which case only existing frames will be returned.
|
| 7746 |
|
|
|
| 7747 |
|
|
If PRINT-VALUES is 0 or `--no-values', print only the names of the
|
| 7748 |
|
|
variables; if it is 1 or `--all-values', print also their values; and
|
| 7749 |
|
|
if it is 2 or `--simple-values', print the name, type and value for
|
| 7750 |
|
|
simple data types, and the name and type for arrays, structures and
|
| 7751 |
|
|
unions.
|
| 7752 |
|
|
|
| 7753 |
|
|
Use of this command to obtain arguments in a single frame is
|
| 7754 |
|
|
deprecated in favor of the `-stack-list-variables' command.
|
| 7755 |
|
|
|
| 7756 |
|
|
GDB Command
|
| 7757 |
|
|
...........
|
| 7758 |
|
|
|
| 7759 |
|
|
GDB does not have an equivalent command. `gdbtk' has a `gdb_get_args'
|
| 7760 |
|
|
command which partially overlaps with the functionality of
|
| 7761 |
|
|
`-stack-list-arguments'.
|
| 7762 |
|
|
|
| 7763 |
|
|
Example
|
| 7764 |
|
|
.......
|
| 7765 |
|
|
|
| 7766 |
|
|
(gdb)
|
| 7767 |
|
|
-stack-list-frames
|
| 7768 |
|
|
^done,
|
| 7769 |
|
|
stack=[
|
| 7770 |
|
|
frame={level="0",addr="0x00010734",func="callee4",
|
| 7771 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7772 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"},
|
| 7773 |
|
|
frame={level="1",addr="0x0001076c",func="callee3",
|
| 7774 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7775 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"},
|
| 7776 |
|
|
frame={level="2",addr="0x0001078c",func="callee2",
|
| 7777 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7778 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"},
|
| 7779 |
|
|
frame={level="3",addr="0x000107b4",func="callee1",
|
| 7780 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7781 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"},
|
| 7782 |
|
|
frame={level="4",addr="0x000107e0",func="main",
|
| 7783 |
|
|
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
|
| 7784 |
|
|
fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"}]
|
| 7785 |
|
|
(gdb)
|
| 7786 |
|
|
-stack-list-arguments 0
|
| 7787 |
|
|
^done,
|
| 7788 |
|
|
stack-args=[
|
| 7789 |
|
|
frame={level="0",args=[]},
|
| 7790 |
|
|
frame={level="1",args=[name="strarg"]},
|
| 7791 |
|
|
frame={level="2",args=[name="intarg",name="strarg"]},
|
| 7792 |
|
|
frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]},
|
| 7793 |
|
|
frame={level="4",args=[]}]
|
| 7794 |
|
|
(gdb)
|
| 7795 |
|
|
-stack-list-arguments 1
|
| 7796 |
|
|
^done,
|
| 7797 |
|
|
stack-args=[
|
| 7798 |
|
|
frame={level="0",args=[]},
|
| 7799 |
|
|
frame={level="1",
|
| 7800 |
|
|
args=[{name="strarg",value="0x11940 \"A string argument.\""}]},
|
| 7801 |
|
|
frame={level="2",args=[
|
| 7802 |
|
|
{name="intarg",value="2"},
|
| 7803 |
|
|
{name="strarg",value="0x11940 \"A string argument.\""}]},
|
| 7804 |
|
|
{frame={level="3",args=[
|
| 7805 |
|
|
{name="intarg",value="2"},
|
| 7806 |
|
|
{name="strarg",value="0x11940 \"A string argument.\""},
|
| 7807 |
|
|
{name="fltarg",value="3.5"}]},
|
| 7808 |
|
|
frame={level="4",args=[]}]
|
| 7809 |
|
|
(gdb)
|
| 7810 |
|
|
-stack-list-arguments 0 2 2
|
| 7811 |
|
|
^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}]
|
| 7812 |
|
|
(gdb)
|
| 7813 |
|
|
-stack-list-arguments 1 2 2
|
| 7814 |
|
|
^done,stack-args=[frame={level="2",
|
| 7815 |
|
|
args=[{name="intarg",value="2"},
|
| 7816 |
|
|
{name="strarg",value="0x11940 \"A string argument.\""}]}]
|
| 7817 |
|
|
(gdb)
|
| 7818 |
|
|
|
| 7819 |
|
|
The `-stack-list-frames' Command
|
| 7820 |
|
|
--------------------------------
|
| 7821 |
|
|
|
| 7822 |
|
|
Synopsis
|
| 7823 |
|
|
........
|
| 7824 |
|
|
|
| 7825 |
|
|
-stack-list-frames [ LOW-FRAME HIGH-FRAME ]
|
| 7826 |
|
|
|
| 7827 |
|
|
List the frames currently on the stack. For each frame it displays
|
| 7828 |
|
|
the following info:
|
| 7829 |
|
|
|
| 7830 |
|
|
`LEVEL'
|
| 7831 |
|
|
The frame number, 0 being the topmost frame, i.e., the innermost
|
| 7832 |
|
|
function.
|
| 7833 |
|
|
|
| 7834 |
|
|
`ADDR'
|
| 7835 |
|
|
The `$pc' value for that frame.
|
| 7836 |
|
|
|
| 7837 |
|
|
`FUNC'
|
| 7838 |
|
|
Function name.
|
| 7839 |
|
|
|
| 7840 |
|
|
`FILE'
|
| 7841 |
|
|
File name of the source file where the function lives.
|
| 7842 |
|
|
|
| 7843 |
|
|
`LINE'
|
| 7844 |
|
|
Line number corresponding to the `$pc'.
|
| 7845 |
|
|
|
| 7846 |
|
|
If invoked without arguments, this command prints a backtrace for the
|
| 7847 |
|
|
whole stack. If given two integer arguments, it shows the frames whose
|
| 7848 |
|
|
levels are between the two arguments (inclusive). If the two arguments
|
| 7849 |
|
|
are equal, it shows the single frame at the corresponding level. It is
|
| 7850 |
|
|
an error if LOW-FRAME is larger than the actual number of frames. On
|
| 7851 |
|
|
the other hand, HIGH-FRAME may be larger than the actual number of
|
| 7852 |
|
|
frames, in which case only existing frames will be returned.
|
| 7853 |
|
|
|
| 7854 |
|
|
GDB Command
|
| 7855 |
|
|
...........
|
| 7856 |
|
|
|
| 7857 |
|
|
The corresponding GDB commands are `backtrace' and `where'.
|
| 7858 |
|
|
|
| 7859 |
|
|
Example
|
| 7860 |
|
|
.......
|
| 7861 |
|
|
|
| 7862 |
|
|
Full stack backtrace:
|
| 7863 |
|
|
|
| 7864 |
|
|
(gdb)
|
| 7865 |
|
|
-stack-list-frames
|
| 7866 |
|
|
^done,stack=
|
| 7867 |
|
|
[frame={level="0",addr="0x0001076c",func="foo",
|
| 7868 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11"},
|
| 7869 |
|
|
frame={level="1",addr="0x000107a4",func="foo",
|
| 7870 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7871 |
|
|
frame={level="2",addr="0x000107a4",func="foo",
|
| 7872 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 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 |
|
|
frame={level="6",addr="0x000107a4",func="foo",
|
| 7880 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7881 |
|
|
frame={level="7",addr="0x000107a4",func="foo",
|
| 7882 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7883 |
|
|
frame={level="8",addr="0x000107a4",func="foo",
|
| 7884 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7885 |
|
|
frame={level="9",addr="0x000107a4",func="foo",
|
| 7886 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7887 |
|
|
frame={level="10",addr="0x000107a4",func="foo",
|
| 7888 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7889 |
|
|
frame={level="11",addr="0x00010738",func="main",
|
| 7890 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4"}]
|
| 7891 |
|
|
(gdb)
|
| 7892 |
|
|
|
| 7893 |
|
|
Show frames between LOW_FRAME and HIGH_FRAME:
|
| 7894 |
|
|
|
| 7895 |
|
|
(gdb)
|
| 7896 |
|
|
-stack-list-frames 3 5
|
| 7897 |
|
|
^done,stack=
|
| 7898 |
|
|
[frame={level="3",addr="0x000107a4",func="foo",
|
| 7899 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7900 |
|
|
frame={level="4",addr="0x000107a4",func="foo",
|
| 7901 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
|
| 7902 |
|
|
frame={level="5",addr="0x000107a4",func="foo",
|
| 7903 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
|
| 7904 |
|
|
(gdb)
|
| 7905 |
|
|
|
| 7906 |
|
|
Show a single frame:
|
| 7907 |
|
|
|
| 7908 |
|
|
(gdb)
|
| 7909 |
|
|
-stack-list-frames 3 3
|
| 7910 |
|
|
^done,stack=
|
| 7911 |
|
|
[frame={level="3",addr="0x000107a4",func="foo",
|
| 7912 |
|
|
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
|
| 7913 |
|
|
(gdb)
|
| 7914 |
|
|
|
| 7915 |
|
|
The `-stack-list-locals' Command
|
| 7916 |
|
|
--------------------------------
|
| 7917 |
|
|
|
| 7918 |
|
|
Synopsis
|
| 7919 |
|
|
........
|
| 7920 |
|
|
|
| 7921 |
|
|
-stack-list-locals PRINT-VALUES
|
| 7922 |
|
|
|
| 7923 |
|
|
Display the local variable names for the selected frame. If
|
| 7924 |
|
|
PRINT-VALUES is 0 or `--no-values', print only the names of the
|
| 7925 |
|
|
variables; if it is 1 or `--all-values', print also their values; and
|
| 7926 |
|
|
if it is 2 or `--simple-values', print the name, type and value for
|
| 7927 |
|
|
simple data types, and the name and type for arrays, structures and
|
| 7928 |
|
|
unions. In this last case, a frontend can immediately display the
|
| 7929 |
|
|
value of simple data types and create variable objects for other data
|
| 7930 |
|
|
types when the user wishes to explore their values in more detail.
|
| 7931 |
|
|
|
| 7932 |
|
|
This command is deprecated in favor of the `-stack-list-variables'
|
| 7933 |
|
|
command.
|
| 7934 |
|
|
|
| 7935 |
|
|
GDB Command
|
| 7936 |
|
|
...........
|
| 7937 |
|
|
|
| 7938 |
|
|
`info locals' in GDB, `gdb_get_locals' in `gdbtk'.
|
| 7939 |
|
|
|
| 7940 |
|
|
Example
|
| 7941 |
|
|
.......
|
| 7942 |
|
|
|
| 7943 |
|
|
(gdb)
|
| 7944 |
|
|
-stack-list-locals 0
|
| 7945 |
|
|
^done,locals=[name="A",name="B",name="C"]
|
| 7946 |
|
|
(gdb)
|
| 7947 |
|
|
-stack-list-locals --all-values
|
| 7948 |
|
|
^done,locals=[{name="A",value="1"},{name="B",value="2"},
|
| 7949 |
|
|
{name="C",value="{1, 2, 3}"}]
|
| 7950 |
|
|
-stack-list-locals --simple-values
|
| 7951 |
|
|
^done,locals=[{name="A",type="int",value="1"},
|
| 7952 |
|
|
{name="B",type="int",value="2"},{name="C",type="int [3]"}]
|
| 7953 |
|
|
(gdb)
|
| 7954 |
|
|
|
| 7955 |
|
|
The `-stack-list-variables' Command
|
| 7956 |
|
|
-----------------------------------
|
| 7957 |
|
|
|
| 7958 |
|
|
Synopsis
|
| 7959 |
|
|
........
|
| 7960 |
|
|
|
| 7961 |
|
|
-stack-list-variables PRINT-VALUES
|
| 7962 |
|
|
|
| 7963 |
|
|
Display the names of local variables and function arguments for the
|
| 7964 |
|
|
selected frame. If PRINT-VALUES is 0 or `--no-values', print only the
|
| 7965 |
|
|
names of the variables; if it is 1 or `--all-values', print also their
|
| 7966 |
|
|
values; and if it is 2 or `--simple-values', print the name, type and
|
| 7967 |
|
|
value for simple data types, and the name and type for arrays,
|
| 7968 |
|
|
structures and unions.
|
| 7969 |
|
|
|
| 7970 |
|
|
Example
|
| 7971 |
|
|
.......
|
| 7972 |
|
|
|
| 7973 |
|
|
(gdb)
|
| 7974 |
|
|
-stack-list-variables --thread 1 --frame 0 --all-values
|
| 7975 |
|
|
^done,variables=[{name="x",value="11"},{name="s",value="{a = 1, b = 2}"}]
|
| 7976 |
|
|
(gdb)
|
| 7977 |
|
|
|
| 7978 |
|
|
The `-stack-select-frame' Command
|
| 7979 |
|
|
---------------------------------
|
| 7980 |
|
|
|
| 7981 |
|
|
Synopsis
|
| 7982 |
|
|
........
|
| 7983 |
|
|
|
| 7984 |
|
|
-stack-select-frame FRAMENUM
|
| 7985 |
|
|
|
| 7986 |
|
|
Change the selected frame. Select a different frame FRAMENUM on the
|
| 7987 |
|
|
stack.
|
| 7988 |
|
|
|
| 7989 |
|
|
This command in deprecated in favor of passing the `--frame' option
|
| 7990 |
|
|
to every command.
|
| 7991 |
|
|
|
| 7992 |
|
|
GDB Command
|
| 7993 |
|
|
...........
|
| 7994 |
|
|
|
| 7995 |
|
|
The corresponding GDB commands are `frame', `up', `down',
|
| 7996 |
|
|
`select-frame', `up-silent', and `down-silent'.
|
| 7997 |
|
|
|
| 7998 |
|
|
Example
|
| 7999 |
|
|
.......
|
| 8000 |
|
|
|
| 8001 |
|
|
(gdb)
|
| 8002 |
|
|
-stack-select-frame 2
|
| 8003 |
|
|
^done
|
| 8004 |
|
|
(gdb)
|
| 8005 |
|
|
|
| 8006 |
|
|
|
| 8007 |
|
|
File: gdb.info, Node: GDB/MI Variable Objects, Next: GDB/MI Data Manipulation, Prev: GDB/MI Stack Manipulation, Up: GDB/MI
|
| 8008 |
|
|
|
| 8009 |
|
|
27.13 GDB/MI Variable Objects
|
| 8010 |
|
|
=============================
|
| 8011 |
|
|
|
| 8012 |
|
|
Introduction to Variable Objects
|
| 8013 |
|
|
--------------------------------
|
| 8014 |
|
|
|
| 8015 |
|
|
Variable objects are "object-oriented" MI interface for examining and
|
| 8016 |
|
|
changing values of expressions. Unlike some other MI interfaces that
|
| 8017 |
|
|
work with expressions, variable objects are specifically designed for
|
| 8018 |
|
|
simple and efficient presentation in the frontend. A variable object
|
| 8019 |
|
|
is identified by string name. When a variable object is created, the
|
| 8020 |
|
|
frontend specifies the expression for that variable object. The
|
| 8021 |
|
|
expression can be a simple variable, or it can be an arbitrary complex
|
| 8022 |
|
|
expression, and can even involve CPU registers. After creating a
|
| 8023 |
|
|
variable object, the frontend can invoke other variable object
|
| 8024 |
|
|
operations--for example to obtain or change the value of a variable
|
| 8025 |
|
|
object, or to change display format.
|
| 8026 |
|
|
|
| 8027 |
|
|
Variable objects have hierarchical tree structure. Any variable
|
| 8028 |
|
|
object that corresponds to a composite type, such as structure in C, has
|
| 8029 |
|
|
a number of child variable objects, for example corresponding to each
|
| 8030 |
|
|
element of a structure. A child variable object can itself have
|
| 8031 |
|
|
children, recursively. Recursion ends when we reach leaf variable
|
| 8032 |
|
|
objects, which always have built-in types. Child variable objects are
|
| 8033 |
|
|
created only by explicit request, so if a frontend is not interested in
|
| 8034 |
|
|
the children of a particular variable object, no child will be created.
|
| 8035 |
|
|
|
| 8036 |
|
|
For a leaf variable object it is possible to obtain its value as a
|
| 8037 |
|
|
string, or set the value from a string. String value can be also
|
| 8038 |
|
|
obtained for a non-leaf variable object, but it's generally a string
|
| 8039 |
|
|
that only indicates the type of the object, and does not list its
|
| 8040 |
|
|
contents. Assignment to a non-leaf variable object is not allowed.
|
| 8041 |
|
|
|
| 8042 |
|
|
A frontend does not need to read the values of all variable objects
|
| 8043 |
|
|
each time the program stops. Instead, MI provides an update command
|
| 8044 |
|
|
that lists all variable objects whose values has changed since the last
|
| 8045 |
|
|
update operation. This considerably reduces the amount of data that
|
| 8046 |
|
|
must be transferred to the frontend. As noted above, children variable
|
| 8047 |
|
|
objects are created on demand, and only leaf variable objects have a
|
| 8048 |
|
|
real value. As result, gdb will read target memory only for leaf
|
| 8049 |
|
|
variables that frontend has created.
|
| 8050 |
|
|
|
| 8051 |
|
|
The automatic update is not always desirable. For example, a
|
| 8052 |
|
|
frontend might want to keep a value of some expression for future
|
| 8053 |
|
|
reference, and never update it. For another example, fetching memory
|
| 8054 |
|
|
is relatively slow for embedded targets, so a frontend might want to
|
| 8055 |
|
|
disable automatic update for the variables that are either not visible
|
| 8056 |
|
|
on the screen, or "closed". This is possible using so called "frozen
|
| 8057 |
|
|
variable objects". Such variable objects are never implicitly updated.
|
| 8058 |
|
|
|
| 8059 |
|
|
Variable objects can be either "fixed" or "floating". For the fixed
|
| 8060 |
|
|
variable object, the expression is parsed when the variable object is
|
| 8061 |
|
|
created, including associating identifiers to specific variables. The
|
| 8062 |
|
|
meaning of expression never changes. For a floating variable object
|
| 8063 |
|
|
the values of variables whose names appear in the expressions are
|
| 8064 |
|
|
re-evaluated every time in the context of the current frame. Consider
|
| 8065 |
|
|
this example:
|
| 8066 |
|
|
|
| 8067 |
|
|
void do_work(...)
|
| 8068 |
|
|
{
|
| 8069 |
|
|
struct work_state state;
|
| 8070 |
|
|
|
| 8071 |
|
|
if (...)
|
| 8072 |
|
|
do_work(...);
|
| 8073 |
|
|
}
|
| 8074 |
|
|
|
| 8075 |
|
|
If a fixed variable object for the `state' variable is created in
|
| 8076 |
|
|
this function, and we enter the recursive call, the the variable object
|
| 8077 |
|
|
will report the value of `state' in the top-level `do_work' invocation.
|
| 8078 |
|
|
On the other hand, a floating variable object will report the value of
|
| 8079 |
|
|
`state' in the current frame.
|
| 8080 |
|
|
|
| 8081 |
|
|
If an expression specified when creating a fixed variable object
|
| 8082 |
|
|
refers to a local variable, the variable object becomes bound to the
|
| 8083 |
|
|
thread and frame in which the variable object is created. When such
|
| 8084 |
|
|
variable object is updated, GDB makes sure that the thread/frame
|
| 8085 |
|
|
combination the variable object is bound to still exists, and
|
| 8086 |
|
|
re-evaluates the variable object in context of that thread/frame.
|
| 8087 |
|
|
|
| 8088 |
|
|
The following is the complete set of GDB/MI operations defined to
|
| 8089 |
|
|
access this functionality:
|
| 8090 |
|
|
|
| 8091 |
|
|
*Operation* *Description*
|
| 8092 |
|
|
`-enable-pretty-printing' enable Python-based pretty-printing
|
| 8093 |
|
|
`-var-create' create a variable object
|
| 8094 |
|
|
`-var-delete' delete the variable object and/or its
|
| 8095 |
|
|
children
|
| 8096 |
|
|
`-var-set-format' set the display format of this variable
|
| 8097 |
|
|
`-var-show-format' show the display format of this variable
|
| 8098 |
|
|
`-var-info-num-children' tells how many children this object has
|
| 8099 |
|
|
`-var-list-children' return a list of the object's children
|
| 8100 |
|
|
`-var-info-type' show the type of this variable object
|
| 8101 |
|
|
`-var-info-expression' print parent-relative expression that this
|
| 8102 |
|
|
variable object represents
|
| 8103 |
|
|
`-var-info-path-expression' print full expression that this variable
|
| 8104 |
|
|
object represents
|
| 8105 |
|
|
`-var-show-attributes' is this variable editable? does it exist
|
| 8106 |
|
|
here?
|
| 8107 |
|
|
`-var-evaluate-expression' get the value of this variable
|
| 8108 |
|
|
`-var-assign' set the value of this variable
|
| 8109 |
|
|
`-var-update' update the variable and its children
|
| 8110 |
|
|
`-var-set-frozen' set frozeness attribute
|
| 8111 |
|
|
`-var-set-update-range' set range of children to display on update
|
| 8112 |
|
|
|
| 8113 |
|
|
In the next subsection we describe each operation in detail and
|
| 8114 |
|
|
suggest how it can be used.
|
| 8115 |
|
|
|
| 8116 |
|
|
Description And Use of Operations on Variable Objects
|
| 8117 |
|
|
-----------------------------------------------------
|
| 8118 |
|
|
|
| 8119 |
|
|
The `-enable-pretty-printing' Command
|
| 8120 |
|
|
-------------------------------------
|
| 8121 |
|
|
|
| 8122 |
|
|
-enable-pretty-printing
|
| 8123 |
|
|
|
| 8124 |
|
|
GDB allows Python-based visualizers to affect the output of the MI
|
| 8125 |
|
|
variable object commands. However, because there was no way to
|
| 8126 |
|
|
implement this in a fully backward-compatible way, a front end must
|
| 8127 |
|
|
request that this functionality be enabled.
|
| 8128 |
|
|
|
| 8129 |
|
|
Once enabled, this feature cannot be disabled.
|
| 8130 |
|
|
|
| 8131 |
|
|
Note that if Python support has not been compiled into GDB, this
|
| 8132 |
|
|
command will still succeed (and do nothing).
|
| 8133 |
|
|
|
| 8134 |
|
|
This feature is currently (as of GDB 7.0) experimental, and may work
|
| 8135 |
|
|
differently in future versions of GDB.
|
| 8136 |
|
|
|
| 8137 |
|
|
The `-var-create' Command
|
| 8138 |
|
|
-------------------------
|
| 8139 |
|
|
|
| 8140 |
|
|
Synopsis
|
| 8141 |
|
|
........
|
| 8142 |
|
|
|
| 8143 |
|
|
-var-create {NAME | "-"}
|
| 8144 |
|
|
{FRAME-ADDR | "*" | "@"} EXPRESSION
|
| 8145 |
|
|
|
| 8146 |
|
|
This operation creates a variable object, which allows the
|
| 8147 |
|
|
monitoring of a variable, the result of an expression, a memory cell or
|
| 8148 |
|
|
a CPU register.
|
| 8149 |
|
|
|
| 8150 |
|
|
The NAME parameter is the string by which the object can be
|
| 8151 |
|
|
referenced. It must be unique. If `-' is specified, the varobj system
|
| 8152 |
|
|
will generate a string "varNNNNNN" automatically. It will be unique
|
| 8153 |
|
|
provided that one does not specify NAME of that format. The command
|
| 8154 |
|
|
fails if a duplicate name is found.
|
| 8155 |
|
|
|
| 8156 |
|
|
The frame under which the expression should be evaluated can be
|
| 8157 |
|
|
specified by FRAME-ADDR. A `*' indicates that the current frame should
|
| 8158 |
|
|
be used. A `@' indicates that a floating variable object must be
|
| 8159 |
|
|
created.
|
| 8160 |
|
|
|
| 8161 |
|
|
EXPRESSION is any expression valid on the current language set (must
|
| 8162 |
|
|
not begin with a `*'), or one of the following:
|
| 8163 |
|
|
|
| 8164 |
|
|
* `*ADDR', where ADDR is the address of a memory cell
|
| 8165 |
|
|
|
| 8166 |
|
|
* `*ADDR-ADDR' -- a memory address range (TBD)
|
| 8167 |
|
|
|
| 8168 |
|
|
* `$REGNAME' -- a CPU register name
|
| 8169 |
|
|
|
| 8170 |
|
|
A varobj's contents may be provided by a Python-based
|
| 8171 |
|
|
pretty-printer. In this case the varobj is known as a "dynamic
|
| 8172 |
|
|
varobj". Dynamic varobjs have slightly different semantics in some
|
| 8173 |
|
|
cases. If the `-enable-pretty-printing' command is not sent, then GDB
|
| 8174 |
|
|
will never create a dynamic varobj. This ensures backward
|
| 8175 |
|
|
compatibility for existing clients.
|
| 8176 |
|
|
|
| 8177 |
|
|
Result
|
| 8178 |
|
|
......
|
| 8179 |
|
|
|
| 8180 |
|
|
This operation returns attributes of the newly-created varobj. These
|
| 8181 |
|
|
are:
|
| 8182 |
|
|
|
| 8183 |
|
|
`name'
|
| 8184 |
|
|
The name of the varobj.
|
| 8185 |
|
|
|
| 8186 |
|
|
`numchild'
|
| 8187 |
|
|
The number of children of the varobj. This number is not
|
| 8188 |
|
|
necessarily reliable for a dynamic varobj. Instead, you must
|
| 8189 |
|
|
examine the `has_more' attribute.
|
| 8190 |
|
|
|
| 8191 |
|
|
`value'
|
| 8192 |
|
|
The varobj's scalar value. For a varobj whose type is some sort of
|
| 8193 |
|
|
aggregate (e.g., a `struct'), or for a dynamic varobj, this value
|
| 8194 |
|
|
will not be interesting.
|
| 8195 |
|
|
|
| 8196 |
|
|
`type'
|
| 8197 |
|
|
The varobj's type. This is a string representation of the type, as
|
| 8198 |
|
|
would be printed by the GDB CLI.
|
| 8199 |
|
|
|
| 8200 |
|
|
`thread-id'
|
| 8201 |
|
|
If a variable object is bound to a specific thread, then this is
|
| 8202 |
|
|
the thread's identifier.
|
| 8203 |
|
|
|
| 8204 |
|
|
`has_more'
|
| 8205 |
|
|
For a dynamic varobj, this indicates whether there appear to be any
|
| 8206 |
|
|
children available. For a non-dynamic varobj, this will be 0.
|
| 8207 |
|
|
|
| 8208 |
|
|
`dynamic'
|
| 8209 |
|
|
This attribute will be present and have the value `1' if the
|
| 8210 |
|
|
varobj is a dynamic varobj. If the varobj is not a dynamic varobj,
|
| 8211 |
|
|
then this attribute will not be present.
|
| 8212 |
|
|
|
| 8213 |
|
|
`displayhint'
|
| 8214 |
|
|
A dynamic varobj can supply a display hint to the front end. The
|
| 8215 |
|
|
value comes directly from the Python pretty-printer object's
|
| 8216 |
|
|
`display_hint' method. *Note Pretty Printing API::.
|
| 8217 |
|
|
|
| 8218 |
|
|
Typical output will look like this:
|
| 8219 |
|
|
|
| 8220 |
|
|
name="NAME",numchild="N",type="TYPE",thread-id="M",
|
| 8221 |
|
|
has_more="HAS_MORE"
|
| 8222 |
|
|
|
| 8223 |
|
|
The `-var-delete' Command
|
| 8224 |
|
|
-------------------------
|
| 8225 |
|
|
|
| 8226 |
|
|
Synopsis
|
| 8227 |
|
|
........
|
| 8228 |
|
|
|
| 8229 |
|
|
-var-delete [ -c ] NAME
|
| 8230 |
|
|
|
| 8231 |
|
|
Deletes a previously created variable object and all of its children.
|
| 8232 |
|
|
With the `-c' option, just deletes the children.
|
| 8233 |
|
|
|
| 8234 |
|
|
Returns an error if the object NAME is not found.
|
| 8235 |
|
|
|
| 8236 |
|
|
The `-var-set-format' Command
|
| 8237 |
|
|
-----------------------------
|
| 8238 |
|
|
|
| 8239 |
|
|
Synopsis
|
| 8240 |
|
|
........
|
| 8241 |
|
|
|
| 8242 |
|
|
-var-set-format NAME FORMAT-SPEC
|
| 8243 |
|
|
|
| 8244 |
|
|
Sets the output format for the value of the object NAME to be
|
| 8245 |
|
|
FORMAT-SPEC.
|
| 8246 |
|
|
|
| 8247 |
|
|
The syntax for the FORMAT-SPEC is as follows:
|
| 8248 |
|
|
|
| 8249 |
|
|
FORMAT-SPEC ==>
|
| 8250 |
|
|
{binary | decimal | hexadecimal | octal | natural}
|
| 8251 |
|
|
|
| 8252 |
|
|
The natural format is the default format choosen automatically based
|
| 8253 |
|
|
on the variable type (like decimal for an `int', hex for pointers,
|
| 8254 |
|
|
etc.).
|
| 8255 |
|
|
|
| 8256 |
|
|
For a variable with children, the format is set only on the variable
|
| 8257 |
|
|
itself, and the children are not affected.
|
| 8258 |
|
|
|
| 8259 |
|
|
The `-var-show-format' Command
|
| 8260 |
|
|
------------------------------
|
| 8261 |
|
|
|
| 8262 |
|
|
Synopsis
|
| 8263 |
|
|
........
|
| 8264 |
|
|
|
| 8265 |
|
|
-var-show-format NAME
|
| 8266 |
|
|
|
| 8267 |
|
|
Returns the format used to display the value of the object NAME.
|
| 8268 |
|
|
|
| 8269 |
|
|
FORMAT ==>
|
| 8270 |
|
|
FORMAT-SPEC
|
| 8271 |
|
|
|
| 8272 |
|
|
The `-var-info-num-children' Command
|
| 8273 |
|
|
------------------------------------
|
| 8274 |
|
|
|
| 8275 |
|
|
Synopsis
|
| 8276 |
|
|
........
|
| 8277 |
|
|
|
| 8278 |
|
|
-var-info-num-children NAME
|
| 8279 |
|
|
|
| 8280 |
|
|
Returns the number of children of a variable object NAME:
|
| 8281 |
|
|
|
| 8282 |
|
|
numchild=N
|
| 8283 |
|
|
|
| 8284 |
|
|
Note that this number is not completely reliable for a dynamic
|
| 8285 |
|
|
varobj. It will return the current number of children, but more
|
| 8286 |
|
|
children may be available.
|
| 8287 |
|
|
|
| 8288 |
|
|
The `-var-list-children' Command
|
| 8289 |
|
|
--------------------------------
|
| 8290 |
|
|
|
| 8291 |
|
|
Synopsis
|
| 8292 |
|
|
........
|
| 8293 |
|
|
|
| 8294 |
|
|
-var-list-children [PRINT-VALUES] NAME [FROM TO]
|
| 8295 |
|
|
|
| 8296 |
|
|
Return a list of the children of the specified variable object and
|
| 8297 |
|
|
create variable objects for them, if they do not already exist. With a
|
| 8298 |
|
|
single argument or if PRINT-VALUES has a value of 0 or `--no-values',
|
| 8299 |
|
|
print only the names of the variables; if PRINT-VALUES is 1 or
|
| 8300 |
|
|
`--all-values', also print their values; and if it is 2 or
|
| 8301 |
|
|
`--simple-values' print the name and value for simple data types and
|
| 8302 |
|
|
just the name for arrays, structures and unions.
|
| 8303 |
|
|
|
| 8304 |
|
|
FROM and TO, if specified, indicate the range of children to report.
|
| 8305 |
|
|
If FROM or TO is less than zero, the range is reset and all children
|
| 8306 |
|
|
will be reported. Otherwise, children starting at FROM (zero-based)
|
| 8307 |
|
|
and up to and excluding TO will be reported.
|
| 8308 |
|
|
|
| 8309 |
|
|
If a child range is requested, it will only affect the current call
|
| 8310 |
|
|
to `-var-list-children', but not future calls to `-var-update'. For
|
| 8311 |
|
|
this, you must instead use `-var-set-update-range'. The intent of this
|
| 8312 |
|
|
approach is to enable a front end to implement any update approach it
|
| 8313 |
|
|
likes; for example, scrolling a view may cause the front end to request
|
| 8314 |
|
|
more children with `-var-list-children', and then the front end could
|
| 8315 |
|
|
call `-var-set-update-range' with a different range to ensure that
|
| 8316 |
|
|
future updates are restricted to just the visible items.
|
| 8317 |
|
|
|
| 8318 |
|
|
For each child the following results are returned:
|
| 8319 |
|
|
|
| 8320 |
|
|
NAME
|
| 8321 |
|
|
Name of the variable object created for this child.
|
| 8322 |
|
|
|
| 8323 |
|
|
EXP
|
| 8324 |
|
|
The expression to be shown to the user by the front end to
|
| 8325 |
|
|
designate this child. For example this may be the name of a
|
| 8326 |
|
|
structure member.
|
| 8327 |
|
|
|
| 8328 |
|
|
For a dynamic varobj, this value cannot be used to form an
|
| 8329 |
|
|
expression. There is no way to do this at all with a dynamic
|
| 8330 |
|
|
varobj.
|
| 8331 |
|
|
|
| 8332 |
|
|
For C/C++ structures there are several pseudo children returned to
|
| 8333 |
|
|
designate access qualifiers. For these pseudo children EXP is
|
| 8334 |
|
|
`public', `private', or `protected'. In this case the type and
|
| 8335 |
|
|
value are not present.
|
| 8336 |
|
|
|
| 8337 |
|
|
A dynamic varobj will not report the access qualifying
|
| 8338 |
|
|
pseudo-children, regardless of the language. This information is
|
| 8339 |
|
|
not available at all with a dynamic varobj.
|
| 8340 |
|
|
|
| 8341 |
|
|
NUMCHILD
|
| 8342 |
|
|
Number of children this child has. For a dynamic varobj, this
|
| 8343 |
|
|
will be 0.
|
| 8344 |
|
|
|
| 8345 |
|
|
TYPE
|
| 8346 |
|
|
The type of the child.
|
| 8347 |
|
|
|
| 8348 |
|
|
VALUE
|
| 8349 |
|
|
If values were requested, this is the value.
|
| 8350 |
|
|
|
| 8351 |
|
|
THREAD-ID
|
| 8352 |
|
|
If this variable object is associated with a thread, this is the
|
| 8353 |
|
|
thread id. Otherwise this result is not present.
|
| 8354 |
|
|
|
| 8355 |
|
|
FROZEN
|
| 8356 |
|
|
If the variable object is frozen, this variable will be present
|
| 8357 |
|
|
with a value of 1.
|
| 8358 |
|
|
|
| 8359 |
|
|
The result may have its own attributes:
|
| 8360 |
|
|
|
| 8361 |
|
|
`displayhint'
|
| 8362 |
|
|
A dynamic varobj can supply a display hint to the front end. The
|
| 8363 |
|
|
value comes directly from the Python pretty-printer object's
|
| 8364 |
|
|
`display_hint' method. *Note Pretty Printing API::.
|
| 8365 |
|
|
|
| 8366 |
|
|
`has_more'
|
| 8367 |
|
|
This is an integer attribute which is nonzero if there are children
|
| 8368 |
|
|
remaining after the end of the selected range.
|
| 8369 |
|
|
|
| 8370 |
|
|
Example
|
| 8371 |
|
|
.......
|
| 8372 |
|
|
|
| 8373 |
|
|
(gdb)
|
| 8374 |
|
|
-var-list-children n
|
| 8375 |
|
|
^done,numchild=N,children=[child={name=NAME,exp=EXP,
|
| 8376 |
|
|
numchild=N,type=TYPE},(repeats N times)]
|
| 8377 |
|
|
(gdb)
|
| 8378 |
|
|
-var-list-children --all-values n
|
| 8379 |
|
|
^done,numchild=N,children=[child={name=NAME,exp=EXP,
|
| 8380 |
|
|
numchild=N,value=VALUE,type=TYPE},(repeats N times)]
|
| 8381 |
|
|
|
| 8382 |
|
|
The `-var-info-type' Command
|
| 8383 |
|
|
----------------------------
|
| 8384 |
|
|
|
| 8385 |
|
|
Synopsis
|
| 8386 |
|
|
........
|
| 8387 |
|
|
|
| 8388 |
|
|
-var-info-type NAME
|
| 8389 |
|
|
|
| 8390 |
|
|
Returns the type of the specified variable NAME. The type is
|
| 8391 |
|
|
returned as a string in the same format as it is output by the GDB CLI:
|
| 8392 |
|
|
|
| 8393 |
|
|
type=TYPENAME
|
| 8394 |
|
|
|
| 8395 |
|
|
The `-var-info-expression' Command
|
| 8396 |
|
|
----------------------------------
|
| 8397 |
|
|
|
| 8398 |
|
|
Synopsis
|
| 8399 |
|
|
........
|
| 8400 |
|
|
|
| 8401 |
|
|
-var-info-expression NAME
|
| 8402 |
|
|
|
| 8403 |
|
|
Returns a string that is suitable for presenting this variable
|
| 8404 |
|
|
object in user interface. The string is generally not valid expression
|
| 8405 |
|
|
in the current language, and cannot be evaluated.
|
| 8406 |
|
|
|
| 8407 |
|
|
For example, if `a' is an array, and variable object `A' was created
|
| 8408 |
|
|
for `a', then we'll get this output:
|
| 8409 |
|
|
|
| 8410 |
|
|
(gdb) -var-info-expression A.1
|
| 8411 |
|
|
^done,lang="C",exp="1"
|
| 8412 |
|
|
|
| 8413 |
|
|
Here, the values of `lang' can be `{"C" | "C++" | "Java"}'.
|
| 8414 |
|
|
|
| 8415 |
|
|
Note that the output of the `-var-list-children' command also
|
| 8416 |
|
|
includes those expressions, so the `-var-info-expression' command is of
|
| 8417 |
|
|
limited use.
|
| 8418 |
|
|
|
| 8419 |
|
|
The `-var-info-path-expression' Command
|
| 8420 |
|
|
---------------------------------------
|
| 8421 |
|
|
|
| 8422 |
|
|
Synopsis
|
| 8423 |
|
|
........
|
| 8424 |
|
|
|
| 8425 |
|
|
-var-info-path-expression NAME
|
| 8426 |
|
|
|
| 8427 |
|
|
Returns an expression that can be evaluated in the current context
|
| 8428 |
|
|
and will yield the same value that a variable object has. Compare this
|
| 8429 |
|
|
with the `-var-info-expression' command, which result can be used only
|
| 8430 |
|
|
for UI presentation. Typical use of the `-var-info-path-expression'
|
| 8431 |
|
|
command is creating a watchpoint from a variable object.
|
| 8432 |
|
|
|
| 8433 |
|
|
This command is currently not valid for children of a dynamic varobj,
|
| 8434 |
|
|
and will give an error when invoked on one.
|
| 8435 |
|
|
|
| 8436 |
|
|
For example, suppose `C' is a C++ class, derived from class `Base',
|
| 8437 |
|
|
and that the `Base' class has a member called `m_size'. Assume a
|
| 8438 |
|
|
variable `c' is has the type of `C' and a variable object `C' was
|
| 8439 |
|
|
created for variable `c'. Then, we'll get this output:
|
| 8440 |
|
|
(gdb) -var-info-path-expression C.Base.public.m_size
|
| 8441 |
|
|
^done,path_expr=((Base)c).m_size)
|
| 8442 |
|
|
|
| 8443 |
|
|
The `-var-show-attributes' Command
|
| 8444 |
|
|
----------------------------------
|
| 8445 |
|
|
|
| 8446 |
|
|
Synopsis
|
| 8447 |
|
|
........
|
| 8448 |
|
|
|
| 8449 |
|
|
-var-show-attributes NAME
|
| 8450 |
|
|
|
| 8451 |
|
|
List attributes of the specified variable object NAME:
|
| 8452 |
|
|
|
| 8453 |
|
|
status=ATTR [ ( ,ATTR )* ]
|
| 8454 |
|
|
|
| 8455 |
|
|
where ATTR is `{ { editable | noneditable } | TBD }'.
|
| 8456 |
|
|
|
| 8457 |
|
|
The `-var-evaluate-expression' Command
|
| 8458 |
|
|
--------------------------------------
|
| 8459 |
|
|
|
| 8460 |
|
|
Synopsis
|
| 8461 |
|
|
........
|
| 8462 |
|
|
|
| 8463 |
|
|
-var-evaluate-expression [-f FORMAT-SPEC] NAME
|
| 8464 |
|
|
|
| 8465 |
|
|
Evaluates the expression that is represented by the specified
|
| 8466 |
|
|
variable object and returns its value as a string. The format of the
|
| 8467 |
|
|
string can be specified with the `-f' option. The possible values of
|
| 8468 |
|
|
this option are the same as for `-var-set-format' (*note
|
| 8469 |
|
|
-var-set-format::). If the `-f' option is not specified, the current
|
| 8470 |
|
|
display format will be used. The current display format can be changed
|
| 8471 |
|
|
using the `-var-set-format' command.
|
| 8472 |
|
|
|
| 8473 |
|
|
value=VALUE
|
| 8474 |
|
|
|
| 8475 |
|
|
Note that one must invoke `-var-list-children' for a variable before
|
| 8476 |
|
|
the value of a child variable can be evaluated.
|
| 8477 |
|
|
|
| 8478 |
|
|
The `-var-assign' Command
|
| 8479 |
|
|
-------------------------
|
| 8480 |
|
|
|
| 8481 |
|
|
Synopsis
|
| 8482 |
|
|
........
|
| 8483 |
|
|
|
| 8484 |
|
|
-var-assign NAME EXPRESSION
|
| 8485 |
|
|
|
| 8486 |
|
|
Assigns the value of EXPRESSION to the variable object specified by
|
| 8487 |
|
|
NAME. The object must be `editable'. If the variable's value is
|
| 8488 |
|
|
altered by the assign, the variable will show up in any subsequent
|
| 8489 |
|
|
`-var-update' list.
|
| 8490 |
|
|
|
| 8491 |
|
|
Example
|
| 8492 |
|
|
.......
|
| 8493 |
|
|
|
| 8494 |
|
|
(gdb)
|
| 8495 |
|
|
-var-assign var1 3
|
| 8496 |
|
|
^done,value="3"
|
| 8497 |
|
|
(gdb)
|
| 8498 |
|
|
-var-update *
|
| 8499 |
|
|
^done,changelist=[{name="var1",in_scope="true",type_changed="false"}]
|
| 8500 |
|
|
(gdb)
|
| 8501 |
|
|
|
| 8502 |
|
|
The `-var-update' Command
|
| 8503 |
|
|
-------------------------
|
| 8504 |
|
|
|
| 8505 |
|
|
Synopsis
|
| 8506 |
|
|
........
|
| 8507 |
|
|
|
| 8508 |
|
|
-var-update [PRINT-VALUES] {NAME | "*"}
|
| 8509 |
|
|
|
| 8510 |
|
|
Reevaluate the expressions corresponding to the variable object NAME
|
| 8511 |
|
|
and all its direct and indirect children, and return the list of
|
| 8512 |
|
|
variable objects whose values have changed; NAME must be a root
|
| 8513 |
|
|
variable object. Here, "changed" means that the result of
|
| 8514 |
|
|
`-var-evaluate-expression' before and after the `-var-update' is
|
| 8515 |
|
|
different. If `*' is used as the variable object names, all existing
|
| 8516 |
|
|
variable objects are updated, except for frozen ones (*note
|
| 8517 |
|
|
-var-set-frozen::). The option PRINT-VALUES determines whether both
|
| 8518 |
|
|
names and values, or just names are printed. The possible values of
|
| 8519 |
|
|
this option are the same as for `-var-list-children' (*note
|
| 8520 |
|
|
-var-list-children::). It is recommended to use the `--all-values'
|
| 8521 |
|
|
option, to reduce the number of MI commands needed on each program stop.
|
| 8522 |
|
|
|
| 8523 |
|
|
With the `*' parameter, if a variable object is bound to a currently
|
| 8524 |
|
|
running thread, it will not be updated, without any diagnostic.
|
| 8525 |
|
|
|
| 8526 |
|
|
If `-var-set-update-range' was previously used on a varobj, then
|
| 8527 |
|
|
only the selected range of children will be reported.
|
| 8528 |
|
|
|
| 8529 |
|
|
`-var-update' reports all the changed varobjs in a tuple named
|
| 8530 |
|
|
`changelist'.
|
| 8531 |
|
|
|
| 8532 |
|
|
Each item in the change list is itself a tuple holding:
|
| 8533 |
|
|
|
| 8534 |
|
|
`name'
|
| 8535 |
|
|
The name of the varobj.
|
| 8536 |
|
|
|
| 8537 |
|
|
`value'
|
| 8538 |
|
|
If values were requested for this update, then this field will be
|
| 8539 |
|
|
present and will hold the value of the varobj.
|
| 8540 |
|
|
|
| 8541 |
|
|
`in_scope'
|
| 8542 |
|
|
This field is a string which may take one of three values:
|
| 8543 |
|
|
|
| 8544 |
|
|
`"true"'
|
| 8545 |
|
|
The variable object's current value is valid.
|
| 8546 |
|
|
|
| 8547 |
|
|
`"false"'
|
| 8548 |
|
|
The variable object does not currently hold a valid value but
|
| 8549 |
|
|
it may hold one in the future if its associated expression
|
| 8550 |
|
|
comes back into scope.
|
| 8551 |
|
|
|
| 8552 |
|
|
`"invalid"'
|
| 8553 |
|
|
The variable object no longer holds a valid value. This can
|
| 8554 |
|
|
occur when the executable file being debugged has changed,
|
| 8555 |
|
|
either through recompilation or by using the GDB `file'
|
| 8556 |
|
|
command. The front end should normally choose to delete
|
| 8557 |
|
|
these variable objects.
|
| 8558 |
|
|
|
| 8559 |
|
|
In the future new values may be added to this list so the front
|
| 8560 |
|
|
should be prepared for this possibility. *Note GDB/MI Development
|
| 8561 |
|
|
and Front Ends: GDB/MI Development and Front Ends.
|
| 8562 |
|
|
|
| 8563 |
|
|
`type_changed'
|
| 8564 |
|
|
This is only present if the varobj is still valid. If the type
|
| 8565 |
|
|
changed, then this will be the string `true'; otherwise it will be
|
| 8566 |
|
|
`false'.
|
| 8567 |
|
|
|
| 8568 |
|
|
`new_type'
|
| 8569 |
|
|
If the varobj's type changed, then this field will be present and
|
| 8570 |
|
|
will hold the new type.
|
| 8571 |
|
|
|
| 8572 |
|
|
`new_num_children'
|
| 8573 |
|
|
For a dynamic varobj, if the number of children changed, or if the
|
| 8574 |
|
|
type changed, this will be the new number of children.
|
| 8575 |
|
|
|
| 8576 |
|
|
The `numchild' field in other varobj responses is generally not
|
| 8577 |
|
|
valid for a dynamic varobj - it will show the number of children
|
| 8578 |
|
|
that GDB knows about, but because dynamic varobjs lazily
|
| 8579 |
|
|
instantiate their children, this will not reflect the number of
|
| 8580 |
|
|
children which may be available.
|
| 8581 |
|
|
|
| 8582 |
|
|
The `new_num_children' attribute only reports changes to the
|
| 8583 |
|
|
number of children known by GDB. This is the only way to detect
|
| 8584 |
|
|
whether an update has removed children (which necessarily can only
|
| 8585 |
|
|
happen at the end of the update range).
|
| 8586 |
|
|
|
| 8587 |
|
|
`displayhint'
|
| 8588 |
|
|
The display hint, if any.
|
| 8589 |
|
|
|
| 8590 |
|
|
`has_more'
|
| 8591 |
|
|
This is an integer value, which will be 1 if there are more
|
| 8592 |
|
|
children available outside the varobj's update range.
|
| 8593 |
|
|
|
| 8594 |
|
|
`dynamic'
|
| 8595 |
|
|
This attribute will be present and have the value `1' if the
|
| 8596 |
|
|
varobj is a dynamic varobj. If the varobj is not a dynamic varobj,
|
| 8597 |
|
|
then this attribute will not be present.
|
| 8598 |
|
|
|
| 8599 |
|
|
`new_children'
|
| 8600 |
|
|
If new children were added to a dynamic varobj within the selected
|
| 8601 |
|
|
update range (as set by `-var-set-update-range'), then they will
|
| 8602 |
|
|
be listed in this attribute.
|
| 8603 |
|
|
|
| 8604 |
|
|
Example
|
| 8605 |
|
|
.......
|
| 8606 |
|
|
|
| 8607 |
|
|
(gdb)
|
| 8608 |
|
|
-var-assign var1 3
|
| 8609 |
|
|
^done,value="3"
|
| 8610 |
|
|
(gdb)
|
| 8611 |
|
|
-var-update --all-values var1
|
| 8612 |
|
|
^done,changelist=[{name="var1",value="3",in_scope="true",
|
| 8613 |
|
|
type_changed="false"}]
|
| 8614 |
|
|
(gdb)
|
| 8615 |
|
|
|
| 8616 |
|
|
The `-var-set-frozen' Command
|
| 8617 |
|
|
-----------------------------
|
| 8618 |
|
|
|
| 8619 |
|
|
Synopsis
|
| 8620 |
|
|
........
|
| 8621 |
|
|
|
| 8622 |
|
|
-var-set-frozen NAME FLAG
|
| 8623 |
|
|
|
| 8624 |
|
|
Set the frozenness flag on the variable object NAME. The FLAG
|
| 8625 |
|
|
parameter should be either `1' to make the variable frozen or `0' to
|
| 8626 |
|
|
make it unfrozen. If a variable object is frozen, then neither itself,
|
| 8627 |
|
|
nor any of its children, are implicitly updated by `-var-update' of a
|
| 8628 |
|
|
parent variable or by `-var-update *'. Only `-var-update' of the
|
| 8629 |
|
|
variable itself will update its value and values of its children.
|
| 8630 |
|
|
After a variable object is unfrozen, it is implicitly updated by all
|
| 8631 |
|
|
subsequent `-var-update' operations. Unfreezing a variable does not
|
| 8632 |
|
|
update it, only subsequent `-var-update' does.
|
| 8633 |
|
|
|
| 8634 |
|
|
Example
|
| 8635 |
|
|
.......
|
| 8636 |
|
|
|
| 8637 |
|
|
(gdb)
|
| 8638 |
|
|
-var-set-frozen V 1
|
| 8639 |
|
|
^done
|
| 8640 |
|
|
(gdb)
|
| 8641 |
|
|
|
| 8642 |
|
|
The `-var-set-update-range' command
|
| 8643 |
|
|
-----------------------------------
|
| 8644 |
|
|
|
| 8645 |
|
|
Synopsis
|
| 8646 |
|
|
........
|
| 8647 |
|
|
|
| 8648 |
|
|
-var-set-update-range NAME FROM TO
|
| 8649 |
|
|
|
| 8650 |
|
|
Set the range of children to be returned by future invocations of
|
| 8651 |
|
|
`-var-update'.
|
| 8652 |
|
|
|
| 8653 |
|
|
FROM and TO indicate the range of children to report. If FROM or TO
|
| 8654 |
|
|
is less than zero, the range is reset and all children will be
|
| 8655 |
|
|
reported. Otherwise, children starting at FROM (zero-based) and up to
|
| 8656 |
|
|
and excluding TO will be reported.
|
| 8657 |
|
|
|
| 8658 |
|
|
Example
|
| 8659 |
|
|
.......
|
| 8660 |
|
|
|
| 8661 |
|
|
(gdb)
|
| 8662 |
|
|
-var-set-update-range V 1 2
|
| 8663 |
|
|
^done
|
| 8664 |
|
|
|
| 8665 |
|
|
The `-var-set-visualizer' command
|
| 8666 |
|
|
---------------------------------
|
| 8667 |
|
|
|
| 8668 |
|
|
Synopsis
|
| 8669 |
|
|
........
|
| 8670 |
|
|
|
| 8671 |
|
|
-var-set-visualizer NAME VISUALIZER
|
| 8672 |
|
|
|
| 8673 |
|
|
Set a visualizer for the variable object NAME.
|
| 8674 |
|
|
|
| 8675 |
|
|
VISUALIZER is the visualizer to use. The special value `None' means
|
| 8676 |
|
|
to disable any visualizer in use.
|
| 8677 |
|
|
|
| 8678 |
|
|
If not `None', VISUALIZER must be a Python expression. This
|
| 8679 |
|
|
expression must evaluate to a callable object which accepts a single
|
| 8680 |
|
|
argument. GDB will call this object with the value of the varobj NAME
|
| 8681 |
|
|
as an argument (this is done so that the same Python pretty-printing
|
| 8682 |
|
|
code can be used for both the CLI and MI). When called, this object
|
| 8683 |
|
|
must return an object which conforms to the pretty-printing interface
|
| 8684 |
|
|
(*note Pretty Printing API::).
|
| 8685 |
|
|
|
| 8686 |
|
|
The pre-defined function `gdb.default_visualizer' may be used to
|
| 8687 |
|
|
select a visualizer by following the built-in process (*note Selecting
|
| 8688 |
|
|
Pretty-Printers::). This is done automatically when a varobj is
|
| 8689 |
|
|
created, and so ordinarily is not needed.
|
| 8690 |
|
|
|
| 8691 |
|
|
This feature is only available if Python support is enabled. The MI
|
| 8692 |
|
|
command `-list-features' (*note GDB/MI Miscellaneous Commands::) can be
|
| 8693 |
|
|
used to check this.
|
| 8694 |
|
|
|
| 8695 |
|
|
Example
|
| 8696 |
|
|
.......
|
| 8697 |
|
|
|
| 8698 |
|
|
Resetting the visualizer:
|
| 8699 |
|
|
|
| 8700 |
|
|
(gdb)
|
| 8701 |
|
|
-var-set-visualizer V None
|
| 8702 |
|
|
^done
|
| 8703 |
|
|
|
| 8704 |
|
|
Reselecting the default (type-based) visualizer:
|
| 8705 |
|
|
|
| 8706 |
|
|
(gdb)
|
| 8707 |
|
|
-var-set-visualizer V gdb.default_visualizer
|
| 8708 |
|
|
^done
|
| 8709 |
|
|
|
| 8710 |
|
|
Suppose `SomeClass' is a visualizer class. A lambda expression can
|
| 8711 |
|
|
be used to instantiate this class for a varobj:
|
| 8712 |
|
|
|
| 8713 |
|
|
(gdb)
|
| 8714 |
|
|
-var-set-visualizer V "lambda val: SomeClass()"
|
| 8715 |
|
|
^done
|
| 8716 |
|
|
|