1 This is gdb.info, produced by makeinfo version 4.8 from
2 ../.././gdb/doc/gdb.texinfo.
4 INFO-DIR-SECTION Software development
6 * Gdb: (gdb). The GNU debugger.
9 This file documents the GNU debugger GDB.
11 This is the Ninth Edition, of `Debugging with GDB: the GNU
12 Source-Level Debugger' for GDB Version 6.5.
14 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
16 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
17 Free Software Foundation, Inc.
19 Permission is granted to copy, distribute and/or modify this document
20 under the terms of the GNU Free Documentation License, Version 1.1 or
21 any later version published by the Free Software Foundation; with the
22 Invariant Sections being "Free Software" and "Free Software Needs Free
23 Documentation", with the Front-Cover Texts being "A GNU Manual," and
24 with the Back-Cover Texts as in (a) below.
26 (a) The Free Software Foundation's Back-Cover Text is: "You have
27 freedom to copy and modify this GNU Manual, like GNU software. Copies
28 published by the Free Software Foundation raise funds for GNU
32 File: gdb.info, Node: GDB/MI Data Manipulation, Next: GDB/MI Program Control, Prev: GDB/MI Breakpoint Table Commands, Up: GDB/MI
34 24.6 GDB/MI Data Manipulation
35 =============================
37 This section describes the GDB/MI commands that manipulate data:
38 examine memory and registers, evaluate expressions, etc.
40 The `-data-disassemble' Command
41 -------------------------------
47 [ -s START-ADDR -e END-ADDR ]
48 | [ -f FILENAME -l LINENUM [ -n LINES ] ]
54 is the beginning address (or `$pc')
60 is the name of the file to disassemble
63 is the line number to disassemble around
66 is the the number of disassembly lines to be produced. If it is
67 -1, the whole function will be disassembled, in case no END-ADDR is
68 specified. If END-ADDR is specified as a non-zero value, and
69 LINES is lower than the number of disassembly lines between
70 START-ADDR and END-ADDR, only LINES lines are displayed; if LINES
71 is higher than the number of lines between START-ADDR and
72 END-ADDR, only the lines up to END-ADDR are displayed.
75 is either 0 (meaning only disassembly) or 1 (meaning mixed source
81 The output for each instruction is composed of four fields:
91 Note that whatever included in the instruction field, is not
92 manipulated directely by GDB/MI, i.e. it is not possible to adjust its
98 There's no direct mapping from this command to the CLI.
103 Disassemble from the current value of `$pc' to `$pc + 20':
106 -data-disassemble -s $pc -e "$pc + 20" -- 0
109 {address="0x000107c0",func-name="main",offset="4",
111 {address="0x000107c4",func-name="main",offset="8",
112 inst="sethi %hi(0x11800), %o2"},
113 {address="0x000107c8",func-name="main",offset="12",
114 inst="or %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"},
115 {address="0x000107cc",func-name="main",offset="16",
116 inst="sethi %hi(0x11800), %o2"},
117 {address="0x000107d0",func-name="main",offset="20",
118 inst="or %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"}]
121 Disassemble the whole `main' function. Line 32 is part of `main'.
123 -data-disassemble -f basics.c -l 32 -- 0
125 {address="0x000107bc",func-name="main",offset="0",
126 inst="save %sp, -112, %sp"},
127 {address="0x000107c0",func-name="main",offset="4",
129 {address="0x000107c4",func-name="main",offset="8",
130 inst="sethi %hi(0x11800), %o2"},
132 {address="0x0001081c",func-name="main",offset="96",inst="ret "},
133 {address="0x00010820",func-name="main",offset="100",inst="restore "}]
136 Disassemble 3 instructions from the start of `main':
139 -data-disassemble -f basics.c -l 32 -n 3 -- 0
141 {address="0x000107bc",func-name="main",offset="0",
142 inst="save %sp, -112, %sp"},
143 {address="0x000107c0",func-name="main",offset="4",
145 {address="0x000107c4",func-name="main",offset="8",
146 inst="sethi %hi(0x11800), %o2"}]
149 Disassemble 3 instructions from the start of `main' in mixed mode:
152 -data-disassemble -f basics.c -l 32 -n 3 -- 1
154 src_and_asm_line={line="31",
155 file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
156 testsuite/gdb.mi/basics.c",line_asm_insn=[
157 {address="0x000107bc",func-name="main",offset="0",
158 inst="save %sp, -112, %sp"}]},
159 src_and_asm_line={line="32",
160 file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
161 testsuite/gdb.mi/basics.c",line_asm_insn=[
162 {address="0x000107c0",func-name="main",offset="4",
164 {address="0x000107c4",func-name="main",offset="8",
165 inst="sethi %hi(0x11800), %o2"}]}]
168 The `-data-evaluate-expression' Command
169 ---------------------------------------
174 -data-evaluate-expression EXPR
176 Evaluate EXPR as an expression. The expression could contain an
177 inferior function call. The function call will execute synchronously.
178 If the expression contains spaces, it must be enclosed in double quotes.
183 The corresponding GDB commands are `print', `output', and `call'. In
184 `gdbtk' only, there's a corresponding `gdb_eval' command.
189 In the following example, the numbers that precede the commands are the
190 "tokens" described in *Note GDB/MI Command Syntax: GDB/MI Command
191 Syntax. Notice how GDB/MI returns the same tokens in its output.
193 211-data-evaluate-expression A
196 311-data-evaluate-expression &A
197 311^done,value="0xefffeb7c"
199 411-data-evaluate-expression A+3
202 511-data-evaluate-expression "A + 3"
206 The `-data-list-changed-registers' Command
207 ------------------------------------------
212 -data-list-changed-registers
214 Display a list of the registers that have changed.
219 GDB doesn't have a direct analog for this command; `gdbtk' has the
220 corresponding command `gdb_changed_register_list'.
232 *stopped,reason="breakpoint-hit",bkptno="1",frame={func="main",
233 args=[],file="try.c",fullname="/home/foo/bar/try.c",line="5"}
235 -data-list-changed-registers
236 ^done,changed-registers=["0","1","2","4","5","6","7","8","9",
237 "10","11","13","14","15","16","17","18","19","20","21","22","23",
238 "24","25","26","27","28","30","31","64","65","66","67","69"]
241 The `-data-list-register-names' Command
242 ---------------------------------------
247 -data-list-register-names [ ( REGNO )+ ]
249 Show a list of register names for the current target. If no
250 arguments are given, it shows a list of the names of all the registers.
251 If integer numbers are given as arguments, it will print a list of the
252 names of the registers corresponding to the arguments. To ensure
253 consistency between a register name and its number, the output list may
254 include empty register names.
259 GDB does not have a command which corresponds to
260 `-data-list-register-names'. In `gdbtk' there is a corresponding
261 command `gdb_regnames'.
266 For the PPC MBX board:
268 -data-list-register-names
269 ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
270 "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
271 "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
272 "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
273 "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
274 "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
275 "", "pc","ps","cr","lr","ctr","xer"]
277 -data-list-register-names 1 2 3
278 ^done,register-names=["r1","r2","r3"]
281 The `-data-list-register-values' Command
282 ----------------------------------------
287 -data-list-register-values FMT [ ( REGNO )*]
289 Display the registers' contents. FMT is the format according to
290 which the registers' contents are to be returned, followed by an
291 optional list of numbers specifying the registers to display. A
292 missing list of numbers indicates that the contents of all the
293 registers must be returned.
295 Allowed formats for FMT are:
318 The corresponding GDB commands are `info reg', `info all-reg', and (in
319 `gdbtk') `gdb_fetch_registers'.
324 For a PPC MBX board (note: line breaks are for readability only, they
325 don't appear in the actual output):
328 -data-list-register-values r 64 65
329 ^done,register-values=[{number="64",value="0xfe00a300"},
330 {number="65",value="0x00029002"}]
332 -data-list-register-values x
333 ^done,register-values=[{number="0",value="0xfe0043c8"},
334 {number="1",value="0x3fff88"},{number="2",value="0xfffffffe"},
335 {number="3",value="0x0"},{number="4",value="0xa"},
336 {number="5",value="0x3fff68"},{number="6",value="0x3fff58"},
337 {number="7",value="0xfe011e98"},{number="8",value="0x2"},
338 {number="9",value="0xfa202820"},{number="10",value="0xfa202808"},
339 {number="11",value="0x1"},{number="12",value="0x0"},
340 {number="13",value="0x4544"},{number="14",value="0xffdfffff"},
341 {number="15",value="0xffffffff"},{number="16",value="0xfffffeff"},
342 {number="17",value="0xefffffed"},{number="18",value="0xfffffffe"},
343 {number="19",value="0xffffffff"},{number="20",value="0xffffffff"},
344 {number="21",value="0xffffffff"},{number="22",value="0xfffffff7"},
345 {number="23",value="0xffffffff"},{number="24",value="0xffffffff"},
346 {number="25",value="0xffffffff"},{number="26",value="0xfffffffb"},
347 {number="27",value="0xffffffff"},{number="28",value="0xf7bfffff"},
348 {number="29",value="0x0"},{number="30",value="0xfe010000"},
349 {number="31",value="0x0"},{number="32",value="0x0"},
350 {number="33",value="0x0"},{number="34",value="0x0"},
351 {number="35",value="0x0"},{number="36",value="0x0"},
352 {number="37",value="0x0"},{number="38",value="0x0"},
353 {number="39",value="0x0"},{number="40",value="0x0"},
354 {number="41",value="0x0"},{number="42",value="0x0"},
355 {number="43",value="0x0"},{number="44",value="0x0"},
356 {number="45",value="0x0"},{number="46",value="0x0"},
357 {number="47",value="0x0"},{number="48",value="0x0"},
358 {number="49",value="0x0"},{number="50",value="0x0"},
359 {number="51",value="0x0"},{number="52",value="0x0"},
360 {number="53",value="0x0"},{number="54",value="0x0"},
361 {number="55",value="0x0"},{number="56",value="0x0"},
362 {number="57",value="0x0"},{number="58",value="0x0"},
363 {number="59",value="0x0"},{number="60",value="0x0"},
364 {number="61",value="0x0"},{number="62",value="0x0"},
365 {number="63",value="0x0"},{number="64",value="0xfe00a300"},
366 {number="65",value="0x29002"},{number="66",value="0x202f04b5"},
367 {number="67",value="0xfe0043b0"},{number="68",value="0xfe00b3e4"},
368 {number="69",value="0x20002b03"}]
371 The `-data-read-memory' Command
372 -------------------------------
377 -data-read-memory [ -o BYTE-OFFSET ]
378 ADDRESS WORD-FORMAT WORD-SIZE
379 NR-ROWS NR-COLS [ ASCHAR ]
384 An expression specifying the address of the first memory word to be
385 read. Complex expressions containing embedded white space should
386 be quoted using the C convention.
389 The format to be used to print the memory words. The notation is
390 the same as for GDB's `print' command (*note Output formats:
394 The size of each memory word in bytes.
397 The number of rows in the output table.
400 The number of columns in the output table.
403 If present, indicates that each row should include an ASCII dump.
404 The value of ASCHAR is used as a padding character when a byte is
405 not a member of the printable ASCII character set (printable ASCII
406 characters are those whose code is between 32 and 126,
410 An offset to add to the ADDRESS before fetching memory.
412 This command displays memory contents as a table of NR-ROWS by
413 NR-COLS words, each word being WORD-SIZE bytes. In total, `NR-ROWS *
414 NR-COLS * WORD-SIZE' bytes are read (returned as `total-bytes').
415 Should less than the requested number of bytes be returned by the
416 target, the missing words are identified using `N/A'. The number of
417 bytes read from the target is returned in `nr-bytes' and the starting
418 address used to read memory in `addr'.
420 The address of the next/previous row or page is available in
421 `next-row' and `prev-row', `next-page' and `prev-page'.
426 The corresponding GDB command is `x'. `gdbtk' has `gdb_get_mem' memory
432 Read six bytes of memory starting at `bytes+6' but then offset by `-6'
433 bytes. Format as three rows of two columns. One byte per word.
434 Display each word in hex.
437 9-data-read-memory -o -6 -- bytes+6 x 1 3 2
438 9^done,addr="0x00001390",nr-bytes="6",total-bytes="6",
439 next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396",
440 prev-page="0x0000138a",memory=[
441 {addr="0x00001390",data=["0x00","0x01"]},
442 {addr="0x00001392",data=["0x02","0x03"]},
443 {addr="0x00001394",data=["0x04","0x05"]}]
446 Read two bytes of memory starting at address `shorts + 64' and
447 display as a single word formatted in decimal.
450 5-data-read-memory shorts+64 d 2 1 1
451 5^done,addr="0x00001510",nr-bytes="2",total-bytes="2",
452 next-row="0x00001512",prev-row="0x0000150e",
453 next-page="0x00001512",prev-page="0x0000150e",memory=[
454 {addr="0x00001510",data=["128"]}]
457 Read thirty two bytes of memory starting at `bytes+16' and format as
458 eight rows of four columns. Include a string encoding with `x' used as
459 the non-printable character.
462 4-data-read-memory bytes+16 x 1 8 4 x
463 4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32",
464 next-row="0x000013c0",prev-row="0x0000139c",
465 next-page="0x000013c0",prev-page="0x00001380",memory=[
466 {addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"},
467 {addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"},
468 {addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"},
469 {addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"},
470 {addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"},
471 {addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"},
472 {addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"},
473 {addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"}]
476 The `-display-delete' Command
477 -----------------------------
482 -display-delete NUMBER
484 Delete the display NUMBER.
489 The corresponding GDB command is `delete display'.
496 The `-display-disable' Command
497 ------------------------------
502 -display-disable NUMBER
504 Disable display NUMBER.
509 The corresponding GDB command is `disable display'.
516 The `-display-enable' Command
517 -----------------------------
522 -display-enable NUMBER
524 Enable display NUMBER.
529 The corresponding GDB command is `enable display'.
536 The `-display-insert' Command
537 -----------------------------
542 -display-insert EXPRESSION
544 Display EXPRESSION every time the program stops.
549 The corresponding GDB command is `display'.
556 The `-display-list' Command
557 ---------------------------
564 List the displays. Do not show the current values.
569 The corresponding GDB command is `info display'.
576 The `-environment-cd' Command
577 -----------------------------
582 -environment-cd PATHDIR
584 Set GDB's working directory.
589 The corresponding GDB command is `cd'.
595 -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
599 The `-environment-directory' Command
600 ------------------------------------
605 -environment-directory [ -r ] [ PATHDIR ]+
607 Add directories PATHDIR to beginning of search path for source files.
608 If the `-r' option is used, the search path is reset to the default
609 search path. If directories PATHDIR are supplied in addition to the
610 `-r' option, the search path is first reset and then addition occurs as
611 normal. Multiple directories may be specified, separated by blanks.
612 Specifying multiple directories in a single command results in the
613 directories added to the beginning of the search path in the same order
614 they were presented in the command. If blanks are needed as part of a
615 directory name, double-quotes should be used around the name. In the
616 command output, the path will show up separated by the system
617 directory-separator character. The directory-seperator character must
618 not be used in any directory name. If no directories are specified,
619 the current search path is displayed.
624 The corresponding GDB command is `dir'.
630 -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
631 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
633 -environment-directory ""
634 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
636 -environment-directory -r /home/jjohnstn/src/gdb /usr/src
637 ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
639 -environment-directory -r
640 ^done,source-path="$cdir:$cwd"
643 The `-environment-path' Command
644 -------------------------------
649 -environment-path [ -r ] [ PATHDIR ]+
651 Add directories PATHDIR to beginning of search path for object files.
652 If the `-r' option is used, the search path is reset to the original
653 search path that existed at gdb start-up. If directories PATHDIR are
654 supplied in addition to the `-r' option, the search path is first reset
655 and then addition occurs as normal. Multiple directories may be
656 specified, separated by blanks. Specifying multiple directories in a
657 single command results in the directories added to the beginning of the
658 search path in the same order they were presented in the command. If
659 blanks are needed as part of a directory name, double-quotes should be
660 used around the name. In the command output, the path will show up
661 separated by the system directory-separator character. The
662 directory-seperator character must not be used in any directory name.
663 If no directories are specified, the current path is displayed.
668 The corresponding GDB command is `path'.
675 ^done,path="/usr/bin"
677 -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
678 ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
680 -environment-path -r /usr/local/bin
681 ^done,path="/usr/local/bin:/usr/bin"
684 The `-environment-pwd' Command
685 ------------------------------
692 Show the current working directory.
697 The corresponding GDB command is `pwd'.
704 ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
708 File: gdb.info, Node: GDB/MI Program Control, Next: GDB/MI Miscellaneous Commands, Prev: GDB/MI Data Manipulation, Up: GDB/MI
710 24.7 GDB/MI Program control
711 ===========================
716 As a result of execution, the inferior program can run to completion, if
717 it doesn't encounter any breakpoints. In this case the output will
718 include an exit code, if the program has exited exceptionally.
723 Program exited normally:
730 *stopped,reason="exited-normally"
733 Program exited exceptionally:
740 *stopped,reason="exited",exit-code="01"
743 Another way the program can terminate is if it receives a signal
744 such as `SIGINT'. In this case, GDB/MI displays this:
747 *stopped,reason="exited-signalled",signal-name="SIGINT",
748 signal-meaning="Interrupt"
750 The `-exec-abort' Command
751 -------------------------
758 Kill the inferior running program.
763 The corresponding GDB command is `kill'.
770 The `-exec-arguments' Command
771 -----------------------------
778 Set the inferior program arguments, to be used in the next
784 The corresponding GDB command is `set args'.
789 Don't have one around.
791 The `-exec-continue' Command
792 ----------------------------
799 Asynchronous command. Resumes the execution of the inferior program
800 until a breakpoint is encountered, or until the inferior exits.
805 The corresponding GDB corresponding is `continue'.
814 *stopped,reason="breakpoint-hit",bkptno="2",frame={func="foo",args=[],
815 file="hello.c",fullname="/home/foo/bar/hello.c",line="13"}
818 The `-exec-finish' Command
819 --------------------------
826 Asynchronous command. Resumes the execution of the inferior program
827 until the current function is exited. Displays the results returned by
833 The corresponding GDB command is `finish'.
838 Function returning `void'.
844 *stopped,reason="function-finished",frame={func="main",args=[],
845 file="hello.c",fullname="/home/foo/bar/hello.c",line="7"}
848 Function returning other than `void'. The name of the internal GDB
849 variable storing the result is printed, together with the value itself.
854 *stopped,reason="function-finished",frame={addr="0x000107b0",func="foo",
855 args=[{name="a",value="1"],{name="b",value="9"}},
856 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
857 gdb-result-var="$1",return-value="0"
860 The `-exec-interrupt' Command
861 -----------------------------
868 Asynchronous command. Interrupts the background execution of the
869 target. Note how the token associated with the stop message is the one
870 for the execution command that has been interrupted. The token for the
871 interrupt itself only appears in the `^done' output. If the user is
872 trying to interrupt a non-running program, an error message will be
878 The corresponding GDB command is `interrupt'.
891 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
892 frame={addr="0x00010140",func="foo",args=[],file="try.c",
893 fullname="/home/foo/bar/try.c",line="13"}
898 ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
901 The `-exec-next' Command
902 ------------------------
909 Asynchronous command. Resumes execution of the inferior program,
910 stopping when the beginning of the next source line is reached.
915 The corresponding GDB command is `next'.
923 *stopped,reason="end-stepping-range",line="8",file="hello.c"
926 The `-exec-next-instruction' Command
927 ------------------------------------
932 -exec-next-instruction
934 Asynchronous command. Executes one machine instruction. If the
935 instruction is a function call continues until the function returns. If
936 the program stops at an instruction in the middle of a source line, the
937 address will be printed as well.
942 The corresponding GDB command is `nexti'.
948 -exec-next-instruction
952 *stopped,reason="end-stepping-range",
953 addr="0x000100d4",line="5",file="hello.c"
956 The `-exec-return' Command
957 --------------------------
964 Makes current function return immediately. Doesn't execute the
965 inferior. Displays the new current frame.
970 The corresponding GDB command is `return'.
976 200-break-insert callee4
977 200^done,bkpt={number="1",addr="0x00010734",
978 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
983 000*stopped,reason="breakpoint-hit",bkptno="1",
984 frame={func="callee4",args=[],
985 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
986 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"}
992 111^done,frame={level="0",func="callee3",
993 args=[{name="strarg",
994 value="0x11940 \"A string argument.\""}],
995 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
996 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
999 The `-exec-run' Command
1000 -----------------------
1007 Asynchronous command. Starts execution of the inferior from the
1008 beginning. The inferior executes until either a breakpoint is
1009 encountered or the program exits.
1014 The corresponding GDB command is `run'.
1021 ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"}
1026 *stopped,reason="breakpoint-hit",bkptno="1",
1027 frame={func="main",args=[],file="recursive2.c",
1028 fullname="/home/foo/bar/recursive2.c",line="4"}
1031 The `-exec-show-arguments' Command
1032 ----------------------------------
1037 -exec-show-arguments
1039 Print the arguments of the program.
1044 The corresponding GDB command is `show args'.
1051 The `-exec-step' Command
1052 ------------------------
1059 Asynchronous command. Resumes execution of the inferior program,
1060 stopping when the beginning of the next source line is reached, if the
1061 next source line is not a function call. If it is, stop at the first
1062 instruction of the called function.
1067 The corresponding GDB command is `step'.
1072 Stepping into a function:
1077 *stopped,reason="end-stepping-range",
1078 frame={func="foo",args=[{name="a",value="10"},
1079 {name="b",value="0"}],file="recursive2.c",
1080 fullname="/home/foo/bar/recursive2.c",line="11"}
1088 *stopped,reason="end-stepping-range",line="14",file="recursive2.c"
1091 The `-exec-step-instruction' Command
1092 ------------------------------------
1097 -exec-step-instruction
1099 Asynchronous command. Resumes the inferior which executes one
1100 machine instruction. The output, once GDB has stopped, will vary
1101 depending on whether we have stopped in the middle of a source line or
1102 not. In the former case, the address at which the program stopped will
1108 The corresponding GDB command is `stepi'.
1114 -exec-step-instruction
1118 *stopped,reason="end-stepping-range",
1119 frame={func="foo",args=[],file="try.c",
1120 fullname="/home/foo/bar/try.c",line="10"}
1122 -exec-step-instruction
1126 *stopped,reason="end-stepping-range",
1127 frame={addr="0x000100f4",func="foo",args=[],file="try.c",
1128 fullname="/home/foo/bar/try.c",line="10"}
1131 The `-exec-until' Command
1132 -------------------------
1137 -exec-until [ LOCATION ]
1139 Asynchronous command. Executes the inferior until the LOCATION
1140 specified in the argument is reached. If there is no argument, the
1141 inferior executes until a source line greater than the current one is
1142 reached. The reason for stopping in this case will be
1148 The corresponding GDB command is `until'.
1154 -exec-until recursive2.c:6
1158 *stopped,reason="location-reached",frame={func="main",args=[],
1159 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6"}
1162 The `-file-exec-and-symbols' Command
1163 ------------------------------------
1168 -file-exec-and-symbols FILE
1170 Specify the executable file to be debugged. This file is the one
1171 from which the symbol table is also read. If no file is specified, the
1172 command clears the executable and symbol information. If breakpoints
1173 are set when using this command with no arguments, GDB will produce
1174 error messages. Otherwise, no output is produced, except a completion
1180 The corresponding GDB command is `file'.
1186 -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
1190 The `-file-exec-file' Command
1191 -----------------------------
1196 -file-exec-file FILE
1198 Specify the executable file to be debugged. Unlike
1199 `-file-exec-and-symbols', the symbol table is _not_ read from this
1200 file. If used without argument, GDB clears the information about the
1201 executable file. No output is produced, except a completion
1207 The corresponding GDB command is `exec-file'.
1213 -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
1217 The `-file-list-exec-sections' Command
1218 --------------------------------------
1223 -file-list-exec-sections
1225 List the sections of the current executable file.
1230 The GDB command `info file' shows, among the rest, the same information
1231 as this command. `gdbtk' has a corresponding command `gdb_load_info'.
1238 The `-file-list-exec-source-file' Command
1239 -----------------------------------------
1244 -file-list-exec-source-file
1246 List the line number, the current source file, and the absolute path
1247 to the current source file for the current executable.
1252 There's no GDB command which directly corresponds to this one.
1258 123-file-list-exec-source-file
1259 123^done,line="1",file="foo.c",fullname="/home/bar/foo.c"
1262 The `-file-list-exec-source-files' Command
1263 ------------------------------------------
1268 -file-list-exec-source-files
1270 List the source files for the current executable.
1272 It will always output the filename, but only when GDB can find the
1273 absolute file name of a source file, will it output the fullname.
1278 There's no GDB command which directly corresponds to this one. `gdbtk'
1279 has an analogous command `gdb_listfiles'.
1285 -file-list-exec-source-files
1287 {file=foo.c,fullname=/home/foo.c},
1288 {file=/home/bar.c,fullname=/home/bar.c},
1289 {file=gdb_could_not_find_fullpath.c}]
1292 The `-file-list-shared-libraries' Command
1293 -----------------------------------------
1298 -file-list-shared-libraries
1300 List the shared libraries in the program.
1305 The corresponding GDB command is `info shared'.
1312 The `-file-list-symbol-files' Command
1313 -------------------------------------
1318 -file-list-symbol-files
1325 The corresponding GDB command is `info file' (part of it).
1332 The `-file-symbol-file' Command
1333 -------------------------------
1338 -file-symbol-file FILE
1340 Read symbol table info from the specified FILE argument. When used
1341 without arguments, clears GDB's symbol table info. No output is
1342 produced, except for a completion notification.
1347 The corresponding GDB command is `symbol-file'.
1353 -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
1358 File: gdb.info, Node: GDB/MI Miscellaneous Commands, Next: GDB/MI Stack Manipulation, Prev: GDB/MI Program Control, Up: GDB/MI
1360 24.8 Miscellaneous GDB commands in GDB/MI
1361 =========================================
1363 The `-gdb-exit' Command
1364 -----------------------
1371 Exit GDB immediately.
1376 Approximately corresponds to `quit'.
1384 The `-gdb-set' Command
1385 ----------------------
1392 Set an internal GDB variable.
1397 The corresponding GDB command is `set'.
1407 The `-gdb-show' Command
1408 -----------------------
1415 Show the current value of a GDB variable.
1420 The corresponding GDB command is `show'.
1430 The `-gdb-version' Command
1431 --------------------------
1438 Show version information for GDB. Used mostly in testing.
1443 There's no equivalent GDB command. GDB by default shows this
1444 information when you start an interactive session.
1452 ~Copyright 2000 Free Software Foundation, Inc.
1453 ~GDB is free software, covered by the GNU General Public License, and
1454 ~you are welcome to change it and/or distribute copies of it under
1455 ~ certain conditions.
1456 ~Type "show copying" to see the conditions.
1457 ~There is absolutely no warranty for GDB. Type "show warranty" for
1459 ~This GDB was configured as
1460 "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi".
1464 The `-interpreter-exec' Command
1465 -------------------------------
1470 -interpreter-exec INTERPRETER COMMAND
1472 Execute the specified COMMAND in the given INTERPRETER.
1477 The corresponding GDB command is `interpreter-exec'.
1483 -interpreter-exec console "break main"
1484 &"During symbol reading, couldn't parse type; debugger out of date?.\n"
1485 &"During symbol reading, bad structure-type format.\n"
1486 ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
1490 The `-inferior-tty-set' Command
1491 -------------------------------
1496 -inferior-tty-set /dev/pts/1
1498 Set terminal for future runs of the program being debugged.
1503 The corresponding GDB command is `set inferior-tty /dev/pts/1'.
1509 -inferior-tty-set /dev/pts/1
1513 The `-inferior-tty-show' Command
1514 --------------------------------
1521 Show terminal for future runs of program being debugged.
1526 The corresponding GDB command is `show inferior-tty'.
1532 -inferior-tty-set /dev/pts/1
1536 ^done,inferior_tty_terminal="/dev/pts/1"
1540 File: gdb.info, Node: GDB/MI Stack Manipulation, Next: GDB/MI Symbol Query, Prev: GDB/MI Miscellaneous Commands, Up: GDB/MI
1542 24.9 GDB/MI Stack Manipulation Commands
1543 =======================================
1545 The `-stack-info-frame' Command
1546 -------------------------------
1553 Get info on the selected frame.
1558 The corresponding GDB command is `info frame' or `frame' (without
1566 ^done,frame={level="1",addr="0x0001076c",func="callee3",
1567 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
1568 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"}
1571 The `-stack-info-depth' Command
1572 -------------------------------
1577 -stack-info-depth [ MAX-DEPTH ]
1579 Return the depth of the stack. If the integer argument MAX-DEPTH is
1580 specified, do not count beyond MAX-DEPTH frames.
1585 There's no equivalent GDB command.
1590 For a stack with frame levels 0 through 11:
1599 -stack-info-depth 12
1602 -stack-info-depth 11
1605 -stack-info-depth 13
1609 The `-stack-list-arguments' Command
1610 -----------------------------------
1615 -stack-list-arguments SHOW-VALUES
1616 [ LOW-FRAME HIGH-FRAME ]
1618 Display a list of the arguments for the frames between LOW-FRAME and
1619 HIGH-FRAME (inclusive). If LOW-FRAME and HIGH-FRAME are not provided,
1620 list the arguments for the whole call stack.
1622 The SHOW-VALUES argument must have a value of 0 or 1. A value of 0
1623 means that only the names of the arguments are listed, a value of 1
1624 means that both names and values of the arguments are printed.
1629 GDB does not have an equivalent command. `gdbtk' has a `gdb_get_args'
1630 command which partially overlaps with the functionality of
1631 `-stack-list-arguments'.
1640 frame={level="0",addr="0x00010734",func="callee4",
1641 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
1642 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"},
1643 frame={level="1",addr="0x0001076c",func="callee3",
1644 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
1645 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"},
1646 frame={level="2",addr="0x0001078c",func="callee2",
1647 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
1648 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"},
1649 frame={level="3",addr="0x000107b4",func="callee1",
1650 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
1651 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"},
1652 frame={level="4",addr="0x000107e0",func="main",
1653 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
1654 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"}]
1656 -stack-list-arguments 0
1659 frame={level="0",args=[]},
1660 frame={level="1",args=[name="strarg"]},
1661 frame={level="2",args=[name="intarg",name="strarg"]},
1662 frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]},
1663 frame={level="4",args=[]}]
1665 -stack-list-arguments 1
1668 frame={level="0",args=[]},
1670 args=[{name="strarg",value="0x11940 \"A string argument.\""}]},
1671 frame={level="2",args=[
1672 {name="intarg",value="2"},
1673 {name="strarg",value="0x11940 \"A string argument.\""}]},
1674 {frame={level="3",args=[
1675 {name="intarg",value="2"},
1676 {name="strarg",value="0x11940 \"A string argument.\""},
1677 {name="fltarg",value="3.5"}]},
1678 frame={level="4",args=[]}]
1680 -stack-list-arguments 0 2 2
1681 ^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}]
1683 -stack-list-arguments 1 2 2
1684 ^done,stack-args=[frame={level="2",
1685 args=[{name="intarg",value="2"},
1686 {name="strarg",value="0x11940 \"A string argument.\""}]}]
1689 The `-stack-list-frames' Command
1690 --------------------------------
1695 -stack-list-frames [ LOW-FRAME HIGH-FRAME ]
1697 List the frames currently on the stack. For each frame it displays
1701 The frame number, 0 being the topmost frame, i.e. the innermost
1705 The `$pc' value for that frame.
1711 File name of the source file where the function lives.
1714 Line number corresponding to the `$pc'.
1716 If invoked without arguments, this command prints a backtrace for the
1717 whole stack. If given two integer arguments, it shows the frames whose
1718 levels are between the two arguments (inclusive). If the two arguments
1719 are equal, it shows the single frame at the corresponding level.
1724 The corresponding GDB commands are `backtrace' and `where'.
1729 Full stack backtrace:
1734 [frame={level="0",addr="0x0001076c",func="foo",
1735 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11"},
1736 frame={level="1",addr="0x000107a4",func="foo",
1737 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1738 frame={level="2",addr="0x000107a4",func="foo",
1739 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1740 frame={level="3",addr="0x000107a4",func="foo",
1741 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1742 frame={level="4",addr="0x000107a4",func="foo",
1743 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1744 frame={level="5",addr="0x000107a4",func="foo",
1745 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1746 frame={level="6",addr="0x000107a4",func="foo",
1747 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1748 frame={level="7",addr="0x000107a4",func="foo",
1749 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1750 frame={level="8",addr="0x000107a4",func="foo",
1751 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1752 frame={level="9",addr="0x000107a4",func="foo",
1753 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1754 frame={level="10",addr="0x000107a4",func="foo",
1755 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1756 frame={level="11",addr="0x00010738",func="main",
1757 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4"}]
1760 Show frames between LOW_FRAME and HIGH_FRAME:
1763 -stack-list-frames 3 5
1765 [frame={level="3",addr="0x000107a4",func="foo",
1766 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1767 frame={level="4",addr="0x000107a4",func="foo",
1768 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"},
1769 frame={level="5",addr="0x000107a4",func="foo",
1770 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
1773 Show a single frame:
1776 -stack-list-frames 3 3
1778 [frame={level="3",addr="0x000107a4",func="foo",
1779 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}]
1782 The `-stack-list-locals' Command
1783 --------------------------------
1788 -stack-list-locals PRINT-VALUES
1790 Display the local variable names for the selected frame. If
1791 PRINT-VALUES is 0 or `--no-values', print only the names of the
1792 variables; if it is 1 or `--all-values', print also their values; and
1793 if it is 2 or `--simple-values', print the name, type and value for
1794 simple data types and the name and type for arrays, structures and
1795 unions. In this last case, a frontend can immediately display the
1796 value of simple data types and create variable objects for other data
1797 types when the the user wishes to explore their values in more detail.
1802 `info locals' in GDB, `gdb_get_locals' in `gdbtk'.
1808 -stack-list-locals 0
1809 ^done,locals=[name="A",name="B",name="C"]
1811 -stack-list-locals --all-values
1812 ^done,locals=[{name="A",value="1"},{name="B",value="2"},
1813 {name="C",value="{1, 2, 3}"}]
1814 -stack-list-locals --simple-values
1815 ^done,locals=[{name="A",type="int",value="1"},
1816 {name="B",type="int",value="2"},{name="C",type="int [3]"}]
1819 The `-stack-select-frame' Command
1820 ---------------------------------
1825 -stack-select-frame FRAMENUM
1827 Change the selected frame. Select a different frame FRAMENUM on the
1833 The corresponding GDB commands are `frame', `up', `down',
1834 `select-frame', `up-silent', and `down-silent'.
1840 -stack-select-frame 2
1845 File: gdb.info, Node: GDB/MI Symbol Query, Next: GDB/MI Target Manipulation, Prev: GDB/MI Stack Manipulation, Up: GDB/MI
1847 24.10 GDB/MI Symbol Query Commands
1848 ==================================
1850 The `-symbol-info-address' Command
1851 ----------------------------------
1856 -symbol-info-address SYMBOL
1858 Describe where SYMBOL is stored.
1863 The corresponding GDB command is `info address'.
1870 The `-symbol-info-file' Command
1871 -------------------------------
1878 Show the file for the symbol.
1883 There's no equivalent GDB command. `gdbtk' has `gdb_find_file'.
1890 The `-symbol-info-function' Command
1891 -----------------------------------
1896 -symbol-info-function
1898 Show which function the symbol lives in.
1903 `gdb_get_function' in `gdbtk'.
1910 The `-symbol-info-line' Command
1911 -------------------------------
1918 Show the core addresses of the code for a source line.
1923 The corresponding GDB command is `info line'. `gdbtk' has the
1924 `gdb_get_line' and `gdb_get_file' commands.
1931 The `-symbol-info-symbol' Command
1932 ---------------------------------
1937 -symbol-info-symbol ADDR
1939 Describe what symbol is at location ADDR.
1944 The corresponding GDB command is `info symbol'.
1951 The `-symbol-list-functions' Command
1952 ------------------------------------
1957 -symbol-list-functions
1959 List the functions in the executable.
1964 `info functions' in GDB, `gdb_listfunc' and `gdb_search' in `gdbtk'.
1971 The `-symbol-list-lines' Command
1972 --------------------------------
1977 -symbol-list-lines FILENAME
1979 Print the list of lines that contain code and their associated
1980 program addresses for the given source filename. The entries are
1981 sorted in ascending PC order.
1986 There is no corresponding GDB command.
1992 -symbol-list-lines basics.c
1993 ^done,lines=[{pc="0x08048554",line="7"},{pc="0x0804855a",line="8"}]
1996 The `-symbol-list-types' Command
1997 --------------------------------
2004 List all the type names.
2009 The corresponding commands are `info types' in GDB, `gdb_search' in
2017 The `-symbol-list-variables' Command
2018 ------------------------------------
2023 -symbol-list-variables
2025 List all the global and static variable names.
2030 `info variables' in GDB, `gdb_search' in `gdbtk'.
2037 The `-symbol-locate' Command
2038 ----------------------------
2048 `gdb_loc' in `gdbtk'.
2055 The `-symbol-type' Command
2056 --------------------------
2061 -symbol-type VARIABLE
2063 Show type of VARIABLE.
2068 The corresponding GDB command is `ptype', `gdbtk' has
2077 File: gdb.info, Node: GDB/MI Target Manipulation, Next: GDB/MI Thread Commands, Prev: GDB/MI Symbol Query, Up: GDB/MI
2079 24.11 GDB/MI Target Manipulation Commands
2080 =========================================
2082 The `-target-attach' Command
2083 ----------------------------
2088 -target-attach PID | FILE
2090 Attach to a process PID or a file FILE outside of GDB.
2095 The corresponding GDB command is `attach'.
2102 The `-target-compare-sections' Command
2103 --------------------------------------
2108 -target-compare-sections [ SECTION ]
2110 Compare data of section SECTION on target to the exec file. Without
2111 the argument, all sections are compared.
2116 The GDB equivalent is `compare-sections'.
2123 The `-target-detach' Command
2124 ----------------------------
2131 Disconnect from the remote target. There's no output.
2136 The corresponding GDB command is `detach'.
2146 The `-target-disconnect' Command
2147 --------------------------------
2154 Disconnect from the remote target. There's no output.
2159 The corresponding GDB command is `disconnect'.
2169 The `-target-download' Command
2170 ------------------------------
2177 Loads the executable onto the remote target. It prints out an
2178 update message every half second, which includes the fields:
2181 The name of the section.
2184 The size of what has been sent so far for that section.
2187 The size of the section.
2190 The total size of what was sent so far (the current and the
2194 The size of the overall executable to download.
2196 Each message is sent as status record (*note GDB/MI Output Syntax:
2197 GDB/MI Output Syntax.).
2199 In addition, it prints the name and size of the sections, as they are
2200 downloaded. These messages include the following fields:
2203 The name of the section.
2206 The size of the section.
2209 The size of the overall executable to download.
2211 At the end, a summary is printed.
2216 The corresponding GDB command is `load'.
2221 Note: each status message appears on a single line. Here the messages
2222 have been broken down so that they can fit onto a page.
2226 +download,{section=".text",section-size="6668",total-size="9880"}
2227 +download,{section=".text",section-sent="512",section-size="6668",
2228 total-sent="512",total-size="9880"}
2229 +download,{section=".text",section-sent="1024",section-size="6668",
2230 total-sent="1024",total-size="9880"}
2231 +download,{section=".text",section-sent="1536",section-size="6668",
2232 total-sent="1536",total-size="9880"}
2233 +download,{section=".text",section-sent="2048",section-size="6668",
2234 total-sent="2048",total-size="9880"}
2235 +download,{section=".text",section-sent="2560",section-size="6668",
2236 total-sent="2560",total-size="9880"}
2237 +download,{section=".text",section-sent="3072",section-size="6668",
2238 total-sent="3072",total-size="9880"}
2239 +download,{section=".text",section-sent="3584",section-size="6668",
2240 total-sent="3584",total-size="9880"}
2241 +download,{section=".text",section-sent="4096",section-size="6668",
2242 total-sent="4096",total-size="9880"}
2243 +download,{section=".text",section-sent="4608",section-size="6668",
2244 total-sent="4608",total-size="9880"}
2245 +download,{section=".text",section-sent="5120",section-size="6668",
2246 total-sent="5120",total-size="9880"}
2247 +download,{section=".text",section-sent="5632",section-size="6668",
2248 total-sent="5632",total-size="9880"}
2249 +download,{section=".text",section-sent="6144",section-size="6668",
2250 total-sent="6144",total-size="9880"}
2251 +download,{section=".text",section-sent="6656",section-size="6668",
2252 total-sent="6656",total-size="9880"}
2253 +download,{section=".init",section-size="28",total-size="9880"}
2254 +download,{section=".fini",section-size="28",total-size="9880"}
2255 +download,{section=".data",section-size="3156",total-size="9880"}
2256 +download,{section=".data",section-sent="512",section-size="3156",
2257 total-sent="7236",total-size="9880"}
2258 +download,{section=".data",section-sent="1024",section-size="3156",
2259 total-sent="7748",total-size="9880"}
2260 +download,{section=".data",section-sent="1536",section-size="3156",
2261 total-sent="8260",total-size="9880"}
2262 +download,{section=".data",section-sent="2048",section-size="3156",
2263 total-sent="8772",total-size="9880"}
2264 +download,{section=".data",section-sent="2560",section-size="3156",
2265 total-sent="9284",total-size="9880"}
2266 +download,{section=".data",section-sent="3072",section-size="3156",
2267 total-sent="9796",total-size="9880"}
2268 ^done,address="0x10004",load-size="9880",transfer-rate="6586",
2272 The `-target-exec-status' Command
2273 ---------------------------------
2280 Provide information on the state of the target (whether it is
2281 running or not, for instance).
2286 There's no equivalent GDB command.
2293 The `-target-list-available-targets' Command
2294 --------------------------------------------
2299 -target-list-available-targets
2301 List the possible targets to connect to.
2306 The corresponding GDB command is `help target'.
2313 The `-target-list-current-targets' Command
2314 ------------------------------------------
2319 -target-list-current-targets
2321 Describe the current target.
2326 The corresponding information is printed by `info file' (among other
2334 The `-target-list-parameters' Command
2335 -------------------------------------
2340 -target-list-parameters
2352 The `-target-select' Command
2353 ----------------------------
2358 -target-select TYPE PARAMETERS ...
2360 Connect GDB to the remote target. This command takes two args:
2363 The type of target, for instance `async', `remote', etc.
2366 Device names, host names and the like. *Note Commands for
2367 managing targets: Target Commands, for more details.
2369 The output is a connection notification, followed by the address at
2370 which the target program is, in the following form:
2372 ^connected,addr="ADDRESS",func="FUNCTION NAME",
2378 The corresponding GDB command is `target'.
2384 -target-select async /dev/ttya
2385 ^connected,addr="0xfe00a300",func="??",args=[]
2389 File: gdb.info, Node: GDB/MI Thread Commands, Next: GDB/MI Tracepoint Commands, Prev: GDB/MI Target Manipulation, Up: GDB/MI
2391 24.12 GDB/MI Thread Commands
2392 ============================
2394 The `-thread-info' Command
2395 --------------------------
2412 The `-thread-list-all-threads' Command
2413 --------------------------------------
2418 -thread-list-all-threads
2423 The equivalent GDB command is `info threads'.
2430 The `-thread-list-ids' Command
2431 ------------------------------
2438 Produces a list of the currently known GDB thread ids. At the end
2439 of the list it also prints the total number of such threads.
2444 Part of `info threads' supplies the same information.
2449 No threads present, besides the main process:
2453 ^done,thread-ids={},number-of-threads="0"
2460 ^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"},
2461 number-of-threads="3"
2464 The `-thread-select' Command
2465 ----------------------------
2470 -thread-select THREADNUM
2472 Make THREADNUM the current thread. It prints the number of the new
2473 current thread, and the topmost frame for that thread.
2478 The corresponding GDB command is `thread'.
2487 *stopped,reason="end-stepping-range",thread-id="2",line="187",
2488 file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
2492 thread-ids={thread-id="3",thread-id="2",thread-id="1"},
2493 number-of-threads="3"
2496 ^done,new-thread-id="3",
2497 frame={level="0",func="vprintf",
2498 args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""},
2499 {name="arg",value="0x2"}],file="vprintf.c",line="31"}
2503 File: gdb.info, Node: GDB/MI Tracepoint Commands, Next: GDB/MI Variable Objects, Prev: GDB/MI Thread Commands, Up: GDB/MI
2505 24.13 GDB/MI Tracepoint Commands
2506 ================================
2508 The tracepoint commands are not yet implemented.
2511 File: gdb.info, Node: GDB/MI Variable Objects, Prev: GDB/MI Tracepoint Commands, Up: GDB/MI
2513 24.14 GDB/MI Variable Objects
2514 =============================
2516 Motivation for Variable Objects in GDB/MI
2517 -----------------------------------------
2519 For the implementation of a variable debugger window (locals, watched
2520 expressions, etc.), we are proposing the adaptation of the existing code
2523 The two main reasons for that are:
2525 1. It has been proven in practice (it is already on its second
2528 2. It will shorten development time (needless to say how important it
2531 The original interface was designed to be used by Tcl code, so it was
2532 slightly changed so it could be used through GDB/MI. This section
2533 describes the GDB/MI operations that will be available and gives some
2534 hints about their use.
2536 _Note_: In addition to the set of operations described here, we
2537 expect the GUI implementation of a variable window to require, at
2538 least, the following operations:
2540 * `-gdb-show' `output-radix'
2542 * `-stack-list-arguments'
2544 * `-stack-list-locals'
2546 * `-stack-select-frame'
2548 Introduction to Variable Objects in GDB/MI
2549 ------------------------------------------
2551 The basic idea behind variable objects is the creation of a named object
2552 to represent a variable, an expression, a memory location or even a CPU
2553 register. For each object created, a set of operations is available for
2554 examining or changing its properties.
2556 Furthermore, complex data types, such as C structures, are
2557 represented in a tree format. For instance, the `struct' type variable
2558 is the root and the children will represent the struct members. If a
2559 child is itself of a complex type, it will also have children of its
2560 own. Appropriate language differences are handled for C, C++ and Java.
2562 When returning the actual values of the objects, this facility allows
2563 for the individual selection of the display format used in the result
2564 creation. It can be chosen among: binary, decimal, hexadecimal, octal
2565 and natural. Natural refers to a default format automatically chosen
2566 based on the variable type (like decimal for an `int', hex for
2569 The following is the complete set of GDB/MI operations defined to
2570 access this functionality:
2572 *Operation* *Description*
2573 `-var-create' create a variable object
2574 `-var-delete' delete the variable object and its children
2575 `-var-set-format' set the display format of this variable
2576 `-var-show-format' show the display format of this variable
2577 `-var-info-num-children' tells how many children this object has
2578 `-var-list-children' return a list of the object's children
2579 `-var-info-type' show the type of this variable object
2580 `-var-info-expression' print what this variable object represents
2581 `-var-show-attributes' is this variable editable? does it exist
2583 `-var-evaluate-expression' get the value of this variable
2584 `-var-assign' set the value of this variable
2585 `-var-update' update the variable and its children
2587 In the next subsection we describe each operation in detail and
2588 suggest how it can be used.
2590 Description And Use of Operations on Variable Objects
2591 -----------------------------------------------------
2593 The `-var-create' Command
2594 -------------------------
2599 -var-create {NAME | "-"}
2600 {FRAME-ADDR | "*"} EXPRESSION
2602 This operation creates a variable object, which allows the
2603 monitoring of a variable, the result of an expression, a memory cell or
2606 The NAME parameter is the string by which the object can be
2607 referenced. It must be unique. If `-' is specified, the varobj system
2608 will generate a string "varNNNNNN" automatically. It will be unique
2609 provided that one does not specify NAME on that format. The command
2610 fails if a duplicate name is found.
2612 The frame under which the expression should be evaluated can be
2613 specified by FRAME-ADDR. A `*' indicates that the current frame should
2616 EXPRESSION is any expression valid on the current language set (must
2617 not begin with a `*'), or one of the following:
2619 * `*ADDR', where ADDR is the address of a memory cell
2621 * `*ADDR-ADDR' -- a memory address range (TBD)
2623 * `$REGNAME' -- a CPU register name
2628 This operation returns the name, number of children and the type of the
2629 object created. Type is returned as a string as the ones generated by
2632 name="NAME",numchild="N",type="TYPE"
2634 The `-var-delete' Command
2635 -------------------------
2642 Deletes a previously created variable object and all of its children.
2644 Returns an error if the object NAME is not found.
2646 The `-var-set-format' Command
2647 -----------------------------
2652 -var-set-format NAME FORMAT-SPEC
2654 Sets the output format for the value of the object NAME to be
2657 The syntax for the FORMAT-SPEC is as follows:
2660 {binary | decimal | hexadecimal | octal | natural}
2662 The `-var-show-format' Command
2663 ------------------------------
2668 -var-show-format NAME
2670 Returns the format used to display the value of the object NAME.
2675 The `-var-info-num-children' Command
2676 ------------------------------------
2681 -var-info-num-children NAME
2683 Returns the number of children of a variable object NAME:
2687 The `-var-list-children' Command
2688 --------------------------------
2693 -var-list-children [PRINT-VALUES] NAME
2695 Return a list of the children of the specified variable object and
2696 create variable objects for them, if they do not already exist. With a
2697 single argument or if PRINT-VALUES has a value for of 0 or
2698 `--no-values', print only the names of the variables; if PRINT-VALUES
2699 is 1 or `--all-values', also print their values; and if it is 2 or
2700 `--simple-values' print the name and value for simple data types and
2701 just the name for arrays, structures and unions.
2707 -var-list-children n
2708 ^done,numchild=N,children=[{name=NAME,
2709 numchild=N,type=TYPE},(repeats N times)]
2711 -var-list-children --all-values n
2712 ^done,numchild=N,children=[{name=NAME,
2713 numchild=N,value=VALUE,type=TYPE},(repeats N times)]
2715 The `-var-info-type' Command
2716 ----------------------------
2723 Returns the type of the specified variable NAME. The type is
2724 returned as a string in the same format as it is output by the GDB CLI:
2728 The `-var-info-expression' Command
2729 ----------------------------------
2734 -var-info-expression NAME
2736 Returns what is represented by the variable object NAME:
2738 lang=LANG-SPEC,exp=EXPRESSION
2740 where LANG-SPEC is `{"C" | "C++" | "Java"}'.
2742 The `-var-show-attributes' Command
2743 ----------------------------------
2748 -var-show-attributes NAME
2750 List attributes of the specified variable object NAME:
2752 status=ATTR [ ( ,ATTR )* ]
2754 where ATTR is `{ { editable | noneditable } | TBD }'.
2756 The `-var-evaluate-expression' Command
2757 --------------------------------------
2762 -var-evaluate-expression NAME
2764 Evaluates the expression that is represented by the specified
2765 variable object and returns its value as a string in the current format
2766 specified for the object:
2770 Note that one must invoke `-var-list-children' for a variable before
2771 the value of a child variable can be evaluated.
2773 The `-var-assign' Command
2774 -------------------------
2779 -var-assign NAME EXPRESSION
2781 Assigns the value of EXPRESSION to the variable object specified by
2782 NAME. The object must be `editable'. If the variable's value is
2783 altered by the assign, the variable will show up in any subsequent
2794 ^done,changelist=[{name="var1",in_scope="true",type_changed="false"}]
2797 The `-var-update' Command
2798 -------------------------
2803 -var-update [PRINT-VALUES] {NAME | "*"}
2805 Update the value of the variable object NAME by evaluating its
2806 expression after fetching all the new values from memory or registers.
2807 A `*' causes all existing variable objects to be updated. The option
2808 PRINT-VALUES determines whether names both and values, or just names
2809 are printed in the manner described for `-var-list-children' (*note
2810 -var-list-children::).
2819 -var-update --all-values var1
2820 ^done,changelist=[{name="var1",value="3",in_scope="true",
2821 type_changed="false"}]
2825 File: gdb.info, Node: Annotations, Next: GDB/MI, Prev: Emacs, Up: Top
2830 This chapter describes annotations in GDB. Annotations were designed
2831 to interface GDB to graphical user interfaces or other similar programs
2832 which want to interact with GDB at a relatively high level.
2834 The annotation mechanism has largely been superseeded by GDB/MI
2839 * Annotations Overview:: What annotations are; the general syntax.
2840 * Prompting:: Annotations marking GDB's need for input.
2841 * Errors:: Annotations for error messages.
2842 * Invalidation:: Some annotations describe things now invalid.
2843 * Annotations for Running::
2844 Whether the program is running, how it stopped, etc.
2845 * Source Annotations:: Annotations describing source code.
2848 File: gdb.info, Node: Annotations Overview, Next: Prompting, Up: Annotations
2850 25.1 What is an Annotation?
2851 ===========================
2853 Annotations start with a newline character, two `control-z' characters,
2854 and the name of the annotation. If there is no additional information
2855 associated with this annotation, the name of the annotation is followed
2856 immediately by a newline. If there is additional information, the name
2857 of the annotation is followed by a space, the additional information,
2858 and a newline. The additional information cannot contain newline
2861 Any output not beginning with a newline and two `control-z'
2862 characters denotes literal output from GDB. Currently there is no need
2863 for GDB to output a newline followed by two `control-z' characters, but
2864 if there was such a need, the annotations could be extended with an
2865 `escape' annotation which means those three characters as output.
2867 The annotation LEVEL, which is specified using the `--annotate'
2868 command line option (*note Mode Options::), controls how much
2869 information GDB prints together with its prompt, values of expressions,
2870 source lines, and other types of output. Level 0 is for no anntations,
2871 level 1 is for use when GDB is run as a subprocess of GNU Emacs, level
2872 3 is the maximum annotation suitable for programs that control GDB, and
2873 level 2 annotations have been made obsolete (*note Limitations of the
2874 Annotation Interface: (annotate)Limitations.).
2876 `set annotate LEVEL'
2877 The GDB command `set annotate' sets the level of annotations to
2878 the specified LEVEL.
2881 Show the current annotation level.
2883 This chapter describes level 3 annotations.
2885 A simple example of starting up GDB with annotations is:
2889 Copyright 2003 Free Software Foundation, Inc.
2890 GDB is free software, covered by the GNU General Public License,
2891 and you are welcome to change it and/or distribute copies of it
2892 under certain conditions.
2893 Type "show copying" to see the conditions.
2894 There is absolutely no warranty for GDB. Type "show warranty"
2896 This GDB was configured as "i386-pc-linux-gnu"
2906 Here `quit' is input to GDB; the rest is output from GDB. The three
2907 lines beginning `^Z^Z' (where `^Z' denotes a `control-z' character) are
2908 annotations; the rest is output from GDB.
2911 File: gdb.info, Node: Prompting, Next: Errors, Prev: Annotations Overview, Up: Annotations
2913 25.2 Annotation for GDB Input
2914 =============================
2916 When GDB prompts for input, it annotates this fact so it is possible to
2917 know when to send output, when the output from a given command is over,
2920 Different kinds of input each have a different "input type". Each
2921 input type has three annotations: a `pre-' annotation, which denotes
2922 the beginning of any prompt which is being output, a plain annotation,
2923 which denotes the end of the prompt, and then a `post-' annotation
2924 which denotes the end of any echo which may (or may not) be associated
2925 with the input. For example, the `prompt' input type features the
2926 following annotations:
2935 When GDB is prompting for a command (the main GDB prompt).
2938 When GDB prompts for a set of commands, like in the `commands'
2939 command. The annotations are repeated for each command which is
2943 When GDB wants the user to select between various overloaded
2947 When GDB wants the user to confirm a potentially dangerous
2950 `prompt-for-continue'
2951 When GDB is asking the user to press return to continue. Note:
2952 Don't expect this to work well; instead use `set height 0' to
2953 disable prompting. This is because the counting of lines is buggy
2954 in the presence of annotations.
2957 File: gdb.info, Node: Errors, Next: Invalidation, Prev: Prompting, Up: Annotations
2964 This annotation occurs right before GDB responds to an interrupt.
2968 This annotation occurs right before GDB responds to an error.
2970 Quit and error annotations indicate that any annotations which GDB
2971 was in the middle of may end abruptly. For example, if a
2972 `value-history-begin' annotation is followed by a `error', one cannot
2973 expect to receive the matching `value-history-end'. One cannot expect
2974 not to receive it either, however; an error annotation does not
2975 necessarily mean that GDB is immediately returning all the way to the
2978 A quit or error annotation may be preceded by
2982 Any output between that and the quit or error annotation is the error
2985 Warning messages are not yet annotated.
2988 File: gdb.info, Node: Invalidation, Next: Annotations for Running, Prev: Errors, Up: Annotations
2990 25.4 Invalidation Notices
2991 =========================
2993 The following annotations say that certain pieces of state may have
2996 `^Z^Zframes-invalid'
2997 The frames (for example, output from the `backtrace' command) may
3000 `^Z^Zbreakpoints-invalid'
3001 The breakpoints may have changed. For example, the user just
3002 added or deleted a breakpoint.
3005 File: gdb.info, Node: Annotations for Running, Next: Source Annotations, Prev: Invalidation, Up: Annotations
3007 25.5 Running the Program
3008 ========================
3010 When the program starts executing due to a GDB command such as `step'
3015 is output. When the program stops,
3019 is output. Before the `stopped' annotation, a variety of
3020 annotations describe how the program stopped.
3022 `^Z^Zexited EXIT-STATUS'
3023 The program exited, and EXIT-STATUS is the exit status (zero for
3024 successful exit, otherwise nonzero).
3027 The program exited with a signal. After the `^Z^Zsignalled', the
3028 annotation continues:
3037 ^Z^Zsignal-string-end
3040 where NAME is the name of the signal, such as `SIGILL' or
3041 `SIGSEGV', and STRING is the explanation of the signal, such as
3042 `Illegal Instruction' or `Segmentation fault'. INTRO-TEXT,
3043 MIDDLE-TEXT, and END-TEXT are for the user's benefit and have no
3047 The syntax of this annotation is just like `signalled', but GDB is
3048 just saying that the program received the signal, not that it was
3051 `^Z^Zbreakpoint NUMBER'
3052 The program hit breakpoint number NUMBER.
3054 `^Z^Zwatchpoint NUMBER'
3055 The program hit watchpoint number NUMBER.
3058 File: gdb.info, Node: Source Annotations, Prev: Annotations for Running, Up: Annotations
3060 25.6 Displaying Source
3061 ======================
3063 The following annotation is used instead of displaying source code:
3065 ^Z^Zsource FILENAME:LINE:CHARACTER:MIDDLE:ADDR
3067 where FILENAME is an absolute file name indicating which source
3068 file, LINE is the line number within that file (where 1 is the first
3069 line in the file), CHARACTER is the character position within the file
3070 (where 0 is the first character in the file) (for most debug formats
3071 this will necessarily point to the beginning of a line), MIDDLE is
3072 `middle' if ADDR is in the middle of the line, or `beg' if ADDR is at
3073 the beginning of the line, and ADDR is the address in the target
3074 program associated with the source which is being displayed. ADDR is
3075 in the form `0x' followed by one or more lowercase hex digits (note
3076 that this does not depend on the language).
3079 File: gdb.info, Node: GDB Bugs, Next: Formatting Documentation, Prev: GDB/MI, Up: Top
3081 26 Reporting Bugs in GDB
3082 ************************
3084 Your bug reports play an essential role in making GDB reliable.
3086 Reporting a bug may help you by bringing a solution to your problem,
3087 or it may not. But in any case the principal function of a bug report
3088 is to help the entire community by making the next version of GDB work
3089 better. Bug reports are your contribution to the maintenance of GDB.
3091 In order for a bug report to serve its purpose, you must include the
3092 information that enables us to fix the bug.
3096 * Bug Criteria:: Have you found a bug?
3097 * Bug Reporting:: How to report bugs
3100 File: gdb.info, Node: Bug Criteria, Next: Bug Reporting, Up: GDB Bugs
3102 26.1 Have you found a bug?
3103 ==========================
3105 If you are not sure whether you have found a bug, here are some
3108 * If the debugger gets a fatal signal, for any input whatever, that
3109 is a GDB bug. Reliable debuggers never crash.
3111 * If GDB produces an error message for valid input, that is a bug.
3112 (Note that if you're cross debugging, the problem may also be
3113 somewhere in the connection to the target.)
3115 * If GDB does not produce an error message for invalid input, that
3116 is a bug. However, you should note that your idea of "invalid
3117 input" might be our idea of "an extension" or "support for
3118 traditional practice".
3120 * If you are an experienced user of debugging tools, your suggestions
3121 for improvement of GDB are welcome in any case.
3124 File: gdb.info, Node: Bug Reporting, Prev: Bug Criteria, Up: GDB Bugs
3126 26.2 How to report bugs
3127 =======================
3129 A number of companies and individuals offer support for GNU products.
3130 If you obtained GDB from a support organization, we recommend you
3131 contact that organization first.
3133 You can find contact information for many support companies and
3134 individuals in the file `etc/SERVICE' in the GNU Emacs distribution.
3136 In any event, we also recommend that you submit bug reports for GDB.
3137 The prefered method is to submit them directly using GDB's Bugs web
3138 page (http://www.gnu.org/software/gdb/bugs/). Alternatively, the
3139 e-mail gateway <bug-gdb@gnu.org> can be used.
3141 *Do not send bug reports to `info-gdb', or to `help-gdb', or to any
3142 newsgroups.* Most users of GDB do not want to receive bug reports.
3143 Those that do have arranged to receive `bug-gdb'.
3145 The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which
3146 serves as a repeater. The mailing list and the newsgroup carry exactly
3147 the same messages. Often people think of posting bug reports to the
3148 newsgroup instead of mailing them. This appears to work, but it has one
3149 problem which can be crucial: a newsgroup posting often lacks a mail
3150 path back to the sender. Thus, if we need to ask for more information,
3151 we may be unable to reach you. For this reason, it is better to send
3152 bug reports to the mailing list.
3154 The fundamental principle of reporting bugs usefully is this:
3155 *report all the facts*. If you are not sure whether to state a fact or
3156 leave it out, state it!
3158 Often people omit facts because they think they know what causes the
3159 problem and assume that some details do not matter. Thus, you might
3160 assume that the name of the variable you use in an example does not
3161 matter. Well, probably it does not, but one cannot be sure. Perhaps
3162 the bug is a stray memory reference which happens to fetch from the
3163 location where that name is stored in memory; perhaps, if the name were
3164 different, the contents of that location would fool the debugger into
3165 doing the right thing despite the bug. Play it safe and give a
3166 specific, complete example. That is the easiest thing for you to do,
3167 and the most helpful.
3169 Keep in mind that the purpose of a bug report is to enable us to fix
3170 the bug. It may be that the bug has been reported previously, but
3171 neither you nor we can know that unless your bug report is complete and
3174 Sometimes people give a few sketchy facts and ask, "Does this ring a
3175 bell?" Those bug reports are useless, and we urge everyone to _refuse
3176 to respond to them_ except to chide the sender to report bugs properly.
3178 To enable us to fix the bug, you should include all these things:
3180 * The version of GDB. GDB announces it if you start with no
3181 arguments; you can also print it at any time using `show version'.
3183 Without this, we will not know whether there is any point in
3184 looking for the bug in the current version of GDB.
3186 * The type of machine you are using, and the operating system name
3189 * What compiler (and its version) was used to compile GDB--e.g.
3192 * What compiler (and its version) was used to compile the program
3193 you are debugging--e.g. "gcc-2.8.1", or "HP92453-01 A.10.32.03 HP
3194 C Compiler". For GCC, you can say `gcc --version' to get this
3195 information; for other compilers, see the documentation for those
3198 * The command arguments you gave the compiler to compile your
3199 example and observe the bug. For example, did you use `-O'? To
3200 guarantee you will not omit something important, list them all. A
3201 copy of the Makefile (or the output from make) is sufficient.
3203 If we were to try to guess the arguments, we would probably guess
3204 wrong and then we might not encounter the bug.
3206 * A complete input script, and all necessary source files, that will
3209 * A description of what behavior you observe that you believe is
3210 incorrect. For example, "It gets a fatal signal."
3212 Of course, if the bug is that GDB gets a fatal signal, then we
3213 will certainly notice it. But if the bug is incorrect output, we
3214 might not notice unless it is glaringly wrong. You might as well
3215 not give us a chance to make a mistake.
3217 Even if the problem you experience is a fatal signal, you should
3218 still say so explicitly. Suppose something strange is going on,
3219 such as, your copy of GDB is out of synch, or you have encountered
3220 a bug in the C library on your system. (This has happened!) Your
3221 copy might crash and ours would not. If you told us to expect a
3222 crash, then when ours fails to crash, we would know that the bug
3223 was not happening for us. If you had not told us to expect a
3224 crash, then we would not be able to draw any conclusion from our
3227 To collect all this information, you can use a session recording
3228 program such as `script', which is available on many Unix systems.
3229 Just run your GDB session inside `script' and then include the
3230 `typescript' file with your bug report.
3232 Another way to record a GDB session is to run GDB inside Emacs and
3233 then save the entire buffer to a file.
3235 * If you wish to suggest changes to the GDB source, send us context
3236 diffs. If you even discuss something in the GDB source, refer to
3237 it by context, not by line number.
3239 The line numbers in our development sources will not match those
3240 in your sources. Your line numbers would convey no useful
3244 Here are some things that are not necessary:
3246 * A description of the envelope of the bug.
3248 Often people who encounter a bug spend a lot of time investigating
3249 which changes to the input file will make the bug go away and which
3250 changes will not affect it.
3252 This is often time consuming and not very useful, because the way
3253 we will find the bug is by running a single example under the
3254 debugger with breakpoints, not by pure deduction from a series of
3255 examples. We recommend that you save your time for something else.
3257 Of course, if you can find a simpler example to report _instead_
3258 of the original one, that is a convenience for us. Errors in the
3259 output will be easier to spot, running under the debugger will take
3260 less time, and so on.
3262 However, simplification is not vital; if you do not want to do
3263 this, report the bug anyway and send us the entire test case you
3266 * A patch for the bug.
3268 A patch for the bug does help us if it is a good one. But do not
3269 omit the necessary information, such as the test case, on the
3270 assumption that a patch is all we need. We might see problems
3271 with your patch and decide to fix the problem another way, or we
3272 might not understand it at all.
3274 Sometimes with a program as complicated as GDB it is very hard to
3275 construct an example that will make the program follow a certain
3276 path through the code. If you do not send us the example, we will
3277 not be able to construct one, so we will not be able to verify
3278 that the bug is fixed.
3280 And if we cannot understand what bug you are trying to fix, or why
3281 your patch should be an improvement, we will not install it. A
3282 test case will help us to understand.
3284 * A guess about what the bug is or what it depends on.
3286 Such guesses are usually wrong. Even we cannot guess right about
3287 such things without first using the debugger to find the facts.
3290 File: gdb.info, Node: Command Line Editing, Next: Using History Interactively, Prev: Formatting Documentation, Up: Top
3292 27 Command Line Editing
3293 ***********************
3295 This chapter describes the basic features of the GNU command line
3300 * Introduction and Notation:: Notation used in this text.
3301 * Readline Interaction:: The minimum set of commands for editing a line.
3302 * Readline Init File:: Customizing Readline from a user's view.
3303 * Bindable Readline Commands:: A description of most of the Readline commands
3304 available for binding
3305 * Readline vi Mode:: A short description of how to make Readline
3306 behave like the vi editor.
3309 File: gdb.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing
3311 27.1 Introduction to Line Editing
3312 =================================
3314 The following paragraphs describe the notation used to represent
3317 The text `C-k' is read as `Control-K' and describes the character
3318 produced when the <k> key is pressed while the Control key is depressed.
3320 The text `M-k' is read as `Meta-K' and describes the character
3321 produced when the Meta key (if you have one) is depressed, and the <k>
3322 key is pressed. The Meta key is labeled <ALT> on many keyboards. On
3323 keyboards with two keys labeled <ALT> (usually to either side of the
3324 space bar), the <ALT> on the left side is generally set to work as a
3325 Meta key. The <ALT> key on the right may also be configured to work as
3326 a Meta key or may be configured as some other modifier, such as a
3327 Compose key for typing accented characters.
3329 If you do not have a Meta or <ALT> key, or another key working as a
3330 Meta key, the identical keystroke can be generated by typing <ESC>
3331 _first_, and then typing <k>. Either process is known as "metafying"
3334 The text `M-C-k' is read as `Meta-Control-k' and describes the
3335 character produced by "metafying" `C-k'.
3337 In addition, several keys have their own names. Specifically,
3338 <DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves
3339 when seen in this text, or in an init file (*note Readline Init File::).
3340 If your keyboard lacks a <LFD> key, typing <C-j> will produce the
3341 desired character. The <RET> key may be labeled <Return> or <Enter> on
3345 File: gdb.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
3347 27.2 Readline Interaction
3348 =========================
3350 Often during an interactive session you type in a long line of text,
3351 only to notice that the first word on the line is misspelled. The
3352 Readline library gives you a set of commands for manipulating the text
3353 as you type it in, allowing you to just fix your typo, and not forcing
3354 you to retype the majority of the line. Using these editing commands,
3355 you move the cursor to the place that needs correction, and delete or
3356 insert the text of the corrections. Then, when you are satisfied with
3357 the line, you simply press <RET>. You do not have to be at the end of
3358 the line to press <RET>; the entire line is accepted regardless of the
3359 location of the cursor within the line.
3363 * Readline Bare Essentials:: The least you need to know about Readline.
3364 * Readline Movement Commands:: Moving about the input line.
3365 * Readline Killing Commands:: How to delete text, and how to get it back!
3366 * Readline Arguments:: Giving numeric arguments to commands.
3367 * Searching:: Searching through previous lines.
3370 File: gdb.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction
3372 27.2.1 Readline Bare Essentials
3373 -------------------------------
3375 In order to enter characters into the line, simply type them. The typed
3376 character appears where the cursor was, and then the cursor moves one
3377 space to the right. If you mistype a character, you can use your erase
3378 character to back up and delete the mistyped character.
3380 Sometimes you may mistype a character, and not notice the error
3381 until you have typed several other characters. In that case, you can
3382 type `C-b' to move the cursor to the left, and then correct your
3383 mistake. Afterwards, you can move the cursor to the right with `C-f'.
3385 When you add text in the middle of a line, you will notice that
3386 characters to the right of the cursor are `pushed over' to make room
3387 for the text that you have inserted. Likewise, when you delete text
3388 behind the cursor, characters to the right of the cursor are `pulled
3389 back' to fill in the blank space created by the removal of the text. A
3390 list of the bare essentials for editing the text of an input line
3394 Move back one character.
3397 Move forward one character.
3399 <DEL> or <Backspace>
3400 Delete the character to the left of the cursor.
3403 Delete the character underneath the cursor.
3406 Insert the character into the line at the cursor.
3409 Undo the last editing command. You can undo all the way back to an
3412 (Depending on your configuration, the <Backspace> key be set to delete
3413 the character to the left of the cursor and the <DEL> key set to delete
3414 the character underneath the cursor, like `C-d', rather than the
3415 character to the left of the cursor.)
3418 File: gdb.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction
3420 27.2.2 Readline Movement Commands
3421 ---------------------------------
3423 The above table describes the most basic keystrokes that you need in
3424 order to do editing of the input line. For your convenience, many
3425 other commands have been added in addition to `C-b', `C-f', `C-d', and
3426 <DEL>. Here are some commands for moving more rapidly about the line.
3429 Move to the start of the line.
3432 Move to the end of the line.
3435 Move forward a word, where a word is composed of letters and
3439 Move backward a word.
3442 Clear the screen, reprinting the current line at the top.
3444 Notice how `C-f' moves forward a character, while `M-f' moves
3445 forward a word. It is a loose convention that control keystrokes
3446 operate on characters while meta keystrokes operate on words.
3449 File: gdb.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction
3451 27.2.3 Readline Killing Commands
3452 --------------------------------
3454 "Killing" text means to delete the text from the line, but to save it
3455 away for later use, usually by "yanking" (re-inserting) it back into
3456 the line. (`Cut' and `paste' are more recent jargon for `kill' and
3459 If the description for a command says that it `kills' text, then you
3460 can be sure that you can get the text back in a different (or the same)
3463 When you use a kill command, the text is saved in a "kill-ring".
3464 Any number of consecutive kills save all of the killed text together, so
3465 that when you yank it back, you get it all. The kill ring is not line
3466 specific; the text that you killed on a previously typed line is
3467 available to be yanked back later, when you are typing another line.
3469 Here is the list of commands for killing text.
3472 Kill the text from the current cursor position to the end of the
3476 Kill from the cursor to the end of the current word, or, if between
3477 words, to the end of the next word. Word boundaries are the same
3478 as those used by `M-f'.
3481 Kill from the cursor the start of the current word, or, if between
3482 words, to the start of the previous word. Word boundaries are the
3483 same as those used by `M-b'.
3486 Kill from the cursor to the previous whitespace. This is
3487 different than `M-<DEL>' because the word boundaries differ.
3490 Here is how to "yank" the text back into the line. Yanking means to
3491 copy the most-recently-killed text from the kill buffer.
3494 Yank the most recently killed text back into the buffer at the
3498 Rotate the kill-ring, and yank the new top. You can only do this
3499 if the prior command is `C-y' or `M-y'.
3502 File: gdb.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction
3504 27.2.4 Readline Arguments
3505 -------------------------
3507 You can pass numeric arguments to Readline commands. Sometimes the
3508 argument acts as a repeat count, other times it is the sign of the
3509 argument that is significant. If you pass a negative argument to a
3510 command which normally acts in a forward direction, that command will
3511 act in a backward direction. For example, to kill text back to the
3512 start of the line, you might type `M-- C-k'.
3514 The general way to pass numeric arguments to a command is to type
3515 meta digits before the command. If the first `digit' typed is a minus
3516 sign (`-'), then the sign of the argument will be negative. Once you
3517 have typed one meta digit to get the argument started, you can type the
3518 remainder of the digits, and then the command. For example, to give
3519 the `C-d' command an argument of 10, you could type `M-1 0 C-d', which
3520 will delete the next ten characters on the input line.
3523 File: gdb.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
3525 27.2.5 Searching for Commands in the History
3526 --------------------------------------------
3528 Readline provides commands for searching through the command history
3529 for lines containing a specified string. There are two search modes:
3530 "incremental" and "non-incremental".
3532 Incremental searches begin before the user has finished typing the
3533 search string. As each character of the search string is typed,
3534 Readline displays the next entry from the history matching the string
3535 typed so far. An incremental search requires only as many characters
3536 as needed to find the desired history entry. To search backward in the
3537 history for a particular string, type `C-r'. Typing `C-s' searches
3538 forward through the history. The characters present in the value of
3539 the `isearch-terminators' variable are used to terminate an incremental
3540 search. If that variable has not been assigned a value, the <ESC> and
3541 `C-J' characters will terminate an incremental search. `C-g' will
3542 abort an incremental search and restore the original line. When the
3543 search is terminated, the history entry containing the search string
3544 becomes the current line.
3546 To find other matching entries in the history list, type `C-r' or
3547 `C-s' as appropriate. This will search backward or forward in the
3548 history for the next entry matching the search string typed so far.
3549 Any other key sequence bound to a Readline command will terminate the
3550 search and execute that command. For instance, a <RET> will terminate
3551 the search and accept the line, thereby executing the command from the
3552 history list. A movement command will terminate the search, make the
3553 last line found the current line, and begin editing.
3555 Readline remembers the last incremental search string. If two
3556 `C-r's are typed without any intervening characters defining a new
3557 search string, any remembered search string is used.
3559 Non-incremental searches read the entire search string before
3560 starting to search for matching history lines. The search string may be
3561 typed by the user or be part of the contents of the current line.
3564 File: gdb.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing
3566 27.3 Readline Init File
3567 =======================
3569 Although the Readline library comes with a set of Emacs-like
3570 keybindings installed by default, it is possible to use a different set
3571 of keybindings. Any user can customize programs that use Readline by
3572 putting commands in an "inputrc" file, conventionally in his home
3573 directory. The name of this file is taken from the value of the
3574 environment variable `INPUTRC'. If that variable is unset, the default
3577 When a program which uses the Readline library starts up, the init
3578 file is read, and the key bindings are set.
3580 In addition, the `C-x C-r' command re-reads this init file, thus
3581 incorporating any changes that you might have made to it.
3585 * Readline Init File Syntax:: Syntax for the commands in the inputrc file.
3587 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
3589 * Sample Init File:: An example inputrc file.
3592 File: gdb.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File
3594 27.3.1 Readline Init File Syntax
3595 --------------------------------
3597 There are only a few basic constructs allowed in the Readline init
3598 file. Blank lines are ignored. Lines beginning with a `#' are
3599 comments. Lines beginning with a `$' indicate conditional constructs
3600 (*note Conditional Init Constructs::). Other lines denote variable
3601 settings and key bindings.
3604 You can modify the run-time behavior of Readline by altering the
3605 values of variables in Readline using the `set' command within the
3606 init file. The syntax is simple:
3610 Here, for example, is how to change from the default Emacs-like
3611 key binding to use `vi' line editing commands:
3615 Variable names and values, where appropriate, are recognized
3616 without regard to case. Unrecognized variable names are ignored.
3618 Boolean variables (those that can be set to on or off) are set to
3619 on if the value is null or empty, ON (case-insensitive), or 1.
3620 Any other value results in the variable being set to off.
3622 A great deal of run-time behavior is changeable with the following
3626 Controls what happens when Readline wants to ring the
3627 terminal bell. If set to `none', Readline never rings the
3628 bell. If set to `visible', Readline uses a visible bell if
3629 one is available. If set to `audible' (the default),
3630 Readline attempts to ring the terminal's bell.
3632 `bind-tty-special-chars'
3633 If set to `on', Readline attempts to bind the control
3634 characters treated specially by the kernel's terminal driver
3635 to their Readline equivalents.
3638 The string to insert at the beginning of the line when the
3639 `insert-comment' command is executed. The default value is
3642 `completion-ignore-case'
3643 If set to `on', Readline performs filename matching and
3644 completion in a case-insensitive fashion. The default value
3647 `completion-query-items'
3648 The number of possible completions that determines when the
3649 user is asked whether the list of possibilities should be
3650 displayed. If the number of possible completions is greater
3651 than this value, Readline will ask the user whether or not he
3652 wishes to view them; otherwise, they are simply listed. This
3653 variable must be set to an integer value greater than or
3654 equal to 0. A negative value means Readline should never ask.
3655 The default limit is `100'.
3658 If set to `on', Readline will convert characters with the
3659 eighth bit set to an ASCII key sequence by stripping the
3660 eighth bit and prefixing an <ESC> character, converting them
3661 to a meta-prefixed key sequence. The default value is `on'.
3663 `disable-completion'
3664 If set to `On', Readline will inhibit word completion.
3665 Completion characters will be inserted into the line as if
3666 they had been mapped to `self-insert'. The default is `off'.
3669 The `editing-mode' variable controls which default set of key
3670 bindings is used. By default, Readline starts up in Emacs
3671 editing mode, where the keystrokes are most similar to Emacs.
3672 This variable can be set to either `emacs' or `vi'.
3675 When set to `on', Readline will try to enable the application
3676 keypad when it is called. Some systems need this to enable
3677 the arrow keys. The default is `off'.
3680 If set to `on', tilde expansion is performed when Readline
3681 attempts word completion. The default is `off'.
3683 `history-preserve-point'
3684 If set to `on', the history code attempts to place point at
3685 the same location on each history line retrieved with
3686 `previous-history' or `next-history'. The default is `off'.
3688 `horizontal-scroll-mode'
3689 This variable can be set to either `on' or `off'. Setting it
3690 to `on' means that the text of the lines being edited will
3691 scroll horizontally on a single screen line when they are
3692 longer than the width of the screen, instead of wrapping onto
3693 a new screen line. By default, this variable is set to `off'.
3696 If set to `on', Readline will enable eight-bit input (it will
3697 not clear the eighth bit in the characters it reads),
3698 regardless of what the terminal claims it can support. The
3699 default value is `off'. The name `meta-flag' is a synonym
3702 `isearch-terminators'
3703 The string of characters that should terminate an incremental
3704 search without subsequently executing the character as a
3705 command (*note Searching::). If this variable has not been
3706 given a value, the characters <ESC> and `C-J' will terminate
3707 an incremental search.
3710 Sets Readline's idea of the current keymap for key binding
3711 commands. Acceptable `keymap' names are `emacs',
3712 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
3713 `vi-command', and `vi-insert'. `vi' is equivalent to
3714 `vi-command'; `emacs' is equivalent to `emacs-standard'. The
3715 default value is `emacs'. The value of the `editing-mode'
3716 variable also affects the default keymap.
3719 If set to `on', completed directory names have a slash
3720 appended. The default is `on'.
3722 `mark-modified-lines'
3723 This variable, when set to `on', causes Readline to display an
3724 asterisk (`*') at the start of history lines which have been
3725 modified. This variable is `off' by default.
3727 `mark-symlinked-directories'
3728 If set to `on', completed names which are symbolic links to
3729 directories have a slash appended (subject to the value of
3730 `mark-directories'). The default is `off'.
3732 `match-hidden-files'
3733 This variable, when set to `on', causes Readline to match
3734 files whose names begin with a `.' (hidden files) when
3735 performing filename completion, unless the leading `.' is
3736 supplied by the user in the filename to be completed. This
3737 variable is `on' by default.
3740 If set to `on', Readline will display characters with the
3741 eighth bit set directly rather than as a meta-prefixed escape
3742 sequence. The default is `off'.
3745 If set to `on', Readline uses an internal `more'-like pager
3746 to display a screenful of possible completions at a time.
3747 This variable is `on' by default.
3749 `print-completions-horizontally'
3750 If set to `on', Readline will display completions with matches
3751 sorted horizontally in alphabetical order, rather than down
3752 the screen. The default is `off'.
3754 `show-all-if-ambiguous'
3755 This alters the default behavior of the completion functions.
3756 If set to `on', words which have more than one possible
3757 completion cause the matches to be listed immediately instead
3758 of ringing the bell. The default value is `off'.
3760 `show-all-if-unmodified'
3761 This alters the default behavior of the completion functions
3762 in a fashion similar to SHOW-ALL-IF-AMBIGUOUS. If set to
3763 `on', words which have more than one possible completion
3764 without any possible partial completion (the possible
3765 completions don't share a common prefix) cause the matches to
3766 be listed immediately instead of ringing the bell. The
3767 default value is `off'.
3770 If set to `on', a character denoting a file's type is
3771 appended to the filename when listing possible completions.
3772 The default is `off'.
3776 The syntax for controlling key bindings in the init file is
3777 simple. First you need to find the name of the command that you
3778 want to change. The following sections contain tables of the
3779 command name, the default keybinding, if any, and a short
3780 description of what the command does.
3782 Once you know the name of the command, simply place on a line in
3783 the init file the name of the key you wish to bind the command to,
3784 a colon, and then the name of the command. The name of the key
3785 can be expressed in different ways, depending on what you find most
3788 In addition to command names, readline allows keys to be bound to
3789 a string that is inserted when the key is pressed (a MACRO).
3791 KEYNAME: FUNCTION-NAME or MACRO
3792 KEYNAME is the name of a key spelled out in English. For
3794 Control-u: universal-argument
3795 Meta-Rubout: backward-kill-word
3796 Control-o: "> output"
3798 In the above example, `C-u' is bound to the function
3799 `universal-argument', `M-DEL' is bound to the function
3800 `backward-kill-word', and `C-o' is bound to run the macro
3801 expressed on the right hand side (that is, to insert the text
3802 `> output' into the line).
3804 A number of symbolic character names are recognized while
3805 processing this key binding syntax: DEL, ESC, ESCAPE, LFD,
3806 NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB.
3808 "KEYSEQ": FUNCTION-NAME or MACRO
3809 KEYSEQ differs from KEYNAME above in that strings denoting an
3810 entire key sequence can be specified, by placing the key
3811 sequence in double quotes. Some GNU Emacs style key escapes
3812 can be used, as in the following example, but the special
3813 character names are not recognized.
3815 "\C-u": universal-argument
3816 "\C-x\C-r": re-read-init-file
3817 "\e[11~": "Function Key 1"
3819 In the above example, `C-u' is again bound to the function
3820 `universal-argument' (just as it was in the first example),
3821 `C-x C-r' is bound to the function `re-read-init-file', and
3822 `<ESC> <[> <1> <1> <~>' is bound to insert the text `Function
3826 The following GNU Emacs style escape sequences are available when
3827 specifying key sequences:
3842 <">, a double quotation mark
3845 <'>, a single quote or apostrophe
3847 In addition to the GNU Emacs style escape sequences, a second set
3848 of backslash escapes is available:
3875 the eight-bit character whose value is the octal value NNN
3876 (one to three digits)
3879 the eight-bit character whose value is the hexadecimal value
3880 HH (one or two hex digits)
3882 When entering the text of a macro, single or double quotes must be
3883 used to indicate a macro definition. Unquoted text is assumed to
3884 be a function name. In the macro body, the backslash escapes
3885 described above are expanded. Backslash will quote any other
3886 character in the macro text, including `"' and `''. For example,
3887 the following binding will make `C-x \' insert a single `\' into
3893 File: gdb.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File
3895 27.3.2 Conditional Init Constructs
3896 ----------------------------------
3898 Readline implements a facility similar in spirit to the conditional
3899 compilation features of the C preprocessor which allows key bindings
3900 and variable settings to be performed as the result of tests. There
3901 are four parser directives used.
3904 The `$if' construct allows bindings to be made based on the
3905 editing mode, the terminal being used, or the application using
3906 Readline. The text of the test extends to the end of the line; no
3907 characters are required to isolate it.
3910 The `mode=' form of the `$if' directive is used to test
3911 whether Readline is in `emacs' or `vi' mode. This may be
3912 used in conjunction with the `set keymap' command, for
3913 instance, to set bindings in the `emacs-standard' and
3914 `emacs-ctlx' keymaps only if Readline is starting out in
3918 The `term=' form may be used to include terminal-specific key
3919 bindings, perhaps to bind the key sequences output by the
3920 terminal's function keys. The word on the right side of the
3921 `=' is tested against both the full name of the terminal and
3922 the portion of the terminal name before the first `-'. This
3923 allows `sun' to match both `sun' and `sun-cmd', for instance.
3926 The APPLICATION construct is used to include
3927 application-specific settings. Each program using the
3928 Readline library sets the APPLICATION NAME, and you can test
3929 for a particular value. This could be used to bind key
3930 sequences to functions useful for a specific program. For
3931 instance, the following command adds a key sequence that
3932 quotes the current or previous word in Bash:
3934 # Quote the current or previous word
3935 "\C-xq": "\eb\"\ef\""
3939 This command, as seen in the previous example, terminates an `$if'
3943 Commands in this branch of the `$if' directive are executed if the
3947 This directive takes a single filename as an argument and reads
3948 commands and bindings from that file. For example, the following
3949 directive reads from `/etc/inputrc':
3950 $include /etc/inputrc
3953 File: gdb.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File
3955 27.3.3 Sample Init File
3956 -----------------------
3958 Here is an example of an INPUTRC file. This illustrates key binding,
3959 variable assignment, and conditional syntax.
3962 # This file controls the behaviour of line input editing for
3963 # programs that use the GNU Readline library. Existing
3964 # programs include FTP, Bash, and GDB.
3966 # You can re-read the inputrc file with C-x C-r.
3967 # Lines beginning with '#' are comments.
3969 # First, include any systemwide bindings and variable
3970 # assignments from /etc/Inputrc
3971 $include /etc/Inputrc
3974 # Set various bindings for emacs mode.
3976 set editing-mode emacs
3980 Meta-Control-h: backward-kill-word Text after the function name is ignored
3983 # Arrow keys in keypad mode
3985 #"\M-OD": backward-char
3986 #"\M-OC": forward-char
3987 #"\M-OA": previous-history
3988 #"\M-OB": next-history
3990 # Arrow keys in ANSI mode
3992 "\M-[D": backward-char
3993 "\M-[C": forward-char
3994 "\M-[A": previous-history
3995 "\M-[B": next-history
3997 # Arrow keys in 8 bit keypad mode
3999 #"\M-\C-OD": backward-char
4000 #"\M-\C-OC": forward-char
4001 #"\M-\C-OA": previous-history
4002 #"\M-\C-OB": next-history
4004 # Arrow keys in 8 bit ANSI mode
4006 #"\M-\C-[D": backward-char
4007 #"\M-\C-[C": forward-char
4008 #"\M-\C-[A": previous-history
4009 #"\M-\C-[B": next-history
4015 # An old-style binding. This happens to be the default.
4018 # Macros that are convenient for shell interaction
4021 "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
4022 # prepare to type a quoted word --
4023 # insert open and close double quotes
4024 # and move to just after the open quote
4025 "\C-x\"": "\"\"\C-b"
4026 # insert a backslash (testing backslash escapes
4027 # in sequences and macros)
4029 # Quote the current or previous word
4030 "\C-xq": "\eb\"\ef\""
4031 # Add a binding to refresh the line, which is unbound
4032 "\C-xr": redraw-current-line
4033 # Edit variable on current line.
4034 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
4037 # use a visible bell if one is available
4038 set bell-style visible
4040 # don't strip characters to 7 bits when reading
4043 # allow iso-latin1 characters to be inserted rather
4044 # than converted to prefix-meta sequences
4045 set convert-meta off
4047 # display characters with the eighth bit set directly
4048 # rather than as meta-prefixed characters
4051 # if there are more than 150 possible completions for
4052 # a word, ask the user if he wants to see all of them
4053 set completion-query-items 150
4059 "\M-.": yank-last-arg
4063 File: gdb.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing
4065 27.4 Bindable Readline Commands
4066 ===============================
4070 * Commands For Moving:: Moving about the line.
4071 * Commands For History:: Getting at previous lines.
4072 * Commands For Text:: Commands for changing text.
4073 * Commands For Killing:: Commands for killing and yanking.
4074 * Numeric Arguments:: Specifying numeric arguments, repeat counts.
4075 * Commands For Completion:: Getting Readline to do the typing for you.
4076 * Keyboard Macros:: Saving and re-executing typed characters
4077 * Miscellaneous Commands:: Other miscellaneous commands.
4079 This section describes Readline commands that may be bound to key
4080 sequences. Command names without an accompanying key sequence are
4083 In the following descriptions, "point" refers to the current cursor
4084 position, and "mark" refers to a cursor position saved by the
4085 `set-mark' command. The text between the point and mark is referred to
4089 File: gdb.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
4091 27.4.1 Commands For Moving
4092 --------------------------
4094 `beginning-of-line (C-a)'
4095 Move to the start of the current line.
4098 Move to the end of the line.
4100 `forward-char (C-f)'
4101 Move forward a character.
4103 `backward-char (C-b)'
4104 Move back a character.
4106 `forward-word (M-f)'
4107 Move forward to the end of the next word. Words are composed of
4110 `backward-word (M-b)'
4111 Move back to the start of the current or previous word. Words are
4112 composed of letters and digits.
4114 `clear-screen (C-l)'
4115 Clear the screen and redraw the current line, leaving the current
4116 line at the top of the screen.
4118 `redraw-current-line ()'
4119 Refresh the current line. By default, this is unbound.
4123 File: gdb.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands
4125 27.4.2 Commands For Manipulating The History
4126 --------------------------------------------
4128 `accept-line (Newline or Return)'
4129 Accept the line regardless of where the cursor is. If this line is
4130 non-empty, it may be added to the history list for future recall
4131 with `add_history()'. If this line is a modified history line,
4132 the history line is restored to its original state.
4134 `previous-history (C-p)'
4135 Move `back' through the history list, fetching the previous
4138 `next-history (C-n)'
4139 Move `forward' through the history list, fetching the next command.
4141 `beginning-of-history (M-<)'
4142 Move to the first line in the history.
4144 `end-of-history (M->)'
4145 Move to the end of the input history, i.e., the line currently
4148 `reverse-search-history (C-r)'
4149 Search backward starting at the current line and moving `up'
4150 through the history as necessary. This is an incremental search.
4152 `forward-search-history (C-s)'
4153 Search forward starting at the current line and moving `down'
4154 through the the history as necessary. This is an incremental
4157 `non-incremental-reverse-search-history (M-p)'
4158 Search backward starting at the current line and moving `up'
4159 through the history as necessary using a non-incremental search
4160 for a string supplied by the user.
4162 `non-incremental-forward-search-history (M-n)'
4163 Search forward starting at the current line and moving `down'
4164 through the the history as necessary using a non-incremental search
4165 for a string supplied by the user.
4167 `history-search-forward ()'
4168 Search forward through the history for the string of characters
4169 between the start of the current line and the point. This is a
4170 non-incremental search. By default, this command is unbound.
4172 `history-search-backward ()'
4173 Search backward through the history for the string of characters
4174 between the start of the current line and the point. This is a
4175 non-incremental search. By default, this command is unbound.
4177 `yank-nth-arg (M-C-y)'
4178 Insert the first argument to the previous command (usually the
4179 second word on the previous line) at point. With an argument N,
4180 insert the Nth word from the previous command (the words in the
4181 previous command begin with word 0). A negative argument inserts
4182 the Nth word from the end of the previous command. Once the
4183 argument N is computed, the argument is extracted as if the `!N'
4184 history expansion had been specified.
4186 `yank-last-arg (M-. or M-_)'
4187 Insert last argument to the previous command (the last word of the
4188 previous history entry). With an argument, behave exactly like
4189 `yank-nth-arg'. Successive calls to `yank-last-arg' move back
4190 through the history list, inserting the last argument of each line
4191 in turn. The history expansion facilities are used to extract the
4192 last argument, as if the `!$' history expansion had been specified.
4196 File: gdb.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands
4198 27.4.3 Commands For Changing Text
4199 ---------------------------------
4202 Delete the character at point. If point is at the beginning of
4203 the line, there are no characters in the line, and the last
4204 character typed was not bound to `delete-char', then return EOF.
4206 `backward-delete-char (Rubout)'
4207 Delete the character behind the cursor. A numeric argument means
4208 to kill the characters instead of deleting them.
4210 `forward-backward-delete-char ()'
4211 Delete the character under the cursor, unless the cursor is at the
4212 end of the line, in which case the character behind the cursor is
4213 deleted. By default, this is not bound to a key.
4215 `quoted-insert (C-q or C-v)'
4216 Add the next character typed to the line verbatim. This is how to
4217 insert key sequences like `C-q', for example.
4219 `tab-insert (M-<TAB>)'
4220 Insert a tab character.
4222 `self-insert (a, b, A, 1, !, ...)'
4225 `transpose-chars (C-t)'
4226 Drag the character before the cursor forward over the character at
4227 the cursor, moving the cursor forward as well. If the insertion
4228 point is at the end of the line, then this transposes the last two
4229 characters of the line. Negative arguments have no effect.
4231 `transpose-words (M-t)'
4232 Drag the word before point past the word after point, moving point
4233 past that word as well. If the insertion point is at the end of
4234 the line, this transposes the last two words on the line.
4237 Uppercase the current (or following) word. With a negative
4238 argument, uppercase the previous word, but do not move the cursor.
4240 `downcase-word (M-l)'
4241 Lowercase the current (or following) word. With a negative
4242 argument, lowercase the previous word, but do not move the cursor.
4244 `capitalize-word (M-c)'
4245 Capitalize the current (or following) word. With a negative
4246 argument, capitalize the previous word, but do not move the cursor.
4249 Toggle overwrite mode. With an explicit positive numeric argument,
4250 switches to overwrite mode. With an explicit non-positive numeric
4251 argument, switches to insert mode. This command affects only
4252 `emacs' mode; `vi' mode does overwrite differently. Each call to
4253 `readline()' starts in insert mode.
4255 In overwrite mode, characters bound to `self-insert' replace the
4256 text at point rather than pushing the text to the right.
4257 Characters bound to `backward-delete-char' replace the character
4258 before point with a space.
4260 By default, this command is unbound.
4264 File: gdb.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands
4266 27.4.4 Killing And Yanking
4267 --------------------------
4270 Kill the text from point to the end of the line.
4272 `backward-kill-line (C-x Rubout)'
4273 Kill backward to the beginning of the line.
4275 `unix-line-discard (C-u)'
4276 Kill backward from the cursor to the beginning of the current line.
4278 `kill-whole-line ()'
4279 Kill all characters on the current line, no matter where point is.
4280 By default, this is unbound.
4283 Kill from point to the end of the current word, or if between
4284 words, to the end of the next word. Word boundaries are the same
4287 `backward-kill-word (M-<DEL>)'
4288 Kill the word behind point. Word boundaries are the same as
4291 `unix-word-rubout (C-w)'
4292 Kill the word behind point, using white space as a word boundary.
4293 The killed text is saved on the kill-ring.
4295 `unix-filename-rubout ()'
4296 Kill the word behind point, using white space and the slash
4297 character as the word boundaries. The killed text is saved on the
4300 `delete-horizontal-space ()'
4301 Delete all spaces and tabs around point. By default, this is
4305 Kill the text in the current region. By default, this command is
4308 `copy-region-as-kill ()'
4309 Copy the text in the region to the kill buffer, so it can be yanked
4310 right away. By default, this command is unbound.
4312 `copy-backward-word ()'
4313 Copy the word before point to the kill buffer. The word
4314 boundaries are the same as `backward-word'. By default, this
4317 `copy-forward-word ()'
4318 Copy the word following point to the kill buffer. The word
4319 boundaries are the same as `forward-word'. By default, this
4323 Yank the top of the kill ring into the buffer at point.
4326 Rotate the kill-ring, and yank the new top. You can only do this
4327 if the prior command is `yank' or `yank-pop'.
4330 File: gdb.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands
4332 27.4.5 Specifying Numeric Arguments
4333 -----------------------------------
4335 `digit-argument (M-0, M-1, ... M--)'
4336 Add this digit to the argument already accumulating, or start a new
4337 argument. `M--' starts a negative argument.
4339 `universal-argument ()'
4340 This is another way to specify an argument. If this command is
4341 followed by one or more digits, optionally with a leading minus
4342 sign, those digits define the argument. If the command is
4343 followed by digits, executing `universal-argument' again ends the
4344 numeric argument, but is otherwise ignored. As a special case, if
4345 this command is immediately followed by a character that is
4346 neither a digit or minus sign, the argument count for the next
4347 command is multiplied by four. The argument count is initially
4348 one, so executing this function the first time makes the argument
4349 count four, a second time makes the argument count sixteen, and so
4350 on. By default, this is not bound to a key.
4353 File: gdb.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands
4355 27.4.6 Letting Readline Type For You
4356 ------------------------------------
4359 Attempt to perform completion on the text before point. The
4360 actual completion performed is application-specific. The default
4361 is filename completion.
4363 `possible-completions (M-?)'
4364 List the possible completions of the text before point.
4366 `insert-completions (M-*)'
4367 Insert all completions of the text before point that would have
4368 been generated by `possible-completions'.
4371 Similar to `complete', but replaces the word to be completed with
4372 a single match from the list of possible completions. Repeated
4373 execution of `menu-complete' steps through the list of possible
4374 completions, inserting each match in turn. At the end of the list
4375 of completions, the bell is rung (subject to the setting of
4376 `bell-style') and the original text is restored. An argument of N
4377 moves N positions forward in the list of matches; a negative
4378 argument may be used to move backward through the list. This
4379 command is intended to be bound to <TAB>, but is unbound by
4382 `delete-char-or-list ()'
4383 Deletes the character under the cursor if not at the beginning or
4384 end of the line (like `delete-char'). If at the end of the line,
4385 behaves identically to `possible-completions'. This command is
4390 File: gdb.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands
4392 27.4.7 Keyboard Macros
4393 ----------------------
4395 `start-kbd-macro (C-x ()'
4396 Begin saving the characters typed into the current keyboard macro.
4398 `end-kbd-macro (C-x ))'
4399 Stop saving the characters typed into the current keyboard macro
4400 and save the definition.
4402 `call-last-kbd-macro (C-x e)'
4403 Re-execute the last keyboard macro defined, by making the
4404 characters in the macro appear as if typed at the keyboard.
4408 File: gdb.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands
4410 27.4.8 Some Miscellaneous Commands
4411 ----------------------------------
4413 `re-read-init-file (C-x C-r)'
4414 Read in the contents of the INPUTRC file, and incorporate any
4415 bindings or variable assignments found there.
4418 Abort the current editing command and ring the terminal's bell
4419 (subject to the setting of `bell-style').
4421 `do-uppercase-version (M-a, M-b, M-X, ...)'
4422 If the metafied character X is lowercase, run the command that is
4423 bound to the corresponding uppercase character.
4425 `prefix-meta (<ESC>)'
4426 Metafy the next character typed. This is for keyboards without a
4427 meta key. Typing `<ESC> f' is equivalent to typing `M-f'.
4429 `undo (C-_ or C-x C-u)'
4430 Incremental undo, separately remembered for each line.
4433 Undo all changes made to this line. This is like executing the
4434 `undo' command enough times to get back to the beginning.
4436 `tilde-expand (M-~)'
4437 Perform tilde expansion on the current word.
4440 Set the mark to the point. If a numeric argument is supplied, the
4441 mark is set to that position.
4443 `exchange-point-and-mark (C-x C-x)'
4444 Swap the point with the mark. The current cursor position is set
4445 to the saved position, and the old cursor position is saved as the
4448 `character-search (C-])'
4449 A character is read and point is moved to the next occurrence of
4450 that character. A negative count searches for previous
4453 `character-search-backward (M-C-])'
4454 A character is read and point is moved to the previous occurrence
4455 of that character. A negative count searches for subsequent
4458 `insert-comment (M-#)'
4459 Without a numeric argument, the value of the `comment-begin'
4460 variable is inserted at the beginning of the current line. If a
4461 numeric argument is supplied, this command acts as a toggle: if
4462 the characters at the beginning of the line do not match the value
4463 of `comment-begin', the value is inserted, otherwise the
4464 characters in `comment-begin' are deleted from the beginning of
4465 the line. In either case, the line is accepted as if a newline
4469 Print all of the functions and their key bindings to the Readline
4470 output stream. If a numeric argument is supplied, the output is
4471 formatted in such a way that it can be made part of an INPUTRC
4472 file. This command is unbound by default.
4475 Print all of the settable variables and their values to the
4476 Readline output stream. If a numeric argument is supplied, the
4477 output is formatted in such a way that it can be made part of an
4478 INPUTRC file. This command is unbound by default.
4481 Print all of the Readline key sequences bound to macros and the
4482 strings they output. If a numeric argument is supplied, the
4483 output is formatted in such a way that it can be made part of an
4484 INPUTRC file. This command is unbound by default.
4486 `emacs-editing-mode (C-e)'
4487 When in `vi' command mode, this causes a switch to `emacs' editing
4490 `vi-editing-mode (M-C-j)'
4491 When in `emacs' editing mode, this causes a switch to `vi' editing
4496 File: gdb.info, Node: Readline vi Mode, Prev: Bindable Readline Commands, Up: Command Line Editing
4498 27.5 Readline vi Mode
4499 =====================
4501 While the Readline library does not have a full set of `vi' editing
4502 functions, it does contain enough to allow simple editing of the line.
4503 The Readline `vi' mode behaves as specified in the POSIX 1003.2
4506 In order to switch interactively between `emacs' and `vi' editing
4507 modes, use the command `M-C-j' (bound to emacs-editing-mode when in
4508 `vi' mode and to vi-editing-mode in `emacs' mode). The Readline
4509 default is `emacs' mode.
4511 When you enter a line in `vi' mode, you are already placed in
4512 `insertion' mode, as if you had typed an `i'. Pressing <ESC> switches
4513 you into `command' mode, where you can edit the text of the line with
4514 the standard `vi' movement keys, move to previous history lines with
4515 `k' and subsequent lines with `j', and so forth.
4518 File: gdb.info, Node: Using History Interactively, Next: Installing GDB, Prev: Command Line Editing, Up: Top
4520 28 Using History Interactively
4521 ******************************
4523 This chapter describes how to use the GNU History Library interactively,
4524 from a user's standpoint. It should be considered a user's guide. For
4525 information on using the GNU History Library in other programs, see the
4526 GNU Readline Library Manual.
4530 * History Interaction:: What it feels like using History as a user.
4533 File: gdb.info, Node: History Interaction, Up: Using History Interactively
4535 28.1 History Expansion
4536 ======================
4538 The History library provides a history expansion feature that is similar
4539 to the history expansion provided by `csh'. This section describes the
4540 syntax used to manipulate the history information.
4542 History expansions introduce words from the history list into the
4543 input stream, making it easy to repeat commands, insert the arguments
4544 to a previous command into the current input line, or fix errors in
4545 previous commands quickly.
4547 History expansion takes place in two parts. The first is to
4548 determine which line from the history list should be used during
4549 substitution. The second is to select portions of that line for
4550 inclusion into the current one. The line selected from the history is
4551 called the "event", and the portions of that line that are acted upon
4552 are called "words". Various "modifiers" are available to manipulate
4553 the selected words. The line is broken into words in the same fashion
4554 that Bash does, so that several words surrounded by quotes are
4555 considered one word. History expansions are introduced by the
4556 appearance of the history expansion character, which is `!' by default.
4560 * Event Designators:: How to specify which history line to use.
4561 * Word Designators:: Specifying which words are of interest.
4562 * Modifiers:: Modifying the results of substitution.
4565 File: gdb.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
4567 28.1.1 Event Designators
4568 ------------------------
4570 An event designator is a reference to a command line entry in the
4574 Start a history substitution, except when followed by a space, tab,
4575 the end of the line, or `='.
4578 Refer to command line N.
4581 Refer to the command N lines back.
4584 Refer to the previous command. This is a synonym for `!-1'.
4587 Refer to the most recent command starting with STRING.
4590 Refer to the most recent command containing STRING. The trailing
4591 `?' may be omitted if the STRING is followed immediately by a
4595 Quick Substitution. Repeat the last command, replacing STRING1
4596 with STRING2. Equivalent to `!!:s/STRING1/STRING2/'.
4599 The entire command line typed so far.
4603 File: gdb.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
4605 28.1.2 Word Designators
4606 -----------------------
4608 Word designators are used to select desired words from the event. A
4609 `:' separates the event specification from the word designator. It may
4610 be omitted if the word designator begins with a `^', `$', `*', `-', or
4611 `%'. Words are numbered from the beginning of the line, with the first
4612 word being denoted by 0 (zero). Words are inserted into the current
4613 line separated by single spaces.
4618 designates the preceding command. When you type this, the
4619 preceding command is repeated in toto.
4622 designates the last argument of the preceding command. This may be
4626 designates the second argument of the most recent command starting
4627 with the letters `fi'.
4629 Here are the word designators:
4632 The `0'th word. For many applications, this is the command word.
4638 The first argument; that is, word 1.
4644 The word matched by the most recent `?STRING?' search.
4647 A range of words; `-Y' abbreviates `0-Y'.
4650 All of the words, except the `0'th. This is a synonym for `1-$'.
4651 It is not an error to use `*' if there is just one word in the
4652 event; the empty string is returned in that case.
4658 Abbreviates `X-$' like `X*', but omits the last word.
4661 If a word designator is supplied without an event specification, the
4662 previous command is used as the event.
4665 File: gdb.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
4670 After the optional word designator, you can add a sequence of one or
4671 more of the following modifiers, each preceded by a `:'.
4674 Remove a trailing pathname component, leaving only the head.
4677 Remove all leading pathname components, leaving the tail.
4680 Remove a trailing suffix of the form `.SUFFIX', leaving the
4684 Remove all but the trailing suffix.
4687 Print the new command but do not execute it.
4690 Substitute NEW for the first occurrence of OLD in the event line.
4691 Any delimiter may be used in place of `/'. The delimiter may be
4692 quoted in OLD and NEW with a single backslash. If `&' appears in
4693 NEW, it is replaced by OLD. A single backslash will quote the
4694 `&'. The final delimiter is optional if it is the last character
4698 Repeat the previous substitution.
4702 Cause changes to be applied over the entire event line. Used in
4703 conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
4706 Apply the following `s' modifier once to each word in the event.
4710 File: gdb.info, Node: Formatting Documentation, Next: Command Line Editing, Prev: GDB Bugs, Up: Top
4712 Appendix A Formatting Documentation
4713 ***********************************
4715 The GDB 4 release includes an already-formatted reference card, ready
4716 for printing with PostScript or Ghostscript, in the `gdb' subdirectory
4717 of the main source directory(1). If you can use PostScript or
4718 Ghostscript with your printer, you can print the reference card
4719 immediately with `refcard.ps'.
4721 The release also includes the source for the reference card. You
4722 can format it, using TeX, by typing:
4726 The GDB reference card is designed to print in "landscape" mode on
4727 US "letter" size paper; that is, on a sheet 11 inches wide by 8.5 inches
4728 high. You will need to specify this form of printing as an option to
4729 your DVI output program.
4731 All the documentation for GDB comes as part of the machine-readable
4732 distribution. The documentation is written in Texinfo format, which is
4733 a documentation system that uses a single source file to produce both
4734 on-line information and a printed manual. You can use one of the Info
4735 formatting commands to create the on-line version of the documentation
4736 and TeX (or `texi2roff') to typeset the printed version.
4738 GDB includes an already formatted copy of the on-line Info version
4739 of this manual in the `gdb' subdirectory. The main Info file is
4740 `gdb-6.5/gdb/gdb.info', and it refers to subordinate files matching
4741 `gdb.info*' in the same directory. If necessary, you can print out
4742 these files, or read them with any editor; but they are easier to read
4743 using the `info' subsystem in GNU Emacs or the standalone `info'
4744 program, available as part of the GNU Texinfo distribution.
4746 If you want to format these Info files yourself, you need one of the
4747 Info formatting programs, such as `texinfo-format-buffer' or `makeinfo'.
4749 If you have `makeinfo' installed, and are in the top level GDB
4750 source directory (`gdb-6.5', in the case of version 6.5), you can make
4751 the Info file by typing:
4756 If you want to typeset and print copies of this manual, you need TeX,
4757 a program to print its DVI output files, and `texinfo.tex', the Texinfo
4760 TeX is a typesetting program; it does not print files directly, but
4761 produces output files called DVI files. To print a typeset document,
4762 you need a program to print DVI files. If your system has TeX
4763 installed, chances are it has such a program. The precise command to
4764 use depends on your system; `lpr -d' is common; another (for PostScript
4765 devices) is `dvips'. The DVI print command may require a file name
4766 without any extension or a `.dvi' extension.
4768 TeX also requires a macro definitions file called `texinfo.tex'.
4769 This file tells TeX how to typeset a document written in Texinfo
4770 format. On its own, TeX cannot either read or typeset a Texinfo file.
4771 `texinfo.tex' is distributed with GDB and is located in the
4772 `gdb-VERSION-NUMBER/texinfo' directory.
4774 If you have TeX and a DVI printer program installed, you can typeset
4775 and print this manual. First switch to the the `gdb' subdirectory of
4776 the main source directory (for example, to `gdb-6.5/gdb') and type:
4780 Then give `gdb.dvi' to your DVI printing program.
4782 ---------- Footnotes ----------
4784 (1) In `gdb-6.5/gdb/refcard.ps' of the version 6.5 release.
4787 File: gdb.info, Node: Installing GDB, Next: Maintenance Commands, Prev: Using History Interactively, Up: Top
4789 Appendix B Installing GDB
4790 *************************
4792 GDB comes with a `configure' script that automates the process of
4793 preparing GDB for installation; you can then use `make' to build the
4796 The GDB distribution includes all the source code you need for GDB
4797 in a single directory, whose name is usually composed by appending the
4798 version number to `gdb'.
4800 For example, the GDB version 6.5 distribution is in the `gdb-6.5'
4801 directory. That directory contains:
4803 `gdb-6.5/configure (and supporting files)'
4804 script for configuring GDB and all its supporting libraries
4807 the source specific to GDB itself
4810 source for the Binary File Descriptor library
4816 source for the `-liberty' free software library
4819 source for the library of opcode tables and disassemblers
4822 source for the GNU command-line interface
4825 source for the GNU filename pattern-matching subroutine
4828 source for the GNU memory-mapped malloc package
4830 The simplest way to configure and build GDB is to run `configure'
4831 from the `gdb-VERSION-NUMBER' source directory, which in this example
4832 is the `gdb-6.5' directory.
4834 First switch to the `gdb-VERSION-NUMBER' source directory if you are
4835 not already in it; then run `configure'. Pass the identifier for the
4836 platform on which GDB will run as an argument.
4844 where HOST is an identifier such as `sun4' or `decstation', that
4845 identifies the platform where GDB will run. (You can often leave off
4846 HOST; `configure' tries to guess the correct value by examining your
4849 Running `configure HOST' and then running `make' builds the `bfd',
4850 `readline', `mmalloc', and `libiberty' libraries, then `gdb' itself.
4851 The configured source files, and the binaries, are left in the
4852 corresponding source directories.
4854 `configure' is a Bourne-shell (`/bin/sh') script; if your system
4855 does not recognize this automatically when you run a different shell,
4856 you may need to run `sh' on it explicitly:
4860 If you run `configure' from a directory that contains source
4861 directories for multiple libraries or programs, such as the `gdb-6.5'
4862 source directory for version 6.5, `configure' creates configuration
4863 files for every directory level underneath (unless you tell it not to,
4864 with the `--norecursion' option).
4866 You should run the `configure' script from the top directory in the
4867 source tree, the `gdb-VERSION-NUMBER' directory. If you run
4868 `configure' from one of the subdirectories, you will configure only
4869 that subdirectory. That is usually not what you want. In particular,
4870 if you run the first `configure' from the `gdb' subdirectory of the
4871 `gdb-VERSION-NUMBER' directory, you will omit the configuration of
4872 `bfd', `readline', and other sibling directories of the `gdb'
4873 subdirectory. This leads to build errors about missing include files
4874 such as `bfd/bfd.h'.
4876 You can install `gdb' anywhere; it has no hardwired paths. However,
4877 you should make sure that the shell on your path (named by the `SHELL'
4878 environment variable) is publicly readable. Remember that GDB uses the
4879 shell to start your program--some systems refuse to let GDB debug child
4880 processes whose programs are not readable.
4884 * Separate Objdir:: Compiling GDB in another directory
4885 * Config Names:: Specifying names for hosts and targets
4886 * Configure Options:: Summary of options for configure
4889 File: gdb.info, Node: Separate Objdir, Next: Config Names, Up: Installing GDB
4891 B.1 Compiling GDB in another directory
4892 ======================================
4894 If you want to run GDB versions for several host or target machines,
4895 you need a different `gdb' compiled for each combination of host and
4896 target. `configure' is designed to make this easy by allowing you to
4897 generate each configuration in a separate subdirectory, rather than in
4898 the source directory. If your `make' program handles the `VPATH'
4899 feature (GNU `make' does), running `make' in each of these directories
4900 builds the `gdb' program specified there.
4902 To build `gdb' in a separate directory, run `configure' with the
4903 `--srcdir' option to specify where to find the source. (You also need
4904 to specify a path to find `configure' itself from your working
4905 directory. If the path to `configure' would be the same as the
4906 argument to `--srcdir', you can leave out the `--srcdir' option; it is
4909 For example, with version 6.5, you can build GDB in a separate
4910 directory for a Sun 4 like this:
4915 ../gdb-6.5/configure sun4
4918 When `configure' builds a configuration using a remote source
4919 directory, it creates a tree for the binaries with the same structure
4920 (and using the same names) as the tree under the source directory. In
4921 the example, you'd find the Sun 4 library `libiberty.a' in the
4922 directory `gdb-sun4/libiberty', and GDB itself in `gdb-sun4/gdb'.
4924 Make sure that your path to the `configure' script has just one
4925 instance of `gdb' in it. If your path to `configure' looks like
4926 `../gdb-6.5/gdb/configure', you are configuring only one subdirectory
4927 of GDB, not the whole package. This leads to build errors about
4928 missing include files such as `bfd/bfd.h'.
4930 One popular reason to build several GDB configurations in separate
4931 directories is to configure GDB for cross-compiling (where GDB runs on
4932 one machine--the "host"--while debugging programs that run on another
4933 machine--the "target"). You specify a cross-debugging target by giving
4934 the `--target=TARGET' option to `configure'.
4936 When you run `make' to build a program or library, you must run it
4937 in a configured directory--whatever directory you were in when you
4938 called `configure' (or one of its subdirectories).
4940 The `Makefile' that `configure' generates in each source directory
4941 also runs recursively. If you type `make' in a source directory such
4942 as `gdb-6.5' (or in a separate configured directory configured with
4943 `--srcdir=DIRNAME/gdb-6.5'), you will build all the required libraries,
4946 When you have multiple hosts or targets configured in separate
4947 directories, you can run `make' on them in parallel (for example, if
4948 they are NFS-mounted on each of the hosts); they will not interfere
4952 File: gdb.info, Node: Config Names, Next: Configure Options, Prev: Separate Objdir, Up: Installing GDB
4954 B.2 Specifying names for hosts and targets
4955 ==========================================
4957 The specifications used for hosts and targets in the `configure' script
4958 are based on a three-part naming scheme, but some short predefined
4959 aliases are also supported. The full naming scheme encodes three pieces
4960 of information in the following pattern:
4962 ARCHITECTURE-VENDOR-OS
4964 For example, you can use the alias `sun4' as a HOST argument, or as
4965 the value for TARGET in a `--target=TARGET' option. The equivalent
4966 full name is `sparc-sun-sunos4'.
4968 The `configure' script accompanying GDB does not provide any query
4969 facility to list all supported host and target names or aliases.
4970 `configure' calls the Bourne shell script `config.sub' to map
4971 abbreviations to full names; you can read the script, if you wish, or
4972 you can use it to test your guesses on abbreviations--for example:
4974 % sh config.sub i386-linux
4976 % sh config.sub alpha-linux
4977 alpha-unknown-linux-gnu
4978 % sh config.sub hp9k700
4980 % sh config.sub sun4
4981 sparc-sun-sunos4.1.1
4982 % sh config.sub sun3
4984 % sh config.sub i986v
4985 Invalid configuration `i986v': machine `i986v' not recognized
4987 `config.sub' is also distributed in the GDB source directory
4988 (`gdb-6.5', for version 6.5).
4991 File: gdb.info, Node: Configure Options, Prev: Config Names, Up: Installing GDB
4993 B.3 `configure' options
4994 =======================
4996 Here is a summary of the `configure' options and arguments that are
4997 most often useful for building GDB. `configure' also has several other
4998 options not listed here. *note (configure.info)What Configure Does::,
4999 for a full explanation of `configure'.
5005 [--norecursion] [--rm]
5009 You may introduce options with a single `-' rather than `--' if you
5010 prefer; but you may abbreviate option names if you use `--'.
5013 Display a quick summary of how to invoke `configure'.
5016 Configure the source to install programs and files under directory
5020 Configure the source to install programs under directory `DIR'.
5023 *Warning: using this option requires GNU `make', or another `make'
5024 that implements the `VPATH' feature.*
5025 Use this option to make configurations in directories separate
5026 from the GDB source directories. Among other things, you can use
5027 this to build (or maintain) several configurations simultaneously,
5028 in separate directories. `configure' writes configuration
5029 specific files in the current directory, but arranges for them to
5030 use the source in the directory DIRNAME. `configure' creates
5031 directories under the working directory in parallel to the source
5032 directories below DIRNAME.
5035 Configure only the directory level where `configure' is executed;
5036 do not propagate configuration to subdirectories.
5039 Configure GDB for cross-debugging programs running on the specified
5040 TARGET. Without this option, GDB is configured to debug programs
5041 that run on the same machine (HOST) as GDB itself.
5043 There is no convenient way to generate a list of all available
5047 Configure GDB to run on the specified HOST.
5049 There is no convenient way to generate a list of all available
5052 There are many other options available as well, but they are
5053 generally needed for special purposes only.
5056 File: gdb.info, Node: Maintenance Commands, Next: Remote Protocol, Prev: Installing GDB, Up: Top
5058 Appendix C Maintenance Commands
5059 *******************************
5061 In addition to commands intended for GDB users, GDB includes a number
5062 of commands intended for GDB developers, that are not documented
5063 elsewhere in this manual. These commands are provided here for
5064 reference. (For commands that turn on debugging messages, see *Note
5065 Debugging Output::.)
5067 `maint agent EXPRESSION'
5068 Translate the given EXPRESSION into remote agent bytecodes. This
5069 command is useful for debugging the Agent Expression mechanism
5070 (*note Agent Expressions::).
5072 `maint info breakpoints'
5073 Using the same format as `info breakpoints', display both the
5074 breakpoints you've set explicitly, and those GDB is using for
5075 internal purposes. Internal breakpoints are shown with negative
5076 breakpoint numbers. The type column identifies what kind of
5077 breakpoint is shown:
5080 Normal, explicitly set breakpoint.
5083 Normal, explicitly set watchpoint.
5086 Internal breakpoint, used to handle correctly stepping through
5090 Internal breakpoint at the target of a `longjmp'.
5093 Temporary internal breakpoint used by the GDB `until' command.
5096 Temporary internal breakpoint used by the GDB `finish'
5100 Shared library events.
5103 `maint check-symtabs'
5104 Check the consistency of psymtabs and symtabs.
5106 `maint cplus first_component NAME'
5107 Print the first C++ class/namespace component of NAME.
5109 `maint cplus namespace'
5110 Print the list of possible C++ namespaces.
5112 `maint demangle NAME'
5113 Demangle a C++ or Objective-C manled NAME.
5115 `maint deprecate COMMAND [REPLACEMENT]'
5116 `maint undeprecate COMMAND'
5117 Deprecate or undeprecate the named COMMAND. Deprecated commands
5118 cause GDB to issue a warning when you use them. The optional
5119 argument REPLACEMENT says which newer command should be used in
5120 favor of the deprecated one; if it is given, GDB will mention the
5121 replacement as part of the warning.
5124 Cause a fatal signal in the debugger and force it to dump its core.
5125 This is supported only on systems which support aborting a program
5126 with the `SIGQUIT' signal.
5128 `maint internal-error [MESSAGE-TEXT]'
5129 `maint internal-warning [MESSAGE-TEXT]'
5130 Cause GDB to call the internal function `internal_error' or
5131 `internal_warning' and hence behave as though an internal error or
5132 internal warning has been detected. In addition to reporting the
5133 internal problem, these functions give the user the opportunity to
5134 either quit GDB or create a core file of the current GDB session.
5136 These commands take an optional parameter MESSAGE-TEXT that is
5137 used as the text of the error or warning message.
5139 Here's an example of using `indernal-error':
5141 (gdb) maint internal-error testing, 1, 2
5142 .../maint.c:121: internal-error: testing, 1, 2
5143 A problem internal to GDB has been detected. Further
5144 debugging may prove unreliable.
5145 Quit this debugging session? (y or n) n
5146 Create a core file? (y or n) n
5150 If GDB is talking to an inferior via the serial protocol, then
5151 this command sends the string TEXT to the inferior, and displays
5152 the response packet. GDB supplies the initial `$' character, the
5153 terminating `#' character, and the checksum.
5155 `maint print architecture [FILE]'
5156 Print the entire architecture configuration. The optional argument
5157 FILE names the file where the output goes.
5159 `maint print dummy-frames'
5160 Prints the contents of GDB's internal dummy-frame stack.
5164 (gdb) print add(2,3)
5165 Breakpoint 2, add (a=2, b=3) at ...
5167 The program being debugged stopped while in a function called from GDB.
5169 (gdb) maint print dummy-frames
5170 0x1a57c80: pc=0x01014068 fp=0x0200bddc sp=0x0200bdd6
5171 top=0x0200bdd4 id={stack=0x200bddc,code=0x101405c}
5172 call_lo=0x01014000 call_hi=0x01014001
5175 Takes an optional file parameter.
5177 `maint print registers [FILE]'
5178 `maint print raw-registers [FILE]'
5179 `maint print cooked-registers [FILE]'
5180 `maint print register-groups [FILE]'
5181 Print GDB's internal register data structures.
5183 The command `maint print raw-registers' includes the contents of
5184 the raw register cache; the command `maint print cooked-registers'
5185 includes the (cooked) value of all registers; and the command
5186 `maint print register-groups' includes the groups that each
5187 register is a member of. *Note Registers: (gdbint)Registers.
5189 These commands take an optional parameter, a file name to which to
5190 write the information.
5192 `maint print reggroups [FILE]'
5193 Print GDB's internal register group data structures. The optional
5194 argument FILE tells to what file to write the information.
5196 The register groups info looks like this:
5198 (gdb) maint print reggroups
5209 This command forces GDB to flush its internal register cache.
5211 `maint print objfiles'
5212 Print a dump of all known object files. For each object file, this
5213 command prints its name, address in memory, and all of its psymtabs
5216 `maint print statistics'
5217 This command prints, for each object file in the program, various
5218 data about that object file followed by the byte cache ("bcache")
5219 statistics for the object file. The objfile data includes the
5220 number of minimal, partical, full, and stabs symbols, the number
5221 of types defined by the objfile, the number of as yet unexpanded
5222 psym tables, the number of line tables and string tables, and the
5223 amount of memory used by the various tables. The bcache
5224 statistics include the counts, sizes, and counts of duplicates of
5225 all and unique objects, max, average, and median entry size, total
5226 memory used and its overhead and savings, and various measures of
5227 the hash table size and chain lengths.
5229 `maint print type EXPR'
5230 Print the type chain for a type specified by EXPR. The argument
5231 can be either a type name or a symbol. If it is a symbol, the
5232 type of that symbol is described. The type chain produced by this
5233 command is a recursive definition of the data type as stored in
5234 GDB's data structures, including its flags and contained types.
5236 `maint set dwarf2 max-cache-age'
5237 `maint show dwarf2 max-cache-age'
5238 Control the DWARF 2 compilation unit cache.
5240 In object files with inter-compilation-unit references, such as
5241 those produced by the GCC option `-feliminate-dwarf2-dups', the
5242 DWARF 2 reader needs to frequently refer to previously read
5243 compilation units. This setting controls how long a compilation
5244 unit will remain in the cache if it is not referenced. A higher
5245 limit means that cached compilation units will be stored in memory
5246 longer, and more total memory will be used. Setting it to zero
5247 disables caching, which will slow down GDB startup, but reduce
5251 `maint show profile'
5252 Control profiling of GDB.
5254 Profiling will be disabled until you use the `maint set profile'
5255 command to enable it. When you enable profiling, the system will
5256 begin collecting timing and execution count data; when you disable
5257 profiling or exit GDB, the results will be written to a log file.
5258 Remember that if you use profiling, GDB will overwrite the
5259 profiling log file (often called `gmon.out'). If you have a
5260 record of important profiling data in a `gmon.out' file, be sure
5261 to move it to a safe location.
5263 Configuring with `--enable-profiling' arranges for GDB to be
5264 compiled with the `-pg' compiler option.
5266 `maint show-debug-regs'
5267 Control whether to show variables that mirror the x86 hardware
5268 debug registers. Use `ON' to enable, `OFF' to disable. If
5269 enabled, the debug registers values are shown when GDB inserts or
5270 removes a hardware breakpoint or watchpoint, and when the inferior
5271 triggers a hardware-assisted breakpoint or watchpoint.
5274 Control whether to display memory usage for each command. If set
5275 to a nonzero value, GDB will display how much memory each command
5276 took, following the command's own output. This can also be
5277 requested by invoking GDB with the `--statistics' command-line
5278 switch (*note Mode Options::).
5281 Control whether to display the execution time for each command. If
5282 set to a nonzero value, GDB will display how much time it took to
5283 execute each command, following the command's own output. This
5284 can also be requested by invoking GDB with the `--statistics'
5285 command-line switch (*note Mode Options::).
5287 `maint translate-address [SECTION] ADDR'
5288 Find the symbol stored at the location specified by the address
5289 ADDR and an optional section name SECTION. If found, GDB prints
5290 the name of the closest symbol and an offset from the symbol's
5291 location to the specified address. This is similar to the `info
5292 address' command (*note Symbols::), except that this command also
5293 allows to find symbols in other sections.
5296 The following command is useful for non-interactive invocations of
5297 GDB, such as in the test suite.
5300 Set the maximum number of seconds GDB will wait for the target
5301 operation to finish. If this time expires, GDB reports and error
5302 and the command is aborted.
5305 Show the current setting of the target wait timeout.
5308 File: gdb.info, Node: Remote Protocol, Next: Agent Expressions, Prev: Maintenance Commands, Up: Top
5310 Appendix D GDB Remote Serial Protocol
5311 *************************************
5317 * Stop Reply Packets::
5318 * General Query Packets::
5319 * Register Packet Format::
5320 * Tracepoint Packets::
5323 * File-I/O remote protocol extension::
5326 File: gdb.info, Node: Overview, Next: Packets, Up: Remote Protocol
5331 There may be occasions when you need to know something about the
5332 protocol--for example, if there is only one serial port to your target
5333 machine, you might want your program to do something special if it
5334 recognizes a packet meant for GDB.
5336 In the examples below, `->' and `<-' are used to indicate
5337 transmitted and received data respectfully.
5339 All GDB commands and responses (other than acknowledgments) are sent
5340 as a PACKET. A PACKET is introduced with the character `$', the actual
5341 PACKET-DATA, and the terminating character `#' followed by a two-digit
5344 `$'PACKET-DATA`#'CHECKSUM
5345 The two-digit CHECKSUM is computed as the modulo 256 sum of all
5346 characters between the leading `$' and the trailing `#' (an eight bit
5349 Implementors should note that prior to GDB 5.0 the protocol
5350 specification also included an optional two-digit SEQUENCE-ID:
5352 `$'SEQUENCE-ID`:'PACKET-DATA`#'CHECKSUM
5354 That SEQUENCE-ID was appended to the acknowledgment. GDB has never
5355 output SEQUENCE-IDs. Stubs that handle packets added since GDB 5.0
5356 must not accept SEQUENCE-ID.
5358 When either the host or the target machine receives a packet, the
5359 first response expected is an acknowledgment: either `+' (to indicate
5360 the package was received correctly) or `-' (to request retransmission):
5362 -> `$'PACKET-DATA`#'CHECKSUM
5364 The host (GDB) sends COMMANDs, and the target (the debugging stub
5365 incorporated in your program) sends a RESPONSE. In the case of step
5366 and continue COMMANDs, the response is only sent when the operation has
5367 completed (the target has again stopped).
5369 PACKET-DATA consists of a sequence of characters with the exception
5370 of `#' and `$' (see `X' packet for additional exceptions).
5372 Fields within the packet should be separated using `,' `;' or `:'.
5373 Except where otherwise noted all numbers are represented in HEX with
5374 leading zeros suppressed.
5376 Implementors should note that prior to GDB 5.0, the character `:'
5377 could not appear as the third character in a packet (as it would
5378 potentially conflict with the SEQUENCE-ID).
5380 Response DATA can be run-length encoded to save space. A `*' means
5381 that the next character is an ASCII encoding giving a repeat count
5382 which stands for that many repetitions of the character preceding the
5383 `*'. The encoding is `n+29', yielding a printable character where `n
5384 >=3' (which is where rle starts to win). The printable characters `$',
5385 `#', `+' and `-' or with a numeric value greater than 126 should not be
5390 means the same as "0000".
5392 The error response returned for some packets includes a two character
5393 error number. That number is not well defined.
5395 For any COMMAND not supported by the stub, an empty response
5396 (`$#00') should be returned. That way it is possible to extend the
5397 protocol. A newer GDB can tell if a packet is supported based on that
5400 A stub is required to support the `g', `G', `m', `M', `c', and `s'
5401 COMMANDs. All other COMMANDs are optional.
5404 File: gdb.info, Node: Packets, Next: Stop Reply Packets, Prev: Overview, Up: Remote Protocol
5409 The following table provides a complete list of all currently defined
5410 COMMANDs and their corresponding response DATA. *Note File-I/O remote
5411 protocol extension::, for details about the File I/O extension of the
5414 Each packet's description has a template showing the packet's overall
5415 syntax, followed by an explanation of the packet's meaning. We include
5416 spaces in some of the templates for clarity; these are not part of the
5417 packet's syntax. No GDB packet uses spaces to separate its components.
5418 For example, a template like `foo BAR BAZ' describes a packet
5419 beginning with the three ASCII bytes `foo', followed by a BAR, followed
5420 directly by a BAZ. GDB does not transmit a space character between the
5421 `foo' and the BAR, or between the BAR and the BAZ.
5423 Note that all packet forms beginning with an upper- or lower-case
5424 letter, other than those described here, are reserved for future use.
5426 Here are the packet descriptions.
5429 Enable extended mode. In extended mode, the remote server is made
5430 persistent. The `R' packet is used to restart the program being
5435 The remote target both supports and has enabled extended mode.
5438 Indicate the reason the target halted. The reply is the same as
5439 for step and continue.
5441 Reply: *Note Stop Reply Packets::, for the reply specifications.
5443 `A ARGLEN,ARGNUM,ARG,...'
5444 Initialized `argv[]' array passed into program. ARGLEN specifies
5445 the number of bytes in the hex encoded byte stream ARG. See
5446 `gdbserver' for more details.
5450 The arguments were set.
5456 (Don't use this packet; its behavior is not well-defined.) Change
5457 the serial line speed to BAUD.
5459 JTC: _When does the transport layer state change? When it's
5460 received, or after the ACK is transmitted. In either case, there
5461 are problems if the command or the acknowledgment packet is
5464 Stan: _If people really wanted to add something like this, and get
5465 it working for the first time, they ought to modify ser-unix.c to
5466 send some kind of out-of-band message to a specially-setup stub
5467 and have the switch happen "in between" packets, so that from
5468 remote protocol's point of view, nothing actually happened._
5471 Set (MODE is `S') or clear (MODE is `C') a breakpoint at ADDR.
5473 Don't use this packet. Use the `Z' and `z' packets instead (*note
5474 insert breakpoint or watchpoint packet::).
5477 Continue. ADDR is address to resume. If ADDR is omitted, resume
5480 Reply: *Note Stop Reply Packets::, for the reply specifications.
5483 Continue with signal SIG (hex signal number). If `;ADDR' is
5484 omitted, resume at same address.
5486 Reply: *Note Stop Reply Packets::, for the reply specifications.
5491 Don't use this packet; instead, define a general set packet (*note
5492 General Query Packets::).
5495 Detach GDB from the remote system. Sent to the remote target
5496 before GDB disconnects via the `detach' command.
5506 A reply from GDB to an `F' packet sent by the target. This is
5507 part of the File-I/O protocol extension. *Note File-I/O remote
5508 protocol extension::, for the specification.
5511 Read general registers.
5515 Each byte of register data is described by two hex digits.
5516 The bytes with the register are transmitted in target byte
5517 order. The size of each register and their position within
5518 the `g' packet are determined by the GDB internal macros
5519 `DEPRECATED_REGISTER_RAW_SIZE' and `REGISTER_NAME' macros.
5520 The specification of several standard `g' packets is
5527 Write general registers. *Note read registers packet::, for a
5528 description of the XX... data.
5538 Set thread for subsequent operations (`m', `M', `g', `G', et.al.).
5539 C depends on the operation to be performed: it should be `c' for
5540 step and continue operations, `g' for other operations. The
5541 thread designator T may be `-1', meaning all the threads, a thread
5542 number, or `0' which means pick any thread.
5552 Step the remote target by a single clock cycle. If `,NNN' is
5553 present, cycle step NNN cycles. If ADDR is present, cycle step
5554 starting at that address.
5557 Signal, then cycle step. *Note step with signal packet::. *Note
5558 cycle step packet::.
5563 FIXME: _There is no description of how to operate when a specific
5564 thread context has been selected (i.e. does 'k' kill only that
5568 Read LENGTH bytes of memory starting at address ADDR. Note that
5569 ADDR may not be aligned to any particular boundary.
5571 The stub need not use any particular size or alignment when
5572 gathering data from memory for the response; even if ADDR is
5573 word-aligned and LENGTH is a multiple of the word size, the stub
5574 is free to use byte accesses, or not. For this reason, this
5575 packet may not be suitable for accessing memory-mapped I/O devices.
5579 Memory contents; each byte is transmitted as a two-digit
5580 hexidecimal number. The reply may contain fewer bytes than
5581 requested if the server was able to read only part of the
5587 `M ADDR,LENGTH:XX...'
5588 Write LENGTH bytes of memory starting at address ADDR. XX... is
5589 the data; each byte is transmitted as a two-digit hexidecimal
5597 for an error (this includes the case where only part of the
5601 Read the value of register N; N is in hex. *Note read registers
5602 packet::, for a description of how the returned register value is
5607 the register's value
5613 Indicating an unrecognized QUERY.
5616 Write register N... with value R.... The register number N is in
5617 hexidecimal, and R... contains two hex digits for each byte in the
5618 register (target byte order).
5629 General query (`q') and set (`Q'). These packets are described
5630 fully in *Note General Query Packets::.
5633 Reset the entire system.
5635 Don't use this packet; use the `R' packet instead.
5638 Restart the program being debugged. XX, while needed, is ignored.
5639 This packet is only available in extended mode.
5641 The `R' packet has no reply.
5644 Single step. ADDR is the address at which to resume. If ADDR is
5645 omitted, resume at same address.
5647 Reply: *Note Stop Reply Packets::, for the reply specifications.
5650 Step with signal. This is analogous to the `C' packet, but
5651 requests a single-step, rather than a normal resumption of
5654 Reply: *Note Stop Reply Packets::, for the reply specifications.
5657 Search backwards starting at address ADDR for a match with pattern
5658 PP and mask MM. PP and MM are 4 bytes. ADDR must be at least 3
5662 Find out if the thread XX is alive.
5666 thread is still alive
5672 Packets starting with `v' are identified by a multi-letter name,
5673 up to the first `;' or `?' (or the end of the packet).
5675 `vCont[;ACTION[:TID]]...'
5676 Resume the inferior, specifying different actions for each thread.
5677 If an action is specified with no TID, then it is applied to any
5678 threads that don't have a specific action specified; if no default
5679 action is specified then other threads should remain stopped.
5680 Specifying multiple default actions is an error; specifying no
5681 actions is also an error. Thread IDs are specified in
5682 hexadecimal. Currently supported actions are:
5688 Continue with signal SIG. SIG should be two hex digits.
5694 Step with signal SIG. SIG should be two hex digits.
5696 The optional ADDR argument normally associated with these packets
5697 is not supported in `vCont'.
5699 Reply: *Note Stop Reply Packets::, for the reply specifications.
5702 Request a list of actions supporetd by the `vCont' packet.
5706 The `vCont' packet is supported. Each ACTION is a supported
5707 command in the `vCont' packet.
5710 The `vCont' packet is not supported.
5712 `X ADDR,LENGTH:XX...'
5713 Write data to memory, where the data is transmitted in binary.
5714 ADDR is address, LENGTH is number of bytes, `XX...' is binary
5715 data. The bytes `0x23' (ASCII `#'), `0x24' (ASCII `$'), and
5716 `0x7d' (ASCII `}') are escaped using `0x7d' (ASCII `}'), and then
5717 XORed with `0x20'. For example, the byte `0x7d' would be
5718 transmitted as the two bytes `0x7d 0x5d'.
5727 `z TYPE,ADDR,LENGTH'
5728 `Z TYPE,ADDR,LENGTH'
5729 Insert (`Z') or remove (`z') a TYPE breakpoint or watchpoint
5730 starting at address ADDRESS and covering the next LENGTH bytes.
5732 Each breakpoint and watchpoint packet TYPE is documented
5735 _Implementation notes: A remote target shall return an empty string
5736 for an unrecognized breakpoint or watchpoint packet TYPE. A
5737 remote target shall support either both or neither of a given
5738 `ZTYPE...' and `zTYPE...' packet pair. To avoid potential
5739 problems with duplicate packets, the operations should be
5740 implemented in an idempotent way._
5744 Insert (`Z0') or remove (`z0') a memory breakpoint at address ADDR
5747 A memory breakpoint is implemented by replacing the instruction at
5748 ADDR with a software breakpoint or trap instruction. The LENGTH
5749 is used by targets that indicates the size of the breakpoint (in
5750 bytes) that should be inserted (e.g., the ARM and MIPS can insert
5751 either a 2 or 4 byte breakpoint).
5753 _Implementation note: It is possible for a target to copy or move
5754 code that contains memory breakpoints (e.g., when implementing
5755 overlays). The behavior of this packet, in the presence of such a
5756 target, is not defined._
5770 Insert (`Z1') or remove (`z1') a hardware breakpoint at address
5771 ADDR of size LENGTH.
5773 A hardware breakpoint is implemented using a mechanism that is not
5774 dependant on being able to modify the target's memory.
5776 _Implementation note: A hardware breakpoint is not affected by code
5791 Insert (`Z2') or remove (`z2') a write watchpoint.
5805 Insert (`Z3') or remove (`z3') a read watchpoint.
5819 Insert (`Z4') or remove (`z4') an access watchpoint.
5833 File: gdb.info, Node: Stop Reply Packets, Next: General Query Packets, Prev: Packets, Up: Remote Protocol
5835 D.3 Stop Reply Packets
5836 ======================
5838 The `C', `c', `S', `s' and `?' packets can receive any of the below as
5839 a reply. In the case of the `C', `c', `S' and `s' packets, that reply
5840 is only returned when the target halts. In the below the exact meaning
5841 of "signal number" is poorly defined. In general one of the UNIX signal
5842 numbering conventions is used.
5844 As in the description of request packets, we include spaces in the
5845 reply templates for clarity; these are not part of the reply packet's
5846 syntax. No GDB stop reply packet uses spaces to separate its
5850 The program received signal number AA (a two-digit hexidecimal
5853 `T AA N1:R1;N2:R2;...'
5854 The program received signal number AA (a two-digit hexidecimal
5855 number). Single-step and breakpoint traps are reported this way.
5856 The `N:R' pairs give the values of important registers or other
5858 1. If N is a hexidecimal number, it is a register number, and the
5859 corresponding R gives that register's value. R is a series
5860 of bytes in target byte order, with each byte given by a
5861 two-digit hex number.
5863 2. If N is `thread', then R is the thread process ID, in hex.
5865 3. If N is `watch', `rwatch', or `awatch', then the packet
5866 indicates a watchpoint hit, and R is the data address, in hex.
5868 4. Otherwise, GDB should ignore this `N:R' pair and go on to the
5869 next; this allows us to extend the protocol in the future.
5872 The process exited, and AA is the exit status. This is only
5873 applicable to certain targets.
5876 The process terminated with signal AA.
5879 `XX...' is hex encoding of ASCII data, to be written as the
5880 program's console output. This can happen at any time while the
5881 program is running and the debugger should continue to wait for
5884 `F CALL-ID,PARAMETER...'
5885 CALL-ID is the identifier which says which host system call should
5886 be called. This is just the name of the function. Translation
5887 into the correct system call is only applicable as it's defined in
5888 GDB. *Note File-I/O remote protocol extension::, for a list of
5889 implemented system calls.
5891 `PARAMETER...' is a list of parameters as defined for this very
5894 The target replies with this packet when it expects GDB to call a
5895 host system call on behalf of the target. GDB replies with an
5896 appropriate `F' packet and keeps up waiting for the next reply
5897 packet from the target. The latest `C', `c', `S' or `s' action is
5898 expected to be continued. *Note File-I/O remote protocol
5899 extension::, for more details.
5903 File: gdb.info, Node: General Query Packets, Next: Register Packet Format, Prev: Stop Reply Packets, Up: Remote Protocol
5905 D.4 General Query Packets
5906 =========================
5908 Packets starting with `q' are "general query packets"; packets starting
5909 with `Q' are "general set packets". General query and set packets are
5910 a semi-unified form for retrieving and sending information to and from
5913 The initial letter of a query or set packet is followed by a name
5914 indicating what sort of thing the packet applies to. For example, GDB
5915 may use a `qSymbol' packet to exchange symbol definitions with the
5916 stub. These packet names follow some conventions:
5918 * The name must not contain commas, colons or semicolons.
5920 * Most GDB query and set packets have a leading upper case letter.
5922 * The names of custom vendor packets should use a company prefix, in
5923 lower case, followed by a period. For example, packets designed at
5924 the Acme Corporation might begin with `qacme.foo' (for querying
5925 foos) or `Qacme.bar' (for setting bars).
5927 The name of a query or set packet should be separated from any
5928 parameters by a `:'; the parameters themselves should be separated by
5929 `,' or `;'. Stubs must be careful to match the full packet name, and
5930 check for a separator or the end of the packet, in case two packet
5931 names share a common prefix. New packets should not begin with `qC',
5934 Like the descriptions of the other packets, each description here
5935 has a template showing the packet's overall syntax, followed by an
5936 explanation of the packet's meaning. We include spaces in some of the
5937 templates for clarity; these are not part of the packet's syntax. No
5938 GDB packet uses spaces to separate its components.
5940 Here are the currently defined query and set packets:
5943 Return the current thread id.
5947 Where PID is an unsigned hexidecimal process id.
5950 Any other reply implies the old pid.
5953 Compute the CRC checksum of a block of memory. Reply:
5955 An error (such as memory fault)
5958 The specified memory region's checksum is CRC32.
5962 Obtain a list of all active thread ids from the target (OS).
5963 Since there may be too many active threads to fit into one reply
5964 packet, this query works iteratively: it may require more than one
5965 query/reply sequence to obtain the entire list of threads. The
5966 first query of the sequence will be the `qfThreadInfo' query;
5967 subsequent queries in the sequence will be the `qsThreadInfo'
5970 NOTE: This packet replaces the `qL' query (see below).
5977 a comma-separated list of thread ids
5980 (lower case letter `L') denotes end of list.
5982 In response to each query, the target will reply with a list of
5983 one or more thread ids, in big-endian unsigned hex, separated by
5984 commas. GDB will respond to each reply with a request for more
5985 thread ids (using the `qs' form of the query), until the target
5986 responds with `l' (lower-case el, for "last").
5988 `qGetTLSAddr:THREAD-ID,OFFSET,LM'
5989 Fetch the address associated with thread local storage specified
5990 by THREAD-ID, OFFSET, and LM.
5992 THREAD-ID is the (big endian, hex encoded) thread id associated
5993 with the thread for which to fetch the TLS address.
5995 OFFSET is the (big endian, hex encoded) offset associated with the
5996 thread local variable. (This offset is obtained from the debug
5997 information associated with the variable.)
5999 LM is the (big endian, hex encoded) OS/ABI specific encoding of the
6000 the load module associated with the thread local storage. For
6001 example, a GNU/Linux system will pass the link map address of the
6002 shared object associated with the thread local storage under
6003 consideration. Other operating environments may choose to
6004 represent the load module differently, so the precise meaning of
6005 this parameter will vary.
6009 Hex encoded (big endian) bytes representing the address of
6010 the thread local storage requested.
6013 An error occurred. NN are hex digits.
6016 An empty reply indicates that `qGetTLSAddr' is not supported
6019 Use of this request packet is controlled by the `set remote
6020 get-thread-local-storage-address' command (*note set remote
6021 get-thread-local-storage-address: Remote configuration.).
6023 `qL STARTFLAG THREADCOUNT NEXTTHREAD'
6024 Obtain thread information from RTOS. Where: STARTFLAG (one hex
6025 digit) is one to indicate the first query and zero to indicate a
6026 subsequent query; THREADCOUNT (two hex digits) is the maximum
6027 number of threads the response packet can contain; and NEXTTHREAD
6028 (eight hex digits), for subsequent queries (STARTFLAG is zero), is
6029 returned in the response as ARGTHREAD.
6031 Don't use this packet; use the `qfThreadInfo' query instead (see
6035 `qM COUNT DONE ARGTHREAD THREAD...'
6036 Where: COUNT (two hex digits) is the number of threads being
6037 returned; DONE (one hex digit) is zero to indicate more
6038 threads and one indicates no further threads; ARGTHREADID
6039 (eight hex digits) is NEXTTHREAD from the request packet;
6040 THREAD... is a sequence of thread IDs from the target.
6041 THREADID (eight hex digits). See
6042 `remote.c:parse_threadlist_response()'.
6045 Get section offsets that the target used when re-locating the
6046 downloaded image. _Note: while a `Bss' offset is included in the
6047 response, GDB ignores this and instead applies the `Data' offset
6048 to the `Bss' section._
6051 `Text=XXX;Data=YYY;Bss=ZZZ'
6054 Returns information on THREADID. Where: MODE is a hex encoded 32
6055 bit mode; THREADID is a hex encoded 64 bit thread ID.
6057 Don't use this packet; use the `qThreadExtraInfo' query instead
6060 Reply: see `remote.c:remote_unpack_thread_info_response()'.
6062 `qPart:OBJECT:read:ANNEX:OFFSET,LENGTH'
6063 Read uninterpreted bytes from the target's special data area
6064 identified by the keyword OBJECT. Request LENGTH bytes starting
6065 at OFFSET bytes into the data. The content and encoding of ANNEX
6066 is specific to the object; it can supply additional details about
6067 what data to access.
6069 Since this packet is ambiguous with the older `qP' packet, we plan
6072 Here are the specific requests of this form defined so far. All
6073 `qPart:OBJECT:read:...' requests use the same reply formats,
6076 `qPart:auxv:read::OFFSET,LENGTH'
6077 Access the target's "auxiliary vector". *Note auxiliary
6078 vector: OS Information, and see *Note read-aux-vector-packet:
6079 Remote configuration. Note ANNEX must be empty.
6083 The OFFSET in the request is at the end of the data. There
6084 is no more data to be read.
6087 Hex encoded data bytes read. This may be fewer bytes than
6088 the LENGTH in the request.
6091 The request was malformed, or ANNEX was invalid.
6094 The offset was invalid, or there was an error encountered
6095 reading the data. NN is a hex-encoded `errno' value.
6098 An empty reply indicates the OBJECT or ANNEX string was not
6099 recognized by the stub.
6101 `qPart:OBJECT:write:ANNEX:OFFSET:DATA...'
6102 Write uninterpreted bytes into the target's special data area
6103 identified by the keyword OBJECT, starting at OFFSET bytes into
6104 the data. `DATA...' is the hex-encoded data to be written. The
6105 content and encoding of ANNEX is specific to the object; it can
6106 supply additional details about what data to access.
6108 No requests of this form are presently in use. This specification
6109 serves as a placeholder to document the common format that new
6110 specific request specifications ought to use.
6114 NN (hex encoded) is the number of bytes written. This may be
6115 fewer bytes than supplied in the request.
6118 The request was malformed, or ANNEX was invalid.
6121 The offset was invalid, or there was an error encountered
6122 writing the data. NN is a hex-encoded `errno' value.
6125 An empty reply indicates the OBJECT or ANNEX string was not
6126 recognized by the stub, or that the object does not support
6129 `qPart:OBJECT:OPERATION:...'
6130 Requests of this form may be added in the future. When a stub does
6131 not recognize the OBJECT keyword, or its support for OBJECT does
6132 not recognize the OPERATION keyword, the stub must respond with an
6136 COMMAND (hex encoded) is passed to the local interpreter for
6137 execution. Invalid commands should be reported using the output
6138 string. Before the final result packet, the target may also
6139 respond with a number of intermediate `OOUTPUT' console output
6140 packets. _Implementors should note that providing access to a
6141 stubs's interpreter may have security implications_.
6145 A command response with no output.
6148 A command response with the hex encoded output string OUTPUT.
6151 Indicate a badly formed request.
6154 An empty reply indicates that `qRcmd' is not recognized.
6156 (Note that the `qRcmd' packet's name is separated from the command
6157 by a `,', not a `:', contrary to the naming conventions above.
6158 Please don't use this packet as a model for new packets.)
6161 Notify the target that GDB is prepared to serve symbol lookup
6162 requests. Accept requests from the target for the values of
6167 The target does not need to look up any (more) symbols.
6170 The target requests the value of symbol SYM_NAME (hex
6171 encoded). GDB may provide the value by using the
6172 `qSymbol:SYM_VALUE:SYM_NAME' message, described below.
6174 `qSymbol:SYM_VALUE:SYM_NAME'
6175 Set the value of SYM_NAME to SYM_VALUE.
6177 SYM_NAME (hex encoded) is the name of a symbol whose value the
6178 target has previously requested.
6180 SYM_VALUE (hex) is the value for symbol SYM_NAME. If GDB cannot
6181 supply a value for SYM_NAME, then this field will be empty.
6185 The target does not need to look up any (more) symbols.
6188 The target requests the value of a new symbol SYM_NAME (hex
6189 encoded). GDB will continue to supply the values of symbols
6190 (if available), until the target ceases to request them.
6194 *Note Tracepoint Packets::.
6196 `qThreadExtraInfo,ID'
6197 Obtain a printable string description of a thread's attributes from
6198 the target OS. ID is a thread-id in big-endian hex. This string
6199 may contain anything that the target OS thinks is interesting for
6200 GDB to tell the user about the thread. The string is displayed in
6201 GDB's `info threads' display. Some examples of possible thread
6202 extra info strings are `Runnable', or `Blocked on Mutex'.
6206 Where `XX...' is a hex encoding of ASCII data, comprising the
6207 printable string containing the extra information about the
6208 thread's attributes.
6210 (Note that the `qThreadExtraInfo' packet's name is separated from
6211 the command by a `,', not a `:', contrary to the naming
6212 conventions above. Please don't use this packet as a model for new
6220 *Note Tracepoint Packets::.
6223 ---------- Footnotes ----------
6225 (1) The `qP' and `qL' packets predate these conventions, and have
6226 arguments without any terminator for the packet name; we suspect they
6227 are in widespread use in places that are difficult to upgrade. The
6228 `qC' packet has no arguments, but some existing stubs (e.g. RedBoot)
6229 are known to not check for the end of the packet.
6232 File: gdb.info, Node: Register Packet Format, Next: Tracepoint Packets, Prev: General Query Packets, Up: Remote Protocol
6234 D.5 Register Packet Format
6235 ==========================
6237 The following `g'/`G' packets have previously been defined. In the
6238 below, some thirty-two bit registers are transferred as sixty-four
6239 bits. Those registers should be zero/sign extended (which?) to fill
6240 the space allocated. Register bytes are transfered in target byte
6241 order. The two nibbles within a register byte are transfered
6242 most-significant - least-significant.
6245 All registers are transfered as thirty-two bit quantities in the
6246 order: 32 general-purpose; sr; lo; hi; bad; cause; pc; 32
6247 floating-point registers; fsr; fir; fp.
6250 All registers are transfered as sixty-four bit quantities
6251 (including thirty-two bit registers such as `sr'). The ordering
6252 is the same as `MIPS32'.
6256 File: gdb.info, Node: Tracepoint Packets, Next: Interrupts, Prev: Register Packet Format, Up: Remote Protocol
6258 D.6 Tracepoint Packets
6259 ======================
6261 Here we describe the packets GDB uses to implement tracepoints (*note
6264 `QTDP:N:ADDR:ENA:STEP:PASS[-]'
6265 Create a new tracepoint, number N, at ADDR. If ENA is `E', then
6266 the tracepoint is enabled; if it is `D', then the tracepoint is
6267 disabled. STEP is the tracepoint's step count, and PASS is its
6268 pass count. If the trailing `-' is present, further `QTDP'
6269 packets will follow to specify this tracepoint's actions.
6273 The packet was understood and carried out.
6276 The packet was not recognized.
6278 `QTDP:-N:ADDR:[S]ACTION...[-]'
6279 Define actions to be taken when a tracepoint is hit. N and ADDR
6280 must be the same as in the initial `QTDP' packet for this
6281 tracepoint. This packet may only be sent immediately after
6282 another `QTDP' packet that ended with a `-'. If the trailing `-'
6283 is present, further `QTDP' packets will follow, specifying more
6284 actions for this tracepoint.
6286 In the series of action packets for a given tracepoint, at most one
6287 can have an `S' before its first ACTION. If such a packet is
6288 sent, it and the following packets define "while-stepping"
6289 actions. Any prior packets define ordinary actions -- that is,
6290 those taken when the tracepoint is first hit. If no action packet
6291 has an `S', then all the packets in the series specify ordinary
6294 The `ACTION...' portion of the packet is a series of actions,
6295 concatenated without separators. Each action has one of the
6299 Collect the registers whose bits are set in MASK. MASK is a
6300 hexidecimal number whose I'th bit is set if register number I
6301 should be collected. (The least significant bit is numbered
6302 zero.) Note that MASK may be any number of digits long; it
6303 may not fit in a 32-bit word.
6305 `M BASEREG,OFFSET,LEN'
6306 Collect LEN bytes of memory starting at the address in
6307 register number BASEREG, plus OFFSET. If BASEREG is `-1',
6308 then the range has a fixed address: OFFSET is the address of
6309 the lowest byte to collect. The BASEREG, OFFSET, and LEN
6310 parameters are all unsigned hexidecimal values (the `-1'
6311 value for BASEREG is a special case).
6314 Evaluate EXPR, whose length is LEN, and collect memory as it
6315 directs. EXPR is an agent expression, as described in *Note
6316 Agent Expressions::. Each byte of the expression is encoded
6317 as a two-digit hex number in the packet; LEN is the number of
6318 bytes in the expression (and thus one-half the number of hex
6319 digits in the packet).
6322 Any number of actions may be packed together in a single `QTDP'
6323 packet, as long as the packet does not exceed the maximum packet
6324 length (400 bytes, for many stubs). There may be only one `R'
6325 action per tracepoint, and it must precede any `M' or `X' actions.
6326 Any registers referred to by `M' and `X' actions must be
6327 collected by a preceding `R' action. (The "while-stepping"
6328 actions are treated as if they were attached to a separate
6329 tracepoint, as far as these restrictions are concerned.)
6333 The packet was understood and carried out.
6336 The packet was not recognized.
6339 Select the N'th tracepoint frame from the buffer, and use the
6340 register and memory contents recorded there to answer subsequent
6341 request packets from GDB.
6343 A successful reply from the stub indicates that the stub has found
6344 the requested frame. The response is a series of parts,
6345 concatenated without separators, describing the frame we selected.
6346 Each part has one of the following forms:
6349 The selected frame is number N in the trace frame buffer; F
6350 is a hexidecimal number. If F is `-1', then there was no
6351 frame matching the criteria in the request packet.
6354 The selected trace frame records a hit of tracepoint number T;
6355 T is a hexidecimal number.
6359 Like `QTFrame:N', but select the first tracepoint frame after the
6360 currently selected frame whose PC is ADDR; ADDR is a hexidecimal
6364 Like `QTFrame:N', but select the first tracepoint frame after the
6365 currently selected frame that is a hit of tracepoint T; T is a
6368 `QTFrame:range:START:END'
6369 Like `QTFrame:N', but select the first tracepoint frame after the
6370 currently selected frame whose PC is between START (inclusive) and
6371 END (exclusive); START and END are hexidecimal numbers.
6373 `QTFrame:outside:START:END'
6374 Like `QTFrame:range:START:END', but select the first frame
6375 _outside_ the given range of addresses.
6378 Begin the tracepoint experiment. Begin collecting data from
6379 tracepoint hits in the trace frame buffer.
6382 End the tracepoint experiment. Stop collecting trace frames.
6385 Clear the table of tracepoints, and empty the trace frame buffer.
6387 `QTro:START1,END1:START2,END2:...'
6388 Establish the given ranges of memory as "transparent". The stub
6389 will answer requests for these ranges from memory's current
6390 contents, if they were not collected as part of the tracepoint hit.
6392 GDB uses this to mark read-only regions of memory, like those
6393 containing program code. Since these areas never change, they
6394 should still have the same contents they did when the tracepoint
6395 was hit, so there's no reason for the stub to refuse to provide
6399 Ask the stub if there is a trace experiment running right now.
6403 There is no trace experiment running.
6406 There is a trace experiment running.
6410 File: gdb.info, Node: Interrupts, Next: Examples, Prev: Tracepoint Packets, Up: Remote Protocol
6415 When a program on the remote target is running, GDB may attempt to
6416 interrupt it by sending a `Ctrl-C' or a `BREAK', control of which is
6417 specified via GDB's `remotebreak' setting (*note set remotebreak::).
6419 The precise meaning of `BREAK' is defined by the transport mechanism
6420 and may, in fact, be undefined. GDB does not currently define a
6421 `BREAK' mechanism for any of the network interfaces.
6423 `Ctrl-C', on the other hand, is defined and implemented for all
6424 transport mechanisms. It is represented by sending the single byte
6425 `0x03' without any of the usual packet overhead described in the
6426 Overview section (*note Overview::). When a `0x03' byte is transmitted
6427 as part of a packet, it is considered to be packet data and does _not_
6428 represent an interrupt. E.g., an `X' packet (*note X packet::, used
6429 for binary downloads, may include an unescaped `0x03' as part of its
6432 Stubs are not required to recognize these interrupt mechanisms and
6433 the precise meaning associated with receipt of the interrupt is
6434 implementation defined. If the stub is successful at interrupting the
6435 running program, it is expected that it will send one of the Stop Reply
6436 Packets (*note Stop Reply Packets::) to GDB as a result of successfully
6437 stopping the program. Interrupts received while the program is stopped
6441 File: gdb.info, Node: Examples, Next: File-I/O remote protocol extension, Prev: Interrupts, Up: Remote Protocol
6446 Example sequence of a target being re-started. Notice how the restart
6447 does not get any direct output:
6454 <- `T001:1234123412341234'
6457 Example sequence of a target being stepped by a single instruction:
6464 <- `T001:1234123412341234'
6472 File: gdb.info, Node: File-I/O remote protocol extension, Prev: Examples, Up: Remote Protocol
6474 D.9 File-I/O remote protocol extension
6475 ======================================
6479 * File-I/O Overview::
6481 * The F request packet::
6482 * The F reply packet::
6484 * The Ctrl-C message::
6488 * List of supported calls::
6489 * Protocol specific representation of datatypes::
6491 * File-I/O Examples::
6494 File: gdb.info, Node: File-I/O Overview, Next: Protocol basics, Up: File-I/O remote protocol extension
6496 D.9.1 File-I/O Overview
6497 -----------------------
6499 The "File I/O remote protocol extension" (short: File-I/O) allows the
6500 target to use the host's file system and console I/O when calling
6501 various system calls. System calls on the target system are translated
6502 into a remote protocol packet to the host system which then performs
6503 the needed actions and returns with an adequate response packet to the
6504 target system. This simulates file system operations even on targets
6505 that lack file systems.
6507 The protocol is defined host- and target-system independent. It uses
6508 its own independent representation of datatypes and values. Both, GDB
6509 and the target's GDB stub are responsible for translating the system
6510 dependent values into the unified protocol values when data is
6513 The communication is synchronous. A system call is possible only
6514 when GDB is waiting for the `C', `c', `S' or `s' packets. While GDB
6515 handles the request for a system call, the target is stopped to allow
6516 deterministic access to the target's memory. Therefore File-I/O is not
6517 interuptible by target signals. It is possible to interrupt File-I/O
6518 by a user interrupt (Ctrl-C), though.
6520 The target's request to perform a host system call does not finish
6521 the latest `C', `c', `S' or `s' action. That means, after finishing
6522 the system call, the target returns to continuing the previous activity
6523 (continue, step). No additional continue or step request from GDB is
6527 <- target requests 'system call X'
6528 target is stopped, GDB executes system call
6529 -> GDB returns result
6530 ... target continues, GDB returns to wait for the target
6531 <- target hits breakpoint and sends a Txx packet
6533 The protocol is only used for files on the host file system and for
6534 I/O on the console. Character or block special devices, pipes, named
6535 pipes or sockets or any other communication method on the host system
6536 are not supported by this protocol.
6539 File: gdb.info, Node: Protocol basics, Next: The F request packet, Prev: File-I/O Overview, Up: File-I/O remote protocol extension
6541 D.9.2 Protocol basics
6542 ---------------------
6544 The File-I/O protocol uses the `F' packet, as request as well as as
6545 reply packet. Since a File-I/O system call can only occur when GDB is
6546 waiting for the continuing or stepping target, the File-I/O request is
6547 a reply that GDB has to expect as a result of a former `C', `c', `S' or
6548 `s' packet. This `F' packet contains all information needed to allow
6549 GDB to call the appropriate host system call:
6551 * A unique identifier for the requested system call.
6553 * All parameters to the system call. Pointers are given as addresses
6554 in the target memory address space. Pointers to strings are given
6555 as pointer/length pair. Numerical values are given as they are.
6556 Numerical control values are given in a protocol specific
6560 At that point GDB has to perform the following actions.
6562 * If parameter pointer values are given, which point to data needed
6563 as input to a system call, GDB requests this data from the target
6564 with a standard `m' packet request. This additional communication
6565 has to be expected by the target implementation and is handled as
6566 any other `m' packet.
6568 * GDB translates all value from protocol representation to host
6569 representation as needed. Datatypes are coerced into the host
6572 * GDB calls the system call
6574 * It then coerces datatypes back to protocol representation.
6576 * If pointer parameters in the request packet point to buffer space
6577 in which a system call is expected to copy data to, the data is
6578 transmitted to the target using a `M' or `X' packet. This packet
6579 has to be expected by the target implementation and is handled as
6580 any other `M' or `X' packet.
6583 Eventually GDB replies with another `F' packet which contains all
6584 necessary information for the target to continue. This at least
6589 * `errno', if has been changed by the system call.
6594 After having done the needed type and value coercion, the target
6595 continues the latest continue or step action.
6598 File: gdb.info, Node: The F request packet, Next: The F reply packet, Prev: Protocol basics, Up: File-I/O remote protocol extension
6600 D.9.3 The `F' request packet
6601 ----------------------------
6603 The `F' request packet has the following format:
6605 `F'CALL-ID`,'PARAMETER...
6607 CALL-ID is the identifier to indicate the host system call to be
6608 called. This is just the name of the function.
6610 PARAMETER... are the parameters to the system call.
6613 Parameters are hexadecimal integer values, either the real values in
6614 case of scalar datatypes, as pointers to target buffer space in case of
6615 compound datatypes and unspecified memory areas or as pointer/length
6616 pairs in case of string parameters. These are appended to the call-id,
6617 each separated from its predecessor by a comma. All values are
6618 transmitted in ASCII string representation, pointer/length pairs
6619 separated by a slash.
6622 File: gdb.info, Node: The F reply packet, Next: Memory transfer, Prev: The F request packet, Up: File-I/O remote protocol extension
6624 D.9.4 The `F' reply packet
6625 --------------------------
6627 The `F' reply packet has the following format:
6629 `F'RETCODE`,'ERRNO`,'CTRL-C FLAG`;'CALL SPECIFIC ATTACHMENT
6631 RETCODE is the return code of the system call as hexadecimal value.
6633 ERRNO is the errno set by the call, in protocol specific
6634 representation. This parameter can be omitted if the call was
6637 CTRL-C FLAG is only send if the user requested a break. In this
6638 case, ERRNO must be send as well, even if the call was successful.
6639 The CTRL-C FLAG itself consists of the character 'C':
6643 or, if the call was interupted before the host call has been
6648 assuming 4 is the protocol specific representation of `EINTR'.
6652 File: gdb.info, Node: Memory transfer, Next: The Ctrl-C message, Prev: The F reply packet, Up: File-I/O remote protocol extension
6654 D.9.5 Memory transfer
6655 ---------------------
6657 Structured data which is transferred using a memory read or write as
6658 e.g. a `struct stat' is expected to be in a protocol specific format
6659 with all scalar multibyte datatypes being big endian. This should be
6660 done by the target before the `F' packet is sent resp. by GDB before it
6661 transfers memory to the target. Transferred pointers to structured
6662 data should point to the already coerced data at any time.
6665 File: gdb.info, Node: The Ctrl-C message, Next: Console I/O, Prev: Memory transfer, Up: File-I/O remote protocol extension
6667 D.9.6 The Ctrl-C message
6668 ------------------------
6670 A special case is, if the CTRL-C FLAG is set in the GDB reply packet.
6671 In this case the target should behave, as if it had gotten a break
6672 message. The meaning for the target is "system call interupted by
6673 `SIGINT'". Consequentially, the target should actually stop (as with a
6674 break message) and return to GDB with a `T02' packet. In this case,
6675 it's important for the target to know, in which state the system call
6676 was interrupted. Since this action is by design not an atomic
6677 operation, we have to differ between two cases:
6679 * The system call hasn't been performed on the host yet.
6681 * The system call on the host has been finished.
6684 These two states can be distinguished by the target by the value of
6685 the returned `errno'. If it's the protocol representation of `EINTR',
6686 the system call hasn't been performed. This is equivalent to the
6687 `EINTR' handling on POSIX systems. In any other case, the target may
6688 presume that the system call has been finished -- successful or not --
6689 and should behave as if the break message arrived right after the
6692 GDB must behave reliable. If the system call has not been called
6693 yet, GDB may send the `F' reply immediately, setting `EINTR' as `errno'
6694 in the packet. If the system call on the host has been finished before
6695 the user requests a break, the full action must be finshed by GDB.
6696 This requires sending `M' or `X' packets as they fit. The `F' packet
6697 may only be send when either nothing has happened or the full action
6701 File: gdb.info, Node: Console I/O, Next: The isatty call, Prev: The Ctrl-C message, Up: File-I/O remote protocol extension
6706 By default and if not explicitely closed by the target system, the file
6707 descriptors 0, 1 and 2 are connected to the GDB console. Output on the
6708 GDB console is handled as any other file output operation (`write(1,
6709 ...)' or `write(2, ...)'). Console input is handled by GDB so that
6710 after the target read request from file descriptor 0 all following
6711 typing is buffered until either one of the following conditions is met:
6713 * The user presses `Ctrl-C'. The behaviour is as explained above,
6714 the `read' system call is treated as finished.
6716 * The user presses `Enter'. This is treated as end of input with a
6719 * The user presses `Ctrl-D'. This is treated as end of input. No
6720 trailing character, especially no Ctrl-D is appended to the input.
6723 If the user has typed more characters as fit in the buffer given to
6724 the read call, the trailing characters are buffered in GDB until either
6725 another `read(0, ...)' is requested by the target or debugging is
6726 stopped on users request.
6729 File: gdb.info, Node: The isatty call, Next: The system call, Prev: Console I/O, Up: File-I/O remote protocol extension
6731 D.9.8 The `isatty' function call
6732 --------------------------------
6734 A special case in this protocol is the library call `isatty' which is
6735 implemented as its own call inside of this protocol. It returns 1 to
6736 the target if the file descriptor given as parameter is attached to the
6737 GDB console, 0 otherwise. Implementing through system calls would
6738 require implementing `ioctl' and would be more complex than needed.
6741 File: gdb.info, Node: The system call, Next: List of supported calls, Prev: The isatty call, Up: File-I/O remote protocol extension
6743 D.9.9 The `system' function call
6744 --------------------------------
6746 The other special case in this protocol is the `system' call which is
6747 implemented as its own call, too. GDB is taking over the full task of
6748 calling the necessary host calls to perform the `system' call. The
6749 return value of `system' is simplified before it's returned to the
6750 target. Basically, the only signal transmitted back is `EINTR' in case
6751 the user pressed `Ctrl-C'. Otherwise the return value consists
6752 entirely of the exit status of the called command.
6754 Due to security concerns, the `system' call is by default refused by
6755 GDB. The user has to allow this call explicitly with the `set remote
6756 system-call-allowed 1' command.
6758 `set remote system-call-allowed'
6759 Control whether to allow the `system' calls in the File I/O
6760 protocol for the remote target. The default is zero (disabled).
6762 `show remote system-call-allowed'
6763 Show the current setting of system calls for the remote File I/O
6767 File: gdb.info, Node: List of supported calls, Next: Protocol specific representation of datatypes, Prev: The system call, Up: File-I/O remote protocol extension
6769 D.9.10 List of supported calls
6770 ------------------------------
6787 File: gdb.info, Node: open, Next: close, Up: List of supported calls
6793 int open(const char *pathname, int flags);
6794 int open(const char *pathname, int flags, mode_t mode);
6797 Fopen,pathptr/len,flags,mode
6799 `flags' is the bitwise or of the following values:
6802 If the file does not exist it will be created. The host rules
6803 apply as far as file ownership and time stamps are concerned.
6806 When used with O_CREAT, if the file already exists it is an error
6810 If the file already exists and the open mode allows writing
6811 (O_RDWR or O_WRONLY is given) it will be truncated to length 0.
6814 The file is opened in append mode.
6817 The file is opened for reading only.
6820 The file is opened for writing only.
6823 The file is opened for reading and writing.
6825 Each other bit is silently ignored.
6828 `mode' is the bitwise or of the following values:
6831 User has read permission.
6834 User has write permission.
6837 Group has read permission.
6840 Group has write permission.
6843 Others have read permission.
6846 Others have write permission.
6848 Each other bit is silently ignored.
6852 open returns the new file descriptor or -1 if an error
6859 pathname already exists and O_CREAT and O_EXCL were used.
6862 pathname refers to a directory.
6865 The requested access is not allowed.
6868 pathname was too long.
6871 A directory component in pathname does not exist.
6874 pathname refers to a device, pipe, named pipe or socket.
6877 pathname refers to a file on a read-only filesystem and write
6878 access was requested.
6881 pathname is an invalid pointer value.
6884 No space on device to create the file.
6887 The process already has the maximum number of files open.
6890 The limit on the total number of files open on the system has been
6894 The call was interrupted by the user.
6897 File: gdb.info, Node: close, Next: read, Prev: open, Up: List of supported calls
6909 close returns zero on success, or -1 if an error occurred.
6915 fd isn't a valid open file descriptor.
6918 The call was interrupted by the user.
6921 File: gdb.info, Node: read, Next: write, Prev: close, Up: List of supported calls
6927 int read(int fd, void *buf, unsigned int count);
6930 Fread,fd,bufptr,count
6933 On success, the number of bytes read is returned.
6934 Zero indicates end of file. If count is zero, read
6935 returns zero as well. On error, -1 is returned.
6941 fd is not a valid file descriptor or is not open for reading.
6944 buf is an invalid pointer value.
6947 The call was interrupted by the user.
6950 File: gdb.info, Node: write, Next: lseek, Prev: read, Up: List of supported calls
6956 int write(int fd, const void *buf, unsigned int count);
6959 Fwrite,fd,bufptr,count
6962 On success, the number of bytes written are returned.
6963 Zero indicates nothing was written. On error, -1
6970 fd is not a valid file descriptor or is not open for writing.
6973 buf is an invalid pointer value.
6976 An attempt was made to write a file that exceeds the host specific
6977 maximum file size allowed.
6980 No space on device to write the data.
6983 The call was interrupted by the user.
6986 File: gdb.info, Node: lseek, Next: rename, Prev: write, Up: List of supported calls
6992 long lseek (int fd, long offset, int flag);
6995 Flseek,fd,offset,flag
7000 The offset is set to offset bytes.
7003 The offset is set to its current location plus offset bytes.
7006 The offset is set to the size of the file plus offset bytes.
7009 On success, the resulting unsigned offset in bytes from
7010 the beginning of the file is returned. Otherwise, a
7011 value of -1 is returned.
7017 fd is not a valid open file descriptor.
7020 fd is associated with the GDB console.
7023 flag is not a proper value.
7026 The call was interrupted by the user.
7029 File: gdb.info, Node: rename, Next: unlink, Prev: lseek, Up: List of supported calls
7035 int rename(const char *oldpath, const char *newpath);
7038 Frename,oldpathptr/len,newpathptr/len
7041 On success, zero is returned. On error, -1 is returned.
7047 newpath is an existing directory, but oldpath is not a directory.
7050 newpath is a non-empty directory.
7053 oldpath or newpath is a directory that is in use by some process.
7056 An attempt was made to make a directory a subdirectory of itself.
7059 A component used as a directory in oldpath or new path is not a
7060 directory. Or oldpath is a directory and newpath exists but is
7064 oldpathptr or newpathptr are invalid pointer values.
7067 No access to the file or the path of the file.
7070 oldpath or newpath was too long.
7073 A directory component in oldpath or newpath does not exist.
7076 The file is on a read-only filesystem.
7079 The device containing the file has no room for the new directory
7083 The call was interrupted by the user.
7086 File: gdb.info, Node: unlink, Next: stat/fstat, Prev: rename, Up: List of supported calls
7092 int unlink(const char *pathname);
7095 Funlink,pathnameptr/len
7098 On success, zero is returned. On error, -1 is returned.
7104 No access to the file or the path of the file.
7107 The system does not allow unlinking of directories.
7110 The file pathname cannot be unlinked because it's being used by
7114 pathnameptr is an invalid pointer value.
7117 pathname was too long.
7120 A directory component in pathname does not exist.
7123 A component of the path is not a directory.
7126 The file is on a read-only filesystem.
7129 The call was interrupted by the user.
7132 File: gdb.info, Node: stat/fstat, Next: gettimeofday, Prev: unlink, Up: List of supported calls
7138 int stat(const char *pathname, struct stat *buf);
7139 int fstat(int fd, struct stat *buf);
7142 Fstat,pathnameptr/len,bufptr
7146 On success, zero is returned. On error, -1 is returned.
7152 fd is not a valid open file.
7155 A directory component in pathname does not exist or the path is an
7159 A component of the path is not a directory.
7162 pathnameptr is an invalid pointer value.
7165 No access to the file or the path of the file.
7168 pathname was too long.
7171 The call was interrupted by the user.
7174 File: gdb.info, Node: gettimeofday, Next: isatty, Prev: stat/fstat, Up: List of supported calls
7180 int gettimeofday(struct timeval *tv, void *tz);
7183 Fgettimeofday,tvptr,tzptr
7186 On success, 0 is returned, -1 otherwise.
7192 tz is a non-NULL pointer.
7195 tvptr and/or tzptr is an invalid pointer value.
7198 File: gdb.info, Node: isatty, Next: system, Prev: gettimeofday, Up: List of supported calls
7210 Returns 1 if fd refers to the GDB console, 0 otherwise.
7216 The call was interrupted by the user.
7219 File: gdb.info, Node: system, Prev: isatty, Up: List of supported calls
7225 int system(const char *command);
7228 Fsystem,commandptr/len
7231 The value returned is -1 on error and the return status
7232 of the command otherwise. Only the exit status of the
7233 command is returned, which is extracted from the hosts
7234 system return value by calling WEXITSTATUS(retval).
7235 In case /bin/sh could not be executed, 127 is returned.
7241 The call was interrupted by the user.
7244 File: gdb.info, Node: Protocol specific representation of datatypes, Next: Constants, Prev: List of supported calls, Up: File-I/O remote protocol extension
7246 D.9.11 Protocol specific representation of datatypes
7247 ----------------------------------------------------
7251 * Integral datatypes::
7257 File: gdb.info, Node: Integral datatypes, Next: Pointer values, Up: Protocol specific representation of datatypes
7262 The integral datatypes used in the system calls are
7264 int, unsigned int, long, unsigned long, mode_t and time_t
7266 `Int', `unsigned int', `mode_t' and `time_t' are implemented as 32
7267 bit values in this protocol.
7269 `Long' and `unsigned long' are implemented as 64 bit types.
7271 *Note Limits::, for corresponding MIN and MAX values (similar to
7272 those in `limits.h') to allow range checking on host and target.
7274 `time_t' datatypes are defined as seconds since the Epoch.
7276 All integral datatypes transferred as part of a memory read or write
7277 of a structured datatype e.g. a `struct stat' have to be given in big
7281 File: gdb.info, Node: Pointer values, Next: struct stat, Prev: Integral datatypes, Up: Protocol specific representation of datatypes
7286 Pointers to target data are transmitted as they are. An exception is
7287 made for pointers to buffers for which the length isn't transmitted as
7288 part of the function call, namely strings. Strings are transmitted as
7289 a pointer/length pair, both as hex values, e.g.
7293 which is a pointer to data of length 18 bytes at position 0x1aaf. The
7294 length is defined as the full string length in bytes, including the
7295 trailing null byte. Example:
7297 ``hello, world'' at address 0x123456
7304 File: gdb.info, Node: struct stat, Next: struct timeval, Prev: Pointer values, Up: Protocol specific representation of datatypes
7309 The buffer of type struct stat used by the target and GDB is defined as
7313 unsigned int st_dev; /* device */
7314 unsigned int st_ino; /* inode */
7315 mode_t st_mode; /* protection */
7316 unsigned int st_nlink; /* number of hard links */
7317 unsigned int st_uid; /* user ID of owner */
7318 unsigned int st_gid; /* group ID of owner */
7319 unsigned int st_rdev; /* device type (if inode device) */
7320 unsigned long st_size; /* total size, in bytes */
7321 unsigned long st_blksize; /* blocksize for filesystem I/O */
7322 unsigned long st_blocks; /* number of blocks allocated */
7323 time_t st_atime; /* time of last access */
7324 time_t st_mtime; /* time of last modification */
7325 time_t st_ctime; /* time of last change */
7328 The integral datatypes are conforming to the definitions given in the
7329 approriate section (see *Note Integral datatypes::, for details) so this
7330 structure is of size 64 bytes.
7332 The values of several fields have a restricted meaning and/or range
7338 st_ino: No valid meaning for the target. Transmitted unchanged.
7340 st_mode: Valid mode bits are described in Appendix C. Any other
7341 bits have currently no meaning for the target.
7343 st_uid: No valid meaning for the target. Transmitted unchanged.
7345 st_gid: No valid meaning for the target. Transmitted unchanged.
7347 st_rdev: No valid meaning for the target. Transmitted unchanged.
7349 st_atime, st_mtime, st_ctime:
7350 These values have a host and file system dependent
7351 accuracy. Especially on Windows hosts the file systems
7352 don't support exact timing values.
7354 The target gets a struct stat of the above representation and is
7355 responsible to coerce it to the target representation before continuing.
7357 Note that due to size differences between the host and target
7358 representation of stat members, these members could eventually get
7359 truncated on the target.
7362 File: gdb.info, Node: struct timeval, Prev: struct stat, Up: Protocol specific representation of datatypes
7367 The buffer of type struct timeval used by the target and GDB is defined
7371 time_t tv_sec; /* second */
7372 long tv_usec; /* microsecond */
7375 The integral datatypes are conforming to the definitions given in the
7376 approriate section (see *Note Integral datatypes::, for details) so this
7377 structure is of size 8 bytes.
7380 File: gdb.info, Node: Constants, Next: File-I/O Examples, Prev: Protocol specific representation of datatypes, Up: File-I/O remote protocol extension
7385 The following values are used for the constants inside of the protocol.
7386 GDB and target are resposible to translate these values before and
7387 after the call as needed.
7398 File: gdb.info, Node: Open flags, Next: mode_t values, Up: Constants
7403 All values are given in hexadecimal representation.
7414 File: gdb.info, Node: mode_t values, Next: Errno values, Prev: Open flags, Up: Constants
7419 All values are given in octal representation.
7434 File: gdb.info, Node: Errno values, Next: Lseek flags, Prev: mode_t values, Up: Constants
7439 All values are given in decimal representation.
7462 EUNKNOWN is used as a fallback error value if a host system returns
7463 any error value not in the list of supported error numbers.
7466 File: gdb.info, Node: Lseek flags, Next: Limits, Prev: Errno values, Up: Constants
7476 File: gdb.info, Node: Limits, Prev: Lseek flags, Up: Constants
7481 All values are given in decimal representation.
7486 LONG_MIN -9223372036854775808
7487 LONG_MAX 9223372036854775807
7488 ULONG_MAX 18446744073709551615
7491 File: gdb.info, Node: File-I/O Examples, Prev: Constants, Up: File-I/O remote protocol extension
7493 D.9.13 File-I/O Examples
7494 ------------------------
7496 Example sequence of a write call, file descriptor 3, buffer is at target
7497 address 0x1234, 6 bytes should be written:
7499 <- `Fwrite,3,1234,6'
7500 _request memory read from target_
7503 _return "6 bytes written"_
7506 Example sequence of a read call, file descriptor 3, buffer is at
7507 target address 0x1234, 6 bytes should be read:
7510 _request memory write to target_
7512 _return "6 bytes read"_
7515 Example sequence of a read call, call fails on the host due to
7516 invalid file descriptor (EBADF):
7521 Example sequence of a read call, user presses Ctrl-C before syscall
7528 Example sequence of a read call, user presses Ctrl-C after syscall on
7536 File: gdb.info, Node: Agent Expressions, Next: Copying, Prev: Remote Protocol, Up: Top
7538 Appendix E The GDB Agent Expression Mechanism
7539 *********************************************
7541 In some applications, it is not feasable for the debugger to interrupt
7542 the program's execution long enough for the developer to learn anything
7543 helpful about its behavior. If the program's correctness depends on its
7544 real-time behavior, delays introduced by a debugger might cause the
7545 program to fail, even when the code itself is correct. It is useful to
7546 be able to observe the program's behavior without interrupting it.
7548 Using GDB's `trace' and `collect' commands, the user can specify
7549 locations in the program, and arbitrary expressions to evaluate when
7550 those locations are reached. Later, using the `tfind' command, she can
7551 examine the values those expressions had when the program hit the trace
7552 points. The expressions may also denote objects in memory --
7553 structures or arrays, for example -- whose values GDB should record;
7554 while visiting a particular tracepoint, the user may inspect those
7555 objects as if they were in memory at that moment. However, because GDB
7556 records these values without interacting with the user, it can do so
7557 quickly and unobtrusively, hopefully not disturbing the program's
7560 When GDB is debugging a remote target, the GDB "agent" code running
7561 on the target computes the values of the expressions itself. To avoid
7562 having a full symbolic expression evaluator on the agent, GDB translates
7563 expressions in the source language into a simpler bytecode language, and
7564 then sends the bytecode to the agent; the agent then executes the
7565 bytecode, and records the values for GDB to retrieve later.
7567 The bytecode language is simple; there are forty-odd opcodes, the
7568 bulk of which are the usual vocabulary of C operands (addition,
7569 subtraction, shifts, and so on) and various sizes of literals and
7570 memory reference operations. The bytecode interpreter operates
7571 strictly on machine-level values -- various sizes of integers and
7572 floating point numbers -- and requires no information about types or
7573 symbols; thus, the interpreter's internal data structures are simple,
7574 and each bytecode requires only a few native machine instructions to
7575 implement it. The interpreter is small, and strict limits on the
7576 memory and time required to evaluate an expression are easy to
7577 determine, making it suitable for use by the debugging agent in
7578 real-time applications.
7582 * General Bytecode Design:: Overview of the interpreter.
7583 * Bytecode Descriptions:: What each one does.
7584 * Using Agent Expressions:: How agent expressions fit into the big picture.
7585 * Varying Target Capabilities:: How to discover what the target can do.
7586 * Tracing on Symmetrix:: Special info for implementation on EMC's
7588 * Rationale:: Why we did it this way.
7591 File: gdb.info, Node: General Bytecode Design, Next: Bytecode Descriptions, Up: Agent Expressions
7593 E.1 General Bytecode Design
7594 ===========================
7596 The agent represents bytecode expressions as an array of bytes. Each
7597 instruction is one byte long (thus the term "bytecode"). Some
7598 instructions are followed by operand bytes; for example, the `goto'
7599 instruction is followed by a destination for the jump.
7601 The bytecode interpreter is a stack-based machine; most instructions
7602 pop their operands off the stack, perform some operation, and push the
7603 result back on the stack for the next instruction to consume. Each
7604 element of the stack may contain either a integer or a floating point
7605 value; these values are as many bits wide as the largest integer that
7606 can be directly manipulated in the source language. Stack elements
7607 carry no record of their type; bytecode could push a value as an
7608 integer, then pop it as a floating point value. However, GDB will not
7609 generate code which does this. In C, one might define the type of a
7610 stack element as follows:
7615 where `LONGEST' and `DOUBLEST' are `typedef' names for the largest
7616 integer and floating point types on the machine.
7618 By the time the bytecode interpreter reaches the end of the
7619 expression, the value of the expression should be the only value left
7620 on the stack. For tracing applications, `trace' bytecodes in the
7621 expression will have recorded the necessary data, and the value on the
7622 stack may be discarded. For other applications, like conditional
7623 breakpoints, the value may be useful.
7625 Separate from the stack, the interpreter has two registers:
7627 The address of the next bytecode to execute.
7630 The address of the start of the bytecode expression, necessary for
7631 interpreting the `goto' and `if_goto' instructions.
7633 Neither of these registers is directly visible to the bytecode
7634 language itself, but they are useful for defining the meanings of the
7635 bytecode operations.
7637 There are no instructions to perform side effects on the running
7638 program, or call the program's functions; we assume that these
7639 expressions are only used for unobtrusive debugging, not for patching
7642 Most bytecode instructions do not distinguish between the various
7643 sizes of values, and operate on full-width values; the upper bits of the
7644 values are simply ignored, since they do not usually make a difference
7645 to the value computed. The exceptions to this rule are:
7646 memory reference instructions (`ref'N)
7647 There are distinct instructions to fetch different word sizes from
7648 memory. Once on the stack, however, the values are treated as
7649 full-size integers. They may need to be sign-extended; the `ext'
7650 instruction exists for this purpose.
7652 the sign-extension instruction (`ext' N)
7653 These clearly need to know which portion of their operand is to be
7654 extended to occupy the full length of the word.
7657 If the interpreter is unable to evaluate an expression completely for
7658 some reason (a memory location is inaccessible, or a divisor is zero,
7659 for example), we say that interpretation "terminates with an error".
7660 This means that the problem is reported back to the interpreter's caller
7661 in some helpful way. In general, code using agent expressions should
7662 assume that they may attempt to divide by zero, fetch arbitrary memory
7663 locations, and misbehave in other ways.
7665 Even complicated C expressions compile to a few bytecode
7666 instructions; for example, the expression `x + y * z' would typically
7667 produce code like the following, assuming that `x' and `y' live in
7668 registers, and `z' is a global variable holding a 32-bit `int':
7671 const32 address of z
7678 In detail, these mean:
7680 Push the value of register 1 (presumably holding `x') onto the
7684 Push the value of register 2 (holding `y').
7686 `const32 address of z'
7687 Push the address of `z' onto the stack.
7690 Fetch a 32-bit word from the address at the top of the stack;
7691 replace the address on the stack with the value. Thus, we replace
7692 the address of `z' with `z''s value.
7695 Sign-extend the value on the top of the stack from 32 bits to full
7696 length. This is necessary because `z' is a signed integer.
7699 Pop the top two numbers on the stack, multiply them, and push their
7700 product. Now the top of the stack contains the value of the
7704 Pop the top two numbers, add them, and push the sum. Now the top
7705 of the stack contains the value of `x + y * z'.
7708 Stop executing; the value left on the stack top is the value to be
7713 File: gdb.info, Node: Bytecode Descriptions, Next: Using Agent Expressions, Prev: General Bytecode Design, Up: Agent Expressions
7715 E.2 Bytecode Descriptions
7716 =========================
7718 Each bytecode description has the following form:
7720 `add' (0x02): A B => A+B
7721 Pop the top two stack items, A and B, as integers; push their sum,
7725 In this example, `add' is the name of the bytecode, and `(0x02)' is
7726 the one-byte value used to encode the bytecode, in hexidecimal. The
7727 phrase "A B => A+B" shows the stack before and after the bytecode
7728 executes. Beforehand, the stack must contain at least two values, A
7729 and B; since the top of the stack is to the right, B is on the top of
7730 the stack, and A is underneath it. After execution, the bytecode will
7731 have popped A and B from the stack, and replaced them with a single
7732 value, A+B. There may be other values on the stack below those shown,
7733 but the bytecode affects only those shown.
7735 Here is another example:
7737 `const8' (0x22) N: => N
7738 Push the 8-bit integer constant N on the stack, without sign
7742 In this example, the bytecode `const8' takes an operand N directly
7743 from the bytecode stream; the operand follows the `const8' bytecode
7744 itself. We write any such operands immediately after the name of the
7745 bytecode, before the colon, and describe the exact encoding of the
7746 operand in the bytecode stream in the body of the bytecode description.
7748 For the `const8' bytecode, there are no stack items given before the
7749 =>; this simply means that the bytecode consumes no values from the
7750 stack. If a bytecode consumes no values, or produces no values, the
7751 list on either side of the => may be empty.
7753 If a value is written as A, B, or N, then the bytecode treats it as
7754 an integer. If a value is written is ADDR, then the bytecode treats it
7757 We do not fully describe the floating point operations here; although
7758 this design can be extended in a clean way to handle floating point
7759 values, they are not of immediate interest to the customer, so we avoid
7760 describing them, to save time.
7763 Prefix for floating-point bytecodes. Not implemented yet.
7765 `add' (0x02): A B => A+B
7766 Pop two integers from the stack, and push their sum, as an integer.
7768 `sub' (0x03): A B => A-B
7769 Pop two integers from the stack, subtract the top value from the
7770 next-to-top value, and push the difference.
7772 `mul' (0x04): A B => A*B
7773 Pop two integers from the stack, multiply them, and push the
7774 product on the stack. Note that, when one multiplies two N-bit
7775 numbers yielding another N-bit number, it is irrelevant whether the
7776 numbers are signed or not; the results are the same.
7778 `div_signed' (0x05): A B => A/B
7779 Pop two signed integers from the stack; divide the next-to-top
7780 value by the top value, and push the quotient. If the divisor is
7781 zero, terminate with an error.
7783 `div_unsigned' (0x06): A B => A/B
7784 Pop two unsigned integers from the stack; divide the next-to-top
7785 value by the top value, and push the quotient. If the divisor is
7786 zero, terminate with an error.
7788 `rem_signed' (0x07): A B => A MODULO B
7789 Pop two signed integers from the stack; divide the next-to-top
7790 value by the top value, and push the remainder. If the divisor is
7791 zero, terminate with an error.
7793 `rem_unsigned' (0x08): A B => A MODULO B
7794 Pop two unsigned integers from the stack; divide the next-to-top
7795 value by the top value, and push the remainder. If the divisor is
7796 zero, terminate with an error.
7798 `lsh' (0x09): A B => A<<B
7799 Pop two integers from the stack; let A be the next-to-top value,
7800 and B be the top value. Shift A left by B bits, and push the
7803 `rsh_signed' (0x0a): A B => `(signed)'A>>B
7804 Pop two integers from the stack; let A be the next-to-top value,
7805 and B be the top value. Shift A right by B bits, inserting copies
7806 of the top bit at the high end, and push the result.
7808 `rsh_unsigned' (0x0b): A B => A>>B
7809 Pop two integers from the stack; let A be the next-to-top value,
7810 and B be the top value. Shift A right by B bits, inserting zero
7811 bits at the high end, and push the result.
7813 `log_not' (0x0e): A => !A
7814 Pop an integer from the stack; if it is zero, push the value one;
7815 otherwise, push the value zero.
7817 `bit_and' (0x0f): A B => A&B
7818 Pop two integers from the stack, and push their bitwise `and'.
7820 `bit_or' (0x10): A B => A|B
7821 Pop two integers from the stack, and push their bitwise `or'.
7823 `bit_xor' (0x11): A B => A^B
7824 Pop two integers from the stack, and push their bitwise
7827 `bit_not' (0x12): A => ~A
7828 Pop an integer from the stack, and push its bitwise complement.
7830 `equal' (0x13): A B => A=B
7831 Pop two integers from the stack; if they are equal, push the value
7832 one; otherwise, push the value zero.
7834 `less_signed' (0x14): A B => A<B
7835 Pop two signed integers from the stack; if the next-to-top value
7836 is less than the top value, push the value one; otherwise, push
7839 `less_unsigned' (0x15): A B => A<B
7840 Pop two unsigned integers from the stack; if the next-to-top value
7841 is less than the top value, push the value one; otherwise, push
7844 `ext' (0x16) N: A => A, sign-extended from N bits
7845 Pop an unsigned value from the stack; treating it as an N-bit
7846 twos-complement value, extend it to full length. This means that
7847 all bits to the left of bit N-1 (where the least significant bit
7848 is bit 0) are set to the value of bit N-1. Note that N may be
7849 larger than or equal to the width of the stack elements of the
7850 bytecode engine; in this case, the bytecode should have no effect.
7852 The number of source bits to preserve, N, is encoded as a single
7853 byte unsigned integer following the `ext' bytecode.
7855 `zero_ext' (0x2a) N: A => A, zero-extended from N bits
7856 Pop an unsigned value from the stack; zero all but the bottom N
7857 bits. This means that all bits to the left of bit N-1 (where the
7858 least significant bit is bit 0) are set to the value of bit N-1.
7860 The number of source bits to preserve, N, is encoded as a single
7861 byte unsigned integer following the `zero_ext' bytecode.
7863 `ref8' (0x17): ADDR => A
7864 `ref16' (0x18): ADDR => A
7865 `ref32' (0x19): ADDR => A
7866 `ref64' (0x1a): ADDR => A
7867 Pop an address ADDR from the stack. For bytecode `ref'N, fetch an
7868 N-bit value from ADDR, using the natural target endianness. Push
7869 the fetched value as an unsigned integer.
7871 Note that ADDR may not be aligned in any particular way; the
7872 `refN' bytecodes should operate correctly for any address.
7874 If attempting to access memory at ADDR would cause a processor
7875 exception of some sort, terminate with an error.
7877 `ref_float' (0x1b): ADDR => D
7878 `ref_double' (0x1c): ADDR => D
7879 `ref_long_double' (0x1d): ADDR => D
7880 `l_to_d' (0x1e): A => D
7881 `d_to_l' (0x1f): D => A
7882 Not implemented yet.
7884 `dup' (0x28): A => A A
7885 Push another copy of the stack's top element.
7887 `swap' (0x2b): A B => B A
7888 Exchange the top two items on the stack.
7891 Discard the top value on the stack.
7893 `if_goto' (0x20) OFFSET: A =>
7894 Pop an integer off the stack; if it is non-zero, branch to the
7895 given offset in the bytecode string. Otherwise, continue to the
7896 next instruction in the bytecode stream. In other words, if A is
7897 non-zero, set the `pc' register to `start' + OFFSET. Thus, an
7898 offset of zero denotes the beginning of the expression.
7900 The OFFSET is stored as a sixteen-bit unsigned value, stored
7901 immediately following the `if_goto' bytecode. It is always stored
7902 most significant byte first, regardless of the target's normal
7903 endianness. The offset is not guaranteed to fall at any particular
7904 alignment within the bytecode stream; thus, on machines where
7905 fetching a 16-bit on an unaligned address raises an exception, you
7906 should fetch the offset one byte at a time.
7908 `goto' (0x21) OFFSET: =>
7909 Branch unconditionally to OFFSET; in other words, set the `pc'
7910 register to `start' + OFFSET.
7912 The offset is stored in the same way as for the `if_goto' bytecode.
7914 `const8' (0x22) N: => N
7915 `const16' (0x23) N: => N
7916 `const32' (0x24) N: => N
7917 `const64' (0x25) N: => N
7918 Push the integer constant N on the stack, without sign extension.
7919 To produce a small negative value, push a small twos-complement
7920 value, and then sign-extend it using the `ext' bytecode.
7922 The constant N is stored in the appropriate number of bytes
7923 following the `const'B bytecode. The constant N is always stored
7924 most significant byte first, regardless of the target's normal
7925 endianness. The constant is not guaranteed to fall at any
7926 particular alignment within the bytecode stream; thus, on machines
7927 where fetching a 16-bit on an unaligned address raises an
7928 exception, you should fetch N one byte at a time.
7930 `reg' (0x26) N: => A
7931 Push the value of register number N, without sign extension. The
7932 registers are numbered following GDB's conventions.
7934 The register number N is encoded as a 16-bit unsigned integer
7935 immediately following the `reg' bytecode. It is always stored most
7936 significant byte first, regardless of the target's normal
7937 endianness. The register number is not guaranteed to fall at any
7938 particular alignment within the bytecode stream; thus, on machines
7939 where fetching a 16-bit on an unaligned address raises an
7940 exception, you should fetch the register number one byte at a time.
7942 `trace' (0x0c): ADDR SIZE =>
7943 Record the contents of the SIZE bytes at ADDR in a trace buffer,
7944 for later retrieval by GDB.
7946 `trace_quick' (0x0d) SIZE: ADDR => ADDR
7947 Record the contents of the SIZE bytes at ADDR in a trace buffer,
7948 for later retrieval by GDB. SIZE is a single byte unsigned
7949 integer following the `trace' opcode.
7951 This bytecode is equivalent to the sequence `dup const8 SIZE
7952 trace', but we provide it anyway to save space in bytecode strings.
7954 `trace16' (0x30) SIZE: ADDR => ADDR
7955 Identical to trace_quick, except that SIZE is a 16-bit big-endian
7956 unsigned integer, not a single byte. This should probably have
7957 been named `trace_quick16', for consistency.
7960 Stop executing bytecode; the result should be the top element of
7961 the stack. If the purpose of the expression was to compute an
7962 lvalue or a range of memory, then the next-to-top of the stack is
7963 the lvalue's address, and the top of the stack is the lvalue's
7968 File: gdb.info, Node: Using Agent Expressions, Next: Varying Target Capabilities, Prev: Bytecode Descriptions, Up: Agent Expressions
7970 E.3 Using Agent Expressions
7971 ===========================
7973 Here is a sketch of a full non-stop debugging cycle, showing how agent
7974 expressions fit into the process.
7976 * The user selects trace points in the program's code at which GDB
7977 should collect data.
7979 * The user specifies expressions to evaluate at each trace point.
7980 These expressions may denote objects in memory, in which case
7981 those objects' contents are recorded as the program runs, or
7982 computed values, in which case the values themselves are recorded.
7984 * GDB transmits the tracepoints and their associated expressions to
7985 the GDB agent, running on the debugging target.
7987 * The agent arranges to be notified when a trace point is hit. Note
7988 that, on some systems, the target operating system is completely
7989 responsible for collecting the data; see *Note Tracing on
7992 * When execution on the target reaches a trace point, the agent
7993 evaluates the expressions associated with that trace point, and
7994 records the resulting values and memory ranges.
7996 * Later, when the user selects a given trace event and inspects the
7997 objects and expression values recorded, GDB talks to the agent to
7998 retrieve recorded data as necessary to meet the user's requests.
7999 If the user asks to see an object whose contents have not been
8000 recorded, GDB reports an error.
8004 File: gdb.info, Node: Varying Target Capabilities, Next: Tracing on Symmetrix, Prev: Using Agent Expressions, Up: Agent Expressions
8006 E.4 Varying Target Capabilities
8007 ===============================
8009 Some targets don't support floating-point, and some would rather not
8010 have to deal with `long long' operations. Also, different targets will
8011 have different stack sizes, and different bytecode buffer lengths.
8013 Thus, GDB needs a way to ask the target about itself. We haven't
8014 worked out the details yet, but in general, GDB should be able to send
8015 the target a packet asking it to describe itself. The reply should be a
8016 packet whose length is explicit, so we can add new information to the
8017 packet in future revisions of the agent, without confusing old versions
8018 of GDB, and it should contain a version number. It should contain at
8019 least the following information:
8021 * whether floating point is supported
8023 * whether `long long' is supported
8025 * maximum acceptable size of bytecode stack
8027 * maximum acceptable length of bytecode expressions
8029 * which registers are actually available for collection
8031 * whether the target supports disabled tracepoints
8035 File: gdb.info, Node: Tracing on Symmetrix, Next: Rationale, Prev: Varying Target Capabilities, Up: Agent Expressions
8037 E.5 Tracing on Symmetrix
8038 ========================
8040 This section documents the API used by the GDB agent to collect data on
8043 Cygnus originally implemented these tracing features to help EMC
8044 Corporation debug their Symmetrix high-availability disk drives. The
8045 Symmetrix application code already includes substantial tracing
8046 facilities; the GDB agent for the Symmetrix system uses those facilities
8047 for its own data collection, via the API described here.
8049 -- Function: DTC_RESPONSE adbg_find_memory_in_frame (FRAME_DEF *FRAME,
8050 char *ADDRESS, char **BUFFER, unsigned int *SIZE)
8051 Search the trace frame FRAME for memory saved from ADDRESS. If
8052 the memory is available, provide the address of the buffer holding
8053 it; otherwise, provide the address of the next saved area.
8055 * If the memory at ADDRESS was saved in FRAME, set `*BUFFER' to
8056 point to the buffer in which that memory was saved, set
8057 `*SIZE' to the number of bytes from ADDRESS that are saved at
8058 `*BUFFER', and return `OK_TARGET_RESPONSE'. (Clearly, in
8059 this case, the function will always set `*SIZE' to a value
8062 * If FRAME does not record any memory at ADDRESS, set `*SIZE'
8063 to the distance from ADDRESS to the start of the saved region
8064 with the lowest address higher than ADDRESS. If there is no
8065 memory saved from any higher address, set `*SIZE' to zero.
8066 Return `NOT_FOUND_TARGET_RESPONSE'.
8068 These two possibilities allow the caller to either retrieve the
8069 data, or walk the address space to the next saved area.
8071 This function allows the GDB agent to map the regions of memory
8072 saved in a particular frame, and retrieve their contents efficiently.
8074 This function also provides a clean interface between the GDB agent
8075 and the Symmetrix tracing structures, making it easier to adapt the GDB
8076 agent to future versions of the Symmetrix system, and vice versa. This
8077 function searches all data saved in FRAME, whether the data is there at
8078 the request of a bytecode expression, or because it falls in one of the
8079 format's memory ranges, or because it was saved from the top of the
8080 stack. EMC can arbitrarily change and enhance the tracing mechanism,
8081 but as long as this function works properly, all collected memory is
8084 The function itself is straightforward to implement. A single pass
8085 over the trace frame's stack area, memory ranges, and expression blocks
8086 can yield the address of the buffer (if the requested address was
8087 saved), and also note the address of the next higher range of memory,
8088 to be returned when the search fails.
8090 As an example, suppose the trace frame `f' has saved sixteen bytes
8091 from address `0x8000' in a buffer at `0x1000', and thirty-two bytes
8092 from address `0xc000' in a buffer at `0x1010'. Here are some sample
8093 calls, and the effect each would have:
8095 `adbg_find_memory_in_frame (f, (char*) 0x8000, &buffer, &size)'
8096 This would set `buffer' to `0x1000', set `size' to sixteen, and
8097 return `OK_TARGET_RESPONSE', since `f' saves sixteen bytes from
8098 `0x8000' at `0x1000'.
8100 `adbg_find_memory_in_frame (f, (char *) 0x8004, &buffer, &size)'
8101 This would set `buffer' to `0x1004', set `size' to twelve, and
8102 return `OK_TARGET_RESPONSE', since `f' saves the twelve bytes from
8103 `0x8004' starting four bytes into the buffer at `0x1000'. This
8104 shows that request addresses may fall in the middle of saved
8105 areas; the function should return the address and size of the
8106 remainder of the buffer.
8108 `adbg_find_memory_in_frame (f, (char *) 0x8100, &buffer, &size)'
8109 This would set `size' to `0x3f00' and return
8110 `NOT_FOUND_TARGET_RESPONSE', since there is no memory saved in `f'
8111 from the address `0x8100', and the next memory available is at
8112 `0x8100 + 0x3f00', or `0xc000'. This shows that request addresses
8113 may fall outside of all saved memory ranges; the function should
8114 indicate the next saved area, if any.
8116 `adbg_find_memory_in_frame (f, (char *) 0x7000, &buffer, &size)'
8117 This would set `size' to `0x1000' and return
8118 `NOT_FOUND_TARGET_RESPONSE', since the next saved memory is at
8119 `0x7000 + 0x1000', or `0x8000'.
8121 `adbg_find_memory_in_frame (f, (char *) 0xf000, &buffer, &size)'
8122 This would set `size' to zero, and return
8123 `NOT_FOUND_TARGET_RESPONSE'. This shows how the function tells the
8124 caller that no further memory ranges have been saved.
8127 As another example, here is a function which will print out the
8128 addresses of all memory saved in the trace frame `frame' on the
8129 Symmetrix INLINES console:
8131 print_frame_addresses (FRAME_DEF *frame)
8140 /* Either find out how much memory we have here, or discover
8141 where the next saved region is. */
8142 if (adbg_find_memory_in_frame (frame, addr, &buffer, &size)
8143 == OK_TARGET_RESPONSE)
8144 printp ("saved %x to %x\n", addr, addr + size);
8151 Note that there is not necessarily any connection between the order
8152 in which the data is saved in the trace frame, and the order in which
8153 `adbg_find_memory_in_frame' will return those memory ranges. The code
8154 above will always print the saved memory regions in order of increasing
8155 address, while the underlying frame structure might store the data in a
8158 [[This section should cover the rest of the Symmetrix functions the
8159 stub relies upon, too.]]
8162 File: gdb.info, Node: Rationale, Prev: Tracing on Symmetrix, Up: Agent Expressions
8167 Some of the design decisions apparent above are arguable.
8169 What about stack overflow/underflow?
8170 GDB should be able to query the target to discover its stack size.
8171 Given that information, GDB can determine at translation time
8172 whether a given expression will overflow the stack. But this spec
8173 isn't about what kinds of error-checking GDB ought to do.
8175 Why are you doing everything in LONGEST?
8176 Speed isn't important, but agent code size is; using LONGEST
8177 brings in a bunch of support code to do things like division, etc.
8178 So this is a serious concern.
8180 First, note that you don't need different bytecodes for different
8181 operand sizes. You can generate code without _knowing_ how big the
8182 stack elements actually are on the target. If the target only
8183 supports 32-bit ints, and you don't send any 64-bit bytecodes,
8184 everything just works. The observation here is that the MIPS and
8185 the Alpha have only fixed-size registers, and you can still get
8186 C's semantics even though most instructions only operate on
8187 full-sized words. You just need to make sure everything is
8188 properly sign-extended at the right times. So there is no need
8189 for 32- and 64-bit variants of the bytecodes. Just implement
8190 everything using the largest size you support.
8192 GDB should certainly check to see what sizes the target supports,
8193 so the user can get an error earlier, rather than later. But this
8194 information is not necessary for correctness.
8196 Why don't you have `>' or `<=' operators?
8197 I want to keep the interpreter small, and we don't need them. We
8198 can combine the `less_' opcodes with `log_not', and swap the order
8199 of the operands, yielding all four asymmetrical comparison
8200 operators. For example, `(x <= y)' is `! (x > y)', which is `! (y
8203 Why do you have `log_not'?
8204 Why do you have `ext'?
8205 Why do you have `zero_ext'?
8206 These are all easily synthesized from other instructions, but I
8207 expect them to be used frequently, and they're simple, so I
8208 include them to keep bytecode strings short.
8210 `log_not' is equivalent to `const8 0 equal'; it's used in half the
8211 relational operators.
8213 `ext N' is equivalent to `const8 S-N lsh const8 S-N rsh_signed',
8214 where S is the size of the stack elements; it follows `refM' and
8215 REG bytecodes when the value should be signed. See the next
8218 `zero_ext N' is equivalent to `constM MASK log_and'; it's used
8219 whenever we push the value of a register, because we can't assume
8220 the upper bits of the register aren't garbage.
8222 Why not have sign-extending variants of the `ref' operators?
8223 Because that would double the number of `ref' operators, and we
8224 need the `ext' bytecode anyway for accessing bitfields.
8226 Why not have constant-address variants of the `ref' operators?
8227 Because that would double the number of `ref' operators again, and
8228 `const32 ADDRESS ref32' is only one byte longer.
8230 Why do the `refN' operators have to support unaligned fetches?
8231 GDB will generate bytecode that fetches multi-byte values at
8232 unaligned addresses whenever the executable's debugging
8233 information tells it to. Furthermore, GDB does not know the value
8234 the pointer will have when GDB generates the bytecode, so it
8235 cannot determine whether a particular fetch will be aligned or not.
8237 In particular, structure bitfields may be several bytes long, but
8238 follow no alignment rules; members of packed structures are not
8239 necessarily aligned either.
8241 In general, there are many cases where unaligned references occur
8242 in correct C code, either at the programmer's explicit request, or
8243 at the compiler's discretion. Thus, it is simpler to make the GDB
8244 agent bytecodes work correctly in all circumstances than to make
8245 GDB guess in each case whether the compiler did the usual thing.
8247 Why are there no side-effecting operators?
8248 Because our current client doesn't want them? That's a cheap
8249 answer. I think the real answer is that I'm afraid of
8250 implementing function calls. We should re-visit this issue after
8251 the present contract is delivered.
8253 Why aren't the `goto' ops PC-relative?
8254 The interpreter has the base address around anyway for PC bounds
8255 checking, and it seemed simpler.
8257 Why is there only one offset size for the `goto' ops?
8258 Offsets are currently sixteen bits. I'm not happy with this
8261 Suppose we have multiple branch ops with different offset sizes.
8262 As I generate code left-to-right, all my jumps are forward jumps
8263 (there are no loops in expressions), so I never know the target
8264 when I emit the jump opcode. Thus, I have to either always assume
8265 the largest offset size, or do jump relaxation on the code after I
8266 generate it, which seems like a big waste of time.
8268 I can imagine a reasonable expression being longer than 256 bytes.
8269 I can't imagine one being longer than 64k. Thus, we need 16-bit
8270 offsets. This kind of reasoning is so bogus, but relaxation is
8273 The other approach would be to generate code right-to-left. Then
8274 I'd always know my offset size. That might be fun.
8276 Where is the function call bytecode?
8277 When we add side-effects, we should add this.
8279 Why does the `reg' bytecode take a 16-bit register number?
8280 Intel's IA-64 architecture has 128 general-purpose registers, and
8281 128 floating-point registers, and I'm sure it has some random
8284 Why do we need `trace' and `trace_quick'?
8285 Because GDB needs to record all the memory contents and registers
8286 an expression touches. If the user wants to evaluate an expression
8287 `x->y->z', the agent must record the values of `x' and `x->y' as
8288 well as the value of `x->y->z'.
8290 Don't the `trace' bytecodes make the interpreter less general?
8291 They do mean that the interpreter contains special-purpose code,
8292 but that doesn't mean the interpreter can only be used for that
8293 purpose. If an expression doesn't use the `trace' bytecodes, they
8294 don't get in its way.
8296 Why doesn't `trace_quick' consume its arguments the way everything else does?
8297 In general, you do want your operators to consume their arguments;
8298 it's consistent, and generally reduces the amount of stack
8299 rearrangement necessary. However, `trace_quick' is a kludge to
8300 save space; it only exists so we needn't write `dup const8 SIZE
8301 trace' before every memory reference. Therefore, it's okay for it
8302 not to consume its arguments; it's meant for a specific context in
8303 which we know exactly what it should do with the stack. If we're
8304 going to have a kludge, it should be an effective kludge.
8306 Why does `trace16' exist?
8307 That opcode was added by the customer that contracted Cygnus for
8308 the data tracing work. I personally think it is unnecessary;
8309 objects that large will be quite rare, so it is okay to use `dup
8310 const16 SIZE trace' in those cases.
8312 Whatever we decide to do with `trace16', we should at least leave
8313 opcode 0x30 reserved, to remain compatible with the customer who
8318 File: gdb.info, Node: Copying, Next: GNU Free Documentation License, Prev: Agent Expressions, Up: Top
8320 Appendix F GNU GENERAL PUBLIC LICENSE
8321 *************************************
8323 Version 2, June 1991
8325 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
8326 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
8328 Everyone is permitted to copy and distribute verbatim copies
8329 of this license document, but changing it is not allowed.
8334 The licenses for most software are designed to take away your freedom
8335 to share and change it. By contrast, the GNU General Public License is
8336 intended to guarantee your freedom to share and change free
8337 software--to make sure the software is free for all its users. This
8338 General Public License applies to most of the Free Software
8339 Foundation's software and to any other program whose authors commit to
8340 using it. (Some other Free Software Foundation software is covered by
8341 the GNU Library General Public License instead.) You can apply it to
8344 When we speak of free software, we are referring to freedom, not
8345 price. Our General Public Licenses are designed to make sure that you
8346 have the freedom to distribute copies of free software (and charge for
8347 this service if you wish), that you receive source code or can get it
8348 if you want it, that you can change the software or use pieces of it in
8349 new free programs; and that you know you can do these things.
8351 To protect your rights, we need to make restrictions that forbid
8352 anyone to deny you these rights or to ask you to surrender the rights.
8353 These restrictions translate to certain responsibilities for you if you
8354 distribute copies of the software, or if you modify it.
8356 For example, if you distribute copies of such a program, whether
8357 gratis or for a fee, you must give the recipients all the rights that
8358 you have. You must make sure that they, too, receive or can get the
8359 source code. And you must show them these terms so they know their
8362 We protect your rights with two steps: (1) copyright the software,
8363 and (2) offer you this license which gives you legal permission to copy,
8364 distribute and/or modify the software.
8366 Also, for each author's protection and ours, we want to make certain
8367 that everyone understands that there is no warranty for this free
8368 software. If the software is modified by someone else and passed on, we
8369 want its recipients to know that what they have is not the original, so
8370 that any problems introduced by others will not reflect on the original
8371 authors' reputations.
8373 Finally, any free program is threatened constantly by software
8374 patents. We wish to avoid the danger that redistributors of a free
8375 program will individually obtain patent licenses, in effect making the
8376 program proprietary. To prevent this, we have made it clear that any
8377 patent must be licensed for everyone's free use or not licensed at all.
8379 The precise terms and conditions for copying, distribution and
8380 modification follow.
8382 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
8383 0. This License applies to any program or other work which contains a
8384 notice placed by the copyright holder saying it may be distributed
8385 under the terms of this General Public License. The "Program",
8386 below, refers to any such program or work, and a "work based on
8387 the Program" means either the Program or any derivative work under
8388 copyright law: that is to say, a work containing the Program or a
8389 portion of it, either verbatim or with modifications and/or
8390 translated into another language. (Hereinafter, translation is
8391 included without limitation in the term "modification".) Each
8392 licensee is addressed as "you".
8394 Activities other than copying, distribution and modification are
8395 not covered by this License; they are outside its scope. The act
8396 of running the Program is not restricted, and the output from the
8397 Program is covered only if its contents constitute a work based on
8398 the Program (independent of having been made by running the
8399 Program). Whether that is true depends on what the Program does.
8401 1. You may copy and distribute verbatim copies of the Program's
8402 source code as you receive it, in any medium, provided that you
8403 conspicuously and appropriately publish on each copy an appropriate
8404 copyright notice and disclaimer of warranty; keep intact all the
8405 notices that refer to this License and to the absence of any
8406 warranty; and give any other recipients of the Program a copy of
8407 this License along with the Program.
8409 You may charge a fee for the physical act of transferring a copy,
8410 and you may at your option offer warranty protection in exchange
8413 2. You may modify your copy or copies of the Program or any portion
8414 of it, thus forming a work based on the Program, and copy and
8415 distribute such modifications or work under the terms of Section 1
8416 above, provided that you also meet all of these conditions:
8418 a. You must cause the modified files to carry prominent notices
8419 stating that you changed the files and the date of any change.
8421 b. You must cause any work that you distribute or publish, that
8422 in whole or in part contains or is derived from the Program
8423 or any part thereof, to be licensed as a whole at no charge
8424 to all third parties under the terms of this License.
8426 c. If the modified program normally reads commands interactively
8427 when run, you must cause it, when started running for such
8428 interactive use in the most ordinary way, to print or display
8429 an announcement including an appropriate copyright notice and
8430 a notice that there is no warranty (or else, saying that you
8431 provide a warranty) and that users may redistribute the
8432 program under these conditions, and telling the user how to
8433 view a copy of this License. (Exception: if the Program
8434 itself is interactive but does not normally print such an
8435 announcement, your work based on the Program is not required
8436 to print an announcement.)
8438 These requirements apply to the modified work as a whole. If
8439 identifiable sections of that work are not derived from the
8440 Program, and can be reasonably considered independent and separate
8441 works in themselves, then this License, and its terms, do not
8442 apply to those sections when you distribute them as separate
8443 works. But when you distribute the same sections as part of a
8444 whole which is a work based on the Program, the distribution of
8445 the whole must be on the terms of this License, whose permissions
8446 for other licensees extend to the entire whole, and thus to each
8447 and every part regardless of who wrote it.
8449 Thus, it is not the intent of this section to claim rights or
8450 contest your rights to work written entirely by you; rather, the
8451 intent is to exercise the right to control the distribution of
8452 derivative or collective works based on the Program.
8454 In addition, mere aggregation of another work not based on the
8455 Program with the Program (or with a work based on the Program) on
8456 a volume of a storage or distribution medium does not bring the
8457 other work under the scope of this License.
8459 3. You may copy and distribute the Program (or a work based on it,
8460 under Section 2) in object code or executable form under the terms
8461 of Sections 1 and 2 above provided that you also do one of the
8464 a. Accompany it with the complete corresponding machine-readable
8465 source code, which must be distributed under the terms of
8466 Sections 1 and 2 above on a medium customarily used for
8467 software interchange; or,
8469 b. Accompany it with a written offer, valid for at least three
8470 years, to give any third party, for a charge no more than your
8471 cost of physically performing source distribution, a complete
8472 machine-readable copy of the corresponding source code, to be
8473 distributed under the terms of Sections 1 and 2 above on a
8474 medium customarily used for software interchange; or,
8476 c. Accompany it with the information you received as to the offer
8477 to distribute corresponding source code. (This alternative is
8478 allowed only for noncommercial distribution and only if you
8479 received the program in object code or executable form with
8480 such an offer, in accord with Subsection b above.)
8482 The source code for a work means the preferred form of the work for
8483 making modifications to it. For an executable work, complete
8484 source code means all the source code for all modules it contains,
8485 plus any associated interface definition files, plus the scripts
8486 used to control compilation and installation of the executable.
8487 However, as a special exception, the source code distributed need
8488 not include anything that is normally distributed (in either
8489 source or binary form) with the major components (compiler,
8490 kernel, and so on) of the operating system on which the executable
8491 runs, unless that component itself accompanies the executable.
8493 If distribution of executable or object code is made by offering
8494 access to copy from a designated place, then offering equivalent
8495 access to copy the source code from the same place counts as
8496 distribution of the source code, even though third parties are not
8497 compelled to copy the source along with the object code.
8499 4. You may not copy, modify, sublicense, or distribute the Program
8500 except as expressly provided under this License. Any attempt
8501 otherwise to copy, modify, sublicense or distribute the Program is
8502 void, and will automatically terminate your rights under this
8503 License. However, parties who have received copies, or rights,
8504 from you under this License will not have their licenses
8505 terminated so long as such parties remain in full compliance.
8507 5. You are not required to accept this License, since you have not
8508 signed it. However, nothing else grants you permission to modify
8509 or distribute the Program or its derivative works. These actions
8510 are prohibited by law if you do not accept this License.
8511 Therefore, by modifying or distributing the Program (or any work
8512 based on the Program), you indicate your acceptance of this
8513 License to do so, and all its terms and conditions for copying,
8514 distributing or modifying the Program or works based on it.
8516 6. Each time you redistribute the Program (or any work based on the
8517 Program), the recipient automatically receives a license from the
8518 original licensor to copy, distribute or modify the Program
8519 subject to these terms and conditions. You may not impose any
8520 further restrictions on the recipients' exercise of the rights
8521 granted herein. You are not responsible for enforcing compliance
8522 by third parties to this License.
8524 7. If, as a consequence of a court judgment or allegation of patent
8525 infringement or for any other reason (not limited to patent
8526 issues), conditions are imposed on you (whether by court order,
8527 agreement or otherwise) that contradict the conditions of this
8528 License, they do not excuse you from the conditions of this
8529 License. If you cannot distribute so as to satisfy simultaneously
8530 your obligations under this License and any other pertinent
8531 obligations, then as a consequence you may not distribute the
8532 Program at all. For example, if a patent license would not permit
8533 royalty-free redistribution of the Program by all those who
8534 receive copies directly or indirectly through you, then the only
8535 way you could satisfy both it and this License would be to refrain
8536 entirely from distribution of the Program.
8538 If any portion of this section is held invalid or unenforceable
8539 under any particular circumstance, the balance of the section is
8540 intended to apply and the section as a whole is intended to apply
8541 in other circumstances.
8543 It is not the purpose of this section to induce you to infringe any
8544 patents or other property right claims or to contest validity of
8545 any such claims; this section has the sole purpose of protecting
8546 the integrity of the free software distribution system, which is
8547 implemented by public license practices. Many people have made
8548 generous contributions to the wide range of software distributed
8549 through that system in reliance on consistent application of that
8550 system; it is up to the author/donor to decide if he or she is
8551 willing to distribute software through any other system and a
8552 licensee cannot impose that choice.
8554 This section is intended to make thoroughly clear what is believed
8555 to be a consequence of the rest of this License.
8557 8. If the distribution and/or use of the Program is restricted in
8558 certain countries either by patents or by copyrighted interfaces,
8559 the original copyright holder who places the Program under this
8560 License may add an explicit geographical distribution limitation
8561 excluding those countries, so that distribution is permitted only
8562 in or among countries not thus excluded. In such case, this
8563 License incorporates the limitation as if written in the body of
8566 9. The Free Software Foundation may publish revised and/or new
8567 versions of the General Public License from time to time. Such
8568 new versions will be similar in spirit to the present version, but
8569 may differ in detail to address new problems or concerns.
8571 Each version is given a distinguishing version number. If the
8572 Program specifies a version number of this License which applies
8573 to it and "any later version", you have the option of following
8574 the terms and conditions either of that version or of any later
8575 version published by the Free Software Foundation. If the Program
8576 does not specify a version number of this License, you may choose
8577 any version ever published by the Free Software Foundation.
8579 10. If you wish to incorporate parts of the Program into other free
8580 programs whose distribution conditions are different, write to the
8581 author to ask for permission. For software which is copyrighted
8582 by the Free Software Foundation, write to the Free Software
8583 Foundation; we sometimes make exceptions for this. Our decision
8584 will be guided by the two goals of preserving the free status of
8585 all derivatives of our free software and of promoting the sharing
8586 and reuse of software generally.
8589 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
8590 WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
8591 LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
8592 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
8593 WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
8594 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
8595 FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
8596 QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
8597 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
8598 SERVICING, REPAIR OR CORRECTION.
8600 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
8601 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
8602 MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
8603 LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
8604 INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
8605 INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
8606 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
8607 OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
8608 OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
8609 ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
8611 END OF TERMS AND CONDITIONS
8612 How to Apply These Terms to Your New Programs
8613 =============================================
8615 If you develop a new program, and you want it to be of the greatest
8616 possible use to the public, the best way to achieve this is to make it
8617 free software which everyone can redistribute and change under these
8620 To do so, attach the following notices to the program. It is safest
8621 to attach them to the start of each source file to most effectively
8622 convey the exclusion of warranty; and each file should have at least
8623 the "copyright" line and a pointer to where the full notice is found.
8625 ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
8626 Copyright (C) YEAR NAME OF AUTHOR
8628 This program is free software; you can redistribute it and/or modify
8629 it under the terms of the GNU General Public License as published by
8630 the Free Software Foundation; either version 2 of the License, or
8631 (at your option) any later version.
8633 This program is distributed in the hope that it will be useful,
8634 but WITHOUT ANY WARRANTY; without even the implied warranty of
8635 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8636 GNU General Public License for more details.
8638 You should have received a copy of the GNU General Public License
8639 along with this program; if not, write to the Free Software
8640 Foundation, Inc., 51 Franklin Street, Fifth Floor,
8641 Boston, MA 02110-1301, USA.
8643 Also add information on how to contact you by electronic and paper
8646 If the program is interactive, make it output a short notice like
8647 this when it starts in an interactive mode:
8649 Gnomovision version 69, Copyright (C) YEAR NAME OF AUTHOR
8650 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
8652 This is free software, and you are welcome to redistribute it
8653 under certain conditions; type `show c' for details.
8655 The hypothetical commands `show w' and `show c' should show the
8656 appropriate parts of the General Public License. Of course, the
8657 commands you use may be called something other than `show w' and `show
8658 c'; they could even be mouse-clicks or menu items--whatever suits your
8661 You should also get your employer (if you work as a programmer) or
8662 your school, if any, to sign a "copyright disclaimer" for the program,
8663 if necessary. Here is a sample; alter the names:
8665 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
8666 `Gnomovision' (which makes passes at compilers) written by James Hacker.
8668 SIGNATURE OF TY COON, 1 April 1989
8669 Ty Coon, President of Vice
8671 This General Public License does not permit incorporating your
8672 program into proprietary programs. If your program is a subroutine
8673 library, you may consider it more useful to permit linking proprietary
8674 applications with the library. If this is what you want to do, use the
8675 GNU Library General Public License instead of this License.