OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc1/] [gdb/] [doc/] [gdb.info-4] - Blame information for rev 341

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
This is gdb.info, produced by makeinfo version 4.8 from ./gdb.texinfo.
2
 
3
INFO-DIR-SECTION Software development
4
START-INFO-DIR-ENTRY
5
* Gdb: (gdb).                     The GNU debugger.
6
END-INFO-DIR-ENTRY
7
 
8
   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
9
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
10
2010 Free Software Foundation, Inc.
11
 
12
   Permission is granted to copy, distribute and/or modify this document
13
under the terms of the GNU Free Documentation License, Version 1.3 or
14
any later version published by the Free Software Foundation; with the
15
Invariant Sections being "Free Software" and "Free Software Needs Free
16
Documentation", with the Front-Cover Texts being "A GNU Manual," and
17
with the Back-Cover Texts as in (a) below.
18
 
19
   (a) The FSF's Back-Cover Text is: "You are free to copy and modify
20
this GNU Manual.  Buying copies from GNU Press supports the FSF in
21
developing GNU and promoting software freedom."
22
 
23
   This file documents the GNU debugger GDB.
24
 
25
   This is the Ninth Edition, of `Debugging with GDB: the GNU
26
Source-Level Debugger' for GDB (GDB) Version 7.2.
27
 
28
   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
29
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
30
2010 Free Software Foundation, Inc.
31
 
32
   Permission is granted to copy, distribute and/or modify this document
33
under the terms of the GNU Free Documentation License, Version 1.3 or
34
any later version published by the Free Software Foundation; with the
35
Invariant Sections being "Free Software" and "Free Software Needs Free
36
Documentation", with the Front-Cover Texts being "A GNU Manual," and
37
with the Back-Cover Texts as in (a) below.
38
 
39
   (a) The FSF's Back-Cover Text is: "You are free to copy and modify
40
this GNU Manual.  Buying copies from GNU Press supports the FSF in
41
developing GNU and promoting software freedom."
42
 
43

44
File: gdb.info,  Node: GDB/MI Data Manipulation,  Next: GDB/MI Tracepoint Commands,  Prev: GDB/MI Variable Objects,  Up: GDB/MI
45
 
46
27.14 GDB/MI Data Manipulation
47
==============================
48
 
49
This section describes the GDB/MI commands that manipulate data:
50
examine memory and registers, evaluate expressions, etc.
51
 
52
The `-data-disassemble' Command
53
-------------------------------
54
 
55
Synopsis
56
........
57
 
58
      -data-disassemble
59
         [ -s START-ADDR -e END-ADDR ]
60
       | [ -f FILENAME -l LINENUM [ -n LINES ] ]
61
       -- MODE
62
 
63
Where:
64
 
65
`START-ADDR'
66
     is the beginning address (or `$pc')
67
 
68
`END-ADDR'
69
     is the end address
70
 
71
`FILENAME'
72
     is the name of the file to disassemble
73
 
74
`LINENUM'
75
     is the line number to disassemble around
76
 
77
`LINES'
78
     is the number of disassembly lines to be produced.  If it is -1,
79
     the whole function will be disassembled, in case no END-ADDR is
80
     specified.  If END-ADDR is specified as a non-zero value, and
81
     LINES is lower than the number of disassembly lines between
82
     START-ADDR and END-ADDR, only LINES lines are displayed; if LINES
83
     is higher than the number of lines between START-ADDR and
84
     END-ADDR, only the lines up to END-ADDR are displayed.
85
 
86
`MODE'
87
     is either 0 (meaning only disassembly) or 1 (meaning mixed source
88
     and disassembly).
89
 
90
Result
91
......
92
 
93
The output for each instruction is composed of four fields:
94
 
95
   * Address
96
 
97
   * Func-name
98
 
99
   * Offset
100
 
101
   * Instruction
102
 
103
   Note that whatever included in the instruction field, is not
104
manipulated directly by GDB/MI, i.e., it is not possible to adjust its
105
format.
106
 
107
GDB Command
108
...........
109
 
110
There's no direct mapping from this command to the CLI.
111
 
112
Example
113
.......
114
 
115
Disassemble from the current value of `$pc' to `$pc + 20':
116
 
117
     (gdb)
118
     -data-disassemble -s $pc -e "$pc + 20" -- 0
119
     ^done,
120
     asm_insns=[
121
     {address="0x000107c0",func-name="main",offset="4",
122
     inst="mov  2, %o0"},
123
     {address="0x000107c4",func-name="main",offset="8",
124
     inst="sethi  %hi(0x11800), %o2"},
125
     {address="0x000107c8",func-name="main",offset="12",
126
     inst="or  %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"},
127
     {address="0x000107cc",func-name="main",offset="16",
128
     inst="sethi  %hi(0x11800), %o2"},
129
     {address="0x000107d0",func-name="main",offset="20",
130
     inst="or  %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"}]
131
     (gdb)
132
 
133
   Disassemble the whole `main' function.  Line 32 is part of `main'.
134
 
135
     -data-disassemble -f basics.c -l 32 -- 0
136
     ^done,asm_insns=[
137
     {address="0x000107bc",func-name="main",offset="0",
138
     inst="save  %sp, -112, %sp"},
139
     {address="0x000107c0",func-name="main",offset="4",
140
     inst="mov   2, %o0"},
141
     {address="0x000107c4",func-name="main",offset="8",
142
     inst="sethi %hi(0x11800), %o2"},
143
     [...]
144
     {address="0x0001081c",func-name="main",offset="96",inst="ret "},
145
     {address="0x00010820",func-name="main",offset="100",inst="restore "}]
146
     (gdb)
147
 
148
   Disassemble 3 instructions from the start of `main':
149
 
150
     (gdb)
151
     -data-disassemble -f basics.c -l 32 -n 3 -- 0
152
     ^done,asm_insns=[
153
     {address="0x000107bc",func-name="main",offset="0",
154
     inst="save  %sp, -112, %sp"},
155
     {address="0x000107c0",func-name="main",offset="4",
156
     inst="mov  2, %o0"},
157
     {address="0x000107c4",func-name="main",offset="8",
158
     inst="sethi  %hi(0x11800), %o2"}]
159
     (gdb)
160
 
161
   Disassemble 3 instructions from the start of `main' in mixed mode:
162
 
163
     (gdb)
164
     -data-disassemble -f basics.c -l 32 -n 3 -- 1
165
     ^done,asm_insns=[
166
     src_and_asm_line={line="31",
167
     file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
168
       testsuite/gdb.mi/basics.c",line_asm_insn=[
169
     {address="0x000107bc",func-name="main",offset="0",
170
     inst="save  %sp, -112, %sp"}]},
171
     src_and_asm_line={line="32",
172
     file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
173
       testsuite/gdb.mi/basics.c",line_asm_insn=[
174
     {address="0x000107c0",func-name="main",offset="4",
175
     inst="mov  2, %o0"},
176
     {address="0x000107c4",func-name="main",offset="8",
177
     inst="sethi  %hi(0x11800), %o2"}]}]
178
     (gdb)
179
 
180
The `-data-evaluate-expression' Command
181
---------------------------------------
182
 
183
Synopsis
184
........
185
 
186
      -data-evaluate-expression EXPR
187
 
188
   Evaluate EXPR as an expression.  The expression could contain an
189
inferior function call.  The function call will execute synchronously.
190
If the expression contains spaces, it must be enclosed in double quotes.
191
 
192
GDB Command
193
...........
194
 
195
The corresponding GDB commands are `print', `output', and `call'.  In
196
`gdbtk' only, there's a corresponding `gdb_eval' command.
197
 
198
Example
199
.......
200
 
201
In the following example, the numbers that precede the commands are the
202
"tokens" described in *Note GDB/MI Command Syntax: GDB/MI Command
203
Syntax.  Notice how GDB/MI returns the same tokens in its output.
204
 
205
     211-data-evaluate-expression A
206
     211^done,value="1"
207
     (gdb)
208
     311-data-evaluate-expression &A
209
     311^done,value="0xefffeb7c"
210
     (gdb)
211
     411-data-evaluate-expression A+3
212
     411^done,value="4"
213
     (gdb)
214
     511-data-evaluate-expression "A + 3"
215
     511^done,value="4"
216
     (gdb)
217
 
218
The `-data-list-changed-registers' Command
219
------------------------------------------
220
 
221
Synopsis
222
........
223
 
224
      -data-list-changed-registers
225
 
226
   Display a list of the registers that have changed.
227
 
228
GDB Command
229
...........
230
 
231
GDB doesn't have a direct analog for this command; `gdbtk' has the
232
corresponding command `gdb_changed_register_list'.
233
 
234
Example
235
.......
236
 
237
On a PPC MBX board:
238
 
239
     (gdb)
240
     -exec-continue
241
     ^running
242
 
243
     (gdb)
244
     *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={
245
     func="main",args=[],file="try.c",fullname="/home/foo/bar/try.c",
246
     line="5"}
247
     (gdb)
248
     -data-list-changed-registers
249
     ^done,changed-registers=["0","1","2","4","5","6","7","8","9",
250
     "10","11","13","14","15","16","17","18","19","20","21","22","23",
251
     "24","25","26","27","28","30","31","64","65","66","67","69"]
252
     (gdb)
253
 
254
The `-data-list-register-names' Command
255
---------------------------------------
256
 
257
Synopsis
258
........
259
 
260
      -data-list-register-names [ ( REGNO )+ ]
261
 
262
   Show a list of register names for the current target.  If no
263
arguments are given, it shows a list of the names of all the registers.
264
If integer numbers are given as arguments, it will print a list of the
265
names of the registers corresponding to the arguments.  To ensure
266
consistency between a register name and its number, the output list may
267
include empty register names.
268
 
269
GDB Command
270
...........
271
 
272
GDB does not have a command which corresponds to
273
`-data-list-register-names'.  In `gdbtk' there is a corresponding
274
command `gdb_regnames'.
275
 
276
Example
277
.......
278
 
279
For the PPC MBX board:
280
     (gdb)
281
     -data-list-register-names
282
     ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
283
     "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
284
     "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
285
     "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
286
     "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
287
     "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
288
     "", "pc","ps","cr","lr","ctr","xer"]
289
     (gdb)
290
     -data-list-register-names 1 2 3
291
     ^done,register-names=["r1","r2","r3"]
292
     (gdb)
293
 
294
The `-data-list-register-values' Command
295
----------------------------------------
296
 
297
Synopsis
298
........
299
 
300
      -data-list-register-values FMT [ ( REGNO )*]
301
 
302
   Display the registers' contents.  FMT is the format according to
303
which the registers' contents are to be returned, followed by an
304
optional list of numbers specifying the registers to display.  A
305
missing list of numbers indicates that the contents of all the
306
registers must be returned.
307
 
308
   Allowed formats for FMT are:
309
 
310
`x'
311
     Hexadecimal
312
 
313
`o'
314
     Octal
315
 
316
`t'
317
     Binary
318
 
319
`d'
320
     Decimal
321
 
322
`r'
323
     Raw
324
 
325
`N'
326
     Natural
327
 
328
GDB Command
329
...........
330
 
331
The corresponding GDB commands are `info reg', `info all-reg', and (in
332
`gdbtk') `gdb_fetch_registers'.
333
 
334
Example
335
.......
336
 
337
For a PPC MBX board (note: line breaks are for readability only, they
338
don't appear in the actual output):
339
 
340
     (gdb)
341
     -data-list-register-values r 64 65
342
     ^done,register-values=[{number="64",value="0xfe00a300"},
343
     {number="65",value="0x00029002"}]
344
     (gdb)
345
     -data-list-register-values x
346
     ^done,register-values=[{number="0",value="0xfe0043c8"},
347
     {number="1",value="0x3fff88"},{number="2",value="0xfffffffe"},
348
     {number="3",value="0x0"},{number="4",value="0xa"},
349
     {number="5",value="0x3fff68"},{number="6",value="0x3fff58"},
350
     {number="7",value="0xfe011e98"},{number="8",value="0x2"},
351
     {number="9",value="0xfa202820"},{number="10",value="0xfa202808"},
352
     {number="11",value="0x1"},{number="12",value="0x0"},
353
     {number="13",value="0x4544"},{number="14",value="0xffdfffff"},
354
     {number="15",value="0xffffffff"},{number="16",value="0xfffffeff"},
355
     {number="17",value="0xefffffed"},{number="18",value="0xfffffffe"},
356
     {number="19",value="0xffffffff"},{number="20",value="0xffffffff"},
357
     {number="21",value="0xffffffff"},{number="22",value="0xfffffff7"},
358
     {number="23",value="0xffffffff"},{number="24",value="0xffffffff"},
359
     {number="25",value="0xffffffff"},{number="26",value="0xfffffffb"},
360
     {number="27",value="0xffffffff"},{number="28",value="0xf7bfffff"},
361
     {number="29",value="0x0"},{number="30",value="0xfe010000"},
362
     {number="31",value="0x0"},{number="32",value="0x0"},
363
     {number="33",value="0x0"},{number="34",value="0x0"},
364
     {number="35",value="0x0"},{number="36",value="0x0"},
365
     {number="37",value="0x0"},{number="38",value="0x0"},
366
     {number="39",value="0x0"},{number="40",value="0x0"},
367
     {number="41",value="0x0"},{number="42",value="0x0"},
368
     {number="43",value="0x0"},{number="44",value="0x0"},
369
     {number="45",value="0x0"},{number="46",value="0x0"},
370
     {number="47",value="0x0"},{number="48",value="0x0"},
371
     {number="49",value="0x0"},{number="50",value="0x0"},
372
     {number="51",value="0x0"},{number="52",value="0x0"},
373
     {number="53",value="0x0"},{number="54",value="0x0"},
374
     {number="55",value="0x0"},{number="56",value="0x0"},
375
     {number="57",value="0x0"},{number="58",value="0x0"},
376
     {number="59",value="0x0"},{number="60",value="0x0"},
377
     {number="61",value="0x0"},{number="62",value="0x0"},
378
     {number="63",value="0x0"},{number="64",value="0xfe00a300"},
379
     {number="65",value="0x29002"},{number="66",value="0x202f04b5"},
380
     {number="67",value="0xfe0043b0"},{number="68",value="0xfe00b3e4"},
381
     {number="69",value="0x20002b03"}]
382
     (gdb)
383
 
384
The `-data-read-memory' Command
385
-------------------------------
386
 
387
Synopsis
388
........
389
 
390
      -data-read-memory [ -o BYTE-OFFSET ]
391
        ADDRESS WORD-FORMAT WORD-SIZE
392
        NR-ROWS NR-COLS [ ASCHAR ]
393
 
394
where:
395
 
396
`ADDRESS'
397
     An expression specifying the address of the first memory word to be
398
     read.  Complex expressions containing embedded white space should
399
     be quoted using the C convention.
400
 
401
`WORD-FORMAT'
402
     The format to be used to print the memory words.  The notation is
403
     the same as for GDB's `print' command (*note Output Formats:
404
     Output Formats.).
405
 
406
`WORD-SIZE'
407
     The size of each memory word in bytes.
408
 
409
`NR-ROWS'
410
     The number of rows in the output table.
411
 
412
`NR-COLS'
413
     The number of columns in the output table.
414
 
415
`ASCHAR'
416
     If present, indicates that each row should include an ASCII dump.
417
     The value of ASCHAR is used as a padding character when a byte is
418
     not a member of the printable ASCII character set (printable ASCII
419
     characters are those whose code is between 32 and 126,
420
     inclusively).
421
 
422
`BYTE-OFFSET'
423
     An offset to add to the ADDRESS before fetching memory.
424
 
425
   This command displays memory contents as a table of NR-ROWS by
426
NR-COLS words, each word being WORD-SIZE bytes.  In total, `NR-ROWS *
427
NR-COLS * WORD-SIZE' bytes are read (returned as `total-bytes').
428
Should less than the requested number of bytes be returned by the
429
target, the missing words are identified using `N/A'.  The number of
430
bytes read from the target is returned in `nr-bytes' and the starting
431
address used to read memory in `addr'.
432
 
433
   The address of the next/previous row or page is available in
434
`next-row' and `prev-row', `next-page' and `prev-page'.
435
 
436
GDB Command
437
...........
438
 
439
The corresponding GDB command is `x'.  `gdbtk' has `gdb_get_mem' memory
440
read command.
441
 
442
Example
443
.......
444
 
445
Read six bytes of memory starting at `bytes+6' but then offset by `-6'
446
bytes.  Format as three rows of two columns.  One byte per word.
447
Display each word in hex.
448
 
449
     (gdb)
450
     9-data-read-memory -o -6 -- bytes+6 x 1 3 2
451
     9^done,addr="0x00001390",nr-bytes="6",total-bytes="6",
452
     next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396",
453
     prev-page="0x0000138a",memory=[
454
     {addr="0x00001390",data=["0x00","0x01"]},
455
     {addr="0x00001392",data=["0x02","0x03"]},
456
     {addr="0x00001394",data=["0x04","0x05"]}]
457
     (gdb)
458
 
459
   Read two bytes of memory starting at address `shorts + 64' and
460
display as a single word formatted in decimal.
461
 
462
     (gdb)
463
     5-data-read-memory shorts+64 d 2 1 1
464
     5^done,addr="0x00001510",nr-bytes="2",total-bytes="2",
465
     next-row="0x00001512",prev-row="0x0000150e",
466
     next-page="0x00001512",prev-page="0x0000150e",memory=[
467
     {addr="0x00001510",data=["128"]}]
468
     (gdb)
469
 
470
   Read thirty two bytes of memory starting at `bytes+16' and format as
471
eight rows of four columns.  Include a string encoding with `x' used as
472
the non-printable character.
473
 
474
     (gdb)
475
     4-data-read-memory bytes+16 x 1 8 4 x
476
     4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32",
477
     next-row="0x000013c0",prev-row="0x0000139c",
478
     next-page="0x000013c0",prev-page="0x00001380",memory=[
479
     {addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"},
480
     {addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"},
481
     {addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"},
482
     {addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"},
483
     {addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"},
484
     {addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"},
485
     {addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"},
486
     {addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"}]
487
     (gdb)
488
 
489

490
File: gdb.info,  Node: GDB/MI Tracepoint Commands,  Next: GDB/MI Symbol Query,  Prev: GDB/MI Data Manipulation,  Up: GDB/MI
491
 
492
27.15 GDB/MI Tracepoint Commands
493
================================
494
 
495
The commands defined in this section implement MI support for
496
tracepoints.  For detailed introduction, see *Note Tracepoints::.
497
 
498
The `-trace-find' Command
499
-------------------------
500
 
501
Synopsis
502
........
503
 
504
      -trace-find MODE [PARAMETERS...]
505
 
506
   Find a trace frame using criteria defined by MODE and PARAMETERS.
507
The following table lists permissible modes and their parameters.  For
508
details of operation, see *Note tfind::.
509
 
510
`none'
511
     No parameters are required.  Stops examining trace frames.
512
 
513
`frame-number'
514
     An integer is required as parameter.  Selects tracepoint frame with
515
     that index.
516
 
517
`tracepoint-number'
518
     An integer is required as parameter.  Finds next trace frame that
519
     corresponds to tracepoint with the specified number.
520
 
521
`pc'
522
     An address is required as parameter.  Finds next trace frame that
523
     corresponds to any tracepoint at the specified address.
524
 
525
`pc-inside-range'
526
     Two addresses are required as parameters.  Finds next trace frame
527
     that corresponds to a tracepoint at an address inside the
528
     specified range.  Both bounds are considered to be inside the
529
     range.
530
 
531
`pc-outside-range'
532
     Two addresses are required as parameters.  Finds next trace frame
533
     that corresponds to a tracepoint at an address outside the
534
     specified range.  Both bounds are considered to be inside the
535
     range.
536
 
537
`line'
538
     Line specification is required as parameter.  *Note Specify
539
     Location::.  Finds next trace frame that corresponds to a
540
     tracepoint at the specified location.
541
 
542
 
543
   If `none' was passed as MODE, the response does not have fields.
544
Otherwise, the response may have the following fields:
545
 
546
`found'
547
     This field has either `0' or `1' as the value, depending on
548
     whether a matching tracepoint was found.
549
 
550
`traceframe'
551
     The index of the found traceframe.  This field is present iff the
552
     `found' field has value of `1'.
553
 
554
`tracepoint'
555
     The index of the found tracepoint.  This field is present iff the
556
     `found' field has value of `1'.
557
 
558
`frame'
559
     The information about the frame corresponding to the found trace
560
     frame.  This field is present only if a trace frame was found.
561
     *Note GDB/MI Frame Information::, for description of this field.
562
 
563
 
564
GDB Command
565
...........
566
 
567
The corresponding GDB command is `tfind'.
568
 
569
-trace-define-variable
570
----------------------
571
 
572
Synopsis
573
........
574
 
575
      -trace-define-variable NAME [ VALUE ]
576
 
577
   Create trace variable NAME if it does not exist.  If VALUE is
578
specified, sets the initial value of the specified trace variable to
579
that value.  Note that the NAME should start with the `$' character.
580
 
581
GDB Command
582
...........
583
 
584
The corresponding GDB command is `tvariable'.
585
 
586
-trace-list-variables
587
---------------------
588
 
589
Synopsis
590
........
591
 
592
      -trace-list-variables
593
 
594
   Return a table of all defined trace variables.  Each element of the
595
table has the following fields:
596
 
597
`name'
598
     The name of the trace variable.  This field is always present.
599
 
600
`initial'
601
     The initial value.  This is a 64-bit signed integer.  This field
602
     is always present.
603
 
604
`current'
605
     The value the trace variable has at the moment.  This is a 64-bit
606
     signed integer.  This field is absent iff current value is not
607
     defined, for example if the trace was never run, or is presently
608
     running.
609
 
610
 
611
GDB Command
612
...........
613
 
614
The corresponding GDB command is `tvariables'.
615
 
616
Example
617
.......
618
 
619
     (gdb)
620
     -trace-list-variables
621
     ^done,trace-variables={nr_rows="1",nr_cols="3",
622
     hdr=[{width="15",alignment="-1",col_name="name",colhdr="Name"},
623
          {width="11",alignment="-1",col_name="initial",colhdr="Initial"},
624
          {width="11",alignment="-1",col_name="current",colhdr="Current"}],
625
     body=[variable={name="$trace_timestamp",initial="0"}
626
           variable={name="$foo",initial="10",current="15"}]}
627
     (gdb)
628
 
629
-trace-save
630
-----------
631
 
632
Synopsis
633
........
634
 
635
      -trace-save [-r ] FILENAME
636
 
637
   Saves the collected trace data to FILENAME.  Without the `-r'
638
option, the data is downloaded from the target and saved in a local
639
file.  With the `-r' option the target is asked to perform the save.
640
 
641
GDB Command
642
...........
643
 
644
The corresponding GDB command is `tsave'.
645
 
646
-trace-start
647
------------
648
 
649
Synopsis
650
........
651
 
652
      -trace-start
653
 
654
   Starts a tracing experiments.  The result of this command does not
655
have any fields.
656
 
657
GDB Command
658
...........
659
 
660
The corresponding GDB command is `tstart'.
661
 
662
-trace-status
663
-------------
664
 
665
Synopsis
666
........
667
 
668
      -trace-status
669
 
670
   Obtains the status of a tracing experiment.  The result may include
671
the following fields:
672
 
673
`supported'
674
     May have a value of either `0', when no tracing operations are
675
     supported, `1', when all tracing operations are supported, or
676
     `file' when examining trace file.  In the latter case, examining
677
     of trace frame is possible but new tracing experiement cannot be
678
     started.  This field is always present.
679
 
680
`running'
681
     May have a value of either `0' or `1' depending on whether tracing
682
     experiement is in progress on target.  This field is present if
683
     `supported' field is not `0'.
684
 
685
`stop-reason'
686
     Report the reason why the tracing was stopped last time.  This
687
     field may be absent iff tracing was never stopped on target yet.
688
     The value of `request' means the tracing was stopped as result of
689
     the `-trace-stop' command.  The value of `overflow' means the
690
     tracing buffer is full.  The value of `disconnection' means
691
     tracing was automatically stopped when GDB has disconnected.  The
692
     value of `passcount' means tracing was stopped when a tracepoint
693
     was passed a maximal number of times for that tracepoint.  This
694
     field is present if `supported' field is not `0'.
695
 
696
`stopping-tracepoint'
697
     The number of tracepoint whose passcount as exceeded.  This field
698
     is present iff the `stop-reason' field has the value of
699
     `passcount'.
700
 
701
`frames'
702
`frames-created'
703
     The `frames' field is a count of the total number of trace frames
704
     in the trace buffer, while `frames-created' is the total created
705
     during the run, including ones that were discarded, such as when a
706
     circular trace buffer filled up.  Both fields are optional.
707
 
708
`buffer-size'
709
`buffer-free'
710
     These fields tell the current size of the tracing buffer and the
711
     remaining space.  These fields are optional.
712
 
713
`circular'
714
     The value of the circular trace buffer flag.  `1' means that the
715
     trace buffer is circular and old trace frames will be discarded if
716
     necessary to make room, `0' means that the trace buffer is linear
717
     and may fill up.
718
 
719
`disconnected'
720
     The value of the disconnected tracing flag.  `1' means that
721
     tracing will continue after GDB disconnects, `0' means that the
722
     trace run will stop.
723
 
724
 
725
GDB Command
726
...........
727
 
728
The corresponding GDB command is `tstatus'.
729
 
730
-trace-stop
731
-----------
732
 
733
Synopsis
734
........
735
 
736
      -trace-stop
737
 
738
   Stops a tracing experiment.  The result of this command has the same
739
fields as `-trace-status', except that the `supported' and `running'
740
fields are not output.
741
 
742
GDB Command
743
...........
744
 
745
The corresponding GDB command is `tstop'.
746
 
747

748
File: gdb.info,  Node: GDB/MI Symbol Query,  Next: GDB/MI File Commands,  Prev: GDB/MI Tracepoint Commands,  Up: GDB/MI
749
 
750
27.16 GDB/MI Symbol Query Commands
751
==================================
752
 
753
The `-symbol-list-lines' Command
754
--------------------------------
755
 
756
Synopsis
757
........
758
 
759
      -symbol-list-lines FILENAME
760
 
761
   Print the list of lines that contain code and their associated
762
program addresses for the given source filename.  The entries are
763
sorted in ascending PC order.
764
 
765
GDB Command
766
...........
767
 
768
There is no corresponding GDB command.
769
 
770
Example
771
.......
772
 
773
     (gdb)
774
     -symbol-list-lines basics.c
775
     ^done,lines=[{pc="0x08048554",line="7"},{pc="0x0804855a",line="8"}]
776
     (gdb)
777
 
778

779
File: gdb.info,  Node: GDB/MI File Commands,  Next: GDB/MI Target Manipulation,  Prev: GDB/MI Symbol Query,  Up: GDB/MI
780
 
781
27.17 GDB/MI File Commands
782
==========================
783
 
784
This section describes the GDB/MI commands to specify executable file
785
names and to read in and obtain symbol table information.
786
 
787
The `-file-exec-and-symbols' Command
788
------------------------------------
789
 
790
Synopsis
791
........
792
 
793
      -file-exec-and-symbols FILE
794
 
795
   Specify the executable file to be debugged.  This file is the one
796
from which the symbol table is also read.  If no file is specified, the
797
command clears the executable and symbol information.  If breakpoints
798
are set when using this command with no arguments, GDB will produce
799
error messages.  Otherwise, no output is produced, except a completion
800
notification.
801
 
802
GDB Command
803
...........
804
 
805
The corresponding GDB command is `file'.
806
 
807
Example
808
.......
809
 
810
     (gdb)
811
     -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
812
     ^done
813
     (gdb)
814
 
815
The `-file-exec-file' Command
816
-----------------------------
817
 
818
Synopsis
819
........
820
 
821
      -file-exec-file FILE
822
 
823
   Specify the executable file to be debugged.  Unlike
824
`-file-exec-and-symbols', the symbol table is _not_ read from this
825
file.  If used without argument, GDB clears the information about the
826
executable file.  No output is produced, except a completion
827
notification.
828
 
829
GDB Command
830
...........
831
 
832
The corresponding GDB command is `exec-file'.
833
 
834
Example
835
.......
836
 
837
     (gdb)
838
     -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
839
     ^done
840
     (gdb)
841
 
842
The `-file-list-exec-source-file' Command
843
-----------------------------------------
844
 
845
Synopsis
846
........
847
 
848
      -file-list-exec-source-file
849
 
850
   List the line number, the current source file, and the absolute path
851
to the current source file for the current executable.  The macro
852
information field has a value of `1' or `0' depending on whether or not
853
the file includes preprocessor macro information.
854
 
855
GDB Command
856
...........
857
 
858
The GDB equivalent is `info source'
859
 
860
Example
861
.......
862
 
863
     (gdb)
864
     123-file-list-exec-source-file
865
     123^done,line="1",file="foo.c",fullname="/home/bar/foo.c,macro-info="1"
866
     (gdb)
867
 
868
The `-file-list-exec-source-files' Command
869
------------------------------------------
870
 
871
Synopsis
872
........
873
 
874
      -file-list-exec-source-files
875
 
876
   List the source files for the current executable.
877
 
878
   It will always output the filename, but only when GDB can find the
879
absolute file name of a source file, will it output the fullname.
880
 
881
GDB Command
882
...........
883
 
884
The GDB equivalent is `info sources'.  `gdbtk' has an analogous command
885
`gdb_listfiles'.
886
 
887
Example
888
.......
889
 
890
     (gdb)
891
     -file-list-exec-source-files
892
     ^done,files=[
893
     {file=foo.c,fullname=/home/foo.c},
894
     {file=/home/bar.c,fullname=/home/bar.c},
895
     {file=gdb_could_not_find_fullpath.c}]
896
     (gdb)
897
 
898
The `-file-symbol-file' Command
899
-------------------------------
900
 
901
Synopsis
902
........
903
 
904
      -file-symbol-file FILE
905
 
906
   Read symbol table info from the specified FILE argument.  When used
907
without arguments, clears GDB's symbol table info.  No output is
908
produced, except for a completion notification.
909
 
910
GDB Command
911
...........
912
 
913
The corresponding GDB command is `symbol-file'.
914
 
915
Example
916
.......
917
 
918
     (gdb)
919
     -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
920
     ^done
921
     (gdb)
922
 
923

924
File: gdb.info,  Node: GDB/MI Target Manipulation,  Next: GDB/MI File Transfer Commands,  Prev: GDB/MI File Commands,  Up: GDB/MI
925
 
926
27.18 GDB/MI Target Manipulation Commands
927
=========================================
928
 
929
The `-target-attach' Command
930
----------------------------
931
 
932
Synopsis
933
........
934
 
935
      -target-attach PID | GID | FILE
936
 
937
   Attach to a process PID or a file FILE outside of GDB, or a thread
938
group GID.  If attaching to a thread group, the id previously returned
939
by `-list-thread-groups --available' must be used.
940
 
941
GDB Command
942
...........
943
 
944
The corresponding GDB command is `attach'.
945
 
946
Example
947
.......
948
 
949
     (gdb)
950
     -target-attach 34
951
     =thread-created,id="1"
952
     *stopped,thread-id="1",frame={addr="0xb7f7e410",func="bar",args=[]}
953
     ^done
954
     (gdb)
955
 
956
The `-target-detach' Command
957
----------------------------
958
 
959
Synopsis
960
........
961
 
962
      -target-detach [ PID | GID ]
963
 
964
   Detach from the remote target which normally resumes its execution.
965
If either PID or GID is specified, detaches from either the specified
966
process, or specified thread group.  There's no output.
967
 
968
GDB Command
969
...........
970
 
971
The corresponding GDB command is `detach'.
972
 
973
Example
974
.......
975
 
976
     (gdb)
977
     -target-detach
978
     ^done
979
     (gdb)
980
 
981
The `-target-disconnect' Command
982
--------------------------------
983
 
984
Synopsis
985
........
986
 
987
      -target-disconnect
988
 
989
   Disconnect from the remote target.  There's no output and the target
990
is generally not resumed.
991
 
992
GDB Command
993
...........
994
 
995
The corresponding GDB command is `disconnect'.
996
 
997
Example
998
.......
999
 
1000
     (gdb)
1001
     -target-disconnect
1002
     ^done
1003
     (gdb)
1004
 
1005
The `-target-download' Command
1006
------------------------------
1007
 
1008
Synopsis
1009
........
1010
 
1011
      -target-download
1012
 
1013
   Loads the executable onto the remote target.  It prints out an
1014
update message every half second, which includes the fields:
1015
 
1016
`section'
1017
     The name of the section.
1018
 
1019
`section-sent'
1020
     The size of what has been sent so far for that section.
1021
 
1022
`section-size'
1023
     The size of the section.
1024
 
1025
`total-sent'
1026
     The total size of what was sent so far (the current and the
1027
     previous sections).
1028
 
1029
`total-size'
1030
     The size of the overall executable to download.
1031
 
1032
Each message is sent as status record (*note GDB/MI Output Syntax:
1033
GDB/MI Output Syntax.).
1034
 
1035
   In addition, it prints the name and size of the sections, as they are
1036
downloaded.  These messages include the following fields:
1037
 
1038
`section'
1039
     The name of the section.
1040
 
1041
`section-size'
1042
     The size of the section.
1043
 
1044
`total-size'
1045
     The size of the overall executable to download.
1046
 
1047
At the end, a summary is printed.
1048
 
1049
GDB Command
1050
...........
1051
 
1052
The corresponding GDB command is `load'.
1053
 
1054
Example
1055
.......
1056
 
1057
Note: each status message appears on a single line.  Here the messages
1058
have been broken down so that they can fit onto a page.
1059
 
1060
     (gdb)
1061
     -target-download
1062
     +download,{section=".text",section-size="6668",total-size="9880"}
1063
     +download,{section=".text",section-sent="512",section-size="6668",
1064
     total-sent="512",total-size="9880"}
1065
     +download,{section=".text",section-sent="1024",section-size="6668",
1066
     total-sent="1024",total-size="9880"}
1067
     +download,{section=".text",section-sent="1536",section-size="6668",
1068
     total-sent="1536",total-size="9880"}
1069
     +download,{section=".text",section-sent="2048",section-size="6668",
1070
     total-sent="2048",total-size="9880"}
1071
     +download,{section=".text",section-sent="2560",section-size="6668",
1072
     total-sent="2560",total-size="9880"}
1073
     +download,{section=".text",section-sent="3072",section-size="6668",
1074
     total-sent="3072",total-size="9880"}
1075
     +download,{section=".text",section-sent="3584",section-size="6668",
1076
     total-sent="3584",total-size="9880"}
1077
     +download,{section=".text",section-sent="4096",section-size="6668",
1078
     total-sent="4096",total-size="9880"}
1079
     +download,{section=".text",section-sent="4608",section-size="6668",
1080
     total-sent="4608",total-size="9880"}
1081
     +download,{section=".text",section-sent="5120",section-size="6668",
1082
     total-sent="5120",total-size="9880"}
1083
     +download,{section=".text",section-sent="5632",section-size="6668",
1084
     total-sent="5632",total-size="9880"}
1085
     +download,{section=".text",section-sent="6144",section-size="6668",
1086
     total-sent="6144",total-size="9880"}
1087
     +download,{section=".text",section-sent="6656",section-size="6668",
1088
     total-sent="6656",total-size="9880"}
1089
     +download,{section=".init",section-size="28",total-size="9880"}
1090
     +download,{section=".fini",section-size="28",total-size="9880"}
1091
     +download,{section=".data",section-size="3156",total-size="9880"}
1092
     +download,{section=".data",section-sent="512",section-size="3156",
1093
     total-sent="7236",total-size="9880"}
1094
     +download,{section=".data",section-sent="1024",section-size="3156",
1095
     total-sent="7748",total-size="9880"}
1096
     +download,{section=".data",section-sent="1536",section-size="3156",
1097
     total-sent="8260",total-size="9880"}
1098
     +download,{section=".data",section-sent="2048",section-size="3156",
1099
     total-sent="8772",total-size="9880"}
1100
     +download,{section=".data",section-sent="2560",section-size="3156",
1101
     total-sent="9284",total-size="9880"}
1102
     +download,{section=".data",section-sent="3072",section-size="3156",
1103
     total-sent="9796",total-size="9880"}
1104
     ^done,address="0x10004",load-size="9880",transfer-rate="6586",
1105
     write-rate="429"
1106
     (gdb)
1107
 
1108
GDB Command
1109
...........
1110
 
1111
No equivalent.
1112
 
1113
Example
1114
.......
1115
 
1116
N.A.
1117
 
1118
The `-target-select' Command
1119
----------------------------
1120
 
1121
Synopsis
1122
........
1123
 
1124
      -target-select TYPE PARAMETERS ...
1125
 
1126
   Connect GDB to the remote target.  This command takes two args:
1127
 
1128
`TYPE'
1129
     The type of target, for instance `remote', etc.
1130
 
1131
`PARAMETERS'
1132
     Device names, host names and the like.  *Note Commands for
1133
     Managing Targets: Target Commands, for more details.
1134
 
1135
   The output is a connection notification, followed by the address at
1136
which the target program is, in the following form:
1137
 
1138
     ^connected,addr="ADDRESS",func="FUNCTION NAME",
1139
       args=[ARG LIST]
1140
 
1141
GDB Command
1142
...........
1143
 
1144
The corresponding GDB command is `target'.
1145
 
1146
Example
1147
.......
1148
 
1149
     (gdb)
1150
     -target-select remote /dev/ttya
1151
     ^connected,addr="0xfe00a300",func="??",args=[]
1152
     (gdb)
1153
 
1154

1155
File: gdb.info,  Node: GDB/MI File Transfer Commands,  Next: GDB/MI Miscellaneous Commands,  Prev: GDB/MI Target Manipulation,  Up: GDB/MI
1156
 
1157
27.19 GDB/MI File Transfer Commands
1158
===================================
1159
 
1160
The `-target-file-put' Command
1161
------------------------------
1162
 
1163
Synopsis
1164
........
1165
 
1166
      -target-file-put HOSTFILE TARGETFILE
1167
 
1168
   Copy file HOSTFILE from the host system (the machine running GDB) to
1169
TARGETFILE on the target system.
1170
 
1171
GDB Command
1172
...........
1173
 
1174
The corresponding GDB command is `remote put'.
1175
 
1176
Example
1177
.......
1178
 
1179
     (gdb)
1180
     -target-file-put localfile remotefile
1181
     ^done
1182
     (gdb)
1183
 
1184
The `-target-file-get' Command
1185
------------------------------
1186
 
1187
Synopsis
1188
........
1189
 
1190
      -target-file-get TARGETFILE HOSTFILE
1191
 
1192
   Copy file TARGETFILE from the target system to HOSTFILE on the host
1193
system.
1194
 
1195
GDB Command
1196
...........
1197
 
1198
The corresponding GDB command is `remote get'.
1199
 
1200
Example
1201
.......
1202
 
1203
     (gdb)
1204
     -target-file-get remotefile localfile
1205
     ^done
1206
     (gdb)
1207
 
1208
The `-target-file-delete' Command
1209
---------------------------------
1210
 
1211
Synopsis
1212
........
1213
 
1214
      -target-file-delete TARGETFILE
1215
 
1216
   Delete TARGETFILE from the target system.
1217
 
1218
GDB Command
1219
...........
1220
 
1221
The corresponding GDB command is `remote delete'.
1222
 
1223
Example
1224
.......
1225
 
1226
     (gdb)
1227
     -target-file-delete remotefile
1228
     ^done
1229
     (gdb)
1230
 
1231

1232
File: gdb.info,  Node: GDB/MI Miscellaneous Commands,  Prev: GDB/MI File Transfer Commands,  Up: GDB/MI
1233
 
1234
27.20 Miscellaneous GDB/MI Commands
1235
===================================
1236
 
1237
The `-gdb-exit' Command
1238
-----------------------
1239
 
1240
Synopsis
1241
........
1242
 
1243
      -gdb-exit
1244
 
1245
   Exit GDB immediately.
1246
 
1247
GDB Command
1248
...........
1249
 
1250
Approximately corresponds to `quit'.
1251
 
1252
Example
1253
.......
1254
 
1255
     (gdb)
1256
     -gdb-exit
1257
     ^exit
1258
 
1259
The `-gdb-set' Command
1260
----------------------
1261
 
1262
Synopsis
1263
........
1264
 
1265
      -gdb-set
1266
 
1267
   Set an internal GDB variable.
1268
 
1269
GDB Command
1270
...........
1271
 
1272
The corresponding GDB command is `set'.
1273
 
1274
Example
1275
.......
1276
 
1277
     (gdb)
1278
     -gdb-set $foo=3
1279
     ^done
1280
     (gdb)
1281
 
1282
The `-gdb-show' Command
1283
-----------------------
1284
 
1285
Synopsis
1286
........
1287
 
1288
      -gdb-show
1289
 
1290
   Show the current value of a GDB variable.
1291
 
1292
GDB Command
1293
...........
1294
 
1295
The corresponding GDB command is `show'.
1296
 
1297
Example
1298
.......
1299
 
1300
     (gdb)
1301
     -gdb-show annotate
1302
     ^done,value="0"
1303
     (gdb)
1304
 
1305
The `-gdb-version' Command
1306
--------------------------
1307
 
1308
Synopsis
1309
........
1310
 
1311
      -gdb-version
1312
 
1313
   Show version information for GDB.  Used mostly in testing.
1314
 
1315
GDB Command
1316
...........
1317
 
1318
The GDB equivalent is `show version'.  GDB by default shows this
1319
information when you start an interactive session.
1320
 
1321
Example
1322
.......
1323
 
1324
     (gdb)
1325
     -gdb-version
1326
     ~GNU gdb 5.2.1
1327
     ~Copyright 2000 Free Software Foundation, Inc.
1328
     ~GDB is free software, covered by the GNU General Public License, and
1329
     ~you are welcome to change it and/or distribute copies of it under
1330
     ~ certain conditions.
1331
     ~Type "show copying" to see the conditions.
1332
     ~There is absolutely no warranty for GDB.  Type "show warranty" for
1333
     ~ details.
1334
     ~This GDB was configured as
1335
      "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi".
1336
     ^done
1337
     (gdb)
1338
 
1339
The `-list-features' Command
1340
----------------------------
1341
 
1342
Returns a list of particular features of the MI protocol that this
1343
version of gdb implements.  A feature can be a command, or a new field
1344
in an output of some command, or even an important bugfix.  While a
1345
frontend can sometimes detect presence of a feature at runtime, it is
1346
easier to perform detection at debugger startup.
1347
 
1348
   The command returns a list of strings, with each string naming an
1349
available feature.  Each returned string is just a name, it does not
1350
have any internal structure.  The list of possible feature names is
1351
given below.
1352
 
1353
   Example output:
1354
 
1355
     (gdb) -list-features
1356
     ^done,result=["feature1","feature2"]
1357
 
1358
   The current list of features is:
1359
 
1360
`frozen-varobjs'
1361
     Indicates presence of the `-var-set-frozen' command, as well as
1362
     possible presense of the `frozen' field in the output of
1363
     `-varobj-create'.
1364
 
1365
`pending-breakpoints'
1366
     Indicates presence of the `-f' option to the `-break-insert'
1367
     command.
1368
 
1369
`python'
1370
     Indicates presence of Python scripting support, Python-based
1371
     pretty-printing commands, and possible presence of the
1372
     `display_hint' field in the output of `-var-list-children'
1373
 
1374
`thread-info'
1375
     Indicates presence of the `-thread-info' command.
1376
 
1377
 
1378
The `-list-target-features' Command
1379
-----------------------------------
1380
 
1381
Returns a list of particular features that are supported by the target.
1382
Those features affect the permitted MI commands, but unlike the
1383
features reported by the `-list-features' command, the features depend
1384
on which target GDB is using at the moment.  Whenever a target can
1385
change, due to commands such as `-target-select', `-target-attach' or
1386
`-exec-run', the list of target features may change, and the frontend
1387
should obtain it again.  Example output:
1388
 
1389
     (gdb) -list-features
1390
     ^done,result=["async"]
1391
 
1392
   The current list of features is:
1393
 
1394
`async'
1395
     Indicates that the target is capable of asynchronous command
1396
     execution, which means that GDB will accept further commands while
1397
     the target is running.
1398
 
1399
`reverse'
1400
     Indicates that the target is capable of reverse execution.  *Note
1401
     Reverse Execution::, for more information.
1402
 
1403
 
1404
The `-list-thread-groups' Command
1405
---------------------------------
1406
 
1407
Synopsis
1408
--------
1409
 
1410
     -list-thread-groups [ --available ] [ --recurse 1 ] [ GROUP ... ]
1411
 
1412
   Lists thread groups (*note Thread groups::).  When a single thread
1413
group is passed as the argument, lists the children of that group.
1414
When several thread group are passed, lists information about those
1415
thread groups.  Without any parameters, lists information about all
1416
top-level thread groups.
1417
 
1418
   Normally, thread groups that are being debugged are reported.  With
1419
the `--available' option, GDB reports thread groups available on the
1420
target.
1421
 
1422
   The output of this command may have either a `threads' result or a
1423
`groups' result.  The `thread' result has a list of tuples as value,
1424
with each tuple describing a thread (*note GDB/MI Thread
1425
Information::).  The `groups' result has a list of tuples as value,
1426
each tuple describing a thread group.  If top-level groups are
1427
requested (that is, no parameter is passed), or when several groups are
1428
passed, the output always has a `groups' result.  The format of the
1429
`group' result is described below.
1430
 
1431
   To reduce the number of roundtrips it's possible to list thread
1432
groups together with their children, by passing the `--recurse' option
1433
and the recursion depth.  Presently, only recursion depth of 1 is
1434
permitted.  If this option is present, then every reported thread group
1435
will also include its children, either as `group' or `threads' field.
1436
 
1437
   In general, any combination of option and parameters is permitted,
1438
with the following caveats:
1439
 
1440
   * When a single thread group is passed, the output will typically be
1441
     the `threads' result.  Because threads may not contain anything,
1442
     the `recurse' option will be ignored.
1443
 
1444
   * When the `--available' option is passed, limited information may
1445
     be available.  In particular, the list of threads of a process
1446
     might be inaccessible.  Further, specifying specific thread groups
1447
     might not give any performance advantage over listing all thread
1448
     groups.  The frontend should assume that `-list-thread-groups
1449
     --available' is always an expensive operation and cache the
1450
     results.
1451
 
1452
 
1453
   The `groups' result is a list of tuples, where each tuple may have
1454
the following fields:
1455
 
1456
`id'
1457
     Identifier of the thread group.  This field is always present.
1458
     The identifier is an opaque string; frontends should not try to
1459
     convert it to an integer, even though it might look like one.
1460
 
1461
`type'
1462
     The type of the thread group.  At present, only `process' is a
1463
     valid type.
1464
 
1465
`pid'
1466
     The target-specific process identifier.  This field is only present
1467
     for thread groups of type `process' and only if the process exists.
1468
 
1469
`num_children'
1470
     The number of children this thread group has.  This field may be
1471
     absent for an available thread group.
1472
 
1473
`threads'
1474
     This field has a list of tuples as value, each tuple describing a
1475
     thread.  It may be present if the `--recurse' option is specified,
1476
     and it's actually possible to obtain the threads.
1477
 
1478
`cores'
1479
     This field is a list of integers, each identifying a core that one
1480
     thread of the group is running on.  This field may be absent if
1481
     such information is not available.
1482
 
1483
`executable'
1484
     The name of the executable file that corresponds to this thread
1485
     group.  The field is only present for thread groups of type
1486
     `process', and only if there is a corresponding executable file.
1487
 
1488
 
1489
Example
1490
-------
1491
 
1492
     gdb
1493
     -list-thread-groups
1494
     ^done,groups=[{id="17",type="process",pid="yyy",num_children="2"}]
1495
     -list-thread-groups 17
1496
     ^done,threads=[{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
1497
        frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]},state="running"},
1498
     {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
1499
        frame={level="0",addr="0x0804891f",func="foo",args=[{name="i",value="10"}],
1500
                file="/tmp/a.c",fullname="/tmp/a.c",line="158"},state="running"}]]
1501
     -list-thread-groups --available
1502
     ^done,groups=[{id="17",type="process",pid="yyy",num_children="2",cores=[1,2]}]
1503
     -list-thread-groups --available --recurse 1
1504
      ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
1505
                     threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]},
1506
                              {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},..]
1507
     -list-thread-groups --available --recurse 1 17 18
1508
     ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
1509
                    threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]},
1510
                             {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},...]
1511
 
1512
The `-add-inferior' Command
1513
---------------------------
1514
 
1515
Synopsis
1516
--------
1517
 
1518
     -add-inferior
1519
 
1520
   Creates a new inferior (*note Inferiors and Programs::).  The created
1521
inferior is not associated with any executable.  Such association may
1522
be established with the `-file-exec-and-symbols' command (*note GDB/MI
1523
File Commands::).  The command response has a single field,
1524
`thread-group', whose value is the identifier of the thread group
1525
corresponding to the new inferior.
1526
 
1527
Example
1528
-------
1529
 
1530
     gdb
1531
     -add-inferior
1532
     ^done,thread-group="i3"
1533
 
1534
The `-interpreter-exec' Command
1535
-------------------------------
1536
 
1537
Synopsis
1538
--------
1539
 
1540
     -interpreter-exec INTERPRETER COMMAND
1541
 
1542
   Execute the specified COMMAND in the given INTERPRETER.
1543
 
1544
GDB Command
1545
-----------
1546
 
1547
The corresponding GDB command is `interpreter-exec'.
1548
 
1549
Example
1550
-------
1551
 
1552
     (gdb)
1553
     -interpreter-exec console "break main"
1554
     &"During symbol reading, couldn't parse type; debugger out of date?.\n"
1555
     &"During symbol reading, bad structure-type format.\n"
1556
     ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
1557
     ^done
1558
     (gdb)
1559
 
1560
The `-inferior-tty-set' Command
1561
-------------------------------
1562
 
1563
Synopsis
1564
--------
1565
 
1566
     -inferior-tty-set /dev/pts/1
1567
 
1568
   Set terminal for future runs of the program being debugged.
1569
 
1570
GDB Command
1571
-----------
1572
 
1573
The corresponding GDB command is `set inferior-tty' /dev/pts/1.
1574
 
1575
Example
1576
-------
1577
 
1578
     (gdb)
1579
     -inferior-tty-set /dev/pts/1
1580
     ^done
1581
     (gdb)
1582
 
1583
The `-inferior-tty-show' Command
1584
--------------------------------
1585
 
1586
Synopsis
1587
--------
1588
 
1589
     -inferior-tty-show
1590
 
1591
   Show terminal for future runs of program being debugged.
1592
 
1593
GDB Command
1594
-----------
1595
 
1596
The corresponding GDB command is `show inferior-tty'.
1597
 
1598
Example
1599
-------
1600
 
1601
     (gdb)
1602
     -inferior-tty-set /dev/pts/1
1603
     ^done
1604
     (gdb)
1605
     -inferior-tty-show
1606
     ^done,inferior_tty_terminal="/dev/pts/1"
1607
     (gdb)
1608
 
1609
The `-enable-timings' Command
1610
-----------------------------
1611
 
1612
Synopsis
1613
--------
1614
 
1615
     -enable-timings [yes | no]
1616
 
1617
   Toggle the printing of the wallclock, user and system times for an MI
1618
command as a field in its output.  This command is to help frontend
1619
developers optimize the performance of their code.  No argument is
1620
equivalent to `yes'.
1621
 
1622
GDB Command
1623
-----------
1624
 
1625
No equivalent.
1626
 
1627
Example
1628
-------
1629
 
1630
     (gdb)
1631
     -enable-timings
1632
     ^done
1633
     (gdb)
1634
     -break-insert main
1635
     ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
1636
     addr="0x080484ed",func="main",file="myprog.c",
1637
     fullname="/home/nickrob/myprog.c",line="73",times="0"},
1638
     time={wallclock="0.05185",user="0.00800",system="0.00000"}
1639
     (gdb)
1640
     -enable-timings no
1641
     ^done
1642
     (gdb)
1643
     -exec-run
1644
     ^running
1645
     (gdb)
1646
     *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
1647
     frame={addr="0x080484ed",func="main",args=[{name="argc",value="1"},
1648
     {name="argv",value="0xbfb60364"}],file="myprog.c",
1649
     fullname="/home/nickrob/myprog.c",line="73"}
1650
     (gdb)
1651
 
1652

1653
File: gdb.info,  Node: Annotations,  Next: JIT Interface,  Prev: GDB/MI,  Up: Top
1654
 
1655
28 GDB Annotations
1656
******************
1657
 
1658
This chapter describes annotations in GDB.  Annotations were designed
1659
to interface GDB to graphical user interfaces or other similar programs
1660
which want to interact with GDB at a relatively high level.
1661
 
1662
   The annotation mechanism has largely been superseded by GDB/MI
1663
(*note GDB/MI::).
1664
 
1665
* Menu:
1666
 
1667
* Annotations Overview::  What annotations are; the general syntax.
1668
* Server Prefix::       Issuing a command without affecting user state.
1669
* Prompting::           Annotations marking GDB's need for input.
1670
* Errors::              Annotations for error messages.
1671
* Invalidation::        Some annotations describe things now invalid.
1672
* Annotations for Running::
1673
                        Whether the program is running, how it stopped, etc.
1674
* Source Annotations::  Annotations describing source code.
1675
 
1676

1677
File: gdb.info,  Node: Annotations Overview,  Next: Server Prefix,  Up: Annotations
1678
 
1679
28.1 What is an Annotation?
1680
===========================
1681
 
1682
Annotations start with a newline character, two `control-z' characters,
1683
and the name of the annotation.  If there is no additional information
1684
associated with this annotation, the name of the annotation is followed
1685
immediately by a newline.  If there is additional information, the name
1686
of the annotation is followed by a space, the additional information,
1687
and a newline.  The additional information cannot contain newline
1688
characters.
1689
 
1690
   Any output not beginning with a newline and two `control-z'
1691
characters denotes literal output from GDB.  Currently there is no need
1692
for GDB to output a newline followed by two `control-z' characters, but
1693
if there was such a need, the annotations could be extended with an
1694
`escape' annotation which means those three characters as output.
1695
 
1696
   The annotation LEVEL, which is specified using the `--annotate'
1697
command line option (*note Mode Options::), controls how much
1698
information GDB prints together with its prompt, values of expressions,
1699
source lines, and other types of output.  Level 0 is for no
1700
annotations, level 1 is for use when GDB is run as a subprocess of GNU
1701
Emacs, level 3 is the maximum annotation suitable for programs that
1702
control GDB, and level 2 annotations have been made obsolete (*note
1703
Limitations of the Annotation Interface: (annotate)Limitations.).
1704
 
1705
`set annotate LEVEL'
1706
     The GDB command `set annotate' sets the level of annotations to
1707
     the specified LEVEL.
1708
 
1709
`show annotate'
1710
     Show the current annotation level.
1711
 
1712
   This chapter describes level 3 annotations.
1713
 
1714
   A simple example of starting up GDB with annotations is:
1715
 
1716
     $ gdb --annotate=3
1717
     GNU gdb 6.0
1718
     Copyright 2003 Free Software Foundation, Inc.
1719
     GDB is free software, covered by the GNU General Public License,
1720
     and you are welcome to change it and/or distribute copies of it
1721
     under certain conditions.
1722
     Type "show copying" to see the conditions.
1723
     There is absolutely no warranty for GDB.  Type "show warranty"
1724
     for details.
1725
     This GDB was configured as "i386-pc-linux-gnu"
1726
 
1727
     ^Z^Zpre-prompt
1728
     (gdb)
1729
     ^Z^Zprompt
1730
     quit
1731
 
1732
     ^Z^Zpost-prompt
1733
     $
1734
 
1735
   Here `quit' is input to GDB; the rest is output from GDB.  The three
1736
lines beginning `^Z^Z' (where `^Z' denotes a `control-z' character) are
1737
annotations; the rest is output from GDB.
1738
 
1739

1740
File: gdb.info,  Node: Server Prefix,  Next: Prompting,  Prev: Annotations Overview,  Up: Annotations
1741
 
1742
28.2 The Server Prefix
1743
======================
1744
 
1745
If you prefix a command with `server ' then it will not affect the
1746
command history, nor will it affect GDB's notion of which command to
1747
repeat if  is pressed on a line by itself.  This means that
1748
commands can be run behind a user's back by a front-end in a
1749
transparent manner.
1750
 
1751
   The `server ' prefix does not affect the recording of values into
1752
the value history; to print a value without recording it into the value
1753
history, use the `output' command instead of the `print' command.
1754
 
1755
   Using this prefix also disables confirmation requests (*note
1756
confirmation requests::).
1757
 
1758

1759
File: gdb.info,  Node: Prompting,  Next: Errors,  Prev: Server Prefix,  Up: Annotations
1760
 
1761
28.3 Annotation for GDB Input
1762
=============================
1763
 
1764
When GDB prompts for input, it annotates this fact so it is possible to
1765
know when to send output, when the output from a given command is over,
1766
etc.
1767
 
1768
   Different kinds of input each have a different "input type".  Each
1769
input type has three annotations: a `pre-' annotation, which denotes
1770
the beginning of any prompt which is being output, a plain annotation,
1771
which denotes the end of the prompt, and then a `post-' annotation
1772
which denotes the end of any echo which may (or may not) be associated
1773
with the input.  For example, the `prompt' input type features the
1774
following annotations:
1775
 
1776
     ^Z^Zpre-prompt
1777
     ^Z^Zprompt
1778
     ^Z^Zpost-prompt
1779
 
1780
   The input types are
1781
 
1782
`prompt'
1783
     When GDB is prompting for a command (the main GDB prompt).
1784
 
1785
`commands'
1786
     When GDB prompts for a set of commands, like in the `commands'
1787
     command.  The annotations are repeated for each command which is
1788
     input.
1789
 
1790
`overload-choice'
1791
     When GDB wants the user to select between various overloaded
1792
     functions.
1793
 
1794
`query'
1795
     When GDB wants the user to confirm a potentially dangerous
1796
     operation.
1797
 
1798
`prompt-for-continue'
1799
     When GDB is asking the user to press return to continue.  Note:
1800
     Don't expect this to work well; instead use `set height 0' to
1801
     disable prompting.  This is because the counting of lines is buggy
1802
     in the presence of annotations.
1803
 
1804

1805
File: gdb.info,  Node: Errors,  Next: Invalidation,  Prev: Prompting,  Up: Annotations
1806
 
1807
28.4 Errors
1808
===========
1809
 
1810
     ^Z^Zquit
1811
 
1812
   This annotation occurs right before GDB responds to an interrupt.
1813
 
1814
     ^Z^Zerror
1815
 
1816
   This annotation occurs right before GDB responds to an error.
1817
 
1818
   Quit and error annotations indicate that any annotations which GDB
1819
was in the middle of may end abruptly.  For example, if a
1820
`value-history-begin' annotation is followed by a `error', one cannot
1821
expect to receive the matching `value-history-end'.  One cannot expect
1822
not to receive it either, however; an error annotation does not
1823
necessarily mean that GDB is immediately returning all the way to the
1824
top level.
1825
 
1826
   A quit or error annotation may be preceded by
1827
 
1828
     ^Z^Zerror-begin
1829
 
1830
   Any output between that and the quit or error annotation is the error
1831
message.
1832
 
1833
   Warning messages are not yet annotated.
1834
 
1835

1836
File: gdb.info,  Node: Invalidation,  Next: Annotations for Running,  Prev: Errors,  Up: Annotations
1837
 
1838
28.5 Invalidation Notices
1839
=========================
1840
 
1841
The following annotations say that certain pieces of state may have
1842
changed.
1843
 
1844
`^Z^Zframes-invalid'
1845
     The frames (for example, output from the `backtrace' command) may
1846
     have changed.
1847
 
1848
`^Z^Zbreakpoints-invalid'
1849
     The breakpoints may have changed.  For example, the user just
1850
     added or deleted a breakpoint.
1851
 
1852

1853
File: gdb.info,  Node: Annotations for Running,  Next: Source Annotations,  Prev: Invalidation,  Up: Annotations
1854
 
1855
28.6 Running the Program
1856
========================
1857
 
1858
When the program starts executing due to a GDB command such as `step'
1859
or `continue',
1860
 
1861
     ^Z^Zstarting
1862
 
1863
   is output.  When the program stops,
1864
 
1865
     ^Z^Zstopped
1866
 
1867
   is output.  Before the `stopped' annotation, a variety of
1868
annotations describe how the program stopped.
1869
 
1870
`^Z^Zexited EXIT-STATUS'
1871
     The program exited, and EXIT-STATUS is the exit status (zero for
1872
     successful exit, otherwise nonzero).
1873
 
1874
`^Z^Zsignalled'
1875
     The program exited with a signal.  After the `^Z^Zsignalled', the
1876
     annotation continues:
1877
 
1878
          INTRO-TEXT
1879
          ^Z^Zsignal-name
1880
          NAME
1881
          ^Z^Zsignal-name-end
1882
          MIDDLE-TEXT
1883
          ^Z^Zsignal-string
1884
          STRING
1885
          ^Z^Zsignal-string-end
1886
          END-TEXT
1887
 
1888
     where NAME is the name of the signal, such as `SIGILL' or
1889
     `SIGSEGV', and STRING is the explanation of the signal, such as
1890
     `Illegal Instruction' or `Segmentation fault'.  INTRO-TEXT,
1891
     MIDDLE-TEXT, and END-TEXT are for the user's benefit and have no
1892
     particular format.
1893
 
1894
`^Z^Zsignal'
1895
     The syntax of this annotation is just like `signalled', but GDB is
1896
     just saying that the program received the signal, not that it was
1897
     terminated with it.
1898
 
1899
`^Z^Zbreakpoint NUMBER'
1900
     The program hit breakpoint number NUMBER.
1901
 
1902
`^Z^Zwatchpoint NUMBER'
1903
     The program hit watchpoint number NUMBER.
1904
 
1905

1906
File: gdb.info,  Node: Source Annotations,  Prev: Annotations for Running,  Up: Annotations
1907
 
1908
28.7 Displaying Source
1909
======================
1910
 
1911
The following annotation is used instead of displaying source code:
1912
 
1913
     ^Z^Zsource FILENAME:LINE:CHARACTER:MIDDLE:ADDR
1914
 
1915
   where FILENAME is an absolute file name indicating which source
1916
file, LINE is the line number within that file (where 1 is the first
1917
line in the file), CHARACTER is the character position within the file
1918
(where 0 is the first character in the file) (for most debug formats
1919
this will necessarily point to the beginning of a line), MIDDLE is
1920
`middle' if ADDR is in the middle of the line, or `beg' if ADDR is at
1921
the beginning of the line, and ADDR is the address in the target
1922
program associated with the source which is being displayed.  ADDR is
1923
in the form `0x' followed by one or more lowercase hex digits (note
1924
that this does not depend on the language).
1925
 
1926

1927
File: gdb.info,  Node: JIT Interface,  Next: GDB Bugs,  Prev: Annotations,  Up: Top
1928
 
1929
29 JIT Compilation Interface
1930
****************************
1931
 
1932
This chapter documents GDB's "just-in-time" (JIT) compilation
1933
interface.  A JIT compiler is a program or library that generates native
1934
executable code at runtime and executes it, usually in order to achieve
1935
good performance while maintaining platform independence.
1936
 
1937
   Programs that use JIT compilation are normally difficult to debug
1938
because portions of their code are generated at runtime, instead of
1939
being loaded from object files, which is where GDB normally finds the
1940
program's symbols and debug information.  In order to debug programs
1941
that use JIT compilation, GDB has an interface that allows the program
1942
to register in-memory symbol files with GDB at runtime.
1943
 
1944
   If you are using GDB to debug a program that uses this interface,
1945
then it should work transparently so long as you have not stripped the
1946
binary.  If you are developing a JIT compiler, then the interface is
1947
documented in the rest of this chapter.  At this time, the only known
1948
client of this interface is the LLVM JIT.
1949
 
1950
   Broadly speaking, the JIT interface mirrors the dynamic loader
1951
interface.  The JIT compiler communicates with GDB by writing data into
1952
a global variable and calling a fuction at a well-known symbol.  When
1953
GDB attaches, it reads a linked list of symbol files from the global
1954
variable to find existing code, and puts a breakpoint in the function
1955
so that it can find out about additional code.
1956
 
1957
* Menu:
1958
 
1959
* Declarations::                Relevant C struct declarations
1960
* Registering Code::            Steps to register code
1961
* Unregistering Code::          Steps to unregister code
1962
 
1963

1964
File: gdb.info,  Node: Declarations,  Next: Registering Code,  Up: JIT Interface
1965
 
1966
29.1 JIT Declarations
1967
=====================
1968
 
1969
These are the relevant struct declarations that a C program should
1970
include to implement the interface:
1971
 
1972
     typedef enum
1973
     {
1974
       JIT_NOACTION = 0,
1975
       JIT_REGISTER_FN,
1976
       JIT_UNREGISTER_FN
1977
     } jit_actions_t;
1978
 
1979
     struct jit_code_entry
1980
     {
1981
       struct jit_code_entry *next_entry;
1982
       struct jit_code_entry *prev_entry;
1983
       const char *symfile_addr;
1984
       uint64_t symfile_size;
1985
     };
1986
 
1987
     struct jit_descriptor
1988
     {
1989
       uint32_t version;
1990
       /* This type should be jit_actions_t, but we use uint32_t
1991
          to be explicit about the bitwidth.  */
1992
       uint32_t action_flag;
1993
       struct jit_code_entry *relevant_entry;
1994
       struct jit_code_entry *first_entry;
1995
     };
1996
 
1997
     /* GDB puts a breakpoint in this function.  */
1998
     void __attribute__((noinline)) __jit_debug_register_code() { };
1999
 
2000
     /* Make sure to specify the version statically, because the
2001
        debugger may check the version before we can set it.  */
2002
     struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
2003
 
2004
   If the JIT is multi-threaded, then it is important that the JIT
2005
synchronize any modifications to this global data properly, which can
2006
easily be done by putting a global mutex around modifications to these
2007
structures.
2008
 
2009

2010
File: gdb.info,  Node: Registering Code,  Next: Unregistering Code,  Prev: Declarations,  Up: JIT Interface
2011
 
2012
29.2 Registering Code
2013
=====================
2014
 
2015
To register code with GDB, the JIT should follow this protocol:
2016
 
2017
   * Generate an object file in memory with symbols and other desired
2018
     debug information.  The file must include the virtual addresses of
2019
     the sections.
2020
 
2021
   * Create a code entry for the file, which gives the start and size
2022
     of the symbol file.
2023
 
2024
   * Add it to the linked list in the JIT descriptor.
2025
 
2026
   * Point the relevant_entry field of the descriptor at the entry.
2027
 
2028
   * Set `action_flag' to `JIT_REGISTER' and call
2029
     `__jit_debug_register_code'.
2030
 
2031
   When GDB is attached and the breakpoint fires, GDB uses the
2032
`relevant_entry' pointer so it doesn't have to walk the list looking for
2033
new code.  However, the linked list must still be maintained in order
2034
to allow GDB to attach to a running process and still find the symbol
2035
files.
2036
 
2037

2038
File: gdb.info,  Node: Unregistering Code,  Prev: Registering Code,  Up: JIT Interface
2039
 
2040
29.3 Unregistering Code
2041
=======================
2042
 
2043
If code is freed, then the JIT should use the following protocol:
2044
 
2045
   * Remove the code entry corresponding to the code from the linked
2046
     list.
2047
 
2048
   * Point the `relevant_entry' field of the descriptor at the code
2049
     entry.
2050
 
2051
   * Set `action_flag' to `JIT_UNREGISTER' and call
2052
     `__jit_debug_register_code'.
2053
 
2054
   If the JIT frees or recompiles code without unregistering it, then
2055
GDB and the JIT will leak the memory used for the associated symbol
2056
files.
2057
 
2058

2059
File: gdb.info,  Node: GDB Bugs,  Next: Command Line Editing,  Prev: JIT Interface,  Up: Top
2060
 
2061
30 Reporting Bugs in GDB
2062
************************
2063
 
2064
Your bug reports play an essential role in making GDB reliable.
2065
 
2066
   Reporting a bug may help you by bringing a solution to your problem,
2067
or it may not.  But in any case the principal function of a bug report
2068
is to help the entire community by making the next version of GDB work
2069
better.  Bug reports are your contribution to the maintenance of GDB.
2070
 
2071
   In order for a bug report to serve its purpose, you must include the
2072
information that enables us to fix the bug.
2073
 
2074
* Menu:
2075
 
2076
* Bug Criteria::                Have you found a bug?
2077
* Bug Reporting::               How to report bugs
2078
 
2079

2080
File: gdb.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: GDB Bugs
2081
 
2082
30.1 Have You Found a Bug?
2083
==========================
2084
 
2085
If you are not sure whether you have found a bug, here are some
2086
guidelines:
2087
 
2088
   * If the debugger gets a fatal signal, for any input whatever, that
2089
     is a GDB bug.  Reliable debuggers never crash.
2090
 
2091
   * If GDB produces an error message for valid input, that is a bug.
2092
     (Note that if you're cross debugging, the problem may also be
2093
     somewhere in the connection to the target.)
2094
 
2095
   * If GDB does not produce an error message for invalid input, that
2096
     is a bug.  However, you should note that your idea of "invalid
2097
     input" might be our idea of "an extension" or "support for
2098
     traditional practice".
2099
 
2100
   * If you are an experienced user of debugging tools, your suggestions
2101
     for improvement of GDB are welcome in any case.
2102
 
2103

2104
File: gdb.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: GDB Bugs
2105
 
2106
30.2 How to Report Bugs
2107
=======================
2108
 
2109
A number of companies and individuals offer support for GNU products.
2110
If you obtained GDB from a support organization, we recommend you
2111
contact that organization first.
2112
 
2113
   You can find contact information for many support companies and
2114
individuals in the file `etc/SERVICE' in the GNU Emacs distribution.
2115
 
2116
   In any event, we also recommend that you submit bug reports for GDB.
2117
The preferred method is to submit them directly using GDB's Bugs web
2118
page (http://www.gnu.org/software/gdb/bugs/).  Alternatively, the
2119
e-mail gateway  can be used.
2120
 
2121
   *Do not send bug reports to `info-gdb', or to `help-gdb', or to any
2122
newsgroups.*  Most users of GDB do not want to receive bug reports.
2123
Those that do have arranged to receive `bug-gdb'.
2124
 
2125
   The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which
2126
serves as a repeater.  The mailing list and the newsgroup carry exactly
2127
the same messages.  Often people think of posting bug reports to the
2128
newsgroup instead of mailing them.  This appears to work, but it has one
2129
problem which can be crucial: a newsgroup posting often lacks a mail
2130
path back to the sender.  Thus, if we need to ask for more information,
2131
we may be unable to reach you.  For this reason, it is better to send
2132
bug reports to the mailing list.
2133
 
2134
   The fundamental principle of reporting bugs usefully is this:
2135
*report all the facts*.  If you are not sure whether to state a fact or
2136
leave it out, state it!
2137
 
2138
   Often people omit facts because they think they know what causes the
2139
problem and assume that some details do not matter.  Thus, you might
2140
assume that the name of the variable you use in an example does not
2141
matter.  Well, probably it does not, but one cannot be sure.  Perhaps
2142
the bug is a stray memory reference which happens to fetch from the
2143
location where that name is stored in memory; perhaps, if the name were
2144
different, the contents of that location would fool the debugger into
2145
doing the right thing despite the bug.  Play it safe and give a
2146
specific, complete example.  That is the easiest thing for you to do,
2147
and the most helpful.
2148
 
2149
   Keep in mind that the purpose of a bug report is to enable us to fix
2150
the bug.  It may be that the bug has been reported previously, but
2151
neither you nor we can know that unless your bug report is complete and
2152
self-contained.
2153
 
2154
   Sometimes people give a few sketchy facts and ask, "Does this ring a
2155
bell?"  Those bug reports are useless, and we urge everyone to _refuse
2156
to respond to them_ except to chide the sender to report bugs properly.
2157
 
2158
   To enable us to fix the bug, you should include all these things:
2159
 
2160
   * The version of GDB.  GDB announces it if you start with no
2161
     arguments; you can also print it at any time using `show version'.
2162
 
2163
     Without this, we will not know whether there is any point in
2164
     looking for the bug in the current version of GDB.
2165
 
2166
   * The type of machine you are using, and the operating system name
2167
     and version number.
2168
 
2169
   * What compiler (and its version) was used to compile GDB--e.g.
2170
     "gcc-2.8.1".
2171
 
2172
   * What compiler (and its version) was used to compile the program
2173
     you are debugging--e.g.  "gcc-2.8.1", or "HP92453-01 A.10.32.03 HP
2174
     C Compiler".  For GCC, you can say `gcc --version' to get this
2175
     information; for other compilers, see the documentation for those
2176
     compilers.
2177
 
2178
   * The command arguments you gave the compiler to compile your
2179
     example and observe the bug.  For example, did you use `-O'?  To
2180
     guarantee you will not omit something important, list them all.  A
2181
     copy of the Makefile (or the output from make) is sufficient.
2182
 
2183
     If we were to try to guess the arguments, we would probably guess
2184
     wrong and then we might not encounter the bug.
2185
 
2186
   * A complete input script, and all necessary source files, that will
2187
     reproduce the bug.
2188
 
2189
   * A description of what behavior you observe that you believe is
2190
     incorrect.  For example, "It gets a fatal signal."
2191
 
2192
     Of course, if the bug is that GDB gets a fatal signal, then we
2193
     will certainly notice it.  But if the bug is incorrect output, we
2194
     might not notice unless it is glaringly wrong.  You might as well
2195
     not give us a chance to make a mistake.
2196
 
2197
     Even if the problem you experience is a fatal signal, you should
2198
     still say so explicitly.  Suppose something strange is going on,
2199
     such as, your copy of GDB is out of synch, or you have encountered
2200
     a bug in the C library on your system.  (This has happened!)  Your
2201
     copy might crash and ours would not.  If you told us to expect a
2202
     crash, then when ours fails to crash, we would know that the bug
2203
     was not happening for us.  If you had not told us to expect a
2204
     crash, then we would not be able to draw any conclusion from our
2205
     observations.
2206
 
2207
     To collect all this information, you can use a session recording
2208
     program such as `script', which is available on many Unix systems.
2209
     Just run your GDB session inside `script' and then include the
2210
     `typescript' file with your bug report.
2211
 
2212
     Another way to record a GDB session is to run GDB inside Emacs and
2213
     then save the entire buffer to a file.
2214
 
2215
   * If you wish to suggest changes to the GDB source, send us context
2216
     diffs.  If you even discuss something in the GDB source, refer to
2217
     it by context, not by line number.
2218
 
2219
     The line numbers in our development sources will not match those
2220
     in your sources.  Your line numbers would convey no useful
2221
     information to us.
2222
 
2223
 
2224
   Here are some things that are not necessary:
2225
 
2226
   * A description of the envelope of the bug.
2227
 
2228
     Often people who encounter a bug spend a lot of time investigating
2229
     which changes to the input file will make the bug go away and which
2230
     changes will not affect it.
2231
 
2232
     This is often time consuming and not very useful, because the way
2233
     we will find the bug is by running a single example under the
2234
     debugger with breakpoints, not by pure deduction from a series of
2235
     examples.  We recommend that you save your time for something else.
2236
 
2237
     Of course, if you can find a simpler example to report _instead_
2238
     of the original one, that is a convenience for us.  Errors in the
2239
     output will be easier to spot, running under the debugger will take
2240
     less time, and so on.
2241
 
2242
     However, simplification is not vital; if you do not want to do
2243
     this, report the bug anyway and send us the entire test case you
2244
     used.
2245
 
2246
   * A patch for the bug.
2247
 
2248
     A patch for the bug does help us if it is a good one.  But do not
2249
     omit the necessary information, such as the test case, on the
2250
     assumption that a patch is all we need.  We might see problems
2251
     with your patch and decide to fix the problem another way, or we
2252
     might not understand it at all.
2253
 
2254
     Sometimes with a program as complicated as GDB it is very hard to
2255
     construct an example that will make the program follow a certain
2256
     path through the code.  If you do not send us the example, we will
2257
     not be able to construct one, so we will not be able to verify
2258
     that the bug is fixed.
2259
 
2260
     And if we cannot understand what bug you are trying to fix, or why
2261
     your patch should be an improvement, we will not install it.  A
2262
     test case will help us to understand.
2263
 
2264
   * A guess about what the bug is or what it depends on.
2265
 
2266
     Such guesses are usually wrong.  Even we cannot guess right about
2267
     such things without first using the debugger to find the facts.
2268
 
2269

2270
File: gdb.info,  Node: Command Line Editing,  Next: Using History Interactively,  Prev: GDB Bugs,  Up: Top
2271
 
2272
31 Command Line Editing
2273
***********************
2274
 
2275
This chapter describes the basic features of the GNU command line
2276
editing interface.
2277
 
2278
* Menu:
2279
 
2280
* Introduction and Notation::   Notation used in this text.
2281
* Readline Interaction::        The minimum set of commands for editing a line.
2282
* Readline Init File::          Customizing Readline from a user's view.
2283
* Bindable Readline Commands::  A description of most of the Readline commands
2284
                                available for binding
2285
* Readline vi Mode::            A short description of how to make Readline
2286
                                behave like the vi editor.
2287
 
2288

2289
File: gdb.info,  Node: Introduction and Notation,  Next: Readline Interaction,  Up: Command Line Editing
2290
 
2291
31.1 Introduction to Line Editing
2292
=================================
2293
 
2294
The following paragraphs describe the notation used to represent
2295
keystrokes.
2296
 
2297
   The text `C-k' is read as `Control-K' and describes the character
2298
produced when the  key is pressed while the Control key is depressed.
2299
 
2300
   The text `M-k' is read as `Meta-K' and describes the character
2301
produced when the Meta key (if you have one) is depressed, and the 
2302
key is pressed.  The Meta key is labeled  on many keyboards.  On
2303
keyboards with two keys labeled  (usually to either side of the
2304
space bar), the  on the left side is generally set to work as a
2305
Meta key.  The  key on the right may also be configured to work as
2306
a Meta key or may be configured as some other modifier, such as a
2307
Compose key for typing accented characters.
2308
 
2309
   If you do not have a Meta or  key, or another key working as a
2310
Meta key, the identical keystroke can be generated by typing 
2311
_first_, and then typing .  Either process is known as "metafying"
2312
the  key.
2313
 
2314
   The text `M-C-k' is read as `Meta-Control-k' and describes the
2315
character produced by "metafying" `C-k'.
2316
 
2317
   In addition, several keys have their own names.  Specifically,
2318
, , , , , and  all stand for themselves
2319
when seen in this text, or in an init file (*note Readline Init File::).
2320
If your keyboard lacks a  key, typing  will produce the
2321
desired character.  The  key may be labeled  or  on
2322
some keyboards.
2323
 
2324

2325
File: gdb.info,  Node: Readline Interaction,  Next: Readline Init File,  Prev: Introduction and Notation,  Up: Command Line Editing
2326
 
2327
31.2 Readline Interaction
2328
=========================
2329
 
2330
Often during an interactive session you type in a long line of text,
2331
only to notice that the first word on the line is misspelled.  The
2332
Readline library gives you a set of commands for manipulating the text
2333
as you type it in, allowing you to just fix your typo, and not forcing
2334
you to retype the majority of the line.  Using these editing commands,
2335
you move the cursor to the place that needs correction, and delete or
2336
insert the text of the corrections.  Then, when you are satisfied with
2337
the line, you simply press .  You do not have to be at the end of
2338
the line to press ; the entire line is accepted regardless of the
2339
location of the cursor within the line.
2340
 
2341
* Menu:
2342
 
2343
* Readline Bare Essentials::    The least you need to know about Readline.
2344
* Readline Movement Commands::  Moving about the input line.
2345
* Readline Killing Commands::   How to delete text, and how to get it back!
2346
* Readline Arguments::          Giving numeric arguments to commands.
2347
* Searching::                   Searching through previous lines.
2348
 
2349

2350
File: gdb.info,  Node: Readline Bare Essentials,  Next: Readline Movement Commands,  Up: Readline Interaction
2351
 
2352
31.2.1 Readline Bare Essentials
2353
-------------------------------
2354
 
2355
In order to enter characters into the line, simply type them.  The typed
2356
character appears where the cursor was, and then the cursor moves one
2357
space to the right.  If you mistype a character, you can use your erase
2358
character to back up and delete the mistyped character.
2359
 
2360
   Sometimes you may mistype a character, and not notice the error
2361
until you have typed several other characters.  In that case, you can
2362
type `C-b' to move the cursor to the left, and then correct your
2363
mistake.  Afterwards, you can move the cursor to the right with `C-f'.
2364
 
2365
   When you add text in the middle of a line, you will notice that
2366
characters to the right of the cursor are `pushed over' to make room
2367
for the text that you have inserted.  Likewise, when you delete text
2368
behind the cursor, characters to the right of the cursor are `pulled
2369
back' to fill in the blank space created by the removal of the text.  A
2370
list of the bare essentials for editing the text of an input line
2371
follows.
2372
 
2373
`C-b'
2374
     Move back one character.
2375
 
2376
`C-f'
2377
     Move forward one character.
2378
 
2379
 or 
2380
     Delete the character to the left of the cursor.
2381
 
2382
`C-d'
2383
     Delete the character underneath the cursor.
2384
 
2385
Printing characters
2386
     Insert the character into the line at the cursor.
2387
 
2388
`C-_' or `C-x C-u'
2389
     Undo the last editing command.  You can undo all the way back to an
2390
     empty line.
2391
 
2392
(Depending on your configuration, the  key be set to delete
2393
the character to the left of the cursor and the  key set to delete
2394
the character underneath the cursor, like `C-d', rather than the
2395
character to the left of the cursor.)
2396
 
2397

2398
File: gdb.info,  Node: Readline Movement Commands,  Next: Readline Killing Commands,  Prev: Readline Bare Essentials,  Up: Readline Interaction
2399
 
2400
31.2.2 Readline Movement Commands
2401
---------------------------------
2402
 
2403
The above table describes the most basic keystrokes that you need in
2404
order to do editing of the input line.  For your convenience, many
2405
other commands have been added in addition to `C-b', `C-f', `C-d', and
2406
.  Here are some commands for moving more rapidly about the line.
2407
 
2408
`C-a'
2409
     Move to the start of the line.
2410
 
2411
`C-e'
2412
     Move to the end of the line.
2413
 
2414
`M-f'
2415
     Move forward a word, where a word is composed of letters and
2416
     digits.
2417
 
2418
`M-b'
2419
     Move backward a word.
2420
 
2421
`C-l'
2422
     Clear the screen, reprinting the current line at the top.
2423
 
2424
   Notice how `C-f' moves forward a character, while `M-f' moves
2425
forward a word.  It is a loose convention that control keystrokes
2426
operate on characters while meta keystrokes operate on words.
2427
 
2428

2429
File: gdb.info,  Node: Readline Killing Commands,  Next: Readline Arguments,  Prev: Readline Movement Commands,  Up: Readline Interaction
2430
 
2431
31.2.3 Readline Killing Commands
2432
--------------------------------
2433
 
2434
"Killing" text means to delete the text from the line, but to save it
2435
away for later use, usually by "yanking" (re-inserting) it back into
2436
the line.  (`Cut' and `paste' are more recent jargon for `kill' and
2437
`yank'.)
2438
 
2439
   If the description for a command says that it `kills' text, then you
2440
can be sure that you can get the text back in a different (or the same)
2441
place later.
2442
 
2443
   When you use a kill command, the text is saved in a "kill-ring".
2444
Any number of consecutive kills save all of the killed text together, so
2445
that when you yank it back, you get it all.  The kill ring is not line
2446
specific; the text that you killed on a previously typed line is
2447
available to be yanked back later, when you are typing another line.
2448
 
2449
   Here is the list of commands for killing text.
2450
 
2451
`C-k'
2452
     Kill the text from the current cursor position to the end of the
2453
     line.
2454
 
2455
`M-d'
2456
     Kill from the cursor to the end of the current word, or, if between
2457
     words, to the end of the next word.  Word boundaries are the same
2458
     as those used by `M-f'.
2459
 
2460
`M-'
2461
     Kill from the cursor the start of the current word, or, if between
2462
     words, to the start of the previous word.  Word boundaries are the
2463
     same as those used by `M-b'.
2464
 
2465
`C-w'
2466
     Kill from the cursor to the previous whitespace.  This is
2467
     different than `M-' because the word boundaries differ.
2468
 
2469
 
2470
   Here is how to "yank" the text back into the line.  Yanking means to
2471
copy the most-recently-killed text from the kill buffer.
2472
 
2473
`C-y'
2474
     Yank the most recently killed text back into the buffer at the
2475
     cursor.
2476
 
2477
`M-y'
2478
     Rotate the kill-ring, and yank the new top.  You can only do this
2479
     if the prior command is `C-y' or `M-y'.
2480
 
2481

2482
File: gdb.info,  Node: Readline Arguments,  Next: Searching,  Prev: Readline Killing Commands,  Up: Readline Interaction
2483
 
2484
31.2.4 Readline Arguments
2485
-------------------------
2486
 
2487
You can pass numeric arguments to Readline commands.  Sometimes the
2488
argument acts as a repeat count, other times it is the sign of the
2489
argument that is significant.  If you pass a negative argument to a
2490
command which normally acts in a forward direction, that command will
2491
act in a backward direction.  For example, to kill text back to the
2492
start of the line, you might type `M-- C-k'.
2493
 
2494
   The general way to pass numeric arguments to a command is to type
2495
meta digits before the command.  If the first `digit' typed is a minus
2496
sign (`-'), then the sign of the argument will be negative.  Once you
2497
have typed one meta digit to get the argument started, you can type the
2498
remainder of the digits, and then the command.  For example, to give
2499
the `C-d' command an argument of 10, you could type `M-1 0 C-d', which
2500
will delete the next ten characters on the input line.
2501
 
2502

2503
File: gdb.info,  Node: Searching,  Prev: Readline Arguments,  Up: Readline Interaction
2504
 
2505
31.2.5 Searching for Commands in the History
2506
--------------------------------------------
2507
 
2508
Readline provides commands for searching through the command history
2509
for lines containing a specified string.  There are two search modes:
2510
"incremental" and "non-incremental".
2511
 
2512
   Incremental searches begin before the user has finished typing the
2513
search string.  As each character of the search string is typed,
2514
Readline displays the next entry from the history matching the string
2515
typed so far.  An incremental search requires only as many characters
2516
as needed to find the desired history entry.  To search backward in the
2517
history for a particular string, type `C-r'.  Typing `C-s' searches
2518
forward through the history.  The characters present in the value of
2519
the `isearch-terminators' variable are used to terminate an incremental
2520
search.  If that variable has not been assigned a value, the  and
2521
`C-J' characters will terminate an incremental search.  `C-g' will
2522
abort an incremental search and restore the original line.  When the
2523
search is terminated, the history entry containing the search string
2524
becomes the current line.
2525
 
2526
   To find other matching entries in the history list, type `C-r' or
2527
`C-s' as appropriate.  This will search backward or forward in the
2528
history for the next entry matching the search string typed so far.
2529
Any other key sequence bound to a Readline command will terminate the
2530
search and execute that command.  For instance, a  will terminate
2531
the search and accept the line, thereby executing the command from the
2532
history list.  A movement command will terminate the search, make the
2533
last line found the current line, and begin editing.
2534
 
2535
   Readline remembers the last incremental search string.  If two
2536
`C-r's are typed without any intervening characters defining a new
2537
search string, any remembered search string is used.
2538
 
2539
   Non-incremental searches read the entire search string before
2540
starting to search for matching history lines.  The search string may be
2541
typed by the user or be part of the contents of the current line.
2542
 
2543

2544
File: gdb.info,  Node: Readline Init File,  Next: Bindable Readline Commands,  Prev: Readline Interaction,  Up: Command Line Editing
2545
 
2546
31.3 Readline Init File
2547
=======================
2548
 
2549
Although the Readline library comes with a set of Emacs-like
2550
keybindings installed by default, it is possible to use a different set
2551
of keybindings.  Any user can customize programs that use Readline by
2552
putting commands in an "inputrc" file, conventionally in his home
2553
directory.  The name of this file is taken from the value of the
2554
environment variable `INPUTRC'.  If that variable is unset, the default
2555
is `~/.inputrc'.
2556
 
2557
   When a program which uses the Readline library starts up, the init
2558
file is read, and the key bindings are set.
2559
 
2560
   In addition, the `C-x C-r' command re-reads this init file, thus
2561
incorporating any changes that you might have made to it.
2562
 
2563
* Menu:
2564
 
2565
* Readline Init File Syntax::   Syntax for the commands in the inputrc file.
2566
 
2567
* Conditional Init Constructs:: Conditional key bindings in the inputrc file.
2568
 
2569
* Sample Init File::            An example inputrc file.
2570
 
2571

2572
File: gdb.info,  Node: Readline Init File Syntax,  Next: Conditional Init Constructs,  Up: Readline Init File
2573
 
2574
31.3.1 Readline Init File Syntax
2575
--------------------------------
2576
 
2577
There are only a few basic constructs allowed in the Readline init
2578
file.  Blank lines are ignored.  Lines beginning with a `#' are
2579
comments.  Lines beginning with a `$' indicate conditional constructs
2580
(*note Conditional Init Constructs::).  Other lines denote variable
2581
settings and key bindings.
2582
 
2583
Variable Settings
2584
     You can modify the run-time behavior of Readline by altering the
2585
     values of variables in Readline using the `set' command within the
2586
     init file.  The syntax is simple:
2587
 
2588
          set VARIABLE VALUE
2589
 
2590
     Here, for example, is how to change from the default Emacs-like
2591
     key binding to use `vi' line editing commands:
2592
 
2593
          set editing-mode vi
2594
 
2595
     Variable names and values, where appropriate, are recognized
2596
     without regard to case.  Unrecognized variable names are ignored.
2597
 
2598
     Boolean variables (those that can be set to on or off) are set to
2599
     on if the value is null or empty, ON (case-insensitive), or 1.
2600
     Any other value results in the variable being set to off.
2601
 
2602
     A great deal of run-time behavior is changeable with the following
2603
     variables.
2604
 
2605
    `bell-style'
2606
          Controls what happens when Readline wants to ring the
2607
          terminal bell.  If set to `none', Readline never rings the
2608
          bell.  If set to `visible', Readline uses a visible bell if
2609
          one is available.  If set to `audible' (the default),
2610
          Readline attempts to ring the terminal's bell.
2611
 
2612
    `bind-tty-special-chars'
2613
          If set to `on', Readline attempts to bind the control
2614
          characters treated specially by the kernel's terminal driver
2615
          to their Readline equivalents.
2616
 
2617
    `comment-begin'
2618
          The string to insert at the beginning of the line when the
2619
          `insert-comment' command is executed.  The default value is
2620
          `"#"'.
2621
 
2622
    `completion-ignore-case'
2623
          If set to `on', Readline performs filename matching and
2624
          completion in a case-insensitive fashion.  The default value
2625
          is `off'.
2626
 
2627
    `completion-query-items'
2628
          The number of possible completions that determines when the
2629
          user is asked whether the list of possibilities should be
2630
          displayed.  If the number of possible completions is greater
2631
          than this value, Readline will ask the user whether or not he
2632
          wishes to view them; otherwise, they are simply listed.  This
2633
          variable must be set to an integer value greater than or
2634
          equal to 0.  A negative value means Readline should never ask.
2635
          The default limit is `100'.
2636
 
2637
    `convert-meta'
2638
          If set to `on', Readline will convert characters with the
2639
          eighth bit set to an ASCII key sequence by stripping the
2640
          eighth bit and prefixing an  character, converting them
2641
          to a meta-prefixed key sequence.  The default value is `on'.
2642
 
2643
    `disable-completion'
2644
          If set to `On', Readline will inhibit word completion.
2645
          Completion  characters will be inserted into the line as if
2646
          they had been mapped to `self-insert'.  The default is `off'.
2647
 
2648
    `editing-mode'
2649
          The `editing-mode' variable controls which default set of key
2650
          bindings is used.  By default, Readline starts up in Emacs
2651
          editing mode, where the keystrokes are most similar to Emacs.
2652
          This variable can be set to either `emacs' or `vi'.
2653
 
2654
    `enable-keypad'
2655
          When set to `on', Readline will try to enable the application
2656
          keypad when it is called.  Some systems need this to enable
2657
          the arrow keys.  The default is `off'.
2658
 
2659
    `expand-tilde'
2660
          If set to `on', tilde expansion is performed when Readline
2661
          attempts word completion.  The default is `off'.
2662
 
2663
    `history-preserve-point'
2664
          If set to `on', the history code attempts to place point at
2665
          the same location on each history line retrieved with
2666
          `previous-history' or `next-history'.  The default is `off'.
2667
 
2668
    `horizontal-scroll-mode'
2669
          This variable can be set to either `on' or `off'.  Setting it
2670
          to `on' means that the text of the lines being edited will
2671
          scroll horizontally on a single screen line when they are
2672
          longer than the width of the screen, instead of wrapping onto
2673
          a new screen line.  By default, this variable is set to `off'.
2674
 
2675
    `input-meta'
2676
          If set to `on', Readline will enable eight-bit input (it will
2677
          not clear the eighth bit in the characters it reads),
2678
          regardless of what the terminal claims it can support.  The
2679
          default value is `off'.  The name `meta-flag' is a synonym
2680
          for this variable.
2681
 
2682
    `isearch-terminators'
2683
          The string of characters that should terminate an incremental
2684
          search without subsequently executing the character as a
2685
          command (*note Searching::).  If this variable has not been
2686
          given a value, the characters  and `C-J' will terminate
2687
          an incremental search.
2688
 
2689
    `keymap'
2690
          Sets Readline's idea of the current keymap for key binding
2691
          commands.  Acceptable `keymap' names are `emacs',
2692
          `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
2693
          `vi-command', and `vi-insert'.  `vi' is equivalent to
2694
          `vi-command'; `emacs' is equivalent to `emacs-standard'.  The
2695
          default value is `emacs'.  The value of the `editing-mode'
2696
          variable also affects the default keymap.
2697
 
2698
    `mark-directories'
2699
          If set to `on', completed directory names have a slash
2700
          appended.  The default is `on'.
2701
 
2702
    `mark-modified-lines'
2703
          This variable, when set to `on', causes Readline to display an
2704
          asterisk (`*') at the start of history lines which have been
2705
          modified.  This variable is `off' by default.
2706
 
2707
    `mark-symlinked-directories'
2708
          If set to `on', completed names which are symbolic links to
2709
          directories have a slash appended (subject to the value of
2710
          `mark-directories').  The default is `off'.
2711
 
2712
    `match-hidden-files'
2713
          This variable, when set to `on', causes Readline to match
2714
          files whose names begin with a `.' (hidden files) when
2715
          performing filename completion, unless the leading `.' is
2716
          supplied by the user in the filename to be completed.  This
2717
          variable is `on' by default.
2718
 
2719
    `output-meta'
2720
          If set to `on', Readline will display characters with the
2721
          eighth bit set directly rather than as a meta-prefixed escape
2722
          sequence.  The default is `off'.
2723
 
2724
    `page-completions'
2725
          If set to `on', Readline uses an internal `more'-like pager
2726
          to display a screenful of possible completions at a time.
2727
          This variable is `on' by default.
2728
 
2729
    `print-completions-horizontally'
2730
          If set to `on', Readline will display completions with matches
2731
          sorted horizontally in alphabetical order, rather than down
2732
          the screen.  The default is `off'.
2733
 
2734
    `show-all-if-ambiguous'
2735
          This alters the default behavior of the completion functions.
2736
          If set to `on', words which have more than one possible
2737
          completion cause the matches to be listed immediately instead
2738
          of ringing the bell.  The default value is `off'.
2739
 
2740
    `show-all-if-unmodified'
2741
          This alters the default behavior of the completion functions
2742
          in a fashion similar to SHOW-ALL-IF-AMBIGUOUS.  If set to
2743
          `on', words which have more than one possible completion
2744
          without any possible partial completion (the possible
2745
          completions don't share a common prefix) cause the matches to
2746
          be listed immediately instead of ringing the bell.  The
2747
          default value is `off'.
2748
 
2749
    `visible-stats'
2750
          If set to `on', a character denoting a file's type is
2751
          appended to the filename when listing possible completions.
2752
          The default is `off'.
2753
 
2754
 
2755
Key Bindings
2756
     The syntax for controlling key bindings in the init file is
2757
     simple.  First you need to find the name of the command that you
2758
     want to change.  The following sections contain tables of the
2759
     command name, the default keybinding, if any, and a short
2760
     description of what the command does.
2761
 
2762
     Once you know the name of the command, simply place on a line in
2763
     the init file the name of the key you wish to bind the command to,
2764
     a colon, and then the name of the command.  The name of the key
2765
     can be expressed in different ways, depending on what you find most
2766
     comfortable.
2767
 
2768
     In addition to command names, readline allows keys to be bound to
2769
     a string that is inserted when the key is pressed (a MACRO).
2770
 
2771
    KEYNAME: FUNCTION-NAME or MACRO
2772
          KEYNAME is the name of a key spelled out in English.  For
2773
          example:
2774
               Control-u: universal-argument
2775
               Meta-Rubout: backward-kill-word
2776
               Control-o: "> output"
2777
 
2778
          In the above example, `C-u' is bound to the function
2779
          `universal-argument', `M-DEL' is bound to the function
2780
          `backward-kill-word', and `C-o' is bound to run the macro
2781
          expressed on the right hand side (that is, to insert the text
2782
          `> output' into the line).
2783
 
2784
          A number of symbolic character names are recognized while
2785
          processing this key binding syntax: DEL, ESC, ESCAPE, LFD,
2786
          NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB.
2787
 
2788
    "KEYSEQ": FUNCTION-NAME or MACRO
2789
          KEYSEQ differs from KEYNAME above in that strings denoting an
2790
          entire key sequence can be specified, by placing the key
2791
          sequence in double quotes.  Some GNU Emacs style key escapes
2792
          can be used, as in the following example, but the special
2793
          character names are not recognized.
2794
 
2795
               "\C-u": universal-argument
2796
               "\C-x\C-r": re-read-init-file
2797
               "\e[11~": "Function Key 1"
2798
 
2799
          In the above example, `C-u' is again bound to the function
2800
          `universal-argument' (just as it was in the first example),
2801
          `C-x C-r' is bound to the function `re-read-init-file', and
2802
          ` <[> <1> <1> <~>' is bound to insert the text `Function
2803
          Key 1'.
2804
 
2805
 
2806
     The following GNU Emacs style escape sequences are available when
2807
     specifying key sequences:
2808
 
2809
    `\C-'
2810
          control prefix
2811
 
2812
    `\M-'
2813
          meta prefix
2814
 
2815
    `\e'
2816
          an escape character
2817
 
2818
    `\\'
2819
          backslash
2820
 
2821
    `\"'
2822
          <">, a double quotation mark
2823
 
2824
    `\''
2825
          <'>, a single quote or apostrophe
2826
 
2827
     In addition to the GNU Emacs style escape sequences, a second set
2828
     of backslash escapes is available:
2829
 
2830
    `\a'
2831
          alert (bell)
2832
 
2833
    `\b'
2834
          backspace
2835
 
2836
    `\d'
2837
          delete
2838
 
2839
    `\f'
2840
          form feed
2841
 
2842
    `\n'
2843
          newline
2844
 
2845
    `\r'
2846
          carriage return
2847
 
2848
    `\t'
2849
          horizontal tab
2850
 
2851
    `\v'
2852
          vertical tab
2853
 
2854
    `\NNN'
2855
          the eight-bit character whose value is the octal value NNN
2856
          (one to three digits)
2857
 
2858
    `\xHH'
2859
          the eight-bit character whose value is the hexadecimal value
2860
          HH (one or two hex digits)
2861
 
2862
     When entering the text of a macro, single or double quotes must be
2863
     used to indicate a macro definition.  Unquoted text is assumed to
2864
     be a function name.  In the macro body, the backslash escapes
2865
     described above are expanded.  Backslash will quote any other
2866
     character in the macro text, including `"' and `''.  For example,
2867
     the following binding will make `C-x \' insert a single `\' into
2868
     the line:
2869
          "\C-x\\": "\\"
2870
 
2871
 
2872

2873
File: gdb.info,  Node: Conditional Init Constructs,  Next: Sample Init File,  Prev: Readline Init File Syntax,  Up: Readline Init File
2874
 
2875
31.3.2 Conditional Init Constructs
2876
----------------------------------
2877
 
2878
Readline implements a facility similar in spirit to the conditional
2879
compilation features of the C preprocessor which allows key bindings
2880
and variable settings to be performed as the result of tests.  There
2881
are four parser directives used.
2882
 
2883
`$if'
2884
     The `$if' construct allows bindings to be made based on the
2885
     editing mode, the terminal being used, or the application using
2886
     Readline.  The text of the test extends to the end of the line; no
2887
     characters are required to isolate it.
2888
 
2889
    `mode'
2890
          The `mode=' form of the `$if' directive is used to test
2891
          whether Readline is in `emacs' or `vi' mode.  This may be
2892
          used in conjunction with the `set keymap' command, for
2893
          instance, to set bindings in the `emacs-standard' and
2894
          `emacs-ctlx' keymaps only if Readline is starting out in
2895
          `emacs' mode.
2896
 
2897
    `term'
2898
          The `term=' form may be used to include terminal-specific key
2899
          bindings, perhaps to bind the key sequences output by the
2900
          terminal's function keys.  The word on the right side of the
2901
          `=' is tested against both the full name of the terminal and
2902
          the portion of the terminal name before the first `-'.  This
2903
          allows `sun' to match both `sun' and `sun-cmd', for instance.
2904
 
2905
    `application'
2906
          The APPLICATION construct is used to include
2907
          application-specific settings.  Each program using the
2908
          Readline library sets the APPLICATION NAME, and you can test
2909
          for a particular value.  This could be used to bind key
2910
          sequences to functions useful for a specific program.  For
2911
          instance, the following command adds a key sequence that
2912
          quotes the current or previous word in Bash:
2913
               $if Bash
2914
               # Quote the current or previous word
2915
               "\C-xq": "\eb\"\ef\""
2916
               $endif
2917
 
2918
`$endif'
2919
     This command, as seen in the previous example, terminates an `$if'
2920
     command.
2921
 
2922
`$else'
2923
     Commands in this branch of the `$if' directive are executed if the
2924
     test fails.
2925
 
2926
`$include'
2927
     This directive takes a single filename as an argument and reads
2928
     commands and bindings from that file.  For example, the following
2929
     directive reads from `/etc/inputrc':
2930
          $include /etc/inputrc
2931
 
2932

2933
File: gdb.info,  Node: Sample Init File,  Prev: Conditional Init Constructs,  Up: Readline Init File
2934
 
2935
31.3.3 Sample Init File
2936
-----------------------
2937
 
2938
Here is an example of an INPUTRC file.  This illustrates key binding,
2939
variable assignment, and conditional syntax.
2940
 
2941
 
2942
     # This file controls the behaviour of line input editing for
2943
     # programs that use the GNU Readline library.  Existing
2944
     # programs include FTP, Bash, and GDB.
2945
     #
2946
     # You can re-read the inputrc file with C-x C-r.
2947
     # Lines beginning with '#' are comments.
2948
     #
2949
     # First, include any systemwide bindings and variable
2950
     # assignments from /etc/Inputrc
2951
     $include /etc/Inputrc
2952
 
2953
     #
2954
     # Set various bindings for emacs mode.
2955
 
2956
     set editing-mode emacs
2957
 
2958
     $if mode=emacs
2959
 
2960
     Meta-Control-h:    backward-kill-word      Text after the function name is ignored
2961
 
2962
     #
2963
     # Arrow keys in keypad mode
2964
     #
2965
     #"\M-OD":        backward-char
2966
     #"\M-OC":        forward-char
2967
     #"\M-OA":        previous-history
2968
     #"\M-OB":        next-history
2969
     #
2970
     # Arrow keys in ANSI mode
2971
     #
2972
     "\M-[D":        backward-char
2973
     "\M-[C":        forward-char
2974
     "\M-[A":        previous-history
2975
     "\M-[B":        next-history
2976
     #
2977
     # Arrow keys in 8 bit keypad mode
2978
     #
2979
     #"\M-\C-OD":       backward-char
2980
     #"\M-\C-OC":       forward-char
2981
     #"\M-\C-OA":       previous-history
2982
     #"\M-\C-OB":       next-history
2983
     #
2984
     # Arrow keys in 8 bit ANSI mode
2985
     #
2986
     #"\M-\C-[D":       backward-char
2987
     #"\M-\C-[C":       forward-char
2988
     #"\M-\C-[A":       previous-history
2989
     #"\M-\C-[B":       next-history
2990
 
2991
     C-q: quoted-insert
2992
 
2993
     $endif
2994
 
2995
     # An old-style binding.  This happens to be the default.
2996
     TAB: complete
2997
 
2998
     # Macros that are convenient for shell interaction
2999
     $if Bash
3000
     # edit the path
3001
     "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
3002
     # prepare to type a quoted word --
3003
     # insert open and close double quotes
3004
     # and move to just after the open quote
3005
     "\C-x\"": "\"\"\C-b"
3006
     # insert a backslash (testing backslash escapes
3007
     # in sequences and macros)
3008
     "\C-x\\": "\\"
3009
     # Quote the current or previous word
3010
     "\C-xq": "\eb\"\ef\""
3011
     # Add a binding to refresh the line, which is unbound
3012
     "\C-xr": redraw-current-line
3013
     # Edit variable on current line.
3014
     "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
3015
     $endif
3016
 
3017
     # use a visible bell if one is available
3018
     set bell-style visible
3019
 
3020
     # don't strip characters to 7 bits when reading
3021
     set input-meta on
3022
 
3023
     # allow iso-latin1 characters to be inserted rather
3024
     # than converted to prefix-meta sequences
3025
     set convert-meta off
3026
 
3027
     # display characters with the eighth bit set directly
3028
     # rather than as meta-prefixed characters
3029
     set output-meta on
3030
 
3031
     # if there are more than 150 possible completions for
3032
     # a word, ask the user if he wants to see all of them
3033
     set completion-query-items 150
3034
 
3035
     # For FTP
3036
     $if Ftp
3037
     "\C-xg": "get \M-?"
3038
     "\C-xt": "put \M-?"
3039
     "\M-.": yank-last-arg
3040
     $endif
3041
 
3042

3043
File: gdb.info,  Node: Bindable Readline Commands,  Next: Readline vi Mode,  Prev: Readline Init File,  Up: Command Line Editing
3044
 
3045
31.4 Bindable Readline Commands
3046
===============================
3047
 
3048
* Menu:
3049
 
3050
* Commands For Moving::         Moving about the line.
3051
* Commands For History::        Getting at previous lines.
3052
* Commands For Text::           Commands for changing text.
3053
* Commands For Killing::        Commands for killing and yanking.
3054
* Numeric Arguments::           Specifying numeric arguments, repeat counts.
3055
* Commands For Completion::     Getting Readline to do the typing for you.
3056
* Keyboard Macros::             Saving and re-executing typed characters
3057
* Miscellaneous Commands::      Other miscellaneous commands.
3058
 
3059
   This section describes Readline commands that may be bound to key
3060
sequences.  Command names without an accompanying key sequence are
3061
unbound by default.
3062
 
3063
   In the following descriptions, "point" refers to the current cursor
3064
position, and "mark" refers to a cursor position saved by the
3065
`set-mark' command.  The text between the point and mark is referred to
3066
as the "region".
3067
 
3068

3069
File: gdb.info,  Node: Commands For Moving,  Next: Commands For History,  Up: Bindable Readline Commands
3070
 
3071
31.4.1 Commands For Moving
3072
--------------------------
3073
 
3074
`beginning-of-line (C-a)'
3075
     Move to the start of the current line.
3076
 
3077
`end-of-line (C-e)'
3078
     Move to the end of the line.
3079
 
3080
`forward-char (C-f)'
3081
     Move forward a character.
3082
 
3083
`backward-char (C-b)'
3084
     Move back a character.
3085
 
3086
`forward-word (M-f)'
3087
     Move forward to the end of the next word.  Words are composed of
3088
     letters and digits.
3089
 
3090
`backward-word (M-b)'
3091
     Move back to the start of the current or previous word.  Words are
3092
     composed of letters and digits.
3093
 
3094
`clear-screen (C-l)'
3095
     Clear the screen and redraw the current line, leaving the current
3096
     line at the top of the screen.
3097
 
3098
`redraw-current-line ()'
3099
     Refresh the current line.  By default, this is unbound.
3100
 
3101
 
3102

3103
File: gdb.info,  Node: Commands For History,  Next: Commands For Text,  Prev: Commands For Moving,  Up: Bindable Readline Commands
3104
 
3105
31.4.2 Commands For Manipulating The History
3106
--------------------------------------------
3107
 
3108
`accept-line (Newline or Return)'
3109
     Accept the line regardless of where the cursor is.  If this line is
3110
     non-empty, it may be added to the history list for future recall
3111
     with `add_history()'.  If this line is a modified history line,
3112
     the history line is restored to its original state.
3113
 
3114
`previous-history (C-p)'
3115
     Move `back' through the history list, fetching the previous
3116
     command.
3117
 
3118
`next-history (C-n)'
3119
     Move `forward' through the history list, fetching the next command.
3120
 
3121
`beginning-of-history (M-<)'
3122
     Move to the first line in the history.
3123
 
3124
`end-of-history (M->)'
3125
     Move to the end of the input history, i.e., the line currently
3126
     being entered.
3127
 
3128
`reverse-search-history (C-r)'
3129
     Search backward starting at the current line and moving `up'
3130
     through the history as necessary.  This is an incremental search.
3131
 
3132
`forward-search-history (C-s)'
3133
     Search forward starting at the current line and moving `down'
3134
     through the the history as necessary.  This is an incremental
3135
     search.
3136
 
3137
`non-incremental-reverse-search-history (M-p)'
3138
     Search backward starting at the current line and moving `up'
3139
     through the history as necessary using a non-incremental search
3140
     for a string supplied by the user.
3141
 
3142
`non-incremental-forward-search-history (M-n)'
3143
     Search forward starting at the current line and moving `down'
3144
     through the the history as necessary using a non-incremental search
3145
     for a string supplied by the user.
3146
 
3147
`history-search-forward ()'
3148
     Search forward through the history for the string of characters
3149
     between the start of the current line and the point.  This is a
3150
     non-incremental search.  By default, this command is unbound.
3151
 
3152
`history-search-backward ()'
3153
     Search backward through the history for the string of characters
3154
     between the start of the current line and the point.  This is a
3155
     non-incremental search.  By default, this command is unbound.
3156
 
3157
`yank-nth-arg (M-C-y)'
3158
     Insert the first argument to the previous command (usually the
3159
     second word on the previous line) at point.  With an argument N,
3160
     insert the Nth word from the previous command (the words in the
3161
     previous command begin with word 0).  A negative argument inserts
3162
     the Nth word from the end of the previous command.  Once the
3163
     argument N is computed, the argument is extracted as if the `!N'
3164
     history expansion had been specified.
3165
 
3166
`yank-last-arg (M-. or M-_)'
3167
     Insert last argument to the previous command (the last word of the
3168
     previous history entry).  With an argument, behave exactly like
3169
     `yank-nth-arg'.  Successive calls to `yank-last-arg' move back
3170
     through the history list, inserting the last argument of each line
3171
     in turn.  The history expansion facilities are used to extract the
3172
     last argument, as if the `!$' history expansion had been specified.
3173
 
3174
 
3175

3176
File: gdb.info,  Node: Commands For Text,  Next: Commands For Killing,  Prev: Commands For History,  Up: Bindable Readline Commands
3177
 
3178
31.4.3 Commands For Changing Text
3179
---------------------------------
3180
 
3181
`delete-char (C-d)'
3182
     Delete the character at point.  If point is at the beginning of
3183
     the line, there are no characters in the line, and the last
3184
     character typed was not bound to `delete-char', then return EOF.
3185
 
3186
`backward-delete-char (Rubout)'
3187
     Delete the character behind the cursor.  A numeric argument means
3188
     to kill the characters instead of deleting them.
3189
 
3190
`forward-backward-delete-char ()'
3191
     Delete the character under the cursor, unless the cursor is at the
3192
     end of the line, in which case the character behind the cursor is
3193
     deleted.  By default, this is not bound to a key.
3194
 
3195
`quoted-insert (C-q or C-v)'
3196
     Add the next character typed to the line verbatim.  This is how to
3197
     insert key sequences like `C-q', for example.
3198
 
3199
`tab-insert (M-)'
3200
     Insert a tab character.
3201
 
3202
`self-insert (a, b, A, 1, !, ...)'
3203
     Insert yourself.
3204
 
3205
`transpose-chars (C-t)'
3206
     Drag the character before the cursor forward over the character at
3207
     the cursor, moving the cursor forward as well.  If the insertion
3208
     point is at the end of the line, then this transposes the last two
3209
     characters of the line.  Negative arguments have no effect.
3210
 
3211
`transpose-words (M-t)'
3212
     Drag the word before point past the word after point, moving point
3213
     past that word as well.  If the insertion point is at the end of
3214
     the line, this transposes the last two words on the line.
3215
 
3216
`upcase-word (M-u)'
3217
     Uppercase the current (or following) word.  With a negative
3218
     argument, uppercase the previous word, but do not move the cursor.
3219
 
3220
`downcase-word (M-l)'
3221
     Lowercase the current (or following) word.  With a negative
3222
     argument, lowercase the previous word, but do not move the cursor.
3223
 
3224
`capitalize-word (M-c)'
3225
     Capitalize the current (or following) word.  With a negative
3226
     argument, capitalize the previous word, but do not move the cursor.
3227
 
3228
`overwrite-mode ()'
3229
     Toggle overwrite mode.  With an explicit positive numeric argument,
3230
     switches to overwrite mode.  With an explicit non-positive numeric
3231
     argument, switches to insert mode.  This command affects only
3232
     `emacs' mode; `vi' mode does overwrite differently.  Each call to
3233
     `readline()' starts in insert mode.
3234
 
3235
     In overwrite mode, characters bound to `self-insert' replace the
3236
     text at point rather than pushing the text to the right.
3237
     Characters bound to `backward-delete-char' replace the character
3238
     before point with a space.
3239
 
3240
     By default, this command is unbound.
3241
 
3242
 
3243

3244
File: gdb.info,  Node: Commands For Killing,  Next: Numeric Arguments,  Prev: Commands For Text,  Up: Bindable Readline Commands
3245
 
3246
31.4.4 Killing And Yanking
3247
--------------------------
3248
 
3249
`kill-line (C-k)'
3250
     Kill the text from point to the end of the line.
3251
 
3252
`backward-kill-line (C-x Rubout)'
3253
     Kill backward to the beginning of the line.
3254
 
3255
`unix-line-discard (C-u)'
3256
     Kill backward from the cursor to the beginning of the current line.
3257
 
3258
`kill-whole-line ()'
3259
     Kill all characters on the current line, no matter where point is.
3260
     By default, this is unbound.
3261
 
3262
`kill-word (M-d)'
3263
     Kill from point to the end of the current word, or if between
3264
     words, to the end of the next word.  Word boundaries are the same
3265
     as `forward-word'.
3266
 
3267
`backward-kill-word (M-)'
3268
     Kill the word behind point.  Word boundaries are the same as
3269
     `backward-word'.
3270
 
3271
`unix-word-rubout (C-w)'
3272
     Kill the word behind point, using white space as a word boundary.
3273
     The killed text is saved on the kill-ring.
3274
 
3275
`unix-filename-rubout ()'
3276
     Kill the word behind point, using white space and the slash
3277
     character as the word boundaries.  The killed text is saved on the
3278
     kill-ring.
3279
 
3280
`delete-horizontal-space ()'
3281
     Delete all spaces and tabs around point.  By default, this is
3282
     unbound.
3283
 
3284
`kill-region ()'
3285
     Kill the text in the current region.  By default, this command is
3286
     unbound.
3287
 
3288
`copy-region-as-kill ()'
3289
     Copy the text in the region to the kill buffer, so it can be yanked
3290
     right away.  By default, this command is unbound.
3291
 
3292
`copy-backward-word ()'
3293
     Copy the word before point to the kill buffer.  The word
3294
     boundaries are the same as `backward-word'.  By default, this
3295
     command is unbound.
3296
 
3297
`copy-forward-word ()'
3298
     Copy the word following point to the kill buffer.  The word
3299
     boundaries are the same as `forward-word'.  By default, this
3300
     command is unbound.
3301
 
3302
`yank (C-y)'
3303
     Yank the top of the kill ring into the buffer at point.
3304
 
3305
`yank-pop (M-y)'
3306
     Rotate the kill-ring, and yank the new top.  You can only do this
3307
     if the prior command is `yank' or `yank-pop'.
3308
 
3309

3310
File: gdb.info,  Node: Numeric Arguments,  Next: Commands For Completion,  Prev: Commands For Killing,  Up: Bindable Readline Commands
3311
 
3312
31.4.5 Specifying Numeric Arguments
3313
-----------------------------------
3314
 
3315
`digit-argument (M-0, M-1, ... M--)'
3316
     Add this digit to the argument already accumulating, or start a new
3317
     argument.  `M--' starts a negative argument.
3318
 
3319
`universal-argument ()'
3320
     This is another way to specify an argument.  If this command is
3321
     followed by one or more digits, optionally with a leading minus
3322
     sign, those digits define the argument.  If the command is
3323
     followed by digits, executing `universal-argument' again ends the
3324
     numeric argument, but is otherwise ignored.  As a special case, if
3325
     this command is immediately followed by a character that is
3326
     neither a digit or minus sign, the argument count for the next
3327
     command is multiplied by four.  The argument count is initially
3328
     one, so executing this function the first time makes the argument
3329
     count four, a second time makes the argument count sixteen, and so
3330
     on.  By default, this is not bound to a key.
3331
 
3332

3333
File: gdb.info,  Node: Commands For Completion,  Next: Keyboard Macros,  Prev: Numeric Arguments,  Up: Bindable Readline Commands
3334
 
3335
31.4.6 Letting Readline Type For You
3336
------------------------------------
3337
 
3338
`complete ()'
3339
     Attempt to perform completion on the text before point.  The
3340
     actual completion performed is application-specific.  The default
3341
     is filename completion.
3342
 
3343
`possible-completions (M-?)'
3344
     List the possible completions of the text before point.
3345
 
3346
`insert-completions (M-*)'
3347
     Insert all completions of the text before point that would have
3348
     been generated by `possible-completions'.
3349
 
3350
`menu-complete ()'
3351
     Similar to `complete', but replaces the word to be completed with
3352
     a single match from the list of possible completions.  Repeated
3353
     execution of `menu-complete' steps through the list of possible
3354
     completions, inserting each match in turn.  At the end of the list
3355
     of completions, the bell is rung (subject to the setting of
3356
     `bell-style') and the original text is restored.  An argument of N
3357
     moves N positions forward in the list of matches; a negative
3358
     argument may be used to move backward through the list.  This
3359
     command is intended to be bound to , but is unbound by
3360
     default.
3361
 
3362
`delete-char-or-list ()'
3363
     Deletes the character under the cursor if not at the beginning or
3364
     end of the line (like `delete-char').  If at the end of the line,
3365
     behaves identically to `possible-completions'.  This command is
3366
     unbound by default.
3367
 
3368
 
3369

3370
File: gdb.info,  Node: Keyboard Macros,  Next: Miscellaneous Commands,  Prev: Commands For Completion,  Up: Bindable Readline Commands
3371
 
3372
31.4.7 Keyboard Macros
3373
----------------------
3374
 
3375
`start-kbd-macro (C-x ()'
3376
     Begin saving the characters typed into the current keyboard macro.
3377
 
3378
`end-kbd-macro (C-x ))'
3379
     Stop saving the characters typed into the current keyboard macro
3380
     and save the definition.
3381
 
3382
`call-last-kbd-macro (C-x e)'
3383
     Re-execute the last keyboard macro defined, by making the
3384
     characters in the macro appear as if typed at the keyboard.
3385
 
3386
 
3387

3388
File: gdb.info,  Node: Miscellaneous Commands,  Prev: Keyboard Macros,  Up: Bindable Readline Commands
3389
 
3390
31.4.8 Some Miscellaneous Commands
3391
----------------------------------
3392
 
3393
`re-read-init-file (C-x C-r)'
3394
     Read in the contents of the INPUTRC file, and incorporate any
3395
     bindings or variable assignments found there.
3396
 
3397
`abort (C-g)'
3398
     Abort the current editing command and ring the terminal's bell
3399
     (subject to the setting of `bell-style').
3400
 
3401
`do-uppercase-version (M-a, M-b, M-X, ...)'
3402
     If the metafied character X is lowercase, run the command that is
3403
     bound to the corresponding uppercase character.
3404
 
3405
`prefix-meta ()'
3406
     Metafy the next character typed.  This is for keyboards without a
3407
     meta key.  Typing ` f' is equivalent to typing `M-f'.
3408
 
3409
`undo (C-_ or C-x C-u)'
3410
     Incremental undo, separately remembered for each line.
3411
 
3412
`revert-line (M-r)'
3413
     Undo all changes made to this line.  This is like executing the
3414
     `undo' command enough times to get back to the beginning.
3415
 
3416
`tilde-expand (M-~)'
3417
     Perform tilde expansion on the current word.
3418
 
3419
`set-mark (C-@)'
3420
     Set the mark to the point.  If a numeric argument is supplied, the
3421
     mark is set to that position.
3422
 
3423
`exchange-point-and-mark (C-x C-x)'
3424
     Swap the point with the mark.  The current cursor position is set
3425
     to the saved position, and the old cursor position is saved as the
3426
     mark.
3427
 
3428
`character-search (C-])'
3429
     A character is read and point is moved to the next occurrence of
3430
     that character.  A negative count searches for previous
3431
     occurrences.
3432
 
3433
`character-search-backward (M-C-])'
3434
     A character is read and point is moved to the previous occurrence
3435
     of that character.  A negative count searches for subsequent
3436
     occurrences.
3437
 
3438
`insert-comment (M-#)'
3439
     Without a numeric argument, the value of the `comment-begin'
3440
     variable is inserted at the beginning of the current line.  If a
3441
     numeric argument is supplied, this command acts as a toggle:  if
3442
     the characters at the beginning of the line do not match the value
3443
     of `comment-begin', the value is inserted, otherwise the
3444
     characters in `comment-begin' are deleted from the beginning of
3445
     the line.  In either case, the line is accepted as if a newline
3446
     had been typed.
3447
 
3448
`dump-functions ()'
3449
     Print all of the functions and their key bindings to the Readline
3450
     output stream.  If a numeric argument is supplied, the output is
3451
     formatted in such a way that it can be made part of an INPUTRC
3452
     file.  This command is unbound by default.
3453
 
3454
`dump-variables ()'
3455
     Print all of the settable variables and their values to the
3456
     Readline output stream.  If a numeric argument is supplied, the
3457
     output is formatted in such a way that it can be made part of an
3458
     INPUTRC file.  This command is unbound by default.
3459
 
3460
`dump-macros ()'
3461
     Print all of the Readline key sequences bound to macros and the
3462
     strings they output.  If a numeric argument is supplied, the
3463
     output is formatted in such a way that it can be made part of an
3464
     INPUTRC file.  This command is unbound by default.
3465
 
3466
`emacs-editing-mode (C-e)'
3467
     When in `vi' command mode, this causes a switch to `emacs' editing
3468
     mode.
3469
 
3470
`vi-editing-mode (M-C-j)'
3471
     When in `emacs' editing mode, this causes a switch to `vi' editing
3472
     mode.
3473
 
3474
 
3475

3476
File: gdb.info,  Node: Readline vi Mode,  Prev: Bindable Readline Commands,  Up: Command Line Editing
3477
 
3478
31.5 Readline vi Mode
3479
=====================
3480
 
3481
While the Readline library does not have a full set of `vi' editing
3482
functions, it does contain enough to allow simple editing of the line.
3483
The Readline `vi' mode behaves as specified in the POSIX 1003.2
3484
standard.
3485
 
3486
   In order to switch interactively between `emacs' and `vi' editing
3487
modes, use the command `M-C-j' (bound to emacs-editing-mode when in
3488
`vi' mode and to vi-editing-mode in `emacs' mode).  The Readline
3489
default is `emacs' mode.
3490
 
3491
   When you enter a line in `vi' mode, you are already placed in
3492
`insertion' mode, as if you had typed an `i'.  Pressing  switches
3493
you into `command' mode, where you can edit the text of the line with
3494
the standard `vi' movement keys, move to previous history lines with
3495
`k' and subsequent lines with `j', and so forth.
3496
 
3497

3498
File: gdb.info,  Node: Using History Interactively,  Next: Formatting Documentation,  Prev: Command Line Editing,  Up: Top
3499
 
3500
32 Using History Interactively
3501
******************************
3502
 
3503
This chapter describes how to use the GNU History Library interactively,
3504
from a user's standpoint.  It should be considered a user's guide.  For
3505
information on using the GNU History Library in other programs, see the
3506
GNU Readline Library Manual.
3507
 
3508
* Menu:
3509
 
3510
* History Interaction::         What it feels like using History as a user.
3511
 
3512

3513
File: gdb.info,  Node: History Interaction,  Up: Using History Interactively
3514
 
3515
32.1 History Expansion
3516
======================
3517
 
3518
The History library provides a history expansion feature that is similar
3519
to the history expansion provided by `csh'.  This section describes the
3520
syntax used to manipulate the history information.
3521
 
3522
   History expansions introduce words from the history list into the
3523
input stream, making it easy to repeat commands, insert the arguments
3524
to a previous command into the current input line, or fix errors in
3525
previous commands quickly.
3526
 
3527
   History expansion takes place in two parts.  The first is to
3528
determine which line from the history list should be used during
3529
substitution.  The second is to select portions of that line for
3530
inclusion into the current one.  The line selected from the history is
3531
called the "event", and the portions of that line that are acted upon
3532
are called "words".  Various "modifiers" are available to manipulate
3533
the selected words.  The line is broken into words in the same fashion
3534
that Bash does, so that several words surrounded by quotes are
3535
considered one word.  History expansions are introduced by the
3536
appearance of the history expansion character, which is `!' by default.
3537
 
3538
* Menu:
3539
 
3540
* Event Designators::   How to specify which history line to use.
3541
* Word Designators::    Specifying which words are of interest.
3542
* Modifiers::           Modifying the results of substitution.
3543
 
3544

3545
File: gdb.info,  Node: Event Designators,  Next: Word Designators,  Up: History Interaction
3546
 
3547
32.1.1 Event Designators
3548
------------------------
3549
 
3550
An event designator is a reference to a command line entry in the
3551
history list.
3552
 
3553
`!'
3554
     Start a history substitution, except when followed by a space, tab,
3555
     the end of the line, or `='.
3556
 
3557
`!N'
3558
     Refer to command line N.
3559
 
3560
`!-N'
3561
     Refer to the command N lines back.
3562
 
3563
`!!'
3564
     Refer to the previous command.  This is a synonym for `!-1'.
3565
 
3566
`!STRING'
3567
     Refer to the most recent command starting with STRING.
3568
 
3569
`!?STRING[?]'
3570
     Refer to the most recent command containing STRING.  The trailing
3571
     `?' may be omitted if the STRING is followed immediately by a
3572
     newline.
3573
 
3574
`^STRING1^STRING2^'
3575
     Quick Substitution.  Repeat the last command, replacing STRING1
3576
     with STRING2.  Equivalent to `!!:s/STRING1/STRING2/'.
3577
 
3578
`!#'
3579
     The entire command line typed so far.
3580
 
3581
 
3582

3583
File: gdb.info,  Node: Word Designators,  Next: Modifiers,  Prev: Event Designators,  Up: History Interaction
3584
 
3585
32.1.2 Word Designators
3586
-----------------------
3587
 
3588
Word designators are used to select desired words from the event.  A
3589
`:' separates the event specification from the word designator.  It may
3590
be omitted if the word designator begins with a `^', `$', `*', `-', or
3591
`%'.  Words are numbered from the beginning of the line, with the first
3592
word being denoted by 0 (zero).  Words are inserted into the current
3593
line separated by single spaces.
3594
 
3595
   For example,
3596
 
3597
`!!'
3598
     designates the preceding command.  When you type this, the
3599
     preceding command is repeated in toto.
3600
 
3601
`!!:$'
3602
     designates the last argument of the preceding command.  This may be
3603
     shortened to `!$'.
3604
 
3605
`!fi:2'
3606
     designates the second argument of the most recent command starting
3607
     with the letters `fi'.
3608
 
3609
   Here are the word designators:
3610
 
3611
`0 (zero)'
3612
     The `0'th word.  For many applications, this is the command word.
3613
 
3614
`N'
3615
     The Nth word.
3616
 
3617
`^'
3618
     The first argument; that is, word 1.
3619
 
3620
`$'
3621
     The last argument.
3622
 
3623
`%'
3624
     The word matched by the most recent `?STRING?' search.
3625
 
3626
`X-Y'
3627
     A range of words; `-Y' abbreviates `0-Y'.
3628
 
3629
`*'
3630
     All of the words, except the `0'th.  This is a synonym for `1-$'.
3631
     It is not an error to use `*' if there is just one word in the
3632
     event; the empty string is returned in that case.
3633
 
3634
`X*'
3635
     Abbreviates `X-$'
3636
 
3637
`X-'
3638
     Abbreviates `X-$' like `X*', but omits the last word.
3639
 
3640
 
3641
   If a word designator is supplied without an event specification, the
3642
previous command is used as the event.
3643
 
3644

3645
File: gdb.info,  Node: Modifiers,  Prev: Word Designators,  Up: History Interaction
3646
 
3647
32.1.3 Modifiers
3648
----------------
3649
 
3650
After the optional word designator, you can add a sequence of one or
3651
more of the following modifiers, each preceded by a `:'.
3652
 
3653
`h'
3654
     Remove a trailing pathname component, leaving only the head.
3655
 
3656
`t'
3657
     Remove all leading  pathname  components, leaving the tail.
3658
 
3659
`r'
3660
     Remove a trailing suffix of the form `.SUFFIX', leaving the
3661
     basename.
3662
 
3663
`e'
3664
     Remove all but the trailing suffix.
3665
 
3666
`p'
3667
     Print the new command but do not execute it.
3668
 
3669
`s/OLD/NEW/'
3670
     Substitute NEW for the first occurrence of OLD in the event line.
3671
     Any delimiter may be used in place of `/'.  The delimiter may be
3672
     quoted in OLD and NEW with a single backslash.  If `&' appears in
3673
     NEW, it is replaced by OLD.  A single backslash will quote the
3674
     `&'.  The final delimiter is optional if it is the last character
3675
     on the input line.
3676
 
3677
`&'
3678
     Repeat the previous substitution.
3679
 
3680
`g'
3681
`a'
3682
     Cause changes to be applied over the entire event line.  Used in
3683
     conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
3684
 
3685
`G'
3686
     Apply the following `s' modifier once to each word in the event.
3687
 
3688
 
3689

3690
File: gdb.info,  Node: Formatting Documentation,  Next: Installing GDB,  Prev: Using History Interactively,  Up: Top
3691
 
3692
Appendix A Formatting Documentation
3693
***********************************
3694
 
3695
The GDB 4 release includes an already-formatted reference card, ready
3696
for printing with PostScript or Ghostscript, in the `gdb' subdirectory
3697
of the main source directory(1).  If you can use PostScript or
3698
Ghostscript with your printer, you can print the reference card
3699
immediately with `refcard.ps'.
3700
 
3701
   The release also includes the source for the reference card.  You
3702
can format it, using TeX, by typing:
3703
 
3704
     make refcard.dvi
3705
 
3706
   The GDB reference card is designed to print in "landscape" mode on
3707
US "letter" size paper; that is, on a sheet 11 inches wide by 8.5 inches
3708
high.  You will need to specify this form of printing as an option to
3709
your DVI output program.
3710
 
3711
   All the documentation for GDB comes as part of the machine-readable
3712
distribution.  The documentation is written in Texinfo format, which is
3713
a documentation system that uses a single source file to produce both
3714
on-line information and a printed manual.  You can use one of the Info
3715
formatting commands to create the on-line version of the documentation
3716
and TeX (or `texi2roff') to typeset the printed version.
3717
 
3718
   GDB includes an already formatted copy of the on-line Info version
3719
of this manual in the `gdb' subdirectory.  The main Info file is
3720
`gdb-7.2/gdb/gdb.info', and it refers to subordinate files matching
3721
`gdb.info*' in the same directory.  If necessary, you can print out
3722
these files, or read them with any editor; but they are easier to read
3723
using the `info' subsystem in GNU Emacs or the standalone `info'
3724
program, available as part of the GNU Texinfo distribution.
3725
 
3726
   If you want to format these Info files yourself, you need one of the
3727
Info formatting programs, such as `texinfo-format-buffer' or `makeinfo'.
3728
 
3729
   If you have `makeinfo' installed, and are in the top level GDB
3730
source directory (`gdb-7.2', in the case of version 7.2), you can make
3731
the Info file by typing:
3732
 
3733
     cd gdb
3734
     make gdb.info
3735
 
3736
   If you want to typeset and print copies of this manual, you need TeX,
3737
a program to print its DVI output files, and `texinfo.tex', the Texinfo
3738
definitions file.
3739
 
3740
   TeX is a typesetting program; it does not print files directly, but
3741
produces output files called DVI files.  To print a typeset document,
3742
you need a program to print DVI files.  If your system has TeX
3743
installed, chances are it has such a program.  The precise command to
3744
use depends on your system; `lpr -d' is common; another (for PostScript
3745
devices) is `dvips'.  The DVI print command may require a file name
3746
without any extension or a `.dvi' extension.
3747
 
3748
   TeX also requires a macro definitions file called `texinfo.tex'.
3749
This file tells TeX how to typeset a document written in Texinfo
3750
format.  On its own, TeX cannot either read or typeset a Texinfo file.
3751
`texinfo.tex' is distributed with GDB and is located in the
3752
`gdb-VERSION-NUMBER/texinfo' directory.
3753
 
3754
   If you have TeX and a DVI printer program installed, you can typeset
3755
and print this manual.  First switch to the `gdb' subdirectory of the
3756
main source directory (for example, to `gdb-7.2/gdb') and type:
3757
 
3758
     make gdb.dvi
3759
 
3760
   Then give `gdb.dvi' to your DVI printing program.
3761
 
3762
   ---------- Footnotes ----------
3763
 
3764
   (1) In `gdb-7.2/gdb/refcard.ps' of the version 7.2 release.
3765
 
3766

3767
File: gdb.info,  Node: Installing GDB,  Next: Maintenance Commands,  Prev: Formatting Documentation,  Up: Top
3768
 
3769
Appendix B Installing GDB
3770
*************************
3771
 
3772
* Menu:
3773
 
3774
* Requirements::                Requirements for building GDB
3775
* Running Configure::           Invoking the GDB `configure' script
3776
* Separate Objdir::             Compiling GDB in another directory
3777
* Config Names::                Specifying names for hosts and targets
3778
* Configure Options::           Summary of options for configure
3779
* System-wide configuration::   Having a system-wide init file
3780
 
3781

3782
File: gdb.info,  Node: Requirements,  Next: Running Configure,  Up: Installing GDB
3783
 
3784
B.1 Requirements for Building GDB
3785
=================================
3786
 
3787
Building GDB requires various tools and packages to be available.
3788
Other packages will be used only if they are found.
3789
 
3790
Tools/Packages Necessary for Building GDB
3791
=========================================
3792
 
3793
ISO C90 compiler
3794
     GDB is written in ISO C90.  It should be buildable with any
3795
     working C90 compiler, e.g. GCC.
3796
 
3797
 
3798
Tools/Packages Optional for Building GDB
3799
========================================
3800
 
3801
Expat
3802
     GDB can use the Expat XML parsing library.  This library may be
3803
     included with your operating system distribution; if it is not, you
3804
     can get the latest version from `http://expat.sourceforge.net'.
3805
     The `configure' script will search for this library in several
3806
     standard locations; if it is installed in an unusual path, you can
3807
     use the `--with-libexpat-prefix' option to specify its location.
3808
 
3809
     Expat is used for:
3810
 
3811
        * Remote protocol memory maps (*note Memory Map Format::)
3812
 
3813
        * Target descriptions (*note Target Descriptions::)
3814
 
3815
        * Remote shared library lists (*note Library List Format::)
3816
 
3817
        * MS-Windows shared libraries (*note Shared Libraries::)
3818
 
3819
zlib
3820
     GDB will use the `zlib' library, if available, to read compressed
3821
     debug sections.  Some linkers, such as GNU gold, are capable of
3822
     producing binaries with compressed debug sections.  If GDB is
3823
     compiled with `zlib', it will be able to read the debug
3824
     information in such binaries.
3825
 
3826
     The `zlib' library is likely included with your operating system
3827
     distribution; if it is not, you can get the latest version from
3828
     `http://zlib.net'.
3829
 
3830
iconv
3831
     GDB's features related to character sets (*note Character Sets::)
3832
     require a functioning `iconv' implementation.  If you are on a GNU
3833
     system, then this is provided by the GNU C Library.  Some other
3834
     systems also provide a working `iconv'.
3835
 
3836
     On systems with `iconv', you can install GNU Libiconv.  If you
3837
     have previously installed Libiconv, you can use the
3838
     `--with-libiconv-prefix' option to configure.
3839
 
3840
     GDB's top-level `configure' and `Makefile' will arrange to build
3841
     Libiconv if a directory named `libiconv' appears in the top-most
3842
     source directory.  If Libiconv is built this way, and if the
3843
     operating system does not provide a suitable `iconv'
3844
     implementation, then the just-built library will automatically be
3845
     used by GDB.  One easy way to set this up is to download GNU
3846
     Libiconv, unpack it, and then rename the directory holding the
3847
     Libiconv source code to `libiconv'.
3848
 
3849

3850
File: gdb.info,  Node: Running Configure,  Next: Separate Objdir,  Prev: Requirements,  Up: Installing GDB
3851
 
3852
B.2 Invoking the GDB `configure' Script
3853
=======================================
3854
 
3855
GDB comes with a `configure' script that automates the process of
3856
preparing GDB for installation; you can then use `make' to build the
3857
`gdb' program.
3858
 
3859
   The GDB distribution includes all the source code you need for GDB
3860
in a single directory, whose name is usually composed by appending the
3861
version number to `gdb'.
3862
 
3863
   For example, the GDB version 7.2 distribution is in the `gdb-7.2'
3864
directory.  That directory contains:
3865
 
3866
`gdb-7.2/configure (and supporting files)'
3867
     script for configuring GDB and all its supporting libraries
3868
 
3869
`gdb-7.2/gdb'
3870
     the source specific to GDB itself
3871
 
3872
`gdb-7.2/bfd'
3873
     source for the Binary File Descriptor library
3874
 
3875
`gdb-7.2/include'
3876
     GNU include files
3877
 
3878
`gdb-7.2/libiberty'
3879
     source for the `-liberty' free software library
3880
 
3881
`gdb-7.2/opcodes'
3882
     source for the library of opcode tables and disassemblers
3883
 
3884
`gdb-7.2/readline'
3885
     source for the GNU command-line interface
3886
 
3887
`gdb-7.2/glob'
3888
     source for the GNU filename pattern-matching subroutine
3889
 
3890
`gdb-7.2/mmalloc'
3891
     source for the GNU memory-mapped malloc package
3892
 
3893
   The simplest way to configure and build GDB is to run `configure'
3894
from the `gdb-VERSION-NUMBER' source directory, which in this example
3895
is the `gdb-7.2' directory.
3896
 
3897
   First switch to the `gdb-VERSION-NUMBER' source directory if you are
3898
not already in it; then run `configure'.  Pass the identifier for the
3899
platform on which GDB will run as an argument.
3900
 
3901
   For example:
3902
 
3903
     cd gdb-7.2
3904
     ./configure HOST
3905
     make
3906
 
3907
where HOST is an identifier such as `sun4' or `decstation', that
3908
identifies the platform where GDB will run.  (You can often leave off
3909
HOST; `configure' tries to guess the correct value by examining your
3910
system.)
3911
 
3912
   Running `configure HOST' and then running `make' builds the `bfd',
3913
`readline', `mmalloc', and `libiberty' libraries, then `gdb' itself.
3914
The configured source files, and the binaries, are left in the
3915
corresponding source directories.
3916
 
3917
   `configure' is a Bourne-shell (`/bin/sh') script; if your system
3918
does not recognize this automatically when you run a different shell,
3919
you may need to run `sh' on it explicitly:
3920
 
3921
     sh configure HOST
3922
 
3923
   If you run `configure' from a directory that contains source
3924
directories for multiple libraries or programs, such as the `gdb-7.2'
3925
source directory for version 7.2, `configure' creates configuration
3926
files for every directory level underneath (unless you tell it not to,
3927
with the `--norecursion' option).
3928
 
3929
   You should run the `configure' script from the top directory in the
3930
source tree, the `gdb-VERSION-NUMBER' directory.  If you run
3931
`configure' from one of the subdirectories, you will configure only
3932
that subdirectory.  That is usually not what you want.  In particular,
3933
if you run the first `configure' from the `gdb' subdirectory of the
3934
`gdb-VERSION-NUMBER' directory, you will omit the configuration of
3935
`bfd', `readline', and other sibling directories of the `gdb'
3936
subdirectory.  This leads to build errors about missing include files
3937
such as `bfd/bfd.h'.
3938
 
3939
   You can install `gdb' anywhere; it has no hardwired paths.  However,
3940
you should make sure that the shell on your path (named by the `SHELL'
3941
environment variable) is publicly readable.  Remember that GDB uses the
3942
shell to start your program--some systems refuse to let GDB debug child
3943
processes whose programs are not readable.
3944
 
3945

3946
File: gdb.info,  Node: Separate Objdir,  Next: Config Names,  Prev: Running Configure,  Up: Installing GDB
3947
 
3948
B.3 Compiling GDB in Another Directory
3949
======================================
3950
 
3951
If you want to run GDB versions for several host or target machines,
3952
you need a different `gdb' compiled for each combination of host and
3953
target.  `configure' is designed to make this easy by allowing you to
3954
generate each configuration in a separate subdirectory, rather than in
3955
the source directory.  If your `make' program handles the `VPATH'
3956
feature (GNU `make' does), running `make' in each of these directories
3957
builds the `gdb' program specified there.
3958
 
3959
   To build `gdb' in a separate directory, run `configure' with the
3960
`--srcdir' option to specify where to find the source.  (You also need
3961
to specify a path to find `configure' itself from your working
3962
directory.  If the path to `configure' would be the same as the
3963
argument to `--srcdir', you can leave out the `--srcdir' option; it is
3964
assumed.)
3965
 
3966
   For example, with version 7.2, you can build GDB in a separate
3967
directory for a Sun 4 like this:
3968
 
3969
     cd gdb-7.2
3970
     mkdir ../gdb-sun4
3971
     cd ../gdb-sun4
3972
     ../gdb-7.2/configure sun4
3973
     make
3974
 
3975
   When `configure' builds a configuration using a remote source
3976
directory, it creates a tree for the binaries with the same structure
3977
(and using the same names) as the tree under the source directory.  In
3978
the example, you'd find the Sun 4 library `libiberty.a' in the
3979
directory `gdb-sun4/libiberty', and GDB itself in `gdb-sun4/gdb'.
3980
 
3981
   Make sure that your path to the `configure' script has just one
3982
instance of `gdb' in it.  If your path to `configure' looks like
3983
`../gdb-7.2/gdb/configure', you are configuring only one subdirectory
3984
of GDB, not the whole package.  This leads to build errors about
3985
missing include files such as `bfd/bfd.h'.
3986
 
3987
   One popular reason to build several GDB configurations in separate
3988
directories is to configure GDB for cross-compiling (where GDB runs on
3989
one machine--the "host"--while debugging programs that run on another
3990
machine--the "target").  You specify a cross-debugging target by giving
3991
the `--target=TARGET' option to `configure'.
3992
 
3993
   When you run `make' to build a program or library, you must run it
3994
in a configured directory--whatever directory you were in when you
3995
called `configure' (or one of its subdirectories).
3996
 
3997
   The `Makefile' that `configure' generates in each source directory
3998
also runs recursively.  If you type `make' in a source directory such
3999
as `gdb-7.2' (or in a separate configured directory configured with
4000
`--srcdir=DIRNAME/gdb-7.2'), you will build all the required libraries,
4001
and then build GDB.
4002
 
4003
   When you have multiple hosts or targets configured in separate
4004
directories, you can run `make' on them in parallel (for example, if
4005
they are NFS-mounted on each of the hosts); they will not interfere
4006
with each other.
4007
 
4008

4009
File: gdb.info,  Node: Config Names,  Next: Configure Options,  Prev: Separate Objdir,  Up: Installing GDB
4010
 
4011
B.4 Specifying Names for Hosts and Targets
4012
==========================================
4013
 
4014
The specifications used for hosts and targets in the `configure' script
4015
are based on a three-part naming scheme, but some short predefined
4016
aliases are also supported.  The full naming scheme encodes three pieces
4017
of information in the following pattern:
4018
 
4019
     ARCHITECTURE-VENDOR-OS
4020
 
4021
   For example, you can use the alias `sun4' as a HOST argument, or as
4022
the value for TARGET in a `--target=TARGET' option.  The equivalent
4023
full name is `sparc-sun-sunos4'.
4024
 
4025
   The `configure' script accompanying GDB does not provide any query
4026
facility to list all supported host and target names or aliases.
4027
`configure' calls the Bourne shell script `config.sub' to map
4028
abbreviations to full names; you can read the script, if you wish, or
4029
you can use it to test your guesses on abbreviations--for example:
4030
 
4031
     % sh config.sub i386-linux
4032
     i386-pc-linux-gnu
4033
     % sh config.sub alpha-linux
4034
     alpha-unknown-linux-gnu
4035
     % sh config.sub hp9k700
4036
     hppa1.1-hp-hpux
4037
     % sh config.sub sun4
4038
     sparc-sun-sunos4.1.1
4039
     % sh config.sub sun3
4040
     m68k-sun-sunos4.1.1
4041
     % sh config.sub i986v
4042
     Invalid configuration `i986v': machine `i986v' not recognized
4043
 
4044
`config.sub' is also distributed in the GDB source directory
4045
(`gdb-7.2', for version 7.2).
4046
 
4047

4048
File: gdb.info,  Node: Configure Options,  Next: System-wide configuration,  Prev: Config Names,  Up: Installing GDB
4049
 
4050
B.5 `configure' Options
4051
=======================
4052
 
4053
Here is a summary of the `configure' options and arguments that are
4054
most often useful for building GDB.  `configure' also has several other
4055
options not listed here.  *note (configure.info)What Configure Does::,
4056
for a full explanation of `configure'.
4057
 
4058
     configure [--help]
4059
               [--prefix=DIR]
4060
               [--exec-prefix=DIR]
4061
               [--srcdir=DIRNAME]
4062
               [--norecursion] [--rm]
4063
               [--target=TARGET]
4064
               HOST
4065
 
4066
You may introduce options with a single `-' rather than `--' if you
4067
prefer; but you may abbreviate option names if you use `--'.
4068
 
4069
`--help'
4070
     Display a quick summary of how to invoke `configure'.
4071
 
4072
`--prefix=DIR'
4073
     Configure the source to install programs and files under directory
4074
     `DIR'.
4075
 
4076
`--exec-prefix=DIR'
4077
     Configure the source to install programs under directory `DIR'.
4078
 
4079
`--srcdir=DIRNAME'
4080
     *Warning: using this option requires GNU `make', or another `make'
4081
     that implements the `VPATH' feature.*
4082
     Use this option to make configurations in directories separate
4083
     from the GDB source directories.  Among other things, you can use
4084
     this to build (or maintain) several configurations simultaneously,
4085
     in separate directories.  `configure' writes
4086
     configuration-specific files in the current directory, but
4087
     arranges for them to use the source in the directory DIRNAME.
4088
     `configure' creates directories under the working directory in
4089
     parallel to the source directories below DIRNAME.
4090
 
4091
`--norecursion'
4092
     Configure only the directory level where `configure' is executed;
4093
     do not propagate configuration to subdirectories.
4094
 
4095
`--target=TARGET'
4096
     Configure GDB for cross-debugging programs running on the specified
4097
     TARGET.  Without this option, GDB is configured to debug programs
4098
     that run on the same machine (HOST) as GDB itself.
4099
 
4100
     There is no convenient way to generate a list of all available
4101
     targets.
4102
 
4103
`HOST ...'
4104
     Configure GDB to run on the specified HOST.
4105
 
4106
     There is no convenient way to generate a list of all available
4107
     hosts.
4108
 
4109
   There are many other options available as well, but they are
4110
generally needed for special purposes only.
4111
 
4112

4113
File: gdb.info,  Node: System-wide configuration,  Prev: Configure Options,  Up: Installing GDB
4114
 
4115
B.6 System-wide configuration and settings
4116
==========================================
4117
 
4118
GDB can be configured to have a system-wide init file; this file will
4119
be read and executed at startup (*note What GDB does during startup:
4120
Startup.).
4121
 
4122
   Here is the corresponding configure option:
4123
 
4124
`--with-system-gdbinit=FILE'
4125
     Specify that the default location of the system-wide init file is
4126
     FILE.
4127
 
4128
   If GDB has been configured with the option `--prefix=$prefix', it
4129
may be subject to relocation.  Two possible cases:
4130
 
4131
   * If the default location of this init file contains `$prefix', it
4132
     will be subject to relocation.  Suppose that the configure options
4133
     are `--prefix=$prefix --with-system-gdbinit=$prefix/etc/gdbinit';
4134
     if GDB is moved from `$prefix' to `$install', the system init file
4135
     is looked for as `$install/etc/gdbinit' instead of
4136
     `$prefix/etc/gdbinit'.
4137
 
4138
   * By contrast, if the default location does not contain the prefix,
4139
     it will not be relocated.  E.g. if GDB has been configured with
4140
     `--prefix=/usr/local --with-system-gdbinit=/usr/share/gdb/gdbinit',
4141
     then GDB will always look for `/usr/share/gdb/gdbinit', wherever
4142
     GDB is installed.
4143
 
4144

4145
File: gdb.info,  Node: Maintenance Commands,  Next: Remote Protocol,  Prev: Installing GDB,  Up: Top
4146
 
4147
Appendix C Maintenance Commands
4148
*******************************
4149
 
4150
In addition to commands intended for GDB users, GDB includes a number
4151
of commands intended for GDB developers, that are not documented
4152
elsewhere in this manual.  These commands are provided here for
4153
reference.  (For commands that turn on debugging messages, see *Note
4154
Debugging Output::.)
4155
 
4156
`maint agent EXPRESSION'
4157
`maint agent-eval EXPRESSION'
4158
     Translate the given EXPRESSION into remote agent bytecodes.  This
4159
     command is useful for debugging the Agent Expression mechanism
4160
     (*note Agent Expressions::).  The `agent' version produces an
4161
     expression useful for data collection, such as by tracepoints,
4162
     while `maint agent-eval' produces an expression that evaluates
4163
     directly to a result.  For instance, a collection expression for
4164
     `globa + globb' will include bytecodes to record four bytes of
4165
     memory at each of the addresses of `globa' and `globb', while
4166
     discarding the result of the addition, while an evaluation
4167
     expression will do the addition and return the sum.
4168
 
4169
`maint info breakpoints'
4170
     Using the same format as `info breakpoints', display both the
4171
     breakpoints you've set explicitly, and those GDB is using for
4172
     internal purposes.  Internal breakpoints are shown with negative
4173
     breakpoint numbers.  The type column identifies what kind of
4174
     breakpoint is shown:
4175
 
4176
    `breakpoint'
4177
          Normal, explicitly set breakpoint.
4178
 
4179
    `watchpoint'
4180
          Normal, explicitly set watchpoint.
4181
 
4182
    `longjmp'
4183
          Internal breakpoint, used to handle correctly stepping through
4184
          `longjmp' calls.
4185
 
4186
    `longjmp resume'
4187
          Internal breakpoint at the target of a `longjmp'.
4188
 
4189
    `until'
4190
          Temporary internal breakpoint used by the GDB `until' command.
4191
 
4192
    `finish'
4193
          Temporary internal breakpoint used by the GDB `finish'
4194
          command.
4195
 
4196
    `shlib events'
4197
          Shared library events.
4198
 
4199
 
4200
`set displaced-stepping'
4201
`show displaced-stepping'
4202
     Control whether or not GDB will do "displaced stepping" if the
4203
     target supports it.  Displaced stepping is a way to single-step
4204
     over breakpoints without removing them from the inferior, by
4205
     executing an out-of-line copy of the instruction that was
4206
     originally at the breakpoint location.  It is also known as
4207
     out-of-line single-stepping.
4208
 
4209
    `set displaced-stepping on'
4210
          If the target architecture supports it, GDB will use
4211
          displaced stepping to step over breakpoints.
4212
 
4213
    `set displaced-stepping off'
4214
          GDB will not use displaced stepping to step over breakpoints,
4215
          even if such is supported by the target architecture.
4216
 
4217
    `set displaced-stepping auto'
4218
          This is the default mode.  GDB will use displaced stepping
4219
          only if non-stop mode is active (*note Non-Stop Mode::) and
4220
          the target architecture supports displaced stepping.
4221
 
4222
`maint check-symtabs'
4223
     Check the consistency of psymtabs and symtabs.
4224
 
4225
`maint cplus first_component NAME'
4226
     Print the first C++ class/namespace component of NAME.
4227
 
4228
`maint cplus namespace'
4229
     Print the list of possible C++ namespaces.
4230
 
4231
`maint demangle NAME'
4232
     Demangle a C++ or Objective-C mangled NAME.
4233
 
4234
`maint deprecate COMMAND [REPLACEMENT]'
4235
`maint undeprecate COMMAND'
4236
     Deprecate or undeprecate the named COMMAND.  Deprecated commands
4237
     cause GDB to issue a warning when you use them.  The optional
4238
     argument REPLACEMENT says which newer command should be used in
4239
     favor of the deprecated one; if it is given, GDB will mention the
4240
     replacement as part of the warning.
4241
 
4242
`maint dump-me'
4243
     Cause a fatal signal in the debugger and force it to dump its core.
4244
     This is supported only on systems which support aborting a program
4245
     with the `SIGQUIT' signal.
4246
 
4247
`maint internal-error [MESSAGE-TEXT]'
4248
`maint internal-warning [MESSAGE-TEXT]'
4249
     Cause GDB to call the internal function `internal_error' or
4250
     `internal_warning' and hence behave as though an internal error or
4251
     internal warning has been detected.  In addition to reporting the
4252
     internal problem, these functions give the user the opportunity to
4253
     either quit GDB or create a core file of the current GDB session.
4254
 
4255
     These commands take an optional parameter MESSAGE-TEXT that is
4256
     used as the text of the error or warning message.
4257
 
4258
     Here's an example of using `internal-error':
4259
 
4260
          (gdb) maint internal-error testing, 1, 2
4261
          .../maint.c:121: internal-error: testing, 1, 2
4262
          A problem internal to GDB has been detected.  Further
4263
          debugging may prove unreliable.
4264
          Quit this debugging session? (y or n) n
4265
          Create a core file? (y or n) n
4266
          (gdb)
4267
 
4268
`maint set internal-error ACTION [ask|yes|no]'
4269
`maint show internal-error ACTION'
4270
`maint set internal-warning ACTION [ask|yes|no]'
4271
`maint show internal-warning ACTION'
4272
     When GDB reports an internal problem (error or warning) it gives
4273
     the user the opportunity to both quit GDB and create a core file
4274
     of the current GDB session.  These commands let you override the
4275
     default behaviour for each particular ACTION, described in the
4276
     table below.
4277
 
4278
    `quit'
4279
          You can specify that GDB should always (yes) or never (no)
4280
          quit.  The default is to ask the user what to do.
4281
 
4282
    `corefile'
4283
          You can specify that GDB should always (yes) or never (no)
4284
          create a core file.  The default is to ask the user what to
4285
          do.
4286
 
4287
`maint packet TEXT'
4288
     If GDB is talking to an inferior via the serial protocol, then
4289
     this command sends the string TEXT to the inferior, and displays
4290
     the response packet.  GDB supplies the initial `$' character, the
4291
     terminating `#' character, and the checksum.
4292
 
4293
`maint print architecture [FILE]'
4294
     Print the entire architecture configuration.  The optional argument
4295
     FILE names the file where the output goes.
4296
 
4297
`maint print c-tdesc'
4298
     Print the current target description (*note Target Descriptions::)
4299
     as a C source file.  The created source file can be used in GDB
4300
     when an XML parser is not available to parse the description.
4301
 
4302
`maint print dummy-frames'
4303
     Prints the contents of GDB's internal dummy-frame stack.
4304
 
4305
          (gdb) b add
4306
          ...
4307
          (gdb) print add(2,3)
4308
          Breakpoint 2, add (a=2, b=3) at ...
4309
          58      return (a + b);
4310
          The program being debugged stopped while in a function called from GDB.
4311
          ...
4312
          (gdb) maint print dummy-frames
4313
          0x1a57c80: pc=0x01014068 fp=0x0200bddc sp=0x0200bdd6
4314
           top=0x0200bdd4 id={stack=0x200bddc,code=0x101405c}
4315
           call_lo=0x01014000 call_hi=0x01014001
4316
          (gdb)
4317
 
4318
     Takes an optional file parameter.
4319
 
4320
`maint print registers [FILE]'
4321
`maint print raw-registers [FILE]'
4322
`maint print cooked-registers [FILE]'
4323
`maint print register-groups [FILE]'
4324
     Print GDB's internal register data structures.
4325
 
4326
     The command `maint print raw-registers' includes the contents of
4327
     the raw register cache; the command `maint print cooked-registers'
4328
     includes the (cooked) value of all registers, including registers
4329
     which aren't available on the target nor visible to user; and the
4330
     command `maint print register-groups' includes the groups that each
4331
     register is a member of.  *Note Registers: (gdbint)Registers.
4332
 
4333
     These commands take an optional parameter, a file name to which to
4334
     write the information.
4335
 
4336
`maint print reggroups [FILE]'
4337
     Print GDB's internal register group data structures.  The optional
4338
     argument FILE tells to what file to write the information.
4339
 
4340
     The register groups info looks like this:
4341
 
4342
          (gdb) maint print reggroups
4343
           Group      Type
4344
           general    user
4345
           float      user
4346
           all        user
4347
           vector     user
4348
           system     user
4349
           save       internal
4350
           restore    internal
4351
 
4352
`flushregs'
4353
     This command forces GDB to flush its internal register cache.
4354
 
4355
`maint print objfiles'
4356
     Print a dump of all known object files.  For each object file, this
4357
     command prints its name, address in memory, and all of its psymtabs
4358
     and symtabs.
4359
 
4360
`maint print section-scripts [REGEXP]'
4361
     Print a dump of scripts specified in the `.debug_gdb_section'
4362
     section.  If REGEXP is specified, only print scripts loaded by
4363
     object files matching REGEXP.  For each script, this command
4364
     prints its name as specified in the objfile, and the full path if
4365
     known.  *Note .debug_gdb_scripts section::.
4366
 
4367
`maint print statistics'
4368
     This command prints, for each object file in the program, various
4369
     data about that object file followed by the byte cache ("bcache")
4370
     statistics for the object file.  The objfile data includes the
4371
     number of minimal, partial, full, and stabs symbols, the number of
4372
     types defined by the objfile, the number of as yet unexpanded psym
4373
     tables, the number of line tables and string tables, and the
4374
     amount of memory used by the various tables.  The bcache
4375
     statistics include the counts, sizes, and counts of duplicates of
4376
     all and unique objects, max, average, and median entry size, total
4377
     memory used and its overhead and savings, and various measures of
4378
     the hash table size and chain lengths.
4379
 
4380
`maint print target-stack'
4381
     A "target" is an interface between the debugger and a particular
4382
     kind of file or process.  Targets can be stacked in "strata", so
4383
     that more than one target can potentially respond to a request.
4384
     In particular, memory accesses will walk down the stack of targets
4385
     until they find a target that is interested in handling that
4386
     particular address.
4387
 
4388
     This command prints a short description of each layer that was
4389
     pushed on the "target stack", starting from the top layer down to
4390
     the bottom one.
4391
 
4392
`maint print type EXPR'
4393
     Print the type chain for a type specified by EXPR.  The argument
4394
     can be either a type name or a symbol.  If it is a symbol, the
4395
     type of that symbol is described.  The type chain produced by this
4396
     command is a recursive definition of the data type as stored in
4397
     GDB's data structures, including its flags and contained types.
4398
 
4399
`maint set dwarf2 always-disassemble'
4400
 
4401
`maint show dwarf2 always-disassemble'
4402
     Control the behavior of `info address' when using DWARF debugging
4403
     information.
4404
 
4405
     The default is `off', which means that GDB should try to describe
4406
     a variable's location in an easily readable format.  When `on',
4407
     GDB will instead display the DWARF location expression in an
4408
     assembly-like format.  Note that some locations are too complex
4409
     for GDB to describe simply; in this case you will always see the
4410
     disassembly form.
4411
 
4412
     Here is an example of the resulting disassembly:
4413
 
4414
          (gdb) info addr argc
4415
          Symbol "argc" is a complex DWARF expression:
4416
               1: DW_OP_fbreg 0
4417
 
4418
     For more information on these expressions, see the DWARF standard
4419
     (http://www.dwarfstd.org/).
4420
 
4421
`maint set dwarf2 max-cache-age'
4422
`maint show dwarf2 max-cache-age'
4423
     Control the DWARF 2 compilation unit cache.
4424
 
4425
     In object files with inter-compilation-unit references, such as
4426
     those produced by the GCC option `-feliminate-dwarf2-dups', the
4427
     DWARF 2 reader needs to frequently refer to previously read
4428
     compilation units.  This setting controls how long a compilation
4429
     unit will remain in the cache if it is not referenced.  A higher
4430
     limit means that cached compilation units will be stored in memory
4431
     longer, and more total memory will be used.  Setting it to zero
4432
     disables caching, which will slow down GDB startup, but reduce
4433
     memory consumption.
4434
 
4435
`maint set profile'
4436
`maint show profile'
4437
     Control profiling of GDB.
4438
 
4439
     Profiling will be disabled until you use the `maint set profile'
4440
     command to enable it.  When you enable profiling, the system will
4441
     begin collecting timing and execution count data; when you disable
4442
     profiling or exit GDB, the results will be written to a log file.
4443
     Remember that if you use profiling, GDB will overwrite the
4444
     profiling log file (often called `gmon.out').  If you have a
4445
     record of important profiling data in a `gmon.out' file, be sure
4446
     to move it to a safe location.
4447
 
4448
     Configuring with `--enable-profiling' arranges for GDB to be
4449
     compiled with the `-pg' compiler option.
4450
 
4451
`maint set show-debug-regs'
4452
`maint show show-debug-regs'
4453
     Control whether to show variables that mirror the hardware debug
4454
     registers.  Use `ON' to enable, `OFF' to disable.  If enabled, the
4455
     debug registers values are shown when GDB inserts or removes a
4456
     hardware breakpoint or watchpoint, and when the inferior triggers
4457
     a hardware-assisted breakpoint or watchpoint.
4458
 
4459
`maint set show-all-tib'
4460
`maint show show-all-tib'
4461
     Control whether to show all non zero areas within a 1k block
4462
     starting at thread local base, when using the `info w32
4463
     thread-information-block' command.
4464
 
4465
`maint space'
4466
     Control whether to display memory usage for each command.  If set
4467
     to a nonzero value, GDB will display how much memory each command
4468
     took, following the command's own output.  This can also be
4469
     requested by invoking GDB with the `--statistics' command-line
4470
     switch (*note Mode Options::).
4471
 
4472
`maint time'
4473
     Control whether to display the execution time for each command.  If
4474
     set to a nonzero value, GDB will display how much time it took to
4475
     execute each command, following the command's own output.  The
4476
     time is not printed for the commands that run the target, since
4477
     there's no mechanism currently to compute how much time was spend
4478
     by GDB and how much time was spend by the program been debugged.
4479
     it's not possibly currently This can also be requested by invoking
4480
     GDB with the `--statistics' command-line switch (*note Mode
4481
     Options::).
4482
 
4483
`maint translate-address [SECTION] ADDR'
4484
     Find the symbol stored at the location specified by the address
4485
     ADDR and an optional section name SECTION.  If found, GDB prints
4486
     the name of the closest symbol and an offset from the symbol's
4487
     location to the specified address.  This is similar to the `info
4488
     address' command (*note Symbols::), except that this command also
4489
     allows to find symbols in other sections.
4490
 
4491
     If section was not specified, the section in which the symbol was
4492
     found is also printed.  For dynamically linked executables, the
4493
     name of executable or shared library containing the symbol is
4494
     printed as well.
4495
 
4496
 
4497
   The following command is useful for non-interactive invocations of
4498
GDB, such as in the test suite.
4499
 
4500
`set watchdog NSEC'
4501
     Set the maximum number of seconds GDB will wait for the target
4502
     operation to finish.  If this time expires, GDB reports and error
4503
     and the command is aborted.
4504
 
4505
`show watchdog'
4506
     Show the current setting of the target wait timeout.
4507
 
4508

4509
File: gdb.info,  Node: Remote Protocol,  Next: Agent Expressions,  Prev: Maintenance Commands,  Up: Top
4510
 
4511
Appendix D GDB Remote Serial Protocol
4512
*************************************
4513
 
4514
* Menu:
4515
 
4516
* Overview::
4517
* Packets::
4518
* Stop Reply Packets::
4519
* General Query Packets::
4520
* Architecture-Specific Protocol Details::
4521
* Tracepoint Packets::
4522
* Host I/O Packets::
4523
* Interrupts::
4524
* Notification Packets::
4525
* Remote Non-Stop::
4526
* Packet Acknowledgment::
4527
* Examples::
4528
* File-I/O Remote Protocol Extension::
4529
* Library List Format::
4530
* Memory Map Format::
4531
* Thread List Format::
4532
 
4533

4534
File: gdb.info,  Node: Overview,  Next: Packets,  Up: Remote Protocol
4535
 
4536
D.1 Overview
4537
============
4538
 
4539
There may be occasions when you need to know something about the
4540
protocol--for example, if there is only one serial port to your target
4541
machine, you might want your program to do something special if it
4542
recognizes a packet meant for GDB.
4543
 
4544
   In the examples below, `->' and `<-' are used to indicate
4545
transmitted and received data, respectively.
4546
 
4547
   All GDB commands and responses (other than acknowledgments and
4548
notifications, see *Note Notification Packets::) are sent as a PACKET.
4549
A PACKET is introduced with the character `$', the actual PACKET-DATA,
4550
and the terminating character `#' followed by a two-digit CHECKSUM:
4551
 
4552
     `$'PACKET-DATA`#'CHECKSUM
4553
   The two-digit CHECKSUM is computed as the modulo 256 sum of all
4554
characters between the leading `$' and the trailing `#' (an eight bit
4555
unsigned checksum).
4556
 
4557
   Implementors should note that prior to GDB 5.0 the protocol
4558
specification also included an optional two-digit SEQUENCE-ID:
4559
 
4560
     `$'SEQUENCE-ID`:'PACKET-DATA`#'CHECKSUM
4561
 
4562
That SEQUENCE-ID was appended to the acknowledgment.  GDB has never
4563
output SEQUENCE-IDs.  Stubs that handle packets added since GDB 5.0
4564
must not accept SEQUENCE-ID.
4565
 
4566
   When either the host or the target machine receives a packet, the
4567
first response expected is an acknowledgment: either `+' (to indicate
4568
the package was received correctly) or `-' (to request retransmission):
4569
 
4570
     -> `$'PACKET-DATA`#'CHECKSUM
4571
     <- `+'
4572
   The `+'/`-' acknowledgments can be disabled once a connection is
4573
established.  *Note Packet Acknowledgment::, for details.
4574
 
4575
   The host (GDB) sends COMMANDs, and the target (the debugging stub
4576
incorporated in your program) sends a RESPONSE.  In the case of step
4577
and continue COMMANDs, the response is only sent when the operation has
4578
completed, and the target has again stopped all threads in all attached
4579
processes.  This is the default all-stop mode behavior, but the remote
4580
protocol also supports GDB's non-stop execution mode; see *Note Remote
4581
Non-Stop::, for details.
4582
 
4583
   PACKET-DATA consists of a sequence of characters with the exception
4584
of `#' and `$' (see `X' packet for additional exceptions).
4585
 
4586
   Fields within the packet should be separated using `,' `;' or `:'.
4587
Except where otherwise noted all numbers are represented in HEX with
4588
leading zeros suppressed.
4589
 
4590
   Implementors should note that prior to GDB 5.0, the character `:'
4591
could not appear as the third character in a packet (as it would
4592
potentially conflict with the SEQUENCE-ID).
4593
 
4594
   Binary data in most packets is encoded either as two hexadecimal
4595
digits per byte of binary data.  This allowed the traditional remote
4596
protocol to work over connections which were only seven-bit clean.
4597
Some packets designed more recently assume an eight-bit clean
4598
connection, and use a more efficient encoding to send and receive
4599
binary data.
4600
 
4601
   The binary data representation uses `7d' (ASCII `}') as an escape
4602
character.  Any escaped byte is transmitted as the escape character
4603
followed by the original character XORed with `0x20'.  For example, the
4604
byte `0x7d' would be transmitted as the two bytes `0x7d 0x5d'.  The
4605
bytes `0x23' (ASCII `#'), `0x24' (ASCII `$'), and `0x7d' (ASCII `}')
4606
must always be escaped.  Responses sent by the stub must also escape
4607
`0x2a' (ASCII `*'), so that it is not interpreted as the start of a
4608
run-length encoded sequence (described next).
4609
 
4610
   Response DATA can be run-length encoded to save space.  Run-length
4611
encoding replaces runs of identical characters with one instance of the
4612
repeated character, followed by a `*' and a repeat count.  The repeat
4613
count is itself sent encoded, to avoid binary characters in DATA: a
4614
value of N is sent as `N+29'.  For a repeat count greater or equal to
4615
3, this produces a printable ASCII character, e.g. a space (ASCII code
4616
32) for a repeat count of 3.  (This is because run-length encoding
4617
starts to win for counts 3 or more.)  Thus, for example, `0* ' is a
4618
run-length encoding of "0000": the space character after `*' means
4619
repeat the leading `0' `32 - 29 = 3' more times.
4620
 
4621
   The printable characters `#' and `$' or with a numeric value greater
4622
than 126 must not be used.  Runs of six repeats (`#') or seven repeats
4623
(`$') can be expanded using a repeat count of only five (`"').  For
4624
example, `00000000' can be encoded as `0*"00'.
4625
 
4626
   The error response returned for some packets includes a two character
4627
error number.  That number is not well defined.
4628
 
4629
   For any COMMAND not supported by the stub, an empty response
4630
(`$#00') should be returned.  That way it is possible to extend the
4631
protocol.  A newer GDB can tell if a packet is supported based on that
4632
response.
4633
 
4634
   A stub is required to support the `g', `G', `m', `M', `c', and `s'
4635
COMMANDs.  All other COMMANDs are optional.
4636
 
4637

4638
File: gdb.info,  Node: Packets,  Next: Stop Reply Packets,  Prev: Overview,  Up: Remote Protocol
4639
 
4640
D.2 Packets
4641
===========
4642
 
4643
The following table provides a complete list of all currently defined
4644
COMMANDs and their corresponding response DATA.  *Note File-I/O Remote
4645
Protocol Extension::, for details about the File I/O extension of the
4646
remote protocol.
4647
 
4648
   Each packet's description has a template showing the packet's overall
4649
syntax, followed by an explanation of the packet's meaning.  We include
4650
spaces in some of the templates for clarity; these are not part of the
4651
packet's syntax.  No GDB packet uses spaces to separate its components.
4652
For example, a template like `foo BAR BAZ' describes a packet
4653
beginning with the three ASCII bytes `foo', followed by a BAR, followed
4654
directly by a BAZ.  GDB does not transmit a space character between the
4655
`foo' and the BAR, or between the BAR and the BAZ.
4656
 
4657
   Several packets and replies include a THREAD-ID field to identify a
4658
thread.  Normally these are positive numbers with a target-specific
4659
interpretation, formatted as big-endian hex strings.  A THREAD-ID can
4660
also be a literal `-1' to indicate all threads, or `0' to pick any
4661
thread.
4662
 
4663
   In addition, the remote protocol supports a multiprocess feature in
4664
which the THREAD-ID syntax is extended to optionally include both
4665
process and thread ID fields, as `pPID.TID'.  The PID (process) and TID
4666
(thread) components each have the format described above: a positive
4667
number with target-specific interpretation formatted as a big-endian
4668
hex string, literal `-1' to indicate all processes or threads
4669
(respectively), or `0' to indicate an arbitrary process or thread.
4670
Specifying just a process, as `pPID', is equivalent to `pPID.-1'.  It
4671
is an error to specify all processes but a specific thread, such as
4672
`p-1.TID'.  Note that the `p' prefix is _not_ used for those packets
4673
and replies explicitly documented to include a process ID, rather than
4674
a THREAD-ID.
4675
 
4676
   The multiprocess THREAD-ID syntax extensions are only used if both
4677
GDB and the stub report support for the `multiprocess' feature using
4678
`qSupported'.  *Note multiprocess extensions::, for more information.
4679
 
4680
   Note that all packet forms beginning with an upper- or lower-case
4681
letter, other than those described here, are reserved for future use.
4682
 
4683
   Here are the packet descriptions.
4684
 
4685
`!'
4686
     Enable extended mode.  In extended mode, the remote server is made
4687
     persistent.  The `R' packet is used to restart the program being
4688
     debugged.
4689
 
4690
     Reply:
4691
    `OK'
4692
          The remote target both supports and has enabled extended mode.
4693
 
4694
`?'
4695
     Indicate the reason the target halted.  The reply is the same as
4696
     for step and continue.  This packet has a special interpretation
4697
     when the target is in non-stop mode; see *Note Remote Non-Stop::.
4698
 
4699
     Reply: *Note Stop Reply Packets::, for the reply specifications.
4700
 
4701
`A ARGLEN,ARGNUM,ARG,...'
4702
     Initialized `argv[]' array passed into program. ARGLEN specifies
4703
     the number of bytes in the hex encoded byte stream ARG.  See
4704
     `gdbserver' for more details.
4705
 
4706
     Reply:
4707
    `OK'
4708
          The arguments were set.
4709
 
4710
    `E NN'
4711
          An error occurred.
4712
 
4713
`b BAUD'
4714
     (Don't use this packet; its behavior is not well-defined.)  Change
4715
     the serial line speed to BAUD.
4716
 
4717
     JTC: _When does the transport layer state change?  When it's
4718
     received, or after the ACK is transmitted.  In either case, there
4719
     are problems if the command or the acknowledgment packet is
4720
     dropped._
4721
 
4722
     Stan: _If people really wanted to add something like this, and get
4723
     it working for the first time, they ought to modify ser-unix.c to
4724
     send some kind of out-of-band message to a specially-setup stub
4725
     and have the switch happen "in between" packets, so that from
4726
     remote protocol's point of view, nothing actually happened._
4727
 
4728
`B ADDR,MODE'
4729
     Set (MODE is `S') or clear (MODE is `C') a breakpoint at ADDR.
4730
 
4731
     Don't use this packet.  Use the `Z' and `z' packets instead (*note
4732
     insert breakpoint or watchpoint packet::).
4733
 
4734
`bc'
4735
     Backward continue.  Execute the target system in reverse.  No
4736
     parameter.  *Note Reverse Execution::, for more information.
4737
 
4738
     Reply: *Note Stop Reply Packets::, for the reply specifications.
4739
 
4740
`bs'
4741
     Backward single step.  Execute one instruction in reverse.  No
4742
     parameter.  *Note Reverse Execution::, for more information.
4743
 
4744
     Reply: *Note Stop Reply Packets::, for the reply specifications.
4745
 
4746
`c [ADDR]'
4747
     Continue.  ADDR is address to resume.  If ADDR is omitted, resume
4748
     at current address.
4749
 
4750
     Reply: *Note Stop Reply Packets::, for the reply specifications.
4751
 
4752
`C SIG[;ADDR]'
4753
     Continue with signal SIG (hex signal number).  If `;ADDR' is
4754
     omitted, resume at same address.
4755
 
4756
     Reply: *Note Stop Reply Packets::, for the reply specifications.
4757
 
4758
`d'
4759
     Toggle debug flag.
4760
 
4761
     Don't use this packet; instead, define a general set packet (*note
4762
     General Query Packets::).
4763
 
4764
`D'
4765
`D;PID'
4766
     The first form of the packet is used to detach GDB from the remote
4767
     system.  It is sent to the remote target before GDB disconnects
4768
     via the `detach' command.
4769
 
4770
     The second form, including a process ID, is used when multiprocess
4771
     protocol extensions are enabled (*note multiprocess extensions::),
4772
     to detach only a specific process.  The PID is specified as a
4773
     big-endian hex string.
4774
 
4775
     Reply:
4776
    `OK'
4777
          for success
4778
 
4779
    `E NN'
4780
          for an error
4781
 
4782
`F RC,EE,CF;XX'
4783
     A reply from GDB to an `F' packet sent by the target.  This is
4784
     part of the File-I/O protocol extension.  *Note File-I/O Remote
4785
     Protocol Extension::, for the specification.
4786
 
4787
`g'
4788
     Read general registers.
4789
 
4790
     Reply:
4791
    `XX...'
4792
          Each byte of register data is described by two hex digits.
4793
          The bytes with the register are transmitted in target byte
4794
          order.  The size of each register and their position within
4795
          the `g' packet are determined by the GDB internal gdbarch
4796
          functions `DEPRECATED_REGISTER_RAW_SIZE' and
4797
          `gdbarch_register_name'.  The specification of several
4798
          standard `g' packets is specified below.
4799
 
4800
    `E NN'
4801
          for an error.
4802
 
4803
`G XX...'
4804
     Write general registers.  *Note read registers packet::, for a
4805
     description of the XX... data.
4806
 
4807
     Reply:
4808
    `OK'
4809
          for success
4810
 
4811
    `E NN'
4812
          for an error
4813
 
4814
`H C THREAD-ID'
4815
     Set thread for subsequent operations (`m', `M', `g', `G', et.al.).
4816
     C depends on the operation to be performed: it should be `c' for
4817
     step and continue operations, `g' for other operations.  The
4818
     thread designator THREAD-ID has the format and interpretation
4819
     described in *Note thread-id syntax::.
4820
 
4821
     Reply:
4822
    `OK'
4823
          for success
4824
 
4825
    `E NN'
4826
          for an error
4827
 
4828
`i [ADDR[,NNN]]'
4829
     Step the remote target by a single clock cycle.  If `,NNN' is
4830
     present, cycle step NNN cycles.  If ADDR is present, cycle step
4831
     starting at that address.
4832
 
4833
`I'
4834
     Signal, then cycle step.  *Note step with signal packet::.  *Note
4835
     cycle step packet::.
4836
 
4837
`k'
4838
     Kill request.
4839
 
4840
     FIXME: _There is no description of how to operate when a specific
4841
     thread context has been selected (i.e. does 'k' kill only that
4842
     thread?)_.
4843
 
4844
`m ADDR,LENGTH'
4845
     Read LENGTH bytes of memory starting at address ADDR.  Note that
4846
     ADDR may not be aligned to any particular boundary.
4847
 
4848
     The stub need not use any particular size or alignment when
4849
     gathering data from memory for the response; even if ADDR is
4850
     word-aligned and LENGTH is a multiple of the word size, the stub
4851
     is free to use byte accesses, or not.  For this reason, this
4852
     packet may not be suitable for accessing memory-mapped I/O devices.
4853
 
4854
     Reply:
4855
    `XX...'
4856
          Memory contents; each byte is transmitted as a two-digit
4857
          hexadecimal number.  The reply may contain fewer bytes than
4858
          requested if the server was able to read only part of the
4859
          region of memory.
4860
 
4861
    `E NN'
4862
          NN is errno
4863
 
4864
`M ADDR,LENGTH:XX...'
4865
     Write LENGTH bytes of memory starting at address ADDR.  XX... is
4866
     the data; each byte is transmitted as a two-digit hexadecimal
4867
     number.
4868
 
4869
     Reply:
4870
    `OK'
4871
          for success
4872
 
4873
    `E NN'
4874
          for an error (this includes the case where only part of the
4875
          data was written).
4876
 
4877
`p N'
4878
     Read the value of register N; N is in hex.  *Note read registers
4879
     packet::, for a description of how the returned register value is
4880
     encoded.
4881
 
4882
     Reply:
4883
    `XX...'
4884
          the register's value
4885
 
4886
    `E NN'
4887
          for an error
4888
 
4889
    `'
4890
          Indicating an unrecognized QUERY.
4891
 
4892
`P N...=R...'
4893
     Write register N... with value R....  The register number N is in
4894
     hexadecimal, and R... contains two hex digits for each byte in the
4895
     register (target byte order).
4896
 
4897
     Reply:
4898
    `OK'
4899
          for success
4900
 
4901
    `E NN'
4902
          for an error
4903
 
4904
`q NAME PARAMS...'
4905
`Q NAME PARAMS...'
4906
     General query (`q') and set (`Q').  These packets are described
4907
     fully in *Note General Query Packets::.
4908
 
4909
`r'
4910
     Reset the entire system.
4911
 
4912
     Don't use this packet; use the `R' packet instead.
4913
 
4914
`R XX'
4915
     Restart the program being debugged.  XX, while needed, is ignored.
4916
     This packet is only available in extended mode (*note extended
4917
     mode::).
4918
 
4919
     The `R' packet has no reply.
4920
 
4921
`s [ADDR]'
4922
     Single step.  ADDR is the address at which to resume.  If ADDR is
4923
     omitted, resume at same address.
4924
 
4925
     Reply: *Note Stop Reply Packets::, for the reply specifications.
4926
 
4927
`S SIG[;ADDR]'
4928
     Step with signal.  This is analogous to the `C' packet, but
4929
     requests a single-step, rather than a normal resumption of
4930
     execution.
4931
 
4932
     Reply: *Note Stop Reply Packets::, for the reply specifications.
4933
 
4934
`t ADDR:PP,MM'
4935
     Search backwards starting at address ADDR for a match with pattern
4936
     PP and mask MM.  PP and MM are 4 bytes.  ADDR must be at least 3
4937
     digits.
4938
 
4939
`T THREAD-ID'
4940
     Find out if the thread THREAD-ID is alive.  *Note thread-id
4941
     syntax::.
4942
 
4943
     Reply:
4944
    `OK'
4945
          thread is still alive
4946
 
4947
    `E NN'
4948
          thread is dead
4949
 
4950
`v'
4951
     Packets starting with `v' are identified by a multi-letter name,
4952
     up to the first `;' or `?' (or the end of the packet).
4953
 
4954
`vAttach;PID'
4955
     Attach to a new process with the specified process ID PID.  The
4956
     process ID is a hexadecimal integer identifying the process.  In
4957
     all-stop mode, all threads in the attached process are stopped; in
4958
     non-stop mode, it may be attached without being stopped if that is
4959
     supported by the target.
4960
 
4961
     This packet is only available in extended mode (*note extended
4962
     mode::).
4963
 
4964
     Reply:
4965
    `E NN'
4966
          for an error
4967
 
4968
    `Any stop packet'
4969
          for success in all-stop mode (*note Stop Reply Packets::)
4970
 
4971
    `OK'
4972
          for success in non-stop mode (*note Remote Non-Stop::)
4973
 
4974
`vCont[;ACTION[:THREAD-ID]]...'
4975
     Resume the inferior, specifying different actions for each thread.
4976
     If an action is specified with no THREAD-ID, then it is applied to
4977
     any threads that don't have a specific action specified; if no
4978
     default action is specified then other threads should remain
4979
     stopped in all-stop mode and in their current state in non-stop
4980
     mode.  Specifying multiple default actions is an error; specifying
4981
     no actions is also an error.  Thread IDs are specified using the
4982
     syntax described in *Note thread-id syntax::.
4983
 
4984
     Currently supported actions are:
4985
 
4986
    `c'
4987
          Continue.
4988
 
4989
    `C SIG'
4990
          Continue with signal SIG.  The signal SIG should be two hex
4991
          digits.
4992
 
4993
    `s'
4994
          Step.
4995
 
4996
    `S SIG'
4997
          Step with signal SIG.  The signal SIG should be two hex
4998
          digits.
4999
 
5000
    `t'
5001
          Stop.
5002
 
5003
     The optional argument ADDR normally associated with the `c', `C',
5004
     `s', and `S' packets is not supported in `vCont'.
5005
 
5006
     The `t' action is only relevant in non-stop mode (*note Remote
5007
     Non-Stop::) and may be ignored by the stub otherwise.  A stop
5008
     reply should be generated for any affected thread not already
5009
     stopped.  When a thread is stopped by means of a `t' action, the
5010
     corresponding stop reply should indicate that the thread has
5011
     stopped with signal `0', regardless of whether the target uses
5012
     some other signal as an implementation detail.
5013
 
5014
     Reply: *Note Stop Reply Packets::, for the reply specifications.
5015
 
5016
`vCont?'
5017
     Request a list of actions supported by the `vCont' packet.
5018
 
5019
     Reply:
5020
    `vCont[;ACTION...]'
5021
          The `vCont' packet is supported.  Each ACTION is a supported
5022
          command in the `vCont' packet.
5023
 
5024
    `'
5025
          The `vCont' packet is not supported.
5026
 
5027
`vFile:OPERATION:PARAMETER...'
5028
     Perform a file operation on the target system.  For details, see
5029
     *Note Host I/O Packets::.
5030
 
5031
`vFlashErase:ADDR,LENGTH'
5032
     Direct the stub to erase LENGTH bytes of flash starting at ADDR.
5033
     The region may enclose any number of flash blocks, but its start
5034
     and end must fall on block boundaries, as indicated by the flash
5035
     block size appearing in the memory map (*note Memory Map
5036
     Format::).  GDB groups flash memory programming operations
5037
     together, and sends a `vFlashDone' request after each group; the
5038
     stub is allowed to delay erase operation until the `vFlashDone'
5039
     packet is received.
5040
 
5041
     The stub must support `vCont' if it reports support for
5042
     multiprocess extensions (*note multiprocess extensions::).  Note
5043
     that in this case `vCont' actions can be specified to apply to all
5044
     threads in a process by using the `pPID.-1' form of the THREAD-ID.
5045
 
5046
     Reply:
5047
    `OK'
5048
          for success
5049
 
5050
    `E NN'
5051
          for an error
5052
 
5053
`vFlashWrite:ADDR:XX...'
5054
     Direct the stub to write data to flash address ADDR.  The data is
5055
     passed in binary form using the same encoding as for the `X'
5056
     packet (*note Binary Data::).  The memory ranges specified by
5057
     `vFlashWrite' packets preceding a `vFlashDone' packet must not
5058
     overlap, and must appear in order of increasing addresses
5059
     (although `vFlashErase' packets for higher addresses may already
5060
     have been received; the ordering is guaranteed only between
5061
     `vFlashWrite' packets).  If a packet writes to an address that was
5062
     neither erased by a preceding `vFlashErase' packet nor by some
5063
     other target-specific method, the results are unpredictable.
5064
 
5065
     Reply:
5066
    `OK'
5067
          for success
5068
 
5069
    `E.memtype'
5070
          for vFlashWrite addressing non-flash memory
5071
 
5072
    `E NN'
5073
          for an error
5074
 
5075
`vFlashDone'
5076
     Indicate to the stub that flash programming operation is finished.
5077
     The stub is permitted to delay or batch the effects of a group of
5078
     `vFlashErase' and `vFlashWrite' packets until a `vFlashDone'
5079
     packet is received.  The contents of the affected regions of flash
5080
     memory are unpredictable until the `vFlashDone' request is
5081
     completed.
5082
 
5083
`vKill;PID'
5084
     Kill the process with the specified process ID.  PID is a
5085
     hexadecimal integer identifying the process.  This packet is used
5086
     in preference to `k' when multiprocess protocol extensions are
5087
     supported; see *Note multiprocess extensions::.
5088
 
5089
     Reply:
5090
    `E NN'
5091
          for an error
5092
 
5093
    `OK'
5094
          for success
5095
 
5096
`vRun;FILENAME[;ARGUMENT]...'
5097
     Run the program FILENAME, passing it each ARGUMENT on its command
5098
     line.  The file and arguments are hex-encoded strings.  If
5099
     FILENAME is an empty string, the stub may use a default program
5100
     (e.g. the last program run).  The program is created in the stopped
5101
     state.
5102
 
5103
     This packet is only available in extended mode (*note extended
5104
     mode::).
5105
 
5106
     Reply:
5107
    `E NN'
5108
          for an error
5109
 
5110
    `Any stop packet'
5111
          for success (*note Stop Reply Packets::)
5112
 
5113
`vStopped'
5114
     In non-stop mode (*note Remote Non-Stop::), acknowledge a previous
5115
     stop reply and prompt for the stub to report another one.
5116
 
5117
     Reply:
5118
    `Any stop packet'
5119
          if there is another unreported stop event (*note Stop Reply
5120
          Packets::)
5121
 
5122
    `OK'
5123
          if there are no unreported stop events
5124
 
5125
`X ADDR,LENGTH:XX...'
5126
     Write data to memory, where the data is transmitted in binary.
5127
     ADDR is address, LENGTH is number of bytes, `XX...' is binary data
5128
     (*note Binary Data::).
5129
 
5130
     Reply:
5131
    `OK'
5132
          for success
5133
 
5134
    `E NN'
5135
          for an error
5136
 
5137
`z TYPE,ADDR,KIND'
5138
`Z TYPE,ADDR,KIND'
5139
     Insert (`Z') or remove (`z') a TYPE breakpoint or watchpoint
5140
     starting at address ADDRESS of kind KIND.
5141
 
5142
     Each breakpoint and watchpoint packet TYPE is documented
5143
     separately.
5144
 
5145
     _Implementation notes: A remote target shall return an empty string
5146
     for an unrecognized breakpoint or watchpoint packet TYPE.  A
5147
     remote target shall support either both or neither of a given
5148
     `ZTYPE...' and `zTYPE...' packet pair.  To avoid potential
5149
     problems with duplicate packets, the operations should be
5150
     implemented in an idempotent way._
5151
 
5152
`z0,ADDR,KIND'
5153
`Z0,ADDR,KIND'
5154
     Insert (`Z0') or remove (`z0') a memory breakpoint at address ADDR
5155
     of type KIND.
5156
 
5157
     A memory breakpoint is implemented by replacing the instruction at
5158
     ADDR with a software breakpoint or trap instruction.  The KIND is
5159
     target-specific and typically indicates the size of the breakpoint
5160
     in bytes that should be inserted.  E.g., the ARM and MIPS can
5161
     insert either a 2 or 4 byte breakpoint.  Some architectures have
5162
     additional meanings for KIND; see *Note Architecture-Specific
5163
     Protocol Details::.
5164
 
5165
     _Implementation note: It is possible for a target to copy or move
5166
     code that contains memory breakpoints (e.g., when implementing
5167
     overlays).  The behavior of this packet, in the presence of such a
5168
     target, is not defined._
5169
 
5170
     Reply:
5171
    `OK'
5172
          success
5173
 
5174
    `'
5175
          not supported
5176
 
5177
    `E NN'
5178
          for an error
5179
 
5180
`z1,ADDR,KIND'
5181
`Z1,ADDR,KIND'
5182
     Insert (`Z1') or remove (`z1') a hardware breakpoint at address
5183
     ADDR.
5184
 
5185
     A hardware breakpoint is implemented using a mechanism that is not
5186
     dependant on being able to modify the target's memory.  KIND has
5187
     the same meaning as in `Z0' packets.
5188
 
5189
     _Implementation note: A hardware breakpoint is not affected by code
5190
     movement._
5191
 
5192
     Reply:
5193
    `OK'
5194
          success
5195
 
5196
    `'
5197
          not supported
5198
 
5199
    `E NN'
5200
          for an error
5201
 
5202
`z2,ADDR,KIND'
5203
`Z2,ADDR,KIND'
5204
     Insert (`Z2') or remove (`z2') a write watchpoint at ADDR.  KIND
5205
     is interpreted as the number of bytes to watch.
5206
 
5207
     Reply:
5208
    `OK'
5209
          success
5210
 
5211
    `'
5212
          not supported
5213
 
5214
    `E NN'
5215
          for an error
5216
 
5217
`z3,ADDR,KIND'
5218
`Z3,ADDR,KIND'
5219
     Insert (`Z3') or remove (`z3') a read watchpoint at ADDR.  KIND is
5220
     interpreted as the number of bytes to watch.
5221
 
5222
     Reply:
5223
    `OK'
5224
          success
5225
 
5226
    `'
5227
          not supported
5228
 
5229
    `E NN'
5230
          for an error
5231
 
5232
`z4,ADDR,KIND'
5233
`Z4,ADDR,KIND'
5234
     Insert (`Z4') or remove (`z4') an access watchpoint at ADDR.  KIND
5235
     is interpreted as the number of bytes to watch.
5236
 
5237
     Reply:
5238
    `OK'
5239
          success
5240
 
5241
    `'
5242
          not supported
5243
 
5244
    `E NN'
5245
          for an error
5246
 
5247
 
5248

5249
File: gdb.info,  Node: Stop Reply Packets,  Next: General Query Packets,  Prev: Packets,  Up: Remote Protocol
5250
 
5251
D.3 Stop Reply Packets
5252
======================
5253
 
5254
The `C', `c', `S', `s', `vCont', `vAttach', `vRun', `vStopped', and `?'
5255
packets can receive any of the below as a reply.  Except for `?' and
5256
`vStopped', that reply is only returned when the target halts.  In the
5257
below the exact meaning of "signal number" is defined by the header
5258
`include/gdb/signals.h' in the GDB source code.
5259
 
5260
   As in the description of request packets, we include spaces in the
5261
reply templates for clarity; these are not part of the reply packet's
5262
syntax.  No GDB stop reply packet uses spaces to separate its
5263
components.
5264
 
5265
`S AA'
5266
     The program received signal number AA (a two-digit hexadecimal
5267
     number).  This is equivalent to a `T' response with no N:R pairs.
5268
 
5269
`T AA N1:R1;N2:R2;...'
5270
     The program received signal number AA (a two-digit hexadecimal
5271
     number).  This is equivalent to an `S' response, except that the
5272
     `N:R' pairs can carry values of important registers and other
5273
     information directly in the stop reply packet, reducing round-trip
5274
     latency.  Single-step and breakpoint traps are reported this way.
5275
     Each `N:R' pair is interpreted as follows:
5276
 
5277
        * If N is a hexadecimal number, it is a register number, and the
5278
          corresponding R gives that register's value.  R is a series
5279
          of bytes in target byte order, with each byte given by a
5280
          two-digit hex number.
5281
 
5282
        * If N is `thread', then R is the THREAD-ID of the stopped
5283
          thread, as specified in *Note thread-id syntax::.
5284
 
5285
        * If N is `core', then R is the hexadecimal number of the core
5286
          on which the stop event was detected.
5287
 
5288
        * If N is a recognized "stop reason", it describes a more
5289
          specific event that stopped the target.  The currently
5290
          defined stop reasons are listed below.  AA should be `05',
5291
          the trap signal.  At most one stop reason should be present.
5292
 
5293
        * Otherwise, GDB should ignore this `N:R' pair and go on to the
5294
          next; this allows us to extend the protocol in the future.
5295
 
5296
     The currently defined stop reasons are:
5297
 
5298
    `watch'
5299
    `rwatch'
5300
    `awatch'
5301
          The packet indicates a watchpoint hit, and R is the data
5302
          address, in hex.
5303
 
5304
    `library'
5305
          The packet indicates that the loaded libraries have changed.
5306
          GDB should use `qXfer:libraries:read' to fetch a new list of
5307
          loaded libraries.  R is ignored.
5308
 
5309
    `replaylog'
5310
          The packet indicates that the target cannot continue replaying
5311
          logged execution events, because it has reached the end (or
5312
          the beginning when executing backward) of the log.  The value
5313
          of R will be either `begin' or `end'.  *Note Reverse
5314
          Execution::, for more information.
5315
 
5316
`W AA'
5317
`W AA ; process:PID'
5318
     The process exited, and AA is the exit status.  This is only
5319
     applicable to certain targets.
5320
 
5321
     The second form of the response, including the process ID of the
5322
     exited process, can be used only when GDB has reported support for
5323
     multiprocess protocol extensions; see *Note multiprocess
5324
     extensions::.  The PID is formatted as a big-endian hex string.
5325
 
5326
`X AA'
5327
`X AA ; process:PID'
5328
     The process terminated with signal AA.
5329
 
5330
     The second form of the response, including the process ID of the
5331
     terminated process, can be used only when GDB has reported support
5332
     for multiprocess protocol extensions; see *Note multiprocess
5333
     extensions::.  The PID is formatted as a big-endian hex string.
5334
 
5335
`O XX...'
5336
     `XX...' is hex encoding of ASCII data, to be written as the
5337
     program's console output.  This can happen at any time while the
5338
     program is running and the debugger should continue to wait for
5339
     `W', `T', etc.  This reply is not permitted in non-stop mode.
5340
 
5341
`F CALL-ID,PARAMETER...'
5342
     CALL-ID is the identifier which says which host system call should
5343
     be called.  This is just the name of the function.  Translation
5344
     into the correct system call is only applicable as it's defined in
5345
     GDB.  *Note File-I/O Remote Protocol Extension::, for a list of
5346
     implemented system calls.
5347
 
5348
     `PARAMETER...' is a list of parameters as defined for this very
5349
     system call.
5350
 
5351
     The target replies with this packet when it expects GDB to call a
5352
     host system call on behalf of the target.  GDB replies with an
5353
     appropriate `F' packet and keeps up waiting for the next reply
5354
     packet from the target.  The latest `C', `c', `S' or `s' action is
5355
     expected to be continued.  *Note File-I/O Remote Protocol
5356
     Extension::, for more details.
5357
 
5358
 
5359

5360
File: gdb.info,  Node: General Query Packets,  Next: Architecture-Specific Protocol Details,  Prev: Stop Reply Packets,  Up: Remote Protocol
5361
 
5362
D.4 General Query Packets
5363
=========================
5364
 
5365
Packets starting with `q' are "general query packets"; packets starting
5366
with `Q' are "general set packets".  General query and set packets are
5367
a semi-unified form for retrieving and sending information to and from
5368
the stub.
5369
 
5370
   The initial letter of a query or set packet is followed by a name
5371
indicating what sort of thing the packet applies to.  For example, GDB
5372
may use a `qSymbol' packet to exchange symbol definitions with the
5373
stub.  These packet names follow some conventions:
5374
 
5375
   * The name must not contain commas, colons or semicolons.
5376
 
5377
   * Most GDB query and set packets have a leading upper case letter.
5378
 
5379
   * The names of custom vendor packets should use a company prefix, in
5380
     lower case, followed by a period.  For example, packets designed at
5381
     the Acme Corporation might begin with `qacme.foo' (for querying
5382
     foos) or `Qacme.bar' (for setting bars).
5383
 
5384
   The name of a query or set packet should be separated from any
5385
parameters by a `:'; the parameters themselves should be separated by
5386
`,' or `;'.  Stubs must be careful to match the full packet name, and
5387
check for a separator or the end of the packet, in case two packet
5388
names share a common prefix.  New packets should not begin with `qC',
5389
`qP', or `qL'(1).
5390
 
5391
   Like the descriptions of the other packets, each description here
5392
has a template showing the packet's overall syntax, followed by an
5393
explanation of the packet's meaning.  We include spaces in some of the
5394
templates for clarity; these are not part of the packet's syntax.  No
5395
GDB packet uses spaces to separate its components.
5396
 
5397
   Here are the currently defined query and set packets:
5398
 
5399
`QAllow:OP:VAL...'
5400
     Specify which operations GDB expects to request of the target, as
5401
     a semicolon-separated list of operation name and value pairs.
5402
     Possible values for OP include `WriteReg', `WriteMem',
5403
     `InsertBreak', `InsertTrace', `InsertFastTrace', and `Stop'. VAL
5404
     is either 0, indicating that GDB will not request the operation,
5405
     or 1, indicating that it may.  (The target can then use this to
5406
     set up its own internals optimally, for instance if the debugger
5407
     never expects to insert breakpoints, it may not need to install
5408
     its own trap handler.)
5409
 
5410
`qC'
5411
     Return the current thread ID.
5412
 
5413
     Reply:
5414
    `QC THREAD-ID'
5415
          Where THREAD-ID is a thread ID as documented in *Note
5416
          thread-id syntax::.
5417
 
5418
    `(anything else)'
5419
          Any other reply implies the old thread ID.
5420
 
5421
`qCRC:ADDR,LENGTH'
5422
     Compute the CRC checksum of a block of memory using CRC-32 defined
5423
     in IEEE 802.3.  The CRC is computed byte at a time, taking the most
5424
     significant bit of each byte first.  The initial pattern code
5425
     `0xffffffff' is used to ensure leading zeros affect the CRC.
5426
 
5427
     _Note:_ This is the same CRC used in validating separate debug
5428
     files (*note Debugging Information in Separate Files: Separate
5429
     Debug Files.).  However the algorithm is slightly different.  When
5430
     validating separate debug files, the CRC is computed taking the
5431
     _least_ significant bit of each byte first, and the final result
5432
     is inverted to detect trailing zeros.
5433
 
5434
     Reply:
5435
    `E NN'
5436
          An error (such as memory fault)
5437
 
5438
    `C CRC32'
5439
          The specified memory region's checksum is CRC32.
5440
 
5441
`qfThreadInfo'
5442
`qsThreadInfo'
5443
     Obtain a list of all active thread IDs from the target (OS).
5444
     Since there may be too many active threads to fit into one reply
5445
     packet, this query works iteratively: it may require more than one
5446
     query/reply sequence to obtain the entire list of threads.  The
5447
     first query of the sequence will be the `qfThreadInfo' query;
5448
     subsequent queries in the sequence will be the `qsThreadInfo'
5449
     query.
5450
 
5451
     NOTE: This packet replaces the `qL' query (see below).
5452
 
5453
     Reply:
5454
    `m THREAD-ID'
5455
          A single thread ID
5456
 
5457
    `m THREAD-ID,THREAD-ID...'
5458
          a comma-separated list of thread IDs
5459
 
5460
    `l'
5461
          (lower case letter `L') denotes end of list.
5462
 
5463
     In response to each query, the target will reply with a list of
5464
     one or more thread IDs, separated by commas.  GDB will respond to
5465
     each reply with a request for more thread ids (using the `qs' form
5466
     of the query), until the target responds with `l' (lower-case ell,
5467
     for "last").  Refer to *Note thread-id syntax::, for the format of
5468
     the THREAD-ID fields.
5469
 
5470
`qGetTLSAddr:THREAD-ID,OFFSET,LM'
5471
     Fetch the address associated with thread local storage specified
5472
     by THREAD-ID, OFFSET, and LM.
5473
 
5474
     THREAD-ID is the thread ID associated with the thread for which to
5475
     fetch the TLS address.  *Note thread-id syntax::.
5476
 
5477
     OFFSET is the (big endian, hex encoded) offset associated with the
5478
     thread local variable.  (This offset is obtained from the debug
5479
     information associated with the variable.)
5480
 
5481
     LM is the (big endian, hex encoded) OS/ABI-specific encoding of the
5482
     the load module associated with the thread local storage.  For
5483
     example, a GNU/Linux system will pass the link map address of the
5484
     shared object associated with the thread local storage under
5485
     consideration.  Other operating environments may choose to
5486
     represent the load module differently, so the precise meaning of
5487
     this parameter will vary.
5488
 
5489
     Reply:
5490
    `XX...'
5491
          Hex encoded (big endian) bytes representing the address of
5492
          the thread local storage requested.
5493
 
5494
    `E NN'
5495
          An error occurred.  NN are hex digits.
5496
 
5497
    `'
5498
          An empty reply indicates that `qGetTLSAddr' is not supported
5499
          by the stub.
5500
 
5501
`qGetTIBAddr:THREAD-ID'
5502
     Fetch address of the Windows OS specific Thread Information Block.
5503
 
5504
     THREAD-ID is the thread ID associated with the thread.
5505
 
5506
     Reply:
5507
    `XX...'
5508
          Hex encoded (big endian) bytes representing the linear
5509
          address of the thread information block.
5510
 
5511
    `E NN'
5512
          An error occured.  This means that either the thread was not
5513
          found, or the address could not be retrieved.
5514
 
5515
    `'
5516
          An empty reply indicates that `qGetTIBAddr' is not supported
5517
          by the stub.
5518
 
5519
`qL STARTFLAG THREADCOUNT NEXTTHREAD'
5520
     Obtain thread information from RTOS.  Where: STARTFLAG (one hex
5521
     digit) is one to indicate the first query and zero to indicate a
5522
     subsequent query; THREADCOUNT (two hex digits) is the maximum
5523
     number of threads the response packet can contain; and NEXTTHREAD
5524
     (eight hex digits), for subsequent queries (STARTFLAG is zero), is
5525
     returned in the response as ARGTHREAD.
5526
 
5527
     Don't use this packet; use the `qfThreadInfo' query instead (see
5528
     above).
5529
 
5530
     Reply:
5531
    `qM COUNT DONE ARGTHREAD THREAD...'
5532
          Where: COUNT (two hex digits) is the number of threads being
5533
          returned; DONE (one hex digit) is zero to indicate more
5534
          threads and one indicates no further threads; ARGTHREADID
5535
          (eight hex digits) is NEXTTHREAD from the request packet;
5536
          THREAD...  is a sequence of thread IDs from the target.
5537
          THREADID (eight hex digits).  See
5538
          `remote.c:parse_threadlist_response()'.
5539
 
5540
`qOffsets'
5541
     Get section offsets that the target used when relocating the
5542
     downloaded image.
5543
 
5544
     Reply:
5545
    `Text=XXX;Data=YYY[;Bss=ZZZ]'
5546
          Relocate the `Text' section by XXX from its original address.
5547
          Relocate the `Data' section by YYY from its original address.
5548
          If the object file format provides segment information (e.g.
5549
          ELF `PT_LOAD' program headers), GDB will relocate entire
5550
          segments by the supplied offsets.
5551
 
5552
          _Note: while a `Bss' offset may be included in the response,
5553
          GDB ignores this and instead applies the `Data' offset to the
5554
          `Bss' section._
5555
 
5556
    `TextSeg=XXX[;DataSeg=YYY]'
5557
          Relocate the first segment of the object file, which
5558
          conventionally contains program code, to a starting address
5559
          of XXX.  If `DataSeg' is specified, relocate the second
5560
          segment, which conventionally contains modifiable data, to a
5561
          starting address of YYY.  GDB will report an error if the
5562
          object file does not contain segment information, or does not
5563
          contain at least as many segments as mentioned in the reply.
5564
          Extra segments are kept at fixed offsets relative to the last
5565
          relocated segment.
5566
 
5567
`qP MODE THREAD-ID'
5568
     Returns information on THREAD-ID.  Where: MODE is a hex encoded 32
5569
     bit mode; THREAD-ID is a thread ID (*note thread-id syntax::).
5570
 
5571
     Don't use this packet; use the `qThreadExtraInfo' query instead
5572
     (see below).
5573
 
5574
     Reply: see `remote.c:remote_unpack_thread_info_response()'.
5575
 
5576
`QNonStop:1'
5577
 
5578
`QNonStop:0'
5579
     Enter non-stop (`QNonStop:1') or all-stop (`QNonStop:0') mode.
5580
     *Note Remote Non-Stop::, for more information.
5581
 
5582
     Reply:
5583
    `OK'
5584
          The request succeeded.
5585
 
5586
    `E NN'
5587
          An error occurred.  NN are hex digits.
5588
 
5589
    `'
5590
          An empty reply indicates that `QNonStop' is not supported by
5591
          the stub.
5592
 
5593
     This packet is not probed by default; the remote stub must request
5594
     it, by supplying an appropriate `qSupported' response (*note
5595
     qSupported::).  Use of this packet is controlled by the `set
5596
     non-stop' command; *note Non-Stop Mode::.
5597
 
5598
`QPassSignals: SIGNAL [;SIGNAL]...'
5599
     Each listed SIGNAL should be passed directly to the inferior
5600
     process.  Signals are numbered identically to continue packets and
5601
     stop replies (*note Stop Reply Packets::).  Each SIGNAL list item
5602
     should be strictly greater than the previous item.  These signals
5603
     do not need to stop the inferior, or be reported to GDB.  All
5604
     other signals should be reported to GDB.  Multiple `QPassSignals'
5605
     packets do not combine; any earlier `QPassSignals' list is
5606
     completely replaced by the new list.  This packet improves
5607
     performance when using `handle SIGNAL nostop noprint pass'.
5608
 
5609
     Reply:
5610
    `OK'
5611
          The request succeeded.
5612
 
5613
    `E NN'
5614
          An error occurred.  NN are hex digits.
5615
 
5616
    `'
5617
          An empty reply indicates that `QPassSignals' is not supported
5618
          by the stub.
5619
 
5620
     Use of this packet is controlled by the `set remote pass-signals'
5621
     command (*note set remote pass-signals: Remote Configuration.).
5622
     This packet is not probed by default; the remote stub must request
5623
     it, by supplying an appropriate `qSupported' response (*note
5624
     qSupported::).
5625
 
5626
`qRcmd,COMMAND'
5627
     COMMAND (hex encoded) is passed to the local interpreter for
5628
     execution.  Invalid commands should be reported using the output
5629
     string.  Before the final result packet, the target may also
5630
     respond with a number of intermediate `OOUTPUT' console output
5631
     packets.  _Implementors should note that providing access to a
5632
     stubs's interpreter may have security implications_.
5633
 
5634
     Reply:
5635
    `OK'
5636
          A command response with no output.
5637
 
5638
    `OUTPUT'
5639
          A command response with the hex encoded output string OUTPUT.
5640
 
5641
    `E NN'
5642
          Indicate a badly formed request.
5643
 
5644
    `'
5645
          An empty reply indicates that `qRcmd' is not recognized.
5646
 
5647
     (Note that the `qRcmd' packet's name is separated from the command
5648
     by a `,', not a `:', contrary to the naming conventions above.
5649
     Please don't use this packet as a model for new packets.)
5650
 
5651
`qSearch:memory:ADDRESS;LENGTH;SEARCH-PATTERN'
5652
     Search LENGTH bytes at ADDRESS for SEARCH-PATTERN.  ADDRESS and
5653
     LENGTH are encoded in hex.  SEARCH-PATTERN is a sequence of bytes,
5654
     hex encoded.
5655
 
5656
     Reply:
5657
    `0'
5658
          The pattern was not found.
5659
 
5660
    `1,address'
5661
          The pattern was found at ADDRESS.
5662
 
5663
    `E NN'
5664
          A badly formed request or an error was encountered while
5665
          searching memory.
5666
 
5667
    `'
5668
          An empty reply indicates that `qSearch:memory' is not
5669
          recognized.
5670
 
5671
`QStartNoAckMode'
5672
     Request that the remote stub disable the normal `+'/`-' protocol
5673
     acknowledgments (*note Packet Acknowledgment::).
5674
 
5675
     Reply:
5676
    `OK'
5677
          The stub has switched to no-acknowledgment mode.  GDB
5678
          acknowledges this reponse, but neither the stub nor GDB shall
5679
          send or expect further `+'/`-' acknowledgments in the current
5680
          connection.
5681
 
5682
    `'
5683
          An empty reply indicates that the stub does not support
5684
          no-acknowledgment mode.
5685
 
5686
`qSupported [:GDBFEATURE [;GDBFEATURE]... ]'
5687
     Tell the remote stub about features supported by GDB, and query
5688
     the stub for features it supports.  This packet allows GDB and the
5689
     remote stub to take advantage of each others' features.
5690
     `qSupported' also consolidates multiple feature probes at startup,
5691
     to improve GDB performance--a single larger packet performs better
5692
     than multiple smaller probe packets on high-latency links.  Some
5693
     features may enable behavior which must not be on by default, e.g.
5694
     because it would confuse older clients or stubs.  Other features
5695
     may describe packets which could be automatically probed for, but
5696
     are not.  These features must be reported before GDB will use
5697
     them.  This "default unsupported" behavior is not appropriate for
5698
     all packets, but it helps to keep the initial connection time
5699
     under control with new versions of GDB which support increasing
5700
     numbers of packets.
5701
 
5702
     Reply:
5703
    `STUBFEATURE [;STUBFEATURE]...'
5704
          The stub supports or does not support each returned
5705
          STUBFEATURE, depending on the form of each STUBFEATURE (see
5706
          below for the possible forms).
5707
 
5708
    `'
5709
          An empty reply indicates that `qSupported' is not recognized,
5710
          or that no features needed to be reported to GDB.
5711
 
5712
     The allowed forms for each feature (either a GDBFEATURE in the
5713
     `qSupported' packet, or a STUBFEATURE in the response) are:
5714
 
5715
    `NAME=VALUE'
5716
          The remote protocol feature NAME is supported, and associated
5717
          with the specified VALUE.  The format of VALUE depends on the
5718
          feature, but it must not include a semicolon.
5719
 
5720
    `NAME+'
5721
          The remote protocol feature NAME is supported, and does not
5722
          need an associated value.
5723
 
5724
    `NAME-'
5725
          The remote protocol feature NAME is not supported.
5726
 
5727
    `NAME?'
5728
          The remote protocol feature NAME may be supported, and GDB
5729
          should auto-detect support in some other way when it is
5730
          needed.  This form will not be used for GDBFEATURE
5731
          notifications, but may be used for STUBFEATURE responses.
5732
 
5733
     Whenever the stub receives a `qSupported' request, the supplied
5734
     set of GDB features should override any previous request.  This
5735
     allows GDB to put the stub in a known state, even if the stub had
5736
     previously been communicating with a different version of GDB.
5737
 
5738
     The following values of GDBFEATURE (for the packet sent by GDB)
5739
     are defined:
5740
 
5741
    `multiprocess'
5742
          This feature indicates whether GDB supports multiprocess
5743
          extensions to the remote protocol.  GDB does not use such
5744
          extensions unless the stub also reports that it supports them
5745
          by including `multiprocess+' in its `qSupported' reply.
5746
          *Note multiprocess extensions::, for details.
5747
 
5748
    `xmlRegisters'
5749
          This feature indicates that GDB supports the XML target
5750
          description.  If the stub sees `xmlRegisters=' with target
5751
          specific strings separated by a comma, it will report register
5752
          description.
5753
 
5754
    `qRelocInsn'
5755
          This feature indicates whether GDB supports the `qRelocInsn'
5756
          packet (*note Relocate instruction reply packet: Tracepoint
5757
          Packets.).
5758
 
5759
     Stubs should ignore any unknown values for GDBFEATURE.  Any GDB
5760
     which sends a `qSupported' packet supports receiving packets of
5761
     unlimited length (earlier versions of GDB may reject overly long
5762
     responses).  Additional values for GDBFEATURE may be defined in
5763
     the future to let the stub take advantage of new features in GDB,
5764
     e.g. incompatible improvements in the remote protocol--the
5765
     `multiprocess' feature is an example of such a feature.  The
5766
     stub's reply should be independent of the GDBFEATURE entries sent
5767
     by GDB; first GDB describes all the features it supports, and then
5768
     the stub replies with all the features it supports.
5769
 
5770
     Similarly, GDB will silently ignore unrecognized stub feature
5771
     responses, as long as each response uses one of the standard forms.
5772
 
5773
     Some features are flags.  A stub which supports a flag feature
5774
     should respond with a `+' form response.  Other features require
5775
     values, and the stub should respond with an `=' form response.
5776
 
5777
     Each feature has a default value, which GDB will use if
5778
     `qSupported' is not available or if the feature is not mentioned
5779
     in the `qSupported' response.  The default values are fixed; a
5780
     stub is free to omit any feature responses that match the defaults.
5781
 
5782
     Not all features can be probed, but for those which can, the
5783
     probing mechanism is useful: in some cases, a stub's internal
5784
     architecture may not allow the protocol layer to know some
5785
     information about the underlying target in advance.  This is
5786
     especially common in stubs which may be configured for multiple
5787
     targets.
5788
 
5789
     These are the currently defined stub features and their properties:
5790
 
5791
     Feature Name            Value         Default  Probe Allowed
5792
                             Required
5793
     `PacketSize'            Yes           `-'      No
5794
     `qXfer:auxv:read'       No            `-'      Yes
5795
     `qXfer:features:read'   No            `-'      Yes
5796
     `qXfer:libraries:read'  No            `-'      Yes
5797
     `qXfer:memory-map:read' No            `-'      Yes
5798
     `qXfer:sdata:read'      No            `-'      Yes
5799
     `qXfer:spu:read'        No            `-'      Yes
5800
     `qXfer:spu:write'       No            `-'      Yes
5801
     `qXfer:siginfo:read'    No            `-'      Yes
5802
     `qXfer:siginfo:write'   No            `-'      Yes
5803
     `qXfer:threads:read'    No            `-'      Yes
5804
     `QNonStop'              No            `-'      Yes
5805
     `QPassSignals'          No            `-'      Yes
5806
     `QStartNoAckMode'       No            `-'      Yes
5807
     `multiprocess'          No            `-'      No
5808
     `ConditionalTracepoints'No            `-'      No
5809
     `ReverseContinue'       No            `-'      No
5810
     `ReverseStep'           No            `-'      No
5811
     `TracepointSource'      No            `-'      No
5812
     `QAllow'                No            `-'      No
5813
 
5814
     These are the currently defined stub features, in more detail:
5815
 
5816
    `PacketSize=BYTES'
5817
          The remote stub can accept packets up to at least BYTES in
5818
          length.  GDB will send packets up to this size for bulk
5819
          transfers, and will never send larger packets.  This is a
5820
          limit on the data characters in the packet, including the
5821
          frame and checksum.  There is no trailing NUL byte in a
5822
          remote protocol packet; if the stub stores packets in a
5823
          NUL-terminated format, it should allow an extra byte in its
5824
          buffer for the NUL.  If this stub feature is not supported,
5825
          GDB guesses based on the size of the `g' packet response.
5826
 
5827
    `qXfer:auxv:read'
5828
          The remote stub understands the `qXfer:auxv:read' packet
5829
          (*note qXfer auxiliary vector read::).
5830
 
5831
    `qXfer:features:read'
5832
          The remote stub understands the `qXfer:features:read' packet
5833
          (*note qXfer target description read::).
5834
 
5835
    `qXfer:libraries:read'
5836
          The remote stub understands the `qXfer:libraries:read' packet
5837
          (*note qXfer library list read::).
5838
 
5839
    `qXfer:memory-map:read'
5840
          The remote stub understands the `qXfer:memory-map:read' packet
5841
          (*note qXfer memory map read::).
5842
 
5843
    `qXfer:sdata:read'
5844
          The remote stub understands the `qXfer:sdata:read' packet
5845
          (*note qXfer sdata read::).
5846
 
5847
    `qXfer:spu:read'
5848
          The remote stub understands the `qXfer:spu:read' packet
5849
          (*note qXfer spu read::).
5850
 
5851
    `qXfer:spu:write'
5852
          The remote stub understands the `qXfer:spu:write' packet
5853
          (*note qXfer spu write::).
5854
 
5855
    `qXfer:siginfo:read'
5856
          The remote stub understands the `qXfer:siginfo:read' packet
5857
          (*note qXfer siginfo read::).
5858
 
5859
    `qXfer:siginfo:write'
5860
          The remote stub understands the `qXfer:siginfo:write' packet
5861
          (*note qXfer siginfo write::).
5862
 
5863
    `qXfer:threads:read'
5864
          The remote stub understands the `qXfer:threads:read' packet
5865
          (*note qXfer threads read::).
5866
 
5867
    `QNonStop'
5868
          The remote stub understands the `QNonStop' packet (*note
5869
          QNonStop::).
5870
 
5871
    `QPassSignals'
5872
          The remote stub understands the `QPassSignals' packet (*note
5873
          QPassSignals::).
5874
 
5875
    `QStartNoAckMode'
5876
          The remote stub understands the `QStartNoAckMode' packet and
5877
          prefers to operate in no-acknowledgment mode.  *Note Packet
5878
          Acknowledgment::.
5879
 
5880
    `multiprocess'
5881
          The remote stub understands the multiprocess extensions to
5882
          the remote protocol syntax.  The multiprocess extensions
5883
          affect the syntax of thread IDs in both packets and replies
5884
          (*note thread-id syntax::), and add process IDs to the `D'
5885
          packet and `W' and `X' replies.  Note that reporting this
5886
          feature indicates support for the syntactic extensions only,
5887
          not that the stub necessarily supports debugging of more than
5888
          one process at a time.  The stub must not use multiprocess
5889
          extensions in packet replies unless GDB has also indicated it
5890
          supports them in its `qSupported' request.
5891
 
5892
    `qXfer:osdata:read'
5893
          The remote stub understands the `qXfer:osdata:read' packet
5894
          ((*note qXfer osdata read::).
5895
 
5896
    `ConditionalTracepoints'
5897
          The remote stub accepts and implements conditional
5898
          expressions defined for tracepoints (*note Tracepoint
5899
          Conditions::).
5900
 
5901
    `ReverseContinue'
5902
          The remote stub accepts and implements the reverse continue
5903
          packet (*note bc::).
5904
 
5905
    `ReverseStep'
5906
          The remote stub accepts and implements the reverse step packet
5907
          (*note bs::).
5908
 
5909
    `TracepointSource'
5910
          The remote stub understands the `QTDPsrc' packet that supplies
5911
          the source form of tracepoint definitions.
5912
 
5913
    `QAllow'
5914
          The remote stub understands the `QAllow' packet.
5915
 
5916
    `StaticTracepoint'
5917
          The remote stub supports static tracepoints.
5918
 
5919
 
5920
`qSymbol::'
5921
     Notify the target that GDB is prepared to serve symbol lookup
5922
     requests.  Accept requests from the target for the values of
5923
     symbols.
5924
 
5925
     Reply:
5926
    `OK'
5927
          The target does not need to look up any (more) symbols.
5928
 
5929
    `qSymbol:SYM_NAME'
5930
          The target requests the value of symbol SYM_NAME (hex
5931
          encoded).  GDB may provide the value by using the
5932
          `qSymbol:SYM_VALUE:SYM_NAME' message, described below.
5933
 
5934
`qSymbol:SYM_VALUE:SYM_NAME'
5935
     Set the value of SYM_NAME to SYM_VALUE.
5936
 
5937
     SYM_NAME (hex encoded) is the name of a symbol whose value the
5938
     target has previously requested.
5939
 
5940
     SYM_VALUE (hex) is the value for symbol SYM_NAME.  If GDB cannot
5941
     supply a value for SYM_NAME, then this field will be empty.
5942
 
5943
     Reply:
5944
    `OK'
5945
          The target does not need to look up any (more) symbols.
5946
 
5947
    `qSymbol:SYM_NAME'
5948
          The target requests the value of a new symbol SYM_NAME (hex
5949
          encoded).  GDB will continue to supply the values of symbols
5950
          (if available), until the target ceases to request them.
5951
 
5952
`qTBuffer'
5953
 
5954
`QTBuffer'
5955
 
5956
`QTDisconnected'
5957
`QTDP'
5958
`QTDPsrc'
5959
`QTDV'
5960
`qTfP'
5961
`qTfV'
5962
`QTFrame'
5963
     *Note Tracepoint Packets::.
5964
 
5965
`qThreadExtraInfo,THREAD-ID'
5966
     Obtain a printable string description of a thread's attributes from
5967
     the target OS.  THREAD-ID is a thread ID; see *Note thread-id
5968
     syntax::.  This string may contain anything that the target OS
5969
     thinks is interesting for GDB to tell the user about the thread.
5970
     The string is displayed in GDB's `info threads' display.  Some
5971
     examples of possible thread extra info strings are `Runnable', or
5972
     `Blocked on Mutex'.
5973
 
5974
     Reply:
5975
    `XX...'
5976
          Where `XX...' is a hex encoding of ASCII data, comprising the
5977
          printable string containing the extra information about the
5978
          thread's attributes.
5979
 
5980
     (Note that the `qThreadExtraInfo' packet's name is separated from
5981
     the command by a `,', not a `:', contrary to the naming
5982
     conventions above.  Please don't use this packet as a model for new
5983
     packets.)
5984
 
5985
`QTSave'
5986
 
5987
`qTsP'
5988
 
5989
`qTsV'
5990
`QTStart'
5991
`QTStop'
5992
`QTinit'
5993
`QTro'
5994
`qTStatus'
5995
`qTV'
5996
`qTfSTM'
5997
`qTsSTM'
5998
`qTSTMat'
5999
     *Note Tracepoint Packets::.
6000
 
6001
`qXfer:OBJECT:read:ANNEX:OFFSET,LENGTH'
6002
     Read uninterpreted bytes from the target's special data area
6003
     identified by the keyword OBJECT.  Request LENGTH bytes starting
6004
     at OFFSET bytes into the data.  The content and encoding of ANNEX
6005
     is specific to OBJECT; it can supply additional details about what
6006
     data to access.
6007
 
6008
     Here are the specific requests of this form defined so far.  All
6009
     `qXfer:OBJECT:read:...' requests use the same reply formats,
6010
     listed below.
6011
 
6012
    `qXfer:auxv:read::OFFSET,LENGTH'
6013
          Access the target's "auxiliary vector".  *Note auxiliary
6014
          vector: OS Information.  Note ANNEX must be empty.
6015
 
6016
          This packet is not probed by default; the remote stub must
6017
          request it, by supplying an appropriate `qSupported' response
6018
          (*note qSupported::).
6019
 
6020
    `qXfer:features:read:ANNEX:OFFSET,LENGTH'
6021
          Access the "target description".  *Note Target
6022
          Descriptions::.  The annex specifies which XML document to
6023
          access.  The main description is always loaded from the
6024
          `target.xml' annex.
6025
 
6026
          This packet is not probed by default; the remote stub must
6027
          request it, by supplying an appropriate `qSupported' response
6028
          (*note qSupported::).
6029
 
6030
    `qXfer:libraries:read:ANNEX:OFFSET,LENGTH'
6031
          Access the target's list of loaded libraries.  *Note Library
6032
          List Format::.  The annex part of the generic `qXfer' packet
6033
          must be empty (*note qXfer read::).
6034
 
6035
          Targets which maintain a list of libraries in the program's
6036
          memory do not need to implement this packet; it is designed
6037
          for platforms where the operating system manages the list of
6038
          loaded libraries.
6039
 
6040
          This packet is not probed by default; the remote stub must
6041
          request it, by supplying an appropriate `qSupported' response
6042
          (*note qSupported::).
6043
 
6044
    `qXfer:memory-map:read::OFFSET,LENGTH'
6045
          Access the target's "memory-map".  *Note Memory Map Format::.
6046
          The annex part of the generic `qXfer' packet must be empty
6047
          (*note qXfer read::).
6048
 
6049
          This packet is not probed by default; the remote stub must
6050
          request it, by supplying an appropriate `qSupported' response
6051
          (*note qSupported::).
6052
 
6053
    `qXfer:sdata:read::OFFSET,LENGTH'
6054
          Read contents of the extra collected static tracepoint marker
6055
          information.  The annex part of the generic `qXfer' packet
6056
          must be empty (*note qXfer read::).  *Note Tracepoint Action
6057
          Lists: Tracepoint Actions.
6058
 
6059
          This packet is not probed by default; the remote stub must
6060
          request it, by supplying an appropriate `qSupported' response
6061
          (*note qSupported::).
6062
 
6063
    `qXfer:siginfo:read::OFFSET,LENGTH'
6064
          Read contents of the extra signal information on the target
6065
          system.  The annex part of the generic `qXfer' packet must be
6066
          empty (*note qXfer read::).
6067
 
6068
          This packet is not probed by default; the remote stub must
6069
          request it, by supplying an appropriate `qSupported' response
6070
          (*note qSupported::).
6071
 
6072
    `qXfer:spu:read:ANNEX:OFFSET,LENGTH'
6073
          Read contents of an `spufs' file on the target system.  The
6074
          annex specifies which file to read; it must be of the form
6075
          `ID/NAME', where ID specifies an SPU context ID in the target
6076
          process, and NAME identifes the `spufs' file in that context
6077
          to be accessed.
6078
 
6079
          This packet is not probed by default; the remote stub must
6080
          request it, by supplying an appropriate `qSupported' response
6081
          (*note qSupported::).
6082
 
6083
    `qXfer:threads:read::OFFSET,LENGTH'
6084
          Access the list of threads on target.  *Note Thread List
6085
          Format::.  The annex part of the generic `qXfer' packet must
6086
          be empty (*note qXfer read::).
6087
 
6088
          This packet is not probed by default; the remote stub must
6089
          request it, by supplying an appropriate `qSupported' response
6090
          (*note qSupported::).
6091
 
6092
    `qXfer:osdata:read::OFFSET,LENGTH'
6093
          Access the target's "operating system information".  *Note
6094
          Operating System Information::.
6095
 
6096
 
6097
     Reply:
6098
    `m DATA'
6099
          Data DATA (*note Binary Data::) has been read from the
6100
          target.  There may be more data at a higher address (although
6101
          it is permitted to return `m' even for the last valid block
6102
          of data, as long as at least one byte of data was read).
6103
          DATA may have fewer bytes than the LENGTH in the request.
6104
 
6105
    `l DATA'
6106
          Data DATA (*note Binary Data::) has been read from the target.
6107
          There is no more data to be read.  DATA may have fewer bytes
6108
          than the LENGTH in the request.
6109
 
6110
    `l'
6111
          The OFFSET in the request is at the end of the data.  There
6112
          is no more data to be read.
6113
 
6114
    `E00'
6115
          The request was malformed, or ANNEX was invalid.
6116
 
6117
    `E NN'
6118
          The offset was invalid, or there was an error encountered
6119
          reading the data.  NN is a hex-encoded `errno' value.
6120
 
6121
    `'
6122
          An empty reply indicates the OBJECT string was not recognized
6123
          by the stub, or that the object does not support reading.
6124
 
6125
`qXfer:OBJECT:write:ANNEX:OFFSET:DATA...'
6126
     Write uninterpreted bytes into the target's special data area
6127
     identified by the keyword OBJECT, starting at OFFSET bytes into
6128
     the data.  DATA... is the binary-encoded data (*note Binary
6129
     Data::) to be written.  The content and encoding of ANNEX is
6130
     specific to OBJECT; it can supply additional details about what
6131
     data to access.
6132
 
6133
     Here are the specific requests of this form defined so far.  All
6134
     `qXfer:OBJECT:write:...' requests use the same reply formats,
6135
     listed below.
6136
 
6137
    `qXfer:siginfo:write::OFFSET:DATA...'
6138
          Write DATA to the extra signal information on the target
6139
          system.  The annex part of the generic `qXfer' packet must be
6140
          empty (*note qXfer write::).
6141
 
6142
          This packet is not probed by default; the remote stub must
6143
          request it, by supplying an appropriate `qSupported' response
6144
          (*note qSupported::).
6145
 
6146
    `qXfer:spu:write:ANNEX:OFFSET:DATA...'
6147
          Write DATA to an `spufs' file on the target system.  The
6148
          annex specifies which file to write; it must be of the form
6149
          `ID/NAME', where ID specifies an SPU context ID in the target
6150
          process, and NAME identifes the `spufs' file in that context
6151
          to be accessed.
6152
 
6153
          This packet is not probed by default; the remote stub must
6154
          request it, by supplying an appropriate `qSupported' response
6155
          (*note qSupported::).
6156
 
6157
     Reply:
6158
    `NN'
6159
          NN (hex encoded) is the number of bytes written.  This may be
6160
          fewer bytes than supplied in the request.
6161
 
6162
    `E00'
6163
          The request was malformed, or ANNEX was invalid.
6164
 
6165
    `E NN'
6166
          The offset was invalid, or there was an error encountered
6167
          writing the data.  NN is a hex-encoded `errno' value.
6168
 
6169
    `'
6170
          An empty reply indicates the OBJECT string was not recognized
6171
          by the stub, or that the object does not support writing.
6172
 
6173
`qXfer:OBJECT:OPERATION:...'
6174
     Requests of this form may be added in the future.  When a stub does
6175
     not recognize the OBJECT keyword, or its support for OBJECT does
6176
     not recognize the OPERATION keyword, the stub must respond with an
6177
     empty packet.
6178
 
6179
`qAttached:PID'
6180
     Return an indication of whether the remote server attached to an
6181
     existing process or created a new process.  When the multiprocess
6182
     protocol extensions are supported (*note multiprocess
6183
     extensions::), PID is an integer in hexadecimal format identifying
6184
     the target process.  Otherwise, GDB will omit the PID field and
6185
     the query packet will be simplified as `qAttached'.
6186
 
6187
     This query is used, for example, to know whether the remote process
6188
     should be detached or killed when a GDB session is ended with the
6189
     `quit' command.
6190
 
6191
     Reply:
6192
    `1'
6193
          The remote server attached to an existing process.
6194
 
6195
    `0'
6196
          The remote server created a new process.
6197
 
6198
    `E NN'
6199
          A badly formed request or an error was encountered.
6200
 
6201
 
6202
   ---------- Footnotes ----------
6203
 
6204
   (1) The `qP' and `qL' packets predate these conventions, and have
6205
arguments without any terminator for the packet name; we suspect they
6206
are in widespread use in places that are difficult to upgrade.  The
6207
`qC' packet has no arguments, but some existing stubs (e.g. RedBoot)
6208
are known to not check for the end of the packet.
6209
 
6210

6211
File: gdb.info,  Node: Architecture-Specific Protocol Details,  Next: Tracepoint Packets,  Prev: General Query Packets,  Up: Remote Protocol
6212
 
6213
D.5 Architecture-Specific Protocol Details
6214
==========================================
6215
 
6216
This section describes how the remote protocol is applied to specific
6217
target architectures.  Also see *Note Standard Target Features::, for
6218
details of XML target descriptions for each architecture.
6219
 
6220
D.5.1 ARM
6221
---------
6222
 
6223
D.5.1.1 Breakpoint Kinds
6224
........................
6225
 
6226
These breakpoint kinds are defined for the `Z0' and `Z1' packets.
6227
 
6228
2
6229
     16-bit Thumb mode breakpoint.
6230
 
6231
3
6232
     32-bit Thumb mode (Thumb-2) breakpoint.
6233
 
6234
4
6235
     32-bit ARM mode breakpoint.
6236
 
6237
 
6238
D.5.2 MIPS
6239
----------
6240
 
6241
D.5.2.1 Register Packet Format
6242
..............................
6243
 
6244
The following `g'/`G' packets have previously been defined.  In the
6245
below, some thirty-two bit registers are transferred as sixty-four
6246
bits.  Those registers should be zero/sign extended (which?)  to fill
6247
the space allocated.  Register bytes are transferred in target byte
6248
order.  The two nibbles within a register byte are transferred
6249
most-significant - least-significant.
6250
 
6251
MIPS32
6252
     All registers are transferred as thirty-two bit quantities in the
6253
     order: 32 general-purpose; sr; lo; hi; bad; cause; pc; 32
6254
     floating-point registers; fsr; fir; fp.
6255
 
6256
MIPS64
6257
     All registers are transferred as sixty-four bit quantities
6258
     (including thirty-two bit registers such as `sr').  The ordering
6259
     is the same as `MIPS32'.
6260
 
6261
 
6262

6263
File: gdb.info,  Node: Tracepoint Packets,  Next: Host I/O Packets,  Prev: Architecture-Specific Protocol Details,  Up: Remote Protocol
6264
 
6265
D.6 Tracepoint Packets
6266
======================
6267
 
6268
Here we describe the packets GDB uses to implement tracepoints (*note
6269
Tracepoints::).
6270
 
6271
`QTDP:N:ADDR:ENA:STEP:PASS[:FFLEN][:XLEN,BYTES][-]'
6272
     Create a new tracepoint, number N, at ADDR.  If ENA is `E', then
6273
     the tracepoint is enabled; if it is `D', then the tracepoint is
6274
     disabled.  STEP is the tracepoint's step count, and PASS is its
6275
     pass count.  If an `F' is present, then the tracepoint is to be a
6276
     fast tracepoint, and the FLEN is the number of bytes that the
6277
     target should copy elsewhere to make room for the tracepoint.  If
6278
     an `X' is present, it introduces a tracepoint condition, which
6279
     consists of a hexadecimal length, followed by a comma and
6280
     hex-encoded bytes, in a manner similar to action encodings as
6281
     described below.  If the trailing `-' is present, further `QTDP'
6282
     packets will follow to specify this tracepoint's actions.
6283
 
6284
     Replies:
6285
    `OK'
6286
          The packet was understood and carried out.
6287
 
6288
    `qRelocInsn'
6289
          *Note Relocate instruction reply packet: Tracepoint Packets.
6290
 
6291
    `'
6292
          The packet was not recognized.
6293
 
6294
`QTDP:-N:ADDR:[S]ACTION...[-]'
6295
     Define actions to be taken when a tracepoint is hit.  N and ADDR
6296
     must be the same as in the initial `QTDP' packet for this
6297
     tracepoint.  This packet may only be sent immediately after
6298
     another `QTDP' packet that ended with a `-'.  If the trailing `-'
6299
     is present, further `QTDP' packets will follow, specifying more
6300
     actions for this tracepoint.
6301
 
6302
     In the series of action packets for a given tracepoint, at most one
6303
     can have an `S' before its first ACTION.  If such a packet is
6304
     sent, it and the following packets define "while-stepping"
6305
     actions.  Any prior packets define ordinary actions -- that is,
6306
     those taken when the tracepoint is first hit.  If no action packet
6307
     has an `S', then all the packets in the series specify ordinary
6308
     tracepoint actions.
6309
 
6310
     The `ACTION...' portion of the packet is a series of actions,
6311
     concatenated without separators.  Each action has one of the
6312
     following forms:
6313
 
6314
    `R MASK'
6315
          Collect the registers whose bits are set in MASK.  MASK is a
6316
          hexadecimal number whose I'th bit is set if register number I
6317
          should be collected.  (The least significant bit is numbered
6318
          zero.)  Note that MASK may be any number of digits long; it
6319
          may not fit in a 32-bit word.
6320
 
6321
    `M BASEREG,OFFSET,LEN'
6322
          Collect LEN bytes of memory starting at the address in
6323
          register number BASEREG, plus OFFSET.  If BASEREG is `-1',
6324
          then the range has a fixed address: OFFSET is the address of
6325
          the lowest byte to collect.  The BASEREG, OFFSET, and LEN
6326
          parameters are all unsigned hexadecimal values (the `-1'
6327
          value for BASEREG is a special case).
6328
 
6329
    `X LEN,EXPR'
6330
          Evaluate EXPR, whose length is LEN, and collect memory as it
6331
          directs.  EXPR is an agent expression, as described in *Note
6332
          Agent Expressions::.  Each byte of the expression is encoded
6333
          as a two-digit hex number in the packet; LEN is the number of
6334
          bytes in the expression (and thus one-half the number of hex
6335
          digits in the packet).
6336
 
6337
 
6338
     Any number of actions may be packed together in a single `QTDP'
6339
     packet, as long as the packet does not exceed the maximum packet
6340
     length (400 bytes, for many stubs).  There may be only one `R'
6341
     action per tracepoint, and it must precede any `M' or `X' actions.
6342
     Any registers referred to by `M' and `X' actions must be
6343
     collected by a preceding `R' action.  (The "while-stepping"
6344
     actions are treated as if they were attached to a separate
6345
     tracepoint, as far as these restrictions are concerned.)
6346
 
6347
     Replies:
6348
    `OK'
6349
          The packet was understood and carried out.
6350
 
6351
    `qRelocInsn'
6352
          *Note Relocate instruction reply packet: Tracepoint Packets.
6353
 
6354
    `'
6355
          The packet was not recognized.
6356
 
6357
`QTDPsrc:N:ADDR:TYPE:START:SLEN:BYTES'
6358
     Specify a source string of tracepoint N at address ADDR.  This is
6359
     useful to get accurate reproduction of the tracepoints originally
6360
     downloaded at the beginning of the trace run.  TYPE is the name of
6361
     the tracepoint part, such as `cond' for the tracepoint's
6362
     conditional expression (see below for a list of types), while
6363
     BYTES is the string, encoded in hexadecimal.
6364
 
6365
     START is the offset of the BYTES within the overall source string,
6366
     while SLEN is the total length of the source string.  This is
6367
     intended for handling source strings that are longer than will fit
6368
     in a single packet.
6369
 
6370
     The available string types are `at' for the location, `cond' for
6371
     the conditional, and `cmd' for an action command.  GDB sends a
6372
     separate packet for each command in the action list, in the same
6373
     order in which the commands are stored in the list.
6374
 
6375
     The target does not need to do anything with source strings except
6376
     report them back as part of the replies to the `qTfP'/`qTsP' query
6377
     packets.
6378
 
6379
     Although this packet is optional, and GDB will only send it if the
6380
     target replies with `TracepointSource' *Note General Query
6381
     Packets::, it makes both disconnected tracing and trace files much
6382
     easier to use.  Otherwise the user must be careful that the
6383
     tracepoints in effect while looking at trace frames are identical
6384
     to the ones in effect during the trace run; even a small
6385
     discrepancy could cause `tdump' not to work, or a particular trace
6386
     frame not be found.
6387
 
6388
`QTDV:N:VALUE'
6389
     Create a new trace state variable, number N, with an initial value
6390
     of VALUE, which is a 64-bit signed integer.  Both N and VALUE are
6391
     encoded as hexadecimal values. GDB has the option of not using
6392
     this packet for initial values of zero; the target should simply
6393
     create the trace state variables as they are mentioned in
6394
     expressions.
6395
 
6396
`QTFrame:N'
6397
     Select the N'th tracepoint frame from the buffer, and use the
6398
     register and memory contents recorded there to answer subsequent
6399
     request packets from GDB.
6400
 
6401
     A successful reply from the stub indicates that the stub has found
6402
     the requested frame.  The response is a series of parts,
6403
     concatenated without separators, describing the frame we selected.
6404
     Each part has one of the following forms:
6405
 
6406
    `F F'
6407
          The selected frame is number N in the trace frame buffer; F
6408
          is a hexadecimal number.  If F is `-1', then there was no
6409
          frame matching the criteria in the request packet.
6410
 
6411
    `T T'
6412
          The selected trace frame records a hit of tracepoint number T;
6413
          T is a hexadecimal number.
6414
 
6415
 
6416
`QTFrame:pc:ADDR'
6417
     Like `QTFrame:N', but select the first tracepoint frame after the
6418
     currently selected frame whose PC is ADDR; ADDR is a hexadecimal
6419
     number.
6420
 
6421
`QTFrame:tdp:T'
6422
     Like `QTFrame:N', but select the first tracepoint frame after the
6423
     currently selected frame that is a hit of tracepoint T; T is a
6424
     hexadecimal number.
6425
 
6426
`QTFrame:range:START:END'
6427
     Like `QTFrame:N', but select the first tracepoint frame after the
6428
     currently selected frame whose PC is between START (inclusive) and
6429
     END (inclusive); START and END are hexadecimal numbers.
6430
 
6431
`QTFrame:outside:START:END'
6432
     Like `QTFrame:range:START:END', but select the first frame
6433
     _outside_ the given range of addresses (exclusive).
6434
 
6435
`QTStart'
6436
     Begin the tracepoint experiment.  Begin collecting data from
6437
     tracepoint hits in the trace frame buffer.  This packet supports
6438
     the `qRelocInsn' reply (*note Relocate instruction reply packet:
6439
     Tracepoint Packets.).
6440
 
6441
`QTStop'
6442
     End the tracepoint experiment.  Stop collecting trace frames.
6443
 
6444
`QTinit'
6445
     Clear the table of tracepoints, and empty the trace frame buffer.
6446
 
6447
`QTro:START1,END1:START2,END2:...'
6448
     Establish the given ranges of memory as "transparent".  The stub
6449
     will answer requests for these ranges from memory's current
6450
     contents, if they were not collected as part of the tracepoint hit.
6451
 
6452
     GDB uses this to mark read-only regions of memory, like those
6453
     containing program code.  Since these areas never change, they
6454
     should still have the same contents they did when the tracepoint
6455
     was hit, so there's no reason for the stub to refuse to provide
6456
     their contents.
6457
 
6458
`QTDisconnected:VALUE'
6459
     Set the choice to what to do with the tracing run when GDB
6460
     disconnects from the target.  A VALUE of 1 directs the target to
6461
     continue the tracing run, while 0 tells the target to stop tracing
6462
     if GDB is no longer in the picture.
6463
 
6464
`qTStatus'
6465
     Ask the stub if there is a trace experiment running right now.
6466
 
6467
     The reply has the form:
6468
 
6469
    `TRUNNING[;FIELD]...'
6470
          RUNNING is a single digit `1' if the trace is presently
6471
          running, or `0' if not.  It is followed by semicolon-separated
6472
          optional fields that an agent may use to report additional
6473
          status.
6474
 
6475
 
6476
     If the trace is not running, the agent may report any of several
6477
     explanations as one of the optional fields:
6478
 
6479
    `tnotrun:0'
6480
          No trace has been run yet.
6481
 
6482
    `tstop:0'
6483
          The trace was stopped by a user-originated stop command.
6484
 
6485
    `tfull:0'
6486
          The trace stopped because the trace buffer filled up.
6487
 
6488
    `tdisconnected:0'
6489
          The trace stopped because GDB disconnected from the target.
6490
 
6491
    `tpasscount:TPNUM'
6492
          The trace stopped because tracepoint TPNUM exceeded its pass
6493
          count.
6494
 
6495
    `terror:TEXT:TPNUM'
6496
          The trace stopped because tracepoint TPNUM had an error.  The
6497
          string TEXT is available to describe the nature of the error
6498
          (for instance, a divide by zero in the condition expression).
6499
          TEXT is hex encoded.
6500
 
6501
    `tunknown:0'
6502
          The trace stopped for some other reason.
6503
 
6504
 
6505
     Additional optional fields supply statistical and other
6506
     information.  Although not required, they are extremely useful for
6507
     users monitoring the progress of a trace run.  If a trace has
6508
     stopped, and these numbers are reported, they must reflect the
6509
     state of the just-stopped trace.
6510
 
6511
    `tframes:N'
6512
          The number of trace frames in the buffer.
6513
 
6514
    `tcreated:N'
6515
          The total number of trace frames created during the run. This
6516
          may be larger than the trace frame count, if the buffer is
6517
          circular.
6518
 
6519
    `tsize:N'
6520
          The total size of the trace buffer, in bytes.
6521
 
6522
    `tfree:N'
6523
          The number of bytes still unused in the buffer.
6524
 
6525
    `circular:N'
6526
          The value of the circular trace buffer flag.  `1' means that
6527
          the trace buffer is circular and old trace frames will be
6528
          discarded if necessary to make room, `0' means that the trace
6529
          buffer is linear and may fill up.
6530
 
6531
    `disconn:N'
6532
          The value of the disconnected tracing flag.  `1' means that
6533
          tracing will continue after GDB disconnects, `0' means that
6534
          the trace run will stop.
6535
 
6536
 
6537
`qTV:VAR'
6538
     Ask the stub for the value of the trace state variable number VAR.
6539
 
6540
     Replies:
6541
    `VVALUE'
6542
          The value of the variable is VALUE.  This will be the current
6543
          value of the variable if the user is examining a running
6544
          target, or a saved value if the variable was collected in the
6545
          trace frame that the user is looking at.  Note that multiple
6546
          requests may result in different reply values, such as when
6547
          requesting values while the program is running.
6548
 
6549
    `U'
6550
          The value of the variable is unknown.  This would occur, for
6551
          example, if the user is examining a trace frame in which the
6552
          requested variable was not collected.
6553
 
6554
`qTfP'
6555
`qTsP'
6556
     These packets request data about tracepoints that are being used by
6557
     the target.  GDB sends `qTfP' to get the first piece of data, and
6558
     multiple `qTsP' to get additional pieces.  Replies to these
6559
     packets generally take the form of the `QTDP' packets that define
6560
     tracepoints. (FIXME add detailed syntax)
6561
 
6562
`qTfV'
6563
`qTsV'
6564
     These packets request data about trace state variables that are on
6565
     the target.  GDB sends `qTfV' to get the first vari of data, and
6566
     multiple `qTsV' to get additional variables.  Replies to these
6567
     packets follow the syntax of the `QTDV' packets that define trace
6568
     state variables.
6569
 
6570
`qTfSTM'
6571
`qTsSTM'
6572
     These packets request data about static tracepoint markers that
6573
     exist in the target program.  GDB sends `qTfSTM' to get the first
6574
     piece of data, and multiple `qTsSTM' to get additional pieces.
6575
     Replies to these packets take the following form:
6576
 
6577
     Reply:
6578
    `m ADDRESS:ID:EXTRA'
6579
          A single marker
6580
 
6581
    `m ADDRESS:ID:EXTRA,ADDRESS:ID:EXTRA...'
6582
          a comma-separated list of markers
6583
 
6584
    `l'
6585
          (lower case letter `L') denotes end of list.
6586
 
6587
    `E NN'
6588
          An error occurred.  NN are hex digits.
6589
 
6590
    `'
6591
          An empty reply indicates that the request is not supported by
6592
          the stub.
6593
 
6594
     ADDRESS is encoded in hex.  ID and EXTRA are strings encoded in
6595
     hex.
6596
 
6597
     In response to each query, the target will reply with a list of
6598
     one or more markers, separated by commas.  GDB will respond to each
6599
     reply with a request for more markers (using the `qs' form of the
6600
     query), until the target responds with `l' (lower-case ell, for
6601
     "last").
6602
 
6603
`qTSTMat:ADDRESS'
6604
     This packets requests data about static tracepoint markers in the
6605
     target program at ADDRESS.  Replies to this packet follow the
6606
     syntax of the `qTfSTM' and `qTsSTM' packets that list static
6607
     tracepoint markers.
6608
 
6609
`QTSave:FILENAME'
6610
     This packet directs the target to save trace data to the file name
6611
     FILENAME in the target's filesystem.  FILENAME is encoded as a hex
6612
     string; the interpretation of the file name (relative vs absolute,
6613
     wild cards, etc) is up to the target.
6614
 
6615
`qTBuffer:OFFSET,LEN'
6616
     Return up to LEN bytes of the current contents of trace buffer,
6617
     starting at OFFSET.  The trace buffer is treated as if it were a
6618
     contiguous collection of traceframes, as per the trace file format.
6619
     The reply consists as many hex-encoded bytes as the target can
6620
     deliver in a packet; it is not an error to return fewer than were
6621
     asked for.  A reply consisting of just `l' indicates that no bytes
6622
     are available.
6623
 
6624
`QTBuffer:circular:VALUE'
6625
     This packet directs the target to use a circular trace buffer if
6626
     VALUE is 1, or a linear buffer if the value is 0.
6627
 
6628
 
6629
D.6.1 Relocate instruction reply packet
6630
---------------------------------------
6631
 
6632
When installing fast tracepoints in memory, the target may need to
6633
relocate the instruction currently at the tracepoint address to a
6634
different address in memory.  For most instructions, a simple copy is
6635
enough, but, for example, call instructions that implicitly push the
6636
return address on the stack, and relative branches or other PC-relative
6637
instructions require offset adjustment, so that the effect of executing
6638
the instruction at a different address is the same as if it had
6639
executed in the original location.
6640
 
6641
   In response to several of the tracepoint packets, the target may also
6642
respond with a number of intermediate `qRelocInsn' request packets
6643
before the final result packet, to have GDB handle this relocation
6644
operation.  If a packet supports this mechanism, its documentation will
6645
explicitly say so.  See for example the above descriptions for the
6646
`QTStart' and `QTDP' packets.  The format of the request is:
6647
 
6648
`qRelocInsn:FROM;TO'
6649
     This requests GDB to copy instruction at address FROM to address
6650
     TO, possibly adjusted so that executing the instruction at TO has
6651
     the same effect as executing it at FROM.  GDB writes the adjusted
6652
     instruction to target memory starting at TO.
6653
 
6654
   Replies:
6655
`qRelocInsn:ADJUSTED_SIZE'
6656
     Informs the stub the relocation is complete.  ADJUSTED_SIZE is the
6657
     length in bytes of resulting relocated instruction sequence.
6658
 
6659
`E NN'
6660
     A badly formed request was detected, or an error was encountered
6661
     while relocating the instruction.
6662
 
6663

6664
File: gdb.info,  Node: Host I/O Packets,  Next: Interrupts,  Prev: Tracepoint Packets,  Up: Remote Protocol
6665
 
6666
D.7 Host I/O Packets
6667
====================
6668
 
6669
The "Host I/O" packets allow GDB to perform I/O operations on the far
6670
side of a remote link.  For example, Host I/O is used to upload and
6671
download files to a remote target with its own filesystem.  Host I/O
6672
uses the same constant values and data structure layout as the
6673
target-initiated File-I/O protocol.  However, the Host I/O packets are
6674
structured differently.  The target-initiated protocol relies on target
6675
memory to store parameters and buffers.  Host I/O requests are
6676
initiated by GDB, and the target's memory is not involved.  *Note
6677
File-I/O Remote Protocol Extension::, for more details on the
6678
target-initiated protocol.
6679
 
6680
   The Host I/O request packets all encode a single operation along with
6681
its arguments.  They have this format:
6682
 
6683
`vFile:OPERATION: PARAMETER...'
6684
     OPERATION is the name of the particular request; the target should
6685
     compare the entire packet name up to the second colon when checking
6686
     for a supported operation.  The format of PARAMETER depends on the
6687
     operation.  Numbers are always passed in hexadecimal.  Negative
6688
     numbers have an explicit minus sign (i.e. two's complement is not
6689
     used).  Strings (e.g. filenames) are encoded as a series of
6690
     hexadecimal bytes.  The last argument to a system call may be a
6691
     buffer of escaped binary data (*note Binary Data::).
6692
 
6693
 
6694
   The valid responses to Host I/O packets are:
6695
 
6696
`F RESULT [, ERRNO] [; ATTACHMENT]'
6697
     RESULT is the integer value returned by this operation, usually
6698
     non-negative for success and -1 for errors.  If an error has
6699
     occured, ERRNO will be included in the result.  ERRNO will have a
6700
     value defined by the File-I/O protocol (*note Errno Values::).  For
6701
     operations which return data, ATTACHMENT supplies the data as a
6702
     binary buffer.  Binary buffers in response packets are escaped in
6703
     the normal way (*note Binary Data::).  See the individual packet
6704
     documentation for the interpretation of RESULT and ATTACHMENT.
6705
 
6706
`'
6707
     An empty response indicates that this operation is not recognized.
6708
 
6709
 
6710
   These are the supported Host I/O operations:
6711
 
6712
`vFile:open: PATHNAME, FLAGS, MODE'
6713
     Open a file at PATHNAME and return a file descriptor for it, or
6714
     return -1 if an error occurs.  PATHNAME is a string, FLAGS is an
6715
     integer indicating a mask of open flags (*note Open Flags::), and
6716
     MODE is an integer indicating a mask of mode bits to use if the
6717
     file is created (*note mode_t Values::).  *Note open::, for
6718
     details of the open flags and mode values.
6719
 
6720
`vFile:close: FD'
6721
     Close the open file corresponding to FD and return 0, or -1 if an
6722
     error occurs.
6723
 
6724
`vFile:pread: FD, COUNT, OFFSET'
6725
     Read data from the open file corresponding to FD.  Up to COUNT
6726
     bytes will be read from the file, starting at OFFSET relative to
6727
     the start of the file.  The target may read fewer bytes; common
6728
     reasons include packet size limits and an end-of-file condition.
6729
     The number of bytes read is returned.  Zero should only be
6730
     returned for a successful read at the end of the file, or if COUNT
6731
     was zero.
6732
 
6733
     The data read should be returned as a binary attachment on success.
6734
     If zero bytes were read, the response should include an empty
6735
     binary attachment (i.e. a trailing semicolon).  The return value
6736
     is the number of target bytes read; the binary attachment may be
6737
     longer if some characters were escaped.
6738
 
6739
`vFile:pwrite: FD, OFFSET, DATA'
6740
     Write DATA (a binary buffer) to the open file corresponding to FD.
6741
     Start the write at OFFSET from the start of the file.  Unlike
6742
     many `write' system calls, there is no separate COUNT argument;
6743
     the length of DATA in the packet is used.  `vFile:write' returns
6744
     the number of bytes written, which may be shorter than the length
6745
     of DATA, or -1 if an error occurred.
6746
 
6747
`vFile:unlink: PATHNAME'
6748
     Delete the file at PATHNAME on the target.  Return 0, or -1 if an
6749
     error occurs.  PATHNAME is a string.
6750
 
6751
 
6752

6753
File: gdb.info,  Node: Interrupts,  Next: Notification Packets,  Prev: Host I/O Packets,  Up: Remote Protocol
6754
 
6755
D.8 Interrupts
6756
==============
6757
 
6758
When a program on the remote target is running, GDB may attempt to
6759
interrupt it by sending a `Ctrl-C', `BREAK' or a `BREAK' followed by
6760
`g', control of which is specified via GDB's `interrupt-sequence'.
6761
 
6762
   The precise meaning of `BREAK' is defined by the transport mechanism
6763
and may, in fact, be undefined.  GDB does not currently define a
6764
`BREAK' mechanism for any of the network interfaces except for TCP, in
6765
which case GDB sends the `telnet' BREAK sequence.
6766
 
6767
   `Ctrl-C', on the other hand, is defined and implemented for all
6768
transport mechanisms.  It is represented by sending the single byte
6769
`0x03' without any of the usual packet overhead described in the
6770
Overview section (*note Overview::).  When a `0x03' byte is transmitted
6771
as part of a packet, it is considered to be packet data and does _not_
6772
represent an interrupt.  E.g., an `X' packet (*note X packet::), used
6773
for binary downloads, may include an unescaped `0x03' as part of its
6774
packet.
6775
 
6776
   `BREAK' followed by `g' is also known as Magic SysRq g.  When Linux
6777
kernel receives this sequence from serial port, it stops execution and
6778
connects to gdb.
6779
 
6780
   Stubs are not required to recognize these interrupt mechanisms and
6781
the precise meaning associated with receipt of the interrupt is
6782
implementation defined.  If the target supports debugging of multiple
6783
threads and/or processes, it should attempt to interrupt all
6784
currently-executing threads and processes.  If the stub is successful
6785
at interrupting the running program, it should send one of the stop
6786
reply packets (*note Stop Reply Packets::) to GDB as a result of
6787
successfully stopping the program in all-stop mode, and a stop reply
6788
for each stopped thread in non-stop mode.  Interrupts received while the
6789
program is stopped are discarded.
6790
 
6791

6792
File: gdb.info,  Node: Notification Packets,  Next: Remote Non-Stop,  Prev: Interrupts,  Up: Remote Protocol
6793
 
6794
D.9 Notification Packets
6795
========================
6796
 
6797
The GDB remote serial protocol includes "notifications", packets that
6798
require no acknowledgment.  Both the GDB and the stub may send
6799
notifications (although the only notifications defined at present are
6800
sent by the stub).  Notifications carry information without incurring
6801
the round-trip latency of an acknowledgment, and so are useful for
6802
low-impact communications where occasional packet loss is not a problem.
6803
 
6804
   A notification packet has the form `% DATA # CHECKSUM', where DATA
6805
is the content of the notification, and CHECKSUM is a checksum of DATA,
6806
computed and formatted as for ordinary GDB packets.  A notification's
6807
DATA never contains `$', `%' or `#' characters.  Upon receiving a
6808
notification, the recipient sends no `+' or `-' to acknowledge the
6809
notification's receipt or to report its corruption.
6810
 
6811
   Every notification's DATA begins with a name, which contains no
6812
colon characters, followed by a colon character.
6813
 
6814
   Recipients should silently ignore corrupted notifications and
6815
notifications they do not understand.  Recipients should restart
6816
timeout periods on receipt of a well-formed notification, whether or
6817
not they understand it.
6818
 
6819
   Senders should only send the notifications described here when this
6820
protocol description specifies that they are permitted.  In the future,
6821
we may extend the protocol to permit existing notifications in new
6822
contexts; this rule helps older senders avoid confusing newer
6823
recipients.
6824
 
6825
   (Older versions of GDB ignore bytes received until they see the `$'
6826
byte that begins an ordinary packet, so new stubs may transmit
6827
notifications without fear of confusing older clients.  There are no
6828
notifications defined for GDB to send at the moment, but we assume that
6829
most older stubs would ignore them, as well.)
6830
 
6831
   The following notification packets from the stub to GDB are defined:
6832
 
6833
`Stop: REPLY'
6834
     Report an asynchronous stop event in non-stop mode.  The REPLY has
6835
     the form of a stop reply, as described in *Note Stop Reply
6836
     Packets::.  Refer to *Note Remote Non-Stop::, for information on
6837
     how these notifications are acknowledged by GDB.
6838
 
6839

6840
File: gdb.info,  Node: Remote Non-Stop,  Next: Packet Acknowledgment,  Prev: Notification Packets,  Up: Remote Protocol
6841
 
6842
D.10 Remote Protocol Support for Non-Stop Mode
6843
==============================================
6844
 
6845
GDB's remote protocol supports non-stop debugging of multi-threaded
6846
programs, as described in *Note Non-Stop Mode::.  If the stub supports
6847
non-stop mode, it should report that to GDB by including `QNonStop+' in
6848
its `qSupported' response (*note qSupported::).
6849
 
6850
   GDB typically sends a `QNonStop' packet only when establishing a new
6851
connection with the stub.  Entering non-stop mode does not alter the
6852
state of any currently-running threads, but targets must stop all
6853
threads in any already-attached processes when entering all-stop mode.
6854
GDB uses the `?' packet as necessary to probe the target state after a
6855
mode change.
6856
 
6857
   In non-stop mode, when an attached process encounters an event that
6858
would otherwise be reported with a stop reply, it uses the asynchronous
6859
notification mechanism (*note Notification Packets::) to inform GDB.
6860
In contrast to all-stop mode, where all threads in all processes are
6861
stopped when a stop reply is sent, in non-stop mode only the thread
6862
reporting the stop event is stopped.  That is, when reporting a `S' or
6863
`T' response to indicate completion of a step operation, hitting a
6864
breakpoint, or a fault, only the affected thread is stopped; any other
6865
still-running threads continue to run.  When reporting a `W' or `X'
6866
response, all running threads belonging to other attached processes
6867
continue to run.
6868
 
6869
   Only one stop reply notification at a time may be pending; if
6870
additional stop events occur before GDB has acknowledged the previous
6871
notification, they must be queued by the stub for later synchronous
6872
transmission in response to `vStopped' packets from GDB.  Because the
6873
notification mechanism is unreliable, the stub is permitted to resend a
6874
stop reply notification if it believes GDB may not have received it.
6875
GDB ignores additional stop reply notifications received before it has
6876
finished processing a previous notification and the stub has completed
6877
sending any queued stop events.
6878
 
6879
   Otherwise, GDB must be prepared to receive a stop reply notification
6880
at any time.  Specifically, they may appear when GDB is not otherwise
6881
reading input from the stub, or when GDB is expecting to read a normal
6882
synchronous response or a `+'/`-' acknowledgment to a packet it has
6883
sent.  Notification packets are distinct from any other communication
6884
from the stub so there is no ambiguity.
6885
 
6886
   After receiving a stop reply notification, GDB shall acknowledge it
6887
by sending a `vStopped' packet (*note vStopped packet::) as a regular,
6888
synchronous request to the stub.  Such acknowledgment is not required
6889
to happen immediately, as GDB is permitted to send other, unrelated
6890
packets to the stub first, which the stub should process normally.
6891
 
6892
   Upon receiving a `vStopped' packet, if the stub has other queued
6893
stop events to report to GDB, it shall respond by sending a normal stop
6894
reply response.  GDB shall then send another `vStopped' packet to
6895
solicit further responses; again, it is permitted to send other,
6896
unrelated packets as well which the stub should process normally.
6897
 
6898
   If the stub receives a `vStopped' packet and there are no additional
6899
stop events to report, the stub shall return an `OK' response.  At this
6900
point, if further stop events occur, the stub shall send a new stop
6901
reply notification, GDB shall accept the notification, and the process
6902
shall be repeated.
6903
 
6904
   In non-stop mode, the target shall respond to the `?' packet as
6905
follows.  First, any incomplete stop reply notification/`vStopped'
6906
sequence in progress is abandoned.  The target must begin a new
6907
sequence reporting stop events for all stopped threads, whether or not
6908
it has previously reported those events to GDB.  The first stop reply
6909
is sent as a synchronous reply to the `?' packet, and subsequent stop
6910
replies are sent as responses to `vStopped' packets using the mechanism
6911
described above.  The target must not send asynchronous stop reply
6912
notifications until the sequence is complete.  If all threads are
6913
running when the target receives the `?' packet, or if the target is
6914
not attached to any process, it shall respond `OK'.
6915
 
6916

6917
File: gdb.info,  Node: Packet Acknowledgment,  Next: Examples,  Prev: Remote Non-Stop,  Up: Remote Protocol
6918
 
6919
D.11 Packet Acknowledgment
6920
==========================
6921
 
6922
By default, when either the host or the target machine receives a
6923
packet, the first response expected is an acknowledgment: either `+'
6924
(to indicate the package was received correctly) or `-' (to request
6925
retransmission).  This mechanism allows the GDB remote protocol to
6926
operate over unreliable transport mechanisms, such as a serial line.
6927
 
6928
   In cases where the transport mechanism is itself reliable (such as a
6929
pipe or TCP connection), the `+'/`-' acknowledgments are redundant.  It
6930
may be desirable to disable them in that case to reduce communication
6931
overhead, or for other reasons.  This can be accomplished by means of
6932
the `QStartNoAckMode' packet; *note QStartNoAckMode::.
6933
 
6934
   When in no-acknowledgment mode, neither the stub nor GDB shall send
6935
or expect `+'/`-' protocol acknowledgments.  The packet and response
6936
format still includes the normal checksum, as described in *Note
6937
Overview::, but the checksum may be ignored by the receiver.
6938
 
6939
   If the stub supports `QStartNoAckMode' and prefers to operate in
6940
no-acknowledgment mode, it should report that to GDB by including
6941
`QStartNoAckMode+' in its response to `qSupported'; *note qSupported::.
6942
If GDB also supports `QStartNoAckMode' and it has not been disabled via
6943
the `set remote noack-packet off' command (*note Remote
6944
Configuration::), GDB may then send a `QStartNoAckMode' packet to the
6945
stub.  Only then may the stub actually turn off packet acknowledgments.
6946
GDB sends a final `+' acknowledgment of the stub's `OK' response, which
6947
can be safely ignored by the stub.
6948
 
6949
   Note that `set remote noack-packet' command only affects negotiation
6950
between GDB and the stub when subsequent connections are made; it does
6951
not affect the protocol acknowledgment state for any current connection.
6952
Since `+'/`-' acknowledgments are enabled by default when a new
6953
connection is established, there is also no protocol request to
6954
re-enable the acknowledgments for the current connection, once disabled.
6955
 
6956

6957
File: gdb.info,  Node: Examples,  Next: File-I/O Remote Protocol Extension,  Prev: Packet Acknowledgment,  Up: Remote Protocol
6958
 
6959
D.12 Examples
6960
=============
6961
 
6962
Example sequence of a target being re-started.  Notice how the restart
6963
does not get any direct output:
6964
 
6965
     -> `R00'
6966
     <- `+'
6967
     _target restarts_
6968
     -> `?'
6969
     <- `+'
6970
     <- `T001:1234123412341234'
6971
     -> `+'
6972
 
6973
   Example sequence of a target being stepped by a single instruction:
6974
 
6975
     -> `G1445...'
6976
     <- `+'
6977
     -> `s'
6978
     <- `+'
6979
     _time passes_
6980
     <- `T001:1234123412341234'
6981
     -> `+'
6982
     -> `g'
6983
     <- `+'
6984
     <- `1455...'
6985
     -> `+'
6986
 
6987

6988
File: gdb.info,  Node: File-I/O Remote Protocol Extension,  Next: Library List Format,  Prev: Examples,  Up: Remote Protocol
6989
 
6990
D.13 File-I/O Remote Protocol Extension
6991
=======================================
6992
 
6993
* Menu:
6994
 
6995
* File-I/O Overview::
6996
* Protocol Basics::
6997
* The F Request Packet::
6998
* The F Reply Packet::
6999
* The Ctrl-C Message::
7000
* Console I/O::
7001
* List of Supported Calls::
7002
* Protocol-specific Representation of Datatypes::
7003
* Constants::
7004
* File-I/O Examples::
7005
 
7006

7007
File: gdb.info,  Node: File-I/O Overview,  Next: Protocol Basics,  Up: File-I/O Remote Protocol Extension
7008
 
7009
D.13.1 File-I/O Overview
7010
------------------------
7011
 
7012
The "File I/O remote protocol extension" (short: File-I/O) allows the
7013
target to use the host's file system and console I/O to perform various
7014
system calls.  System calls on the target system are translated into a
7015
remote protocol packet to the host system, which then performs the
7016
needed actions and returns a response packet to the target system.
7017
This simulates file system operations even on targets that lack file
7018
systems.
7019
 
7020
   The protocol is defined to be independent of both the host and
7021
target systems.  It uses its own internal representation of datatypes
7022
and values.  Both GDB and the target's GDB stub are responsible for
7023
translating the system-dependent value representations into the internal
7024
protocol representations when data is transmitted.
7025
 
7026
   The communication is synchronous.  A system call is possible only
7027
when GDB is waiting for a response from the `C', `c', `S' or `s'
7028
packets.  While GDB handles the request for a system call, the target
7029
is stopped to allow deterministic access to the target's memory.
7030
Therefore File-I/O is not interruptible by target signals.  On the
7031
other hand, it is possible to interrupt File-I/O by a user interrupt
7032
(`Ctrl-C') within GDB.
7033
 
7034
   The target's request to perform a host system call does not finish
7035
the latest `C', `c', `S' or `s' action.  That means, after finishing
7036
the system call, the target returns to continuing the previous activity
7037
(continue, step).  No additional continue or step request from GDB is
7038
required.
7039
 
7040
     (gdb) continue
7041
       <- target requests 'system call X'
7042
       target is stopped, GDB executes system call
7043
       -> GDB returns result
7044
       ... target continues, GDB returns to wait for the target
7045
       <- target hits breakpoint and sends a Txx packet
7046
 
7047
   The protocol only supports I/O on the console and to regular files on
7048
the host file system.  Character or block special devices, pipes, named
7049
pipes, sockets or any other communication method on the host system are
7050
not supported by this protocol.
7051
 
7052
   File I/O is not supported in non-stop mode.
7053
 
7054

7055
File: gdb.info,  Node: Protocol Basics,  Next: The F Request Packet,  Prev: File-I/O Overview,  Up: File-I/O Remote Protocol Extension
7056
 
7057
D.13.2 Protocol Basics
7058
----------------------
7059
 
7060
The File-I/O protocol uses the `F' packet as the request as well as
7061
reply packet.  Since a File-I/O system call can only occur when GDB is
7062
waiting for a response from the continuing or stepping target, the
7063
File-I/O request is a reply that GDB has to expect as a result of a
7064
previous `C', `c', `S' or `s' packet.  This `F' packet contains all
7065
information needed to allow GDB to call the appropriate host system
7066
call:
7067
 
7068
   * A unique identifier for the requested system call.
7069
 
7070
   * All parameters to the system call.  Pointers are given as addresses
7071
     in the target memory address space.  Pointers to strings are given
7072
     as pointer/length pair.  Numerical values are given as they are.
7073
     Numerical control flags are given in a protocol-specific
7074
     representation.
7075
 
7076
 
7077
   At this point, GDB has to perform the following actions.
7078
 
7079
   * If the parameters include pointer values to data needed as input
7080
     to a system call, GDB requests this data from the target with a
7081
     standard `m' packet request.  This additional communication has to
7082
     be expected by the target implementation and is handled as any
7083
     other `m' packet.
7084
 
7085
   * GDB translates all value from protocol representation to host
7086
     representation as needed.  Datatypes are coerced into the host
7087
     types.
7088
 
7089
   * GDB calls the system call.
7090
 
7091
   * It then coerces datatypes back to protocol representation.
7092
 
7093
   * If the system call is expected to return data in buffer space
7094
     specified by pointer parameters to the call, the data is
7095
     transmitted to the target using a `M' or `X' packet.  This packet
7096
     has to be expected by the target implementation and is handled as
7097
     any other `M' or `X' packet.
7098
 
7099
 
7100
   Eventually GDB replies with another `F' packet which contains all
7101
necessary information for the target to continue.  This at least
7102
contains
7103
 
7104
   * Return value.
7105
 
7106
   * `errno', if has been changed by the system call.
7107
 
7108
   * "Ctrl-C" flag.
7109
 
7110
 
7111
   After having done the needed type and value coercion, the target
7112
continues the latest continue or step action.
7113
 
7114

7115
File: gdb.info,  Node: The F Request Packet,  Next: The F Reply Packet,  Prev: Protocol Basics,  Up: File-I/O Remote Protocol Extension
7116
 
7117
D.13.3 The `F' Request Packet
7118
-----------------------------
7119
 
7120
The `F' request packet has the following format:
7121
 
7122
`FCALL-ID,PARAMETER...'
7123
     CALL-ID is the identifier to indicate the host system call to be
7124
     called.  This is just the name of the function.
7125
 
7126
     PARAMETER... are the parameters to the system call.  Parameters
7127
     are hexadecimal integer values, either the actual values in case
7128
     of scalar datatypes, pointers to target buffer space in case of
7129
     compound datatypes and unspecified memory areas, or pointer/length
7130
     pairs in case of string parameters.  These are appended to the
7131
     CALL-ID as a comma-delimited list.  All values are transmitted in
7132
     ASCII string representation, pointer/length pairs separated by a
7133
     slash.
7134
 
7135
 
7136

7137
File: gdb.info,  Node: The F Reply Packet,  Next: The Ctrl-C Message,  Prev: The F Request Packet,  Up: File-I/O Remote Protocol Extension
7138
 
7139
D.13.4 The `F' Reply Packet
7140
---------------------------
7141
 
7142
The `F' reply packet has the following format:
7143
 
7144
`FRETCODE,ERRNO,CTRL-C FLAG;CALL-SPECIFIC ATTACHMENT'
7145
     RETCODE is the return code of the system call as hexadecimal value.
7146
 
7147
     ERRNO is the `errno' set by the call, in protocol-specific
7148
     representation.  This parameter can be omitted if the call was
7149
     successful.
7150
 
7151
     CTRL-C FLAG is only sent if the user requested a break.  In this
7152
     case, ERRNO must be sent as well, even if the call was successful.
7153
     The CTRL-C FLAG itself consists of the character `C':
7154
 
7155
          F0,0,C
7156
 
7157
     or, if the call was interrupted before the host call has been
7158
     performed:
7159
 
7160
          F-1,4,C
7161
 
7162
     assuming 4 is the protocol-specific representation of `EINTR'.
7163
 
7164
 
7165

7166
File: gdb.info,  Node: The Ctrl-C Message,  Next: Console I/O,  Prev: The F Reply Packet,  Up: File-I/O Remote Protocol Extension
7167
 
7168
D.13.5 The `Ctrl-C' Message
7169
---------------------------
7170
 
7171
If the `Ctrl-C' flag is set in the GDB reply packet (*note The F Reply
7172
Packet::), the target should behave as if it had gotten a break
7173
message.  The meaning for the target is "system call interrupted by
7174
`SIGINT'".  Consequentially, the target should actually stop (as with a
7175
break message) and return to GDB with a `T02' packet.
7176
 
7177
   It's important for the target to know in which state the system call
7178
was interrupted.  There are two possible cases:
7179
 
7180
   * The system call hasn't been performed on the host yet.
7181
 
7182
   * The system call on the host has been finished.
7183
 
7184
 
7185
   These two states can be distinguished by the target by the value of
7186
the returned `errno'.  If it's the protocol representation of `EINTR',
7187
the system call hasn't been performed.  This is equivalent to the
7188
`EINTR' handling on POSIX systems.  In any other case, the target may
7189
presume that the system call has been finished -- successfully or not
7190
-- and should behave as if the break message arrived right after the
7191
system call.
7192
 
7193
   GDB must behave reliably.  If the system call has not been called
7194
yet, GDB may send the `F' reply immediately, setting `EINTR' as `errno'
7195
in the packet.  If the system call on the host has been finished before
7196
the user requests a break, the full action must be finished by GDB.
7197
This requires sending `M' or `X' packets as necessary.  The `F' packet
7198
may only be sent when either nothing has happened or the full action
7199
has been completed.
7200
 
7201

7202
File: gdb.info,  Node: Console I/O,  Next: List of Supported Calls,  Prev: The Ctrl-C Message,  Up: File-I/O Remote Protocol Extension
7203
 
7204
D.13.6 Console I/O
7205
------------------
7206
 
7207
By default and if not explicitly closed by the target system, the file
7208
descriptors 0, 1 and 2 are connected to the GDB console.  Output on the
7209
GDB console is handled as any other file output operation (`write(1,
7210
...)' or `write(2, ...)').  Console input is handled by GDB so that
7211
after the target read request from file descriptor 0 all following
7212
typing is buffered until either one of the following conditions is met:
7213
 
7214
   * The user types `Ctrl-c'.  The behaviour is as explained above, and
7215
     the `read' system call is treated as finished.
7216
 
7217
   * The user presses .  This is treated as end of input with a
7218
     trailing newline.
7219
 
7220
   * The user types `Ctrl-d'.  This is treated as end of input.  No
7221
     trailing character (neither newline nor `Ctrl-D') is appended to
7222
     the input.
7223
 
7224
 
7225
   If the user has typed more characters than fit in the buffer given to
7226
the `read' call, the trailing characters are buffered in GDB until
7227
either another `read(0, ...)' is requested by the target, or debugging
7228
is stopped at the user's request.
7229
 
7230

7231
File: gdb.info,  Node: List of Supported Calls,  Next: Protocol-specific Representation of Datatypes,  Prev: Console I/O,  Up: File-I/O Remote Protocol Extension
7232
 
7233
D.13.7 List of Supported Calls
7234
------------------------------
7235
 
7236
* Menu:
7237
 
7238
* open::
7239
* close::
7240
* read::
7241
* write::
7242
* lseek::
7243
* rename::
7244
* unlink::
7245
* stat/fstat::
7246
* gettimeofday::
7247
* isatty::
7248
* system::
7249
 
7250

7251
File: gdb.info,  Node: open,  Next: close,  Up: List of Supported Calls
7252
 
7253
open
7254
....
7255
 
7256
Synopsis:
7257
          int open(const char *pathname, int flags);
7258
          int open(const char *pathname, int flags, mode_t mode);
7259
 
7260
Request:
7261
     `Fopen,PATHPTR/LEN,FLAGS,MODE'
7262
 
7263
     FLAGS is the bitwise `OR' of the following values:
7264
 
7265
    `O_CREAT'
7266
          If the file does not exist it will be created.  The host
7267
          rules apply as far as file ownership and time stamps are
7268
          concerned.
7269
 
7270
    `O_EXCL'
7271
          When used with `O_CREAT', if the file already exists it is an
7272
          error and open() fails.
7273
 
7274
    `O_TRUNC'
7275
          If the file already exists and the open mode allows writing
7276
          (`O_RDWR' or `O_WRONLY' is given) it will be truncated to
7277
          zero length.
7278
 
7279
    `O_APPEND'
7280
          The file is opened in append mode.
7281
 
7282
    `O_RDONLY'
7283
          The file is opened for reading only.
7284
 
7285
    `O_WRONLY'
7286
          The file is opened for writing only.
7287
 
7288
    `O_RDWR'
7289
          The file is opened for reading and writing.
7290
 
7291
     Other bits are silently ignored.
7292
 
7293
     MODE is the bitwise `OR' of the following values:
7294
 
7295
    `S_IRUSR'
7296
          User has read permission.
7297
 
7298
    `S_IWUSR'
7299
          User has write permission.
7300
 
7301
    `S_IRGRP'
7302
          Group has read permission.
7303
 
7304
    `S_IWGRP'
7305
          Group has write permission.
7306
 
7307
    `S_IROTH'
7308
          Others have read permission.
7309
 
7310
    `S_IWOTH'
7311
          Others have write permission.
7312
 
7313
     Other bits are silently ignored.
7314
 
7315
Return value:
7316
     `open' returns the new file descriptor or -1 if an error occurred.
7317
 
7318
Errors:
7319
 
7320
    `EEXIST'
7321
          PATHNAME already exists and `O_CREAT' and `O_EXCL' were used.
7322
 
7323
    `EISDIR'
7324
          PATHNAME refers to a directory.
7325
 
7326
    `EACCES'
7327
          The requested access is not allowed.
7328
 
7329
    `ENAMETOOLONG'
7330
          PATHNAME was too long.
7331
 
7332
    `ENOENT'
7333
          A directory component in PATHNAME does not exist.
7334
 
7335
    `ENODEV'
7336
          PATHNAME refers to a device, pipe, named pipe or socket.
7337
 
7338
    `EROFS'
7339
          PATHNAME refers to a file on a read-only filesystem and write
7340
          access was requested.
7341
 
7342
    `EFAULT'
7343
          PATHNAME is an invalid pointer value.
7344
 
7345
    `ENOSPC'
7346
          No space on device to create the file.
7347
 
7348
    `EMFILE'
7349
          The process already has the maximum number of files open.
7350
 
7351
    `ENFILE'
7352
          The limit on the total number of files open on the system has
7353
          been reached.
7354
 
7355
    `EINTR'
7356
          The call was interrupted by the user.
7357
 
7358
 
7359

7360
File: gdb.info,  Node: close,  Next: read,  Prev: open,  Up: List of Supported Calls
7361
 
7362
close
7363
.....
7364
 
7365
Synopsis:
7366
          int close(int fd);
7367
 
7368
Request:
7369
     `Fclose,FD'
7370
 
7371
Return value:
7372
     `close' returns zero on success, or -1 if an error occurred.
7373
 
7374
Errors:
7375
 
7376
    `EBADF'
7377
          FD isn't a valid open file descriptor.
7378
 
7379
    `EINTR'
7380
          The call was interrupted by the user.
7381
 
7382
 
7383

7384
File: gdb.info,  Node: read,  Next: write,  Prev: close,  Up: List of Supported Calls
7385
 
7386
read
7387
....
7388
 
7389
Synopsis:
7390
          int read(int fd, void *buf, unsigned int count);
7391
 
7392
Request:
7393
     `Fread,FD,BUFPTR,COUNT'
7394
 
7395
Return value:
7396
     On success, the number of bytes read is returned.  Zero indicates
7397
     end of file.  If count is zero, read returns zero as well.  On
7398
     error, -1 is returned.
7399
 
7400
Errors:
7401
 
7402
    `EBADF'
7403
          FD is not a valid file descriptor or is not open for reading.
7404
 
7405
    `EFAULT'
7406
          BUFPTR is an invalid pointer value.
7407
 
7408
    `EINTR'
7409
          The call was interrupted by the user.
7410
 
7411
 
7412

7413
File: gdb.info,  Node: write,  Next: lseek,  Prev: read,  Up: List of Supported Calls
7414
 
7415
write
7416
.....
7417
 
7418
Synopsis:
7419
          int write(int fd, const void *buf, unsigned int count);
7420
 
7421
Request:
7422
     `Fwrite,FD,BUFPTR,COUNT'
7423
 
7424
Return value:
7425
     On success, the number of bytes written are returned.  Zero
7426
     indicates nothing was written.  On error, -1 is returned.
7427
 
7428
Errors:
7429
 
7430
    `EBADF'
7431
          FD is not a valid file descriptor or is not open for writing.
7432
 
7433
    `EFAULT'
7434
          BUFPTR is an invalid pointer value.
7435
 
7436
    `EFBIG'
7437
          An attempt was made to write a file that exceeds the
7438
          host-specific maximum file size allowed.
7439
 
7440
    `ENOSPC'
7441
          No space on device to write the data.
7442
 
7443
    `EINTR'
7444
          The call was interrupted by the user.
7445
 
7446
 
7447

7448
File: gdb.info,  Node: lseek,  Next: rename,  Prev: write,  Up: List of Supported Calls
7449
 
7450
lseek
7451
.....
7452
 
7453
Synopsis:
7454
          long lseek (int fd, long offset, int flag);
7455
 
7456
Request:
7457
     `Flseek,FD,OFFSET,FLAG'
7458
 
7459
     FLAG is one of:
7460
 
7461
    `SEEK_SET'
7462
          The offset is set to OFFSET bytes.
7463
 
7464
    `SEEK_CUR'
7465
          The offset is set to its current location plus OFFSET bytes.
7466
 
7467
    `SEEK_END'
7468
          The offset is set to the size of the file plus OFFSET bytes.
7469
 
7470
Return value:
7471
     On success, the resulting unsigned offset in bytes from the
7472
     beginning of the file is returned.  Otherwise, a value of -1 is
7473
     returned.
7474
 
7475
Errors:
7476
 
7477
    `EBADF'
7478
          FD is not a valid open file descriptor.
7479
 
7480
    `ESPIPE'
7481
          FD is associated with the GDB console.
7482
 
7483
    `EINVAL'
7484
          FLAG is not a proper value.
7485
 
7486
    `EINTR'
7487
          The call was interrupted by the user.
7488
 
7489
 
7490

7491
File: gdb.info,  Node: rename,  Next: unlink,  Prev: lseek,  Up: List of Supported Calls
7492
 
7493
rename
7494
......
7495
 
7496
Synopsis:
7497
          int rename(const char *oldpath, const char *newpath);
7498
 
7499
Request:
7500
     `Frename,OLDPATHPTR/LEN,NEWPATHPTR/LEN'
7501
 
7502
Return value:
7503
     On success, zero is returned.  On error, -1 is returned.
7504
 
7505
Errors:
7506
 
7507
    `EISDIR'
7508
          NEWPATH is an existing directory, but OLDPATH is not a
7509
          directory.
7510
 
7511
    `EEXIST'
7512
          NEWPATH is a non-empty directory.
7513
 
7514
    `EBUSY'
7515
          OLDPATH or NEWPATH is a directory that is in use by some
7516
          process.
7517
 
7518
    `EINVAL'
7519
          An attempt was made to make a directory a subdirectory of
7520
          itself.
7521
 
7522
    `ENOTDIR'
7523
          A  component used as a directory in OLDPATH or new path is
7524
          not a directory.  Or OLDPATH is a directory and NEWPATH
7525
          exists but is not a directory.
7526
 
7527
    `EFAULT'
7528
          OLDPATHPTR or NEWPATHPTR are invalid pointer values.
7529
 
7530
    `EACCES'
7531
          No access to the file or the path of the file.
7532
 
7533
    `ENAMETOOLONG'
7534
          OLDPATH or NEWPATH was too long.
7535
 
7536
    `ENOENT'
7537
          A directory component in OLDPATH or NEWPATH does not exist.
7538
 
7539
    `EROFS'
7540
          The file is on a read-only filesystem.
7541
 
7542
    `ENOSPC'
7543
          The device containing the file has no room for the new
7544
          directory entry.
7545
 
7546
    `EINTR'
7547
          The call was interrupted by the user.
7548
 
7549
 
7550

7551
File: gdb.info,  Node: unlink,  Next: stat/fstat,  Prev: rename,  Up: List of Supported Calls
7552
 
7553
unlink
7554
......
7555
 
7556
Synopsis:
7557
          int unlink(const char *pathname);
7558
 
7559
Request:
7560
     `Funlink,PATHNAMEPTR/LEN'
7561
 
7562
Return value:
7563
     On success, zero is returned.  On error, -1 is returned.
7564
 
7565
Errors:
7566
 
7567
    `EACCES'
7568
          No access to the file or the path of the file.
7569
 
7570
    `EPERM'
7571
          The system does not allow unlinking of directories.
7572
 
7573
    `EBUSY'
7574
          The file PATHNAME cannot be unlinked because it's being used
7575
          by another process.
7576
 
7577
    `EFAULT'
7578
          PATHNAMEPTR is an invalid pointer value.
7579
 
7580
    `ENAMETOOLONG'
7581
          PATHNAME was too long.
7582
 
7583
    `ENOENT'
7584
          A directory component in PATHNAME does not exist.
7585
 
7586
    `ENOTDIR'
7587
          A component of the path is not a directory.
7588
 
7589
    `EROFS'
7590
          The file is on a read-only filesystem.
7591
 
7592
    `EINTR'
7593
          The call was interrupted by the user.
7594
 
7595
 
7596

7597
File: gdb.info,  Node: stat/fstat,  Next: gettimeofday,  Prev: unlink,  Up: List of Supported Calls
7598
 
7599
stat/fstat
7600
..........
7601
 
7602
Synopsis:
7603
          int stat(const char *pathname, struct stat *buf);
7604
          int fstat(int fd, struct stat *buf);
7605
 
7606
Request:
7607
     `Fstat,PATHNAMEPTR/LEN,BUFPTR'
7608
     `Ffstat,FD,BUFPTR'
7609
 
7610
Return value:
7611
     On success, zero is returned.  On error, -1 is returned.
7612
 
7613
Errors:
7614
 
7615
    `EBADF'
7616
          FD is not a valid open file.
7617
 
7618
    `ENOENT'
7619
          A directory component in PATHNAME does not exist or the path
7620
          is an empty string.
7621
 
7622
    `ENOTDIR'
7623
          A component of the path is not a directory.
7624
 
7625
    `EFAULT'
7626
          PATHNAMEPTR is an invalid pointer value.
7627
 
7628
    `EACCES'
7629
          No access to the file or the path of the file.
7630
 
7631
    `ENAMETOOLONG'
7632
          PATHNAME was too long.
7633
 
7634
    `EINTR'
7635
          The call was interrupted by the user.
7636
 
7637
 
7638

7639
File: gdb.info,  Node: gettimeofday,  Next: isatty,  Prev: stat/fstat,  Up: List of Supported Calls
7640
 
7641
gettimeofday
7642
............
7643
 
7644
Synopsis:
7645
          int gettimeofday(struct timeval *tv, void *tz);
7646
 
7647
Request:
7648
     `Fgettimeofday,TVPTR,TZPTR'
7649
 
7650
Return value:
7651
     On success, 0 is returned, -1 otherwise.
7652
 
7653
Errors:
7654
 
7655
    `EINVAL'
7656
          TZ is a non-NULL pointer.
7657
 
7658
    `EFAULT'
7659
          TVPTR and/or TZPTR is an invalid pointer value.
7660
 
7661
 
7662

7663
File: gdb.info,  Node: isatty,  Next: system,  Prev: gettimeofday,  Up: List of Supported Calls
7664
 
7665
isatty
7666
......
7667
 
7668
Synopsis:
7669
          int isatty(int fd);
7670
 
7671
Request:
7672
     `Fisatty,FD'
7673
 
7674
Return value:
7675
     Returns 1 if FD refers to the GDB console, 0 otherwise.
7676
 
7677
Errors:
7678
 
7679
    `EINTR'
7680
          The call was interrupted by the user.
7681
 
7682
 
7683
   Note that the `isatty' call is treated as a special case: it returns
7684
1 to the target if the file descriptor is attached to the GDB console,
7685
 
7686
implementing `ioctl' and would be more complex than needed.
7687
 
7688

7689
File: gdb.info,  Node: system,  Prev: isatty,  Up: List of Supported Calls
7690
 
7691
system
7692
......
7693
 
7694
Synopsis:
7695
          int system(const char *command);
7696
 
7697
Request:
7698
     `Fsystem,COMMANDPTR/LEN'
7699
 
7700
Return value:
7701
     If LEN is zero, the return value indicates whether a shell is
7702
     available.  A zero return value indicates a shell is not available.
7703
     For non-zero LEN, the value returned is -1 on error and the return
7704
     status of the command otherwise.  Only the exit status of the
7705
     command is returned, which is extracted from the host's `system'
7706
     return value by calling `WEXITSTATUS(retval)'.  In case `/bin/sh'
7707
     could not be executed, 127 is returned.
7708
 
7709
Errors:
7710
 
7711
    `EINTR'
7712
          The call was interrupted by the user.
7713
 
7714
 
7715
   GDB takes over the full task of calling the necessary host calls to
7716
perform the `system' call.  The return value of `system' on the host is
7717
simplified before it's returned to the target.  Any termination signal
7718
information from the child process is discarded, and the return value
7719
consists entirely of the exit status of the called command.
7720
 
7721
   Due to security concerns, the `system' call is by default refused by
7722
GDB.  The user has to allow this call explicitly with the `set remote
7723
system-call-allowed 1' command.
7724
 
7725
`set remote system-call-allowed'
7726
     Control whether to allow the `system' calls in the File I/O
7727
     protocol for the remote target.  The default is zero (disabled).
7728
 
7729
`show remote system-call-allowed'
7730
     Show whether the `system' calls are allowed in the File I/O
7731
     protocol.
7732
 
7733

7734
File: gdb.info,  Node: Protocol-specific Representation of Datatypes,  Next: Constants,  Prev: List of Supported Calls,  Up: File-I/O Remote Protocol Extension
7735
 
7736
D.13.8 Protocol-specific Representation of Datatypes
7737
----------------------------------------------------
7738
 
7739
* Menu:
7740
 
7741
* Integral Datatypes::
7742
* Pointer Values::
7743
* Memory Transfer::
7744
* struct stat::
7745
* struct timeval::
7746
 
7747

7748
File: gdb.info,  Node: Integral Datatypes,  Next: Pointer Values,  Up: Protocol-specific Representation of Datatypes
7749
 
7750
Integral Datatypes
7751
..................
7752
 
7753
The integral datatypes used in the system calls are `int', `unsigned
7754
int', `long', `unsigned long', `mode_t', and `time_t'.
7755
 
7756
   `int', `unsigned int', `mode_t' and `time_t' are implemented as 32
7757
bit values in this protocol.
7758
 
7759
   `long' and `unsigned long' are implemented as 64 bit types.
7760
 
7761
   *Note Limits::, for corresponding MIN and MAX values (similar to
7762
those in `limits.h') to allow range checking on host and target.
7763
 
7764
   `time_t' datatypes are defined as seconds since the Epoch.
7765
 
7766
   All integral datatypes transferred as part of a memory read or write
7767
of a structured datatype e.g. a `struct stat' have to be given in big
7768
endian byte order.
7769
 
7770

7771
File: gdb.info,  Node: Pointer Values,  Next: Memory Transfer,  Prev: Integral Datatypes,  Up: Protocol-specific Representation of Datatypes
7772
 
7773
Pointer Values
7774
..............
7775
 
7776
Pointers to target data are transmitted as they are.  An exception is
7777
made for pointers to buffers for which the length isn't transmitted as
7778
part of the function call, namely strings.  Strings are transmitted as
7779
a pointer/length pair, both as hex values, e.g.
7780
 
7781
     `1aaf/12'
7782
 
7783
which is a pointer to data of length 18 bytes at position 0x1aaf.  The
7784
length is defined as the full string length in bytes, including the
7785
trailing null byte.  For example, the string `"hello world"' at address
7786
0x123456 is transmitted as
7787
 
7788
     `123456/d'
7789
 
7790

7791
File: gdb.info,  Node: Memory Transfer,  Next: struct stat,  Prev: Pointer Values,  Up: Protocol-specific Representation of Datatypes
7792
 
7793
Memory Transfer
7794
...............
7795
 
7796
Structured data which is transferred using a memory read or write (for
7797
example, a `struct stat') is expected to be in a protocol-specific
7798
format with all scalar multibyte datatypes being big endian.
7799
Translation to this representation needs to be done both by the target
7800
before the `F' packet is sent, and by GDB before it transfers memory to
7801
the target.  Transferred pointers to structured data should point to
7802
the already-coerced data at any time.
7803
 
7804

7805
File: gdb.info,  Node: struct stat,  Next: struct timeval,  Prev: Memory Transfer,  Up: Protocol-specific Representation of Datatypes
7806
 
7807
struct stat
7808
...........
7809
 
7810
The buffer of type `struct stat' used by the target and GDB is defined
7811
as follows:
7812
 
7813
     struct stat {
7814
         unsigned int  st_dev;      /* device */
7815
         unsigned int  st_ino;      /* inode */
7816
         mode_t        st_mode;     /* protection */
7817
         unsigned int  st_nlink;    /* number of hard links */
7818
         unsigned int  st_uid;      /* user ID of owner */
7819
         unsigned int  st_gid;      /* group ID of owner */
7820
         unsigned int  st_rdev;     /* device type (if inode device) */
7821
         unsigned long st_size;     /* total size, in bytes */
7822
         unsigned long st_blksize;  /* blocksize for filesystem I/O */
7823
         unsigned long st_blocks;   /* number of blocks allocated */
7824
         time_t        st_atime;    /* time of last access */
7825
         time_t        st_mtime;    /* time of last modification */
7826
         time_t        st_ctime;    /* time of last change */
7827
     };
7828
 
7829
   The integral datatypes conform to the definitions given in the
7830
appropriate section (see *Note Integral Datatypes::, for details) so
7831
this structure is of size 64 bytes.
7832
 
7833
   The values of several fields have a restricted meaning and/or range
7834
of values.
7835
 
7836
`st_dev'
7837
     A value of 0 represents a file, 1 the console.
7838
 
7839
`st_ino'
7840
     No valid meaning for the target.  Transmitted unchanged.
7841
 
7842
`st_mode'
7843
     Valid mode bits are described in *Note Constants::.  Any other
7844
     bits have currently no meaning for the target.
7845
 
7846
`st_uid'
7847
`st_gid'
7848
`st_rdev'
7849
     No valid meaning for the target.  Transmitted unchanged.
7850
 
7851
`st_atime'
7852
`st_mtime'
7853
`st_ctime'
7854
     These values have a host and file system dependent accuracy.
7855
     Especially on Windows hosts, the file system may not support exact
7856
     timing values.
7857
 
7858
   The target gets a `struct stat' of the above representation and is
7859
responsible for coercing it to the target representation before
7860
continuing.
7861
 
7862
   Note that due to size differences between the host, target, and
7863
protocol representations of `struct stat' members, these members could
7864
eventually get truncated on the target.
7865
 
7866

7867
File: gdb.info,  Node: struct timeval,  Prev: struct stat,  Up: Protocol-specific Representation of Datatypes
7868
 
7869
struct timeval
7870
..............
7871
 
7872
The buffer of type `struct timeval' used by the File-I/O protocol is
7873
defined as follows:
7874
 
7875
     struct timeval {
7876
         time_t tv_sec;  /* second */
7877
         long   tv_usec; /* microsecond */
7878
     };
7879
 
7880
   The integral datatypes conform to the definitions given in the
7881
appropriate section (see *Note Integral Datatypes::, for details) so
7882
this structure is of size 8 bytes.
7883
 
7884

7885
File: gdb.info,  Node: Constants,  Next: File-I/O Examples,  Prev: Protocol-specific Representation of Datatypes,  Up: File-I/O Remote Protocol Extension
7886
 
7887
D.13.9 Constants
7888
----------------
7889
 
7890
The following values are used for the constants inside of the protocol.
7891
GDB and target are responsible for translating these values before and
7892
after the call as needed.
7893
 
7894
* Menu:
7895
 
7896
* Open Flags::
7897
* mode_t Values::
7898
* Errno Values::
7899
* Lseek Flags::
7900
* Limits::
7901
 
7902

7903
File: gdb.info,  Node: Open Flags,  Next: mode_t Values,  Up: Constants
7904
 
7905
Open Flags
7906
..........
7907
 
7908
All values are given in hexadecimal representation.
7909
 
7910
       O_RDONLY        0x0
7911
       O_WRONLY        0x1
7912
       O_RDWR          0x2
7913
       O_APPEND        0x8
7914
       O_CREAT       0x200
7915
       O_TRUNC       0x400
7916
       O_EXCL        0x800
7917
 
7918

7919
File: gdb.info,  Node: mode_t Values,  Next: Errno Values,  Prev: Open Flags,  Up: Constants
7920
 
7921
mode_t Values
7922
.............
7923
 
7924
All values are given in octal representation.
7925
 
7926
       S_IFREG       0100000
7927
       S_IFDIR        040000
7928
       S_IRUSR          0400
7929
       S_IWUSR          0200
7930
       S_IXUSR          0100
7931
       S_IRGRP           040
7932
       S_IWGRP           020
7933
       S_IXGRP           010
7934
       S_IROTH            04
7935
       S_IWOTH            02
7936
       S_IXOTH            01
7937
 
7938

7939
File: gdb.info,  Node: Errno Values,  Next: Lseek Flags,  Prev: mode_t Values,  Up: Constants
7940
 
7941
Errno Values
7942
............
7943
 
7944
All values are given in decimal representation.
7945
 
7946
       EPERM           1
7947
       ENOENT          2
7948
       EINTR           4
7949
       EBADF           9
7950
       EACCES         13
7951
       EFAULT         14
7952
       EBUSY          16
7953
       EEXIST         17
7954
       ENODEV         19
7955
       ENOTDIR        20
7956
       EISDIR         21
7957
       EINVAL         22
7958
       ENFILE         23
7959
       EMFILE         24
7960
       EFBIG          27
7961
       ENOSPC         28
7962
       ESPIPE         29
7963
       EROFS          30
7964
       ENAMETOOLONG   91
7965
       EUNKNOWN       9999
7966
 
7967
   `EUNKNOWN' is used as a fallback error value if a host system returns
7968
 any error value not in the list of supported error numbers.
7969
 
7970

7971
File: gdb.info,  Node: Lseek Flags,  Next: Limits,  Prev: Errno Values,  Up: Constants
7972
 
7973
Lseek Flags
7974
...........
7975
 
7976
       SEEK_SET      0
7977
       SEEK_CUR      1
7978
       SEEK_END      2
7979
 
7980

7981
File: gdb.info,  Node: Limits,  Prev: Lseek Flags,  Up: Constants
7982
 
7983
Limits
7984
......
7985
 
7986
All values are given in decimal representation.
7987
 
7988
       INT_MIN       -2147483648
7989
       INT_MAX        2147483647
7990
       UINT_MAX       4294967295
7991
       LONG_MIN      -9223372036854775808
7992
       LONG_MAX       9223372036854775807
7993
       ULONG_MAX      18446744073709551615
7994
 
7995

7996
File: gdb.info,  Node: File-I/O Examples,  Prev: Constants,  Up: File-I/O Remote Protocol Extension
7997
 
7998
D.13.10 File-I/O Examples
7999
-------------------------
8000
 
8001
Example sequence of a write call, file descriptor 3, buffer is at target
8002
address 0x1234, 6 bytes should be written:
8003
 
8004
     <- `Fwrite,3,1234,6'
8005
     _request memory read from target_
8006
     -> `m1234,6'
8007
     <- XXXXXX
8008
     _return "6 bytes written"_
8009
     -> `F6'
8010
 
8011
   Example sequence of a read call, file descriptor 3, buffer is at
8012
target address 0x1234, 6 bytes should be read:
8013
 
8014
     <- `Fread,3,1234,6'
8015
     _request memory write to target_
8016
     -> `X1234,6:XXXXXX'
8017
     _return "6 bytes read"_
8018
     -> `F6'
8019
 
8020
   Example sequence of a read call, call fails on the host due to
8021
invalid file descriptor (`EBADF'):
8022
 
8023
     <- `Fread,3,1234,6'
8024
     -> `F-1,9'
8025
 
8026
   Example sequence of a read call, user presses `Ctrl-c' before
8027
syscall on host is called:
8028
 
8029
     <- `Fread,3,1234,6'
8030
     -> `F-1,4,C'
8031
     <- `T02'
8032
 
8033
   Example sequence of a read call, user presses `Ctrl-c' after syscall
8034
on host is called:
8035
 
8036
     <- `Fread,3,1234,6'
8037
     -> `X1234,6:XXXXXX'
8038
     <- `T02'
8039
 
8040

8041
File: gdb.info,  Node: Library List Format,  Next: Memory Map Format,  Prev: File-I/O Remote Protocol Extension,  Up: Remote Protocol
8042
 
8043
D.14 Library List Format
8044
========================
8045
 
8046
On some platforms, a dynamic loader (e.g. `ld.so') runs in the same
8047
process as your application to manage libraries.  In this case, GDB can
8048
use the loader's symbol table and normal memory operations to maintain
8049
a list of shared libraries.  On other platforms, the operating system
8050
manages loaded libraries.  GDB can not retrieve the list of currently
8051
loaded libraries through memory operations, so it uses the
8052
`qXfer:libraries:read' packet (*note qXfer library list read::)
8053
instead.  The remote stub queries the target's operating system and
8054
reports which libraries are loaded.
8055
 
8056
   The `qXfer:libraries:read' packet returns an XML document which
8057
lists loaded libraries and their offsets.  Each library has an
8058
associated name and one or more segment or section base addresses,
8059
which report where the library was loaded in memory.
8060
 
8061
   For the common case of libraries that are fully linked binaries, the
8062
library should have a list of segments.  If the target supports dynamic
8063
linking of a relocatable object file, its library XML element should
8064
instead include a list of allocated sections.  The segment or section
8065
bases are start addresses, not relocation offsets; they do not depend
8066
on the library's link-time base addresses.
8067
 
8068
   GDB must be linked with the Expat library to support XML library
8069
lists.  *Note Expat::.
8070
 
8071
   A simple memory map, with one loaded library relocated by a single
8072
offset, looks like this:
8073
 
8074
     
8075
       
8076
         
8077
       
8078
     
8079
 
8080
   Another simple memory map, with one loaded library with three
8081
allocated sections (.text, .data, .bss), looks like this:
8082
 
8083
     
8084
       
8085
         
8086
         
8087
         
8088
       
8089
     
8090
 
8091
   The format of a library list is described by this DTD:
8092
 
8093
     
8094
     
8095
     
8096
     
8097
     
8098
     
8099
     
8100
     
8101
     
8102
 
8103
   In addition, segments and section descriptors cannot be mixed within
8104
a single library element, and you must supply at least one segment or
8105
section for each library.
8106
 
8107

8108
File: gdb.info,  Node: Memory Map Format,  Next: Thread List Format,  Prev: Library List Format,  Up: Remote Protocol
8109
 
8110
D.15 Memory Map Format
8111
======================
8112
 
8113
To be able to write into flash memory, GDB needs to obtain a memory map
8114
from the target.  This section describes the format of the memory map.
8115
 
8116
   The memory map is obtained using the `qXfer:memory-map:read' (*note
8117
qXfer memory map read::) packet and is an XML document that lists
8118
memory regions.
8119
 
8120
   GDB must be linked with the Expat library to support XML memory
8121
maps.  *Note Expat::.
8122
 
8123
   The top-level structure of the document is shown below:
8124
 
8125
     
8126
     
8127
               PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"
8128
                      "http://sourceware.org/gdb/gdb-memory-map.dtd">
8129
     
8130
         region...
8131
     
8132
 
8133
   Each region can be either:
8134
 
8135
   * A region of RAM starting at ADDR and extending for LENGTH bytes
8136
     from there:
8137
 
8138
          
8139
 
8140
   * A region of read-only memory:
8141
 
8142
          
8143
 
8144
   * A region of flash memory, with erasure blocks BLOCKSIZE bytes in
8145
     length:
8146
 
8147
          
8148
            BLOCKSIZE
8149
          
8150
 
8151
 
8152
   Regions must not overlap.  GDB assumes that areas of memory not
8153
covered by the memory map are RAM, and uses the ordinary `M' and `X'
8154
packets to write to addresses in such ranges.
8155
 
8156
   The formal DTD for memory map format is given below:
8157
 
8158
     
8159
     
8160
     
8161
     
8162
     
8163
     
8164
     
8165
     
8166
     
8167
     
8169
     
8170
                             start   CDATA   #REQUIRED
8171
                             length  CDATA   #REQUIRED
8172
                             device  CDATA   #IMPLIED>
8173
     
8174
     
8175
     
8176
 
8177

8178
File: gdb.info,  Node: Thread List Format,  Prev: Memory Map Format,  Up: Remote Protocol
8179
 
8180
D.16 Thread List Format
8181
=======================
8182
 
8183
To efficiently update the list of threads and their attributes, GDB
8184
issues the `qXfer:threads:read' packet (*note qXfer threads read::) and
8185
obtains the XML document with the following structure:
8186
 
8187
     
8188
     
8189
         
8190
         ... description ...
8191
         
8192
     
8193
 
8194
   Each `thread' element must have the `id' attribute that identifies
8195
the thread (*note thread-id syntax::).  The `core' attribute, if
8196
present, specifies which processor core the thread was last executing
8197
on.  The content of the of `thread' element is interpreted as
8198
human-readable auxilliary information.
8199
 
8200

8201
File: gdb.info,  Node: Agent Expressions,  Next: Target Descriptions,  Prev: Remote Protocol,  Up: Top
8202
 
8203
Appendix E The GDB Agent Expression Mechanism
8204
*********************************************
8205
 
8206
In some applications, it is not feasible for the debugger to interrupt
8207
the program's execution long enough for the developer to learn anything
8208
helpful about its behavior.  If the program's correctness depends on its
8209
real-time behavior, delays introduced by a debugger might cause the
8210
program to fail, even when the code itself is correct.  It is useful to
8211
be able to observe the program's behavior without interrupting it.
8212
 
8213
   Using GDB's `trace' and `collect' commands, the user can specify
8214
locations in the program, and arbitrary expressions to evaluate when
8215
those locations are reached.  Later, using the `tfind' command, she can
8216
examine the values those expressions had when the program hit the trace
8217
points.  The expressions may also denote objects in memory --
8218
structures or arrays, for example -- whose values GDB should record;
8219
while visiting a particular tracepoint, the user may inspect those
8220
objects as if they were in memory at that moment.  However, because GDB
8221
records these values without interacting with the user, it can do so
8222
quickly and unobtrusively, hopefully not disturbing the program's
8223
behavior.
8224
 
8225
   When GDB is debugging a remote target, the GDB "agent" code running
8226
on the target computes the values of the expressions itself.  To avoid
8227
having a full symbolic expression evaluator on the agent, GDB translates
8228
expressions in the source language into a simpler bytecode language, and
8229
then sends the bytecode to the agent; the agent then executes the
8230
bytecode, and records the values for GDB to retrieve later.
8231
 
8232
   The bytecode language is simple; there are forty-odd opcodes, the
8233
bulk of which are the usual vocabulary of C operands (addition,
8234
subtraction, shifts, and so on) and various sizes of literals and
8235
memory reference operations.  The bytecode interpreter operates
8236
strictly on machine-level values -- various sizes of integers and
8237
floating point numbers -- and requires no information about types or
8238
symbols; thus, the interpreter's internal data structures are simple,
8239
and each bytecode requires only a few native machine instructions to
8240
implement it.  The interpreter is small, and strict limits on the
8241
memory and time required to evaluate an expression are easy to
8242
determine, making it suitable for use by the debugging agent in
8243
real-time applications.
8244
 
8245
* Menu:
8246
 
8247
* General Bytecode Design::     Overview of the interpreter.
8248
* Bytecode Descriptions::       What each one does.
8249
* Using Agent Expressions::     How agent expressions fit into the big picture.
8250
* Varying Target Capabilities:: How to discover what the target can do.
8251
* Rationale::                   Why we did it this way.
8252
 
8253

8254
File: gdb.info,  Node: General Bytecode Design,  Next: Bytecode Descriptions,  Up: Agent Expressions
8255
 
8256
E.1 General Bytecode Design
8257
===========================
8258
 
8259
The agent represents bytecode expressions as an array of bytes.  Each
8260
instruction is one byte long (thus the term "bytecode").  Some
8261
instructions are followed by operand bytes; for example, the `goto'
8262
instruction is followed by a destination for the jump.
8263
 
8264
   The bytecode interpreter is a stack-based machine; most instructions
8265
pop their operands off the stack, perform some operation, and push the
8266
result back on the stack for the next instruction to consume.  Each
8267
element of the stack may contain either a integer or a floating point
8268
value; these values are as many bits wide as the largest integer that
8269
can be directly manipulated in the source language.  Stack elements
8270
carry no record of their type; bytecode could push a value as an
8271
integer, then pop it as a floating point value.  However, GDB will not
8272
generate code which does this.  In C, one might define the type of a
8273
stack element as follows:
8274
     union agent_val {
8275
       LONGEST l;
8276
       DOUBLEST d;
8277
     };
8278
   where `LONGEST' and `DOUBLEST' are `typedef' names for the largest
8279
integer and floating point types on the machine.
8280
 
8281
   By the time the bytecode interpreter reaches the end of the
8282
expression, the value of the expression should be the only value left
8283
on the stack.  For tracing applications, `trace' bytecodes in the
8284
expression will have recorded the necessary data, and the value on the
8285
stack may be discarded.  For other applications, like conditional
8286
breakpoints, the value may be useful.
8287
 
8288
   Separate from the stack, the interpreter has two registers:
8289
`pc'
8290
     The address of the next bytecode to execute.
8291
 
8292
`start'
8293
     The address of the start of the bytecode expression, necessary for
8294
     interpreting the `goto' and `if_goto' instructions.
8295
 
8296
   Neither of these registers is directly visible to the bytecode
8297
language itself, but they are useful for defining the meanings of the
8298
bytecode operations.
8299
 
8300
   There are no instructions to perform side effects on the running
8301
program, or call the program's functions; we assume that these
8302
expressions are only used for unobtrusive debugging, not for patching
8303
the running code.
8304
 
8305
   Most bytecode instructions do not distinguish between the various
8306
sizes of values, and operate on full-width values; the upper bits of the
8307
values are simply ignored, since they do not usually make a difference
8308
to the value computed.  The exceptions to this rule are:
8309
memory reference instructions (`ref'N)
8310
     There are distinct instructions to fetch different word sizes from
8311
     memory.  Once on the stack, however, the values are treated as
8312
     full-size integers.  They may need to be sign-extended; the `ext'
8313
     instruction exists for this purpose.
8314
 
8315
the sign-extension instruction (`ext' N)
8316
     These clearly need to know which portion of their operand is to be
8317
     extended to occupy the full length of the word.
8318
 
8319
 
8320
   If the interpreter is unable to evaluate an expression completely for
8321
some reason (a memory location is inaccessible, or a divisor is zero,
8322
for example), we say that interpretation "terminates with an error".
8323
This means that the problem is reported back to the interpreter's caller
8324
in some helpful way.  In general, code using agent expressions should
8325
assume that they may attempt to divide by zero, fetch arbitrary memory
8326
locations, and misbehave in other ways.
8327
 
8328
   Even complicated C expressions compile to a few bytecode
8329
instructions; for example, the expression `x + y * z' would typically
8330
produce code like the following, assuming that `x' and `y' live in
8331
registers, and `z' is a global variable holding a 32-bit `int':
8332
     reg 1
8333
     reg 2
8334
     const32 address of z
8335
     ref32
8336
     ext 32
8337
     mul
8338
     add
8339
     end
8340
 
8341
   In detail, these mean:
8342
`reg 1'
8343
     Push the value of register 1 (presumably holding `x') onto the
8344
     stack.
8345
 
8346
`reg 2'
8347
     Push the value of register 2 (holding `y').
8348
 
8349
`const32 address of z'
8350
     Push the address of `z' onto the stack.
8351
 
8352
`ref32'
8353
     Fetch a 32-bit word from the address at the top of the stack;
8354
     replace the address on the stack with the value.  Thus, we replace
8355
     the address of `z' with `z''s value.
8356
 
8357
`ext 32'
8358
     Sign-extend the value on the top of the stack from 32 bits to full
8359
     length.  This is necessary because `z' is a signed integer.
8360
 
8361
`mul'
8362
     Pop the top two numbers on the stack, multiply them, and push their
8363
     product.  Now the top of the stack contains the value of the
8364
     expression `y * z'.
8365
 
8366
`add'
8367
     Pop the top two numbers, add them, and push the sum.  Now the top
8368
     of the stack contains the value of `x + y * z'.
8369
 
8370
`end'
8371
     Stop executing; the value left on the stack top is the value to be
8372
     recorded.
8373
 
8374
 

powered by: WebSVN 2.1.0

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