OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [doc/] [gdb.info-3] - Blame information for rev 421

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 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.1 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.1.
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.1 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: MicroBlaze,  Next: MIPS Embedded,  Prev: M68K,  Up: Embedded Processors
45
 
46
21.3.4 MicroBlaze
47
-----------------
48
 
49
The MicroBlaze is a soft-core processor supported on various Xilinx
50
FPGAs, such as Spartan or Virtex series.  Boards with these processors
51
usually have JTAG ports which connect to a host system running the
52
Xilinx Embedded Development Kit (EDK) or Software Development Kit (SDK).
53
This host system is used to download the configuration bitstream to the
54
target FPGA.  The Xilinx Microprocessor Debugger (XMD) program
55
communicates with the target board using the JTAG interface and
56
presents a `gdbserver' interface to the board.  By default `xmd' uses
57
port `1234'.  (While it is possible to change this default port, it
58
requires the use of undocumented `xmd' commands.  Contact Xilinx
59
support if you need to do this.)
60
 
61
   Use these GDB commands to connect to the MicroBlaze target processor.
62
 
63
`target remote :1234'
64
     Use this command to connect to the target if you are running GDB
65
     on the same system as `xmd'.
66
 
67
`target remote XMD-HOST:1234'
68
     Use this command to connect to the target if it is connected to
69
     `xmd' running on a different system named XMD-HOST.
70
 
71
`load'
72
     Use this command to download a program to the MicroBlaze target.
73
 
74
`set debug microblaze N'
75
     Enable MicroBlaze-specific debugging messages if non-zero.
76
 
77
`show debug microblaze N'
78
     Show MicroBlaze-specific debugging level.
79
 
80

81
File: gdb.info,  Node: MIPS Embedded,  Next: OpenRISC 1000,  Prev: MicroBlaze,  Up: Embedded Processors
82
 
83
21.3.5 MIPS Embedded
84
--------------------
85
 
86
GDB can use the MIPS remote debugging protocol to talk to a MIPS board
87
attached to a serial line.  This is available when you configure GDB
88
with `--target=mips-idt-ecoff'.
89
 
90
   Use these GDB commands to specify the connection to your target
91
board:
92
 
93
`target mips PORT'
94
     To run a program on the board, start up `gdb' with the name of
95
     your program as the argument.  To connect to the board, use the
96
     command `target mips PORT', where PORT is the name of the serial
97
     port connected to the board.  If the program has not already been
98
     downloaded to the board, you may use the `load' command to
99
     download it.  You can then use all the usual GDB commands.
100
 
101
     For example, this sequence connects to the target board through a
102
     serial port, and loads and runs a program called PROG through the
103
     debugger:
104
 
105
          host$ gdb PROG
106
          GDB is free software and ...
107
          (gdb) target mips /dev/ttyb
108
          (gdb) load PROG
109
          (gdb) run
110
 
111
`target mips HOSTNAME:PORTNUMBER'
112
     On some GDB host configurations, you can specify a TCP connection
113
     (for instance, to a serial line managed by a terminal
114
     concentrator) instead of a serial port, using the syntax
115
     `HOSTNAME:PORTNUMBER'.
116
 
117
`target pmon PORT'
118
     PMON ROM monitor.
119
 
120
`target ddb PORT'
121
     NEC's DDB variant of PMON for Vr4300.
122
 
123
`target lsi PORT'
124
     LSI variant of PMON.
125
 
126
`target r3900 DEV'
127
     Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
128
 
129
`target array DEV'
130
     Array Tech LSI33K RAID controller board.
131
 
132
 
133
GDB also supports these special commands for MIPS targets:
134
 
135
`set mipsfpu double'
136
`set mipsfpu single'
137
`set mipsfpu none'
138
`set mipsfpu auto'
139
`show mipsfpu'
140
     If your target board does not support the MIPS floating point
141
     coprocessor, you should use the command `set mipsfpu none' (if you
142
     need this, you may wish to put the command in your GDB init file).
143
     This tells GDB how to find the return value of functions which
144
     return floating point values.  It also allows GDB to avoid saving
145
     the floating point registers when calling functions on the board.
146
     If you are using a floating point coprocessor with only single
147
     precision floating point support, as on the R4650 processor, use
148
     the command `set mipsfpu single'.  The default double precision
149
     floating point coprocessor may be selected using `set mipsfpu
150
     double'.
151
 
152
     In previous versions the only choices were double precision or no
153
     floating point, so `set mipsfpu on' will select double precision
154
     and `set mipsfpu off' will select no floating point.
155
 
156
     As usual, you can inquire about the `mipsfpu' variable with `show
157
     mipsfpu'.
158
 
159
`set timeout SECONDS'
160
`set retransmit-timeout SECONDS'
161
`show timeout'
162
`show retransmit-timeout'
163
     You can control the timeout used while waiting for a packet, in
164
     the MIPS remote protocol, with the `set timeout SECONDS' command.
165
     The default is 5 seconds.  Similarly, you can control the timeout
166
     used while waiting for an acknowledgment of a packet with the `set
167
     retransmit-timeout SECONDS' command.  The default is 3 seconds.
168
     You can inspect both values with `show timeout' and `show
169
     retransmit-timeout'.  (These commands are _only_ available when
170
     GDB is configured for `--target=mips-idt-ecoff'.)
171
 
172
     The timeout set by `set timeout' does not apply when GDB is
173
     waiting for your program to stop.  In that case, GDB waits forever
174
     because it has no way of knowing how long the program is going to
175
     run before stopping.
176
 
177
`set syn-garbage-limit NUM'
178
     Limit the maximum number of characters GDB should ignore when it
179
     tries to synchronize with the remote target.  The default is 10
180
     characters.  Setting the limit to -1 means there's no limit.
181
 
182
`show syn-garbage-limit'
183
     Show the current limit on the number of characters to ignore when
184
     trying to synchronize with the remote system.
185
 
186
`set monitor-prompt PROMPT'
187
     Tell GDB to expect the specified PROMPT string from the remote
188
     monitor.  The default depends on the target:
189
    pmon target
190
          `PMON'
191
 
192
    ddb target
193
          `NEC010'
194
 
195
    lsi target
196
          `PMON>'
197
 
198
`show monitor-prompt'
199
     Show the current strings GDB expects as the prompt from the remote
200
     monitor.
201
 
202
`set monitor-warnings'
203
     Enable or disable monitor warnings about hardware breakpoints.
204
     This has effect only for the `lsi' target.  When on, GDB will
205
     display warning messages whose codes are returned by the `lsi'
206
     PMON monitor for breakpoint commands.
207
 
208
`show monitor-warnings'
209
     Show the current setting of printing monitor warnings.
210
 
211
`pmon COMMAND'
212
     This command allows sending an arbitrary COMMAND string to the
213
     monitor.  The monitor must be in debug mode for this to work.
214
 
215

216
File: gdb.info,  Node: OpenRISC 1000,  Next: PA,  Prev: MIPS Embedded,  Up: Embedded Processors
217
 
218
21.3.6 OpenRISC 1000
219
--------------------
220
 
221
See OR1k Architecture document (`www.opencores.org') for more
222
information about platform and commands.
223
 
224
`target jtag jtag://HOST:PORT'
225
     Connects to remote JTAG server.  JTAG remote server can be either
226
     an or1ksim or JTAG server, connected via parallel port to the
227
     board.
228
 
229
     Example: `target jtag jtag://localhost:9999'
230
 
231
`or1ksim COMMAND'
232
     If connected to `or1ksim' OpenRISC 1000 Architectural Simulator,
233
     proprietary commands can be executed.
234
 
235
`info or1k spr'
236
     Displays spr groups.
237
 
238
`info or1k spr GROUP'
239
`info or1k spr GROUPNO'
240
     Displays register names in selected group.
241
 
242
`info or1k spr GROUP REGISTER'
243
`info or1k spr REGISTER'
244
`info or1k spr GROUPNO REGISTERNO'
245
`info or1k spr REGISTERNO'
246
     Shows information about specified spr register.
247
 
248
`spr GROUP REGISTER VALUE'
249
`spr REGISTER VALUE'
250
`spr GROUPNO REGISTERNO VALUE'
251
`spr REGISTERNO VALUE'
252
     Writes VALUE to specified spr register.
253
 
254
   Some implementations of OpenRISC 1000 Architecture also have
255
hardware trace.  It is very similar to GDB trace, except it does not
256
interfere with normal program execution and is thus much faster.
257
Hardware breakpoints/watchpoint triggers can be set using:
258
`$LEA/$LDATA'
259
     Load effective address/data
260
 
261
`$SEA/$SDATA'
262
     Store effective address/data
263
 
264
`$AEA/$ADATA'
265
     Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA)
266
 
267
`$FETCH'
268
     Fetch data
269
 
270
   When triggered, it can capture low level data, like: `PC', `LSEA',
271
`LDATA', `SDATA', `READSPR', `WRITESPR', `INSTR'.
272
 
273
   `htrace' commands:
274
`hwatch CONDITIONAL'
275
     Set hardware watchpoint on combination of Load/Store Effective
276
     Address(es) or Data.  For example:
277
 
278
     `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
279
     ($SDATA >= 50)'
280
 
281
     `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
282
     ($SDATA >= 50)'
283
 
284
`htrace info'
285
     Display information about current HW trace configuration.
286
 
287
`htrace trigger CONDITIONAL'
288
     Set starting criteria for HW trace.
289
 
290
`htrace qualifier CONDITIONAL'
291
     Set acquisition qualifier for HW trace.
292
 
293
`htrace stop CONDITIONAL'
294
     Set HW trace stopping criteria.
295
 
296
`htrace record [DATA]*'
297
     Selects the data to be recorded, when qualifier is met and HW
298
     trace was triggered.
299
 
300
`htrace enable'
301
`htrace disable'
302
     Enables/disables the HW trace.
303
 
304
`htrace rewind [FILENAME]'
305
     Clears currently recorded trace data.
306
 
307
     If filename is specified, new trace file is made and any newly
308
     collected data will be written there.
309
 
310
`htrace print [START [LEN]]'
311
     Prints trace buffer, using current record configuration.
312
 
313
`htrace mode continuous'
314
     Set continuous trace mode.
315
 
316
`htrace mode suspend'
317
     Set suspend trace mode.
318
 
319
 
320

321
File: gdb.info,  Node: PowerPC Embedded,  Next: Sparclet,  Prev: PA,  Up: Embedded Processors
322
 
323
21.3.7 PowerPC Embedded
324
-----------------------
325
 
326
GDB provides the following PowerPC-specific commands:
327
 
328
`set powerpc soft-float'
329
`show powerpc soft-float'
330
     Force GDB to use (or not use) a software floating point calling
331
     convention.  By default, GDB selects the calling convention based
332
     on the selected architecture and the provided executable file.
333
 
334
`set powerpc vector-abi'
335
`show powerpc vector-abi'
336
     Force GDB to use the specified calling convention for vector
337
     arguments and return values.  The valid options are `auto';
338
     `generic', to avoid vector registers even if they are present;
339
     `altivec', to use AltiVec registers; and `spe' to use SPE
340
     registers.  By default, GDB selects the calling convention based
341
     on the selected architecture and the provided executable file.
342
 
343
`target dink32 DEV'
344
     DINK32 ROM monitor.
345
 
346
`target ppcbug DEV'
347
 
348
`target ppcbug1 DEV'
349
     PPCBUG ROM monitor for PowerPC.
350
 
351
`target sds DEV'
352
     SDS monitor, running on a PowerPC board (such as Motorola's ADS).
353
 
354
   The following commands specific to the SDS protocol are supported by
355
GDB:
356
 
357
`set sdstimeout NSEC'
358
     Set the timeout for SDS protocol reads to be NSEC seconds.  The
359
     default is 2 seconds.
360
 
361
`show sdstimeout'
362
     Show the current value of the SDS timeout.
363
 
364
`sds COMMAND'
365
     Send the specified COMMAND string to the SDS monitor.
366
 
367

368
File: gdb.info,  Node: PA,  Next: PowerPC Embedded,  Prev: OpenRISC 1000,  Up: Embedded Processors
369
 
370
21.3.8 HP PA Embedded
371
---------------------
372
 
373
`target op50n DEV'
374
     OP50N monitor, running on an OKI HPPA board.
375
 
376
`target w89k DEV'
377
     W89K monitor, running on a Winbond HPPA board.
378
 
379
 
380

381
File: gdb.info,  Node: Sparclet,  Next: Sparclite,  Prev: PowerPC Embedded,  Up: Embedded Processors
382
 
383
21.3.9 Tsqware Sparclet
384
-----------------------
385
 
386
GDB enables developers to debug tasks running on Sparclet targets from
387
a Unix host.  GDB uses code that runs on both the Unix host and on the
388
Sparclet target.  The program `gdb' is installed and executed on the
389
Unix host.
390
 
391
`remotetimeout ARGS'
392
     GDB supports the option `remotetimeout'.  This option is set by
393
     the user, and  ARGS represents the number of seconds GDB waits for
394
     responses.
395
 
396
   When compiling for debugging, include the options `-g' to get debug
397
information and `-Ttext' to relocate the program to where you wish to
398
load it on the target.  You may also want to add the options `-n' or
399
`-N' in order to reduce the size of the sections.  Example:
400
 
401
     sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
402
 
403
   You can use `objdump' to verify that the addresses are what you
404
intended:
405
 
406
     sparclet-aout-objdump --headers --syms prog
407
 
408
   Once you have set your Unix execution search path to find GDB, you
409
are ready to run GDB.  From your Unix host, run `gdb' (or
410
`sparclet-aout-gdb', depending on your installation).
411
 
412
   GDB comes up showing the prompt:
413
 
414
     (gdbslet)
415
 
416
* Menu:
417
 
418
* Sparclet File::                Setting the file to debug
419
* Sparclet Connection::          Connecting to Sparclet
420
* Sparclet Download::            Sparclet download
421
* Sparclet Execution::           Running and debugging
422
 
423

424
File: gdb.info,  Node: Sparclet File,  Next: Sparclet Connection,  Up: Sparclet
425
 
426
21.3.9.1 Setting File to Debug
427
..............................
428
 
429
The GDB command `file' lets you choose with program to debug.
430
 
431
     (gdbslet) file prog
432
 
433
   GDB then attempts to read the symbol table of `prog'.  GDB locates
434
the file by searching the directories listed in the command search path.
435
If the file was compiled with debug information (option `-g'), source
436
files will be searched as well.  GDB locates the source files by
437
searching the directories listed in the directory search path (*note
438
Your Program's Environment: Environment.).  If it fails to find a file,
439
it displays a message such as:
440
 
441
     prog: No such file or directory.
442
 
443
   When this happens, add the appropriate directories to the search
444
paths with the GDB commands `path' and `dir', and execute the `target'
445
command again.
446
 
447

448
File: gdb.info,  Node: Sparclet Connection,  Next: Sparclet Download,  Prev: Sparclet File,  Up: Sparclet
449
 
450
21.3.9.2 Connecting to Sparclet
451
...............................
452
 
453
The GDB command `target' lets you connect to a Sparclet target.  To
454
connect to a target on serial port "`ttya'", type:
455
 
456
     (gdbslet) target sparclet /dev/ttya
457
     Remote target sparclet connected to /dev/ttya
458
     main () at ../prog.c:3
459
 
460
   GDB displays messages like these:
461
 
462
     Connected to ttya.
463
 
464

465
File: gdb.info,  Node: Sparclet Download,  Next: Sparclet Execution,  Prev: Sparclet Connection,  Up: Sparclet
466
 
467
21.3.9.3 Sparclet Download
468
..........................
469
 
470
Once connected to the Sparclet target, you can use the GDB `load'
471
command to download the file from the host to the target.  The file
472
name and load offset should be given as arguments to the `load' command.
473
Since the file format is aout, the program must be loaded to the
474
starting address.  You can use `objdump' to find out what this value
475
is.  The load offset is an offset which is added to the VMA (virtual
476
memory address) of each of the file's sections.  For instance, if the
477
program `prog' was linked to text address 0x1201000, with data at
478
0x12010160 and bss at 0x12010170, in GDB, type:
479
 
480
     (gdbslet) load prog 0x12010000
481
     Loading section .text, size 0xdb0 vma 0x12010000
482
 
483
   If the code is loaded at a different address then what the program
484
was linked to, you may need to use the `section' and `add-symbol-file'
485
commands to tell GDB where to map the symbol table.
486
 
487

488
File: gdb.info,  Node: Sparclet Execution,  Prev: Sparclet Download,  Up: Sparclet
489
 
490
21.3.9.4 Running and Debugging
491
..............................
492
 
493
You can now begin debugging the task using GDB's execution control
494
commands, `b', `step', `run', etc.  See the GDB manual for the list of
495
commands.
496
 
497
     (gdbslet) b main
498
     Breakpoint 1 at 0x12010000: file prog.c, line 3.
499
     (gdbslet) run
500
     Starting program: prog
501
     Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
502
     3        char *symarg = 0;
503
     (gdbslet) step
504
     4        char *execarg = "hello!";
505
     (gdbslet)
506
 
507

508
File: gdb.info,  Node: Sparclite,  Next: Z8000,  Prev: Sparclet,  Up: Embedded Processors
509
 
510
21.3.10 Fujitsu Sparclite
511
-------------------------
512
 
513
`target sparclite DEV'
514
     Fujitsu sparclite boards, used only for the purpose of loading.
515
     You must use an additional command to debug the program.  For
516
     example: target remote DEV using GDB standard remote protocol.
517
 
518
 
519

520
File: gdb.info,  Node: Z8000,  Next: AVR,  Prev: Sparclite,  Up: Embedded Processors
521
 
522
21.3.11 Zilog Z8000
523
-------------------
524
 
525
When configured for debugging Zilog Z8000 targets, GDB includes a Z8000
526
simulator.
527
 
528
   For the Z8000 family, `target sim' simulates either the Z8002 (the
529
unsegmented variant of the Z8000 architecture) or the Z8001 (the
530
segmented variant).  The simulator recognizes which architecture is
531
appropriate by inspecting the object code.
532
 
533
`target sim ARGS'
534
     Debug programs on a simulated CPU.  If the simulator supports setup
535
     options, specify them via ARGS.
536
 
537
After specifying this target, you can debug programs for the simulated
538
CPU in the same style as programs for your host computer; use the
539
`file' command to load a new program image, the `run' command to run
540
your program, and so on.
541
 
542
   As well as making available all the usual machine registers (*note
543
Registers: Registers.), the Z8000 simulator provides three additional
544
items of information as specially named registers:
545
 
546
`cycles'
547
     Counts clock-ticks in the simulator.
548
 
549
`insts'
550
     Counts instructions run in the simulator.
551
 
552
`time'
553
     Execution time in 60ths of a second.
554
 
555
 
556
   You can refer to these values in GDB expressions with the usual
557
conventions; for example, `b fputc if $cycles>5000' sets a conditional
558
breakpoint that suspends only after at least 5000 simulated clock ticks.
559
 
560

561
File: gdb.info,  Node: AVR,  Next: CRIS,  Prev: Z8000,  Up: Embedded Processors
562
 
563
21.3.12 Atmel AVR
564
-----------------
565
 
566
When configured for debugging the Atmel AVR, GDB supports the following
567
AVR-specific commands:
568
 
569
`info io_registers'
570
     This command displays information about the AVR I/O registers.  For
571
     each register, GDB prints its number and value.
572
 
573

574
File: gdb.info,  Node: CRIS,  Next: Super-H,  Prev: AVR,  Up: Embedded Processors
575
 
576
21.3.13 CRIS
577
------------
578
 
579
When configured for debugging CRIS, GDB provides the following
580
CRIS-specific commands:
581
 
582
`set cris-version VER'
583
     Set the current CRIS version to VER, either `10' or `32'.  The
584
     CRIS version affects register names and sizes.  This command is
585
     useful in case autodetection of the CRIS version fails.
586
 
587
`show cris-version'
588
     Show the current CRIS version.
589
 
590
`set cris-dwarf2-cfi'
591
     Set the usage of DWARF-2 CFI for CRIS debugging.  The default is
592
     `on'.  Change to `off' when using `gcc-cris' whose version is below
593
     `R59'.
594
 
595
`show cris-dwarf2-cfi'
596
     Show the current state of using DWARF-2 CFI.
597
 
598
`set cris-mode MODE'
599
     Set the current CRIS mode to MODE.  It should only be changed when
600
     debugging in guru mode, in which case it should be set to `guru'
601
     (the default is `normal').
602
 
603
`show cris-mode'
604
     Show the current CRIS mode.
605
 
606

607
File: gdb.info,  Node: Super-H,  Prev: CRIS,  Up: Embedded Processors
608
 
609
21.3.14 Renesas Super-H
610
-----------------------
611
 
612
For the Renesas Super-H processor, GDB provides these commands:
613
 
614
`regs'
615
     Show the values of all Super-H registers.
616
 
617
`set sh calling-convention CONVENTION'
618
     Set the calling-convention used when calling functions from GDB.
619
     Allowed values are `gcc', which is the default setting, and
620
     `renesas'.  With the `gcc' setting, functions are called using the
621
     GCC calling convention.  If the DWARF-2 information of the called
622
     function specifies that the function follows the Renesas calling
623
     convention, the function is called using the Renesas calling
624
     convention.  If the calling convention is set to `renesas', the
625
     Renesas calling convention is always used, regardless of the
626
     DWARF-2 information.  This can be used to override the default of
627
     `gcc' if debug information is missing, or the compiler does not
628
     emit the DWARF-2 calling convention entry for a function.
629
 
630
`show sh calling-convention'
631
     Show the current calling convention setting.
632
 
633
 
634

635
File: gdb.info,  Node: Architectures,  Prev: Embedded Processors,  Up: Configurations
636
 
637
21.4 Architectures
638
==================
639
 
640
This section describes characteristics of architectures that affect all
641
uses of GDB with the architecture, both native and cross.
642
 
643
* Menu:
644
 
645
* i386::
646
* A29K::
647
* Alpha::
648
* MIPS::
649
* HPPA::               HP PA architecture
650
* SPU::                Cell Broadband Engine SPU architecture
651
* PowerPC::
652
 
653

654
File: gdb.info,  Node: i386,  Next: A29K,  Up: Architectures
655
 
656
21.4.1 x86 Architecture-specific Issues
657
---------------------------------------
658
 
659
`set struct-convention MODE'
660
     Set the convention used by the inferior to return `struct's and
661
     `union's from functions to MODE.  Possible values of MODE are
662
     `"pcc"', `"reg"', and `"default"' (the default).  `"default"' or
663
     `"pcc"' means that `struct's are returned on the stack, while
664
     `"reg"' means that a `struct' or a `union' whose size is 1, 2, 4,
665
     or 8 bytes will be returned in a register.
666
 
667
`show struct-convention'
668
     Show the current setting of the convention to return `struct's
669
     from functions.
670
 
671

672
File: gdb.info,  Node: A29K,  Next: Alpha,  Prev: i386,  Up: Architectures
673
 
674
21.4.2 A29K
675
-----------
676
 
677
`set rstack_high_address ADDRESS'
678
     On AMD 29000 family processors, registers are saved in a separate
679
     "register stack".  There is no way for GDB to determine the extent
680
     of this stack.  Normally, GDB just assumes that the stack is
681
     "large enough".  This may result in GDB referencing memory
682
     locations that do not exist.  If necessary, you can get around
683
     this problem by specifying the ending address of the register
684
     stack with the `set rstack_high_address' command.  The argument
685
     should be an address, which you probably want to precede with `0x'
686
     to specify in hexadecimal.
687
 
688
`show rstack_high_address'
689
     Display the current limit of the register stack, on AMD 29000
690
     family processors.
691
 
692
 
693

694
File: gdb.info,  Node: Alpha,  Next: MIPS,  Prev: A29K,  Up: Architectures
695
 
696
21.4.3 Alpha
697
------------
698
 
699
See the following section.
700
 
701

702
File: gdb.info,  Node: MIPS,  Next: HPPA,  Prev: Alpha,  Up: Architectures
703
 
704
21.4.4 MIPS
705
-----------
706
 
707
Alpha- and MIPS-based computers use an unusual stack frame, which
708
sometimes requires GDB to search backward in the object code to find
709
the beginning of a function.
710
 
711
   To improve response time (especially for embedded applications, where
712
GDB may be restricted to a slow serial line for this search) you may
713
want to limit the size of this search, using one of these commands:
714
 
715
`set heuristic-fence-post LIMIT'
716
     Restrict GDB to examining at most LIMIT bytes in its search for
717
     the beginning of a function.  A value of 0 (the default) means
718
     there is no limit.  However, except for 0, the larger the limit
719
     the more bytes `heuristic-fence-post' must search and therefore
720
     the longer it takes to run.  You should only need to use this
721
     command when debugging a stripped executable.
722
 
723
`show heuristic-fence-post'
724
     Display the current limit.
725
 
726
These commands are available _only_ when GDB is configured for
727
debugging programs on Alpha or MIPS processors.
728
 
729
   Several MIPS-specific commands are available when debugging MIPS
730
programs:
731
 
732
`set mips abi ARG'
733
     Tell GDB which MIPS ABI is used by the inferior.  Possible values
734
     of ARG are:
735
 
736
    `auto'
737
          The default ABI associated with the current binary (this is
738
          the default).
739
 
740
    `o32'
741
 
742
    `o64'
743
 
744
    `n32'
745
 
746
    `n64'
747
 
748
    `eabi32'
749
 
750
    `eabi64'
751
 
752
    `auto'
753
 
754
`show mips abi'
755
     Show the MIPS ABI used by GDB to debug the inferior.
756
 
757
`set mipsfpu'
758
`show mipsfpu'
759
     *Note set mipsfpu: MIPS Embedded.
760
 
761
`set mips mask-address ARG'
762
     This command determines whether the most-significant 32 bits of
763
     64-bit MIPS addresses are masked off.  The argument ARG can be
764
     `on', `off', or `auto'.  The latter is the default setting, which
765
     lets GDB determine the correct value.
766
 
767
`show mips mask-address'
768
     Show whether the upper 32 bits of MIPS addresses are masked off or
769
     not.
770
 
771
`set remote-mips64-transfers-32bit-regs'
772
     This command controls compatibility with 64-bit MIPS targets that
773
     transfer data in 32-bit quantities.  If you have an old MIPS 64
774
     target that transfers 32 bits for some registers, like SR and FSR,
775
     and 64 bits for other registers, set this option to `on'.
776
 
777
`show remote-mips64-transfers-32bit-regs'
778
     Show the current setting of compatibility with older MIPS 64
779
     targets.
780
 
781
`set debug mips'
782
     This command turns on and off debugging messages for the
783
     MIPS-specific target code in GDB.
784
 
785
`show debug mips'
786
     Show the current setting of MIPS debugging messages.
787
 
788

789
File: gdb.info,  Node: HPPA,  Next: SPU,  Prev: MIPS,  Up: Architectures
790
 
791
21.4.5 HPPA
792
-----------
793
 
794
When GDB is debugging the HP PA architecture, it provides the following
795
special commands:
796
 
797
`set debug hppa'
798
     This command determines whether HPPA architecture-specific
799
     debugging messages are to be displayed.
800
 
801
`show debug hppa'
802
     Show whether HPPA debugging messages are displayed.
803
 
804
`maint print unwind ADDRESS'
805
     This command displays the contents of the unwind table entry at the
806
     given ADDRESS.
807
 
808
 
809

810
File: gdb.info,  Node: SPU,  Next: PowerPC,  Prev: HPPA,  Up: Architectures
811
 
812
21.4.6 Cell Broadband Engine SPU architecture
813
---------------------------------------------
814
 
815
When GDB is debugging the Cell Broadband Engine SPU architecture, it
816
provides the following special commands:
817
 
818
`info spu event'
819
     Display SPU event facility status.  Shows current event mask and
820
     pending event status.
821
 
822
`info spu signal'
823
     Display SPU signal notification facility status.  Shows pending
824
     signal-control word and signal notification mode of both signal
825
     notification channels.
826
 
827
`info spu mailbox'
828
     Display SPU mailbox facility status.  Shows all pending entries,
829
     in order of processing, in each of the SPU Write Outbound, SPU
830
     Write Outbound Interrupt, and SPU Read Inbound mailboxes.
831
 
832
`info spu dma'
833
     Display MFC DMA status.  Shows all pending commands in the MFC DMA
834
     queue.  For each entry, opcode, tag, class IDs, effective and
835
     local store addresses and transfer size are shown.
836
 
837
`info spu proxydma'
838
     Display MFC Proxy-DMA status.  Shows all pending commands in the
839
     MFC Proxy-DMA queue.  For each entry, opcode, tag, class IDs,
840
     effective and local store addresses and transfer size are shown.
841
 
842
 
843
   When GDB is debugging a combined PowerPC/SPU application on the Cell
844
Broadband Engine, it provides in addition the following special
845
commands:
846
 
847
`set spu stop-on-load ARG'
848
     Set whether to stop for new SPE threads.  When set to `on', GDB
849
     will give control to the user when a new SPE thread enters its
850
     `main' function.  The default is `off'.
851
 
852
`show spu stop-on-load'
853
     Show whether to stop for new SPE threads.
854
 
855
`set spu auto-flush-cache ARG'
856
     Set whether to automatically flush the software-managed cache.
857
     When set to `on', GDB will automatically cause the SPE
858
     software-managed cache to be flushed whenever SPE execution stops.
859
     This provides a consistent view of PowerPC memory that is
860
     accessed via the cache.  If an application does not use the
861
     software-managed cache, this option has no effect.
862
 
863
`show spu auto-flush-cache'
864
     Show whether to automatically flush the software-managed cache.
865
 
866
 
867

868
File: gdb.info,  Node: PowerPC,  Prev: SPU,  Up: Architectures
869
 
870
21.4.7 PowerPC
871
--------------
872
 
873
When GDB is debugging the PowerPC architecture, it provides a set of
874
pseudo-registers to enable inspection of 128-bit wide Decimal Floating
875
Point numbers stored in the floating point registers. These values must
876
be stored in two consecutive registers, always starting at an even
877
register like `f0' or `f2'.
878
 
879
   The pseudo-registers go from `$dl0' through `$dl15', and are formed
880
by joining the even/odd register pairs `f0' and `f1' for `$dl0', `f2'
881
and `f3' for `$dl1' and so on.
882
 
883
   For POWER7 processors, GDB provides a set of pseudo-registers, the
884
64-bit wide Extended Floating Point Registers (`f32' through `f63').
885
 
886

887
File: gdb.info,  Node: Controlling GDB,  Next: Extending GDB,  Prev: Configurations,  Up: Top
888
 
889
22 Controlling GDB
890
******************
891
 
892
You can alter the way GDB interacts with you by using the `set'
893
command.  For commands controlling how GDB displays data, see *Note
894
Print Settings: Print Settings.  Other settings are described here.
895
 
896
* Menu:
897
 
898
* Prompt::                      Prompt
899
* Editing::                     Command editing
900
* Command History::             Command history
901
* Screen Size::                 Screen size
902
* Numbers::                     Numbers
903
* ABI::                         Configuring the current ABI
904
* Messages/Warnings::           Optional warnings and messages
905
* Debugging Output::            Optional messages about internal happenings
906
* Other Misc Settings::         Other Miscellaneous Settings
907
 
908

909
File: gdb.info,  Node: Prompt,  Next: Editing,  Up: Controlling GDB
910
 
911
22.1 Prompt
912
===========
913
 
914
GDB indicates its readiness to read a command by printing a string
915
called the "prompt".  This string is normally `(gdb)'.  You can change
916
the prompt string with the `set prompt' command.  For instance, when
917
debugging GDB with GDB, it is useful to change the prompt in one of the
918
GDB sessions so that you can always tell which one you are talking to.
919
 
920
   _Note:_  `set prompt' does not add a space for you after the prompt
921
you set.  This allows you to set a prompt which ends in a space or a
922
prompt that does not.
923
 
924
`set prompt NEWPROMPT'
925
     Directs GDB to use NEWPROMPT as its prompt string henceforth.
926
 
927
`show prompt'
928
     Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
929
 
930

931
File: gdb.info,  Node: Editing,  Next: Command History,  Prev: Prompt,  Up: Controlling GDB
932
 
933
22.2 Command Editing
934
====================
935
 
936
GDB reads its input commands via the "Readline" interface.  This GNU
937
library provides consistent behavior for programs which provide a
938
command line interface to the user.  Advantages are GNU Emacs-style or
939
"vi"-style inline editing of commands, `csh'-like history substitution,
940
and a storage and recall of command history across debugging sessions.
941
 
942
   You may control the behavior of command line editing in GDB with the
943
command `set'.
944
 
945
`set editing'
946
`set editing on'
947
     Enable command line editing (enabled by default).
948
 
949
`set editing off'
950
     Disable command line editing.
951
 
952
`show editing'
953
     Show whether command line editing is enabled.
954
 
955
   *Note Command Line Editing::, for more details about the Readline
956
interface.  Users unfamiliar with GNU Emacs or `vi' are encouraged to
957
read that chapter.
958
 
959

960
File: gdb.info,  Node: Command History,  Next: Screen Size,  Prev: Editing,  Up: Controlling GDB
961
 
962
22.3 Command History
963
====================
964
 
965
GDB can keep track of the commands you type during your debugging
966
sessions, so that you can be certain of precisely what happened.  Use
967
these commands to manage the GDB command history facility.
968
 
969
   GDB uses the GNU History library, a part of the Readline package, to
970
provide the history facility.  *Note Using History Interactively::, for
971
the detailed description of the History library.
972
 
973
   To issue a command to GDB without affecting certain aspects of the
974
state which is seen by users, prefix it with `server ' (*note Server
975
Prefix::).  This means that this command will not affect the command
976
history, nor will it affect GDB's notion of which command to repeat if
977
 is pressed on a line by itself.
978
 
979
   The server prefix does not affect the recording of values into the
980
value history; to print a value without recording it into the value
981
history, use the `output' command instead of the `print' command.
982
 
983
   Here is the description of GDB commands related to command history.
984
 
985
`set history filename FNAME'
986
     Set the name of the GDB command history file to FNAME.  This is
987
     the file where GDB reads an initial command history list, and
988
     where it writes the command history from this session when it
989
     exits.  You can access this list through history expansion or
990
     through the history command editing characters listed below.  This
991
     file defaults to the value of the environment variable
992
     `GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS)
993
     if this variable is not set.
994
 
995
`set history save'
996
`set history save on'
997
     Record command history in a file, whose name may be specified with
998
     the `set history filename' command.  By default, this option is
999
     disabled.
1000
 
1001
`set history save off'
1002
     Stop recording command history in a file.
1003
 
1004
`set history size SIZE'
1005
     Set the number of commands which GDB keeps in its history list.
1006
     This defaults to the value of the environment variable `HISTSIZE',
1007
     or to 256 if this variable is not set.
1008
 
1009
   History expansion assigns special meaning to the character `!'.
1010
*Note Event Designators::, for more details.
1011
 
1012
   Since `!' is also the logical not operator in C, history expansion
1013
is off by default. If you decide to enable history expansion with the
1014
`set history expansion on' command, you may sometimes need to follow
1015
`!' (when it is used as logical not, in an expression) with a space or
1016
a tab to prevent it from being expanded.  The readline history
1017
facilities do not attempt substitution on the strings `!=' and `!(',
1018
even when history expansion is enabled.
1019
 
1020
   The commands to control history expansion are:
1021
 
1022
`set history expansion on'
1023
`set history expansion'
1024
     Enable history expansion.  History expansion is off by default.
1025
 
1026
`set history expansion off'
1027
     Disable history expansion.
1028
 
1029
`show history'
1030
`show history filename'
1031
`show history save'
1032
`show history size'
1033
`show history expansion'
1034
     These commands display the state of the GDB history parameters.
1035
     `show history' by itself displays all four states.
1036
 
1037
`show commands'
1038
     Display the last ten commands in the command history.
1039
 
1040
`show commands N'
1041
     Print ten commands centered on command number N.
1042
 
1043
`show commands +'
1044
     Print ten commands just after the commands last printed.
1045
 
1046

1047
File: gdb.info,  Node: Screen Size,  Next: Numbers,  Prev: Command History,  Up: Controlling GDB
1048
 
1049
22.4 Screen Size
1050
================
1051
 
1052
Certain commands to GDB may produce large amounts of information output
1053
to the screen.  To help you read all of it, GDB pauses and asks you for
1054
input at the end of each page of output.  Type  when you want to
1055
continue the output, or `q' to discard the remaining output.  Also, the
1056
screen width setting determines when to wrap lines of output.
1057
Depending on what is being printed, GDB tries to break the line at a
1058
readable place, rather than simply letting it overflow onto the
1059
following line.
1060
 
1061
   Normally GDB knows the size of the screen from the terminal driver
1062
software.  For example, on Unix GDB uses the termcap data base together
1063
with the value of the `TERM' environment variable and the `stty rows'
1064
and `stty cols' settings.  If this is not correct, you can override it
1065
with the `set height' and `set width' commands:
1066
 
1067
`set height LPP'
1068
`show height'
1069
`set width CPL'
1070
`show width'
1071
     These `set' commands specify a screen height of LPP lines and a
1072
     screen width of CPL characters.  The associated `show' commands
1073
     display the current settings.
1074
 
1075
     If you specify a height of zero lines, GDB does not pause during
1076
     output no matter how long the output is.  This is useful if output
1077
     is to a file or to an editor buffer.
1078
 
1079
     Likewise, you can specify `set width 0' to prevent GDB from
1080
     wrapping its output.
1081
 
1082
`set pagination on'
1083
`set pagination off'
1084
     Turn the output pagination on or off; the default is on.  Turning
1085
     pagination off is the alternative to `set height 0'.
1086
 
1087
`show pagination'
1088
     Show the current pagination mode.
1089
 
1090

1091
File: gdb.info,  Node: Numbers,  Next: ABI,  Prev: Screen Size,  Up: Controlling GDB
1092
 
1093
22.5 Numbers
1094
============
1095
 
1096
You can always enter numbers in octal, decimal, or hexadecimal in GDB
1097
by the usual conventions: octal numbers begin with `0', decimal numbers
1098
end with `.', and hexadecimal numbers begin with `0x'.  Numbers that
1099
neither begin with `0' or `0x', nor end with a `.' are, by default,
1100
entered in base 10; likewise, the default display for numbers--when no
1101
particular format is specified--is base 10.  You can change the default
1102
base for both input and output with the commands described below.
1103
 
1104
`set input-radix BASE'
1105
     Set the default base for numeric input.  Supported choices for
1106
     BASE are decimal 8, 10, or 16.  BASE must itself be specified
1107
     either unambiguously or using the current input radix; for
1108
     example, any of
1109
 
1110
          set input-radix 012
1111
          set input-radix 10.
1112
          set input-radix 0xa
1113
 
1114
     sets the input base to decimal.  On the other hand, `set
1115
     input-radix 10' leaves the input radix unchanged, no matter what
1116
     it was, since `10', being without any leading or trailing signs of
1117
     its base, is interpreted in the current radix.  Thus, if the
1118
     current radix is 16, `10' is interpreted in hex, i.e. as 16
1119
     decimal, which doesn't change the radix.
1120
 
1121
`set output-radix BASE'
1122
     Set the default base for numeric display.  Supported choices for
1123
     BASE are decimal 8, 10, or 16.  BASE must itself be specified
1124
     either unambiguously or using the current input radix.
1125
 
1126
`show input-radix'
1127
     Display the current default base for numeric input.
1128
 
1129
`show output-radix'
1130
     Display the current default base for numeric display.
1131
 
1132
`set radix [BASE]'
1133
`show radix'
1134
     These commands set and show the default base for both input and
1135
     output of numbers.  `set radix' sets the radix of input and output
1136
     to the same base; without an argument, it resets the radix back to
1137
     its default value of 10.
1138
 
1139
 
1140

1141
File: gdb.info,  Node: ABI,  Next: Messages/Warnings,  Prev: Numbers,  Up: Controlling GDB
1142
 
1143
22.6 Configuring the Current ABI
1144
================================
1145
 
1146
GDB can determine the "ABI" (Application Binary Interface) of your
1147
application automatically.  However, sometimes you need to override its
1148
conclusions.  Use these commands to manage GDB's view of the current
1149
ABI.
1150
 
1151
   One GDB configuration can debug binaries for multiple operating
1152
system targets, either via remote debugging or native emulation.  GDB
1153
will autodetect the "OS ABI" (Operating System ABI) in use, but you can
1154
override its conclusion using the `set osabi' command.  One example
1155
where this is useful is in debugging of binaries which use an alternate
1156
C library (e.g. UCLIBC for GNU/Linux) which does not have the same
1157
identifying marks that the standard C library for your platform
1158
provides.
1159
 
1160
`show osabi'
1161
     Show the OS ABI currently in use.
1162
 
1163
`set osabi'
1164
     With no argument, show the list of registered available OS ABI's.
1165
 
1166
`set osabi ABI'
1167
     Set the current OS ABI to ABI.
1168
 
1169
   Generally, the way that an argument of type `float' is passed to a
1170
function depends on whether the function is prototyped.  For a
1171
prototyped (i.e. ANSI/ISO style) function, `float' arguments are passed
1172
unchanged, according to the architecture's convention for `float'.  For
1173
unprototyped (i.e. K&R style) functions, `float' arguments are first
1174
promoted to type `double' and then passed.
1175
 
1176
   Unfortunately, some forms of debug information do not reliably
1177
indicate whether a function is prototyped.  If GDB calls a function
1178
that is not marked as prototyped, it consults `set
1179
coerce-float-to-double'.
1180
 
1181
`set coerce-float-to-double'
1182
`set coerce-float-to-double on'
1183
     Arguments of type `float' will be promoted to `double' when passed
1184
     to an unprototyped function.  This is the default setting.
1185
 
1186
`set coerce-float-to-double off'
1187
     Arguments of type `float' will be passed directly to unprototyped
1188
     functions.
1189
 
1190
`show coerce-float-to-double'
1191
     Show the current setting of promoting `float' to `double'.
1192
 
1193
   GDB needs to know the ABI used for your program's C++ objects.  The
1194
correct C++ ABI depends on which C++ compiler was used to build your
1195
application.  GDB only fully supports programs with a single C++ ABI;
1196
if your program contains code using multiple C++ ABI's or if GDB can
1197
not identify your program's ABI correctly, you can tell GDB which ABI
1198
to use.  Currently supported ABI's include "gnu-v2", for `g++' versions
1199
before 3.0, "gnu-v3", for `g++' versions 3.0 and later, and "hpaCC" for
1200
the HP ANSI C++ compiler.  Other C++ compilers may use the "gnu-v2" or
1201
"gnu-v3" ABI's as well.  The default setting is "auto".
1202
 
1203
`show cp-abi'
1204
     Show the C++ ABI currently in use.
1205
 
1206
`set cp-abi'
1207
     With no argument, show the list of supported C++ ABI's.
1208
 
1209
`set cp-abi ABI'
1210
`set cp-abi auto'
1211
     Set the current C++ ABI to ABI, or return to automatic detection.
1212
 
1213

1214
File: gdb.info,  Node: Messages/Warnings,  Next: Debugging Output,  Prev: ABI,  Up: Controlling GDB
1215
 
1216
22.7 Optional Warnings and Messages
1217
===================================
1218
 
1219
By default, GDB is silent about its inner workings.  If you are running
1220
on a slow machine, you may want to use the `set verbose' command.  This
1221
makes GDB tell you when it does a lengthy internal operation, so you
1222
will not think it has crashed.
1223
 
1224
   Currently, the messages controlled by `set verbose' are those which
1225
announce that the symbol table for a source file is being read; see
1226
`symbol-file' in *Note Commands to Specify Files: Files.
1227
 
1228
`set verbose on'
1229
     Enables GDB output of certain informational messages.
1230
 
1231
`set verbose off'
1232
     Disables GDB output of certain informational messages.
1233
 
1234
`show verbose'
1235
     Displays whether `set verbose' is on or off.
1236
 
1237
   By default, if GDB encounters bugs in the symbol table of an object
1238
file, it is silent; but if you are debugging a compiler, you may find
1239
this information useful (*note Errors Reading Symbol Files: Symbol
1240
Errors.).
1241
 
1242
`set complaints LIMIT'
1243
     Permits GDB to output LIMIT complaints about each type of unusual
1244
     symbols before becoming silent about the problem.  Set LIMIT to
1245
     zero to suppress all complaints; set it to a large number to
1246
     prevent complaints from being suppressed.
1247
 
1248
`show complaints'
1249
     Displays how many symbol complaints GDB is permitted to produce.
1250
 
1251
 
1252
   By default, GDB is cautious, and asks what sometimes seems to be a
1253
lot of stupid questions to confirm certain commands.  For example, if
1254
you try to run a program which is already running:
1255
 
1256
     (gdb) run
1257
     The program being debugged has been started already.
1258
     Start it from the beginning? (y or n)
1259
 
1260
   If you are willing to unflinchingly face the consequences of your own
1261
commands, you can disable this "feature":
1262
 
1263
`set confirm off'
1264
     Disables confirmation requests.
1265
 
1266
`set confirm on'
1267
     Enables confirmation requests (the default).
1268
 
1269
`show confirm'
1270
     Displays state of confirmation requests.
1271
 
1272
 
1273
   If you need to debug user-defined commands or sourced files you may
1274
find it useful to enable "command tracing".  In this mode each command
1275
will be printed as it is executed, prefixed with one or more `+'
1276
symbols, the quantity denoting the call depth of each command.
1277
 
1278
`set trace-commands on'
1279
     Enable command tracing.
1280
 
1281
`set trace-commands off'
1282
     Disable command tracing.
1283
 
1284
`show trace-commands'
1285
     Display the current state of command tracing.
1286
 
1287

1288
File: gdb.info,  Node: Debugging Output,  Next: Other Misc Settings,  Prev: Messages/Warnings,  Up: Controlling GDB
1289
 
1290
22.8 Optional Messages about Internal Happenings
1291
================================================
1292
 
1293
GDB has commands that enable optional debugging messages from various
1294
GDB subsystems; normally these commands are of interest to GDB
1295
maintainers, or when reporting a bug.  This section documents those
1296
commands.
1297
 
1298
`set exec-done-display'
1299
     Turns on or off the notification of asynchronous commands'
1300
     completion.  When on, GDB will print a message when an
1301
     asynchronous command finishes its execution.  The default is off.
1302
 
1303
`show exec-done-display'
1304
     Displays the current setting of asynchronous command completion
1305
     notification.
1306
 
1307
`set debug arch'
1308
     Turns on or off display of gdbarch debugging info.  The default is
1309
     off
1310
 
1311
`show debug arch'
1312
     Displays the current state of displaying gdbarch debugging info.
1313
 
1314
`set debug aix-thread'
1315
     Display debugging messages about inner workings of the AIX thread
1316
     module.
1317
 
1318
`show debug aix-thread'
1319
     Show the current state of AIX thread debugging info display.
1320
 
1321
`set debug dwarf2-die'
1322
     Dump DWARF2 DIEs after they are read in.  The value is the number
1323
     of nesting levels to print.  A value of zero turns off the display.
1324
 
1325
`show debug dwarf2-die'
1326
     Show the current state of DWARF2 DIE debugging.
1327
 
1328
`set debug displaced'
1329
     Turns on or off display of GDB debugging info for the displaced
1330
     stepping support.  The default is off.
1331
 
1332
`show debug displaced'
1333
     Displays the current state of displaying GDB debugging info
1334
     related to displaced stepping.
1335
 
1336
`set debug event'
1337
     Turns on or off display of GDB event debugging info.  The default
1338
     is off.
1339
 
1340
`show debug event'
1341
     Displays the current state of displaying GDB event debugging info.
1342
 
1343
`set debug expression'
1344
     Turns on or off display of debugging info about GDB expression
1345
     parsing.  The default is off.
1346
 
1347
`show debug expression'
1348
     Displays the current state of displaying debugging info about GDB
1349
     expression parsing.
1350
 
1351
`set debug frame'
1352
     Turns on or off display of GDB frame debugging info.  The default
1353
     is off.
1354
 
1355
`show debug frame'
1356
     Displays the current state of displaying GDB frame debugging info.
1357
 
1358
`set debug gnu-nat'
1359
     Turns on or off debugging messages from the GNU/Hurd debug support.
1360
 
1361
`show debug gnu-nat'
1362
     Show the current state of GNU/Hurd debugging messages.
1363
 
1364
`set debug infrun'
1365
     Turns on or off display of GDB debugging info for running the
1366
     inferior.  The default is off.  `infrun.c' contains GDB's runtime
1367
     state machine used for implementing operations such as
1368
     single-stepping the inferior.
1369
 
1370
`show debug infrun'
1371
     Displays the current state of GDB inferior debugging.
1372
 
1373
`set debug lin-lwp'
1374
     Turns on or off debugging messages from the Linux LWP debug
1375
     support.
1376
 
1377
`show debug lin-lwp'
1378
     Show the current state of Linux LWP debugging messages.
1379
 
1380
`set debug lin-lwp-async'
1381
     Turns on or off debugging messages from the Linux LWP async debug
1382
     support.
1383
 
1384
`show debug lin-lwp-async'
1385
     Show the current state of Linux LWP async debugging messages.
1386
 
1387
`set debug observer'
1388
     Turns on or off display of GDB observer debugging.  This includes
1389
     info such as the notification of observable events.
1390
 
1391
`show debug observer'
1392
     Displays the current state of observer debugging.
1393
 
1394
`set debug overload'
1395
     Turns on or off display of GDB C++ overload debugging info. This
1396
     includes info such as ranking of functions, etc.  The default is
1397
     off.
1398
 
1399
`show debug overload'
1400
     Displays the current state of displaying GDB C++ overload
1401
     debugging info.
1402
 
1403
`set debug parser'
1404
     Turns on or off the display of expression parser debugging output.
1405
     Internally, this sets the `yydebug' variable in the expression
1406
     parser.  *Note Tracing Your Parser: (bison)Tracing, for details.
1407
     The default is off.
1408
 
1409
`show debug parser'
1410
     Show the current state of expression parser debugging.
1411
 
1412
`set debug remote'
1413
     Turns on or off display of reports on all packets sent back and
1414
     forth across the serial line to the remote machine.  The info is
1415
     printed on the GDB standard output stream. The default is off.
1416
 
1417
`show debug remote'
1418
     Displays the state of display of remote packets.
1419
 
1420
`set debug serial'
1421
     Turns on or off display of GDB serial debugging info. The default
1422
     is off.
1423
 
1424
`show debug serial'
1425
     Displays the current state of displaying GDB serial debugging info.
1426
 
1427
`set debug solib-frv'
1428
     Turns on or off debugging messages for FR-V shared-library code.
1429
 
1430
`show debug solib-frv'
1431
     Display the current state of FR-V shared-library code debugging
1432
     messages.
1433
 
1434
`set debug target'
1435
     Turns on or off display of GDB target debugging info. This info
1436
     includes what is going on at the target level of GDB, as it
1437
     happens. The default is 0.  Set it to 1 to track events, and to 2
1438
     to also track the value of large memory transfers.  Changes to
1439
     this flag do not take effect until the next time you connect to a
1440
     target or use the `run' command.
1441
 
1442
`show debug target'
1443
     Displays the current state of displaying GDB target debugging info.
1444
 
1445
`set debug timestamp'
1446
     Turns on or off display of timestamps with GDB debugging info.
1447
     When enabled, seconds and microseconds are displayed before each
1448
     debugging message.
1449
 
1450
`show debug timestamp'
1451
     Displays the current state of displaying timestamps with GDB
1452
     debugging info.
1453
 
1454
`set debugvarobj'
1455
     Turns on or off display of GDB variable object debugging info. The
1456
     default is off.
1457
 
1458
`show debugvarobj'
1459
     Displays the current state of displaying GDB variable object
1460
     debugging info.
1461
 
1462
`set debug xml'
1463
     Turns on or off debugging messages for built-in XML parsers.
1464
 
1465
`show debug xml'
1466
     Displays the current state of XML debugging messages.
1467
 
1468

1469
File: gdb.info,  Node: Other Misc Settings,  Prev: Debugging Output,  Up: Controlling GDB
1470
 
1471
22.9 Other Miscellaneous Settings
1472
=================================
1473
 
1474
`set interactive-mode'
1475
     If `on', forces GDB to operate interactively.  If `off', forces
1476
     GDB to operate non-interactively, If `auto' (the default), GDB
1477
     guesses which mode to use, based on whether the debugger was
1478
     started in a terminal or not.
1479
 
1480
     In the vast majority of cases, the debugger should be able to guess
1481
     correctly which mode should be used.  But this setting can be
1482
     useful in certain specific cases, such as running a MinGW GDB
1483
     inside a cygwin window.
1484
 
1485
`show interactive-mode'
1486
     Displays whether the debugger is operating in interactive mode or
1487
     not.
1488
 
1489

1490
File: gdb.info,  Node: Extending GDB,  Next: Interpreters,  Prev: Controlling GDB,  Up: Top
1491
 
1492
23 Extending GDB
1493
****************
1494
 
1495
GDB provides two mechanisms for extension.  The first is based on
1496
composition of GDB commands, and the second is based on the Python
1497
scripting language.
1498
 
1499
   To facilitate the use of these extensions, GDB is capable of
1500
evaluating the contents of a file.  When doing so, GDB can recognize
1501
which scripting language is being used by looking at the filename
1502
extension.  Files with an unrecognized filename extension are always
1503
treated as a GDB Command Files.  *Note Command files: Command Files.
1504
 
1505
   You can control how GDB evaluates these files with the following
1506
setting:
1507
 
1508
`set script-extension off'
1509
     All scripts are always evaluated as GDB Command Files.
1510
 
1511
`set script-extension soft'
1512
     The debugger determines the scripting language based on filename
1513
     extension.  If this scripting language is supported, GDB evaluates
1514
     the script using that language.  Otherwise, it evaluates the file
1515
     as a GDB Command File.
1516
 
1517
`set script-extension strict'
1518
     The debugger determines the scripting language based on filename
1519
     extension, and evaluates the script using that language.  If the
1520
     language is not supported, then the evaluation fails.
1521
 
1522
`show script-extension'
1523
     Display the current value of the `script-extension' option.
1524
 
1525
 
1526
* Menu:
1527
 
1528
* Sequences::          Canned Sequences of Commands
1529
* Python::             Scripting GDB using Python
1530
 
1531

1532
File: gdb.info,  Node: Sequences,  Next: Python,  Up: Extending GDB
1533
 
1534
23.1 Canned Sequences of Commands
1535
=================================
1536
 
1537
Aside from breakpoint commands (*note Breakpoint Command Lists: Break
1538
Commands.), GDB provides two ways to store sequences of commands for
1539
execution as a unit: user-defined commands and command files.
1540
 
1541
* Menu:
1542
 
1543
* Define::             How to define your own commands
1544
* Hooks::              Hooks for user-defined commands
1545
* Command Files::      How to write scripts of commands to be stored in a file
1546
* Output::             Commands for controlled output
1547
 
1548

1549
File: gdb.info,  Node: Define,  Next: Hooks,  Up: Sequences
1550
 
1551
23.1.1 User-defined Commands
1552
----------------------------
1553
 
1554
A "user-defined command" is a sequence of GDB commands to which you
1555
assign a new name as a command.  This is done with the `define'
1556
command.  User commands may accept up to 10 arguments separated by
1557
whitespace.  Arguments are accessed within the user command via
1558
`$arg0...$arg9'.  A trivial example:
1559
 
1560
     define adder
1561
       print $arg0 + $arg1 + $arg2
1562
     end
1563
 
1564
To execute the command use:
1565
 
1566
     adder 1 2 3
1567
 
1568
This defines the command `adder', which prints the sum of its three
1569
arguments.  Note the arguments are text substitutions, so they may
1570
reference variables, use complex expressions, or even perform inferior
1571
functions calls.
1572
 
1573
   In addition, `$argc' may be used to find out how many arguments have
1574
been passed.  This expands to a number in the range 0...10.
1575
 
1576
     define adder
1577
       if $argc == 2
1578
         print $arg0 + $arg1
1579
       end
1580
       if $argc == 3
1581
         print $arg0 + $arg1 + $arg2
1582
       end
1583
     end
1584
 
1585
`define COMMANDNAME'
1586
     Define a command named COMMANDNAME.  If there is already a command
1587
     by that name, you are asked to confirm that you want to redefine
1588
     it.  COMMANDNAME may be a bare command name consisting of letters,
1589
     numbers, dashes, and underscores.  It may also start with any
1590
     predefined prefix command.  For example, `define target my-target'
1591
     creates a user-defined `target my-target' command.
1592
 
1593
     The definition of the command is made up of other GDB command
1594
     lines, which are given following the `define' command.  The end of
1595
     these commands is marked by a line containing `end'.
1596
 
1597
`document COMMANDNAME'
1598
     Document the user-defined command COMMANDNAME, so that it can be
1599
     accessed by `help'.  The command COMMANDNAME must already be
1600
     defined.  This command reads lines of documentation just as
1601
     `define' reads the lines of the command definition, ending with
1602
     `end'.  After the `document' command is finished, `help' on command
1603
     COMMANDNAME displays the documentation you have written.
1604
 
1605
     You may use the `document' command again to change the
1606
     documentation of a command.  Redefining the command with `define'
1607
     does not change the documentation.
1608
 
1609
`dont-repeat'
1610
     Used inside a user-defined command, this tells GDB that this
1611
     command should not be repeated when the user hits  (*note
1612
     repeat last command: Command Syntax.).
1613
 
1614
`help user-defined'
1615
     List all user-defined commands, with the first line of the
1616
     documentation (if any) for each.
1617
 
1618
`show user'
1619
`show user COMMANDNAME'
1620
     Display the GDB commands used to define COMMANDNAME (but not its
1621
     documentation).  If no COMMANDNAME is given, display the
1622
     definitions for all user-defined commands.
1623
 
1624
`show max-user-call-depth'
1625
`set max-user-call-depth'
1626
     The value of `max-user-call-depth' controls how many recursion
1627
     levels are allowed in user-defined commands before GDB suspects an
1628
     infinite recursion and aborts the command.
1629
 
1630
   In addition to the above commands, user-defined commands frequently
1631
use control flow commands, described in *Note Command Files::.
1632
 
1633
   When user-defined commands are executed, the commands of the
1634
definition are not printed.  An error in any command stops execution of
1635
the user-defined command.
1636
 
1637
   If used interactively, commands that would ask for confirmation
1638
proceed without asking when used inside a user-defined command.  Many
1639
GDB commands that normally print messages to say what they are doing
1640
omit the messages when used in a user-defined command.
1641
 
1642

1643
File: gdb.info,  Node: Hooks,  Next: Command Files,  Prev: Define,  Up: Sequences
1644
 
1645
23.1.2 User-defined Command Hooks
1646
---------------------------------
1647
 
1648
You may define "hooks", which are a special kind of user-defined
1649
command.  Whenever you run the command `foo', if the user-defined
1650
command `hook-foo' exists, it is executed (with no arguments) before
1651
that command.
1652
 
1653
   A hook may also be defined which is run after the command you
1654
executed.  Whenever you run the command `foo', if the user-defined
1655
command `hookpost-foo' exists, it is executed (with no arguments) after
1656
that command.  Post-execution hooks may exist simultaneously with
1657
pre-execution hooks, for the same command.
1658
 
1659
   It is valid for a hook to call the command which it hooks.  If this
1660
occurs, the hook is not re-executed, thereby avoiding infinite
1661
recursion.
1662
 
1663
   In addition, a pseudo-command, `stop' exists.  Defining
1664
(`hook-stop') makes the associated commands execute every time
1665
execution stops in your program: before breakpoint commands are run,
1666
displays are printed, or the stack frame is printed.
1667
 
1668
   For example, to ignore `SIGALRM' signals while single-stepping, but
1669
treat them normally during normal execution, you could define:
1670
 
1671
     define hook-stop
1672
     handle SIGALRM nopass
1673
     end
1674
 
1675
     define hook-run
1676
     handle SIGALRM pass
1677
     end
1678
 
1679
     define hook-continue
1680
     handle SIGALRM pass
1681
     end
1682
 
1683
   As a further example, to hook at the beginning and end of the `echo'
1684
command, and to add extra text to the beginning and end of the message,
1685
you could define:
1686
 
1687
     define hook-echo
1688
     echo <<<---
1689
     end
1690
 
1691
     define hookpost-echo
1692
     echo --->>>\n
1693
     end
1694
 
1695
     (gdb) echo Hello World
1696
     <<<---Hello World--->>>
1697
     (gdb)
1698
 
1699
   You can define a hook for any single-word command in GDB, but not
1700
for command aliases; you should define a hook for the basic command
1701
name, e.g.  `backtrace' rather than `bt'.  You can hook a multi-word
1702
command by adding `hook-' or `hookpost-' to the last word of the
1703
command, e.g.  `define target hook-remote' to add a hook to `target
1704
remote'.
1705
 
1706
   If an error occurs during the execution of your hook, execution of
1707
GDB commands stops and GDB issues a prompt (before the command that you
1708
actually typed had a chance to run).
1709
 
1710
   If you try to define a hook which does not match any known command,
1711
you get a warning from the `define' command.
1712
 
1713

1714
File: gdb.info,  Node: Command Files,  Next: Output,  Prev: Hooks,  Up: Sequences
1715
 
1716
23.1.3 Command Files
1717
--------------------
1718
 
1719
A command file for GDB is a text file made of lines that are GDB
1720
commands.  Comments (lines starting with `#') may also be included.  An
1721
empty line in a command file does nothing; it does not mean to repeat
1722
the last command, as it would from the terminal.
1723
 
1724
   You can request the execution of a command file with the `source'
1725
command.  Note that the `source' command is also used to evaluate
1726
scripts that are not Command Files.  The exact behavior can be
1727
configured using the `script-extension' setting.  *Note Extending GDB:
1728
Extending GDB.
1729
 
1730
`source [`-v'] FILENAME'
1731
     Execute the command file FILENAME.
1732
 
1733
   The lines in a command file are generally executed sequentially,
1734
unless the order of execution is changed by one of the _flow-control
1735
commands_ described below.  The commands are not printed as they are
1736
executed.  An error in any command terminates execution of the command
1737
file and control is returned to the console.
1738
 
1739
   GDB searches for FILENAME in the current directory and then on the
1740
search path (specified with the `directory' command).
1741
 
1742
   If `-v', for verbose mode, is given then GDB displays each command
1743
as it is executed.  The option must be given before FILENAME, and is
1744
interpreted as part of the filename anywhere else.
1745
 
1746
   Commands that would ask for confirmation if used interactively
1747
proceed without asking when used in a command file.  Many GDB commands
1748
that normally print messages to say what they are doing omit the
1749
messages when called from command files.
1750
 
1751
   GDB also accepts command input from standard input.  In this mode,
1752
normal output goes to standard output and error output goes to standard
1753
error.  Errors in a command file supplied on standard input do not
1754
terminate execution of the command file--execution continues with the
1755
next command.
1756
 
1757
     gdb < cmds > log 2>&1
1758
 
1759
   (The syntax above will vary depending on the shell used.) This
1760
example will execute commands from the file `cmds'. All output and
1761
errors would be directed to `log'.
1762
 
1763
   Since commands stored on command files tend to be more general than
1764
commands typed interactively, they frequently need to deal with
1765
complicated situations, such as different or unexpected values of
1766
variables and symbols, changes in how the program being debugged is
1767
built, etc.  GDB provides a set of flow-control commands to deal with
1768
these complexities.  Using these commands, you can write complex
1769
scripts that loop over data structures, execute commands conditionally,
1770
etc.
1771
 
1772
`if'
1773
`else'
1774
     This command allows to include in your script conditionally
1775
     executed commands. The `if' command takes a single argument, which
1776
     is an expression to evaluate.  It is followed by a series of
1777
     commands that are executed only if the expression is true (its
1778
     value is nonzero).  There can then optionally be an `else' line,
1779
     followed by a series of commands that are only executed if the
1780
     expression was false.  The end of the list is marked by a line
1781
     containing `end'.
1782
 
1783
`while'
1784
     This command allows to write loops.  Its syntax is similar to
1785
     `if': the command takes a single argument, which is an expression
1786
     to evaluate, and must be followed by the commands to execute, one
1787
     per line, terminated by an `end'.  These commands are called the
1788
     "body" of the loop.  The commands in the body of `while' are
1789
     executed repeatedly as long as the expression evaluates to true.
1790
 
1791
`loop_break'
1792
     This command exits the `while' loop in whose body it is included.
1793
     Execution of the script continues after that `while's `end' line.
1794
 
1795
`loop_continue'
1796
     This command skips the execution of the rest of the body of
1797
     commands in the `while' loop in whose body it is included.
1798
     Execution branches to the beginning of the `while' loop, where it
1799
     evaluates the controlling expression.
1800
 
1801
`end'
1802
     Terminate the block of commands that are the body of `if', `else',
1803
     or `while' flow-control commands.
1804
 
1805

1806
File: gdb.info,  Node: Output,  Prev: Command Files,  Up: Sequences
1807
 
1808
23.1.4 Commands for Controlled Output
1809
-------------------------------------
1810
 
1811
During the execution of a command file or a user-defined command, normal
1812
GDB output is suppressed; the only output that appears is what is
1813
explicitly printed by the commands in the definition.  This section
1814
describes three commands useful for generating exactly the output you
1815
want.
1816
 
1817
`echo TEXT'
1818
     Print TEXT.  Nonprinting characters can be included in TEXT using
1819
     C escape sequences, such as `\n' to print a newline.  *No newline
1820
     is printed unless you specify one.* In addition to the standard C
1821
     escape sequences, a backslash followed by a space stands for a
1822
     space.  This is useful for displaying a string with spaces at the
1823
     beginning or the end, since leading and trailing spaces are
1824
     otherwise trimmed from all arguments.  To print ` and foo = ', use
1825
     the command `echo \ and foo = \ '.
1826
 
1827
     A backslash at the end of TEXT can be used, as in C, to continue
1828
     the command onto subsequent lines.  For example,
1829
 
1830
          echo This is some text\n\
1831
          which is continued\n\
1832
          onto several lines.\n
1833
 
1834
     produces the same output as
1835
 
1836
          echo This is some text\n
1837
          echo which is continued\n
1838
          echo onto several lines.\n
1839
 
1840
`output EXPRESSION'
1841
     Print the value of EXPRESSION and nothing but that value: no
1842
     newlines, no `$NN = '.  The value is not entered in the value
1843
     history either.  *Note Expressions: Expressions, for more
1844
     information on expressions.
1845
 
1846
`output/FMT EXPRESSION'
1847
     Print the value of EXPRESSION in format FMT.  You can use the same
1848
     formats as for `print'.  *Note Output Formats: Output Formats, for
1849
     more information.
1850
 
1851
`printf TEMPLATE, EXPRESSIONS...'
1852
     Print the values of one or more EXPRESSIONS under the control of
1853
     the string TEMPLATE.  To print several values, make EXPRESSIONS be
1854
     a comma-separated list of individual expressions, which may be
1855
     either numbers or pointers.  Their values are printed as specified
1856
     by TEMPLATE, exactly as a C program would do by executing the code
1857
     below:
1858
 
1859
          printf (TEMPLATE, EXPRESSIONS...);
1860
 
1861
     As in `C' `printf', ordinary characters in TEMPLATE are printed
1862
     verbatim, while "conversion specification" introduced by the `%'
1863
     character cause subsequent EXPRESSIONS to be evaluated, their
1864
     values converted and formatted according to type and style
1865
     information encoded in the conversion specifications, and then
1866
     printed.
1867
 
1868
     For example, you can print two values in hex like this:
1869
 
1870
          printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
1871
 
1872
     `printf' supports all the standard `C' conversion specifications,
1873
     including the flags and modifiers between the `%' character and
1874
     the conversion letter, with the following exceptions:
1875
 
1876
        * The argument-ordering modifiers, such as `2$', are not
1877
          supported.
1878
 
1879
        * The modifier `*' is not supported for specifying precision or
1880
          width.
1881
 
1882
        * The `'' flag (for separation of digits into groups according
1883
          to `LC_NUMERIC'') is not supported.
1884
 
1885
        * The type modifiers `hh', `j', `t', and `z' are not supported.
1886
 
1887
        * The conversion letter `n' (as in `%n') is not supported.
1888
 
1889
        * The conversion letters `a' and `A' are not supported.
1890
 
1891
     Note that the `ll' type modifier is supported only if the
1892
     underlying `C' implementation used to build GDB supports the `long
1893
     long int' type, and the `L' type modifier is supported only if
1894
     `long double' type is available.
1895
 
1896
     As in `C', `printf' supports simple backslash-escape sequences,
1897
     such as `\n', `\t', `\\', `\"', `\a', and `\f', that consist of
1898
     backslash followed by a single character.  Octal and hexadecimal
1899
     escape sequences are not supported.
1900
 
1901
     Additionally, `printf' supports conversion specifications for DFP
1902
     ("Decimal Floating Point") types using the following length
1903
     modifiers together with a floating point specifier.  letters:
1904
 
1905
        * `H' for printing `Decimal32' types.
1906
 
1907
        * `D' for printing `Decimal64' types.
1908
 
1909
        * `DD' for printing `Decimal128' types.
1910
 
1911
     If the underlying `C' implementation used to build GDB has support
1912
     for the three length modifiers for DFP types, other modifiers such
1913
     as width and precision will also be available for GDB to use.
1914
 
1915
     In case there is no such `C' support, no additional modifiers will
1916
     be available and the value will be printed in the standard way.
1917
 
1918
     Here's an example of printing DFP types using the above conversion
1919
     letters:
1920
          printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
1921
 
1922
 
1923

1924
File: gdb.info,  Node: Python,  Prev: Sequences,  Up: Extending GDB
1925
 
1926
23.2 Scripting GDB using Python
1927
===============================
1928
 
1929
You can script GDB using the Python programming language
1930
(http://www.python.org/).  This feature is available only if GDB was
1931
configured using `--with-python'.
1932
 
1933
* Menu:
1934
 
1935
* Python Commands::             Accessing Python from GDB.
1936
* Python API::                  Accessing GDB from Python.
1937
 
1938

1939
File: gdb.info,  Node: Python Commands,  Next: Python API,  Up: Python
1940
 
1941
23.2.1 Python Commands
1942
----------------------
1943
 
1944
GDB provides one command for accessing the Python interpreter, and one
1945
related setting:
1946
 
1947
`python [CODE]'
1948
     The `python' command can be used to evaluate Python code.
1949
 
1950
     If given an argument, the `python' command will evaluate the
1951
     argument as a Python command.  For example:
1952
 
1953
          (gdb) python print 23
1954
          23
1955
 
1956
     If you do not provide an argument to `python', it will act as a
1957
     multi-line command, like `define'.  In this case, the Python
1958
     script is made up of subsequent command lines, given after the
1959
     `python' command.  This command list is terminated using a line
1960
     containing `end'.  For example:
1961
 
1962
          (gdb) python
1963
          Type python script
1964
          End with a line saying just "end".
1965
          >print 23
1966
          >end
1967
          23
1968
 
1969
`maint set python print-stack'
1970
     By default, GDB will print a stack trace when an error occurs in a
1971
     Python script.  This can be controlled using `maint set python
1972
     print-stack': if `on', the default, then Python stack printing is
1973
     enabled; if `off', then Python stack printing is disabled.
1974
 
1975
   It is also possible to execute a Python script from the GDB
1976
interpreter:
1977
 
1978
`source `script-name''
1979
     The script name must end with `.py' and GDB must be configured to
1980
     recognize the script language based on filename extension using
1981
     the `script-extension' setting.  *Note Extending GDB: Extending
1982
     GDB.
1983
 
1984
`python execfile ("script-name")'
1985
     This method is based on the `execfile' Python built-in function,
1986
     and thus is always available.
1987
 
1988

1989
File: gdb.info,  Node: Python API,  Prev: Python Commands,  Up: Python
1990
 
1991
23.2.2 Python API
1992
-----------------
1993
 
1994
At startup, GDB overrides Python's `sys.stdout' and `sys.stderr' to
1995
print using GDB's output-paging streams.  A Python program which
1996
outputs to one of these streams may have its output interrupted by the
1997
user (*note Screen Size::).  In this situation, a Python
1998
`KeyboardInterrupt' exception is thrown.
1999
 
2000
* Menu:
2001
 
2002
* Basic Python::                Basic Python Functions.
2003
* Exception Handling::
2004
* Auto-loading::                Automatically loading Python code.
2005
* Values From Inferior::
2006
* Types In Python::             Python representation of types.
2007
* Pretty Printing::             Pretty-printing values.
2008
* Selecting Pretty-Printers::   How GDB chooses a pretty-printer.
2009
* Commands In Python::          Implementing new commands in Python.
2010
* Functions In Python::         Writing new convenience functions.
2011
* Objfiles In Python::          Object files.
2012
* Frames In Python::            Acessing inferior stack frames from Python.
2013
* Lazy Strings In Python::      Python representation of lazy strings.
2014
 
2015

2016
File: gdb.info,  Node: Basic Python,  Next: Exception Handling,  Up: Python API
2017
 
2018
23.2.2.1 Basic Python
2019
.....................
2020
 
2021
GDB introduces a new Python module, named `gdb'.  All methods and
2022
classes added by GDB are placed in this module.  GDB automatically
2023
`import's the `gdb' module for use in all scripts evaluated by the
2024
`python' command.
2025
 
2026
 -- Function: execute command [from_tty]
2027
     Evaluate COMMAND, a string, as a GDB CLI command.  If a GDB
2028
     exception happens while COMMAND runs, it is translated as
2029
     described in *Note Exception Handling: Exception Handling.  If no
2030
     exceptions occur, this function returns `None'.
2031
 
2032
     FROM_TTY specifies whether GDB ought to consider this command as
2033
     having originated from the user invoking it interactively.  It
2034
     must be a boolean value.  If omitted, it defaults to `False'.
2035
 
2036
 -- Function: parameter parameter
2037
     Return the value of a GDB parameter.  PARAMETER is a string naming
2038
     the parameter to look up; PARAMETER may contain spaces if the
2039
     parameter has a multi-part name.  For example, `print object' is a
2040
     valid parameter name.
2041
 
2042
     If the named parameter does not exist, this function throws a
2043
     `RuntimeError'.  Otherwise, the parameter's value is converted to
2044
     a Python value of the appropriate type, and returned.
2045
 
2046
 -- Function: history number
2047
     Return a value from GDB's value history (*note Value History::).
2048
     NUMBER indicates which history element to return.  If NUMBER is
2049
     negative, then GDB will take its absolute value and count backward
2050
     from the last element (i.e., the most recent element) to find the
2051
     value to return.  If NUMBER is zero, then GDB will return the most
2052
     recent element.  If the element specified by NUMBER doesn't exist
2053
     in the value history, a `RuntimeError' exception will be raised.
2054
 
2055
     If no exception is raised, the return value is always an instance
2056
     of `gdb.Value' (*note Values From Inferior::).
2057
 
2058
 -- Function: parse_and_eval expression
2059
     Parse EXPRESSION as an expression in the current language,
2060
     evaluate it, and return the result as a `gdb.Value'.  EXPRESSION
2061
     must be a string.
2062
 
2063
     This function can be useful when implementing a new command (*note
2064
     Commands In Python::), as it provides a way to parse the command's
2065
     argument as an expression.  It is also useful simply to compute
2066
     values, for example, it is the only way to get the value of a
2067
     convenience variable (*note Convenience Vars::) as a `gdb.Value'.
2068
 
2069
 -- Function: write string
2070
     Print a string to GDB's paginated standard output stream.  Writing
2071
     to `sys.stdout' or `sys.stderr' will automatically call this
2072
     function.
2073
 
2074
 -- Function: flush
2075
     Flush GDB's paginated standard output stream.  Flushing
2076
     `sys.stdout' or `sys.stderr' will automatically call this function.
2077
 
2078

2079
File: gdb.info,  Node: Exception Handling,  Next: Auto-loading,  Prev: Basic Python,  Up: Python API
2080
 
2081
23.2.2.2 Exception Handling
2082
...........................
2083
 
2084
When executing the `python' command, Python exceptions uncaught within
2085
the Python code are translated to calls to GDB error-reporting
2086
mechanism.  If the command that called `python' does not handle the
2087
error, GDB will terminate it and print an error message containing the
2088
Python exception name, the associated value, and the Python call stack
2089
backtrace at the point where the exception was raised.  Example:
2090
 
2091
     (gdb) python print foo
2092
     Traceback (most recent call last):
2093
       File "", line 1, in 
2094
     NameError: name 'foo' is not defined
2095
 
2096
   GDB errors that happen in GDB commands invoked by Python code are
2097
converted to Python `RuntimeError' exceptions.  User interrupt (via
2098
`C-c' or by typing `q' at a pagination prompt) is translated to a
2099
Python `KeyboardInterrupt' exception.  If you catch these exceptions in
2100
your Python code, your exception handler will see `RuntimeError' or
2101
`KeyboardInterrupt' as the exception type, the GDB error message as its
2102
value, and the Python call stack backtrace at the Python statement
2103
closest to where the GDB error occured as the traceback.
2104
 
2105

2106
File: gdb.info,  Node: Auto-loading,  Next: Values From Inferior,  Prev: Exception Handling,  Up: Python API
2107
 
2108
23.2.2.3 Auto-loading
2109
.....................
2110
 
2111
When a new object file is read (for example, due to the `file' command,
2112
or because the inferior has loaded a shared library), GDB will look for
2113
a file named `OBJFILE-gdb.py', where OBJFILE is the object file's real
2114
name, formed by ensuring that the file name is absolute, following all
2115
symlinks, and resolving `.' and `..'  components.  If this file exists
2116
and is readable, GDB will evaluate it as a Python script.
2117
 
2118
   If this file does not exist, and if the parameter
2119
`debug-file-directory' is set (*note Separate Debug Files::), then GDB
2120
will use for its each separated directory component `component' the
2121
file named ``component'/REAL-NAME', where REAL-NAME is the object
2122
file's real name, as described above.
2123
 
2124
   Finally, if this file does not exist, then GDB will look for a file
2125
named `DATA-DIRECTORY/python/auto-load/REAL-NAME', where DATA-DIRECTORY
2126
is GDB's data directory (available via `show data-directory', *note
2127
Data Files::), and REAL-NAME is the object file's real name, as
2128
described above.
2129
 
2130
   When reading an auto-loaded file, GDB sets the "current objfile".
2131
This is available via the `gdb.current_objfile' function (*note
2132
Objfiles In Python::).  This can be useful for registering
2133
objfile-specific pretty-printers.
2134
 
2135
   The auto-loading feature is useful for supplying application-specific
2136
debugging commands and scripts.  You can enable or disable this
2137
feature, and view its current state.
2138
 
2139
`maint set python auto-load [yes|no]'
2140
     Enable or disable the Python auto-loading feature.
2141
 
2142
`show python auto-load'
2143
     Show whether Python auto-loading is enabled or disabled.
2144
 
2145
   GDB does not track which files it has already auto-loaded.  So, your
2146
`-gdb.py' file should take care to ensure that it may be evaluated
2147
multiple times without error.
2148
 
2149

2150
File: gdb.info,  Node: Values From Inferior,  Next: Types In Python,  Prev: Auto-loading,  Up: Python API
2151
 
2152
23.2.2.4 Values From Inferior
2153
.............................
2154
 
2155
GDB provides values it obtains from the inferior program in an object
2156
of type `gdb.Value'.  GDB uses this object for its internal bookkeeping
2157
of the inferior's values, and for fetching values when necessary.
2158
 
2159
   Inferior values that are simple scalars can be used directly in
2160
Python expressions that are valid for the value's data type.  Here's an
2161
example for an integer or floating-point value `some_val':
2162
 
2163
     bar = some_val + 2
2164
 
2165
As result of this, `bar' will also be a `gdb.Value' object whose values
2166
are of the same type as those of `some_val'.
2167
 
2168
   Inferior values that are structures or instances of some class can
2169
be accessed using the Python "dictionary syntax".  For example, if
2170
`some_val' is a `gdb.Value' instance holding a structure, you can
2171
access its `foo' element with:
2172
 
2173
     bar = some_val['foo']
2174
 
2175
   Again, `bar' will also be a `gdb.Value' object.
2176
 
2177
   The following attributes are provided:
2178
 
2179
      -- Instance Variable of Value: address
2180
          If this object is addressable, this read-only attribute holds
2181
          a `gdb.Value' object representing the address.  Otherwise,
2182
          this attribute holds `None'.
2183
 
2184
      -- Instance Variable of Value: is_optimized_out
2185
          This read-only boolean attribute is true if the compiler
2186
          optimized out this value, thus it is not available for
2187
          fetching from the inferior.
2188
 
2189
      -- Instance Variable of Value: type
2190
          The type of this `gdb.Value'.  The value of this attribute is
2191
          a `gdb.Type' object.
2192
 
2193
   The following methods are provided:
2194
 
2195
      -- Method on Value: cast type
2196
          Return a new instance of `gdb.Value' that is the result of
2197
          casting this instance to the type described by TYPE, which
2198
          must be a `gdb.Type' object.  If the cast cannot be performed
2199
          for some reason, this method throws an exception.
2200
 
2201
      -- Method on Value: dereference
2202
          For pointer data types, this method returns a new `gdb.Value'
2203
          object whose contents is the object pointed to by the
2204
          pointer.  For example, if `foo' is a C pointer to an `int',
2205
          declared in your C program as
2206
 
2207
               int *foo;
2208
 
2209
          then you can use the corresponding `gdb.Value' to access what
2210
          `foo' points to like this:
2211
 
2212
               bar = foo.dereference ()
2213
 
2214
          The result `bar' will be a `gdb.Value' object holding the
2215
          value pointed to by `foo'.
2216
 
2217
      -- Method on Value: string [encoding] [errors] [length]
2218
          If this `gdb.Value' represents a string, then this method
2219
          converts the contents to a Python string.  Otherwise, this
2220
          method will throw an exception.
2221
 
2222
          Strings are recognized in a language-specific way; whether a
2223
          given `gdb.Value' represents a string is determined by the
2224
          current language.
2225
 
2226
          For C-like languages, a value is a string if it is a pointer
2227
          to or an array of characters or ints.  The string is assumed
2228
          to be terminated by a zero of the appropriate width.  However
2229
          if the optional length argument is given, the string will be
2230
          converted to that given length, ignoring any embedded zeros
2231
          that the string may contain.
2232
 
2233
          If the optional ENCODING argument is given, it must be a
2234
          string naming the encoding of the string in the `gdb.Value',
2235
          such as `"ascii"', `"iso-8859-6"' or `"utf-8"'.  It accepts
2236
          the same encodings as the corresponding argument to Python's
2237
          `string.decode' method, and the Python codec machinery will
2238
          be used to convert the string.  If ENCODING is not given, or
2239
          if ENCODING is the empty string, then either the
2240
          `target-charset' (*note Character Sets::) will be used, or a
2241
          language-specific encoding will be used, if the current
2242
          language is able to supply one.
2243
 
2244
          The optional ERRORS argument is the same as the corresponding
2245
          argument to Python's `string.decode' method.
2246
 
2247
          If the optional LENGTH argument is given, the string will be
2248
          fetched and converted to the given length.
2249
 
2250
      -- Method on Value: lazy_string [encoding] [length]
2251
          If this `gdb.Value' represents a string, then this method
2252
          converts the contents to a `gdb.LazyString' (*note Lazy
2253
          Strings In Python::).  Otherwise, this method will throw an
2254
          exception.
2255
 
2256
          If the optional ENCODING argument is given, it must be a
2257
          string naming the encoding of the `gdb.LazyString'.  Some
2258
          examples are: `ascii', `iso-8859-6' or `utf-8'.  If the
2259
          ENCODING argument is an encoding that GDB does recognize, GDB
2260
          will raise an error.
2261
 
2262
          When a lazy string is printed, the GDB encoding machinery is
2263
          used to convert the string during printing.  If the optional
2264
          ENCODING argument is not provided, or is an empty string, GDB
2265
          will automatically select the encoding most suitable for the
2266
          string type.  For further information on encoding in GDB
2267
          please see *Note Character Sets::.
2268
 
2269
          If the optional LENGTH argument is given, the string will be
2270
          fetched and encoded to the length of characters specified.  If
2271
          the LENGTH argument is not provided, the string will be
2272
          fetched and encoded until a null of appropriate width is
2273
          found.
2274
 
2275

2276
File: gdb.info,  Node: Types In Python,  Next: Pretty Printing,  Prev: Values From Inferior,  Up: Python API
2277
 
2278
23.2.2.5 Types In Python
2279
........................
2280
 
2281
GDB represents types from the inferior using the class `gdb.Type'.
2282
 
2283
   The following type-related functions are available in the `gdb'
2284
module:
2285
 
2286
 -- Function: lookup_type name [block]
2287
     This function looks up a type by name.  NAME is the name of the
2288
     type to look up.  It must be a string.
2289
 
2290
     Ordinarily, this function will return an instance of `gdb.Type'.
2291
     If the named type cannot be found, it will throw an exception.
2292
 
2293
   An instance of `Type' has the following attributes:
2294
 
2295
      -- Instance Variable of Type: code
2296
          The type code for this type.  The type code will be one of the
2297
          `TYPE_CODE_' constants defined below.
2298
 
2299
      -- Instance Variable of Type: sizeof
2300
          The size of this type, in target `char' units.  Usually, a
2301
          target's `char' type will be an 8-bit byte.  However, on some
2302
          unusual platforms, this type may have a different size.
2303
 
2304
      -- Instance Variable of Type: tag
2305
          The tag name for this type.  The tag name is the name after
2306
          `struct', `union', or `enum' in C and C++; not all languages
2307
          have this concept.  If this type has no tag name, then `None'
2308
          is returned.
2309
 
2310
   The following methods are provided:
2311
 
2312
      -- Method on Type: fields
2313
          For structure and union types, this method returns the
2314
          fields.  Range types have two fields, the minimum and maximum
2315
          values.  Enum types have one field per enum constant.
2316
          Function and method types have one field per parameter.  The
2317
          base types of C++ classes are also represented as fields.  If
2318
          the type has no fields, or does not fit into one of these
2319
          categories, an empty sequence will be returned.
2320
 
2321
          Each field is an object, with some pre-defined attributes:
2322
         `bitpos'
2323
               This attribute is not available for `static' fields (as
2324
               in C++ or Java).  For non-`static' fields, the value is
2325
               the bit position of the field.
2326
 
2327
         `name'
2328
               The name of the field, or `None' for anonymous fields.
2329
 
2330
         `artificial'
2331
               This is `True' if the field is artificial, usually
2332
               meaning that it was provided by the compiler and not the
2333
               user.  This attribute is always provided, and is `False'
2334
               if the field is not artificial.
2335
 
2336
         `is_base_class'
2337
               This is `True' if the field represents a base class of a
2338
               C++ structure.  This attribute is always provided, and
2339
               is `False' if the field is not a base class of the type
2340
               that is the argument of `fields', or if that type was
2341
               not a C++ class.
2342
 
2343
         `bitsize'
2344
               If the field is packed, or is a bitfield, then this will
2345
               have a non-zero value, which is the size of the field in
2346
               bits.  Otherwise, this will be zero; in this case the
2347
               field's size is given by its type.
2348
 
2349
         `type'
2350
               The type of the field.  This is usually an instance of
2351
               `Type', but it can be `None' in some situations.
2352
 
2353
      -- Method on Type: const
2354
          Return a new `gdb.Type' object which represents a
2355
          `const'-qualified variant of this type.
2356
 
2357
      -- Method on Type: volatile
2358
          Return a new `gdb.Type' object which represents a
2359
          `volatile'-qualified variant of this type.
2360
 
2361
      -- Method on Type: unqualified
2362
          Return a new `gdb.Type' object which represents an unqualified
2363
          variant of this type.  That is, the result is neither `const'
2364
          nor `volatile'.
2365
 
2366
      -- Method on Type: range
2367
          Return a Python `Tuple' object that contains two elements: the
2368
          low bound of the argument type and the high bound of that
2369
          type.  If the type does not have a range, GDB will raise a
2370
          `RuntimeError' exception.
2371
 
2372
      -- Method on Type: reference
2373
          Return a new `gdb.Type' object which represents a reference
2374
          to this type.
2375
 
2376
      -- Method on Type: pointer
2377
          Return a new `gdb.Type' object which represents a pointer to
2378
          this type.
2379
 
2380
      -- Method on Type: strip_typedefs
2381
          Return a new `gdb.Type' that represents the real type, after
2382
          removing all layers of typedefs.
2383
 
2384
      -- Method on Type: target
2385
          Return a new `gdb.Type' object which represents the target
2386
          type of this type.
2387
 
2388
          For a pointer type, the target type is the type of the
2389
          pointed-to object.  For an array type (meaning C-like
2390
          arrays), the target type is the type of the elements of the
2391
          array.  For a function or method type, the target type is the
2392
          type of the return value.  For a complex type, the target
2393
          type is the type of the elements.  For a typedef, the target
2394
          type is the aliased type.
2395
 
2396
          If the type does not have a target, this method will throw an
2397
          exception.
2398
 
2399
      -- Method on Type: template_argument n
2400
          If this `gdb.Type' is an instantiation of a template, this
2401
          will return a new `gdb.Type' which represents the type of the
2402
          Nth template argument.
2403
 
2404
          If this `gdb.Type' is not a template type, this will throw an
2405
          exception.  Ordinarily, only C++ code will have template
2406
          types.
2407
 
2408
          NAME is searched for globally.
2409
 
2410
   Each type has a code, which indicates what category this type falls
2411
into.  The available type categories are represented by constants
2412
defined in the `gdb' module:
2413
 
2414
`TYPE_CODE_PTR'
2415
     The type is a pointer.
2416
 
2417
`TYPE_CODE_ARRAY'
2418
     The type is an array.
2419
 
2420
`TYPE_CODE_STRUCT'
2421
     The type is a structure.
2422
 
2423
`TYPE_CODE_UNION'
2424
     The type is a union.
2425
 
2426
`TYPE_CODE_ENUM'
2427
     The type is an enum.
2428
 
2429
`TYPE_CODE_FLAGS'
2430
     A bit flags type, used for things such as status registers.
2431
 
2432
`TYPE_CODE_FUNC'
2433
     The type is a function.
2434
 
2435
`TYPE_CODE_INT'
2436
     The type is an integer type.
2437
 
2438
`TYPE_CODE_FLT'
2439
     A floating point type.
2440
 
2441
`TYPE_CODE_VOID'
2442
     The special type `void'.
2443
 
2444
`TYPE_CODE_SET'
2445
     A Pascal set type.
2446
 
2447
`TYPE_CODE_RANGE'
2448
     A range type, that is, an integer type with bounds.
2449
 
2450
`TYPE_CODE_STRING'
2451
     A string type.  Note that this is only used for certain languages
2452
     with language-defined string types; C strings are not represented
2453
     this way.
2454
 
2455
`TYPE_CODE_BITSTRING'
2456
     A string of bits.
2457
 
2458
`TYPE_CODE_ERROR'
2459
     An unknown or erroneous type.
2460
 
2461
`TYPE_CODE_METHOD'
2462
     A method type, as found in C++ or Java.
2463
 
2464
`TYPE_CODE_METHODPTR'
2465
     A pointer-to-member-function.
2466
 
2467
`TYPE_CODE_MEMBERPTR'
2468
     A pointer-to-member.
2469
 
2470
`TYPE_CODE_REF'
2471
     A reference type.
2472
 
2473
`TYPE_CODE_CHAR'
2474
     A character type.
2475
 
2476
`TYPE_CODE_BOOL'
2477
     A boolean type.
2478
 
2479
`TYPE_CODE_COMPLEX'
2480
     A complex float type.
2481
 
2482
`TYPE_CODE_TYPEDEF'
2483
     A typedef to some other type.
2484
 
2485
`TYPE_CODE_NAMESPACE'
2486
     A C++ namespace.
2487
 
2488
`TYPE_CODE_DECFLOAT'
2489
     A decimal floating point type.
2490
 
2491
`TYPE_CODE_INTERNAL_FUNCTION'
2492
     A function internal to GDB.  This is the type used to represent
2493
     convenience functions.
2494
 
2495

2496
File: gdb.info,  Node: Pretty Printing,  Next: Selecting Pretty-Printers,  Prev: Types In Python,  Up: Python API
2497
 
2498
23.2.2.6 Pretty Printing
2499
........................
2500
 
2501
GDB provides a mechanism to allow pretty-printing of values using
2502
Python code.  The pretty-printer API allows application-specific code
2503
to greatly simplify the display of complex objects.  This mechanism
2504
works for both MI and the CLI.
2505
 
2506
   For example, here is how a C++ `std::string' looks without a
2507
pretty-printer:
2508
 
2509
     (gdb) print s
2510
     $1 = {
2511
       static npos = 4294967295,
2512
       _M_dataplus = {
2513
         > = {
2514
           <__gnu_cxx::new_allocator> = {}, },
2515
         members of std::basic_string, std::allocator >::_Alloc_hider:
2516
         _M_p = 0x804a014 "abcd"
2517
       }
2518
     }
2519
 
2520
   After a pretty-printer for `std::string' has been installed, only
2521
the contents are printed:
2522
 
2523
     (gdb) print s
2524
     $2 = "abcd"
2525
 
2526
   A pretty-printer is just an object that holds a value and implements
2527
a specific interface, defined here.
2528
 
2529
 -- Operation on pretty printer: children (self)
2530
     GDB will call this method on a pretty-printer to compute the
2531
     children of the pretty-printer's value.
2532
 
2533
     This method must return an object conforming to the Python iterator
2534
     protocol.  Each item returned by the iterator must be a tuple
2535
     holding two elements.  The first element is the "name" of the
2536
     child; the second element is the child's value.  The value can be
2537
     any Python object which is convertible to a GDB value.
2538
 
2539
     This method is optional.  If it does not exist, GDB will act as
2540
     though the value has no children.
2541
 
2542
 -- Operation on pretty printer: display_hint (self)
2543
     The CLI may call this method and use its result to change the
2544
     formatting of a value.  The result will also be supplied to an MI
2545
     consumer as a `displayhint' attribute of the variable being
2546
     printed.
2547
 
2548
     This method is optional.  If it does exist, this method must
2549
     return a string.
2550
 
2551
     Some display hints are predefined by GDB:
2552
 
2553
    `array'
2554
          Indicate that the object being printed is "array-like".  The
2555
          CLI uses this to respect parameters such as `set print
2556
          elements' and `set print array'.
2557
 
2558
    `map'
2559
          Indicate that the object being printed is "map-like", and
2560
          that the children of this value can be assumed to alternate
2561
          between keys and values.
2562
 
2563
    `string'
2564
          Indicate that the object being printed is "string-like".  If
2565
          the printer's `to_string' method returns a Python string of
2566
          some kind, then GDB will call its internal language-specific
2567
          string-printing function to format the string.  For the CLI
2568
          this means adding quotation marks, possibly escaping some
2569
          characters, respecting `set print elements', and the like.
2570
 
2571
 -- Operation on pretty printer: to_string (self)
2572
     GDB will call this method to display the string representation of
2573
     the value passed to the object's constructor.
2574
 
2575
     When printing from the CLI, if the `to_string' method exists, then
2576
     GDB will prepend its result to the values returned by `children'.
2577
     Exactly how this formatting is done is dependent on the display
2578
     hint, and may change as more hints are added.  Also, depending on
2579
     the print settings (*note Print Settings::), the CLI may print
2580
     just the result of `to_string' in a stack trace, omitting the
2581
     result of `children'.
2582
 
2583
     If this method returns a string, it is printed verbatim.
2584
 
2585
     Otherwise, if this method returns an instance of `gdb.Value', then
2586
     GDB prints this value.  This may result in a call to another
2587
     pretty-printer.
2588
 
2589
     If instead the method returns a Python value which is convertible
2590
     to a `gdb.Value', then GDB performs the conversion and prints the
2591
     resulting value.  Again, this may result in a call to another
2592
     pretty-printer.  Python scalars (integers, floats, and booleans)
2593
     and strings are convertible to `gdb.Value'; other types are not.
2594
 
2595
     If the result is not one of these types, an exception is raised.
2596
 
2597

2598
File: gdb.info,  Node: Selecting Pretty-Printers,  Next: Commands In Python,  Prev: Pretty Printing,  Up: Python API
2599
 
2600
23.2.2.7 Selecting Pretty-Printers
2601
..................................
2602
 
2603
The Python list `gdb.pretty_printers' contains an array of functions
2604
that have been registered via addition as a pretty-printer.  Each
2605
`gdb.Objfile' also contains a `pretty_printers' attribute.
2606
 
2607
   A function on one of these lists is passed a single `gdb.Value'
2608
argument and should return a pretty-printer object conforming to the
2609
interface definition above (*note Pretty Printing::).  If a function
2610
cannot create a pretty-printer for the value, it should return `None'.
2611
 
2612
   GDB first checks the `pretty_printers' attribute of each
2613
`gdb.Objfile' and iteratively calls each function in the list for that
2614
`gdb.Objfile' until it receives a pretty-printer object.  After these
2615
lists have been exhausted, it tries the global `gdb.pretty-printers'
2616
list, again calling each function until an object is returned.
2617
 
2618
   The order in which the objfiles are searched is not specified.  For a
2619
given list, functions are always invoked from the head of the list, and
2620
iterated over sequentially until the end of the list, or a printer
2621
object is returned.
2622
 
2623
   Here is an example showing how a `std::string' printer might be
2624
written:
2625
 
2626
     class StdStringPrinter:
2627
         "Print a std::string"
2628
 
2629
         def __init__ (self, val):
2630
             self.val = val
2631
 
2632
         def to_string (self):
2633
             return self.val['_M_dataplus']['_M_p']
2634
 
2635
         def display_hint (self):
2636
             return 'string'
2637
 
2638
   And here is an example showing how a lookup function for the printer
2639
example above might be written.
2640
 
2641
     def str_lookup_function (val):
2642
 
2643
         lookup_tag = val.type.tag
2644
         regex = re.compile ("^std::basic_string$")
2645
         if lookup_tag == None:
2646
             return None
2647
         if regex.match (lookup_tag):
2648
             return StdStringPrinter (val)
2649
 
2650
         return None
2651
 
2652
   The example lookup function extracts the value's type, and attempts
2653
to match it to a type that it can pretty-print.  If it is a type the
2654
printer can pretty-print, it will return a printer object.  If not, it
2655
returns `None'.
2656
 
2657
   We recommend that you put your core pretty-printers into a Python
2658
package.  If your pretty-printers are for use with a library, we
2659
further recommend embedding a version number into the package name.
2660
This practice will enable GDB to load multiple versions of your
2661
pretty-printers at the same time, because they will have different
2662
names.
2663
 
2664
   You should write auto-loaded code (*note Auto-loading::) such that it
2665
can be evaluated multiple times without changing its meaning.  An ideal
2666
auto-load file will consist solely of `import's of your printer
2667
modules, followed by a call to a register pretty-printers with the
2668
current objfile.
2669
 
2670
   Taken as a whole, this approach will scale nicely to multiple
2671
inferiors, each potentially using a different library version.
2672
Embedding a version number in the Python package name will ensure that
2673
GDB is able to load both sets of printers simultaneously.  Then,
2674
because the search for pretty-printers is done by objfile, and because
2675
your auto-loaded code took care to register your library's printers
2676
with a specific objfile, GDB will find the correct printers for the
2677
specific version of the library used by each inferior.
2678
 
2679
   To continue the `std::string' example (*note Pretty Printing::),
2680
this code might appear in `gdb.libstdcxx.v6':
2681
 
2682
     def register_printers (objfile):
2683
         objfile.pretty_printers.add (str_lookup_function)
2684
 
2685
And then the corresponding contents of the auto-load file would be:
2686
 
2687
     import gdb.libstdcxx.v6
2688
     gdb.libstdcxx.v6.register_printers (gdb.current_objfile ())
2689
 
2690

2691
File: gdb.info,  Node: Commands In Python,  Next: Functions In Python,  Prev: Selecting Pretty-Printers,  Up: Python API
2692
 
2693
23.2.2.8 Commands In Python
2694
...........................
2695
 
2696
You can implement new GDB CLI commands in Python.  A CLI command is
2697
implemented using an instance of the `gdb.Command' class, most commonly
2698
using a subclass.
2699
 
2700
 -- Method on Command: __init__ name COMMAND_CLASS [COMPLETER_CLASS]
2701
          [PREFIX]
2702
     The object initializer for `Command' registers the new command
2703
     with GDB.  This initializer is normally invoked from the subclass'
2704
     own `__init__' method.
2705
 
2706
     NAME is the name of the command.  If NAME consists of multiple
2707
     words, then the initial words are looked for as prefix commands.
2708
     In this case, if one of the prefix commands does not exist, an
2709
     exception is raised.
2710
 
2711
     There is no support for multi-line commands.
2712
 
2713
     COMMAND_CLASS should be one of the `COMMAND_' constants defined
2714
     below.  This argument tells GDB how to categorize the new command
2715
     in the help system.
2716
 
2717
     COMPLETER_CLASS is an optional argument.  If given, it should be
2718
     one of the `COMPLETE_' constants defined below.  This argument
2719
     tells GDB how to perform completion for this command.  If not
2720
     given, GDB will attempt to complete using the object's `complete'
2721
     method (see below); if no such method is found, an error will
2722
     occur when completion is attempted.
2723
 
2724
     PREFIX is an optional argument.  If `True', then the new command
2725
     is a prefix command; sub-commands of this command may be
2726
     registered.
2727
 
2728
     The help text for the new command is taken from the Python
2729
     documentation string for the command's class, if there is one.  If
2730
     no documentation string is provided, the default value "This
2731
     command is not documented." is used.
2732
 
2733
 -- Method on Command: dont_repeat
2734
     By default, a GDB command is repeated when the user enters a blank
2735
     line at the command prompt.  A command can suppress this behavior
2736
     by invoking the `dont_repeat' method.  This is similar to the user
2737
     command `dont-repeat', see *Note dont-repeat: Define.
2738
 
2739
 -- Method on Command: invoke argument from_tty
2740
     This method is called by GDB when this command is invoked.
2741
 
2742
     ARGUMENT is a string.  It is the argument to the command, after
2743
     leading and trailing whitespace has been stripped.
2744
 
2745
     FROM_TTY is a boolean argument.  When true, this means that the
2746
     command was entered by the user at the terminal; when false it
2747
     means that the command came from elsewhere.
2748
 
2749
     If this method throws an exception, it is turned into a GDB
2750
     `error' call.  Otherwise, the return value is ignored.
2751
 
2752
 -- Method on Command: complete text word
2753
     This method is called by GDB when the user attempts completion on
2754
     this command.  All forms of completion are handled by this method,
2755
     that is, the  and  key bindings (*note Completion::),
2756
     and the `complete' command (*note complete: Help.).
2757
 
2758
     The arguments TEXT and WORD are both strings.  TEXT holds the
2759
     complete command line up to the cursor's location.  WORD holds the
2760
     last word of the command line; this is computed using a
2761
     word-breaking heuristic.
2762
 
2763
     The `complete' method can return several values:
2764
        * If the return value is a sequence, the contents of the
2765
          sequence are used as the completions.  It is up to `complete'
2766
          to ensure that the contents actually do complete the word.  A
2767
          zero-length sequence is allowed, it means that there were no
2768
          completions available.  Only string elements of the sequence
2769
          are used; other elements in the sequence are ignored.
2770
 
2771
        * If the return value is one of the `COMPLETE_' constants
2772
          defined below, then the corresponding GDB-internal completion
2773
          function is invoked, and its result is used.
2774
 
2775
        * All other results are treated as though there were no
2776
          available completions.
2777
 
2778
   When a new command is registered, it must be declared as a member of
2779
some general class of commands.  This is used to classify top-level
2780
commands in the on-line help system; note that prefix commands are not
2781
listed under their own category but rather that of their top-level
2782
command.  The available classifications are represented by constants
2783
defined in the `gdb' module:
2784
 
2785
`COMMAND_NONE'
2786
     The command does not belong to any particular class.  A command in
2787
     this category will not be displayed in any of the help categories.
2788
 
2789
`COMMAND_RUNNING'
2790
     The command is related to running the inferior.  For example,
2791
     `start', `step', and `continue' are in this category.  Type `help
2792
     running' at the GDB prompt to see a list of commands in this
2793
     category.
2794
 
2795
`COMMAND_DATA'
2796
     The command is related to data or variables.  For example, `call',
2797
     `find', and `print' are in this category.  Type `help data' at the
2798
     GDB prompt to see a list of commands in this category.
2799
 
2800
`COMMAND_STACK'
2801
     The command has to do with manipulation of the stack.  For example,
2802
     `backtrace', `frame', and `return' are in this category.  Type
2803
     `help stack' at the GDB prompt to see a list of commands in this
2804
     category.
2805
 
2806
`COMMAND_FILES'
2807
     This class is used for file-related commands.  For example,
2808
     `file', `list' and `section' are in this category.  Type `help
2809
     files' at the GDB prompt to see a list of commands in this
2810
     category.
2811
 
2812
`COMMAND_SUPPORT'
2813
     This should be used for "support facilities", generally meaning
2814
     things that are useful to the user when interacting with GDB, but
2815
     not related to the state of the inferior.  For example, `help',
2816
     `make', and `shell' are in this category.  Type `help support' at
2817
     the GDB prompt to see a list of commands in this category.
2818
 
2819
`COMMAND_STATUS'
2820
     The command is an `info'-related command, that is, related to the
2821
     state of GDB itself.  For example, `info', `macro', and `show' are
2822
     in this category.  Type `help status' at the GDB prompt to see a
2823
     list of commands in this category.
2824
 
2825
`COMMAND_BREAKPOINTS'
2826
     The command has to do with breakpoints.  For example, `break',
2827
     `clear', and `delete' are in this category.  Type `help
2828
     breakpoints' at the GDB prompt to see a list of commands in this
2829
     category.
2830
 
2831
`COMMAND_TRACEPOINTS'
2832
     The command has to do with tracepoints.  For example, `trace',
2833
     `actions', and `tfind' are in this category.  Type `help
2834
     tracepoints' at the GDB prompt to see a list of commands in this
2835
     category.
2836
 
2837
`COMMAND_OBSCURE'
2838
     The command is only used in unusual circumstances, or is not of
2839
     general interest to users.  For example, `checkpoint', `fork', and
2840
     `stop' are in this category.  Type `help obscure' at the GDB
2841
     prompt to see a list of commands in this category.
2842
 
2843
`COMMAND_MAINTENANCE'
2844
     The command is only useful to GDB maintainers.  The `maintenance'
2845
     and `flushregs' commands are in this category.  Type `help
2846
     internals' at the GDB prompt to see a list of commands in this
2847
     category.
2848
 
2849
   A new command can use a predefined completion function, either by
2850
specifying it via an argument at initialization, or by returning it
2851
from the `complete' method.  These predefined completion constants are
2852
all defined in the `gdb' module:
2853
 
2854
`COMPLETE_NONE'
2855
     This constant means that no completion should be done.
2856
 
2857
`COMPLETE_FILENAME'
2858
     This constant means that filename completion should be performed.
2859
 
2860
`COMPLETE_LOCATION'
2861
     This constant means that location completion should be done.
2862
     *Note Specify Location::.
2863
 
2864
`COMPLETE_COMMAND'
2865
     This constant means that completion should examine GDB command
2866
     names.
2867
 
2868
`COMPLETE_SYMBOL'
2869
     This constant means that completion should be done using symbol
2870
     names as the source.
2871
 
2872
   The following code snippet shows how a trivial CLI command can be
2873
implemented in Python:
2874
 
2875
     class HelloWorld (gdb.Command):
2876
       """Greet the whole world."""
2877
 
2878
       def __init__ (self):
2879
         super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE)
2880
 
2881
       def invoke (self, arg, from_tty):
2882
         print "Hello, World!"
2883
 
2884
     HelloWorld ()
2885
 
2886
   The last line instantiates the class, and is necessary to trigger the
2887
registration of the command with GDB.  Depending on how the Python code
2888
is read into GDB, you may need to import the `gdb' module explicitly.
2889
 
2890

2891
File: gdb.info,  Node: Functions In Python,  Next: Objfiles In Python,  Prev: Commands In Python,  Up: Python API
2892
 
2893
23.2.2.9 Writing new convenience functions
2894
..........................................
2895
 
2896
You can implement new convenience functions (*note Convenience Vars::)
2897
in Python.  A convenience function is an instance of a subclass of the
2898
class `gdb.Function'.
2899
 
2900
 -- Method on Function: __init__ name
2901
     The initializer for `Function' registers the new function with
2902
     GDB.  The argument NAME is the name of the function, a string.
2903
     The function will be visible to the user as a convenience variable
2904
     of type `internal function', whose name is the same as the given
2905
     NAME.
2906
 
2907
     The documentation for the new function is taken from the
2908
     documentation string for the new class.
2909
 
2910
 -- Method on Function: invoke *ARGS
2911
     When a convenience function is evaluated, its arguments are
2912
     converted to instances of `gdb.Value', and then the function's
2913
     `invoke' method is called.  Note that GDB does not predetermine
2914
     the arity of convenience functions.  Instead, all available
2915
     arguments are passed to `invoke', following the standard Python
2916
     calling convention.  In particular, a convenience function can
2917
     have default values for parameters without ill effect.
2918
 
2919
     The return value of this method is used as its value in the
2920
     enclosing expression.  If an ordinary Python value is returned, it
2921
     is converted to a `gdb.Value' following the usual rules.
2922
 
2923
   The following code snippet shows how a trivial convenience function
2924
can be implemented in Python:
2925
 
2926
     class Greet (gdb.Function):
2927
       """Return string to greet someone.
2928
     Takes a name as argument."""
2929
 
2930
       def __init__ (self):
2931
         super (Greet, self).__init__ ("greet")
2932
 
2933
       def invoke (self, name):
2934
         return "Hello, %s!" % name.string ()
2935
 
2936
     Greet ()
2937
 
2938
   The last line instantiates the class, and is necessary to trigger the
2939
registration of the function with GDB.  Depending on how the Python
2940
code is read into GDB, you may need to import the `gdb' module
2941
explicitly.
2942
 
2943

2944
File: gdb.info,  Node: Objfiles In Python,  Next: Frames In Python,  Prev: Functions In Python,  Up: Python API
2945
 
2946
23.2.2.10 Objfiles In Python
2947
............................
2948
 
2949
GDB loads symbols for an inferior from various symbol-containing files
2950
(*note Files::).  These include the primary executable file, any shared
2951
libraries used by the inferior, and any separate debug info files
2952
(*note Separate Debug Files::).  GDB calls these symbol-containing
2953
files "objfiles".
2954
 
2955
   The following objfile-related functions are available in the `gdb'
2956
module:
2957
 
2958
 -- Function: current_objfile
2959
     When auto-loading a Python script (*note Auto-loading::), GDB sets
2960
     the "current objfile" to the corresponding objfile.  This function
2961
     returns the current objfile.  If there is no current objfile, this
2962
     function returns `None'.
2963
 
2964
 -- Function: objfiles
2965
     Return a sequence of all the objfiles current known to GDB.  *Note
2966
     Objfiles In Python::.
2967
 
2968
   Each objfile is represented by an instance of the `gdb.Objfile'
2969
class.
2970
 
2971
 -- Instance Variable of Objfile: filename
2972
     The file name of the objfile as a string.
2973
 
2974
 -- Instance Variable of Objfile: pretty_printers
2975
     The `pretty_printers' attribute is a list of functions.  It is
2976
     used to look up pretty-printers.  A `Value' is passed to each
2977
     function in order; if the function returns `None', then the search
2978
     continues.  Otherwise, the return value should be an object which
2979
     is used to format the value.  *Note Pretty Printing::, for more
2980
     information.
2981
 
2982

2983
File: gdb.info,  Node: Frames In Python,  Next: Lazy Strings In Python,  Prev: Objfiles In Python,  Up: Python API
2984
 
2985
23.2.2.11 Acessing inferior stack frames from Python.
2986
.....................................................
2987
 
2988
When the debugged program stops, GDB is able to analyze its call stack
2989
(*note Stack frames: Frames.).  The `gdb.Frame' class represents a
2990
frame in the stack.  A `gdb.Frame' object is only valid while its
2991
corresponding frame exists in the inferior's stack.  If you try to use
2992
an invalid frame object, GDB will throw a `RuntimeError' exception.
2993
 
2994
   Two `gdb.Frame' objects can be compared for equality with the `=='
2995
operator, like:
2996
 
2997
     (gdb) python print gdb.newest_frame() == gdb.selected_frame ()
2998
     True
2999
 
3000
   The following frame-related functions are available in the `gdb'
3001
module:
3002
 
3003
 -- Function: selected_frame
3004
     Return the selected frame object.  (*note Selecting a Frame:
3005
     Selection.).
3006
 
3007
 -- Function: frame_stop_reason_string reason
3008
     Return a string explaining the reason why GDB stopped unwinding
3009
     frames, as expressed by the given REASON code (an integer, see the
3010
     `unwind_stop_reason' method further down in this section).
3011
 
3012
   A `gdb.Frame' object has the following methods:
3013
 
3014
      -- Method on Frame: is_valid
3015
          Returns true if the `gdb.Frame' object is valid, false if not.
3016
          A frame object can become invalid if the frame it refers to
3017
          doesn't exist anymore in the inferior.  All `gdb.Frame'
3018
          methods will throw an exception if it is invalid at the time
3019
          the method is called.
3020
 
3021
      -- Method on Frame: name
3022
          Returns the function name of the frame, or `None' if it can't
3023
          be obtained.
3024
 
3025
      -- Method on Frame: type
3026
          Returns the type of the frame.  The value can be one of
3027
          `gdb.NORMAL_FRAME', `gdb.DUMMY_FRAME', `gdb.SIGTRAMP_FRAME'
3028
          or `gdb.SENTINEL_FRAME'.
3029
 
3030
      -- Method on Frame: unwind_stop_reason
3031
          Return an integer representing the reason why it's not
3032
          possible to find more frames toward the outermost frame.  Use
3033
          `gdb.frame_stop_reason_string' to convert the value returned
3034
          by this function to a string.
3035
 
3036
      -- Method on Frame: pc
3037
          Returns the frame's resume address.
3038
 
3039
      -- Method on Frame: older
3040
          Return the frame that called this frame.
3041
 
3042
      -- Method on Frame: newer
3043
          Return the frame called by this frame.
3044
 
3045
      -- Method on Frame: read_var variable
3046
          Return the value of the given variable in this frame.
3047
          VARIABLE must be a string.
3048
 
3049

3050
File: gdb.info,  Node: Lazy Strings In Python,  Prev: Frames In Python,  Up: Python API
3051
 
3052
23.2.2.12 Python representation of lazy strings.
3053
................................................
3054
 
3055
A "lazy string" is a string whose contents is not retrieved or encoded
3056
until it is needed.
3057
 
3058
   A `gdb.LazyString' is represented in GDB as an `address' that points
3059
to a region of memory, an `encoding' that will be used to encode that
3060
region of memory, and a `length' to delimit the region of memory that
3061
represents the string.  The difference between a `gdb.LazyString' and a
3062
string wrapped within a `gdb.Value' is that a `gdb.LazyString' will be
3063
treated differently by GDB when printing.  A `gdb.LazyString' is
3064
retrieved and encoded during printing, while a `gdb.Value' wrapping a
3065
string is immediately retrieved and encoded on creation.
3066
 
3067
   A `gdb.LazyString' object has the following functions:
3068
 
3069
 -- Method on LazyString: value
3070
     Convert the `gdb.LazyString' to a `gdb.Value'.  This value will
3071
     point to the string in memory, but will lose all the delayed
3072
     retrieval, encoding and handling that GDB applies to a
3073
     `gdb.LazyString'.
3074
 
3075
 -- Instance Variable of LazyString: address
3076
     This attribute holds the address of the string.  This attribute is
3077
     not writable.
3078
 
3079
 -- Instance Variable of LazyString: length
3080
     This attribute holds the length of the string in characters.  If
3081
     the length is -1, then the string will be fetched and encoded up
3082
     to the first null of appropriate width.  This attribute is not
3083
     writable.
3084
 
3085
 -- Instance Variable of LazyString: encoding
3086
     This attribute holds the encoding that will be applied to the
3087
     string when the string is printed by GDB.  If the encoding is not
3088
     set, or contains an empty string,  then GDB will select the most
3089
     appropriate encoding when the string is printed.  This attribute
3090
     is not writable.
3091
 
3092
 -- Instance Variable of LazyString: type
3093
     This attribute holds the type that is represented by the lazy
3094
     string's type.  For a lazy string this will always be a pointer
3095
     type.  To resolve this to the lazy string's character type, use
3096
     the type's `target' method.  *Note Types In Python::.  This
3097
     attribute is not writable.
3098
 
3099

3100
File: gdb.info,  Node: Interpreters,  Next: TUI,  Prev: Extending GDB,  Up: Top
3101
 
3102
24 Command Interpreters
3103
***********************
3104
 
3105
GDB supports multiple command interpreters, and some command
3106
infrastructure to allow users or user interface writers to switch
3107
between interpreters or run commands in other interpreters.
3108
 
3109
   GDB currently supports two command interpreters, the console
3110
interpreter (sometimes called the command-line interpreter or CLI) and
3111
the machine interface interpreter (or GDB/MI).  This manual describes
3112
both of these interfaces in great detail.
3113
 
3114
   By default, GDB will start with the console interpreter.  However,
3115
the user may choose to start GDB with another interpreter by specifying
3116
the `-i' or `--interpreter' startup options.  Defined interpreters
3117
include:
3118
 
3119
`console'
3120
     The traditional console or command-line interpreter.  This is the
3121
     most often used interpreter with GDB. With no interpreter
3122
     specified at runtime, GDB will use this interpreter.
3123
 
3124
`mi'
3125
     The newest GDB/MI interface (currently `mi2').  Used primarily by
3126
     programs wishing to use GDB as a backend for a debugger GUI or an
3127
     IDE.  For more information, see *Note The GDB/MI Interface: GDB/MI.
3128
 
3129
`mi2'
3130
     The current GDB/MI interface.
3131
 
3132
`mi1'
3133
     The GDB/MI interface included in GDB 5.1, 5.2, and 5.3.
3134
 
3135
 
3136
   The interpreter being used by GDB may not be dynamically switched at
3137
runtime.  Although possible, this could lead to a very precarious
3138
situation.  Consider an IDE using GDB/MI.  If a user enters the command
3139
"interpreter-set console" in a console view, GDB would switch to using
3140
the console interpreter, rendering the IDE inoperable!
3141
 
3142
   Although you may only choose a single interpreter at startup, you
3143
may execute commands in any interpreter from the current interpreter
3144
using the appropriate command.  If you are running the console
3145
interpreter, simply use the `interpreter-exec' command:
3146
 
3147
     interpreter-exec mi "-data-list-register-names"
3148
 
3149
   GDB/MI has a similar command, although it is only available in
3150
versions of GDB which support GDB/MI version 2 (or greater).
3151
 
3152

3153
File: gdb.info,  Node: TUI,  Next: Emacs,  Prev: Interpreters,  Up: Top
3154
 
3155
25 GDB Text User Interface
3156
**************************
3157
 
3158
* Menu:
3159
 
3160
* TUI Overview::                TUI overview
3161
* TUI Keys::                    TUI key bindings
3162
* TUI Single Key Mode::         TUI single key mode
3163
* TUI Commands::                TUI-specific commands
3164
* TUI Configuration::           TUI configuration variables
3165
 
3166
   The GDB Text User Interface (TUI) is a terminal interface which uses
3167
the `curses' library to show the source file, the assembly output, the
3168
program registers and GDB commands in separate text windows.  The TUI
3169
mode is supported only on platforms where a suitable version of the
3170
`curses' library is available.
3171
 
3172
   The TUI mode is enabled by default when you invoke GDB as either
3173
`gdbtui' or `gdb -tui'.  You can also switch in and out of TUI mode
3174
while GDB runs by using various TUI commands and key bindings, such as
3175
`C-x C-a'.  *Note TUI Key Bindings: TUI Keys.
3176
 
3177

3178
File: gdb.info,  Node: TUI Overview,  Next: TUI Keys,  Up: TUI
3179
 
3180
25.1 TUI Overview
3181
=================
3182
 
3183
In TUI mode, GDB can display several text windows:
3184
 
3185
_command_
3186
     This window is the GDB command window with the GDB prompt and the
3187
     GDB output.  The GDB input is still managed using readline.
3188
 
3189
_source_
3190
     The source window shows the source file of the program.  The
3191
     current line and active breakpoints are displayed in this window.
3192
 
3193
_assembly_
3194
     The assembly window shows the disassembly output of the program.
3195
 
3196
_register_
3197
     This window shows the processor registers.  Registers are
3198
     highlighted when their values change.
3199
 
3200
   The source and assembly windows show the current program position by
3201
highlighting the current line and marking it with a `>' marker.
3202
Breakpoints are indicated with two markers.  The first marker indicates
3203
the breakpoint type:
3204
 
3205
`B'
3206
     Breakpoint which was hit at least once.
3207
 
3208
`b'
3209
     Breakpoint which was never hit.
3210
 
3211
`H'
3212
     Hardware breakpoint which was hit at least once.
3213
 
3214
`h'
3215
     Hardware breakpoint which was never hit.
3216
 
3217
   The second marker indicates whether the breakpoint is enabled or not:
3218
 
3219
`+'
3220
     Breakpoint is enabled.
3221
 
3222
`-'
3223
     Breakpoint is disabled.
3224
 
3225
   The source, assembly and register windows are updated when the
3226
current thread changes, when the frame changes, or when the program
3227
counter changes.
3228
 
3229
   These windows are not all visible at the same time.  The command
3230
window is always visible.  The others can be arranged in several
3231
layouts:
3232
 
3233
   * source only,
3234
 
3235
   * assembly only,
3236
 
3237
   * source and assembly,
3238
 
3239
   * source and registers, or
3240
 
3241
   * assembly and registers.
3242
 
3243
   A status line above the command window shows the following
3244
information:
3245
 
3246
_target_
3247
     Indicates the current GDB target.  (*note Specifying a Debugging
3248
     Target: Targets.).
3249
 
3250
_process_
3251
     Gives the current process or thread number.  When no process is
3252
     being debugged, this field is set to `No process'.
3253
 
3254
_function_
3255
     Gives the current function name for the selected frame.  The name
3256
     is demangled if demangling is turned on (*note Print Settings::).
3257
     When there is no symbol corresponding to the current program
3258
     counter, the string `??' is displayed.
3259
 
3260
_line_
3261
     Indicates the current line number for the selected frame.  When
3262
     the current line number is not known, the string `??' is displayed.
3263
 
3264
_pc_
3265
     Indicates the current program counter address.
3266
 
3267

3268
File: gdb.info,  Node: TUI Keys,  Next: TUI Single Key Mode,  Prev: TUI Overview,  Up: TUI
3269
 
3270
25.2 TUI Key Bindings
3271
=====================
3272
 
3273
The TUI installs several key bindings in the readline keymaps (*note
3274
Command Line Editing::).  The following key bindings are installed for
3275
both TUI mode and the GDB standard mode.
3276
 
3277
`C-x C-a'
3278
`C-x a'
3279
`C-x A'
3280
     Enter or leave the TUI mode.  When leaving the TUI mode, the
3281
     curses window management stops and GDB operates using its standard
3282
     mode, writing on the terminal directly.  When reentering the TUI
3283
     mode, control is given back to the curses windows.  The screen is
3284
     then refreshed.
3285
 
3286
`C-x 1'
3287
     Use a TUI layout with only one window.  The layout will either be
3288
     `source' or `assembly'.  When the TUI mode is not active, it will
3289
     switch to the TUI mode.
3290
 
3291
     Think of this key binding as the Emacs `C-x 1' binding.
3292
 
3293
`C-x 2'
3294
     Use a TUI layout with at least two windows.  When the current
3295
     layout already has two windows, the next layout with two windows
3296
     is used.  When a new layout is chosen, one window will always be
3297
     common to the previous layout and the new one.
3298
 
3299
     Think of it as the Emacs `C-x 2' binding.
3300
 
3301
`C-x o'
3302
     Change the active window.  The TUI associates several key bindings
3303
     (like scrolling and arrow keys) with the active window.  This
3304
     command gives the focus to the next TUI window.
3305
 
3306
     Think of it as the Emacs `C-x o' binding.
3307
 
3308
`C-x s'
3309
     Switch in and out of the TUI SingleKey mode that binds single keys
3310
     to GDB commands (*note TUI Single Key Mode::).
3311
 
3312
   The following key bindings only work in the TUI mode:
3313
 
3314
3315
     Scroll the active window one page up.
3316
 
3317
3318
     Scroll the active window one page down.
3319
 
3320
3321
     Scroll the active window one line up.
3322
 
3323
3324
     Scroll the active window one line down.
3325
 
3326
3327
     Scroll the active window one column left.
3328
 
3329
3330
     Scroll the active window one column right.
3331
 
3332
`C-L'
3333
     Refresh the screen.
3334
 
3335
   Because the arrow keys scroll the active window in the TUI mode, they
3336
are not available for their normal use by readline unless the command
3337
window has the focus.  When another window is active, you must use
3338
other readline key bindings such as `C-p', `C-n', `C-b' and `C-f' to
3339
control the command window.
3340
 
3341

3342
File: gdb.info,  Node: TUI Single Key Mode,  Next: TUI Commands,  Prev: TUI Keys,  Up: TUI
3343
 
3344
25.3 TUI Single Key Mode
3345
========================
3346
 
3347
The TUI also provides a "SingleKey" mode, which binds several
3348
frequently used GDB commands to single keys.  Type `C-x s' to switch
3349
into this mode, where the following key bindings are used:
3350
 
3351
`c'
3352
     continue
3353
 
3354
`d'
3355
     down
3356
 
3357
`f'
3358
     finish
3359
 
3360
`n'
3361
     next
3362
 
3363
`q'
3364
     exit the SingleKey mode.
3365
 
3366
`r'
3367
     run
3368
 
3369
`s'
3370
     step
3371
 
3372
`u'
3373
     up
3374
 
3375
`v'
3376
     info locals
3377
 
3378
`w'
3379
     where
3380
 
3381
   Other keys temporarily switch to the GDB command prompt.  The key
3382
that was pressed is inserted in the editing buffer so that it is
3383
possible to type most GDB commands without interaction with the TUI
3384
SingleKey mode.  Once the command is entered the TUI SingleKey mode is
3385
restored.  The only way to permanently leave this mode is by typing `q'
3386
or `C-x s'.
3387
 
3388

3389
File: gdb.info,  Node: TUI Commands,  Next: TUI Configuration,  Prev: TUI Single Key Mode,  Up: TUI
3390
 
3391
25.4 TUI-specific Commands
3392
==========================
3393
 
3394
The TUI has specific commands to control the text windows.  These
3395
commands are always available, even when GDB is not in the TUI mode.
3396
When GDB is in the standard mode, most of these commands will
3397
automatically switch to the TUI mode.
3398
 
3399
`info win'
3400
     List and give the size of all displayed windows.
3401
 
3402
`layout next'
3403
     Display the next layout.
3404
 
3405
`layout prev'
3406
     Display the previous layout.
3407
 
3408
`layout src'
3409
     Display the source window only.
3410
 
3411
`layout asm'
3412
     Display the assembly window only.
3413
 
3414
`layout split'
3415
     Display the source and assembly window.
3416
 
3417
`layout regs'
3418
     Display the register window together with the source or assembly
3419
     window.
3420
 
3421
`focus next'
3422
     Make the next window active for scrolling.
3423
 
3424
`focus prev'
3425
     Make the previous window active for scrolling.
3426
 
3427
`focus src'
3428
     Make the source window active for scrolling.
3429
 
3430
`focus asm'
3431
     Make the assembly window active for scrolling.
3432
 
3433
`focus regs'
3434
     Make the register window active for scrolling.
3435
 
3436
`focus cmd'
3437
     Make the command window active for scrolling.
3438
 
3439
`refresh'
3440
     Refresh the screen.  This is similar to typing `C-L'.
3441
 
3442
`tui reg float'
3443
     Show the floating point registers in the register window.
3444
 
3445
`tui reg general'
3446
     Show the general registers in the register window.
3447
 
3448
`tui reg next'
3449
     Show the next register group.  The list of register groups as well
3450
     as their order is target specific.  The predefined register groups
3451
     are the following: `general', `float', `system', `vector', `all',
3452
     `save', `restore'.
3453
 
3454
`tui reg system'
3455
     Show the system registers in the register window.
3456
 
3457
`update'
3458
     Update the source window and the current execution point.
3459
 
3460
`winheight NAME +COUNT'
3461
`winheight NAME -COUNT'
3462
     Change the height of the window NAME by COUNT lines.  Positive
3463
     counts increase the height, while negative counts decrease it.
3464
 
3465
`tabset NCHARS'
3466
     Set the width of tab stops to be NCHARS characters.
3467
 
3468

3469
File: gdb.info,  Node: TUI Configuration,  Prev: TUI Commands,  Up: TUI
3470
 
3471
25.5 TUI Configuration Variables
3472
================================
3473
 
3474
Several configuration variables control the appearance of TUI windows.
3475
 
3476
`set tui border-kind KIND'
3477
     Select the border appearance for the source, assembly and register
3478
     windows.  The possible values are the following:
3479
    `space'
3480
          Use a space character to draw the border.
3481
 
3482
    `ascii'
3483
          Use ASCII characters `+', `-' and `|' to draw the border.
3484
 
3485
    `acs'
3486
          Use the Alternate Character Set to draw the border.  The
3487
          border is drawn using character line graphics if the terminal
3488
          supports them.
3489
 
3490
`set tui border-mode MODE'
3491
`set tui active-border-mode MODE'
3492
     Select the display attributes for the borders of the inactive
3493
     windows or the active window.  The MODE can be one of the
3494
     following:
3495
    `normal'
3496
          Use normal attributes to display the border.
3497
 
3498
    `standout'
3499
          Use standout mode.
3500
 
3501
    `reverse'
3502
          Use reverse video mode.
3503
 
3504
    `half'
3505
          Use half bright mode.
3506
 
3507
    `half-standout'
3508
          Use half bright and standout mode.
3509
 
3510
    `bold'
3511
          Use extra bright or bold mode.
3512
 
3513
    `bold-standout'
3514
          Use extra bright or bold and standout mode.
3515
 
3516

3517
File: gdb.info,  Node: Emacs,  Next: GDB/MI,  Prev: TUI,  Up: Top
3518
 
3519
26 Using GDB under GNU Emacs
3520
****************************
3521
 
3522
A special interface allows you to use GNU Emacs to view (and edit) the
3523
source files for the program you are debugging with GDB.
3524
 
3525
   To use this interface, use the command `M-x gdb' in Emacs.  Give the
3526
executable file you want to debug as an argument.  This command starts
3527
GDB as a subprocess of Emacs, with input and output through a newly
3528
created Emacs buffer.
3529
 
3530
   Running GDB under Emacs can be just like running GDB normally except
3531
for two things:
3532
 
3533
   * All "terminal" input and output goes through an Emacs buffer,
3534
     called the GUD buffer.
3535
 
3536
     This applies both to GDB commands and their output, and to the
3537
     input and output done by the program you are debugging.
3538
 
3539
     This is useful because it means that you can copy the text of
3540
     previous commands and input them again; you can even use parts of
3541
     the output in this way.
3542
 
3543
     All the facilities of Emacs' Shell mode are available for
3544
     interacting with your program.  In particular, you can send
3545
     signals the usual way--for example, `C-c C-c' for an interrupt,
3546
     `C-c C-z' for a stop.
3547
 
3548
   * GDB displays source code through Emacs.
3549
 
3550
     Each time GDB displays a stack frame, Emacs automatically finds the
3551
     source file for that frame and puts an arrow (`=>') at the left
3552
     margin of the current line.  Emacs uses a separate buffer for
3553
     source display, and splits the screen to show both your GDB session
3554
     and the source.
3555
 
3556
     Explicit GDB `list' or search commands still produce output as
3557
     usual, but you probably have no reason to use them from Emacs.
3558
 
3559
   We call this "text command mode".  Emacs 22.1, and later, also uses
3560
a graphical mode, enabled by default, which provides further buffers
3561
that can control the execution and describe the state of your program.
3562
*Note GDB Graphical Interface: (Emacs)GDB Graphical Interface.
3563
 
3564
   If you specify an absolute file name when prompted for the `M-x gdb'
3565
argument, then Emacs sets your current working directory to where your
3566
program resides.  If you only specify the file name, then Emacs sets
3567
your current working directory to to the directory associated with the
3568
previous buffer.  In this case, GDB may find your program by searching
3569
your environment's `PATH' variable, but on some operating systems it
3570
might not find the source.  So, although the GDB input and output
3571
session proceeds normally, the auxiliary buffer does not display the
3572
current source and line of execution.
3573
 
3574
   The initial working directory of GDB is printed on the top line of
3575
the GUD buffer and this serves as a default for the commands that
3576
specify files for GDB to operate on.  *Note Commands to Specify Files:
3577
Files.
3578
 
3579
   By default, `M-x gdb' calls the program called `gdb'.  If you need
3580
to call GDB by a different name (for example, if you keep several
3581
configurations around, with different names) you can customize the
3582
Emacs variable `gud-gdb-command-name' to run the one you want.
3583
 
3584
   In the GUD buffer, you can use these special Emacs commands in
3585
addition to the standard Shell mode commands:
3586
 
3587
`C-h m'
3588
     Describe the features of Emacs' GUD Mode.
3589
 
3590
`C-c C-s'
3591
     Execute to another source line, like the GDB `step' command; also
3592
     update the display window to show the current file and location.
3593
 
3594
`C-c C-n'
3595
     Execute to next source line in this function, skipping all function
3596
     calls, like the GDB `next' command.  Then update the display window
3597
     to show the current file and location.
3598
 
3599
`C-c C-i'
3600
     Execute one instruction, like the GDB `stepi' command; update
3601
     display window accordingly.
3602
 
3603
`C-c C-f'
3604
     Execute until exit from the selected stack frame, like the GDB
3605
     `finish' command.
3606
 
3607
`C-c C-r'
3608
     Continue execution of your program, like the GDB `continue'
3609
     command.
3610
 
3611
`C-c <'
3612
     Go up the number of frames indicated by the numeric argument
3613
     (*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'
3614
     command.
3615
 
3616
`C-c >'
3617
     Go down the number of frames indicated by the numeric argument,
3618
     like the GDB `down' command.
3619
 
3620
   In any source file, the Emacs command `C-x ' (`gud-break')
3621
tells GDB to set a breakpoint on the source line point is on.
3622
 
3623
   In text command mode, if you type `M-x speedbar', Emacs displays a
3624
separate frame which shows a backtrace when the GUD buffer is current.
3625
Move point to any frame in the stack and type  to make it become
3626
the current frame and display the associated source in the source
3627
buffer.  Alternatively, click `Mouse-2' to make the selected frame
3628
become the current one.  In graphical mode, the speedbar displays watch
3629
expressions.
3630
 
3631
   If you accidentally delete the source-display buffer, an easy way to
3632
get it back is to type the command `f' in the GDB buffer, to request a
3633
frame display; when you run under Emacs, this recreates the source
3634
buffer if necessary to show you the context of the current frame.
3635
 
3636
   The source files displayed in Emacs are in ordinary Emacs buffers
3637
which are visiting the source files in the usual way.  You can edit the
3638
files with these buffers if you wish; but keep in mind that GDB
3639
communicates with Emacs in terms of line numbers.  If you add or delete
3640
lines from the text, the line numbers that GDB knows cease to
3641
correspond properly with the code.
3642
 
3643
   A more detailed description of Emacs' interaction with GDB is given
3644
in the Emacs manual (*note Debuggers: (Emacs)Debuggers.).
3645
 
3646

3647
File: gdb.info,  Node: GDB/MI,  Next: Annotations,  Prev: Emacs,  Up: Top
3648
 
3649
27 The GDB/MI Interface
3650
***********************
3651
 
3652
Function and Purpose
3653
====================
3654
 
3655
GDB/MI is a line based machine oriented text interface to GDB and is
3656
activated by specifying using the `--interpreter' command line option
3657
(*note Mode Options::).  It is specifically intended to support the
3658
development of systems which use the debugger as just one small
3659
component of a larger system.
3660
 
3661
   This chapter is a specification of the GDB/MI interface.  It is
3662
written in the form of a reference manual.
3663
 
3664
   Note that GDB/MI is still under construction, so some of the
3665
features described below are incomplete and subject to change (*note
3666
GDB/MI Development and Front Ends: GDB/MI Development and Front Ends.).
3667
 
3668
Notation and Terminology
3669
========================
3670
 
3671
This chapter uses the following notation:
3672
 
3673
   * `|' separates two alternatives.
3674
 
3675
   * `[ SOMETHING ]' indicates that SOMETHING is optional: it may or
3676
     may not be given.
3677
 
3678
   * `( GROUP )*' means that GROUP inside the parentheses may repeat
3679
     zero or more times.
3680
 
3681
   * `( GROUP )+' means that GROUP inside the parentheses may repeat
3682
     one or more times.
3683
 
3684
   * `"STRING"' means a literal STRING.
3685
 
3686
* Menu:
3687
 
3688
* GDB/MI General Design::
3689
* GDB/MI Command Syntax::
3690
* GDB/MI Compatibility with CLI::
3691
* GDB/MI Development and Front Ends::
3692
* GDB/MI Output Records::
3693
* GDB/MI Simple Examples::
3694
* GDB/MI Command Description Format::
3695
* GDB/MI Breakpoint Commands::
3696
* GDB/MI Program Context::
3697
* GDB/MI Thread Commands::
3698
* GDB/MI Program Execution::
3699
* GDB/MI Stack Manipulation::
3700
* GDB/MI Variable Objects::
3701
* GDB/MI Data Manipulation::
3702
* GDB/MI Tracepoint Commands::
3703
* GDB/MI Symbol Query::
3704
* GDB/MI File Commands::
3705
* GDB/MI Target Manipulation::
3706
* GDB/MI File Transfer Commands::
3707
* GDB/MI Miscellaneous Commands::
3708
 
3709

3710
File: gdb.info,  Node: GDB/MI General Design,  Next: GDB/MI Command Syntax,  Up: GDB/MI
3711
 
3712
27.1 GDB/MI General Design
3713
==========================
3714
 
3715
Interaction of a GDB/MI frontend with GDB involves three
3716
parts--commands sent to GDB, responses to those commands and
3717
notifications.  Each command results in exactly one response,
3718
indicating either successful completion of the command, or an error.
3719
For the commands that do not resume the target, the response contains
3720
the requested information.  For the commands that resume the target, the
3721
response only indicates whether the target was successfully resumed.
3722
Notifications is the mechanism for reporting changes in the state of the
3723
target, or in GDB state, that cannot conveniently be associated with a
3724
command and reported as part of that command response.
3725
 
3726
   The important examples of notifications are:
3727
   * Exec notifications.  These are used to report changes in target
3728
     state--when a target is resumed, or stopped.  It would not be
3729
     feasible to include this information in response of resuming
3730
     commands, because one resume commands can result in multiple
3731
     events in different threads.  Also, quite some time may pass
3732
     before any event happens in the target, while a frontend needs to
3733
     know whether the resuming command itself was successfully executed.
3734
 
3735
   * Console output, and status notifications.  Console output
3736
     notifications are used to report output of CLI commands, as well as
3737
     diagnostics for other commands.  Status notifications are used to
3738
     report the progress of a long-running operation.  Naturally,
3739
     including this information in command response would mean no
3740
     output is produced until the command is finished, which is
3741
     undesirable.
3742
 
3743
   * General notifications.  Commands may have various side effects on
3744
     the GDB or target state beyond their official purpose.  For
3745
     example, a command may change the selected thread.  Although such
3746
     changes can be included in command response, using notification
3747
     allows for more orthogonal frontend design.
3748
 
3749
 
3750
   There's no guarantee that whenever an MI command reports an error,
3751
GDB or the target are in any specific state, and especially, the state
3752
is not reverted to the state before the MI command was processed.
3753
Therefore, whenever an MI command results in an error, we recommend
3754
that the frontend refreshes all the information shown in the user
3755
interface.
3756
 
3757
* Menu:
3758
 
3759
* Context management::
3760
* Asynchronous and non-stop modes::
3761
* Thread groups::
3762
 
3763

3764
File: gdb.info,  Node: Context management,  Next: Asynchronous and non-stop modes,  Up: GDB/MI General Design
3765
 
3766
27.1.1 Context management
3767
-------------------------
3768
 
3769
In most cases when GDB accesses the target, this access is done in
3770
context of a specific thread and frame (*note Frames::).  Often, even
3771
when accessing global data, the target requires that a thread be
3772
specified.  The CLI interface maintains the selected thread and frame,
3773
and supplies them to target on each command.  This is convenient,
3774
because a command line user would not want to specify that information
3775
explicitly on each command, and because user interacts with GDB via a
3776
single terminal, so no confusion is possible as to what thread and
3777
frame are the current ones.
3778
 
3779
   In the case of MI, the concept of selected thread and frame is less
3780
useful.  First, a frontend can easily remember this information itself.
3781
Second, a graphical frontend can have more than one window, each one
3782
used for debugging a different thread, and the frontend might want to
3783
access additional threads for internal purposes.  This increases the
3784
risk that by relying on implicitly selected thread, the frontend may be
3785
operating on a wrong one.  Therefore, each MI command should explicitly
3786
specify which thread and frame to operate on.  To make it possible,
3787
each MI command accepts the `--thread' and `--frame' options, the value
3788
to each is GDB identifier for thread and frame to operate on.
3789
 
3790
   Usually, each top-level window in a frontend allows the user to
3791
select a thread and a frame, and remembers the user selection for
3792
further operations.  However, in some cases GDB may suggest that the
3793
current thread be changed.  For example, when stopping on a breakpoint
3794
it is reasonable to switch to the thread where breakpoint is hit.  For
3795
another example, if the user issues the CLI `thread' command via the
3796
frontend, it is desirable to change the frontend's selected thread to
3797
the one specified by user.  GDB communicates the suggestion to change
3798
current thread using the `=thread-selected' notification.  No such
3799
notification is available for the selected frame at the moment.
3800
 
3801
   Note that historically, MI shares the selected thread with CLI, so
3802
frontends used the `-thread-select' to execute commands in the right
3803
context.  However, getting this to work right is cumbersome.  The
3804
simplest way is for frontend to emit `-thread-select' command before
3805
every command.  This doubles the number of commands that need to be
3806
sent.  The alternative approach is to suppress `-thread-select' if the
3807
selected thread in GDB is supposed to be identical to the thread the
3808
frontend wants to operate on.  However, getting this optimization right
3809
can be tricky.  In particular, if the frontend sends several commands
3810
to GDB, and one of the commands changes the selected thread, then the
3811
behaviour of subsequent commands will change.  So, a frontend should
3812
either wait for response from such problematic commands, or explicitly
3813
add `-thread-select' for all subsequent commands.  No frontend is known
3814
to do this exactly right, so it is suggested to just always pass the
3815
`--thread' and `--frame' options.
3816
 
3817

3818
File: gdb.info,  Node: Asynchronous and non-stop modes,  Next: Thread groups,  Prev: Context management,  Up: GDB/MI General Design
3819
 
3820
27.1.2 Asynchronous command execution and non-stop mode
3821
-------------------------------------------------------
3822
 
3823
On some targets, GDB is capable of processing MI commands even while
3824
the target is running.  This is called "asynchronous command execution"
3825
(*note Background Execution::).  The frontend may specify a preferrence
3826
for asynchronous execution using the `-gdb-set target-async 1' command,
3827
which should be emitted before either running the executable or
3828
attaching to the target.  After the frontend has started the executable
3829
or attached to the target, it can find if asynchronous execution is
3830
enabled using the `-list-target-features' command.
3831
 
3832
   Even if GDB can accept a command while target is running, many
3833
commands that access the target do not work when the target is running.
3834
Therefore, asynchronous command execution is most useful when combined
3835
with non-stop mode (*note Non-Stop Mode::).  Then, it is possible to
3836
examine the state of one thread, while other threads are running.
3837
 
3838
   When a given thread is running, MI commands that try to access the
3839
target in the context of that thread may not work, or may work only on
3840
some targets.  In particular, commands that try to operate on thread's
3841
stack will not work, on any target.  Commands that read memory, or
3842
modify breakpoints, may work or not work, depending on the target.  Note
3843
that even commands that operate on global state, such as `print',
3844
`set', and breakpoint commands, still access the target in the context
3845
of a specific thread,  so frontend should try to find a stopped thread
3846
and perform the operation on that thread (using the `--thread' option).
3847
 
3848
   Which commands will work in the context of a running thread is
3849
highly target dependent.  However, the two commands `-exec-interrupt',
3850
to stop a thread, and `-thread-info', to find the state of a thread,
3851
will always work.
3852
 
3853

3854
File: gdb.info,  Node: Thread groups,  Prev: Asynchronous and non-stop modes,  Up: GDB/MI General Design
3855
 
3856
27.1.3 Thread groups
3857
--------------------
3858
 
3859
GDB may be used to debug several processes at the same time.  On some
3860
platfroms, GDB may support debugging of several hardware systems, each
3861
one having several cores with several different processes running on
3862
each core.  This section describes the MI mechanism to support such
3863
debugging scenarios.
3864
 
3865
   The key observation is that regardless of the structure of the
3866
target, MI can have a global list of threads, because most commands that
3867
accept the `--thread' option do not need to know what process that
3868
thread belongs to.  Therefore, it is not necessary to introduce neither
3869
additional `--process' option, nor an notion of the current process in
3870
the MI interface.  The only strictly new feature that is required is
3871
the ability to find how the threads are grouped into processes.
3872
 
3873
   To allow the user to discover such grouping, and to support arbitrary
3874
hierarchy of machines/cores/processes, MI introduces the concept of a
3875
"thread group".  Thread group is a collection of threads and other
3876
thread groups.  A thread group always has a string identifier, a type,
3877
and may have additional attributes specific to the type.  A new
3878
command, `-list-thread-groups', returns the list of top-level thread
3879
groups, which correspond to processes that GDB is debugging at the
3880
moment.  By passing an identifier of a thread group to the
3881
`-list-thread-groups' command, it is possible to obtain the members of
3882
specific thread group.
3883
 
3884
   To allow the user to easily discover processes, and other objects, he
3885
wishes to debug, a concept of "available thread group" is introduced.
3886
Available thread group is an thread group that GDB is not debugging,
3887
but that can be attached to, using the `-target-attach' command.  The
3888
list of available top-level thread groups can be obtained using
3889
`-list-thread-groups --available'.  In general, the content of a thread
3890
group may be only retrieved only after attaching to that thread group.
3891
 
3892

3893
File: gdb.info,  Node: GDB/MI Command Syntax,  Next: GDB/MI Compatibility with CLI,  Prev: GDB/MI General Design,  Up: GDB/MI
3894
 
3895
27.2 GDB/MI Command Syntax
3896
==========================
3897
 
3898
* Menu:
3899
 
3900
* GDB/MI Input Syntax::
3901
* GDB/MI Output Syntax::
3902
 
3903

3904
File: gdb.info,  Node: GDB/MI Input Syntax,  Next: GDB/MI Output Syntax,  Up: GDB/MI Command Syntax
3905
 
3906
27.2.1 GDB/MI Input Syntax
3907
--------------------------
3908
 
3909
`COMMAND ==>'
3910
     `CLI-COMMAND | MI-COMMAND'
3911
 
3912
`CLI-COMMAND ==>'
3913
     `[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDB
3914
     CLI command.
3915
 
3916
`MI-COMMAND ==>'
3917
     `[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " "
3918
     PARAMETER )* NL'
3919
 
3920
`TOKEN ==>'
3921
     "any sequence of digits"
3922
 
3923
`OPTION ==>'
3924
     `"-" PARAMETER [ " " PARAMETER ]'
3925
 
3926
`PARAMETER ==>'
3927
     `NON-BLANK-SEQUENCE | C-STRING'
3928
 
3929
`OPERATION ==>'
3930
     _any of the operations described in this chapter_
3931
 
3932
`NON-BLANK-SEQUENCE ==>'
3933
     _anything, provided it doesn't contain special characters such as
3934
     "-", NL, """ and of course " "_
3935
 
3936
`C-STRING ==>'
3937
     `""" SEVEN-BIT-ISO-C-STRING-CONTENT """'
3938
 
3939
`NL ==>'
3940
     `CR | CR-LF'
3941
 
3942
Notes:
3943
 
3944
   * The CLI commands are still handled by the MI interpreter; their
3945
     output is described below.
3946
 
3947
   * The `TOKEN', when present, is passed back when the command
3948
     finishes.
3949
 
3950
   * Some MI commands accept optional arguments as part of the parameter
3951
     list.  Each option is identified by a leading `-' (dash) and may be
3952
     followed by an optional argument parameter.  Options occur first
3953
     in the parameter list and can be delimited from normal parameters
3954
     using `--' (this is useful when some parameters begin with a dash).
3955
 
3956
   Pragmatics:
3957
 
3958
   * We want easy access to the existing CLI syntax (for debugging).
3959
 
3960
   * We want it to be easy to spot a MI operation.
3961
 
3962

3963
File: gdb.info,  Node: GDB/MI Output Syntax,  Prev: GDB/MI Input Syntax,  Up: GDB/MI Command Syntax
3964
 
3965
27.2.2 GDB/MI Output Syntax
3966
---------------------------
3967
 
3968
The output from GDB/MI consists of zero or more out-of-band records
3969
followed, optionally, by a single result record.  This result record is
3970
for the most recent command.  The sequence of output records is
3971
terminated by `(gdb)'.
3972
 
3973
   If an input command was prefixed with a `TOKEN' then the
3974
corresponding output for that command will also be prefixed by that same
3975
TOKEN.
3976
 
3977
`OUTPUT ==>'
3978
     `( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'
3979
 
3980
`RESULT-RECORD ==>'
3981
     ` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'
3982
 
3983
`OUT-OF-BAND-RECORD ==>'
3984
     `ASYNC-RECORD | STREAM-RECORD'
3985
 
3986
`ASYNC-RECORD ==>'
3987
     `EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'
3988
 
3989
`EXEC-ASYNC-OUTPUT ==>'
3990
     `[ TOKEN ] "*" ASYNC-OUTPUT'
3991
 
3992
`STATUS-ASYNC-OUTPUT ==>'
3993
     `[ TOKEN ] "+" ASYNC-OUTPUT'
3994
 
3995
`NOTIFY-ASYNC-OUTPUT ==>'
3996
     `[ TOKEN ] "=" ASYNC-OUTPUT'
3997
 
3998
`ASYNC-OUTPUT ==>'
3999
     `ASYNC-CLASS ( "," RESULT )* NL'
4000
 
4001
`RESULT-CLASS ==>'
4002
     `"done" | "running" | "connected" | "error" | "exit"'
4003
 
4004
`ASYNC-CLASS ==>'
4005
     `"stopped" | OTHERS' (where OTHERS will be added depending on the
4006
     needs--this is still in development).
4007
 
4008
`RESULT ==>'
4009
     ` VARIABLE "=" VALUE'
4010
 
4011
`VARIABLE ==>'
4012
     ` STRING '
4013
 
4014
`VALUE ==>'
4015
     ` CONST | TUPLE | LIST '
4016
 
4017
`CONST ==>'
4018
     `C-STRING'
4019
 
4020
`TUPLE ==>'
4021
     ` "{}" | "{" RESULT ( "," RESULT )* "}" '
4022
 
4023
`LIST ==>'
4024
     ` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*
4025
     "]" '
4026
 
4027
`STREAM-RECORD ==>'
4028
     `CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'
4029
 
4030
`CONSOLE-STREAM-OUTPUT ==>'
4031
     `"~" C-STRING'
4032
 
4033
`TARGET-STREAM-OUTPUT ==>'
4034
     `"@" C-STRING'
4035
 
4036
`LOG-STREAM-OUTPUT ==>'
4037
     `"&" C-STRING'
4038
 
4039
`NL ==>'
4040
     `CR | CR-LF'
4041
 
4042
`TOKEN ==>'
4043
     _any sequence of digits_.
4044
 
4045
Notes:
4046
 
4047
   * All output sequences end in a single line containing a period.
4048
 
4049
   * The `TOKEN' is from the corresponding request.  Note that for all
4050
     async output, while the token is allowed by the grammar and may be
4051
     output by future versions of GDB for select async output messages,
4052
     it is generally omitted.  Frontends should treat all async output
4053
     as reporting general changes in the state of the target and there
4054
     should be no need to associate async output to any prior command.
4055
 
4056
   * STATUS-ASYNC-OUTPUT contains on-going status information about the
4057
     progress of a slow operation.  It can be discarded.  All status
4058
     output is prefixed by `+'.
4059
 
4060
   * EXEC-ASYNC-OUTPUT contains asynchronous state change on the target
4061
     (stopped, started, disappeared).  All async output is prefixed by
4062
     `*'.
4063
 
4064
   * NOTIFY-ASYNC-OUTPUT contains supplementary information that the
4065
     client should handle (e.g., a new breakpoint information).  All
4066
     notify output is prefixed by `='.
4067
 
4068
   * CONSOLE-STREAM-OUTPUT is output that should be displayed as is in
4069
     the console.  It is the textual response to a CLI command.  All
4070
     the console output is prefixed by `~'.
4071
 
4072
   * TARGET-STREAM-OUTPUT is the output produced by the target program.
4073
     All the target output is prefixed by `@'.
4074
 
4075
   * LOG-STREAM-OUTPUT is output text coming from GDB's internals, for
4076
     instance messages that should be displayed as part of an error
4077
     log.  All the log output is prefixed by `&'.
4078
 
4079
   * New GDB/MI commands should only output LISTS containing VALUES.
4080
 
4081
 
4082
   *Note GDB/MI Stream Records: GDB/MI Stream Records, for more details
4083
about the various output records.
4084
 
4085

4086
File: gdb.info,  Node: GDB/MI Compatibility with CLI,  Next: GDB/MI Development and Front Ends,  Prev: GDB/MI Command Syntax,  Up: GDB/MI
4087
 
4088
27.3 GDB/MI Compatibility with CLI
4089
==================================
4090
 
4091
For the developers convenience CLI commands can be entered directly,
4092
but there may be some unexpected behaviour.  For example, commands that
4093
query the user will behave as if the user replied yes, breakpoint
4094
command lists are not executed and some CLI commands, such as `if',
4095
`when' and `define', prompt for further input with `>', which is not
4096
valid MI output.
4097
 
4098
   This feature may be removed at some stage in the future and it is
4099
recommended that front ends use the `-interpreter-exec' command (*note
4100
-interpreter-exec::).
4101
 
4102

4103
File: gdb.info,  Node: GDB/MI Development and Front Ends,  Next: GDB/MI Output Records,  Prev: GDB/MI Compatibility with CLI,  Up: GDB/MI
4104
 
4105
27.4 GDB/MI Development and Front Ends
4106
======================================
4107
 
4108
The application which takes the MI output and presents the state of the
4109
program being debugged to the user is called a "front end".
4110
 
4111
   Although GDB/MI is still incomplete, it is currently being used by a
4112
variety of front ends to GDB.  This makes it difficult to introduce new
4113
functionality without breaking existing usage.  This section tries to
4114
minimize the problems by describing how the protocol might change.
4115
 
4116
   Some changes in MI need not break a carefully designed front end, and
4117
for these the MI version will remain unchanged.  The following is a
4118
list of changes that may occur within one level, so front ends should
4119
parse MI output in a way that can handle them:
4120
 
4121
   * New MI commands may be added.
4122
 
4123
   * New fields may be added to the output of any MI command.
4124
 
4125
   * The range of values for fields with specified values, e.g.,
4126
     `in_scope' (*note -var-update::) may be extended.
4127
 
4128
 
4129
   If the changes are likely to break front ends, the MI version level
4130
will be increased by one.  This will allow the front end to parse the
4131
output according to the MI version.  Apart from mi0, new versions of
4132
GDB will not support old versions of MI and it will be the
4133
responsibility of the front end to work with the new one.
4134
 
4135
   The best way to avoid unexpected changes in MI that might break your
4136
front end is to make your project known to GDB developers and follow
4137
development on  and .
4138
 
4139

4140
File: gdb.info,  Node: GDB/MI Output Records,  Next: GDB/MI Simple Examples,  Prev: GDB/MI Development and Front Ends,  Up: GDB/MI
4141
 
4142
27.5 GDB/MI Output Records
4143
==========================
4144
 
4145
* Menu:
4146
 
4147
* GDB/MI Result Records::
4148
* GDB/MI Stream Records::
4149
* GDB/MI Async Records::
4150
* GDB/MI Frame Information::
4151
* GDB/MI Thread Information::
4152
 
4153

4154
File: gdb.info,  Node: GDB/MI Result Records,  Next: GDB/MI Stream Records,  Up: GDB/MI Output Records
4155
 
4156
27.5.1 GDB/MI Result Records
4157
----------------------------
4158
 
4159
In addition to a number of out-of-band notifications, the response to a
4160
GDB/MI command includes one of the following result indications:
4161
 
4162
`"^done" [ "," RESULTS ]'
4163
     The synchronous operation was successful, `RESULTS' are the return
4164
     values.
4165
 
4166
`"^running"'
4167
     This result record is equivalent to `^done'.  Historically, it was
4168
     output instead of `^done' if the command has resumed the target.
4169
     This behaviour is maintained for backward compatibility, but all
4170
     frontends should treat `^done' and `^running' identically and rely
4171
     on the `*running' output record to determine which threads are
4172
     resumed.
4173
 
4174
`"^connected"'
4175
     GDB has connected to a remote target.
4176
 
4177
`"^error" "," C-STRING'
4178
     The operation failed.  The `C-STRING' contains the corresponding
4179
     error message.
4180
 
4181
`"^exit"'
4182
     GDB has terminated.
4183
 
4184
 
4185

4186
File: gdb.info,  Node: GDB/MI Stream Records,  Next: GDB/MI Async Records,  Prev: GDB/MI Result Records,  Up: GDB/MI Output Records
4187
 
4188
27.5.2 GDB/MI Stream Records
4189
----------------------------
4190
 
4191
GDB internally maintains a number of output streams: the console, the
4192
target, and the log.  The output intended for each of these streams is
4193
funneled through the GDB/MI interface using "stream records".
4194
 
4195
   Each stream record begins with a unique "prefix character" which
4196
identifies its stream (*note GDB/MI Output Syntax: GDB/MI Output
4197
Syntax.).  In addition to the prefix, each stream record contains a
4198
`STRING-OUTPUT'.  This is either raw text (with an implicit new line)
4199
or a quoted C string (which does not contain an implicit newline).
4200
 
4201
`"~" STRING-OUTPUT'
4202
     The console output stream contains text that should be displayed
4203
     in the CLI console window.  It contains the textual responses to
4204
     CLI commands.
4205
 
4206
`"@" STRING-OUTPUT'
4207
     The target output stream contains any textual output from the
4208
     running target.  This is only present when GDB's event loop is
4209
     truly asynchronous, which is currently only the case for remote
4210
     targets.
4211
 
4212
`"&" STRING-OUTPUT'
4213
     The log stream contains debugging messages being produced by GDB's
4214
     internals.
4215
 
4216

4217
File: gdb.info,  Node: GDB/MI Async Records,  Next: GDB/MI Frame Information,  Prev: GDB/MI Stream Records,  Up: GDB/MI Output Records
4218
 
4219
27.5.3 GDB/MI Async Records
4220
---------------------------
4221
 
4222
"Async" records are used to notify the GDB/MI client of additional
4223
changes that have occurred.  Those changes can either be a consequence
4224
of GDB/MI commands (e.g., a breakpoint modified) or a result of target
4225
activity (e.g., target stopped).
4226
 
4227
   The following is the list of possible async records:
4228
 
4229
`*running,thread-id="THREAD"'
4230
     The target is now running.  The THREAD field tells which specific
4231
     thread is now running, and can be `all' if all threads are
4232
     running.  The frontend should assume that no interaction with a
4233
     running thread is possible after this notification is produced.
4234
     The frontend should not assume that this notification is output
4235
     only once for any command.  GDB may emit this notification several
4236
     times, either for different threads, because it cannot resume all
4237
     threads together, or even for a single thread, if the thread must
4238
     be stepped though some code before letting it run freely.
4239
 
4240
`*stopped,reason="REASON",thread-id="ID",stopped-threads="STOPPED",core="CORE"'
4241
     The target has stopped.  The REASON field can have one of the
4242
     following values:
4243
 
4244
    `breakpoint-hit'
4245
          A breakpoint was reached.
4246
 
4247
    `watchpoint-trigger'
4248
          A watchpoint was triggered.
4249
 
4250
    `read-watchpoint-trigger'
4251
          A read watchpoint was triggered.
4252
 
4253
    `access-watchpoint-trigger'
4254
          An access watchpoint was triggered.
4255
 
4256
    `function-finished'
4257
          An -exec-finish or similar CLI command was accomplished.
4258
 
4259
    `location-reached'
4260
          An -exec-until or similar CLI command was accomplished.
4261
 
4262
    `watchpoint-scope'
4263
          A watchpoint has gone out of scope.
4264
 
4265
    `end-stepping-range'
4266
          An -exec-next, -exec-next-instruction, -exec-step,
4267
          -exec-step-instruction or similar CLI command was
4268
          accomplished.
4269
 
4270
    `exited-signalled'
4271
          The inferior exited because of a signal.
4272
 
4273
    `exited'
4274
          The inferior exited.
4275
 
4276
    `exited-normally'
4277
          The inferior exited normally.
4278
 
4279
    `signal-received'
4280
          A signal was received by the inferior.
4281
 
4282
     The ID field identifies the thread that directly caused the stop -
4283
     for example by hitting a breakpoint.  Depending on whether all-stop
4284
     mode is in effect (*note All-Stop Mode::), GDB may either stop all
4285
     threads, or only the thread that directly triggered the stop.  If
4286
     all threads are stopped, the STOPPED field will have the value of
4287
     `"all"'.  Otherwise, the value of the STOPPED field will be a list
4288
     of thread identifiers.  Presently, this list will always include a
4289
     single thread, but frontend should be prepared to see several
4290
     threads in the list.  The CORE field reports the processor core on
4291
     which the stop event has happened.  This field may be absent if
4292
     such information is not available.
4293
 
4294
`=thread-group-created,id="ID"'
4295
`=thread-group-exited,id="ID"'
4296
     A thread thread group either was attached to, or has
4297
     exited/detached from.  The ID field contains the GDB identifier of
4298
     the thread group.
4299
 
4300
`=thread-created,id="ID",group-id="GID"'
4301
`=thread-exited,id="ID",group-id="GID"'
4302
     A thread either was created, or has exited.  The ID field contains
4303
     the GDB identifier of the thread.  The GID field identifies the
4304
     thread group this thread belongs to.
4305
 
4306
`=thread-selected,id="ID"'
4307
     Informs that the selected thread was changed as result of the last
4308
     command.  This notification is not emitted as result of
4309
     `-thread-select' command but is emitted whenever an MI command
4310
     that is not documented to change the selected thread actually
4311
     changes it.  In particular, invoking, directly or indirectly (via
4312
     user-defined command), the CLI `thread' command, will generate
4313
     this notification.
4314
 
4315
     We suggest that in response to this notification, front ends
4316
     highlight the selected thread and cause subsequent commands to
4317
     apply to that thread.
4318
 
4319
`=library-loaded,...'
4320
     Reports that a new library file was loaded by the program.  This
4321
     notification has 4 fields--ID, TARGET-NAME, HOST-NAME, and
4322
     SYMBOLS-LOADED.  The ID field is an opaque identifier of the
4323
     library.  For remote debugging case, TARGET-NAME and HOST-NAME
4324
     fields give the name of the library file on the target, and on the
4325
     host respectively.  For native debugging, both those fields have
4326
     the same value.  The SYMBOLS-LOADED field reports if the debug
4327
     symbols for this library are loaded.
4328
 
4329
`=library-unloaded,...'
4330
     Reports that a library was unloaded by the program.  This
4331
     notification has 3 fields--ID, TARGET-NAME and HOST-NAME with the
4332
     same meaning as for the `=library-loaded' notification
4333
 
4334
 
4335

4336
File: gdb.info,  Node: GDB/MI Frame Information,  Next: GDB/MI Thread Information,  Prev: GDB/MI Async Records,  Up: GDB/MI Output Records
4337
 
4338
27.5.4 GDB/MI Frame Information
4339
-------------------------------
4340
 
4341
Response from many MI commands includes an information about stack
4342
frame.  This information is a tuple that may have the following fields:
4343
 
4344
`level'
4345
     The level of the stack frame.  The innermost frame has the level of
4346
     zero.  This field is always present.
4347
 
4348
`func'
4349
     The name of the function corresponding to the frame.  This field
4350
     may be absent if GDB is unable to determine the function name.
4351
 
4352
`addr'
4353
     The code address for the frame.  This field is always present.
4354
 
4355
`file'
4356
     The name of the source files that correspond to the frame's code
4357
     address.  This field may be absent.
4358
 
4359
`line'
4360
     The source line corresponding to the frames' code address.  This
4361
     field may be absent.
4362
 
4363
`from'
4364
     The name of the binary file (either executable or shared library)
4365
     the corresponds to the frame's code address.  This field may be
4366
     absent.
4367
 
4368
 
4369

4370
File: gdb.info,  Node: GDB/MI Thread Information,  Prev: GDB/MI Frame Information,  Up: GDB/MI Output Records
4371
 
4372
27.5.5 GDB/MI Thread Information
4373
--------------------------------
4374
 
4375
Whenever GDB has to report an information about a thread, it uses a
4376
tuple with the following fields:
4377
 
4378
`id'
4379
     The numeric id assigned to the thread by GDB.  This field is
4380
     always present.
4381
 
4382
`target-id'
4383
     Target-specific string identifying the thread.  This field is
4384
     always present.
4385
 
4386
`details'
4387
     Additional information about the thread provided by the target.
4388
     It is supposed to be human-readable and not interpreted by the
4389
     frontend.  This field is optional.
4390
 
4391
`state'
4392
     Either `stopped' or `running', depending on whether the thread is
4393
     presently running.  This field is always present.
4394
 
4395
`core'
4396
     The value of this field is an integer number of the processor core
4397
     the thread was last seen on.  This field is optional.
4398
 
4399

4400
File: gdb.info,  Node: GDB/MI Simple Examples,  Next: GDB/MI Command Description Format,  Prev: GDB/MI Output Records,  Up: GDB/MI
4401
 
4402
27.6 Simple Examples of GDB/MI Interaction
4403
==========================================
4404
 
4405
This subsection presents several simple examples of interaction using
4406
the GDB/MI interface.  In these examples, `->' means that the following
4407
line is passed to GDB/MI as input, while `<-' means the output received
4408
from GDB/MI.
4409
 
4410
   Note the line breaks shown in the examples are here only for
4411
readability, they don't appear in the real output.
4412
 
4413
Setting a Breakpoint
4414
--------------------
4415
 
4416
Setting a breakpoint generates synchronous output which contains
4417
detailed information of the breakpoint.
4418
 
4419
     -> -break-insert main
4420
     <- ^done,bkpt={number="1",type="breakpoint",disp="keep",
4421
         enabled="y",addr="0x08048564",func="main",file="myprog.c",
4422
         fullname="/home/nickrob/myprog.c",line="68",times="0"}
4423
     <- (gdb)
4424
 
4425
Program Execution
4426
-----------------
4427
 
4428
Program execution generates asynchronous records and MI gives the
4429
reason that execution stopped.
4430
 
4431
     -> -exec-run
4432
     <- ^running
4433
     <- (gdb)
4434
     <- *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
4435
        frame={addr="0x08048564",func="main",
4436
        args=[{name="argc",value="1"},{name="argv",value="0xbfc4d4d4"}],
4437
        file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"}
4438
     <- (gdb)
4439
     -> -exec-continue
4440
     <- ^running
4441
     <- (gdb)
4442
     <- *stopped,reason="exited-normally"
4443
     <- (gdb)
4444
 
4445
Quitting GDB
4446
------------
4447
 
4448
Quitting GDB just prints the result class `^exit'.
4449
 
4450
     -> (gdb)
4451
     <- -gdb-exit
4452
     <- ^exit
4453
 
4454
   Please note that `^exit' is printed immediately, but it might take
4455
some time for GDB to actually exit.  During that time, GDB performs
4456
necessary cleanups, including killing programs being debugged or
4457
disconnecting from debug hardware, so the frontend should wait till GDB
4458
exits and should only forcibly kill GDB if it fails to exit in
4459
reasonable time.
4460
 
4461
A Bad Command
4462
-------------
4463
 
4464
Here's what happens if you pass a non-existent command:
4465
 
4466
     -> -rubbish
4467
     <- ^error,msg="Undefined MI command: rubbish"
4468
     <- (gdb)
4469
 
4470

4471
File: gdb.info,  Node: GDB/MI Command Description Format,  Next: GDB/MI Breakpoint Commands,  Prev: GDB/MI Simple Examples,  Up: GDB/MI
4472
 
4473
27.7 GDB/MI Command Description Format
4474
======================================
4475
 
4476
The remaining sections describe blocks of commands.  Each block of
4477
commands is laid out in a fashion similar to this section.
4478
 
4479
Motivation
4480
----------
4481
 
4482
The motivation for this collection of commands.
4483
 
4484
Introduction
4485
------------
4486
 
4487
A brief introduction to this collection of commands as a whole.
4488
 
4489
Commands
4490
--------
4491
 
4492
For each command in the block, the following is described:
4493
 
4494
Synopsis
4495
........
4496
 
4497
      -command ARGS...
4498
 
4499
Result
4500
......
4501
 
4502
GDB Command
4503
...........
4504
 
4505
The corresponding GDB CLI command(s), if any.
4506
 
4507
Example
4508
.......
4509
 
4510
Example(s) formatted for readability.  Some of the described commands
4511
have not been implemented yet and these are labeled N.A. (not
4512
available).
4513
 
4514

4515
File: gdb.info,  Node: GDB/MI Breakpoint Commands,  Next: GDB/MI Program Context,  Prev: GDB/MI Command Description Format,  Up: GDB/MI
4516
 
4517
27.8 GDB/MI Breakpoint Commands
4518
===============================
4519
 
4520
This section documents GDB/MI commands for manipulating breakpoints.
4521
 
4522
The `-break-after' Command
4523
--------------------------
4524
 
4525
Synopsis
4526
........
4527
 
4528
      -break-after NUMBER COUNT
4529
 
4530
   The breakpoint number NUMBER is not in effect until it has been hit
4531
COUNT times.  To see how this is reflected in the output of the
4532
`-break-list' command, see the description of the `-break-list' command
4533
below.
4534
 
4535
GDB Command
4536
...........
4537
 
4538
The corresponding GDB command is `ignore'.
4539
 
4540
Example
4541
.......
4542
 
4543
     (gdb)
4544
     -break-insert main
4545
     ^done,bkpt={number="1",type="breakpoint",disp="keep",
4546
     enabled="y",addr="0x000100d0",func="main",file="hello.c",
4547
     fullname="/home/foo/hello.c",line="5",times="0"}
4548
     (gdb)
4549
     -break-after 1 3
4550
     ~
4551
     ^done
4552
     (gdb)
4553
     -break-list
4554
     ^done,BreakpointTable={nr_rows="1",nr_cols="6",
4555
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4556
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4557
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4558
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4559
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4560
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4561
     body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
4562
     addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
4563
     line="5",times="0",ignore="3"}]}
4564
     (gdb)
4565
 
4566
The `-break-commands' Command
4567
-----------------------------
4568
 
4569
Synopsis
4570
........
4571
 
4572
      -break-commands NUMBER [ COMMAND1 ... COMMANDN ]
4573
 
4574
   Specifies the CLI commands that should be executed when breakpoint
4575
NUMBER is hit.  The parameters COMMAND1 to COMMANDN are the commands.
4576
If no command is specified, any previously-set commands are cleared.
4577
*Note Break Commands::.  Typical use of this functionality is tracing a
4578
program, that is, printing of values of some variables whenever
4579
breakpoint is hit and then continuing.
4580
 
4581
GDB Command
4582
...........
4583
 
4584
The corresponding GDB command is `commands'.
4585
 
4586
Example
4587
.......
4588
 
4589
     (gdb)
4590
     -break-insert main
4591
     ^done,bkpt={number="1",type="breakpoint",disp="keep",
4592
     enabled="y",addr="0x000100d0",func="main",file="hello.c",
4593
     fullname="/home/foo/hello.c",line="5",times="0"}
4594
     (gdb)
4595
     -break-commands 1 "print v" "continue"
4596
     ^done
4597
     (gdb)
4598
 
4599
The `-break-condition' Command
4600
------------------------------
4601
 
4602
Synopsis
4603
........
4604
 
4605
      -break-condition NUMBER EXPR
4606
 
4607
   Breakpoint NUMBER will stop the program only if the condition in
4608
EXPR is true.  The condition becomes part of the `-break-list' output
4609
(see the description of the `-break-list' command below).
4610
 
4611
GDB Command
4612
...........
4613
 
4614
The corresponding GDB command is `condition'.
4615
 
4616
Example
4617
.......
4618
 
4619
     (gdb)
4620
     -break-condition 1 1
4621
     ^done
4622
     (gdb)
4623
     -break-list
4624
     ^done,BreakpointTable={nr_rows="1",nr_cols="6",
4625
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4626
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4627
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4628
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4629
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4630
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4631
     body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
4632
     addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
4633
     line="5",cond="1",times="0",ignore="3"}]}
4634
     (gdb)
4635
 
4636
The `-break-delete' Command
4637
---------------------------
4638
 
4639
Synopsis
4640
........
4641
 
4642
      -break-delete ( BREAKPOINT )+
4643
 
4644
   Delete the breakpoint(s) whose number(s) are specified in the
4645
argument list.  This is obviously reflected in the breakpoint list.
4646
 
4647
GDB Command
4648
...........
4649
 
4650
The corresponding GDB command is `delete'.
4651
 
4652
Example
4653
.......
4654
 
4655
     (gdb)
4656
     -break-delete 1
4657
     ^done
4658
     (gdb)
4659
     -break-list
4660
     ^done,BreakpointTable={nr_rows="0",nr_cols="6",
4661
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4662
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4663
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4664
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4665
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4666
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4667
     body=[]}
4668
     (gdb)
4669
 
4670
The `-break-disable' Command
4671
----------------------------
4672
 
4673
Synopsis
4674
........
4675
 
4676
      -break-disable ( BREAKPOINT )+
4677
 
4678
   Disable the named BREAKPOINT(s).  The field `enabled' in the break
4679
list is now set to `n' for the named BREAKPOINT(s).
4680
 
4681
GDB Command
4682
...........
4683
 
4684
The corresponding GDB command is `disable'.
4685
 
4686
Example
4687
.......
4688
 
4689
     (gdb)
4690
     -break-disable 2
4691
     ^done
4692
     (gdb)
4693
     -break-list
4694
     ^done,BreakpointTable={nr_rows="1",nr_cols="6",
4695
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4696
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4697
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4698
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4699
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4700
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4701
     body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="n",
4702
     addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
4703
     line="5",times="0"}]}
4704
     (gdb)
4705
 
4706
The `-break-enable' Command
4707
---------------------------
4708
 
4709
Synopsis
4710
........
4711
 
4712
      -break-enable ( BREAKPOINT )+
4713
 
4714
   Enable (previously disabled) BREAKPOINT(s).
4715
 
4716
GDB Command
4717
...........
4718
 
4719
The corresponding GDB command is `enable'.
4720
 
4721
Example
4722
.......
4723
 
4724
     (gdb)
4725
     -break-enable 2
4726
     ^done
4727
     (gdb)
4728
     -break-list
4729
     ^done,BreakpointTable={nr_rows="1",nr_cols="6",
4730
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4731
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4732
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4733
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4734
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4735
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4736
     body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
4737
     addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
4738
     line="5",times="0"}]}
4739
     (gdb)
4740
 
4741
The `-break-info' Command
4742
-------------------------
4743
 
4744
Synopsis
4745
........
4746
 
4747
      -break-info BREAKPOINT
4748
 
4749
   Get information about a single breakpoint.
4750
 
4751
GDB Command
4752
...........
4753
 
4754
The corresponding GDB command is `info break BREAKPOINT'.
4755
 
4756
Example
4757
.......
4758
 
4759
N.A.
4760
 
4761
The `-break-insert' Command
4762
---------------------------
4763
 
4764
Synopsis
4765
........
4766
 
4767
      -break-insert [ -t ] [ -h ] [ -f ] [ -d ]
4768
         [ -c CONDITION ] [ -i IGNORE-COUNT ]
4769
         [ -p THREAD ] [ LOCATION ]
4770
 
4771
If specified, LOCATION, can be one of:
4772
 
4773
   * function
4774
 
4775
   * filename:linenum
4776
 
4777
   * filename:function
4778
 
4779
   * *address
4780
 
4781
   The possible optional parameters of this command are:
4782
 
4783
`-t'
4784
     Insert a temporary breakpoint.
4785
 
4786
`-h'
4787
     Insert a hardware breakpoint.
4788
 
4789
`-c CONDITION'
4790
     Make the breakpoint conditional on CONDITION.
4791
 
4792
`-i IGNORE-COUNT'
4793
     Initialize the IGNORE-COUNT.
4794
 
4795
`-f'
4796
     If LOCATION cannot be parsed (for example if it refers to unknown
4797
     files or functions), create a pending breakpoint. Without this
4798
     flag, GDB will report an error, and won't create a breakpoint, if
4799
     LOCATION cannot be parsed.
4800
 
4801
`-d'
4802
     Create a disabled breakpoint.
4803
 
4804
Result
4805
......
4806
 
4807
The result is in the form:
4808
 
4809
     ^done,bkpt={number="NUMBER",type="TYPE",disp="del"|"keep",
4810
     enabled="y"|"n",addr="HEX",func="FUNCNAME",file="FILENAME",
4811
     fullname="FULL_FILENAME",line="LINENO",[thread="THREADNO,]
4812
     times="TIMES"}
4813
 
4814
where NUMBER is the GDB number for this breakpoint, FUNCNAME is the
4815
name of the function where the breakpoint was inserted, FILENAME is the
4816
name of the source file which contains this function, LINENO is the
4817
source line number within that file and TIMES the number of times that
4818
the breakpoint has been hit (always 0 for -break-insert but may be
4819
greater for -break-info or -break-list which use the same output).
4820
 
4821
   Note: this format is open to change.
4822
 
4823
GDB Command
4824
...........
4825
 
4826
The corresponding GDB commands are `break', `tbreak', `hbreak',
4827
`thbreak', and `rbreak'.
4828
 
4829
Example
4830
.......
4831
 
4832
     (gdb)
4833
     -break-insert main
4834
     ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",
4835
     fullname="/home/foo/recursive2.c,line="4",times="0"}
4836
     (gdb)
4837
     -break-insert -t foo
4838
     ^done,bkpt={number="2",addr="0x00010774",file="recursive2.c",
4839
     fullname="/home/foo/recursive2.c,line="11",times="0"}
4840
     (gdb)
4841
     -break-list
4842
     ^done,BreakpointTable={nr_rows="2",nr_cols="6",
4843
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4844
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4845
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4846
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4847
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4848
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4849
     body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
4850
     addr="0x0001072c", func="main",file="recursive2.c",
4851
     fullname="/home/foo/recursive2.c,"line="4",times="0"},
4852
     bkpt={number="2",type="breakpoint",disp="del",enabled="y",
4853
     addr="0x00010774",func="foo",file="recursive2.c",
4854
     fullname="/home/foo/recursive2.c",line="11",times="0"}]}
4855
     (gdb)
4856
     -break-insert -r foo.*
4857
     ~int foo(int, int);
4858
     ^done,bkpt={number="3",addr="0x00010774",file="recursive2.c,
4859
     "fullname="/home/foo/recursive2.c",line="11",times="0"}
4860
     (gdb)
4861
 
4862
The `-break-list' Command
4863
-------------------------
4864
 
4865
Synopsis
4866
........
4867
 
4868
      -break-list
4869
 
4870
   Displays the list of inserted breakpoints, showing the following
4871
fields:
4872
 
4873
`Number'
4874
     number of the breakpoint
4875
 
4876
`Type'
4877
     type of the breakpoint: `breakpoint' or `watchpoint'
4878
 
4879
`Disposition'
4880
     should the breakpoint be deleted or disabled when it is hit: `keep'
4881
     or `nokeep'
4882
 
4883
`Enabled'
4884
     is the breakpoint enabled or no: `y' or `n'
4885
 
4886
`Address'
4887
     memory location at which the breakpoint is set
4888
 
4889
`What'
4890
     logical location of the breakpoint, expressed by function name,
4891
     file name, line number
4892
 
4893
`Times'
4894
     number of times the breakpoint has been hit
4895
 
4896
   If there are no breakpoints or watchpoints, the `BreakpointTable'
4897
`body' field is an empty list.
4898
 
4899
GDB Command
4900
...........
4901
 
4902
The corresponding GDB command is `info break'.
4903
 
4904
Example
4905
.......
4906
 
4907
     (gdb)
4908
     -break-list
4909
     ^done,BreakpointTable={nr_rows="2",nr_cols="6",
4910
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4911
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4912
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4913
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4914
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4915
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4916
     body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
4917
     addr="0x000100d0",func="main",file="hello.c",line="5",times="0"},
4918
     bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
4919
     addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c",
4920
     line="13",times="0"}]}
4921
     (gdb)
4922
 
4923
   Here's an example of the result when there are no breakpoints:
4924
 
4925
     (gdb)
4926
     -break-list
4927
     ^done,BreakpointTable={nr_rows="0",nr_cols="6",
4928
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
4929
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
4930
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
4931
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
4932
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
4933
     {width="40",alignment="2",col_name="what",colhdr="What"}],
4934
     body=[]}
4935
     (gdb)
4936
 
4937
The `-break-watch' Command
4938
--------------------------
4939
 
4940
Synopsis
4941
........
4942
 
4943
      -break-watch [ -a | -r ]
4944
 
4945
   Create a watchpoint.  With the `-a' option it will create an
4946
"access" watchpoint, i.e., a watchpoint that triggers either on a read
4947
from or on a write to the memory location.  With the `-r' option, the
4948
watchpoint created is a "read" watchpoint, i.e., it will trigger only
4949
when the memory location is accessed for reading.  Without either of
4950
the options, the watchpoint created is a regular watchpoint, i.e., it
4951
will trigger when the memory location is accessed for writing.  *Note
4952
Setting Watchpoints: Set Watchpoints.
4953
 
4954
   Note that `-break-list' will report a single list of watchpoints and
4955
breakpoints inserted.
4956
 
4957
GDB Command
4958
...........
4959
 
4960
The corresponding GDB commands are `watch', `awatch', and `rwatch'.
4961
 
4962
Example
4963
.......
4964
 
4965
Setting a watchpoint on a variable in the `main' function:
4966
 
4967
     (gdb)
4968
     -break-watch x
4969
     ^done,wpt={number="2",exp="x"}
4970
     (gdb)
4971
     -exec-continue
4972
     ^running
4973
     (gdb)
4974
     *stopped,reason="watchpoint-trigger",wpt={number="2",exp="x"},
4975
     value={old="-268439212",new="55"},
4976
     frame={func="main",args=[],file="recursive2.c",
4977
     fullname="/home/foo/bar/recursive2.c",line="5"}
4978
     (gdb)
4979
 
4980
   Setting a watchpoint on a variable local to a function.  GDB will
4981
stop the program execution twice: first for the variable changing
4982
value, then for the watchpoint going out of scope.
4983
 
4984
     (gdb)
4985
     -break-watch C
4986
     ^done,wpt={number="5",exp="C"}
4987
     (gdb)
4988
     -exec-continue
4989
     ^running
4990
     (gdb)
4991
     *stopped,reason="watchpoint-trigger",
4992
     wpt={number="5",exp="C"},value={old="-276895068",new="3"},
4993
     frame={func="callee4",args=[],
4994
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
4995
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
4996
     (gdb)
4997
     -exec-continue
4998
     ^running
4999
     (gdb)
5000
     *stopped,reason="watchpoint-scope",wpnum="5",
5001
     frame={func="callee3",args=[{name="strarg",
5002
     value="0x11940 \"A string argument.\""}],
5003
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5004
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
5005
     (gdb)
5006
 
5007
   Listing breakpoints and watchpoints, at different points in the
5008
program execution.  Note that once the watchpoint goes out of scope, it
5009
is deleted.
5010
 
5011
     (gdb)
5012
     -break-watch C
5013
     ^done,wpt={number="2",exp="C"}
5014
     (gdb)
5015
     -break-list
5016
     ^done,BreakpointTable={nr_rows="2",nr_cols="6",
5017
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
5018
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
5019
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
5020
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
5021
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
5022
     {width="40",alignment="2",col_name="what",colhdr="What"}],
5023
     body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
5024
     addr="0x00010734",func="callee4",
5025
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5026
     fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",times="1"},
5027
     bkpt={number="2",type="watchpoint",disp="keep",
5028
     enabled="y",addr="",what="C",times="0"}]}
5029
     (gdb)
5030
     -exec-continue
5031
     ^running
5032
     (gdb)
5033
     *stopped,reason="watchpoint-trigger",wpt={number="2",exp="C"},
5034
     value={old="-276895068",new="3"},
5035
     frame={func="callee4",args=[],
5036
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5037
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
5038
     (gdb)
5039
     -break-list
5040
     ^done,BreakpointTable={nr_rows="2",nr_cols="6",
5041
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
5042
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
5043
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
5044
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
5045
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
5046
     {width="40",alignment="2",col_name="what",colhdr="What"}],
5047
     body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
5048
     addr="0x00010734",func="callee4",
5049
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5050
     fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"},
5051
     bkpt={number="2",type="watchpoint",disp="keep",
5052
     enabled="y",addr="",what="C",times="-5"}]}
5053
     (gdb)
5054
     -exec-continue
5055
     ^running
5056
     ^done,reason="watchpoint-scope",wpnum="2",
5057
     frame={func="callee3",args=[{name="strarg",
5058
     value="0x11940 \"A string argument.\""}],
5059
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5060
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
5061
     (gdb)
5062
     -break-list
5063
     ^done,BreakpointTable={nr_rows="1",nr_cols="6",
5064
     hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
5065
     {width="14",alignment="-1",col_name="type",colhdr="Type"},
5066
     {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
5067
     {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
5068
     {width="10",alignment="-1",col_name="addr",colhdr="Address"},
5069
     {width="40",alignment="2",col_name="what",colhdr="What"}],
5070
     body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
5071
     addr="0x00010734",func="callee4",
5072
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5073
     fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
5074
     times="1"}]}
5075
     (gdb)
5076
 
5077

5078
File: gdb.info,  Node: GDB/MI Program Context,  Next: GDB/MI Thread Commands,  Prev: GDB/MI Breakpoint Commands,  Up: GDB/MI
5079
 
5080
27.9 GDB/MI  Program Context
5081
============================
5082
 
5083
The `-exec-arguments' Command
5084
-----------------------------
5085
 
5086
Synopsis
5087
........
5088
 
5089
      -exec-arguments ARGS
5090
 
5091
   Set the inferior program arguments, to be used in the next
5092
`-exec-run'.
5093
 
5094
GDB Command
5095
...........
5096
 
5097
The corresponding GDB command is `set args'.
5098
 
5099
Example
5100
.......
5101
 
5102
     (gdb)
5103
     -exec-arguments -v word
5104
     ^done
5105
     (gdb)
5106
 
5107
The `-environment-cd' Command
5108
-----------------------------
5109
 
5110
Synopsis
5111
........
5112
 
5113
      -environment-cd PATHDIR
5114
 
5115
   Set GDB's working directory.
5116
 
5117
GDB Command
5118
...........
5119
 
5120
The corresponding GDB command is `cd'.
5121
 
5122
Example
5123
.......
5124
 
5125
     (gdb)
5126
     -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
5127
     ^done
5128
     (gdb)
5129
 
5130
The `-environment-directory' Command
5131
------------------------------------
5132
 
5133
Synopsis
5134
........
5135
 
5136
      -environment-directory [ -r ] [ PATHDIR ]+
5137
 
5138
   Add directories PATHDIR to beginning of search path for source files.
5139
If the `-r' option is used, the search path is reset to the default
5140
search path.  If directories PATHDIR are supplied in addition to the
5141
`-r' option, the search path is first reset and then addition occurs as
5142
normal.  Multiple directories may be specified, separated by blanks.
5143
Specifying multiple directories in a single command results in the
5144
directories added to the beginning of the search path in the same order
5145
they were presented in the command.  If blanks are needed as part of a
5146
directory name, double-quotes should be used around the name.  In the
5147
command output, the path will show up separated by the system
5148
directory-separator character.  The directory-separator character must
5149
not be used in any directory name.  If no directories are specified,
5150
the current search path is displayed.
5151
 
5152
GDB Command
5153
...........
5154
 
5155
The corresponding GDB command is `dir'.
5156
 
5157
Example
5158
.......
5159
 
5160
     (gdb)
5161
     -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
5162
     ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
5163
     (gdb)
5164
     -environment-directory ""
5165
     ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
5166
     (gdb)
5167
     -environment-directory -r /home/jjohnstn/src/gdb /usr/src
5168
     ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
5169
     (gdb)
5170
     -environment-directory -r
5171
     ^done,source-path="$cdir:$cwd"
5172
     (gdb)
5173
 
5174
The `-environment-path' Command
5175
-------------------------------
5176
 
5177
Synopsis
5178
........
5179
 
5180
      -environment-path [ -r ] [ PATHDIR ]+
5181
 
5182
   Add directories PATHDIR to beginning of search path for object files.
5183
If the `-r' option is used, the search path is reset to the original
5184
search path that existed at gdb start-up.  If directories PATHDIR are
5185
supplied in addition to the `-r' option, the search path is first reset
5186
and then addition occurs as normal.  Multiple directories may be
5187
specified, separated by blanks.  Specifying multiple directories in a
5188
single command results in the directories added to the beginning of the
5189
search path in the same order they were presented in the command.  If
5190
blanks are needed as part of a directory name, double-quotes should be
5191
used around the name.  In the command output, the path will show up
5192
separated by the system directory-separator character.  The
5193
directory-separator character must not be used in any directory name.
5194
If no directories are specified, the current path is displayed.
5195
 
5196
GDB Command
5197
...........
5198
 
5199
The corresponding GDB command is `path'.
5200
 
5201
Example
5202
.......
5203
 
5204
     (gdb)
5205
     -environment-path
5206
     ^done,path="/usr/bin"
5207
     (gdb)
5208
     -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
5209
     ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
5210
     (gdb)
5211
     -environment-path -r /usr/local/bin
5212
     ^done,path="/usr/local/bin:/usr/bin"
5213
     (gdb)
5214
 
5215
The `-environment-pwd' Command
5216
------------------------------
5217
 
5218
Synopsis
5219
........
5220
 
5221
      -environment-pwd
5222
 
5223
   Show the current working directory.
5224
 
5225
GDB Command
5226
...........
5227
 
5228
The corresponding GDB command is `pwd'.
5229
 
5230
Example
5231
.......
5232
 
5233
     (gdb)
5234
     -environment-pwd
5235
     ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
5236
     (gdb)
5237
 
5238

5239
File: gdb.info,  Node: GDB/MI Thread Commands,  Next: GDB/MI Program Execution,  Prev: GDB/MI Program Context,  Up: GDB/MI
5240
 
5241
27.10 GDB/MI Thread Commands
5242
============================
5243
 
5244
The `-thread-info' Command
5245
--------------------------
5246
 
5247
Synopsis
5248
........
5249
 
5250
      -thread-info [ THREAD-ID ]
5251
 
5252
   Reports information about either a specific thread, if the THREAD-ID
5253
parameter is present, or about all threads.  When printing information
5254
about all threads, also reports the current thread.
5255
 
5256
GDB Command
5257
...........
5258
 
5259
The `info thread' command prints the same information about all threads.
5260
 
5261
Example
5262
.......
5263
 
5264
     -thread-info
5265
     ^done,threads=[
5266
     {id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
5267
        frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]},state="running"},
5268
     {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
5269
        frame={level="0",addr="0x0804891f",func="foo",args=[{name="i",value="10"}],
5270
                file="/tmp/a.c",fullname="/tmp/a.c",line="158"},state="running"}],
5271
     current-thread-id="1"
5272
     (gdb)
5273
 
5274
   The `state' field may have the following values:
5275
 
5276
`stopped'
5277
     The thread is stopped.  Frame information is available for stopped
5278
     threads.
5279
 
5280
`running'
5281
     The thread is running.  There's no frame information for running
5282
     threads.
5283
 
5284
 
5285
The `-thread-list-ids' Command
5286
------------------------------
5287
 
5288
Synopsis
5289
........
5290
 
5291
      -thread-list-ids
5292
 
5293
   Produces a list of the currently known GDB thread ids.  At the end
5294
of the list it also prints the total number of such threads.
5295
 
5296
   This command is retained for historical reasons, the `-thread-info'
5297
command should be used instead.
5298
 
5299
GDB Command
5300
...........
5301
 
5302
Part of `info threads' supplies the same information.
5303
 
5304
Example
5305
.......
5306
 
5307
     (gdb)
5308
     -thread-list-ids
5309
     ^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"},
5310
     current-thread-id="1",number-of-threads="3"
5311
     (gdb)
5312
 
5313
The `-thread-select' Command
5314
----------------------------
5315
 
5316
Synopsis
5317
........
5318
 
5319
      -thread-select THREADNUM
5320
 
5321
   Make THREADNUM the current thread.  It prints the number of the new
5322
current thread, and the topmost frame for that thread.
5323
 
5324
   This command is deprecated in favor of explicitly using the
5325
`--thread' option to each command.
5326
 
5327
GDB Command
5328
...........
5329
 
5330
The corresponding GDB command is `thread'.
5331
 
5332
Example
5333
.......
5334
 
5335
     (gdb)
5336
     -exec-next
5337
     ^running
5338
     (gdb)
5339
     *stopped,reason="end-stepping-range",thread-id="2",line="187",
5340
     file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
5341
     (gdb)
5342
     -thread-list-ids
5343
     ^done,
5344
     thread-ids={thread-id="3",thread-id="2",thread-id="1"},
5345
     number-of-threads="3"
5346
     (gdb)
5347
     -thread-select 3
5348
     ^done,new-thread-id="3",
5349
     frame={level="0",func="vprintf",
5350
     args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""},
5351
     {name="arg",value="0x2"}],file="vprintf.c",line="31"}
5352
     (gdb)
5353
 
5354

5355
File: gdb.info,  Node: GDB/MI Program Execution,  Next: GDB/MI Stack Manipulation,  Prev: GDB/MI Thread Commands,  Up: GDB/MI
5356
 
5357
27.11 GDB/MI Program Execution
5358
==============================
5359
 
5360
These are the asynchronous commands which generate the out-of-band
5361
record `*stopped'.  Currently GDB only really executes asynchronously
5362
with remote targets and this interaction is mimicked in other cases.
5363
 
5364
The `-exec-continue' Command
5365
----------------------------
5366
 
5367
Synopsis
5368
........
5369
 
5370
      -exec-continue [--reverse] [--all|--thread-group N]
5371
 
5372
   Resumes the execution of the inferior program, which will continue
5373
to execute until it reaches a debugger stop event.  If the `--reverse'
5374
option is specified, execution resumes in reverse until it reaches a
5375
stop event.  Stop events may include
5376
   * breakpoints or watchpoints
5377
 
5378
   * signals or exceptions
5379
 
5380
   * the end of the process (or its beginning under `--reverse')
5381
 
5382
   * the end or beginning of a replay log if one is being used.
5383
   In all-stop mode (*note All-Stop Mode::), may resume only one
5384
thread, or all threads, depending on the value of the
5385
`scheduler-locking' variable.  If `--all' is specified, all threads
5386
will be resumed.  The `--all' option is ignored in all-stop mode.  If
5387
the `--thread-group' options is specified, then all threads in that
5388
thread group are resumed.
5389
 
5390
GDB Command
5391
...........
5392
 
5393
The corresponding GDB corresponding is `continue'.
5394
 
5395
Example
5396
.......
5397
 
5398
     -exec-continue
5399
     ^running
5400
     (gdb)
5401
     @Hello world
5402
     *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={
5403
     func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c",
5404
     line="13"}
5405
     (gdb)
5406
 
5407
The `-exec-finish' Command
5408
--------------------------
5409
 
5410
Synopsis
5411
........
5412
 
5413
      -exec-finish [--reverse]
5414
 
5415
   Resumes the execution of the inferior program until the current
5416
function is exited.  Displays the results returned by the function.  If
5417
the `--reverse' option is specified, resumes the reverse execution of
5418
the inferior program until the point where current function was called.
5419
 
5420
GDB Command
5421
...........
5422
 
5423
The corresponding GDB command is `finish'.
5424
 
5425
Example
5426
.......
5427
 
5428
Function returning `void'.
5429
 
5430
     -exec-finish
5431
     ^running
5432
     (gdb)
5433
     @hello from foo
5434
     *stopped,reason="function-finished",frame={func="main",args=[],
5435
     file="hello.c",fullname="/home/foo/bar/hello.c",line="7"}
5436
     (gdb)
5437
 
5438
   Function returning other than `void'.  The name of the internal GDB
5439
variable storing the result is printed, together with the value itself.
5440
 
5441
     -exec-finish
5442
     ^running
5443
     (gdb)
5444
     *stopped,reason="function-finished",frame={addr="0x000107b0",func="foo",
5445
     args=[{name="a",value="1"],{name="b",value="9"}},
5446
     file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
5447
     gdb-result-var="$1",return-value="0"
5448
     (gdb)
5449
 
5450
The `-exec-interrupt' Command
5451
-----------------------------
5452
 
5453
Synopsis
5454
........
5455
 
5456
      -exec-interrupt [--all|--thread-group N]
5457
 
5458
   Interrupts the background execution of the target.  Note how the
5459
token associated with the stop message is the one for the execution
5460
command that has been interrupted.  The token for the interrupt itself
5461
only appears in the `^done' output.  If the user is trying to interrupt
5462
a non-running program, an error message will be printed.
5463
 
5464
   Note that when asynchronous execution is enabled, this command is
5465
asynchronous just like other execution commands.  That is, first the
5466
`^done' response will be printed, and the target stop will be reported
5467
after that using the `*stopped' notification.
5468
 
5469
   In non-stop mode, only the context thread is interrupted by default.
5470
All threads will be interrupted if the `--all' option is specified.  If
5471
the `--thread-group' option is specified, all threads in that group
5472
will be interrupted.
5473
 
5474
GDB Command
5475
...........
5476
 
5477
The corresponding GDB command is `interrupt'.
5478
 
5479
Example
5480
.......
5481
 
5482
     (gdb)
5483
     111-exec-continue
5484
     111^running
5485
 
5486
     (gdb)
5487
     222-exec-interrupt
5488
     222^done
5489
     (gdb)
5490
     111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
5491
     frame={addr="0x00010140",func="foo",args=[],file="try.c",
5492
     fullname="/home/foo/bar/try.c",line="13"}
5493
     (gdb)
5494
 
5495
     (gdb)
5496
     -exec-interrupt
5497
     ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
5498
     (gdb)
5499
 
5500
The `-exec-jump' Command
5501
------------------------
5502
 
5503
Synopsis
5504
........
5505
 
5506
      -exec-jump LOCATION
5507
 
5508
   Resumes execution of the inferior program at the location specified
5509
by parameter.  *Note Specify Location::, for a description of the
5510
different forms of LOCATION.
5511
 
5512
GDB Command
5513
...........
5514
 
5515
The corresponding GDB command is `jump'.
5516
 
5517
Example
5518
.......
5519
 
5520
     -exec-jump foo.c:10
5521
     *running,thread-id="all"
5522
     ^running
5523
 
5524
The `-exec-next' Command
5525
------------------------
5526
 
5527
Synopsis
5528
........
5529
 
5530
      -exec-next [--reverse]
5531
 
5532
   Resumes execution of the inferior program, stopping when the
5533
beginning of the next source line is reached.
5534
 
5535
   If the `--reverse' option is specified, resumes reverse execution of
5536
the inferior program, stopping at the beginning of the previous source
5537
line.  If you issue this command on the first line of a function, it
5538
will take you back to the caller of that function, to the source line
5539
where the function was called.
5540
 
5541
GDB Command
5542
...........
5543
 
5544
The corresponding GDB command is `next'.
5545
 
5546
Example
5547
.......
5548
 
5549
     -exec-next
5550
     ^running
5551
     (gdb)
5552
     *stopped,reason="end-stepping-range",line="8",file="hello.c"
5553
     (gdb)
5554
 
5555
The `-exec-next-instruction' Command
5556
------------------------------------
5557
 
5558
Synopsis
5559
........
5560
 
5561
      -exec-next-instruction [--reverse]
5562
 
5563
   Executes one machine instruction.  If the instruction is a function
5564
call, continues until the function returns.  If the program stops at an
5565
instruction in the middle of a source line, the address will be printed
5566
as well.
5567
 
5568
   If the `--reverse' option is specified, resumes reverse execution of
5569
the inferior program, stopping at the previous instruction.  If the
5570
previously executed instruction was a return from another function, it
5571
will continue to execute in reverse until the call to that function
5572
(from the current stack frame) is reached.
5573
 
5574
GDB Command
5575
...........
5576
 
5577
The corresponding GDB command is `nexti'.
5578
 
5579
Example
5580
.......
5581
 
5582
     (gdb)
5583
     -exec-next-instruction
5584
     ^running
5585
 
5586
     (gdb)
5587
     *stopped,reason="end-stepping-range",
5588
     addr="0x000100d4",line="5",file="hello.c"
5589
     (gdb)
5590
 
5591
The `-exec-return' Command
5592
--------------------------
5593
 
5594
Synopsis
5595
........
5596
 
5597
      -exec-return
5598
 
5599
   Makes current function return immediately.  Doesn't execute the
5600
inferior.  Displays the new current frame.
5601
 
5602
GDB Command
5603
...........
5604
 
5605
The corresponding GDB command is `return'.
5606
 
5607
Example
5608
.......
5609
 
5610
     (gdb)
5611
     200-break-insert callee4
5612
     200^done,bkpt={number="1",addr="0x00010734",
5613
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
5614
     (gdb)
5615
     000-exec-run
5616
     000^running
5617
     (gdb)
5618
     000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
5619
     frame={func="callee4",args=[],
5620
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5621
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
5622
     (gdb)
5623
     205-break-delete
5624
     205^done
5625
     (gdb)
5626
     111-exec-return
5627
     111^done,frame={level="0",func="callee3",
5628
     args=[{name="strarg",
5629
     value="0x11940 \"A string argument.\""}],
5630
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5631
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
5632
     (gdb)
5633
 
5634
The `-exec-run' Command
5635
-----------------------
5636
 
5637
Synopsis
5638
........
5639
 
5640
      -exec-run
5641
 
5642
   Starts execution of the inferior from the beginning.  The inferior
5643
executes until either a breakpoint is encountered or the program exits.
5644
In the latter case the output will include an exit code, if the
5645
program has exited exceptionally.
5646
 
5647
GDB Command
5648
...........
5649
 
5650
The corresponding GDB command is `run'.
5651
 
5652
Examples
5653
........
5654
 
5655
     (gdb)
5656
     -break-insert main
5657
     ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"}
5658
     (gdb)
5659
     -exec-run
5660
     ^running
5661
     (gdb)
5662
     *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
5663
     frame={func="main",args=[],file="recursive2.c",
5664
     fullname="/home/foo/bar/recursive2.c",line="4"}
5665
     (gdb)
5666
 
5667
Program exited normally:
5668
 
5669
     (gdb)
5670
     -exec-run
5671
     ^running
5672
     (gdb)
5673
     x = 55
5674
     *stopped,reason="exited-normally"
5675
     (gdb)
5676
 
5677
Program exited exceptionally:
5678
 
5679
     (gdb)
5680
     -exec-run
5681
     ^running
5682
     (gdb)
5683
     x = 55
5684
     *stopped,reason="exited",exit-code="01"
5685
     (gdb)
5686
 
5687
   Another way the program can terminate is if it receives a signal
5688
such as `SIGINT'.  In this case, GDB/MI displays this:
5689
 
5690
     (gdb)
5691
     *stopped,reason="exited-signalled",signal-name="SIGINT",
5692
     signal-meaning="Interrupt"
5693
 
5694
The `-exec-step' Command
5695
------------------------
5696
 
5697
Synopsis
5698
........
5699
 
5700
      -exec-step [--reverse]
5701
 
5702
   Resumes execution of the inferior program, stopping when the
5703
beginning of the next source line is reached, if the next source line
5704
is not a function call.  If it is, stop at the first instruction of the
5705
called function.  If the `--reverse' option is specified, resumes
5706
reverse execution of the inferior program, stopping at the beginning of
5707
the previously executed source line.
5708
 
5709
GDB Command
5710
...........
5711
 
5712
The corresponding GDB command is `step'.
5713
 
5714
Example
5715
.......
5716
 
5717
Stepping into a function:
5718
 
5719
     -exec-step
5720
     ^running
5721
     (gdb)
5722
     *stopped,reason="end-stepping-range",
5723
     frame={func="foo",args=[{name="a",value="10"},
5724
     {name="b",value="0"}],file="recursive2.c",
5725
     fullname="/home/foo/bar/recursive2.c",line="11"}
5726
     (gdb)
5727
 
5728
   Regular stepping:
5729
 
5730
     -exec-step
5731
     ^running
5732
     (gdb)
5733
     *stopped,reason="end-stepping-range",line="14",file="recursive2.c"
5734
     (gdb)
5735
 
5736
The `-exec-step-instruction' Command
5737
------------------------------------
5738
 
5739
Synopsis
5740
........
5741
 
5742
      -exec-step-instruction [--reverse]
5743
 
5744
   Resumes the inferior which executes one machine instruction.  If the
5745
`--reverse' option is specified, resumes reverse execution of the
5746
inferior program, stopping at the previously executed instruction.  The
5747
output, once GDB has stopped, will vary depending on whether we have
5748
stopped in the middle of a source line or not.  In the former case, the
5749
address at which the program stopped will be printed as well.
5750
 
5751
GDB Command
5752
...........
5753
 
5754
The corresponding GDB command is `stepi'.
5755
 
5756
Example
5757
.......
5758
 
5759
     (gdb)
5760
     -exec-step-instruction
5761
     ^running
5762
 
5763
     (gdb)
5764
     *stopped,reason="end-stepping-range",
5765
     frame={func="foo",args=[],file="try.c",
5766
     fullname="/home/foo/bar/try.c",line="10"}
5767
     (gdb)
5768
     -exec-step-instruction
5769
     ^running
5770
 
5771
     (gdb)
5772
     *stopped,reason="end-stepping-range",
5773
     frame={addr="0x000100f4",func="foo",args=[],file="try.c",
5774
     fullname="/home/foo/bar/try.c",line="10"}
5775
     (gdb)
5776
 
5777
The `-exec-until' Command
5778
-------------------------
5779
 
5780
Synopsis
5781
........
5782
 
5783
      -exec-until [ LOCATION ]
5784
 
5785
   Executes the inferior until the LOCATION specified in the argument
5786
is reached.  If there is no argument, the inferior executes until a
5787
source line greater than the current one is reached.  The reason for
5788
stopping in this case will be `location-reached'.
5789
 
5790
GDB Command
5791
...........
5792
 
5793
The corresponding GDB command is `until'.
5794
 
5795
Example
5796
.......
5797
 
5798
     (gdb)
5799
     -exec-until recursive2.c:6
5800
     ^running
5801
     (gdb)
5802
     x = 55
5803
     *stopped,reason="location-reached",frame={func="main",args=[],
5804
     file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6"}
5805
     (gdb)
5806
 
5807

5808
File: gdb.info,  Node: GDB/MI Stack Manipulation,  Next: GDB/MI Variable Objects,  Prev: GDB/MI Program Execution,  Up: GDB/MI
5809
 
5810
27.12 GDB/MI Stack Manipulation Commands
5811
========================================
5812
 
5813
The `-stack-info-frame' Command
5814
-------------------------------
5815
 
5816
Synopsis
5817
........
5818
 
5819
      -stack-info-frame
5820
 
5821
   Get info on the selected frame.
5822
 
5823
GDB Command
5824
...........
5825
 
5826
The corresponding GDB command is `info frame' or `frame' (without
5827
arguments).
5828
 
5829
Example
5830
.......
5831
 
5832
     (gdb)
5833
     -stack-info-frame
5834
     ^done,frame={level="1",addr="0x0001076c",func="callee3",
5835
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5836
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"}
5837
     (gdb)
5838
 
5839
The `-stack-info-depth' Command
5840
-------------------------------
5841
 
5842
Synopsis
5843
........
5844
 
5845
      -stack-info-depth [ MAX-DEPTH ]
5846
 
5847
   Return the depth of the stack.  If the integer argument MAX-DEPTH is
5848
specified, do not count beyond MAX-DEPTH frames.
5849
 
5850
GDB Command
5851
...........
5852
 
5853
There's no equivalent GDB command.
5854
 
5855
Example
5856
.......
5857
 
5858
For a stack with frame levels 0 through 11:
5859
 
5860
     (gdb)
5861
     -stack-info-depth
5862
     ^done,depth="12"
5863
     (gdb)
5864
     -stack-info-depth 4
5865
     ^done,depth="4"
5866
     (gdb)
5867
     -stack-info-depth 12
5868
     ^done,depth="12"
5869
     (gdb)
5870
     -stack-info-depth 11
5871
     ^done,depth="11"
5872
     (gdb)
5873
     -stack-info-depth 13
5874
     ^done,depth="12"
5875
     (gdb)
5876
 
5877
The `-stack-list-arguments' Command
5878
-----------------------------------
5879
 
5880
Synopsis
5881
........
5882
 
5883
      -stack-list-arguments PRINT-VALUES
5884
         [ LOW-FRAME HIGH-FRAME ]
5885
 
5886
   Display a list of the arguments for the frames between LOW-FRAME and
5887
HIGH-FRAME (inclusive).  If LOW-FRAME and HIGH-FRAME are not provided,
5888
list the arguments for the whole call stack.  If the two arguments are
5889
equal, show the single frame at the corresponding level.  It is an
5890
error if LOW-FRAME is larger than the actual number of frames.  On the
5891
other hand, HIGH-FRAME may be larger than the actual number of frames,
5892
in which case only existing frames will be returned.
5893
 
5894
   If PRINT-VALUES is 0 or `--no-values', print only the names of the
5895
variables; if it is 1 or `--all-values', print also their values; and
5896
if it is 2 or `--simple-values', print the name, type and value for
5897
simple data types, and the name and type for arrays, structures and
5898
unions.
5899
 
5900
   Use of this command to obtain arguments in a single frame is
5901
deprecated in favor of the `-stack-list-variables' command.
5902
 
5903
GDB Command
5904
...........
5905
 
5906
GDB does not have an equivalent command.  `gdbtk' has a `gdb_get_args'
5907
command which partially overlaps with the functionality of
5908
`-stack-list-arguments'.
5909
 
5910
Example
5911
.......
5912
 
5913
     (gdb)
5914
     -stack-list-frames
5915
     ^done,
5916
     stack=[
5917
     frame={level="0",addr="0x00010734",func="callee4",
5918
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5919
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"},
5920
     frame={level="1",addr="0x0001076c",func="callee3",
5921
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5922
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"},
5923
     frame={level="2",addr="0x0001078c",func="callee2",
5924
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5925
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"},
5926
     frame={level="3",addr="0x000107b4",func="callee1",
5927
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5928
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"},
5929
     frame={level="4",addr="0x000107e0",func="main",
5930
     file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
5931
     fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"}]
5932
     (gdb)
5933
     -stack-list-arguments 0
5934
     ^done,
5935
     stack-args=[
5936
     frame={level="0",args=[]},
5937
     frame={level="1",args=[name="strarg"]},
5938
     frame={level="2",args=[name="intarg",name="strarg"]},
5939
     frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]},
5940
     frame={level="4",args=[]}]
5941
     (gdb)
5942
     -stack-list-arguments 1
5943
     ^done,
5944
     stack-args=[
5945
     frame={level="0",args=[]},
5946
     frame={level="1",
5947
      args=[{name="strarg",value="0x11940 \"A string argument.\""}]},
5948
     frame={level="2",args=[
5949
     {name="intarg",value="2"},
5950
     {name="strarg",value="0x11940 \"A string argument.\""}]},
5951
     {frame={level="3",args=[
5952
     {name="intarg",value="2"},
5953
     {name="strarg",value="0x11940 \"A string argument.\""},
5954
     {name="fltarg",value="3.5"}]},
5955
     frame={level="4",args=[]}]
5956
     (gdb)
5957
     -stack-list-arguments 0 2 2
5958
     ^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}]
5959
     (gdb)
5960
     -stack-list-arguments 1 2 2
5961
     ^done,stack-args=[frame={level="2",
5962
     args=[{name="intarg",value="2"},
5963
     {name="strarg",value="0x11940 \"A string argument.\""}]}]
5964
     (gdb)
5965
 
5966
The `-stack-list-frames' Command
5967
--------------------------------
5968
 
5969
Synopsis
5970
........
5971
 
5972
      -stack-list-frames [ LOW-FRAME HIGH-FRAME ]
5973
 
5974
   List the frames currently on the stack.  For each frame it displays
5975
the following info:
5976
 
5977
`LEVEL'
5978
     The frame number, 0 being the topmost frame, i.e., the innermost
5979
     function.
5980
 
5981
`ADDR'
5982
     The `$pc' value for that frame.
5983
 
5984
`FUNC'
5985
     Function name.
5986
 
5987
`FILE'
5988
     File name of the source file where the function lives.
5989
 
5990
`LINE'
5991
     Line number corresponding to the `$pc'.
5992
 
5993
   If invoked without arguments, this command prints a backtrace for the
5994
whole stack.  If given two integer arguments, it shows the frames whose
5995
levels are between the two arguments (inclusive).  If the two arguments
5996
are equal, it shows the single frame at the corresponding level.  It is
5997
an error if LOW-FRAME is larger than the actual number of frames.  On
5998
the other hand, HIGH-FRAME may be larger than the actual number of
5999
frames, in which case only existing frames will be returned.
6000
 
6001
GDB Command
6002
...........
6003
 
6004
The corresponding GDB commands are `backtrace' and `where'.
6005
 
6006
Example
6007
.......
6008
 
6009
Full stack backtrace:
6010
 
6011
     (gdb)
6012
     -stack-list-frames
6013
     ^done,stack=
6014
     [frame={level="0",addr="0x0001076c",func="foo",
6015
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11"},
6016
     frame={level="1",addr="0x000107a4",func="foo",
6017
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6018
     frame={level="2",addr="0x000107a4",func="foo",
6019
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6020
     frame={level="3",addr="0x000107a4",func="foo",
6021
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6022
     frame={level="4",addr="0x000107a4",func="foo",
6023
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6024
     frame={level="5",addr="0x000107a4",func="foo",
6025
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6026
     frame={level="6",addr="0x000107a4",func="foo",
6027
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6028
     frame={level="7",addr="0x000107a4",func="foo",
6029
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6030
     frame={level="8",addr="0x000107a4",func="foo",
6031
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6032
     frame={level="9",addr="0x000107a4",func="foo",
6033
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6034
     frame={level="10",addr="0x000107a4",func="foo",
6035
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6036
     frame={level="11",addr="0x00010738",func="main",
6037
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4"}]
6038
     (gdb)
6039
 
6040
   Show frames between LOW_FRAME and HIGH_FRAME:
6041
 
6042
     (gdb)
6043
     -stack-list-frames 3 5
6044
     ^done,stack=
6045
     [frame={level="3",addr="0x000107a4",func="foo",
6046
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6047
     frame={level="4",addr="0x000107a4",func="foo",
6048
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
6049
     frame={level="5",addr="0x000107a4",func="foo",
6050
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
6051
     (gdb)
6052
 
6053
   Show a single frame:
6054
 
6055
     (gdb)
6056
     -stack-list-frames 3 3
6057
     ^done,stack=
6058
     [frame={level="3",addr="0x000107a4",func="foo",
6059
       file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
6060
     (gdb)
6061
 
6062
The `-stack-list-locals' Command
6063
--------------------------------
6064
 
6065
Synopsis
6066
........
6067
 
6068
      -stack-list-locals PRINT-VALUES
6069
 
6070
   Display the local variable names for the selected frame.  If
6071
PRINT-VALUES is 0 or `--no-values', print only the names of the
6072
variables; if it is 1 or `--all-values', print also their values; and
6073
if it is 2 or `--simple-values', print the name, type and value for
6074
simple data types, and the name and type for arrays, structures and
6075
unions.  In this last case, a frontend can immediately display the
6076
value of simple data types and create variable objects for other data
6077
types when the user wishes to explore their values in more detail.
6078
 
6079
   This command is deprecated in favor of the `-stack-list-variables'
6080
command.
6081
 
6082
GDB Command
6083
...........
6084
 
6085
`info locals' in GDB, `gdb_get_locals' in `gdbtk'.
6086
 
6087
Example
6088
.......
6089
 
6090
     (gdb)
6091
     -stack-list-locals 0
6092
     ^done,locals=[name="A",name="B",name="C"]
6093
     (gdb)
6094
     -stack-list-locals --all-values
6095
     ^done,locals=[{name="A",value="1"},{name="B",value="2"},
6096
       {name="C",value="{1, 2, 3}"}]
6097
     -stack-list-locals --simple-values
6098
     ^done,locals=[{name="A",type="int",value="1"},
6099
       {name="B",type="int",value="2"},{name="C",type="int [3]"}]
6100
     (gdb)
6101
 
6102
The `-stack-list-variables' Command
6103
-----------------------------------
6104
 
6105
Synopsis
6106
........
6107
 
6108
      -stack-list-variables PRINT-VALUES
6109
 
6110
   Display the names of local variables and function arguments for the
6111
selected frame.  If PRINT-VALUES is 0 or `--no-values', print only the
6112
names of the variables; if it is 1 or `--all-values', print also their
6113
values; and if it is 2 or `--simple-values', print the name, type and
6114
value for simple data types, and the name and type for arrays,
6115
structures and unions.
6116
 
6117
Example
6118
.......
6119
 
6120
     (gdb)
6121
     -stack-list-variables --thread 1 --frame 0 --all-values
6122
     ^done,variables=[{name="x",value="11"},{name="s",value="{a = 1, b = 2}"}]
6123
     (gdb)
6124
 
6125
The `-stack-select-frame' Command
6126
---------------------------------
6127
 
6128
Synopsis
6129
........
6130
 
6131
      -stack-select-frame FRAMENUM
6132
 
6133
   Change the selected frame.  Select a different frame FRAMENUM on the
6134
stack.
6135
 
6136
   This command in deprecated in favor of passing the `--frame' option
6137
to every command.
6138
 
6139
GDB Command
6140
...........
6141
 
6142
The corresponding GDB commands are `frame', `up', `down',
6143
`select-frame', `up-silent', and `down-silent'.
6144
 
6145
Example
6146
.......
6147
 
6148
     (gdb)
6149
     -stack-select-frame 2
6150
     ^done
6151
     (gdb)
6152
 
6153

6154
File: gdb.info,  Node: GDB/MI Variable Objects,  Next: GDB/MI Data Manipulation,  Prev: GDB/MI Stack Manipulation,  Up: GDB/MI
6155
 
6156
27.13 GDB/MI Variable Objects
6157
=============================
6158
 
6159
Introduction to Variable Objects
6160
--------------------------------
6161
 
6162
Variable objects are "object-oriented" MI interface for examining and
6163
changing values of expressions.  Unlike some other MI interfaces that
6164
work with expressions, variable objects are specifically designed for
6165
simple and efficient presentation in the frontend.  A variable object
6166
is identified by string name.  When a variable object is created, the
6167
frontend specifies the expression for that variable object.  The
6168
expression can be a simple variable, or it can be an arbitrary complex
6169
expression, and can even involve CPU registers.  After creating a
6170
variable object, the frontend can invoke other variable object
6171
operations--for example to obtain or change the value of a variable
6172
object, or to change display format.
6173
 
6174
   Variable objects have hierarchical tree structure.  Any variable
6175
object that corresponds to a composite type, such as structure in C, has
6176
a number of child variable objects, for example corresponding to each
6177
element of a structure.  A child variable object can itself have
6178
children, recursively.  Recursion ends when we reach leaf variable
6179
objects, which always have built-in types.  Child variable objects are
6180
created only by explicit request, so if a frontend is not interested in
6181
the children of a particular variable object, no child will be created.
6182
 
6183
   For a leaf variable object it is possible to obtain its value as a
6184
string, or set the value from a string.  String value can be also
6185
obtained for a non-leaf variable object, but it's generally a string
6186
that only indicates the type of the object, and does not list its
6187
contents.  Assignment to a non-leaf variable object is not allowed.
6188
 
6189
   A frontend does not need to read the values of all variable objects
6190
each time the program stops.  Instead, MI provides an update command
6191
that lists all variable objects whose values has changed since the last
6192
update operation.  This considerably reduces the amount of data that
6193
must be transferred to the frontend.  As noted above, children variable
6194
objects are created on demand, and only leaf variable objects have a
6195
real value.  As result, gdb will read target memory only for leaf
6196
variables that frontend has created.
6197
 
6198
   The automatic update is not always desirable.  For example, a
6199
frontend might want to keep a value of some expression for future
6200
reference, and never update it.  For another example,  fetching memory
6201
is relatively slow for embedded targets, so a frontend might want to
6202
disable automatic update for the variables that are either not visible
6203
on the screen, or "closed".  This is possible using so called "frozen
6204
variable objects".  Such variable objects are never implicitly updated.
6205
 
6206
   Variable objects can be either "fixed" or "floating".  For the fixed
6207
variable object, the expression is parsed when the variable object is
6208
created, including associating identifiers to specific variables.  The
6209
meaning of expression never changes.  For a floating variable object
6210
the values of variables whose names appear in the expressions are
6211
re-evaluated every time in the context of the current frame.  Consider
6212
this example:
6213
 
6214
     void do_work(...)
6215
     {
6216
             struct work_state state;
6217
 
6218
             if (...)
6219
                do_work(...);
6220
     }
6221
 
6222
   If a fixed variable object for the `state' variable is created in
6223
this function, and we enter the recursive call, the the variable object
6224
will report the value of `state' in the top-level `do_work' invocation.
6225
On the other hand, a floating variable object will report the value of
6226
`state' in the current frame.
6227
 
6228
   If an expression specified when creating a fixed variable object
6229
refers to a local variable, the variable object becomes bound to the
6230
thread and frame in which the variable object is created.  When such
6231
variable object is updated, GDB makes sure that the thread/frame
6232
combination the variable object is bound to still exists, and
6233
re-evaluates the variable object in context of that thread/frame.
6234
 
6235
   The following is the complete set of GDB/MI operations defined to
6236
access this functionality:
6237
 
6238
*Operation*                   *Description*
6239
`-enable-pretty-printing'     enable Python-based pretty-printing
6240
`-var-create'                 create a variable object
6241
`-var-delete'                 delete the variable object and/or its
6242
                              children
6243
`-var-set-format'             set the display format of this variable
6244
`-var-show-format'            show the display format of this variable
6245
`-var-info-num-children'      tells how many children this object has
6246
`-var-list-children'          return a list of the object's children
6247
`-var-info-type'              show the type of this variable object
6248
`-var-info-expression'        print parent-relative expression that this
6249
                              variable object represents
6250
`-var-info-path-expression'   print full expression that this variable
6251
                              object represents
6252
`-var-show-attributes'        is this variable editable? does it exist
6253
                              here?
6254
`-var-evaluate-expression'    get the value of this variable
6255
`-var-assign'                 set the value of this variable
6256
`-var-update'                 update the variable and its children
6257
`-var-set-frozen'             set frozeness attribute
6258
`-var-set-update-range'       set range of children to display on update
6259
 
6260
   In the next subsection we describe each operation in detail and
6261
suggest how it can be used.
6262
 
6263
Description And Use of Operations on Variable Objects
6264
-----------------------------------------------------
6265
 
6266
The `-enable-pretty-printing' Command
6267
-------------------------------------
6268
 
6269
     -enable-pretty-printing
6270
 
6271
   GDB allows Python-based visualizers to affect the output of the MI
6272
variable object commands.  However, because there was no way to
6273
implement this in a fully backward-compatible way, a front end must
6274
request that this functionality be enabled.
6275
 
6276
   Once enabled, this feature cannot be disabled.
6277
 
6278
   Note that if Python support has not been compiled into GDB, this
6279
command will still succeed (and do nothing).
6280
 
6281
   This feature is currently (as of GDB 7.0) experimental, and may work
6282
differently in future versions of GDB.
6283
 
6284
The `-var-create' Command
6285
-------------------------
6286
 
6287
Synopsis
6288
........
6289
 
6290
      -var-create {NAME | "-"}
6291
         {FRAME-ADDR | "*" | "@"} EXPRESSION
6292
 
6293
   This operation creates a variable object, which allows the
6294
monitoring of a variable, the result of an expression, a memory cell or
6295
a CPU register.
6296
 
6297
   The NAME parameter is the string by which the object can be
6298
referenced.  It must be unique.  If `-' is specified, the varobj system
6299
will generate a string "varNNNNNN" automatically.  It will be unique
6300
provided that one does not specify NAME of that format.  The command
6301
fails if a duplicate name is found.
6302
 
6303
   The frame under which the expression should be evaluated can be
6304
specified by FRAME-ADDR.  A `*' indicates that the current frame should
6305
be used.  A `@' indicates that a floating variable object must be
6306
created.
6307
 
6308
   EXPRESSION is any expression valid on the current language set (must
6309
not begin with a `*'), or one of the following:
6310
 
6311
   * `*ADDR', where ADDR is the address of a memory cell
6312
 
6313
   * `*ADDR-ADDR' -- a memory address range (TBD)
6314
 
6315
   * `$REGNAME' -- a CPU register name
6316
 
6317
   A varobj's contents may be provided by a Python-based
6318
pretty-printer.  In this case the varobj is known as a "dynamic
6319
varobj".  Dynamic varobjs have slightly different semantics in some
6320
cases.  If the `-enable-pretty-printing' command is not sent, then GDB
6321
will never create a dynamic varobj.  This ensures backward
6322
compatibility for existing clients.
6323
 
6324
Result
6325
......
6326
 
6327
This operation returns attributes of the newly-created varobj.  These
6328
are:
6329
 
6330
`name'
6331
     The name of the varobj.
6332
 
6333
`numchild'
6334
     The number of children of the varobj.  This number is not
6335
     necessarily reliable for a dynamic varobj.  Instead, you must
6336
     examine the `has_more' attribute.
6337
 
6338
`value'
6339
     The varobj's scalar value.  For a varobj whose type is some sort of
6340
     aggregate (e.g., a `struct'), or for a dynamic varobj, this value
6341
     will not be interesting.
6342
 
6343
`type'
6344
     The varobj's type.  This is a string representation of the type, as
6345
     would be printed by the GDB CLI.
6346
 
6347
`thread-id'
6348
     If a variable object is bound to a specific thread, then this is
6349
     the thread's identifier.
6350
 
6351
`has_more'
6352
     For a dynamic varobj, this indicates whether there appear to be any
6353
     children available.  For a non-dynamic varobj, this will be 0.
6354
 
6355
`dynamic'
6356
     This attribute will be present and have the value `1' if the
6357
     varobj is a dynamic varobj.  If the varobj is not a dynamic varobj,
6358
     then this attribute will not be present.
6359
 
6360
`displayhint'
6361
     A dynamic varobj can supply a display hint to the front end.  The
6362
     value comes directly from the Python pretty-printer object's
6363
     `display_hint' method.  *Note Pretty Printing::.
6364
 
6365
   Typical output will look like this:
6366
 
6367
      name="NAME",numchild="N",type="TYPE",thread-id="M",
6368
       has_more="HAS_MORE"
6369
 
6370
The `-var-delete' Command
6371
-------------------------
6372
 
6373
Synopsis
6374
........
6375
 
6376
      -var-delete [ -c ] NAME
6377
 
6378
   Deletes a previously created variable object and all of its children.
6379
With the `-c' option, just deletes the children.
6380
 
6381
   Returns an error if the object NAME is not found.
6382
 
6383
The `-var-set-format' Command
6384
-----------------------------
6385
 
6386
Synopsis
6387
........
6388
 
6389
      -var-set-format NAME FORMAT-SPEC
6390
 
6391
   Sets the output format for the value of the object NAME to be
6392
FORMAT-SPEC.
6393
 
6394
   The syntax for the FORMAT-SPEC is as follows:
6395
 
6396
      FORMAT-SPEC ==>
6397
      {binary | decimal | hexadecimal | octal | natural}
6398
 
6399
   The natural format is the default format choosen automatically based
6400
on the variable type (like decimal for an `int', hex for pointers,
6401
etc.).
6402
 
6403
   For a variable with children, the format is set only on the variable
6404
itself, and the children are not affected.
6405
 
6406
The `-var-show-format' Command
6407
------------------------------
6408
 
6409
Synopsis
6410
........
6411
 
6412
      -var-show-format NAME
6413
 
6414
   Returns the format used to display the value of the object NAME.
6415
 
6416
      FORMAT ==>
6417
      FORMAT-SPEC
6418
 
6419
The `-var-info-num-children' Command
6420
------------------------------------
6421
 
6422
Synopsis
6423
........
6424
 
6425
      -var-info-num-children NAME
6426
 
6427
   Returns the number of children of a variable object NAME:
6428
 
6429
      numchild=N
6430
 
6431
   Note that this number is not completely reliable for a dynamic
6432
varobj.  It will return the current number of children, but more
6433
children may be available.
6434
 
6435
The `-var-list-children' Command
6436
--------------------------------
6437
 
6438
Synopsis
6439
........
6440
 
6441
      -var-list-children [PRINT-VALUES] NAME [FROM TO]
6442
 
6443
   Return a list of the children of the specified variable object and
6444
create variable objects for them, if they do not already exist.  With a
6445
single argument or if PRINT-VALUES has a value for of 0 or
6446
`--no-values', print only the names of the variables; if PRINT-VALUES
6447
is 1 or `--all-values', also print their values; and if it is 2 or
6448
`--simple-values' print the name and value for simple data types and
6449
just the name for arrays, structures and unions.
6450
 
6451
   FROM and TO, if specified, indicate the range of children to report.
6452
If FROM or TO is less than zero, the range is reset and all children
6453
will be reported.  Otherwise, children starting at FROM (zero-based)
6454
and up to and excluding TO will be reported.
6455
 
6456
   If a child range is requested, it will only affect the current call
6457
to `-var-list-children', but not future calls to `-var-update'.  For
6458
this, you must instead use `-var-set-update-range'.  The intent of this
6459
approach is to enable a front end to implement any update approach it
6460
likes; for example, scrolling a view may cause the front end to request
6461
more children with `-var-list-children', and then the front end could
6462
call `-var-set-update-range' with a different range to ensure that
6463
future updates are restricted to just the visible items.
6464
 
6465
   For each child the following results are returned:
6466
 
6467
NAME
6468
     Name of the variable object created for this child.
6469
 
6470
EXP
6471
     The expression to be shown to the user by the front end to
6472
     designate this child.  For example this may be the name of a
6473
     structure member.
6474
 
6475
     For a dynamic varobj, this value cannot be used to form an
6476
     expression.  There is no way to do this at all with a dynamic
6477
     varobj.
6478
 
6479
     For C/C++ structures there are several pseudo children returned to
6480
     designate access qualifiers.  For these pseudo children EXP is
6481
     `public', `private', or `protected'.  In this case the type and
6482
     value are not present.
6483
 
6484
     A dynamic varobj will not report the access qualifying
6485
     pseudo-children, regardless of the language.  This information is
6486
     not available at all with a dynamic varobj.
6487
 
6488
NUMCHILD
6489
     Number of children this child has.  For a dynamic varobj, this
6490
     will be 0.
6491
 
6492
TYPE
6493
     The type of the child.
6494
 
6495
VALUE
6496
     If values were requested, this is the value.
6497
 
6498
THREAD-ID
6499
     If this variable object is associated with a thread, this is the
6500
     thread id.  Otherwise this result is not present.
6501
 
6502
FROZEN
6503
     If the variable object is frozen, this variable will be present
6504
     with a value of 1.
6505
 
6506
   The result may have its own attributes:
6507
 
6508
`displayhint'
6509
     A dynamic varobj can supply a display hint to the front end.  The
6510
     value comes directly from the Python pretty-printer object's
6511
     `display_hint' method.  *Note Pretty Printing::.
6512
 
6513
`has_more'
6514
     This is an integer attribute which is nonzero if there are children
6515
     remaining after the end of the selected range.
6516
 
6517
Example
6518
.......
6519
 
6520
     (gdb)
6521
      -var-list-children n
6522
      ^done,numchild=N,children=[child={name=NAME,exp=EXP,
6523
      numchild=N,type=TYPE},(repeats N times)]
6524
     (gdb)
6525
      -var-list-children --all-values n
6526
      ^done,numchild=N,children=[child={name=NAME,exp=EXP,
6527
      numchild=N,value=VALUE,type=TYPE},(repeats N times)]
6528
 
6529
The `-var-info-type' Command
6530
----------------------------
6531
 
6532
Synopsis
6533
........
6534
 
6535
      -var-info-type NAME
6536
 
6537
   Returns the type of the specified variable NAME.  The type is
6538
returned as a string in the same format as it is output by the GDB CLI:
6539
 
6540
      type=TYPENAME
6541
 
6542
The `-var-info-expression' Command
6543
----------------------------------
6544
 
6545
Synopsis
6546
........
6547
 
6548
      -var-info-expression NAME
6549
 
6550
   Returns a string that is suitable for presenting this variable
6551
object in user interface.  The string is generally not valid expression
6552
in the current language, and cannot be evaluated.
6553
 
6554
   For example, if `a' is an array, and variable object `A' was created
6555
for `a', then we'll get this output:
6556
 
6557
     (gdb) -var-info-expression A.1
6558
     ^done,lang="C",exp="1"
6559
 
6560
Here, the values of `lang' can be `{"C" | "C++" | "Java"}'.
6561
 
6562
   Note that the output of the `-var-list-children' command also
6563
includes those expressions, so the `-var-info-expression' command is of
6564
limited use.
6565
 
6566
The `-var-info-path-expression' Command
6567
---------------------------------------
6568
 
6569
Synopsis
6570
........
6571
 
6572
      -var-info-path-expression NAME
6573
 
6574
   Returns an expression that can be evaluated in the current context
6575
and will yield the same value that a variable object has.  Compare this
6576
with the `-var-info-expression' command, which result can be used only
6577
for UI presentation.  Typical use of the `-var-info-path-expression'
6578
command is creating a watchpoint from a variable object.
6579
 
6580
   This command is currently not valid for children of a dynamic varobj,
6581
and will give an error when invoked on one.
6582
 
6583
   For example, suppose `C' is a C++ class, derived from class `Base',
6584
and that the `Base' class has a member called `m_size'.  Assume a
6585
variable `c' is has the type of `C' and a variable object `C' was
6586
created for variable `c'.  Then, we'll get this output:
6587
     (gdb) -var-info-path-expression C.Base.public.m_size
6588
     ^done,path_expr=((Base)c).m_size)
6589
 
6590
The `-var-show-attributes' Command
6591
----------------------------------
6592
 
6593
Synopsis
6594
........
6595
 
6596
      -var-show-attributes NAME
6597
 
6598
   List attributes of the specified variable object NAME:
6599
 
6600
      status=ATTR [ ( ,ATTR )* ]
6601
 
6602
where ATTR is `{ { editable | noneditable } | TBD }'.
6603
 
6604
The `-var-evaluate-expression' Command
6605
--------------------------------------
6606
 
6607
Synopsis
6608
........
6609
 
6610
      -var-evaluate-expression [-f FORMAT-SPEC] NAME
6611
 
6612
   Evaluates the expression that is represented by the specified
6613
variable object and returns its value as a string.  The format of the
6614
string can be specified with the `-f' option.  The possible values of
6615
this option are the same as for `-var-set-format' (*note
6616
-var-set-format::).  If the `-f' option is not specified, the current
6617
display format will be used.  The current display format can be changed
6618
using the `-var-set-format' command.
6619
 
6620
      value=VALUE
6621
 
6622
   Note that one must invoke `-var-list-children' for a variable before
6623
the value of a child variable can be evaluated.
6624
 
6625
The `-var-assign' Command
6626
-------------------------
6627
 
6628
Synopsis
6629
........
6630
 
6631
      -var-assign NAME EXPRESSION
6632
 
6633
   Assigns the value of EXPRESSION to the variable object specified by
6634
NAME.  The object must be `editable'.  If the variable's value is
6635
altered by the assign, the variable will show up in any subsequent
6636
`-var-update' list.
6637
 
6638
Example
6639
.......
6640
 
6641
     (gdb)
6642
     -var-assign var1 3
6643
     ^done,value="3"
6644
     (gdb)
6645
     -var-update *
6646
     ^done,changelist=[{name="var1",in_scope="true",type_changed="false"}]
6647
     (gdb)
6648
 
6649
The `-var-update' Command
6650
-------------------------
6651
 
6652
Synopsis
6653
........
6654
 
6655
      -var-update [PRINT-VALUES] {NAME | "*"}
6656
 
6657
   Reevaluate the expressions corresponding to the variable object NAME
6658
and all its direct and indirect children, and return the list of
6659
variable objects whose values have changed; NAME must be a root
6660
variable object.  Here, "changed" means that the result of
6661
`-var-evaluate-expression' before and after the `-var-update' is
6662
different.  If `*' is used as the variable object names, all existing
6663
variable objects are updated, except for frozen ones (*note
6664
-var-set-frozen::).  The option PRINT-VALUES determines whether both
6665
names and values, or just names are printed.  The possible values of
6666
this option are the same as for `-var-list-children' (*note
6667
-var-list-children::).  It is recommended to use the `--all-values'
6668
option, to reduce the number of MI commands needed on each program stop.
6669
 
6670
   With the `*' parameter, if a variable object is bound to a currently
6671
running thread, it will not be updated, without any diagnostic.
6672
 
6673
   If `-var-set-update-range' was previously used on a varobj, then
6674
only the selected range of children will be reported.
6675
 
6676
   `-var-update' reports all the changed varobjs in a tuple named
6677
`changelist'.
6678
 
6679
   Each item in the change list is itself a tuple holding:
6680
 
6681
`name'
6682
     The name of the varobj.
6683
 
6684
`value'
6685
     If values were requested for this update, then this field will be
6686
     present and will hold the value of the varobj.
6687
 
6688
`in_scope'
6689
     This field is a string which may take one of three values:
6690
 
6691
    `"true"'
6692
          The variable object's current value is valid.
6693
 
6694
    `"false"'
6695
          The variable object does not currently hold a valid value but
6696
          it may hold one in the future if its associated expression
6697
          comes back into scope.
6698
 
6699
    `"invalid"'
6700
          The variable object no longer holds a valid value.  This can
6701
          occur when the executable file being debugged has changed,
6702
          either through recompilation or by using the GDB `file'
6703
          command.  The front end should normally choose to delete
6704
          these variable objects.
6705
 
6706
     In the future new values may be added to this list so the front
6707
     should be prepared for this possibility.  *Note GDB/MI Development
6708
     and Front Ends: GDB/MI Development and Front Ends.
6709
 
6710
`type_changed'
6711
     This is only present if the varobj is still valid.  If the type
6712
     changed, then this will be the string `true'; otherwise it will be
6713
     `false'.
6714
 
6715
`new_type'
6716
     If the varobj's type changed, then this field will be present and
6717
     will hold the new type.
6718
 
6719
`new_num_children'
6720
     For a dynamic varobj, if the number of children changed, or if the
6721
     type changed, this will be the new number of children.
6722
 
6723
     The `numchild' field in other varobj responses is generally not
6724
     valid for a dynamic varobj - it will show the number of children
6725
     that GDB knows about, but because dynamic varobjs lazily
6726
     instantiate their children, this will not reflect the number of
6727
     children which may be available.
6728
 
6729
     The `new_num_children' attribute only reports changes to the
6730
     number of children known by GDB.  This is the only way to detect
6731
     whether an update has removed children (which necessarily can only
6732
     happen at the end of the update range).
6733
 
6734
`displayhint'
6735
     The display hint, if any.
6736
 
6737
`has_more'
6738
     This is an integer value, which will be 1 if there are more
6739
     children available outside the varobj's update range.
6740
 
6741
`dynamic'
6742
     This attribute will be present and have the value `1' if the
6743
     varobj is a dynamic varobj.  If the varobj is not a dynamic varobj,
6744
     then this attribute will not be present.
6745
 
6746
`new_children'
6747
     If new children were added to a dynamic varobj within the selected
6748
     update range (as set by `-var-set-update-range'), then they will
6749
     be listed in this attribute.
6750
 
6751
Example
6752
.......
6753
 
6754
     (gdb)
6755
     -var-assign var1 3
6756
     ^done,value="3"
6757
     (gdb)
6758
     -var-update --all-values var1
6759
     ^done,changelist=[{name="var1",value="3",in_scope="true",
6760
     type_changed="false"}]
6761
     (gdb)
6762
 
6763
The `-var-set-frozen' Command
6764
-----------------------------
6765
 
6766
Synopsis
6767
........
6768
 
6769
      -var-set-frozen NAME FLAG
6770
 
6771
   Set the frozenness flag on the variable object NAME.  The FLAG
6772
parameter should be either `1' to make the variable frozen or `0' to
6773
make it unfrozen.  If a variable object is frozen, then neither itself,
6774
nor any of its children, are implicitly updated by `-var-update' of a
6775
parent variable or by `-var-update *'.  Only `-var-update' of the
6776
variable itself will update its value and values of its children.
6777
After a variable object is unfrozen, it is implicitly updated by all
6778
subsequent `-var-update' operations.  Unfreezing a variable does not
6779
update it, only subsequent `-var-update' does.
6780
 
6781
Example
6782
.......
6783
 
6784
     (gdb)
6785
     -var-set-frozen V 1
6786
     ^done
6787
     (gdb)
6788
 
6789
The `-var-set-update-range' command
6790
-----------------------------------
6791
 
6792
Synopsis
6793
........
6794
 
6795
      -var-set-update-range NAME FROM TO
6796
 
6797
   Set the range of children to be returned by future invocations of
6798
`-var-update'.
6799
 
6800
   FROM and TO indicate the range of children to report.  If FROM or TO
6801
is less than zero, the range is reset and all children will be
6802
reported.  Otherwise, children starting at FROM (zero-based) and up to
6803
and excluding TO will be reported.
6804
 
6805
Example
6806
.......
6807
 
6808
     (gdb)
6809
     -var-set-update-range V 1 2
6810
     ^done
6811
 
6812
The `-var-set-visualizer' command
6813
---------------------------------
6814
 
6815
Synopsis
6816
........
6817
 
6818
      -var-set-visualizer NAME VISUALIZER
6819
 
6820
   Set a visualizer for the variable object NAME.
6821
 
6822
   VISUALIZER is the visualizer to use.  The special value `None' means
6823
to disable any visualizer in use.
6824
 
6825
   If not `None', VISUALIZER must be a Python expression.  This
6826
expression must evaluate to a callable object which accepts a single
6827
argument.  GDB will call this object with the value of the varobj NAME
6828
as an argument (this is done so that the same Python pretty-printing
6829
code can be used for both the CLI and MI).  When called, this object
6830
must return an object which conforms to the pretty-printing interface
6831
(*note Pretty Printing::).
6832
 
6833
   The pre-defined function `gdb.default_visualizer' may be used to
6834
select a visualizer by following the built-in process (*note Selecting
6835
Pretty-Printers::).  This is done automatically when a varobj is
6836
created, and so ordinarily is not needed.
6837
 
6838
   This feature is only available if Python support is enabled.  The MI
6839
command `-list-features' (*note GDB/MI Miscellaneous Commands::) can be
6840
used to check this.
6841
 
6842
Example
6843
.......
6844
 
6845
Resetting the visualizer:
6846
 
6847
     (gdb)
6848
     -var-set-visualizer V None
6849
     ^done
6850
 
6851
   Reselecting the default (type-based) visualizer:
6852
 
6853
     (gdb)
6854
     -var-set-visualizer V gdb.default_visualizer
6855
     ^done
6856
 
6857
   Suppose `SomeClass' is a visualizer class.  A lambda expression can
6858
be used to instantiate this class for a varobj:
6859
 
6860
     (gdb)
6861
     -var-set-visualizer V "lambda val: SomeClass()"
6862
     ^done
6863
 
6864

6865
File: gdb.info,  Node: GDB/MI Data Manipulation,  Next: GDB/MI Tracepoint Commands,  Prev: GDB/MI Variable Objects,  Up: GDB/MI
6866
 
6867
27.14 GDB/MI Data Manipulation
6868
==============================
6869
 
6870
This section describes the GDB/MI commands that manipulate data:
6871
examine memory and registers, evaluate expressions, etc.
6872
 
6873
The `-data-disassemble' Command
6874
-------------------------------
6875
 
6876
Synopsis
6877
........
6878
 
6879
      -data-disassemble
6880
         [ -s START-ADDR -e END-ADDR ]
6881
       | [ -f FILENAME -l LINENUM [ -n LINES ] ]
6882
       -- MODE
6883
 
6884
Where:
6885
 
6886
`START-ADDR'
6887
     is the beginning address (or `$pc')
6888
 
6889
`END-ADDR'
6890
     is the end address
6891
 
6892
`FILENAME'
6893
     is the name of the file to disassemble
6894
 
6895
`LINENUM'
6896
     is the line number to disassemble around
6897
 
6898
`LINES'
6899
     is the number of disassembly lines to be produced.  If it is -1,
6900
     the whole function will be disassembled, in case no END-ADDR is
6901
     specified.  If END-ADDR is specified as a non-zero value, and
6902
     LINES is lower than the number of disassembly lines between
6903
     START-ADDR and END-ADDR, only LINES lines are displayed; if LINES
6904
     is higher than the number of lines between START-ADDR and
6905
     END-ADDR, only the lines up to END-ADDR are displayed.
6906
 
6907
`MODE'
6908
     is either 0 (meaning only disassembly) or 1 (meaning mixed source
6909
     and disassembly).
6910
 
6911
Result
6912
......
6913
 
6914
The output for each instruction is composed of four fields:
6915
 
6916
   * Address
6917
 
6918
   * Func-name
6919
 
6920
   * Offset
6921
 
6922
   * Instruction
6923
 
6924
   Note that whatever included in the instruction field, is not
6925
manipulated directly by GDB/MI, i.e., it is not possible to adjust its
6926
format.
6927
 
6928
GDB Command
6929
...........
6930
 
6931
There's no direct mapping from this command to the CLI.
6932
 
6933
Example
6934
.......
6935
 
6936
Disassemble from the current value of `$pc' to `$pc + 20':
6937
 
6938
     (gdb)
6939
     -data-disassemble -s $pc -e "$pc + 20" -- 0
6940
     ^done,
6941
     asm_insns=[
6942
     {address="0x000107c0",func-name="main",offset="4",
6943
     inst="mov  2, %o0"},
6944
     {address="0x000107c4",func-name="main",offset="8",
6945
     inst="sethi  %hi(0x11800), %o2"},
6946
     {address="0x000107c8",func-name="main",offset="12",
6947
     inst="or  %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"},
6948
     {address="0x000107cc",func-name="main",offset="16",
6949
     inst="sethi  %hi(0x11800), %o2"},
6950
     {address="0x000107d0",func-name="main",offset="20",
6951
     inst="or  %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"}]
6952
     (gdb)
6953
 
6954
   Disassemble the whole `main' function.  Line 32 is part of `main'.
6955
 
6956
     -data-disassemble -f basics.c -l 32 -- 0
6957
     ^done,asm_insns=[
6958
     {address="0x000107bc",func-name="main",offset="0",
6959
     inst="save  %sp, -112, %sp"},
6960
     {address="0x000107c0",func-name="main",offset="4",
6961
     inst="mov   2, %o0"},
6962
     {address="0x000107c4",func-name="main",offset="8",
6963
     inst="sethi %hi(0x11800), %o2"},
6964
     [...]
6965
     {address="0x0001081c",func-name="main",offset="96",inst="ret "},
6966
     {address="0x00010820",func-name="main",offset="100",inst="restore "}]
6967
     (gdb)
6968
 
6969
   Disassemble 3 instructions from the start of `main':
6970
 
6971
     (gdb)
6972
     -data-disassemble -f basics.c -l 32 -n 3 -- 0
6973
     ^done,asm_insns=[
6974
     {address="0x000107bc",func-name="main",offset="0",
6975
     inst="save  %sp, -112, %sp"},
6976
     {address="0x000107c0",func-name="main",offset="4",
6977
     inst="mov  2, %o0"},
6978
     {address="0x000107c4",func-name="main",offset="8",
6979
     inst="sethi  %hi(0x11800), %o2"}]
6980
     (gdb)
6981
 
6982
   Disassemble 3 instructions from the start of `main' in mixed mode:
6983
 
6984
     (gdb)
6985
     -data-disassemble -f basics.c -l 32 -n 3 -- 1
6986
     ^done,asm_insns=[
6987
     src_and_asm_line={line="31",
6988
     file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
6989
       testsuite/gdb.mi/basics.c",line_asm_insn=[
6990
     {address="0x000107bc",func-name="main",offset="0",
6991
     inst="save  %sp, -112, %sp"}]},
6992
     src_and_asm_line={line="32",
6993
     file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
6994
       testsuite/gdb.mi/basics.c",line_asm_insn=[
6995
     {address="0x000107c0",func-name="main",offset="4",
6996
     inst="mov  2, %o0"},
6997
     {address="0x000107c4",func-name="main",offset="8",
6998
     inst="sethi  %hi(0x11800), %o2"}]}]
6999
     (gdb)
7000
 
7001
The `-data-evaluate-expression' Command
7002
---------------------------------------
7003
 
7004
Synopsis
7005
........
7006
 
7007
      -data-evaluate-expression EXPR
7008
 
7009
   Evaluate EXPR as an expression.  The expression could contain an
7010
inferior function call.  The function call will execute synchronously.
7011
If the expression contains spaces, it must be enclosed in double quotes.
7012
 
7013
GDB Command
7014
...........
7015
 
7016
The corresponding GDB commands are `print', `output', and `call'.  In
7017
`gdbtk' only, there's a corresponding `gdb_eval' command.
7018
 
7019
Example
7020
.......
7021
 
7022
In the following example, the numbers that precede the commands are the
7023
"tokens" described in *Note GDB/MI Command Syntax: GDB/MI Command
7024
Syntax.  Notice how GDB/MI returns the same tokens in its output.
7025
 
7026
     211-data-evaluate-expression A
7027
     211^done,value="1"
7028
     (gdb)
7029
     311-data-evaluate-expression &A
7030
     311^done,value="0xefffeb7c"
7031
     (gdb)
7032
     411-data-evaluate-expression A+3
7033
     411^done,value="4"
7034
     (gdb)
7035
     511-data-evaluate-expression "A + 3"
7036
     511^done,value="4"
7037
     (gdb)
7038
 
7039
The `-data-list-changed-registers' Command
7040
------------------------------------------
7041
 
7042
Synopsis
7043
........
7044
 
7045
      -data-list-changed-registers
7046
 
7047
   Display a list of the registers that have changed.
7048
 
7049
GDB Command
7050
...........
7051
 
7052
GDB doesn't have a direct analog for this command; `gdbtk' has the
7053
corresponding command `gdb_changed_register_list'.
7054
 
7055
Example
7056
.......
7057
 
7058
On a PPC MBX board:
7059
 
7060
     (gdb)
7061
     -exec-continue
7062
     ^running
7063
 
7064
     (gdb)
7065
     *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={
7066
     func="main",args=[],file="try.c",fullname="/home/foo/bar/try.c",
7067
     line="5"}
7068
     (gdb)
7069
     -data-list-changed-registers
7070
     ^done,changed-registers=["0","1","2","4","5","6","7","8","9",
7071
     "10","11","13","14","15","16","17","18","19","20","21","22","23",
7072
     "24","25","26","27","28","30","31","64","65","66","67","69"]
7073
     (gdb)
7074
 
7075
The `-data-list-register-names' Command
7076
---------------------------------------
7077
 
7078
Synopsis
7079
........
7080
 
7081
      -data-list-register-names [ ( REGNO )+ ]
7082
 
7083
   Show a list of register names for the current target.  If no
7084
arguments are given, it shows a list of the names of all the registers.
7085
If integer numbers are given as arguments, it will print a list of the
7086
names of the registers corresponding to the arguments.  To ensure
7087
consistency between a register name and its number, the output list may
7088
include empty register names.
7089
 
7090
GDB Command
7091
...........
7092
 
7093
GDB does not have a command which corresponds to
7094
`-data-list-register-names'.  In `gdbtk' there is a corresponding
7095
command `gdb_regnames'.
7096
 
7097
Example
7098
.......
7099
 
7100
For the PPC MBX board:
7101
     (gdb)
7102
     -data-list-register-names
7103
     ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
7104
     "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
7105
     "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
7106
     "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
7107
     "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
7108
     "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
7109
     "", "pc","ps","cr","lr","ctr","xer"]
7110
     (gdb)
7111
     -data-list-register-names 1 2 3
7112
     ^done,register-names=["r1","r2","r3"]
7113
     (gdb)
7114
 
7115
The `-data-list-register-values' Command
7116
----------------------------------------
7117
 
7118
Synopsis
7119
........
7120
 
7121
      -data-list-register-values FMT [ ( REGNO )*]
7122
 
7123
   Display the registers' contents.  FMT is the format according to
7124
which the registers' contents are to be returned, followed by an
7125
optional list of numbers specifying the registers to display.  A
7126
missing list of numbers indicates that the contents of all the
7127
registers must be returned.
7128
 
7129
   Allowed formats for FMT are:
7130
 
7131
`x'
7132
     Hexadecimal
7133
 
7134
`o'
7135
     Octal
7136
 
7137
`t'
7138
     Binary
7139
 
7140
`d'
7141
     Decimal
7142
 
7143
`r'
7144
     Raw
7145
 
7146
`N'
7147
     Natural
7148
 
7149
GDB Command
7150
...........
7151
 
7152
The corresponding GDB commands are `info reg', `info all-reg', and (in
7153
`gdbtk') `gdb_fetch_registers'.
7154
 
7155
Example
7156
.......
7157
 
7158
For a PPC MBX board (note: line breaks are for readability only, they
7159
don't appear in the actual output):
7160
 
7161
     (gdb)
7162
     -data-list-register-values r 64 65
7163
     ^done,register-values=[{number="64",value="0xfe00a300"},
7164
     {number="65",value="0x00029002"}]
7165
     (gdb)
7166
     -data-list-register-values x
7167
     ^done,register-values=[{number="0",value="0xfe0043c8"},
7168
     {number="1",value="0x3fff88"},{number="2",value="0xfffffffe"},
7169
     {number="3",value="0x0"},{number="4",value="0xa"},
7170
     {number="5",value="0x3fff68"},{number="6",value="0x3fff58"},
7171
     {number="7",value="0xfe011e98"},{number="8",value="0x2"},
7172
     {number="9",value="0xfa202820"},{number="10",value="0xfa202808"},
7173
     {number="11",value="0x1"},{number="12",value="0x0"},
7174
     {number="13",value="0x4544"},{number="14",value="0xffdfffff"},
7175
     {number="15",value="0xffffffff"},{number="16",value="0xfffffeff"},
7176
     {number="17",value="0xefffffed"},{number="18",value="0xfffffffe"},
7177
     {number="19",value="0xffffffff"},{number="20",value="0xffffffff"},
7178
     {number="21",value="0xffffffff"},{number="22",value="0xfffffff7"},
7179
     {number="23",value="0xffffffff"},{number="24",value="0xffffffff"},
7180
     {number="25",value="0xffffffff"},{number="26",value="0xfffffffb"},
7181
     {number="27",value="0xffffffff"},{number="28",value="0xf7bfffff"},
7182
     {number="29",value="0x0"},{number="30",value="0xfe010000"},
7183
     {number="31",value="0x0"},{number="32",value="0x0"},
7184
     {number="33",value="0x0"},{number="34",value="0x0"},
7185
     {number="35",value="0x0"},{number="36",value="0x0"},
7186
     {number="37",value="0x0"},{number="38",value="0x0"},
7187
     {number="39",value="0x0"},{number="40",value="0x0"},
7188
     {number="41",value="0x0"},{number="42",value="0x0"},
7189
     {number="43",value="0x0"},{number="44",value="0x0"},
7190
     {number="45",value="0x0"},{number="46",value="0x0"},
7191
     {number="47",value="0x0"},{number="48",value="0x0"},
7192
     {number="49",value="0x0"},{number="50",value="0x0"},
7193
     {number="51",value="0x0"},{number="52",value="0x0"},
7194
     {number="53",value="0x0"},{number="54",value="0x0"},
7195
     {number="55",value="0x0"},{number="56",value="0x0"},
7196
     {number="57",value="0x0"},{number="58",value="0x0"},
7197
     {number="59",value="0x0"},{number="60",value="0x0"},
7198
     {number="61",value="0x0"},{number="62",value="0x0"},
7199
     {number="63",value="0x0"},{number="64",value="0xfe00a300"},
7200
     {number="65",value="0x29002"},{number="66",value="0x202f04b5"},
7201
     {number="67",value="0xfe0043b0"},{number="68",value="0xfe00b3e4"},
7202
     {number="69",value="0x20002b03"}]
7203
     (gdb)
7204
 
7205
The `-data-read-memory' Command
7206
-------------------------------
7207
 
7208
Synopsis
7209
........
7210
 
7211
      -data-read-memory [ -o BYTE-OFFSET ]
7212
        ADDRESS WORD-FORMAT WORD-SIZE
7213
        NR-ROWS NR-COLS [ ASCHAR ]
7214
 
7215
where:
7216
 
7217
`ADDRESS'
7218
     An expression specifying the address of the first memory word to be
7219
     read.  Complex expressions containing embedded white space should
7220
     be quoted using the C convention.
7221
 
7222
`WORD-FORMAT'
7223
     The format to be used to print the memory words.  The notation is
7224
     the same as for GDB's `print' command (*note Output Formats:
7225
     Output Formats.).
7226
 
7227
`WORD-SIZE'
7228
     The size of each memory word in bytes.
7229
 
7230
`NR-ROWS'
7231
     The number of rows in the output table.
7232
 
7233
`NR-COLS'
7234
     The number of columns in the output table.
7235
 
7236
`ASCHAR'
7237
     If present, indicates that each row should include an ASCII dump.
7238
     The value of ASCHAR is used as a padding character when a byte is
7239
     not a member of the printable ASCII character set (printable ASCII
7240
     characters are those whose code is between 32 and 126,
7241
     inclusively).
7242
 
7243
`BYTE-OFFSET'
7244
     An offset to add to the ADDRESS before fetching memory.
7245
 
7246
   This command displays memory contents as a table of NR-ROWS by
7247
NR-COLS words, each word being WORD-SIZE bytes.  In total, `NR-ROWS *
7248
NR-COLS * WORD-SIZE' bytes are read (returned as `total-bytes').
7249
Should less than the requested number of bytes be returned by the
7250
target, the missing words are identified using `N/A'.  The number of
7251
bytes read from the target is returned in `nr-bytes' and the starting
7252
address used to read memory in `addr'.
7253
 
7254
   The address of the next/previous row or page is available in
7255
`next-row' and `prev-row', `next-page' and `prev-page'.
7256
 
7257
GDB Command
7258
...........
7259
 
7260
The corresponding GDB command is `x'.  `gdbtk' has `gdb_get_mem' memory
7261
read command.
7262
 
7263
Example
7264
.......
7265
 
7266
Read six bytes of memory starting at `bytes+6' but then offset by `-6'
7267
bytes.  Format as three rows of two columns.  One byte per word.
7268
Display each word in hex.
7269
 
7270
     (gdb)
7271
     9-data-read-memory -o -6 -- bytes+6 x 1 3 2
7272
     9^done,addr="0x00001390",nr-bytes="6",total-bytes="6",
7273
     next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396",
7274
     prev-page="0x0000138a",memory=[
7275
     {addr="0x00001390",data=["0x00","0x01"]},
7276
     {addr="0x00001392",data=["0x02","0x03"]},
7277
     {addr="0x00001394",data=["0x04","0x05"]}]
7278
     (gdb)
7279
 
7280
   Read two bytes of memory starting at address `shorts + 64' and
7281
display as a single word formatted in decimal.
7282
 
7283
     (gdb)
7284
     5-data-read-memory shorts+64 d 2 1 1
7285
     5^done,addr="0x00001510",nr-bytes="2",total-bytes="2",
7286
     next-row="0x00001512",prev-row="0x0000150e",
7287
     next-page="0x00001512",prev-page="0x0000150e",memory=[
7288
     {addr="0x00001510",data=["128"]}]
7289
     (gdb)
7290
 
7291
   Read thirty two bytes of memory starting at `bytes+16' and format as
7292
eight rows of four columns.  Include a string encoding with `x' used as
7293
the non-printable character.
7294
 
7295
     (gdb)
7296
     4-data-read-memory bytes+16 x 1 8 4 x
7297
     4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32",
7298
     next-row="0x000013c0",prev-row="0x0000139c",
7299
     next-page="0x000013c0",prev-page="0x00001380",memory=[
7300
     {addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"},
7301
     {addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"},
7302
     {addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"},
7303
     {addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"},
7304
     {addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"},
7305
     {addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"},
7306
     {addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"},
7307
     {addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"}]
7308
     (gdb)
7309
 
7310

7311
File: gdb.info,  Node: GDB/MI Tracepoint Commands,  Next: GDB/MI Symbol Query,  Prev: GDB/MI Data Manipulation,  Up: GDB/MI
7312
 
7313
27.15 GDB/MI Tracepoint Commands
7314
================================
7315
 
7316
The tracepoint commands are not yet implemented.
7317
 
7318

7319
File: gdb.info,  Node: GDB/MI Symbol Query,  Next: GDB/MI File Commands,  Prev: GDB/MI Tracepoint Commands,  Up: GDB/MI
7320
 
7321
27.16 GDB/MI Symbol Query Commands
7322
==================================
7323
 
7324
The `-symbol-list-lines' Command
7325
--------------------------------
7326
 
7327
Synopsis
7328
........
7329
 
7330
      -symbol-list-lines FILENAME
7331
 
7332
   Print the list of lines that contain code and their associated
7333
program addresses for the given source filename.  The entries are
7334
sorted in ascending PC order.
7335
 
7336
GDB Command
7337
...........
7338
 
7339
There is no corresponding GDB command.
7340
 
7341
Example
7342
.......
7343
 
7344
     (gdb)
7345
     -symbol-list-lines basics.c
7346
     ^done,lines=[{pc="0x08048554",line="7"},{pc="0x0804855a",line="8"}]
7347
     (gdb)
7348
 
7349

7350
File: gdb.info,  Node: GDB/MI File Commands,  Next: GDB/MI Target Manipulation,  Prev: GDB/MI Symbol Query,  Up: GDB/MI
7351
 
7352
27.17 GDB/MI File Commands
7353
==========================
7354
 
7355
This section describes the GDB/MI commands to specify executable file
7356
names and to read in and obtain symbol table information.
7357
 
7358
The `-file-exec-and-symbols' Command
7359
------------------------------------
7360
 
7361
Synopsis
7362
........
7363
 
7364
      -file-exec-and-symbols FILE
7365
 
7366
   Specify the executable file to be debugged.  This file is the one
7367
from which the symbol table is also read.  If no file is specified, the
7368
command clears the executable and symbol information.  If breakpoints
7369
are set when using this command with no arguments, GDB will produce
7370
error messages.  Otherwise, no output is produced, except a completion
7371
notification.
7372
 
7373
GDB Command
7374
...........
7375
 
7376
The corresponding GDB command is `file'.
7377
 
7378
Example
7379
.......
7380
 
7381
     (gdb)
7382
     -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
7383
     ^done
7384
     (gdb)
7385
 
7386
The `-file-exec-file' Command
7387
-----------------------------
7388
 
7389
Synopsis
7390
........
7391
 
7392
      -file-exec-file FILE
7393
 
7394
   Specify the executable file to be debugged.  Unlike
7395
`-file-exec-and-symbols', the symbol table is _not_ read from this
7396
file.  If used without argument, GDB clears the information about the
7397
executable file.  No output is produced, except a completion
7398
notification.
7399
 
7400
GDB Command
7401
...........
7402
 
7403
The corresponding GDB command is `exec-file'.
7404
 
7405
Example
7406
.......
7407
 
7408
     (gdb)
7409
     -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
7410
     ^done
7411
     (gdb)
7412
 
7413
The `-file-list-exec-source-file' Command
7414
-----------------------------------------
7415
 
7416
Synopsis
7417
........
7418
 
7419
      -file-list-exec-source-file
7420
 
7421
   List the line number, the current source file, and the absolute path
7422
to the current source file for the current executable.  The macro
7423
information field has a value of `1' or `0' depending on whether or not
7424
the file includes preprocessor macro information.
7425
 
7426
GDB Command
7427
...........
7428
 
7429
The GDB equivalent is `info source'
7430
 
7431
Example
7432
.......
7433
 
7434
     (gdb)
7435
     123-file-list-exec-source-file
7436
     123^done,line="1",file="foo.c",fullname="/home/bar/foo.c,macro-info="1"
7437
     (gdb)
7438
 
7439
The `-file-list-exec-source-files' Command
7440
------------------------------------------
7441
 
7442
Synopsis
7443
........
7444
 
7445
      -file-list-exec-source-files
7446
 
7447
   List the source files for the current executable.
7448
 
7449
   It will always output the filename, but only when GDB can find the
7450
absolute file name of a source file, will it output the fullname.
7451
 
7452
GDB Command
7453
...........
7454
 
7455
The GDB equivalent is `info sources'.  `gdbtk' has an analogous command
7456
`gdb_listfiles'.
7457
 
7458
Example
7459
.......
7460
 
7461
     (gdb)
7462
     -file-list-exec-source-files
7463
     ^done,files=[
7464
     {file=foo.c,fullname=/home/foo.c},
7465
     {file=/home/bar.c,fullname=/home/bar.c},
7466
     {file=gdb_could_not_find_fullpath.c}]
7467
     (gdb)
7468
 
7469
The `-file-symbol-file' Command
7470
-------------------------------
7471
 
7472
Synopsis
7473
........
7474
 
7475
      -file-symbol-file FILE
7476
 
7477
   Read symbol table info from the specified FILE argument.  When used
7478
without arguments, clears GDB's symbol table info.  No output is
7479
produced, except for a completion notification.
7480
 
7481
GDB Command
7482
...........
7483
 
7484
The corresponding GDB command is `symbol-file'.
7485
 
7486
Example
7487
.......
7488
 
7489
     (gdb)
7490
     -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
7491
     ^done
7492
     (gdb)
7493
 
7494

7495
File: gdb.info,  Node: GDB/MI Target Manipulation,  Next: GDB/MI File Transfer Commands,  Prev: GDB/MI File Commands,  Up: GDB/MI
7496
 
7497
27.18 GDB/MI Target Manipulation Commands
7498
=========================================
7499
 
7500
The `-target-attach' Command
7501
----------------------------
7502
 
7503
Synopsis
7504
........
7505
 
7506
      -target-attach PID | GID | FILE
7507
 
7508
   Attach to a process PID or a file FILE outside of GDB, or a thread
7509
group GID.  If attaching to a thread group, the id previously returned
7510
by `-list-thread-groups --available' must be used.
7511
 
7512
GDB Command
7513
...........
7514
 
7515
The corresponding GDB command is `attach'.
7516
 
7517
Example
7518
.......
7519
 
7520
     (gdb)
7521
     -target-attach 34
7522
     =thread-created,id="1"
7523
     *stopped,thread-id="1",frame={addr="0xb7f7e410",func="bar",args=[]}
7524
     ^done
7525
     (gdb)
7526
 
7527
The `-target-detach' Command
7528
----------------------------
7529
 
7530
Synopsis
7531
........
7532
 
7533
      -target-detach [ PID | GID ]
7534
 
7535
   Detach from the remote target which normally resumes its execution.
7536
If either PID or GID is specified, detaches from either the specified
7537
process, or specified thread group.  There's no output.
7538
 
7539
GDB Command
7540
...........
7541
 
7542
The corresponding GDB command is `detach'.
7543
 
7544
Example
7545
.......
7546
 
7547
     (gdb)
7548
     -target-detach
7549
     ^done
7550
     (gdb)
7551
 
7552
The `-target-disconnect' Command
7553
--------------------------------
7554
 
7555
Synopsis
7556
........
7557
 
7558
      -target-disconnect
7559
 
7560
   Disconnect from the remote target.  There's no output and the target
7561
is generally not resumed.
7562
 
7563
GDB Command
7564
...........
7565
 
7566
The corresponding GDB command is `disconnect'.
7567
 
7568
Example
7569
.......
7570
 
7571
     (gdb)
7572
     -target-disconnect
7573
     ^done
7574
     (gdb)
7575
 
7576
The `-target-download' Command
7577
------------------------------
7578
 
7579
Synopsis
7580
........
7581
 
7582
      -target-download
7583
 
7584
   Loads the executable onto the remote target.  It prints out an
7585
update message every half second, which includes the fields:
7586
 
7587
`section'
7588
     The name of the section.
7589
 
7590
`section-sent'
7591
     The size of what has been sent so far for that section.
7592
 
7593
`section-size'
7594
     The size of the section.
7595
 
7596
`total-sent'
7597
     The total size of what was sent so far (the current and the
7598
     previous sections).
7599
 
7600
`total-size'
7601
     The size of the overall executable to download.
7602
 
7603
Each message is sent as status record (*note GDB/MI Output Syntax:
7604
GDB/MI Output Syntax.).
7605
 
7606
   In addition, it prints the name and size of the sections, as they are
7607
downloaded.  These messages include the following fields:
7608
 
7609
`section'
7610
     The name of the section.
7611
 
7612
`section-size'
7613
     The size of the section.
7614
 
7615
`total-size'
7616
     The size of the overall executable to download.
7617
 
7618
At the end, a summary is printed.
7619
 
7620
GDB Command
7621
...........
7622
 
7623
The corresponding GDB command is `load'.
7624
 
7625
Example
7626
.......
7627
 
7628
Note: each status message appears on a single line.  Here the messages
7629
have been broken down so that they can fit onto a page.
7630
 
7631
     (gdb)
7632
     -target-download
7633
     +download,{section=".text",section-size="6668",total-size="9880"}
7634
     +download,{section=".text",section-sent="512",section-size="6668",
7635
     total-sent="512",total-size="9880"}
7636
     +download,{section=".text",section-sent="1024",section-size="6668",
7637
     total-sent="1024",total-size="9880"}
7638
     +download,{section=".text",section-sent="1536",section-size="6668",
7639
     total-sent="1536",total-size="9880"}
7640
     +download,{section=".text",section-sent="2048",section-size="6668",
7641
     total-sent="2048",total-size="9880"}
7642
     +download,{section=".text",section-sent="2560",section-size="6668",
7643
     total-sent="2560",total-size="9880"}
7644
     +download,{section=".text",section-sent="3072",section-size="6668",
7645
     total-sent="3072",total-size="9880"}
7646
     +download,{section=".text",section-sent="3584",section-size="6668",
7647
     total-sent="3584",total-size="9880"}
7648
     +download,{section=".text",section-sent="4096",section-size="6668",
7649
     total-sent="4096",total-size="9880"}
7650
     +download,{section=".text",section-sent="4608",section-size="6668",
7651
     total-sent="4608",total-size="9880"}
7652
     +download,{section=".text",section-sent="5120",section-size="6668",
7653
     total-sent="5120",total-size="9880"}
7654
     +download,{section=".text",section-sent="5632",section-size="6668",
7655
     total-sent="5632",total-size="9880"}
7656
     +download,{section=".text",section-sent="6144",section-size="6668",
7657
     total-sent="6144",total-size="9880"}
7658
     +download,{section=".text",section-sent="6656",section-size="6668",
7659
     total-sent="6656",total-size="9880"}
7660
     +download,{section=".init",section-size="28",total-size="9880"}
7661
     +download,{section=".fini",section-size="28",total-size="9880"}
7662
     +download,{section=".data",section-size="3156",total-size="9880"}
7663
     +download,{section=".data",section-sent="512",section-size="3156",
7664
     total-sent="7236",total-size="9880"}
7665
     +download,{section=".data",section-sent="1024",section-size="3156",
7666
     total-sent="7748",total-size="9880"}
7667
     +download,{section=".data",section-sent="1536",section-size="3156",
7668
     total-sent="8260",total-size="9880"}
7669
     +download,{section=".data",section-sent="2048",section-size="3156",
7670
     total-sent="8772",total-size="9880"}
7671
     +download,{section=".data",section-sent="2560",section-size="3156",
7672
     total-sent="9284",total-size="9880"}
7673
     +download,{section=".data",section-sent="3072",section-size="3156",
7674
     total-sent="9796",total-size="9880"}
7675
     ^done,address="0x10004",load-size="9880",transfer-rate="6586",
7676
     write-rate="429"
7677
     (gdb)
7678
 
7679
GDB Command
7680
...........
7681
 
7682
No equivalent.
7683
 
7684
Example
7685
.......
7686
 
7687
N.A.
7688
 
7689
The `-target-select' Command
7690
----------------------------
7691
 
7692
Synopsis
7693
........
7694
 
7695
      -target-select TYPE PARAMETERS ...
7696
 
7697
   Connect GDB to the remote target.  This command takes two args:
7698
 
7699
`TYPE'
7700
     The type of target, for instance `remote', etc.
7701
 
7702
`PARAMETERS'
7703
     Device names, host names and the like.  *Note Commands for
7704
     Managing Targets: Target Commands, for more details.
7705
 
7706
   The output is a connection notification, followed by the address at
7707
which the target program is, in the following form:
7708
 
7709
     ^connected,addr="ADDRESS",func="FUNCTION NAME",
7710
       args=[ARG LIST]
7711
 
7712
GDB Command
7713
...........
7714
 
7715
The corresponding GDB command is `target'.
7716
 
7717
Example
7718
.......
7719
 
7720
     (gdb)
7721
     -target-select remote /dev/ttya
7722
     ^connected,addr="0xfe00a300",func="??",args=[]
7723
     (gdb)
7724
 
7725

7726
File: gdb.info,  Node: GDB/MI File Transfer Commands,  Next: GDB/MI Miscellaneous Commands,  Prev: GDB/MI Target Manipulation,  Up: GDB/MI
7727
 
7728
27.19 GDB/MI File Transfer Commands
7729
===================================
7730
 
7731
The `-target-file-put' Command
7732
------------------------------
7733
 
7734
Synopsis
7735
........
7736
 
7737
      -target-file-put HOSTFILE TARGETFILE
7738
 
7739
   Copy file HOSTFILE from the host system (the machine running GDB) to
7740
TARGETFILE on the target system.
7741
 
7742
GDB Command
7743
...........
7744
 
7745
The corresponding GDB command is `remote put'.
7746
 
7747
Example
7748
.......
7749
 
7750
     (gdb)
7751
     -target-file-put localfile remotefile
7752
     ^done
7753
     (gdb)
7754
 
7755
The `-target-file-get' Command
7756
------------------------------
7757
 
7758
Synopsis
7759
........
7760
 
7761
      -target-file-get TARGETFILE HOSTFILE
7762
 
7763
   Copy file TARGETFILE from the target system to HOSTFILE on the host
7764
system.
7765
 
7766
GDB Command
7767
...........
7768
 
7769
The corresponding GDB command is `remote get'.
7770
 
7771
Example
7772
.......
7773
 
7774
     (gdb)
7775
     -target-file-get remotefile localfile
7776
     ^done
7777
     (gdb)
7778
 
7779
The `-target-file-delete' Command
7780
---------------------------------
7781
 
7782
Synopsis
7783
........
7784
 
7785
      -target-file-delete TARGETFILE
7786
 
7787
   Delete TARGETFILE from the target system.
7788
 
7789
GDB Command
7790
...........
7791
 
7792
The corresponding GDB command is `remote delete'.
7793
 
7794
Example
7795
.......
7796
 
7797
     (gdb)
7798
     -target-file-delete remotefile
7799
     ^done
7800
     (gdb)
7801
 
7802

7803
File: gdb.info,  Node: GDB/MI Miscellaneous Commands,  Prev: GDB/MI File Transfer Commands,  Up: GDB/MI
7804
 
7805
27.20 Miscellaneous GDB/MI Commands
7806
===================================
7807
 
7808
The `-gdb-exit' Command
7809
-----------------------
7810
 
7811
Synopsis
7812
........
7813
 
7814
      -gdb-exit
7815
 
7816
   Exit GDB immediately.
7817
 
7818
GDB Command
7819
...........
7820
 
7821
Approximately corresponds to `quit'.
7822
 
7823
Example
7824
.......
7825
 
7826
     (gdb)
7827
     -gdb-exit
7828
     ^exit
7829
 
7830
The `-gdb-set' Command
7831
----------------------
7832
 
7833
Synopsis
7834
........
7835
 
7836
      -gdb-set
7837
 
7838
   Set an internal GDB variable.
7839
 
7840
GDB Command
7841
...........
7842
 
7843
The corresponding GDB command is `set'.
7844
 
7845
Example
7846
.......
7847
 
7848
     (gdb)
7849
     -gdb-set $foo=3
7850
     ^done
7851
     (gdb)
7852
 
7853
The `-gdb-show' Command
7854
-----------------------
7855
 
7856
Synopsis
7857
........
7858
 
7859
      -gdb-show
7860
 
7861
   Show the current value of a GDB variable.
7862
 
7863
GDB Command
7864
...........
7865
 
7866
The corresponding GDB command is `show'.
7867
 
7868
Example
7869
.......
7870
 
7871
     (gdb)
7872
     -gdb-show annotate
7873
     ^done,value="0"
7874
     (gdb)
7875
 
7876
The `-gdb-version' Command
7877
--------------------------
7878
 
7879
Synopsis
7880
........
7881
 
7882
      -gdb-version
7883
 
7884
   Show version information for GDB.  Used mostly in testing.
7885
 
7886
GDB Command
7887
...........
7888
 
7889
The GDB equivalent is `show version'.  GDB by default shows this
7890
information when you start an interactive session.
7891
 
7892
Example
7893
.......
7894
 
7895
     (gdb)
7896
     -gdb-version
7897
     ~GNU gdb 5.2.1
7898
     ~Copyright 2000 Free Software Foundation, Inc.
7899
     ~GDB is free software, covered by the GNU General Public License, and
7900
     ~you are welcome to change it and/or distribute copies of it under
7901
     ~ certain conditions.
7902
     ~Type "show copying" to see the conditions.
7903
     ~There is absolutely no warranty for GDB.  Type "show warranty" for
7904
     ~ details.
7905
     ~This GDB was configured as
7906
      "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi".
7907
     ^done
7908
     (gdb)
7909
 
7910
The `-list-features' Command
7911
----------------------------
7912
 
7913
Returns a list of particular features of the MI protocol that this
7914
version of gdb implements.  A feature can be a command, or a new field
7915
in an output of some command, or even an important bugfix.  While a
7916
frontend can sometimes detect presence of a feature at runtime, it is
7917
easier to perform detection at debugger startup.
7918
 
7919
   The command returns a list of strings, with each string naming an
7920
available feature.  Each returned string is just a name, it does not
7921
have any internal structure.  The list of possible feature names is
7922
given below.
7923
 
7924
   Example output:
7925
 
7926
     (gdb) -list-features
7927
     ^done,result=["feature1","feature2"]
7928
 
7929
   The current list of features is:
7930
 
7931
`frozen-varobjs'
7932
     Indicates presence of the `-var-set-frozen' command, as well as
7933
     possible presense of the `frozen' field in the output of
7934
     `-varobj-create'.
7935
 
7936
`pending-breakpoints'
7937
     Indicates presence of the `-f' option to the `-break-insert'
7938
     command.
7939
 
7940
`python'
7941
     Indicates presence of Python scripting support, Python-based
7942
     pretty-printing commands, and possible presence of the
7943
     `display_hint' field in the output of `-var-list-children'
7944
 
7945
`thread-info'
7946
     Indicates presence of the `-thread-info' command.
7947
 
7948
 
7949
The `-list-target-features' Command
7950
-----------------------------------
7951
 
7952
Returns a list of particular features that are supported by the target.
7953
Those features affect the permitted MI commands, but unlike the
7954
features reported by the `-list-features' command, the features depend
7955
on which target GDB is using at the moment.  Whenever a target can
7956
change, due to commands such as `-target-select', `-target-attach' or
7957
`-exec-run', the list of target features may change, and the frontend
7958
should obtain it again.  Example output:
7959
 
7960
     (gdb) -list-features
7961
     ^done,result=["async"]
7962
 
7963
   The current list of features is:
7964
 
7965
`async'
7966
     Indicates that the target is capable of asynchronous command
7967
     execution, which means that GDB will accept further commands while
7968
     the target is running.
7969
 
7970
 
7971
The `-list-thread-groups' Command
7972
---------------------------------
7973
 
7974
Synopsis
7975
--------
7976
 
7977
     -list-thread-groups [ --available ] [ --recurse 1 ] [ GROUP ... ]
7978
 
7979
   Lists thread groups (*note Thread groups::).  When a single thread
7980
group is passed as the argument, lists the children of that group.
7981
When several thread group are passed, lists information about those
7982
thread groups.  Without any parameters, lists information about all
7983
top-level thread groups.
7984
 
7985
   Normally, thread groups that are being debugged are reported.  With
7986
the `--available' option, GDB reports thread groups available on the
7987
target.
7988
 
7989
   The output of this command may have either a `threads' result or a
7990
`groups' result.  The `thread' result has a list of tuples as value,
7991
with each tuple describing a thread (*note GDB/MI Thread
7992
Information::).  The `groups' result has a list of tuples as value,
7993
each tuple describing a thread group.  If top-level groups are
7994
requested (that is, no parameter is passed), or when several groups are
7995
passed, the output always has a `groups' result.  The format of the
7996
`group' result is described below.
7997
 
7998
   To reduce the number of roundtrips it's possible to list thread
7999
groups together with their children, by passing the `--recurse' option
8000
and the recursion depth.  Presently, only recursion depth of 1 is
8001
permitted.  If this option is present, then every reported thread group
8002
will also include its children, either as `group' or `threads' field.
8003
 
8004
   In general, any combination of option and parameters is permitted,
8005
with the following caveats:
8006
 
8007
   * When a single thread group is passed, the output will typically be
8008
     the `threads' result.  Because threads may not contain anything,
8009
     the `recurse' option will be ignored.
8010
 
8011
   * When the `--available' option is passed, limited information may
8012
     be available.  In particular, the list of threads of a process
8013
     might be inaccessible.  Further, specifying specific thread groups
8014
     might not give any performance advantage over listing all thread
8015
     groups.  The frontend should assume that `-list-thread-groups
8016
     --available' is always an expensive operation and cache the
8017
     results.
8018
 
8019
 
8020
   The `groups' result is a list of tuples, where each tuple may have
8021
the following fields:
8022
 
8023
`id'
8024
     Identifier of the thread group.  This field is always present.
8025
 
8026
`type'
8027
     The type of the thread group.  At present, only `process' is a
8028
     valid type.
8029
 
8030
`pid'
8031
     The target-specific process identifier.  This field is only present
8032
     for thread groups of type `process'.
8033
 
8034
`num_children'
8035
     The number of children this thread group has.  This field may be
8036
     absent for an available thread group.
8037
 
8038
`threads'
8039
     This field has a list of tuples as value, each tuple describing a
8040
     thread.  It may be present if the `--recurse' option is specified,
8041
     and it's actually possible to obtain the threads.
8042
 
8043
`cores'
8044
     This field is a list of integers, each identifying a core that one
8045
     thread of the group is running on.  This field may be absent if
8046
     such information is not available.
8047
 
8048
 
8049
Example
8050
-------
8051
 
8052
     gdb
8053
     -list-thread-groups
8054
     ^done,groups=[{id="17",type="process",pid="yyy",num_children="2"}]
8055
     -list-thread-groups 17
8056
     ^done,threads=[{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
8057
        frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]},state="running"},
8058
     {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
8059
        frame={level="0",addr="0x0804891f",func="foo",args=[{name="i",value="10"}],
8060
                file="/tmp/a.c",fullname="/tmp/a.c",line="158"},state="running"}]]
8061
     -list-thread-groups --available
8062
     ^done,groups=[{id="17",type="process",pid="yyy",num_children="2",cores=[1,2]}]
8063
     -list-thread-groups --available --recurse 1
8064
      ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
8065
                     threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]},
8066
                              {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},..]
8067
     -list-thread-groups --available --recurse 1 17 18
8068
     ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
8069
                    threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]},
8070
                             {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},...]
8071
 
8072
The `-interpreter-exec' Command
8073
-------------------------------
8074
 
8075
Synopsis
8076
--------
8077
 
8078
     -interpreter-exec INTERPRETER COMMAND
8079
 
8080
   Execute the specified COMMAND in the given INTERPRETER.
8081
 
8082
GDB Command
8083
-----------
8084
 
8085
The corresponding GDB command is `interpreter-exec'.
8086
 
8087
Example
8088
-------
8089
 
8090
     (gdb)
8091
     -interpreter-exec console "break main"
8092
     &"During symbol reading, couldn't parse type; debugger out of date?.\n"
8093
     &"During symbol reading, bad structure-type format.\n"
8094
     ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
8095
     ^done
8096
     (gdb)
8097
 
8098
The `-inferior-tty-set' Command
8099
-------------------------------
8100
 
8101
Synopsis
8102
--------
8103
 
8104
     -inferior-tty-set /dev/pts/1
8105
 
8106
   Set terminal for future runs of the program being debugged.
8107
 
8108
GDB Command
8109
-----------
8110
 
8111
The corresponding GDB command is `set inferior-tty' /dev/pts/1.
8112
 
8113
Example
8114
-------
8115
 
8116
     (gdb)
8117
     -inferior-tty-set /dev/pts/1
8118
     ^done
8119
     (gdb)
8120
 
8121
The `-inferior-tty-show' Command
8122
--------------------------------
8123
 
8124
Synopsis
8125
--------
8126
 
8127
     -inferior-tty-show
8128
 
8129
   Show terminal for future runs of program being debugged.
8130
 
8131
GDB Command
8132
-----------
8133
 
8134
The corresponding GDB command is `show inferior-tty'.
8135
 
8136
Example
8137
-------
8138
 
8139
     (gdb)
8140
     -inferior-tty-set /dev/pts/1
8141
     ^done
8142
     (gdb)
8143
     -inferior-tty-show
8144
     ^done,inferior_tty_terminal="/dev/pts/1"
8145
     (gdb)
8146
 
8147
The `-enable-timings' Command
8148
-----------------------------
8149
 
8150
Synopsis
8151
--------
8152
 
8153
     -enable-timings [yes | no]
8154
 
8155
   Toggle the printing of the wallclock, user and system times for an MI
8156
command as a field in its output.  This command is to help frontend
8157
developers optimize the performance of their code.  No argument is
8158
equivalent to `yes'.
8159
 
8160
GDB Command
8161
-----------
8162
 
8163
No equivalent.
8164
 
8165
Example
8166
-------
8167
 
8168
     (gdb)
8169
     -enable-timings
8170
     ^done
8171
     (gdb)
8172
     -break-insert main
8173
     ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
8174
     addr="0x080484ed",func="main",file="myprog.c",
8175
     fullname="/home/nickrob/myprog.c",line="73",times="0"},
8176
     time={wallclock="0.05185",user="0.00800",system="0.00000"}
8177
     (gdb)
8178
     -enable-timings no
8179
     ^done
8180
     (gdb)
8181
     -exec-run
8182
     ^running
8183
     (gdb)
8184
     *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
8185
     frame={addr="0x080484ed",func="main",args=[{name="argc",value="1"},
8186
     {name="argv",value="0xbfb60364"}],file="myprog.c",
8187
     fullname="/home/nickrob/myprog.c",line="73"}
8188
     (gdb)
8189
 
8190

8191
File: gdb.info,  Node: Annotations,  Next: JIT Interface,  Prev: GDB/MI,  Up: Top
8192
 
8193
28 GDB Annotations
8194
******************
8195
 
8196
This chapter describes annotations in GDB.  Annotations were designed
8197
to interface GDB to graphical user interfaces or other similar programs
8198
which want to interact with GDB at a relatively high level.
8199
 
8200
   The annotation mechanism has largely been superseded by GDB/MI
8201
(*note GDB/MI::).
8202
 
8203
* Menu:
8204
 
8205
* Annotations Overview::  What annotations are; the general syntax.
8206
* Server Prefix::       Issuing a command without affecting user state.
8207
* Prompting::           Annotations marking GDB's need for input.
8208
* Errors::              Annotations for error messages.
8209
* Invalidation::        Some annotations describe things now invalid.
8210
* Annotations for Running::
8211
                        Whether the program is running, how it stopped, etc.
8212
* Source Annotations::  Annotations describing source code.
8213
 
8214

8215
File: gdb.info,  Node: Annotations Overview,  Next: Server Prefix,  Up: Annotations
8216
 
8217
28.1 What is an Annotation?
8218
===========================
8219
 
8220
Annotations start with a newline character, two `control-z' characters,
8221
and the name of the annotation.  If there is no additional information
8222
associated with this annotation, the name of the annotation is followed
8223
immediately by a newline.  If there is additional information, the name
8224
of the annotation is followed by a space, the additional information,
8225
and a newline.  The additional information cannot contain newline
8226
characters.
8227
 
8228
   Any output not beginning with a newline and two `control-z'
8229
characters denotes literal output from GDB.  Currently there is no need
8230
for GDB to output a newline followed by two `control-z' characters, but
8231
if there was such a need, the annotations could be extended with an
8232
`escape' annotation which means those three characters as output.
8233
 
8234
   The annotation LEVEL, which is specified using the `--annotate'
8235
command line option (*note Mode Options::), controls how much
8236
information GDB prints together with its prompt, values of expressions,
8237
source lines, and other types of output.  Level 0 is for no
8238
annotations, level 1 is for use when GDB is run as a subprocess of GNU
8239
Emacs, level 3 is the maximum annotation suitable for programs that
8240
control GDB, and level 2 annotations have been made obsolete (*note
8241
Limitations of the Annotation Interface: (annotate)Limitations.).
8242
 
8243
`set annotate LEVEL'
8244
     The GDB command `set annotate' sets the level of annotations to
8245
     the specified LEVEL.
8246
 
8247
`show annotate'
8248
     Show the current annotation level.
8249
 
8250
   This chapter describes level 3 annotations.
8251
 
8252
   A simple example of starting up GDB with annotations is:
8253
 
8254
     $ gdb --annotate=3
8255
     GNU gdb 6.0
8256
     Copyright 2003 Free Software Foundation, Inc.
8257
     GDB is free software, covered by the GNU General Public License,
8258
     and you are welcome to change it and/or distribute copies of it
8259
     under certain conditions.
8260
     Type "show copying" to see the conditions.
8261
     There is absolutely no warranty for GDB.  Type "show warranty"
8262
     for details.
8263
     This GDB was configured as "i386-pc-linux-gnu"
8264
 
8265
     ^Z^Zpre-prompt
8266
     (gdb)
8267
     ^Z^Zprompt
8268
     quit
8269
 
8270
     ^Z^Zpost-prompt
8271
     $
8272
 
8273
   Here `quit' is input to GDB; the rest is output from GDB.  The three
8274
lines beginning `^Z^Z' (where `^Z' denotes a `control-z' character) are
8275
annotations; the rest is output from GDB.
8276
 
8277

8278
File: gdb.info,  Node: Server Prefix,  Next: Prompting,  Prev: Annotations Overview,  Up: Annotations
8279
 
8280
28.2 The Server Prefix
8281
======================
8282
 
8283
If you prefix a command with `server ' then it will not affect the
8284
command history, nor will it affect GDB's notion of which command to
8285
repeat if  is pressed on a line by itself.  This means that
8286
commands can be run behind a user's back by a front-end in a
8287
transparent manner.
8288
 
8289
   The `server ' prefix does not affect the recording of values into
8290
the value history; to print a value without recording it into the value
8291
history, use the `output' command instead of the `print' command.
8292
 
8293
   Using this prefix also disables confirmation requests (*note
8294
confirmation requests::).
8295
 
8296

8297
File: gdb.info,  Node: Prompting,  Next: Errors,  Prev: Server Prefix,  Up: Annotations
8298
 
8299
28.3 Annotation for GDB Input
8300
=============================
8301
 
8302
When GDB prompts for input, it annotates this fact so it is possible to
8303
know when to send output, when the output from a given command is over,
8304
etc.
8305
 
8306
   Different kinds of input each have a different "input type".  Each
8307
input type has three annotations: a `pre-' annotation, which denotes
8308
the beginning of any prompt which is being output, a plain annotation,
8309
which denotes the end of the prompt, and then a `post-' annotation
8310
which denotes the end of any echo which may (or may not) be associated
8311
with the input.  For example, the `prompt' input type features the
8312
following annotations:
8313
 
8314
     ^Z^Zpre-prompt
8315
     ^Z^Zprompt
8316
     ^Z^Zpost-prompt
8317
 
8318
   The input types are
8319
 
8320
`prompt'
8321
     When GDB is prompting for a command (the main GDB prompt).
8322
 
8323
`commands'
8324
     When GDB prompts for a set of commands, like in the `commands'
8325
     command.  The annotations are repeated for each command which is
8326
     input.
8327
 
8328
`overload-choice'
8329
     When GDB wants the user to select between various overloaded
8330
     functions.
8331
 
8332
`query'
8333
     When GDB wants the user to confirm a potentially dangerous
8334
     operation.
8335
 
8336
`prompt-for-continue'
8337
     When GDB is asking the user to press return to continue.  Note:
8338
     Don't expect this to work well; instead use `set height 0' to
8339
     disable prompting.  This is because the counting of lines is buggy
8340
     in the presence of annotations.
8341
 
8342

8343
File: gdb.info,  Node: Errors,  Next: Invalidation,  Prev: Prompting,  Up: Annotations
8344
 
8345
28.4 Errors
8346
===========
8347
 
8348
     ^Z^Zquit
8349
 
8350
   This annotation occurs right before GDB responds to an interrupt.
8351
 
8352
     ^Z^Zerror
8353
 
8354
   This annotation occurs right before GDB responds to an error.
8355
 
8356
   Quit and error annotations indicate that any annotations which GDB
8357
was in the middle of may end abruptly.  For example, if a
8358
`value-history-begin' annotation is followed by a `error', one cannot
8359
expect to receive the matching `value-history-end'.  One cannot expect
8360
not to receive it either, however; an error annotation does not
8361
necessarily mean that GDB is immediately returning all the way to the
8362
top level.
8363
 
8364
   A quit or error annotation may be preceded by
8365
 
8366
     ^Z^Zerror-begin
8367
 
8368
   Any output between that and the quit or error annotation is the error
8369
message.
8370
 
8371
   Warning messages are not yet annotated.
8372
 
8373

8374
File: gdb.info,  Node: Invalidation,  Next: Annotations for Running,  Prev: Errors,  Up: Annotations
8375
 
8376
28.5 Invalidation Notices
8377
=========================
8378
 
8379
The following annotations say that certain pieces of state may have
8380
changed.
8381
 
8382
`^Z^Zframes-invalid'
8383
     The frames (for example, output from the `backtrace' command) may
8384
     have changed.
8385
 
8386
`^Z^Zbreakpoints-invalid'
8387
     The breakpoints may have changed.  For example, the user just
8388
     added or deleted a breakpoint.
8389
 
8390

8391
File: gdb.info,  Node: Annotations for Running,  Next: Source Annotations,  Prev: Invalidation,  Up: Annotations
8392
 
8393
28.6 Running the Program
8394
========================
8395
 
8396
When the program starts executing due to a GDB command such as `step'
8397
or `continue',
8398
 
8399
     ^Z^Zstarting
8400
 
8401
   is output.  When the program stops,
8402
 
8403
     ^Z^Zstopped
8404
 
8405
   is output.  Before the `stopped' annotation, a variety of
8406
annotations describe how the program stopped.
8407
 
8408
`^Z^Zexited EXIT-STATUS'
8409
     The program exited, and EXIT-STATUS is the exit status (zero for
8410
     successful exit, otherwise nonzero).
8411
 
8412
`^Z^Zsignalled'
8413
     The program exited with a signal.  After the `^Z^Zsignalled', the
8414
     annotation continues:
8415
 
8416
          INTRO-TEXT
8417
          ^Z^Zsignal-name
8418
          NAME
8419
          ^Z^Zsignal-name-end
8420
          MIDDLE-TEXT
8421
          ^Z^Zsignal-string
8422
          STRING
8423
          ^Z^Zsignal-string-end
8424
          END-TEXT
8425
 
8426
     where NAME is the name of the signal, such as `SIGILL' or
8427
     `SIGSEGV', and STRING is the explanation of the signal, such as
8428
     `Illegal Instruction' or `Segmentation fault'.  INTRO-TEXT,
8429
     MIDDLE-TEXT, and END-TEXT are for the user's benefit and have no
8430
     particular format.
8431
 
8432
`^Z^Zsignal'
8433
     The syntax of this annotation is just like `signalled', but GDB is
8434
     just saying that the program received the signal, not that it was
8435
     terminated with it.
8436
 
8437
`^Z^Zbreakpoint NUMBER'
8438
     The program hit breakpoint number NUMBER.
8439
 
8440
`^Z^Zwatchpoint NUMBER'
8441
     The program hit watchpoint number NUMBER.
8442
 
8443

8444
File: gdb.info,  Node: Source Annotations,  Prev: Annotations for Running,  Up: Annotations
8445
 
8446
28.7 Displaying Source
8447
======================
8448
 
8449
The following annotation is used instead of displaying source code:
8450
 
8451
     ^Z^Zsource FILENAME:LINE:CHARACTER:MIDDLE:ADDR
8452
 
8453
   where FILENAME is an absolute file name indicating which source
8454
file, LINE is the line number within that file (where 1 is the first
8455
line in the file), CHARACTER is the character position within the file
8456
(where 0 is the first character in the file) (for most debug formats
8457
this will necessarily point to the beginning of a line), MIDDLE is
8458
`middle' if ADDR is in the middle of the line, or `beg' if ADDR is at
8459
the beginning of the line, and ADDR is the address in the target
8460
program associated with the source which is being displayed.  ADDR is
8461
in the form `0x' followed by one or more lowercase hex digits (note
8462
that this does not depend on the language).
8463
 
8464

8465
File: gdb.info,  Node: JIT Interface,  Next: GDB Bugs,  Prev: Annotations,  Up: Top
8466
 
8467
29 JIT Compilation Interface
8468
****************************
8469
 
8470
This chapter documents GDB's "just-in-time" (JIT) compilation
8471
interface.  A JIT compiler is a program or library that generates native
8472
executable code at runtime and executes it, usually in order to achieve
8473
good performance while maintaining platform independence.
8474
 
8475
   Programs that use JIT compilation are normally difficult to debug
8476
because portions of their code are generated at runtime, instead of
8477
being loaded from object files, which is where GDB normally finds the
8478
program's symbols and debug information.  In order to debug programs
8479
that use JIT compilation, GDB has an interface that allows the program
8480
to register in-memory symbol files with GDB at runtime.
8481
 
8482
   If you are using GDB to debug a program that uses this interface,
8483
then it should work transparently so long as you have not stripped the
8484
binary.  If you are developing a JIT compiler, then the interface is
8485
documented in the rest of this chapter.  At this time, the only known
8486
client of this interface is the LLVM JIT.
8487
 
8488
   Broadly speaking, the JIT interface mirrors the dynamic loader
8489
interface.  The JIT compiler communicates with GDB by writing data into
8490
a global variable and calling a fuction at a well-known symbol.  When
8491
GDB attaches, it reads a linked list of symbol files from the global
8492
variable to find existing code, and puts a breakpoint in the function
8493
so that it can find out about additional code.
8494
 
8495
* Menu:
8496
 
8497
* Declarations::                Relevant C struct declarations
8498
* Registering Code::            Steps to register code
8499
* Unregistering Code::          Steps to unregister code
8500
 
8501

8502
File: gdb.info,  Node: Declarations,  Next: Registering Code,  Up: JIT Interface
8503
 
8504
29.1 JIT Declarations
8505
=====================
8506
 
8507
These are the relevant struct declarations that a C program should
8508
include to implement the interface:
8509
 
8510
     typedef enum
8511
     {
8512
       JIT_NOACTION = 0,
8513
       JIT_REGISTER_FN,
8514
       JIT_UNREGISTER_FN
8515
     } jit_actions_t;
8516
 
8517
     struct jit_code_entry
8518
     {
8519
       struct jit_code_entry *next_entry;
8520
       struct jit_code_entry *prev_entry;
8521
       const char *symfile_addr;
8522
       uint64_t symfile_size;
8523
     };
8524
 
8525
     struct jit_descriptor
8526
     {
8527
       uint32_t version;
8528
       /* This type should be jit_actions_t, but we use uint32_t
8529
          to be explicit about the bitwidth.  */
8530
       uint32_t action_flag;
8531
       struct jit_code_entry *relevant_entry;
8532
       struct jit_code_entry *first_entry;
8533
     };
8534
 
8535
     /* GDB puts a breakpoint in this function.  */
8536
     void __attribute__((noinline)) __jit_debug_register_code() { };
8537
 
8538
     /* Make sure to specify the version statically, because the
8539
        debugger may check the version before we can set it.  */
8540
     struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
8541
 
8542
   If the JIT is multi-threaded, then it is important that the JIT
8543
synchronize any modifications to this global data properly, which can
8544
easily be done by putting a global mutex around modifications to these
8545
structures.
8546
 
8547

8548
File: gdb.info,  Node: Registering Code,  Next: Unregistering Code,  Prev: Declarations,  Up: JIT Interface
8549
 
8550
29.2 Registering Code
8551
=====================
8552
 
8553
To register code with GDB, the JIT should follow this protocol:
8554
 
8555
   * Generate an object file in memory with symbols and other desired
8556
     debug information.  The file must include the virtual addresses of
8557
     the sections.
8558
 
8559
   * Create a code entry for the file, which gives the start and size
8560
     of the symbol file.
8561
 
8562
   * Add it to the linked list in the JIT descriptor.
8563
 
8564
   * Point the relevant_entry field of the descriptor at the entry.
8565
 
8566
   * Set `action_flag' to `JIT_REGISTER' and call
8567
     `__jit_debug_register_code'.
8568
 
8569
   When GDB is attached and the breakpoint fires, GDB uses the
8570
`relevant_entry' pointer so it doesn't have to walk the list looking for
8571
new code.  However, the linked list must still be maintained in order
8572
to allow GDB to attach to a running process and still find the symbol
8573
files.
8574
 
8575

8576
File: gdb.info,  Node: Unregistering Code,  Prev: Registering Code,  Up: JIT Interface
8577
 
8578
29.3 Unregistering Code
8579
=======================
8580
 
8581
If code is freed, then the JIT should use the following protocol:
8582
 
8583
   * Remove the code entry corresponding to the code from the linked
8584
     list.
8585
 
8586
   * Point the `relevant_entry' field of the descriptor at the code
8587
     entry.
8588
 
8589
   * Set `action_flag' to `JIT_UNREGISTER' and call
8590
     `__jit_debug_register_code'.
8591
 
8592
   If the JIT frees or recompiles code without unregistering it, then
8593
GDB and the JIT will leak the memory used for the associated symbol
8594
files.
8595
 
8596

8597
File: gdb.info,  Node: GDB Bugs,  Next: Command Line Editing,  Prev: JIT Interface,  Up: Top
8598
 
8599
30 Reporting Bugs in GDB
8600
************************
8601
 
8602
Your bug reports play an essential role in making GDB reliable.
8603
 
8604
   Reporting a bug may help you by bringing a solution to your problem,
8605
or it may not.  But in any case the principal function of a bug report
8606
is to help the entire community by making the next version of GDB work
8607
better.  Bug reports are your contribution to the maintenance of GDB.
8608
 
8609
   In order for a bug report to serve its purpose, you must include the
8610
information that enables us to fix the bug.
8611
 
8612
* Menu:
8613
 
8614
* Bug Criteria::                Have you found a bug?
8615
* Bug Reporting::               How to report bugs
8616
 
8617

8618
File: gdb.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: GDB Bugs
8619
 
8620
30.1 Have You Found a Bug?
8621
==========================
8622
 
8623
If you are not sure whether you have found a bug, here are some
8624
guidelines:
8625
 
8626
   * If the debugger gets a fatal signal, for any input whatever, that
8627
     is a GDB bug.  Reliable debuggers never crash.
8628
 
8629
   * If GDB produces an error message for valid input, that is a bug.
8630
     (Note that if you're cross debugging, the problem may also be
8631
     somewhere in the connection to the target.)
8632
 
8633
   * If GDB does not produce an error message for invalid input, that
8634
     is a bug.  However, you should note that your idea of "invalid
8635
     input" might be our idea of "an extension" or "support for
8636
     traditional practice".
8637
 
8638
   * If you are an experienced user of debugging tools, your suggestions
8639
     for improvement of GDB are welcome in any case.
8640
 
8641

8642
File: gdb.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: GDB Bugs
8643
 
8644
30.2 How to Report Bugs
8645
=======================
8646
 
8647
A number of companies and individuals offer support for GNU products.
8648
If you obtained GDB from a support organization, we recommend you
8649
contact that organization first.
8650
 
8651
   You can find contact information for many support companies and
8652
individuals in the file `etc/SERVICE' in the GNU Emacs distribution.
8653
 
8654
   In any event, we also recommend that you submit bug reports for GDB.
8655
The preferred method is to submit them directly using GDB's Bugs web
8656
page (http://www.gnu.org/software/gdb/bugs/).  Alternatively, the
8657
e-mail gateway  can be used.
8658
 
8659
   *Do not send bug reports to `info-gdb', or to `help-gdb', or to any
8660
newsgroups.*  Most users of GDB do not want to receive bug reports.
8661
Those that do have arranged to receive `bug-gdb'.
8662
 
8663
   The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which
8664
serves as a repeater.  The mailing list and the newsgroup carry exactly
8665
the same messages.  Often people think of posting bug reports to the
8666
newsgroup instead of mailing them.  This appears to work, but it has one
8667
problem which can be crucial: a newsgroup posting often lacks a mail
8668
path back to the sender.  Thus, if we need to ask for more information,
8669
we may be unable to reach you.  For this reason, it is better to send
8670
bug reports to the mailing list.
8671
 
8672
   The fundamental principle of reporting bugs usefully is this:
8673
*report all the facts*.  If you are not sure whether to state a fact or
8674
leave it out, state it!
8675
 
8676
   Often people omit facts because they think they know what causes the
8677
problem and assume that some details do not matter.  Thus, you might
8678
assume that the name of the variable you use in an example does not
8679
matter.  Well, probably it does not, but one cannot be sure.  Perhaps
8680
the bug is a stray memory reference which happens to fetch from the
8681
location where that name is stored in memory; perhaps, if the name were
8682
different, the contents of that location would fool the debugger into
8683
doing the right thing despite the bug.  Play it safe and give a
8684
specific, complete example.  That is the easiest thing for you to do,
8685
and the most helpful.
8686
 
8687
   Keep in mind that the purpose of a bug report is to enable us to fix
8688
the bug.  It may be that the bug has been reported previously, but
8689
neither you nor we can know that unless your bug report is complete and
8690
self-contained.
8691
 
8692
   Sometimes people give a few sketchy facts and ask, "Does this ring a
8693
bell?"  Those bug reports are useless, and we urge everyone to _refuse
8694
to respond to them_ except to chide the sender to report bugs properly.
8695
 
8696
   To enable us to fix the bug, you should include all these things:
8697
 
8698
   * The version of GDB.  GDB announces it if you start with no
8699
     arguments; you can also print it at any time using `show version'.
8700
 
8701
     Without this, we will not know whether there is any point in
8702
     looking for the bug in the current version of GDB.
8703
 
8704
   * The type of machine you are using, and the operating system name
8705
     and version number.
8706
 
8707
   * What compiler (and its version) was used to compile GDB--e.g.
8708
     "gcc-2.8.1".
8709
 
8710
   * What compiler (and its version) was used to compile the program
8711
     you are debugging--e.g.  "gcc-2.8.1", or "HP92453-01 A.10.32.03 HP
8712
     C Compiler".  For GCC, you can say `gcc --version' to get this
8713
     information; for other compilers, see the documentation for those
8714
     compilers.
8715
 
8716
   * The command arguments you gave the compiler to compile your
8717
     example and observe the bug.  For example, did you use `-O'?  To
8718
     guarantee you will not omit something important, list them all.  A
8719
     copy of the Makefile (or the output from make) is sufficient.
8720
 
8721
     If we were to try to guess the arguments, we would probably guess
8722
     wrong and then we might not encounter the bug.
8723
 
8724
   * A complete input script, and all necessary source files, that will
8725
     reproduce the bug.
8726
 
8727
   * A description of what behavior you observe that you believe is
8728
     incorrect.  For example, "It gets a fatal signal."
8729
 
8730
     Of course, if the bug is that GDB gets a fatal signal, then we
8731
     will certainly notice it.  But if the bug is incorrect output, we
8732
     might not notice unless it is glaringly wrong.  You might as well
8733
     not give us a chance to make a mistake.
8734
 
8735
     Even if the problem you experience is a fatal signal, you should
8736
     still say so explicitly.  Suppose something strange is going on,
8737
     such as, your copy of GDB is out of synch, or you have encountered
8738
     a bug in the C library on your system.  (This has happened!)  Your
8739
     copy might crash and ours would not.  If you told us to expect a
8740
     crash, then when ours fails to crash, we would know that the bug
8741
     was not happening for us.  If you had not told us to expect a
8742
     crash, then we would not be able to draw any conclusion from our
8743
     observations.
8744
 
8745
     To collect all this information, you can use a session recording
8746
     program such as `script', which is available on many Unix systems.
8747
     Just run your GDB session inside `script' and then include the
8748
     `typescript' file with your bug report.
8749
 
8750
     Another way to record a GDB session is to run GDB inside Emacs and
8751
     then save the entire buffer to a file.
8752
 
8753
   * If you wish to suggest changes to the GDB source, send us context
8754
     diffs.  If you even discuss something in the GDB source, refer to
8755
     it by context, not by line number.
8756
 
8757
     The line numbers in our development sources will not match those
8758
     in your sources.  Your line numbers would convey no useful
8759
     information to us.
8760
 
8761
 
8762
   Here are some things that are not necessary:
8763
 
8764
   * A description of the envelope of the bug.
8765
 
8766
     Often people who encounter a bug spend a lot of time investigating
8767
     which changes to the input file will make the bug go away and which
8768
     changes will not affect it.
8769
 
8770
     This is often time consuming and not very useful, because the way
8771
     we will find the bug is by running a single example under the
8772
     debugger with breakpoints, not by pure deduction from a series of
8773
     examples.  We recommend that you save your time for something else.
8774
 
8775
     Of course, if you can find a simpler example to report _instead_
8776
     of the original one, that is a convenience for us.  Errors in the
8777
     output will be easier to spot, running under the debugger will take
8778
     less time, and so on.
8779
 
8780
     However, simplification is not vital; if you do not want to do
8781
     this, report the bug anyway and send us the entire test case you
8782
     used.
8783
 
8784
   * A patch for the bug.
8785
 
8786
     A patch for the bug does help us if it is a good one.  But do not
8787
     omit the necessary information, such as the test case, on the
8788
     assumption that a patch is all we need.  We might see problems
8789
     with your patch and decide to fix the problem another way, or we
8790
     might not understand it at all.
8791
 
8792
     Sometimes with a program as complicated as GDB it is very hard to
8793
     construct an example that will make the program follow a certain
8794
     path through the code.  If you do not send us the example, we will
8795
     not be able to construct one, so we will not be able to verify
8796
     that the bug is fixed.
8797
 
8798
     And if we cannot understand what bug you are trying to fix, or why
8799
     your patch should be an improvement, we will not install it.  A
8800
     test case will help us to understand.
8801
 
8802
   * A guess about what the bug is or what it depends on.
8803
 
8804
     Such guesses are usually wrong.  Even we cannot guess right about
8805
     such things without first using the debugger to find the facts.
8806
 
8807

8808
File: gdb.info,  Node: Command Line Editing,  Next: Using History Interactively,  Prev: GDB Bugs,  Up: Top
8809
 
8810
31 Command Line Editing
8811
***********************
8812
 
8813
This chapter describes the basic features of the GNU command line
8814
editing interface.
8815
 
8816
* Menu:
8817
 
8818
* Introduction and Notation::   Notation used in this text.
8819
* Readline Interaction::        The minimum set of commands for editing a line.
8820
* Readline Init File::          Customizing Readline from a user's view.
8821
* Bindable Readline Commands::  A description of most of the Readline commands
8822
                                available for binding
8823
* Readline vi Mode::            A short description of how to make Readline
8824
                                behave like the vi editor.
8825
 
8826

8827
File: gdb.info,  Node: Introduction and Notation,  Next: Readline Interaction,  Up: Command Line Editing
8828
 
8829
31.1 Introduction to Line Editing
8830
=================================
8831
 
8832
The following paragraphs describe the notation used to represent
8833
keystrokes.
8834
 
8835
   The text `C-k' is read as `Control-K' and describes the character
8836
produced when the  key is pressed while the Control key is depressed.
8837
 
8838
   The text `M-k' is read as `Meta-K' and describes the character
8839
produced when the Meta key (if you have one) is depressed, and the 
8840
key is pressed.  The Meta key is labeled  on many keyboards.  On
8841
keyboards with two keys labeled  (usually to either side of the
8842
space bar), the  on the left side is generally set to work as a
8843
Meta key.  The  key on the right may also be configured to work as
8844
a Meta key or may be configured as some other modifier, such as a
8845
Compose key for typing accented characters.
8846
 
8847
   If you do not have a Meta or  key, or another key working as a
8848
Meta key, the identical keystroke can be generated by typing 
8849
_first_, and then typing .  Either process is known as "metafying"
8850
the  key.
8851
 
8852
   The text `M-C-k' is read as `Meta-Control-k' and describes the
8853
character produced by "metafying" `C-k'.
8854
 
8855
   In addition, several keys have their own names.  Specifically,
8856
, , , , , and  all stand for themselves
8857
when seen in this text, or in an init file (*note Readline Init File::).
8858
If your keyboard lacks a  key, typing  will produce the
8859
desired character.  The  key may be labeled  or  on
8860
some keyboards.
8861
 
8862

8863
File: gdb.info,  Node: Readline Interaction,  Next: Readline Init File,  Prev: Introduction and Notation,  Up: Command Line Editing
8864
 
8865
31.2 Readline Interaction
8866
=========================
8867
 
8868
Often during an interactive session you type in a long line of text,
8869
only to notice that the first word on the line is misspelled.  The
8870
Readline library gives you a set of commands for manipulating the text
8871
as you type it in, allowing you to just fix your typo, and not forcing
8872
you to retype the majority of the line.  Using these editing commands,
8873
you move the cursor to the place that needs correction, and delete or
8874
insert the text of the corrections.  Then, when you are satisfied with
8875
the line, you simply press .  You do not have to be at the end of
8876
the line to press ; the entire line is accepted regardless of the
8877
location of the cursor within the line.
8878
 
8879
* Menu:
8880
 
8881
* Readline Bare Essentials::    The least you need to know about Readline.
8882
* Readline Movement Commands::  Moving about the input line.
8883
* Readline Killing Commands::   How to delete text, and how to get it back!
8884
* Readline Arguments::          Giving numeric arguments to commands.
8885
* Searching::                   Searching through previous lines.
8886
 
8887

8888
File: gdb.info,  Node: Readline Bare Essentials,  Next: Readline Movement Commands,  Up: Readline Interaction
8889
 
8890
31.2.1 Readline Bare Essentials
8891
-------------------------------
8892
 
8893
In order to enter characters into the line, simply type them.  The typed
8894
character appears where the cursor was, and then the cursor moves one
8895
space to the right.  If you mistype a character, you can use your erase
8896
character to back up and delete the mistyped character.
8897
 
8898
   Sometimes you may mistype a character, and not notice the error
8899
until you have typed several other characters.  In that case, you can
8900
type `C-b' to move the cursor to the left, and then correct your
8901
mistake.  Afterwards, you can move the cursor to the right with `C-f'.
8902
 
8903
   When you add text in the middle of a line, you will notice that
8904
characters to the right of the cursor are `pushed over' to make room
8905
for the text that you have inserted.  Likewise, when you delete text
8906
behind the cursor, characters to the right of the cursor are `pulled
8907
back' to fill in the blank space created by the removal of the text.  A
8908
list of the bare essentials for editing the text of an input line
8909
follows.
8910
 
8911
`C-b'
8912
     Move back one character.
8913
 
8914
`C-f'
8915
     Move forward one character.
8916
 
8917
 or 
8918
     Delete the character to the left of the cursor.
8919
 
8920
`C-d'
8921
     Delete the character underneath the cursor.
8922
 
8923
Printing characters
8924
     Insert the character into the line at the cursor.
8925
 
8926
`C-_' or `C-x C-u'
8927
     Undo the last editing command.  You can undo all the way back to an
8928
     empty line.
8929
 
8930
(Depending on your configuration, the  key be set to delete
8931
the character to the left of the cursor and the  key set to delete
8932
the character underneath the cursor, like `C-d', rather than the
8933
character to the left of the cursor.)
8934
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.