X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fdoc%2Fgdb.texinfo;h=f00cf2b287cb7e4030e6c9096685d2ec52bbafe4;hb=1abaf70c9430cffb9779153a4518e1c5093d742a;hp=b951ae244bf78aa85ba18f0a45b82fa062acd5c8;hpb=c60eb6f167ea93741f61354c1f4fa3541372cd51;p=binutils-gdb.git diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b951ae244bf..f00cf2b287c 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -28,11 +28,9 @@ @syncodeindex fn cp @c !!set GDB manual's edition---not the same as GDB version! +@c This is updated by GNU Press. @set EDITION Ninth -@c !!set GDB manual's revision date -@set DATE June 2002 - @c !!set GDB edit command default editor @set EDITOR /bin/ex @@ -49,9 +47,9 @@ This file documents the @sc{gnu} debugger @value{GDBN}. -This is the @value{EDITION} Edition, @value{DATE}, -of @cite{Debugging with @value{GDBN}: the @sc{gnu} Source-Level Debugger} -for @value{GDBN} Version @value{GDBVN}. +This is the @value{EDITION} Edition, of @cite{Debugging with +@value{GDBN}: the @sc{gnu} Source-Level Debugger} for @value{GDBN} +Version @value{GDBVN}. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,@* 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. @@ -74,7 +72,6 @@ development.'' @subtitle The @sc{gnu} Source-Level Debugger @sp 1 @subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN} -@subtitle @value{DATE} @author Richard Stallman, Roland Pesch, Stan Shebs, et al. @page @tex @@ -115,7 +112,7 @@ development.'' This file describes @value{GDBN}, the @sc{gnu} symbolic debugger. -This is the @value{EDITION} Edition, @value{DATE}, for @value{GDBN} Version +This is the @value{EDITION} Edition, for @value{GDBN} Version @value{GDBVN}. Copyright (C) 1988-2003 Free Software Foundation, Inc. @@ -146,6 +143,7 @@ Copyright (C) 1988-2003 Free Software Foundation, Inc. * Controlling GDB:: Controlling @value{GDBN} * Sequences:: Canned sequences of commands * TUI:: @value{GDBN} Text User Interface +* Interpreters:: Command Interpreters * Emacs:: Using @value{GDBN} under @sc{gnu} Emacs * Annotations:: @value{GDBN}'s annotation interface. * GDB/MI:: @value{GDBN}'s Machine Interface. @@ -371,7 +369,7 @@ Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore. David Johnson wrote the original COFF support; Pace Willison did the original support for encapsulated COFF. -Brent Benson of Harris Computer Systems contributed DWARF2 support. +Brent Benson of Harris Computer Systems contributed DWARF 2 support. Adam de Boor and Bradley Davis contributed the ISI Optimum V support. Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS @@ -1124,6 +1122,7 @@ Do not use this option if you run @value{GDBN} from Emacs Use the interpreter @var{interp} for interface with the controlling program or device. This option is meant to be set by programs which communicate with @value{GDBN} using it as a back end. +@xref{Interpreters, , Command Interpreters}. @samp{--interpreter=mi} (or @samp{--interpreter=mi2}) causes @value{GDBN} to use the current @dfn{@sc{gdb/mi} interface} @@ -2512,6 +2511,8 @@ example, on the DSU, only two data breakpoints can be set at a time, and @value{GDBN} will reject this command if more than two are used. Delete or disable unused hardware breakpoints before setting new ones (@pxref{Disabling, ,Disabling}). @xref{Conditions, ,Break conditions}. +@xref{set remote hardware-breakpoint-limit}. + @kindex thbreak @item thbreak @var{args} @@ -2748,6 +2749,8 @@ when a non-current thread's activity changes the expression. (Hardware watchpoints, in contrast, watch an expression in all threads.) @end quotation +@xref{set remote hardware-watchpoint-limit}. + @node Set Catchpoints @subsection Setting catchpoints @cindex catchpoints, setting @@ -4711,13 +4714,12 @@ No symbol "foo" in current context. To solve such problems, either recompile without optimizations, or use a different debug info format, if the compiler supports several such -formats. For example, @value{NGCC}, the @sc{gnu} C/C@t{++} compiler usually -supports the @samp{-gstabs} option. @samp{-gstabs} produces debug info -in a format that is superior to formats such as COFF. You may be able -to use DWARF2 (@samp{-gdwarf-2}), which is also an effective form for -debug info. See @ref{Debugging Options,,Options for Debugging Your -Program or @sc{gnu} CC, gcc.info, Using @sc{gnu} CC}, for more -information. +formats. For example, @value{NGCC}, the @sc{gnu} C/C@t{++} compiler +usually supports the @option{-gstabs+} option. @option{-gstabs+} +produces debug info in a format that is superior to formats such as +COFF. You may be able to use DWARF 2 (@option{-gdwarf-2}), which is also +an effective form for debug info. @xref{Debugging Options,,Options +for Debugging Your Program or @sc{gnu} CC, gcc.info, Using @sc{gnu} CC}. @node Arrays @@ -7812,11 +7814,12 @@ effectively, you must compile your C@t{++} programs with a supported C@t{++} compiler, such as @sc{gnu} @code{g++}, or the HP ANSI C@t{++} compiler (@code{aCC}). -For best results when using @sc{gnu} C@t{++}, use the stabs debugging -format. You can select that format explicitly with the @code{g++} -command-line options @samp{-gstabs} or @samp{-gstabs+}. See -@ref{Debugging Options,,Options for Debugging Your Program or @sc{gnu} -CC, gcc.info, Using @sc{gnu} CC}, for more information. +For best results when using @sc{gnu} C@t{++}, use the DWARF 2 debugging +format; if it doesn't work on your system, try the stabs+ debugging +format. You can select those formats explicitly with the @code{g++} +command-line options @option{-gdwarf-2} and @option{-gstabs+}. +@xref{Debugging Options,,Options for Debugging Your Program or @sc{gnu} +CC, gcc.info, Using @sc{gnu} CC}. @menu * C Operators:: C and C@t{++} operators @@ -8062,28 +8065,21 @@ and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers. @cindex expressions in C@t{++} @value{GDBN} expression handling can interpret most C@t{++} expressions. -@cindex C@t{++} support, not in @sc{coff} -@cindex @sc{coff} versus C@t{++} -@cindex C@t{++} and object formats -@cindex object formats and C@t{++} -@cindex a.out and C@t{++} -@cindex @sc{ecoff} and C@t{++} -@cindex @sc{xcoff} and C@t{++} -@cindex @sc{elf}/stabs and C@t{++} -@cindex @sc{elf}/@sc{dwarf} and C@t{++} -@c FIXME!! GDB may eventually be able to debug C++ using DWARF; check -@c periodically whether this has happened... +@cindex debugging C@t{++} programs +@cindex C@t{++} compilers +@cindex debug formats and C@t{++} +@cindex @value{NGCC} and C@t{++} @quotation @emph{Warning:} @value{GDBN} can only debug C@t{++} code if you use the -proper compiler. Typically, C@t{++} debugging depends on the use of -additional debugging information in the symbol table, and thus requires -special support. In particular, if your compiler generates a.out, MIPS -@sc{ecoff}, RS/6000 @sc{xcoff}, or @sc{elf} with stabs extensions to the -symbol table, these facilities are all available. (With @sc{gnu} CC, -you can use the @samp{-gstabs} option to request stabs debugging -extensions explicitly.) Where the object code format is standard -@sc{coff} or @sc{dwarf} in @sc{elf}, on the other hand, most of the C@t{++} -support in @value{GDBN} does @emph{not} work. +proper compiler and the proper debug format. Currently, @value{GDBN} +works best when debugging C@t{++} code that is compiled with +@value{NGCC} 2.95.3 or with @value{NGCC} 3.1 or newer, using the options +@option{-gdwarf-2} or @option{-gstabs+}. DWARF 2 is preferred over +stabs+. Most configurations of @value{NGCC} emit either DWARF 2 or +stabs+ as their default debug format, so you usually don't need to +specify a debug format explicitly. Other compilers and/or debug formats +are likely to work badly or not at all when using @value{GDBN} to debug +C@t{++} code. @end quotation @enumerate @@ -9342,6 +9338,7 @@ program. To debug a core dump of a previous run, you must also tell @menu * Files:: Commands to specify files +* Separate Debug Files:: Debugging information in separate files * Symbol Errors:: Errors reading symbol files @end menu @@ -9789,6 +9786,190 @@ set @samp{solib-absolute-prefix} to a nonexistant directory to prevent Display the current shared library search path. @end table + +@node Separate Debug Files +@section Debugging Information in Separate Files +@cindex separate debugging information files +@cindex debugging information in separate files +@cindex @file{.debug} subdirectories +@cindex debugging information directory, global +@cindex global debugging information directory + +@value{GDBN} allows you to put a program's debugging information in a +file separate from the executable itself, in a way that allows +@value{GDBN} to find and load the debugging information automatically. +Since debugging information can be very large --- sometimes larger +than the executable code itself --- some systems distribute debugging +information for their executables in separate files, which users can +install only when they need to debug a problem. + +If an executable's debugging information has been extracted to a +separate file, the executable should contain a @dfn{debug link} giving +the name of the debugging information file (with no directory +components), and a checksum of its contents. (The exact form of a +debug link is described below.) If the full name of the directory +containing the executable is @var{execdir}, and the executable has a +debug link that specifies the name @var{debugfile}, then @value{GDBN} +will automatically search for the debugging information file in three +places: + +@itemize @bullet +@item +the directory containing the executable file (that is, it will look +for a file named @file{@var{execdir}/@var{debugfile}}, +@item +a subdirectory of that directory named @file{.debug} (that is, the +file @file{@var{execdir}/.debug/@var{debugfile}}, and +@item +a subdirectory of the global debug file directory that includes the +executable's full path, and the name from the link (that is, the file +@file{@var{globaldebugdir}/@var{execdir}/@var{debugfile}}, where +@var{globaldebugdir} is the global debug file directory, and +@var{execdir} has been turned into a relative path). +@end itemize +@noindent +@value{GDBN} checks under each of these names for a debugging +information file whose checksum matches that given in the link, and +reads the debugging information from the first one it finds. + +So, for example, if you ask @value{GDBN} to debug @file{/usr/bin/ls}, +which has a link containing the name @file{ls.debug}, and the global +debug directory is @file{/usr/lib/debug}, then @value{GDBN} will look +for debug information in @file{/usr/bin/ls.debug}, +@file{/usr/bin/.debug/ls.debug}, and +@file{/usr/lib/debug/usr/bin/ls.debug}. + +You can set the global debugging info directory's name, and view the +name @value{GDBN} is currently using. + +@table @code + +@kindex set debug-file-directory +@item set debug-file-directory @var{directory} +Set the directory which @value{GDBN} searches for separate debugging +information files to @var{directory}. + +@kindex show debug-file-directory +@item show debug-file-directory +Show the directory @value{GDBN} searches for separate debugging +information files. + +@end table + +@cindex @code{.gnu_debuglink} sections +@cindex debug links +A debug link is a special section of the executable file named +@code{.gnu_debuglink}. The section must contain: + +@itemize +@item +A filename, with any leading directory components removed, followed by +a zero byte, +@item +zero to three bytes of padding, as needed to reach the next four-byte +boundary within the section, and +@item +a four-byte CRC checksum, stored in the same endianness used for the +executable file itself. The checksum is computed on the debugging +information file's full contents by the function given below, passing +zero as the @var{crc} argument. +@end itemize + +Any executable file format can carry a debug link, as long as it can +contain a section named @code{.gnu_debuglink} with the contents +described above. + +The debugging information file itself should be an ordinary +executable, containing a full set of linker symbols, sections, and +debugging information. The sections of the debugging information file +should have the same names, addresses and sizes as the original file, +but they need not contain any data --- much like a @code{.bss} section +in an ordinary executable. + +As of December 2002, there is no standard GNU utility to produce +separated executable / debugging information file pairs. Ulrich +Drepper's @file{elfutils} package, starting with version 0.53, +contains a version of the @code{strip} command such that the command +@kbd{strip foo -f foo.debug} removes the debugging information from +the executable file @file{foo}, places it in the file +@file{foo.debug}, and leaves behind a debug link in @file{foo}. + +Since there are many different ways to compute CRC's (different +polynomials, reversals, byte ordering, etc.), the simplest way to +describe the CRC used in @code{.gnu_debuglink} sections is to give the +complete code for a function that computes it: + +@kindex @code{gnu_debuglink_crc32} +@smallexample +unsigned long +gnu_debuglink_crc32 (unsigned long crc, + unsigned char *buf, size_t len) +@{ + static const unsigned long crc32_table[256] = + @{ + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d + @}; + unsigned char *end; + + crc = ~crc & 0xffffffff; + for (end = buf + len; buf < end; ++buf) + crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); + return ~crc & 0xffffffff;; +@} +@end smallexample + + @node Symbol Errors @section Errors reading symbol files @@ -10172,6 +10353,7 @@ is supported other than to try it. @menu * Server:: Using the gdbserver program * NetWare:: Using the gdbserve.nlm program +* Remote configuration:: Remote configuration * remote stub:: Implementing a remote stub @end menu @@ -10344,6 +10526,23 @@ argument is a device name (usually a serial device, like communications with the server via serial line @file{/dev/ttyb}. @end table +@node Remote configuration +@section Remote configuration + +The following configuration options are available when debugging remote +programs: + +@table @code +@kindex set remote hardware-watchpoint-limit +@kindex set remote hardware-breakpoint-limit +@anchor{set remote hardware-watchpoint-limit} +@anchor{set remote hardware-breakpoint-limit} +@item set remote hardware-watchpoint-limit @var{limit} +@itemx set remote hardware-breakpoint-limit @var{limit} +Restrict @value{GDBN} to using @var{limit} remote hardware breakpoint or +watchpoints. A limit of -1, the default, is treated as unlimited. +@end table + @node remote stub @section Implementing a remote stub @@ -10962,9 +11161,12 @@ This command is supported only with some DPMI servers. @cindex native Cygwin debugging @cindex Cygwin-specific commands -@value{GDBN} supports native debugging of MS Windows programs, and -defines a few commands specific to the Cygwin port. This -subsection describes those commands. +@value{GDBN} supports native debugging of MS Windows programs, including +DLLs with and without symbolic debugging information. There are various +additional Cygwin-specific commands, described in this subsection. The +subsubsection @pxref{Non-debug DLL symbols} describes working with DLLs +that have no debugging symbols. + @table @code @kindex info w32 @@ -11042,6 +11244,130 @@ Displays if the debuggee will be started with a shell. @end table +@menu +* Non-debug DLL symbols:: Support for DLLs without debugging symbols +@end menu + +@node Non-debug DLL symbols +@subsubsection Support for DLLs without debugging symbols +@cindex DLLs with no debugging symbols +@cindex Minimal symbols and DLLs + +Very often on windows, some of the DLLs that your program relies on do +not include symbolic debugging information (for example, +@file{kernel32.dll}). When @value{GDBN} doesn't recognize any debugging +symbols in a DLL, it relies on the minimal amount of symbolic +information contained in the DLL's export table. This subsubsection +describes working with such symbols, known internally to @value{GDBN} as +``minimal symbols''. + +Note that before the debugged program has started execution, no DLLs +will have been loaded. The easiest way around this problem is simply to +start the program --- either by setting a breakpoint or letting the +program run once to completion. It is also possible to force +@value{GDBN} to load a particular DLL before starting the executable --- +see the shared library information in @pxref{Files} or the +@code{dll-symbols} command in @pxref{Cygwin Native}. Currently, +explicitly loading symbols from a DLL with no debugging information will +cause the symbol names to be duplicated in @value{GDBN}'s lookup table, +which may adversely affect symbol lookup performance. + +@subsubsection DLL name prefixes + +In keeping with the naming conventions used by the Microsoft debugging +tools, DLL export symbols are made available with a prefix based on the +DLL name, for instance @code{KERNEL32!CreateFileA}. The plain name is +also entered into the symbol table, so @code{CreateFileA} is often +sufficient. In some cases there will be name clashes within a program +(particularly if the executable itself includes full debugging symbols) +necessitating the use of the fully qualified name when referring to the +contents of the DLL. Use single-quotes around the name to avoid the +exclamation mark (``!'') being interpreted as a language operator. + +Note that the internal name of the DLL may be all upper-case, even +though the file name of the DLL is lower-case, or vice-versa. Since +symbols within @value{GDBN} are @emph{case-sensitive} this may cause +some confusion. If in doubt, try the @code{info functions} and +@code{info variables} commands or even @code{maint print msymbols} (see +@pxref{Symbols}). Here's an example: + +@smallexample +(gdb) info function CreateFileA +All functions matching regular expression "CreateFileA": + +Non-debugging symbols: +0x77e885f4 CreateFileA +0x77e885f4 KERNEL32!CreateFileA +@end smallexample + +@smallexample +(gdb) info function ! +All functions matching regular expression "!": + +Non-debugging symbols: +0x6100114c cygwin1!__assert +0x61004034 cygwin1!_dll_crt0@@0 +0x61004240 cygwin1!dll_crt0(per_process *) +[etc...] +@end smallexample + +@subsubsection Working with minimal symbols + +Symbols extracted from a DLL's export table do not contain very much +type information. All that @value{GDBN} can do is guess whether a symbol +refers to a function or variable depending on the linker section that +contains the symbol. Also note that the actual contents of the memory +contained in a DLL are not available unless the program is running. This +means that you cannot examine the contents of a variable or disassemble +a function within a DLL without a running program. + +Variables are generally treated as pointers and dereferenced +automatically. For this reason, it is often necessary to prefix a +variable name with the address-of operator (``&'') and provide explicit +type information in the command. Here's an example of the type of +problem: + +@smallexample +(gdb) print 'cygwin1!__argv' +$1 = 268572168 +@end smallexample + +@smallexample +(gdb) x 'cygwin1!__argv' +0x10021610: "\230y\"" +@end smallexample + +And two possible solutions: + +@smallexample +(gdb) print ((char **)'cygwin1!__argv')[0] +$2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram" +@end smallexample + +@smallexample +(gdb) x/2x &'cygwin1!__argv' +0x610c0aa8 : 0x10021608 0x00000000 +(gdb) x/x 0x10021608 +0x10021608: 0x0022fd98 +(gdb) x/s 0x0022fd98 +0x22fd98: "/cygdrive/c/mydirectory/myprogram" +@end smallexample + +Setting a break point within a DLL is possible even before the program +starts execution. However, under these circumstances, @value{GDBN} can't +examine the initial instructions of the function in order to skip the +function's frame set-up code. You can work around this by using ``*&'' +to set the breakpoint at a raw memory address: + +@smallexample +(gdb) break *&'python22!PyOS_Readline' +Breakpoint 1 at 0x1e04eff0 +@end smallexample + +The author of these extensions is not entirely convinced that setting a +break point within a shared DLL like @file{kernel32.dll} is completely +safe. + @node Embedded OS @section Embedded Operating Systems @@ -11229,7 +11555,6 @@ configurations. * ARM:: ARM * H8/300:: Hitachi H8/300 * H8/500:: Hitachi H8/500 -* i960:: Intel i960 * M32R/D:: Mitsubishi M32R/D * M68K:: Motorola M68K * MIPS Embedded:: MIPS Embedded @@ -11483,128 +11808,6 @@ memory}. The accepted values for @var{mod} are @code{small}, @end table -@node i960 -@subsection Intel i960 - -@table @code - -@kindex target mon960 -@item target mon960 @var{dev} -MON960 monitor for Intel i960. - -@kindex target nindy -@item target nindy @var{devicename} -An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is -the name of the serial device to use for the connection, e.g. -@file{/dev/ttya}. - -@end table - -@cindex Nindy -@cindex i960 -@dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When -@value{GDBN} is configured to control a remote Intel 960 using Nindy, you can -tell @value{GDBN} how to connect to the 960 in several ways: - -@itemize @bullet -@item -Through command line options specifying serial port, version of the -Nindy protocol, and communications speed; - -@item -By responding to a prompt on startup; - -@item -By using the @code{target} command at any point during your @value{GDBN} -session. @xref{Target Commands, ,Commands for managing targets}. - -@end itemize - -@cindex download to Nindy-960 -With the Nindy interface to an Intel 960 board, @code{load} -downloads @var{filename} to the 960 as well as adding its symbols in -@value{GDBN}. - -@menu -* Nindy Startup:: Startup with Nindy -* Nindy Options:: Options for Nindy -* Nindy Reset:: Nindy reset command -@end menu - -@node Nindy Startup -@subsubsection Startup with Nindy - -If you simply start @code{@value{GDBP}} without using any command-line -options, you are prompted for what serial port to use, @emph{before} you -reach the ordinary @value{GDBN} prompt: - -@smallexample -Attach /dev/ttyNN -- specify NN, or "quit" to quit: -@end smallexample - -@noindent -Respond to the prompt with whatever suffix (after @samp{/dev/tty}) -identifies the serial port you want to use. You can, if you choose, -simply start up with no Nindy connection by responding to the prompt -with an empty line. If you do this and later wish to attach to Nindy, -use @code{target} (@pxref{Target Commands, ,Commands for managing targets}). - -@node Nindy Options -@subsubsection Options for Nindy - -These are the startup options for beginning your @value{GDBN} session with a -Nindy-960 board attached: - -@table @code -@item -r @var{port} -Specify the serial port name of a serial interface to be used to connect -to the target system. This option is only available when @value{GDBN} is -configured for the Intel 960 target architecture. You may specify -@var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a -device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique -suffix for a specific @code{tty} (e.g. @samp{-r a}). - -@item -O -(An uppercase letter ``O'', not a zero.) Specify that @value{GDBN} should use -the ``old'' Nindy monitor protocol to connect to the target system. -This option is only available when @value{GDBN} is configured for the Intel 960 -target architecture. - -@quotation -@emph{Warning:} if you specify @samp{-O}, but are actually trying to -connect to a target system that expects the newer protocol, the connection -fails, appearing to be a speed mismatch. @value{GDBN} repeatedly -attempts to reconnect at several different line speeds. You can abort -this process with an interrupt. -@end quotation - -@item -brk -Specify that @value{GDBN} should first send a @code{BREAK} signal to the target -system, in an attempt to reset it, before connecting to a Nindy target. - -@quotation -@emph{Warning:} Many target systems do not have the hardware that this -requires; it only works with a few boards. -@end quotation -@end table - -The standard @samp{-b} option controls the line speed used on the serial -port. - -@c @group -@node Nindy Reset -@subsubsection Nindy reset command - -@table @code -@item reset -@kindex reset -For a Nindy target, this command sends a ``break'' to the remote target -system; this is only useful if the target has been equipped with a -circuit to perform a hard reset (or some other interesting action) when -a break is detected. -@end table -@c @end group - @node M32R/D @subsection Mitsubishi M32R/D @@ -11646,19 +11849,6 @@ ROM 68K monitor, running on an M68K IDP board. @end table -If @value{GDBN} is configured with @code{m68*-ericsson-*}, it will -instead have only a single special target command: - -@table @code - -@kindex target es1800 -@item target es1800 @var{dev} -ES-1800 emulator for M68K. - -@end table - -[context?] - @table @code @kindex target rombug @@ -11904,7 +12094,7 @@ Set acquisition qualifier for HW trace. Set HW trace stopping criteria. @kindex htrace record -@item htrace record @var{[data]*} +@item htrace record [@var{data}]* Selects the data to be recorded, when qualifier is met and HW trace was triggered. @@ -11915,14 +12105,14 @@ triggered. Enables/disables the HW trace. @kindex htrace rewind -@item htrace rewind @var{[filename]} +@item htrace rewind [@var{filename}] Clears currently recorded trace data. If filename is specified, new trace file is made and any newly collected data will be written there. @kindex htrace print -@item htrace print @var{[start [len]]} +@item htrace print [@var{start} [@var{len}]] Prints trace buffer, using current record configuration. @kindex htrace mode continuous @@ -12653,6 +12843,32 @@ Arguments of type @code{float} will be passed directly to unprototyped functions. @end table +@kindex set cp-abi +@kindex show cp-abi +@value{GDBN} needs to know the ABI used for your program's C@t{++} +objects. The correct C@t{++} ABI depends on which C@t{++} compiler was +used to build your application. @value{GDBN} only fully supports +programs with a single C@t{++} ABI; if your program contains code using +multiple C@t{++} ABI's or if @value{GDBN} can not identify your +program's ABI correctly, you can tell @value{GDBN} which ABI to use. +Currently supported ABI's include ``gnu-v2'', for @code{g++} versions +before 3.0, ``gnu-v3'', for @code{g++} versions 3.0 and later, and +``hpaCC'' for the HP ANSI C@t{++} compiler. Other C@t{++} compilers may +use the ``gnu-v2'' or ``gnu-v3'' ABI's as well. The default setting is +``auto''. + +@table @code +@item show cp-abi +Show the C@t{++} ABI currently in use. + +@item set cp-abi +With no argument, show the list of supported C@t{++} ABI's. + +@item set cp-abi @var{abi} +@itemx set cp-abi auto +Set the current C@t{++} ABI to @var{abi}, or return to automatic detection. +@end table + @node Messages/Warnings @section Optional warnings and messages @@ -12754,6 +12970,14 @@ default is off. @item show debug expression Displays the current state of displaying @value{GDBN} expression debugging info. +@kindex set debug frame +@item set debug frame +Turns on or off display of @value{GDBN} frame debugging info. The +default is off. +@kindex show debug frame +@item show debug frame +Displays the current state of displaying @value{GDBN} frame debugging +info. @kindex set debug overload @item set debug overload Turns on or off display of @value{GDBN} C@t{++} overload debugging @@ -13171,6 +13395,69 @@ string are the simple ones that consist of backslash followed by a letter. @end table +@node Interpreters +@chapter Command Interpreters +@cindex command interpreters + +@value{GDBN} supports multiple command interpreters, and some command +infrastructure to allow users or user interface writers to switch +between interpreters or run commands in other interpreters. + +@value{GDBN} currently supports two command interpreters, the console +interpreter (sometimes called the command-line interpreter or @sc{cli}) +and the machine interface interpreter (or @sc{gdb/mi}). This manual +describes both of these interfaces in great detail. + +By default, @value{GDBN} will start with the console interpreter. +However, the user may choose to start @value{GDBN} with another +interpreter by specifying the @option{-i} or @option{--interpreter} +startup options. Defined interpreters include: + +@table @code +@item console +@cindex console interpreter +The traditional console or command-line interpreter. This is the most often +used interpreter with @value{GDBN}. With no interpreter specified at runtime, +@value{GDBN} will use this interpreter. + +@item mi +@cindex mi interpreter +The newest @sc{gdb/mi} interface (currently @code{mi2}). Used primarily +by programs wishing to use @value{GDBN} as a backend for a debugger GUI +or an IDE. For more information, see @ref{GDB/MI, ,The @sc{gdb/mi} +Interface}. + +@item mi2 +@cindex mi2 interpreter +The current @sc{gdb/mi} interface. + +@item mi1 +@cindex mi1 interpreter +The @sc{gdb/mi} interface included in @value{GDBN} 5.1, 5.2, and 5.3. + +@end table + +@cindex invoke another interpreter +The interpreter being used by @value{GDBN} may not be dynamically +switched at runtime. Although possible, this could lead to a very +precarious situation. Consider an IDE using @sc{gdb/mi}. If a user +enters the command "interpreter-set console" in a console view, +@value{GDBN} would switch to using the console interpreter, rendering +the IDE inoperable! + +@kindex interpreter-exec +Although you may only choose a single interpreter at startup, you may execute +commands in any interpreter from the current interpreter using the appropriate +command. If you are running the console interpreter, simply use the +@code{interpreter-exec} command: + +@smallexample +interpreter-exec mi "-data-list-register-names" +@end smallexample + +@sc{gdb/mi} has a similar command, although it is only available in versions of +@value{GDBN} which support @sc{gdb/mi} version 2 (or greater). + @node TUI @chapter @value{GDBN} Text User Interface @cindex TUI @@ -13758,1681 +14045,7451 @@ environment. Users of this environment can use a new command, each value is printed in its own window. @end ignore -@include annotate.texi -@include gdbmi.texinfo -@node GDB Bugs -@chapter Reporting Bugs in @value{GDBN} -@cindex bugs in @value{GDBN} -@cindex reporting bugs in @value{GDBN} +@node GDB/MI +@chapter The @sc{gdb/mi} Interface -Your bug reports play an essential role in making @value{GDBN} reliable. +@unnumberedsec Function and Purpose -Reporting a bug may help you by bringing a solution to your problem, or it -may not. But in any case the principal function of a bug report is to help -the entire community by making the next version of @value{GDBN} work better. Bug -reports are your contribution to the maintenance of @value{GDBN}. +@cindex @sc{gdb/mi}, its purpose +@sc{gdb/mi} is a line based machine oriented text interface to @value{GDBN}. It is +specifically intended to support the development of systems which use +the debugger as just one small component of a larger system. -In order for a bug report to serve its purpose, you must include the -information that enables us to fix the bug. +This chapter is a specification of the @sc{gdb/mi} interface. It is written +in the form of a reference manual. -@menu -* Bug Criteria:: Have you found a bug? -* Bug Reporting:: How to report bugs -@end menu +Note that @sc{gdb/mi} is still under construction, so some of the +features described below are incomplete and subject to change. -@node Bug Criteria -@section Have you found a bug? -@cindex bug criteria +@unnumberedsec Notation and Terminology -If you are not sure whether you have found a bug, here are some guidelines: +@cindex notational conventions, for @sc{gdb/mi} +This chapter uses the following notation: @itemize @bullet -@cindex fatal signal -@cindex debugger crash -@cindex crash of debugger @item -If the debugger gets a fatal signal, for any input whatever, that is a -@value{GDBN} bug. Reliable debuggers never crash. +@code{|} separates two alternatives. -@cindex error on valid input @item -If @value{GDBN} produces an error message for valid input, that is a -bug. (Note that if you're cross debugging, the problem may also be -somewhere in the connection to the target.) +@code{[ @var{something} ]} indicates that @var{something} is optional: +it may or may not be given. -@cindex invalid input @item -If @value{GDBN} does not produce an error message for invalid input, -that is a bug. However, you should note that your idea of -``invalid input'' might be our idea of ``an extension'' or ``support -for traditional practice''. +@code{( @var{group} )*} means that @var{group} inside the parentheses +may repeat zero or more times. @item -If you are an experienced user of debugging tools, your suggestions -for improvement of @value{GDBN} are welcome in any case. +@code{( @var{group} )+} means that @var{group} inside the parentheses +may repeat one or more times. + +@item +@code{"@var{string}"} means a literal @var{string}. @end itemize -@node Bug Reporting -@section How to report bugs -@cindex bug reports -@cindex @value{GDBN} bugs, reporting +@ignore +@heading Dependencies +@end ignore -A number of companies and individuals offer support for @sc{gnu} products. -If you obtained @value{GDBN} from a support organization, we recommend you -contact that organization first. +@heading Acknowledgments -You can find contact information for many support companies and -individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs -distribution. -@c should add a web page ref... +In alphabetic order: Andrew Cagney, Fernando Nasser, Stan Shebs and +Elena Zannoni. -In any event, we also recommend that you submit bug reports for -@value{GDBN}. The prefered method is to submit them directly using -@uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web -page}. Alternatively, the @email{bug-gdb@@gnu.org, e-mail gateway} can -be used. +@menu +* GDB/MI Command Syntax:: +* GDB/MI Compatibility with CLI:: +* GDB/MI Output Records:: +* GDB/MI Command Description Format:: +* GDB/MI Breakpoint Table Commands:: +* GDB/MI Data Manipulation:: +* GDB/MI Program Control:: +* GDB/MI Miscellaneous Commands:: +@ignore +* GDB/MI Kod Commands:: +* GDB/MI Memory Overlay Commands:: +* GDB/MI Signal Handling Commands:: +@end ignore +* GDB/MI Stack Manipulation:: +* GDB/MI Symbol Query:: +* GDB/MI Target Manipulation:: +* GDB/MI Thread Commands:: +* GDB/MI Tracepoint Commands:: +* GDB/MI Variable Objects:: +@end menu -@strong{Do not send bug reports to @samp{info-gdb}, or to -@samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do -not want to receive bug reports. Those that do have arranged to receive -@samp{bug-gdb}. +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Command Syntax +@section @sc{gdb/mi} Command Syntax -The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which -serves as a repeater. The mailing list and the newsgroup carry exactly -the same messages. Often people think of posting bug reports to the -newsgroup instead of mailing them. This appears to work, but it has one -problem which can be crucial: a newsgroup posting often lacks a mail -path back to the sender. Thus, if we need to ask for more information, -we may be unable to reach you. For this reason, it is better to send -bug reports to the mailing list. +@menu +* GDB/MI Input Syntax:: +* GDB/MI Output Syntax:: +* GDB/MI Simple Examples:: +@end menu -The fundamental principle of reporting bugs usefully is this: -@strong{report all the facts}. If you are not sure whether to state a -fact or leave it out, state it! +@node GDB/MI Input Syntax +@subsection @sc{gdb/mi} Input Syntax -Often people omit facts because they think they know what causes the -problem and assume that some details do not matter. Thus, you might -assume that the name of the variable you use in an example does not matter. -Well, probably it does not, but one cannot be sure. Perhaps the bug is a -stray memory reference which happens to fetch from the location where that -name is stored in memory; perhaps, if the name were different, the contents -of that location would fool the debugger into doing the right thing despite -the bug. Play it safe and give a specific, complete example. That is the -easiest thing for you to do, and the most helpful. +@cindex input syntax for @sc{gdb/mi} +@cindex @sc{gdb/mi}, input syntax +@table @code +@item @var{command} @expansion{} +@code{@var{cli-command} | @var{mi-command}} -Keep in mind that the purpose of a bug report is to enable us to fix the -bug. It may be that the bug has been reported previously, but neither -you nor we can know that unless your bug report is complete and -self-contained. +@item @var{cli-command} @expansion{} +@code{[ @var{token} ] @var{cli-command} @var{nl}}, where +@var{cli-command} is any existing @value{GDBN} CLI command. -Sometimes people give a few sketchy facts and ask, ``Does this ring a -bell?'' Those bug reports are useless, and we urge everyone to -@emph{refuse to respond to them} except to chide the sender to report -bugs properly. +@item @var{mi-command} @expansion{} +@code{[ @var{token} ] "-" @var{operation} ( " " @var{option} )* +@code{[} " --" @code{]} ( " " @var{parameter} )* @var{nl}} -To enable us to fix the bug, you should include all these things: +@item @var{token} @expansion{} +"any sequence of digits" -@itemize @bullet -@item -The version of @value{GDBN}. @value{GDBN} announces it if you start -with no arguments; you can also print it at any time using @code{show -version}. +@item @var{option} @expansion{} +@code{"-" @var{parameter} [ " " @var{parameter} ]} -Without this, we will not know whether there is any point in looking for -the bug in the current version of @value{GDBN}. +@item @var{parameter} @expansion{} +@code{@var{non-blank-sequence} | @var{c-string}} -@item -The type of machine you are using, and the operating system name and -version number. +@item @var{operation} @expansion{} +@emph{any of the operations described in this chapter} -@item -What compiler (and its version) was used to compile @value{GDBN}---e.g. -``@value{GCC}--2.8.1''. +@item @var{non-blank-sequence} @expansion{} +@emph{anything, provided it doesn't contain special characters such as +"-", @var{nl}, """ and of course " "} -@item -What compiler (and its version) was used to compile the program you are -debugging---e.g. ``@value{GCC}--2.8.1'', or ``HP92453-01 A.10.32.03 HP -C Compiler''. For GCC, you can say @code{gcc --version} to get this -information; for other compilers, see the documentation for those -compilers. +@item @var{c-string} @expansion{} +@code{""" @var{seven-bit-iso-c-string-content} """} -@item -The command arguments you gave the compiler to compile your example and -observe the bug. For example, did you use @samp{-O}? To guarantee -you will not omit something important, list them all. A copy of the -Makefile (or the output from make) is sufficient. +@item @var{nl} @expansion{} +@code{CR | CR-LF} +@end table -If we were to try to guess the arguments, we would probably guess wrong -and then we might not encounter the bug. +@noindent +Notes: +@itemize @bullet @item -A complete input script, and all necessary source files, that will -reproduce the bug. +The CLI commands are still handled by the @sc{mi} interpreter; their +output is described below. @item -A description of what behavior you observe that you believe is -incorrect. For example, ``It gets a fatal signal.'' - -Of course, if the bug is that @value{GDBN} gets a fatal signal, then we -will certainly notice it. But if the bug is incorrect output, we might -not notice unless it is glaringly wrong. You might as well not give us -a chance to make a mistake. - -Even if the problem you experience is a fatal signal, you should still -say so explicitly. Suppose something strange is going on, such as, your -copy of @value{GDBN} is out of synch, or you have encountered a bug in -the C library on your system. (This has happened!) Your copy might -crash and ours would not. If you told us to expect a crash, then when -ours fails to crash, we would know that the bug was not happening for -us. If you had not told us to expect a crash, then we would not be able -to draw any conclusion from our observations. +The @code{@var{token}}, when present, is passed back when the command +finishes. @item -If you wish to suggest changes to the @value{GDBN} source, send us context -diffs. If you even discuss something in the @value{GDBN} source, refer to -it by context, not by line number. - -The line numbers in our development sources will not match those in your -sources. Your line numbers would convey no useful information to us. - +Some @sc{mi} commands accept optional arguments as part of the parameter +list. Each option is identified by a leading @samp{-} (dash) and may be +followed by an optional argument parameter. Options occur first in the +parameter list and can be delimited from normal parameters using +@samp{--} (this is useful when some parameters begin with a dash). @end itemize -Here are some things that are not necessary: +Pragmatics: @itemize @bullet @item -A description of the envelope of the bug. - -Often people who encounter a bug spend a lot of time investigating -which changes to the input file will make the bug go away and which -changes will not affect it. - -This is often time consuming and not very useful, because the way we -will find the bug is by running a single example under the debugger -with breakpoints, not by pure deduction from a series of examples. -We recommend that you save your time for something else. - -Of course, if you can find a simpler example to report @emph{instead} -of the original one, that is a convenience for us. Errors in the -output will be easier to spot, running under the debugger will take -less time, and so on. - -However, simplification is not vital; if you do not want to do this, -report the bug anyway and send us the entire test case you used. +We want easy access to the existing CLI syntax (for debugging). @item -A patch for the bug. +We want it to be easy to spot a @sc{mi} operation. +@end itemize -A patch for the bug does help us if it is a good one. But do not omit -the necessary information, such as the test case, on the assumption that -a patch is all we need. We might see problems with your patch and decide -to fix the problem another way, or we might not understand it at all. +@node GDB/MI Output Syntax +@subsection @sc{gdb/mi} Output Syntax -Sometimes with a program as complicated as @value{GDBN} it is very hard to -construct an example that will make the program follow a certain path -through the code. If you do not send us the example, we will not be able -to construct one, so we will not be able to verify that the bug is fixed. +@cindex output syntax of @sc{gdb/mi} +@cindex @sc{gdb/mi}, output syntax +The output from @sc{gdb/mi} consists of zero or more out-of-band records +followed, optionally, by a single result record. This result record +is for the most recent command. The sequence of output records is +terminated by @samp{(@value{GDBP})}. -And if we cannot understand what bug you are trying to fix, or why your -patch should be an improvement, we will not install it. A test case will -help us to understand. +If an input command was prefixed with a @code{@var{token}} then the +corresponding output for that command will also be prefixed by that same +@var{token}. -@item -A guess about what the bug is or what it depends on. +@table @code +@item @var{output} @expansion{} +@code{( @var{out-of-band-record} )* [ @var{result-record} ] "(gdb)" @var{nl}} -Such guesses are usually wrong. Even we cannot guess right about such -things without first using the debugger to find the facts. -@end itemize +@item @var{result-record} @expansion{} +@code{ [ @var{token} ] "^" @var{result-class} ( "," @var{result} )* @var{nl}} -@c The readline documentation is distributed with the readline code -@c and consists of the two following files: -@c rluser.texinfo -@c inc-hist.texinfo -@c Use -I with makeinfo to point to the appropriate directory, -@c environment var TEXINPUTS with TeX. -@include rluser.texinfo -@include inc-hist.texinfo +@item @var{out-of-band-record} @expansion{} +@code{@var{async-record} | @var{stream-record}} +@item @var{async-record} @expansion{} +@code{@var{exec-async-output} | @var{status-async-output} | @var{notify-async-output}} -@node Formatting Documentation -@appendix Formatting Documentation +@item @var{exec-async-output} @expansion{} +@code{[ @var{token} ] "*" @var{async-output}} -@cindex @value{GDBN} reference card -@cindex reference card -The @value{GDBN} 4 release includes an already-formatted reference card, ready -for printing with PostScript or Ghostscript, in the @file{gdb} -subdirectory of the main source directory@footnote{In -@file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN} -release.}. If you can use PostScript or Ghostscript with your printer, -you can print the reference card immediately with @file{refcard.ps}. +@item @var{status-async-output} @expansion{} +@code{[ @var{token} ] "+" @var{async-output}} -The release also includes the source for the reference card. You -can format it, using @TeX{}, by typing: +@item @var{notify-async-output} @expansion{} +@code{[ @var{token} ] "=" @var{async-output}} -@smallexample -make refcard.dvi -@end smallexample +@item @var{async-output} @expansion{} +@code{@var{async-class} ( "," @var{result} )* @var{nl}} -The @value{GDBN} reference card is designed to print in @dfn{landscape} -mode on US ``letter'' size paper; -that is, on a sheet 11 inches wide by 8.5 inches -high. You will need to specify this form of printing as an option to -your @sc{dvi} output program. +@item @var{result-class} @expansion{} +@code{"done" | "running" | "connected" | "error" | "exit"} -@cindex documentation +@item @var{async-class} @expansion{} +@code{"stopped" | @var{others}} (where @var{others} will be added +depending on the needs---this is still in development). -All the documentation for @value{GDBN} comes as part of the machine-readable -distribution. The documentation is written in Texinfo format, which is -a documentation system that uses a single source file to produce both -on-line information and a printed manual. You can use one of the Info -formatting commands to create the on-line version of the documentation -and @TeX{} (or @code{texi2roff}) to typeset the printed version. +@item @var{result} @expansion{} +@code{ @var{variable} "=" @var{value}} -@value{GDBN} includes an already formatted copy of the on-line Info -version of this manual in the @file{gdb} subdirectory. The main Info -file is @file{gdb-@value{GDBVN}/gdb/gdb.info}, and it refers to -subordinate files matching @samp{gdb.info*} in the same directory. If -necessary, you can print out these files, or read them with any editor; -but they are easier to read using the @code{info} subsystem in @sc{gnu} -Emacs or the standalone @code{info} program, available as part of the -@sc{gnu} Texinfo distribution. +@item @var{variable} @expansion{} +@code{ @var{string} } -If you want to format these Info files yourself, you need one of the -Info formatting programs, such as @code{texinfo-format-buffer} or -@code{makeinfo}. +@item @var{value} @expansion{} +@code{ @var{const} | @var{tuple} | @var{list} } -If you have @code{makeinfo} installed, and are in the top level -@value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of -version @value{GDBVN}), you can make the Info file by typing: +@item @var{const} @expansion{} +@code{@var{c-string}} -@smallexample -cd gdb -make gdb.info -@end smallexample +@item @var{tuple} @expansion{} +@code{ "@{@}" | "@{" @var{result} ( "," @var{result} )* "@}" } -If you want to typeset and print copies of this manual, you need @TeX{}, -a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the -Texinfo definitions file. +@item @var{list} @expansion{} +@code{ "[]" | "[" @var{value} ( "," @var{value} )* "]" | "[" +@var{result} ( "," @var{result} )* "]" } -@TeX{} is a typesetting program; it does not print files directly, but -produces output files called @sc{dvi} files. To print a typeset -document, you need a program to print @sc{dvi} files. If your system -has @TeX{} installed, chances are it has such a program. The precise -command to use depends on your system; @kbd{lpr -d} is common; another -(for PostScript devices) is @kbd{dvips}. The @sc{dvi} print command may -require a file name without any extension or a @samp{.dvi} extension. +@item @var{stream-record} @expansion{} +@code{@var{console-stream-output} | @var{target-stream-output} | @var{log-stream-output}} -@TeX{} also requires a macro definitions file called -@file{texinfo.tex}. This file tells @TeX{} how to typeset a document -written in Texinfo format. On its own, @TeX{} cannot either read or -typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB -and is located in the @file{gdb-@var{version-number}/texinfo} -directory. +@item @var{console-stream-output} @expansion{} +@code{"~" @var{c-string}} -If you have @TeX{} and a @sc{dvi} printer program installed, you can -typeset and print this manual. First switch to the the @file{gdb} -subdirectory of the main source directory (for example, to -@file{gdb-@value{GDBVN}/gdb}) and type: +@item @var{target-stream-output} @expansion{} +@code{"@@" @var{c-string}} -@smallexample -make gdb.dvi -@end smallexample +@item @var{log-stream-output} @expansion{} +@code{"&" @var{c-string}} -Then give @file{gdb.dvi} to your @sc{dvi} printing program. +@item @var{nl} @expansion{} +@code{CR | CR-LF} -@node Installing GDB -@appendix Installing @value{GDBN} -@cindex configuring @value{GDBN} -@cindex installation +@item @var{token} @expansion{} +@emph{any sequence of digits}. +@end table -@value{GDBN} comes with a @code{configure} script that automates the process -of preparing @value{GDBN} for installation; you can then use @code{make} to -build the @code{gdb} program. -@iftex -@c irrelevant in info file; it's as current as the code it lives with. -@footnote{If you have a more recent version of @value{GDBN} than @value{GDBVN}, -look at the @file{README} file in the sources; we may have improved the -installation procedures since publishing this manual.} -@end iftex +@noindent +Notes: -The @value{GDBN} distribution includes all the source code you need for -@value{GDBN} in a single directory, whose name is usually composed by -appending the version number to @samp{gdb}. +@itemize @bullet +@item +All output sequences end in a single line containing a period. -For example, the @value{GDBN} version @value{GDBVN} distribution is in the -@file{gdb-@value{GDBVN}} directory. That directory contains: +@item +The @code{@var{token}} is from the corresponding request. If an execution +command is interrupted by the @samp{-exec-interrupt} command, the +@var{token} associated with the @samp{*stopped} message is the one of the +original execution command, not the one of the interrupt command. -@table @code -@item gdb-@value{GDBVN}/configure @r{(and supporting files)} -script for configuring @value{GDBN} and all its supporting libraries +@item +@cindex status output in @sc{gdb/mi} +@var{status-async-output} contains on-going status information about the +progress of a slow operation. It can be discarded. All status output is +prefixed by @samp{+}. -@item gdb-@value{GDBVN}/gdb -the source specific to @value{GDBN} itself +@item +@cindex async output in @sc{gdb/mi} +@var{exec-async-output} contains asynchronous state change on the target +(stopped, started, disappeared). All async output is prefixed by +@samp{*}. -@item gdb-@value{GDBVN}/bfd -source for the Binary File Descriptor library +@item +@cindex notify output in @sc{gdb/mi} +@var{notify-async-output} contains supplementary information that the +client should handle (e.g., a new breakpoint information). All notify +output is prefixed by @samp{=}. -@item gdb-@value{GDBVN}/include -@sc{gnu} include files +@item +@cindex console output in @sc{gdb/mi} +@var{console-stream-output} is output that should be displayed as is in the +console. It is the textual response to a CLI command. All the console +output is prefixed by @samp{~}. -@item gdb-@value{GDBVN}/libiberty -source for the @samp{-liberty} free software library +@item +@cindex target output in @sc{gdb/mi} +@var{target-stream-output} is the output produced by the target program. +All the target output is prefixed by @samp{@@}. -@item gdb-@value{GDBVN}/opcodes -source for the library of opcode tables and disassemblers +@item +@cindex log output in @sc{gdb/mi} +@var{log-stream-output} is output text coming from @value{GDBN}'s internals, for +instance messages that should be displayed as part of an error log. All +the log output is prefixed by @samp{&}. -@item gdb-@value{GDBVN}/readline -source for the @sc{gnu} command-line interface +@item +@cindex list output in @sc{gdb/mi} +New @sc{gdb/mi} commands should only output @var{lists} containing +@var{values}. -@item gdb-@value{GDBVN}/glob -source for the @sc{gnu} filename pattern-matching subroutine -@item gdb-@value{GDBVN}/mmalloc -source for the @sc{gnu} memory-mapped malloc package -@end table +@end itemize -The simplest way to configure and build @value{GDBN} is to run @code{configure} -from the @file{gdb-@var{version-number}} source directory, which in -this example is the @file{gdb-@value{GDBVN}} directory. +@xref{GDB/MI Stream Records, , @sc{gdb/mi} Stream Records}, for more +details about the various output records. -First switch to the @file{gdb-@var{version-number}} source directory -if you are not already in it; then run @code{configure}. Pass the -identifier for the platform on which @value{GDBN} will run as an -argument. +@node GDB/MI Simple Examples +@subsection Simple Examples of @sc{gdb/mi} Interaction +@cindex @sc{gdb/mi}, simple examples -For example: +This subsection presents several simple examples of interaction using +the @sc{gdb/mi} interface. In these examples, @samp{->} means that the +following line is passed to @sc{gdb/mi} as input, while @samp{<-} means +the output received from @sc{gdb/mi}. + +@subsubheading Target Stop +@c Ummm... There is no "-stop" command. This assumes async, no? +Here's an example of stopping the inferior process: @smallexample -cd gdb-@value{GDBVN} -./configure @var{host} -make +-> -stop +<- (@value{GDBP}) @end smallexample @noindent -where @var{host} is an identifier such as @samp{sun4} or -@samp{decstation}, that identifies the platform where @value{GDBN} will run. -(You can often leave off @var{host}; @code{configure} tries to guess the -correct value by examining your system.) +and later: -Running @samp{configure @var{host}} and then running @code{make} builds the -@file{bfd}, @file{readline}, @file{mmalloc}, and @file{libiberty} -libraries, then @code{gdb} itself. The configured source files, and the -binaries, are left in the corresponding source directories. +@smallexample +<- *stop,reason="stop",address="0x123",source="a.c:123" +<- (@value{GDBP}) +@end smallexample -@need 750 -@code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your -system does not recognize this automatically when you run a different -shell, you may need to run @code{sh} on it explicitly: +@subsubheading Simple CLI Command + +Here's an example of a simple CLI command being passed through +@sc{gdb/mi} and on to the CLI. @smallexample -sh configure @var{host} +-> print 1+2 +<- &"print 1+2\n" +<- ~"$1 = 3\n" +<- ^done +<- (@value{GDBP}) @end smallexample -If you run @code{configure} from a directory that contains source -directories for multiple libraries or programs, such as the -@file{gdb-@value{GDBVN}} source directory for version @value{GDBVN}, @code{configure} -creates configuration files for every directory level underneath (unless -you tell it not to, with the @samp{--norecursion} option). +@subsubheading Command With Side Effects + +@smallexample +-> -symbol-file xyz.exe +<- *breakpoint,nr="3",address="0x123",source="a.c:123" +<- (@value{GDBP}) +@end smallexample -You can run the @code{configure} script from any of the -subordinate directories in the @value{GDBN} distribution if you only want to -configure that subdirectory, but be sure to specify a path to it. +@subsubheading A Bad Command -For example, with version @value{GDBVN}, type the following to configure only -the @code{bfd} subdirectory: +Here's what happens if you pass a non-existent command: @smallexample -@group -cd gdb-@value{GDBVN}/bfd -../configure @var{host} -@end group +-> -rubbish +<- ^error,msg="Undefined MI command: rubbish" +<- (@value{GDBP}) @end smallexample -You can install @code{@value{GDBP}} anywhere; it has no hardwired paths. -However, you should make sure that the shell on your path (named by -the @samp{SHELL} environment variable) is publicly readable. Remember -that @value{GDBN} uses the shell to start your program---some systems refuse to -let @value{GDBN} debug child processes whose programs are not readable. +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Compatibility with CLI +@section @sc{gdb/mi} Compatibility with CLI + +@cindex compatibility, @sc{gdb/mi} and CLI +@cindex @sc{gdb/mi}, compatibility with CLI +To help users familiar with @value{GDBN}'s existing CLI interface, @sc{gdb/mi} +accepts existing CLI commands. As specified by the syntax, such +commands can be directly entered into the @sc{gdb/mi} interface and @value{GDBN} will +respond. + +This mechanism is provided as an aid to developers of @sc{gdb/mi} +clients and not as a reliable interface into the CLI. Since the command +is being interpreteted in an environment that assumes @sc{gdb/mi} +behaviour, the exact output of such commands is likely to end up being +an un-supported hybrid of @sc{gdb/mi} and CLI output. + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Output Records +@section @sc{gdb/mi} Output Records @menu -* Separate Objdir:: Compiling @value{GDBN} in another directory -* Config Names:: Specifying names for hosts and targets -* Configure Options:: Summary of options for configure +* GDB/MI Result Records:: +* GDB/MI Stream Records:: +* GDB/MI Out-of-band Records:: @end menu -@node Separate Objdir -@section Compiling @value{GDBN} in another directory - -If you want to run @value{GDBN} versions for several host or target machines, -you need a different @code{gdb} compiled for each combination of -host and target. @code{configure} is designed to make this easy by -allowing you to generate each configuration in a separate subdirectory, -rather than in the source directory. If your @code{make} program -handles the @samp{VPATH} feature (@sc{gnu} @code{make} does), running -@code{make} in each of these directories builds the @code{gdb} -program specified there. +@node GDB/MI Result Records +@subsection @sc{gdb/mi} Result Records -To build @code{gdb} in a separate directory, run @code{configure} -with the @samp{--srcdir} option to specify where to find the source. -(You also need to specify a path to find @code{configure} -itself from your working directory. If the path to @code{configure} -would be the same as the argument to @samp{--srcdir}, you can leave out -the @samp{--srcdir} option; it is assumed.) +@cindex result records in @sc{gdb/mi} +@cindex @sc{gdb/mi}, result records +In addition to a number of out-of-band notifications, the response to a +@sc{gdb/mi} command includes one of the following result indications: -For example, with version @value{GDBVN}, you can build @value{GDBN} in a -separate directory for a Sun 4 like this: +@table @code +@findex ^done +@item "^done" [ "," @var{results} ] +The synchronous operation was successful, @code{@var{results}} are the return +values. + +@item "^running" +@findex ^running +@c Is this one correct? Should it be an out-of-band notification? +The asynchronous operation was successfully started. The target is +running. -@smallexample -@group -cd gdb-@value{GDBVN} -mkdir ../gdb-sun4 -cd ../gdb-sun4 -../gdb-@value{GDBVN}/configure sun4 -make -@end group -@end smallexample +@item "^error" "," @var{c-string} +@findex ^error +The operation failed. The @code{@var{c-string}} contains the corresponding +error message. +@end table -When @code{configure} builds a configuration using a remote source -directory, it creates a tree for the binaries with the same structure -(and using the same names) as the tree under the source directory. In -the example, you'd find the Sun 4 library @file{libiberty.a} in the -directory @file{gdb-sun4/libiberty}, and @value{GDBN} itself in -@file{gdb-sun4/gdb}. +@node GDB/MI Stream Records +@subsection @sc{gdb/mi} Stream Records -One popular reason to build several @value{GDBN} configurations in separate -directories is to configure @value{GDBN} for cross-compiling (where -@value{GDBN} runs on one machine---the @dfn{host}---while debugging -programs that run on another machine---the @dfn{target}). -You specify a cross-debugging target by -giving the @samp{--target=@var{target}} option to @code{configure}. +@cindex @sc{gdb/mi}, stream records +@cindex stream records in @sc{gdb/mi} +@value{GDBN} internally maintains a number of output streams: the console, the +target, and the log. The output intended for each of these streams is +funneled through the @sc{gdb/mi} interface using @dfn{stream records}. -When you run @code{make} to build a program or library, you must run -it in a configured directory---whatever directory you were in when you -called @code{configure} (or one of its subdirectories). +Each stream record begins with a unique @dfn{prefix character} which +identifies its stream (@pxref{GDB/MI Output Syntax, , @sc{gdb/mi} Output +Syntax}). In addition to the prefix, each stream record contains a +@code{@var{string-output}}. This is either raw text (with an implicit new +line) or a quoted C string (which does not contain an implicit newline). -The @code{Makefile} that @code{configure} generates in each source -directory also runs recursively. If you type @code{make} in a source -directory such as @file{gdb-@value{GDBVN}} (or in a separate configured -directory configured with @samp{--srcdir=@var{dirname}/gdb-@value{GDBVN}}), you -will build all the required libraries, and then build GDB. +@table @code +@item "~" @var{string-output} +The console output stream contains text that should be displayed in the +CLI console window. It contains the textual responses to CLI commands. -When you have multiple hosts or targets configured in separate -directories, you can run @code{make} on them in parallel (for example, -if they are NFS-mounted on each of the hosts); they will not interfere -with each other. +@item "@@" @var{string-output} +The target output stream contains any textual output from the running +target. -@node Config Names -@section Specifying names for hosts and targets +@item "&" @var{string-output} +The log stream contains debugging messages being produced by @value{GDBN}'s +internals. +@end table -The specifications used for hosts and targets in the @code{configure} -script are based on a three-part naming scheme, but some short predefined -aliases are also supported. The full naming scheme encodes three pieces -of information in the following pattern: +@node GDB/MI Out-of-band Records +@subsection @sc{gdb/mi} Out-of-band Records -@smallexample -@var{architecture}-@var{vendor}-@var{os} -@end smallexample +@cindex out-of-band records in @sc{gdb/mi} +@cindex @sc{gdb/mi}, out-of-band records +@dfn{Out-of-band} records are used to notify the @sc{gdb/mi} client of +additional changes that have occurred. Those changes can either be a +consequence of @sc{gdb/mi} (e.g., a breakpoint modified) or a result of +target activity (e.g., target stopped). -For example, you can use the alias @code{sun4} as a @var{host} argument, -or as the value for @var{target} in a @code{--target=@var{target}} -option. The equivalent full name is @samp{sparc-sun-sunos4}. +The following is a preliminary list of possible out-of-band records. -The @code{configure} script accompanying @value{GDBN} does not provide -any query facility to list all supported host and target names or -aliases. @code{configure} calls the Bourne shell script -@code{config.sub} to map abbreviations to full names; you can read the -script, if you wish, or you can use it to test your guesses on -abbreviations---for example: +@table @code +@item "*" "stop" +@end table -@smallexample -% sh config.sub i386-linux -i386-pc-linux-gnu -% sh config.sub alpha-linux -alpha-unknown-linux-gnu -% sh config.sub hp9k700 -hppa1.1-hp-hpux -% sh config.sub sun4 -sparc-sun-sunos4.1.1 -% sh config.sub sun3 -m68k-sun-sunos4.1.1 -% sh config.sub i986v -Invalid configuration `i986v': machine `i986v' not recognized -@end smallexample -@noindent -@code{config.sub} is also distributed in the @value{GDBN} source -directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}). +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Command Description Format +@section @sc{gdb/mi} Command Description Format -@node Configure Options -@section @code{configure} options +The remaining sections describe blocks of commands. Each block of +commands is laid out in a fashion similar to this section. -Here is a summary of the @code{configure} options and arguments that -are most often useful for building @value{GDBN}. @code{configure} also has -several other options not listed here. @inforef{What Configure -Does,,configure.info}, for a full explanation of @code{configure}. +Note the the line breaks shown in the examples are here only for +readability. They don't appear in the real output. +Also note that the commands with a non-available example (N.A.@:) are +not yet implemented. -@smallexample -configure @r{[}--help@r{]} - @r{[}--prefix=@var{dir}@r{]} - @r{[}--exec-prefix=@var{dir}@r{]} - @r{[}--srcdir=@var{dirname}@r{]} - @r{[}--norecursion@r{]} @r{[}--rm@r{]} - @r{[}--target=@var{target}@r{]} - @var{host} -@end smallexample +@subheading Motivation -@noindent -You may introduce options with a single @samp{-} rather than -@samp{--} if you prefer; but you may abbreviate option names if you use -@samp{--}. +The motivation for this collection of commands. -@table @code -@item --help -Display a quick summary of how to invoke @code{configure}. +@subheading Introduction -@item --prefix=@var{dir} -Configure the source to install programs and files under directory -@file{@var{dir}}. +A brief introduction to this collection of commands as a whole. -@item --exec-prefix=@var{dir} -Configure the source to install programs under directory -@file{@var{dir}}. +@subheading Commands -@c avoid splitting the warning from the explanation: -@need 2000 -@item --srcdir=@var{dirname} -@strong{Warning: using this option requires @sc{gnu} @code{make}, or another -@code{make} that implements the @code{VPATH} feature.}@* -Use this option to make configurations in directories separate from the -@value{GDBN} source directories. Among other things, you can use this to -build (or maintain) several configurations simultaneously, in separate -directories. @code{configure} writes configuration specific files in -the current directory, but arranges for them to use the source in the -directory @var{dirname}. @code{configure} creates directories under -the working directory in parallel to the source directories below -@var{dirname}. +For each command in the block, the following is described: -@item --norecursion -Configure only the directory level where @code{configure} is executed; do not -propagate configuration to subdirectories. +@subsubheading Synopsis -@item --target=@var{target} -Configure @value{GDBN} for cross-debugging programs running on the specified -@var{target}. Without this option, @value{GDBN} is configured to debug -programs that run on the same machine (@var{host}) as @value{GDBN} itself. +@smallexample + -command @var{args}@dots{} +@end smallexample -There is no convenient way to generate a list of all available targets. +@subsubheading @value{GDBN} Command -@item @var{host} @dots{} -Configure @value{GDBN} to run on the specified @var{host}. +The corresponding @value{GDBN} CLI command. -There is no convenient way to generate a list of all available hosts. -@end table +@subsubheading Result -There are many other options available as well, but they are generally -needed for special purposes only. +@subsubheading Out-of-band -@node Maintenance Commands -@appendix Maintenance Commands -@cindex maintenance commands -@cindex internal commands +@subsubheading Notes -In addition to commands intended for @value{GDBN} users, @value{GDBN} -includes a number of commands intended for @value{GDBN} developers. -These commands are provided here for reference. +@subsubheading Example -@table @code -@kindex maint info breakpoints -@item @anchor{maint info breakpoints}maint info breakpoints -Using the same format as @samp{info breakpoints}, display both the -breakpoints you've set explicitly, and those @value{GDBN} is using for -internal purposes. Internal breakpoints are shown with negative -breakpoint numbers. The type column identifies what kind of breakpoint -is shown: -@table @code -@item breakpoint -Normal, explicitly set breakpoint. +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Breakpoint Table Commands +@section @sc{gdb/mi} Breakpoint table commands -@item watchpoint -Normal, explicitly set watchpoint. +@cindex breakpoint commands for @sc{gdb/mi} +@cindex @sc{gdb/mi}, breakpoint commands +This section documents @sc{gdb/mi} commands for manipulating +breakpoints. -@item longjmp -Internal breakpoint, used to handle correctly stepping through -@code{longjmp} calls. +@subheading The @code{-break-after} Command +@findex -break-after -@item longjmp resume -Internal breakpoint at the target of a @code{longjmp}. +@subsubheading Synopsis -@item until -Temporary internal breakpoint used by the @value{GDBN} @code{until} command. +@smallexample + -break-after @var{number} @var{count} +@end smallexample -@item finish -Temporary internal breakpoint used by the @value{GDBN} @code{finish} command. +The breakpoint number @var{number} is not in effect until it has been +hit @var{count} times. To see how this is reflected in the output of +the @samp{-break-list} command, see the description of the +@samp{-break-list} command below. -@item shlib events -Shared library events. +@subsubheading @value{GDBN} Command -@end table +The corresponding @value{GDBN} command is @samp{ignore}. -@kindex maint internal-error -@kindex maint internal-warning -@item maint internal-error -@itemx maint internal-warning -Cause @value{GDBN} to call the internal function @code{internal_error} -or @code{internal_warning} and hence behave as though an internal error -or internal warning has been detected. In addition to reporting the -internal problem, these functions give the user the opportunity to -either quit @value{GDBN} or create a core file of the current -@value{GDBN} session. +@subsubheading Example @smallexample -(gdb) @kbd{maint internal-error testing, 1, 2} -@dots{}/maint.c:121: internal-error: testing, 1, 2 -A problem internal to GDB has been detected. Further -debugging may prove unreliable. -Quit this debugging session? (y or n) @kbd{n} -Create a core file? (y or n) @kbd{n} -(gdb) +(@value{GDBP}) +-break-insert main +^done,bkpt=@{number="1",addr="0x000100d0",file="hello.c",line="5"@} +(@value{GDBP}) +-break-after 1 3 +~ +^done +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="1",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", +addr="0x000100d0",func="main",file="hello.c",line="5",times="0", +ignore="3"@}]@} +(@value{GDBP}) @end smallexample -Takes an optional parameter that is used as the text of the error or -warning message. +@ignore +@subheading The @code{-break-catch} Command +@findex -break-catch -@kindex maint print registers -@kindex maint print raw-registers -@kindex maint print cooked-registers -@item maint print registers -@itemx maint print raw-registers -@itemx maint print cooked-registers -Print @value{GDBN}'s internal register data structures. +@subheading The @code{-break-commands} Command +@findex -break-commands +@end ignore -The command @samp{maint print raw-registers} includes the contents of -the raw register cache; and the command @samp{maint print -cooked-registers} includes the (cooked) value of all registers. -@xref{Registers,, Registers, gdbint, @value{GDBN} Internals}. -Takes an optional file parameter. +@subheading The @code{-break-condition} Command +@findex -break-condition -@end table +@subsubheading Synopsis + +@smallexample + -break-condition @var{number} @var{expr} +@end smallexample +Breakpoint @var{number} will stop the program only if the condition in +@var{expr} is true. The condition becomes part of the +@samp{-break-list} output (see the description of the @samp{-break-list} +command below). -@node Remote Protocol -@appendix @value{GDBN} Remote Serial Protocol +@subsubheading @value{GDBN} Command -@menu -* Overview:: -* Packets:: -* Stop Reply Packets:: -* General Query Packets:: -* Register Packet Format:: -* Examples:: -@end menu +The corresponding @value{GDBN} command is @samp{condition}. -@node Overview -@section Overview +@subsubheading Example -There may be occasions when you need to know something about the -protocol---for example, if there is only one serial port to your target -machine, you might want your program to do something special if it -recognizes a packet meant for @value{GDBN}. +@smallexample +(@value{GDBP}) +-break-condition 1 1 +^done +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="1",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", +addr="0x000100d0",func="main",file="hello.c",line="5",cond="1", +times="0",ignore="3"@}]@} +(@value{GDBP}) +@end smallexample -In the examples below, @samp{->} and @samp{<-} are used to indicate -transmitted and received data respectfully. +@subheading The @code{-break-delete} Command +@findex -break-delete -@cindex protocol, @value{GDBN} remote serial -@cindex serial protocol, @value{GDBN} remote -@cindex remote serial protocol -All @value{GDBN} commands and responses (other than acknowledgments) are -sent as a @var{packet}. A @var{packet} is introduced with the character -@samp{$}, the actual @var{packet-data}, and the terminating character -@samp{#} followed by a two-digit @var{checksum}: +@subsubheading Synopsis @smallexample -@code{$}@var{packet-data}@code{#}@var{checksum} + -break-delete ( @var{breakpoint} )+ +@end smallexample + +Delete the breakpoint(s) whose number(s) are specified in the argument +list. This is obviously reflected in the breakpoint list. + +@subsubheading @value{GDBN} command + +The corresponding @value{GDBN} command is @samp{delete}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-break-delete 1 +^done +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="0",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[]@} +(@value{GDBP}) +@end smallexample + +@subheading The @code{-break-disable} Command +@findex -break-disable + +@subsubheading Synopsis + +@smallexample + -break-disable ( @var{breakpoint} )+ +@end smallexample + +Disable the named @var{breakpoint}(s). The field @samp{enabled} in the +break list is now set to @samp{n} for the named @var{breakpoint}(s). + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{disable}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-break-disable 2 +^done +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="1",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="n", +addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@}]@} +(@value{GDBP}) +@end smallexample + +@subheading The @code{-break-enable} Command +@findex -break-enable + +@subsubheading Synopsis + +@smallexample + -break-enable ( @var{breakpoint} )+ +@end smallexample + +Enable (previously disabled) @var{breakpoint}(s). + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{enable}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-break-enable 2 +^done +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="1",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y", +addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@}]@} +(@value{GDBP}) +@end smallexample + +@subheading The @code{-break-info} Command +@findex -break-info + +@subsubheading Synopsis + +@smallexample + -break-info @var{breakpoint} +@end smallexample + +@c REDUNDANT??? +Get information about a single breakpoint. + +@subsubheading @value{GDBN} command + +The corresponding @value{GDBN} command is @samp{info break @var{breakpoint}}. + +@subsubheading Example +N.A. + +@subheading The @code{-break-insert} Command +@findex -break-insert + +@subsubheading Synopsis + +@smallexample + -break-insert [ -t ] [ -h ] [ -r ] + [ -c @var{condition} ] [ -i @var{ignore-count} ] + [ -p @var{thread} ] [ @var{line} | @var{addr} ] @end smallexample -@noindent -@cindex checksum, for @value{GDBN} remote @noindent -The two-digit @var{checksum} is computed as the modulo 256 sum of all -characters between the leading @samp{$} and the trailing @samp{#} (an -eight bit unsigned checksum). +If specified, @var{line}, can be one of: -Implementors should note that prior to @value{GDBN} 5.0 the protocol -specification also included an optional two-digit @var{sequence-id}: +@itemize @bullet +@item function +@c @item +offset +@c @item -offset +@c @item linenum +@item filename:linenum +@item filename:function +@item *address +@end itemize + +The possible optional parameters of this command are: + +@table @samp +@item -t +Insert a tempoary breakpoint. +@item -h +Insert a hardware breakpoint. +@item -c @var{condition} +Make the breakpoint conditional on @var{condition}. +@item -i @var{ignore-count} +Initialize the @var{ignore-count}. +@item -r +Insert a regular breakpoint in all the functions whose names match the +given regular expression. Other flags are not applicable to regular +expresson. +@end table + +@subsubheading Result + +The result is in the form: @smallexample -@code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum} + ^done,bkptno="@var{number}",func="@var{funcname}", + file="@var{filename}",line="@var{lineno}" @end smallexample -@cindex sequence-id, for @value{GDBN} remote @noindent -That @var{sequence-id} was appended to the acknowledgment. @value{GDBN} -has never output @var{sequence-id}s. Stubs that handle packets added -since @value{GDBN} 5.0 must not accept @var{sequence-id}. +where @var{number} is the @value{GDBN} number for this breakpoint, @var{funcname} +is the name of the function where the breakpoint was inserted, +@var{filename} is the name of the source file which contains this +function, and @var{lineno} is the source line number within that file. -@cindex acknowledgment, for @value{GDBN} remote -When either the host or the target machine receives a packet, the first -response expected is an acknowledgment: either @samp{+} (to indicate -the package was received correctly) or @samp{-} (to request -retransmission): +Note: this format is open to change. +@c An out-of-band breakpoint instead of part of the result? + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{break}, @samp{tbreak}, +@samp{hbreak}, @samp{thbreak}, and @samp{rbreak}. + +@subsubheading Example @smallexample --> @code{$}@var{packet-data}@code{#}@var{checksum} -<- @code{+} +(@value{GDBP}) +-break-insert main +^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@} +(@value{GDBP}) +-break-insert -t foo +^done,bkpt=@{number="2",addr="0x00010774",file="recursive2.c",line="11"@} +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="2",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", +addr="0x0001072c", func="main",file="recursive2.c",line="4",times="0"@}, +bkpt=@{number="2",type="breakpoint",disp="del",enabled="y", +addr="0x00010774",func="foo",file="recursive2.c",line="11",times="0"@}]@} +(@value{GDBP}) +-break-insert -r foo.* +~int foo(int, int); +^done,bkpt=@{number="3",addr="0x00010774",file="recursive2.c",line="11"@} +(@value{GDBP}) +@end smallexample + +@subheading The @code{-break-list} Command +@findex -break-list + +@subsubheading Synopsis + +@smallexample + -break-list +@end smallexample + +Displays the list of inserted breakpoints, showing the following fields: + +@table @samp +@item Number +number of the breakpoint +@item Type +type of the breakpoint: @samp{breakpoint} or @samp{watchpoint} +@item Disposition +should the breakpoint be deleted or disabled when it is hit: @samp{keep} +or @samp{nokeep} +@item Enabled +is the breakpoint enabled or no: @samp{y} or @samp{n} +@item Address +memory location at which the breakpoint is set +@item What +logical location of the breakpoint, expressed by function name, file +name, line number +@item Times +number of times the breakpoint has been hit +@end table + +If there are no breakpoints or watchpoints, the @code{BreakpointTable} +@code{body} field is an empty list. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info break}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="2",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", +addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@}, +bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y", +addr="0x00010114",func="foo",file="hello.c",line="13",times="0"@}]@} +(@value{GDBP}) +@end smallexample + +Here's an example of the result when there are no breakpoints: + +@smallexample +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="0",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[]@} +(@value{GDBP}) +@end smallexample + +@subheading The @code{-break-watch} Command +@findex -break-watch + +@subsubheading Synopsis + +@smallexample + -break-watch [ -a | -r ] +@end smallexample + +Create a watchpoint. With the @samp{-a} option it will create an +@dfn{access} watchpoint, i.e. a watchpoint that triggers either on a +read from or on a write to the memory location. With the @samp{-r} +option, the watchpoint created is a @dfn{read} watchpoint, i.e. it will +trigger only when the memory location is accessed for reading. Without +either of the options, the watchpoint created is a regular watchpoint, +i.e. it will trigger when the memory location is accessed for writing. +@xref{Set Watchpoints, , Setting watchpoints}. + +Note that @samp{-break-list} will report a single list of watchpoints and +breakpoints inserted. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{watch}, @samp{awatch}, and +@samp{rwatch}. + +@subsubheading Example + +Setting a watchpoint on a variable in the @code{main} function: + +@smallexample +(@value{GDBP}) +-break-watch x +^done,wpt=@{number="2",exp="x"@} +(@value{GDBP}) +-exec-continue +^running +^done,reason="watchpoint-trigger",wpt=@{number="2",exp="x"@}, +value=@{old="-268439212",new="55"@}, +frame=@{func="main",args=[],file="recursive2.c",line="5"@} +(@value{GDBP}) +@end smallexample + +Setting a watchpoint on a variable local to a function. @value{GDBN} will stop +the program execution twice: first for the variable changing value, then +for the watchpoint going out of scope. + +@smallexample +(@value{GDBP}) +-break-watch C +^done,wpt=@{number="5",exp="C"@} +(@value{GDBP}) +-exec-continue +^running +^done,reason="watchpoint-trigger", +wpt=@{number="5",exp="C"@},value=@{old="-276895068",new="3"@}, +frame=@{func="callee4",args=[], +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="13"@} +(@value{GDBP}) +-exec-continue +^running +^done,reason="watchpoint-scope",wpnum="5", +frame=@{func="callee3",args=[@{name="strarg", +value="0x11940 \"A string argument.\""@}], +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="18"@} +(@value{GDBP}) +@end smallexample + +Listing breakpoints and watchpoints, at different points in the program +execution. Note that once the watchpoint goes out of scope, it is +deleted. + +@smallexample +(@value{GDBP}) +-break-watch C +^done,wpt=@{number="2",exp="C"@} +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="2",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", +addr="0x00010734",func="callee4", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@}, +bkpt=@{number="2",type="watchpoint",disp="keep", +enabled="y",addr="",what="C",times="0"@}]@} +(@value{GDBP}) +-exec-continue +^running +^done,reason="watchpoint-trigger",wpt=@{number="2",exp="C"@}, +value=@{old="-276895068",new="3"@}, +frame=@{func="callee4",args=[], +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="13"@} +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="2",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", +addr="0x00010734",func="callee4", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@}, +bkpt=@{number="2",type="watchpoint",disp="keep", +enabled="y",addr="",what="C",times="-5"@}]@} +(@value{GDBP}) +-exec-continue +^running +^done,reason="watchpoint-scope",wpnum="2", +frame=@{func="callee3",args=[@{name="strarg", +value="0x11940 \"A string argument.\""@}], +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="18"@} +(@value{GDBP}) +-break-list +^done,BreakpointTable=@{nr_rows="1",nr_cols="6", +hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@}, +@{width="14",alignment="-1",col_name="type",colhdr="Type"@}, +@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@}, +@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@}, +@{width="10",alignment="-1",col_name="addr",colhdr="Address"@}, +@{width="40",alignment="2",col_name="what",colhdr="What"@}], +body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", +addr="0x00010734",func="callee4", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@}]@} +(@value{GDBP}) +@end smallexample + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Data Manipulation +@section @sc{gdb/mi} Data Manipulation + +@cindex data manipulation, in @sc{gdb/mi} +@cindex @sc{gdb/mi}, data manipulation +This section describes the @sc{gdb/mi} commands that manipulate data: +examine memory and registers, evaluate expressions, etc. + +@c REMOVED FROM THE INTERFACE. +@c @subheading -data-assign +@c Change the value of a program variable. Plenty of side effects. +@c @subsubheading GDB command +@c set variable +@c @subsubheading Example +@c N.A. + +@subheading The @code{-data-disassemble} Command +@findex -data-disassemble + +@subsubheading Synopsis + +@smallexample + -data-disassemble + [ -s @var{start-addr} -e @var{end-addr} ] + | [ -f @var{filename} -l @var{linenum} [ -n @var{lines} ] ] + -- @var{mode} @end smallexample + @noindent +Where: -The host (@value{GDBN}) sends @var{command}s, and the target (the -debugging stub incorporated in your program) sends a @var{response}. In -the case of step and continue @var{command}s, the response is only sent -when the operation has completed (the target has again stopped). +@table @samp +@item @var{start-addr} +is the beginning address (or @code{$pc}) +@item @var{end-addr} +is the end address +@item @var{filename} +is the name of the file to disassemble +@item @var{linenum} +is the line number to disassemble around +@item @var{lines} +is the the number of disassembly lines to be produced. If it is -1, +the whole function will be disassembled, in case no @var{end-addr} is +specified. If @var{end-addr} is specified as a non-zero value, and +@var{lines} is lower than the number of disassembly lines between +@var{start-addr} and @var{end-addr}, only @var{lines} lines are +displayed; if @var{lines} is higher than the number of lines between +@var{start-addr} and @var{end-addr}, only the lines up to @var{end-addr} +are displayed. +@item @var{mode} +is either 0 (meaning only disassembly) or 1 (meaning mixed source and +disassembly). +@end table -@var{packet-data} consists of a sequence of characters with the -exception of @samp{#} and @samp{$} (see @samp{X} packet for additional -exceptions). +@subsubheading Result -Fields within the packet should be separated using @samp{,} @samp{;} or -@cindex remote protocol, field separator -@samp{:}. Except where otherwise noted all numbers are represented in -@sc{hex} with leading zeros suppressed. +The output for each instruction is composed of four fields: -Implementors should note that prior to @value{GDBN} 5.0, the character -@samp{:} could not appear as the third character in a packet (as it -would potentially conflict with the @var{sequence-id}). +@itemize @bullet +@item Address +@item Func-name +@item Offset +@item Instruction +@end itemize -Response @var{data} can be run-length encoded to save space. A @samp{*} -means that the next character is an @sc{ascii} encoding giving a repeat count -which stands for that many repetitions of the character preceding the -@samp{*}. The encoding is @code{n+29}, yielding a printable character -where @code{n >=3} (which is where rle starts to win). The printable -characters @samp{$}, @samp{#}, @samp{+} and @samp{-} or with a numeric -value greater than 126 should not be used. +Note that whatever included in the instruction field, is not manipulated +directely by @sc{gdb/mi}, i.e. it is not possible to adjust its format. -Some remote systems have used a different run-length encoding mechanism -loosely refered to as the cisco encoding. Following the @samp{*} -character are two hex digits that indicate the size of the packet. +@subsubheading @value{GDBN} Command + +There's no direct mapping from this command to the CLI. + +@subsubheading Example + +Disassemble from the current value of @code{$pc} to @code{$pc + 20}: + +@smallexample +(@value{GDBP}) +-data-disassemble -s $pc -e "$pc + 20" -- 0 +^done, +asm_insns=[ +@{address="0x000107c0",func-name="main",offset="4", +inst="mov 2, %o0"@}, +@{address="0x000107c4",func-name="main",offset="8", +inst="sethi %hi(0x11800), %o2"@}, +@{address="0x000107c8",func-name="main",offset="12", +inst="or %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"@}, +@{address="0x000107cc",func-name="main",offset="16", +inst="sethi %hi(0x11800), %o2"@}, +@{address="0x000107d0",func-name="main",offset="20", +inst="or %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"@}] +(@value{GDBP}) +@end smallexample + +Disassemble the whole @code{main} function. Line 32 is part of +@code{main}. + +@smallexample +-data-disassemble -f basics.c -l 32 -- 0 +^done,asm_insns=[ +@{address="0x000107bc",func-name="main",offset="0", +inst="save %sp, -112, %sp"@}, +@{address="0x000107c0",func-name="main",offset="4", +inst="mov 2, %o0"@}, +@{address="0x000107c4",func-name="main",offset="8", +inst="sethi %hi(0x11800), %o2"@}, +[@dots{}] +@{address="0x0001081c",func-name="main",offset="96",inst="ret "@}, +@{address="0x00010820",func-name="main",offset="100",inst="restore "@}] +(@value{GDBP}) +@end smallexample + +Disassemble 3 instructions from the start of @code{main}: + +@smallexample +(@value{GDBP}) +-data-disassemble -f basics.c -l 32 -n 3 -- 0 +^done,asm_insns=[ +@{address="0x000107bc",func-name="main",offset="0", +inst="save %sp, -112, %sp"@}, +@{address="0x000107c0",func-name="main",offset="4", +inst="mov 2, %o0"@}, +@{address="0x000107c4",func-name="main",offset="8", +inst="sethi %hi(0x11800), %o2"@}] +(@value{GDBP}) +@end smallexample + +Disassemble 3 instructions from the start of @code{main} in mixed mode: + +@smallexample +(@value{GDBP}) +-data-disassemble -f basics.c -l 32 -n 3 -- 1 +^done,asm_insns=[ +src_and_asm_line=@{line="31", +file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \ + testsuite/gdb.mi/basics.c",line_asm_insn=[ +@{address="0x000107bc",func-name="main",offset="0", +inst="save %sp, -112, %sp"@}]@}, +src_and_asm_line=@{line="32", +file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \ + testsuite/gdb.mi/basics.c",line_asm_insn=[ +@{address="0x000107c0",func-name="main",offset="4", +inst="mov 2, %o0"@}, +@{address="0x000107c4",func-name="main",offset="8", +inst="sethi %hi(0x11800), %o2"@}]@}] +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-data-evaluate-expression} Command +@findex -data-evaluate-expression + +@subsubheading Synopsis + +@smallexample + -data-evaluate-expression @var{expr} +@end smallexample + +Evaluate @var{expr} as an expression. The expression could contain an +inferior function call. The function call will execute synchronously. +If the expression contains spaces, it must be enclosed in double quotes. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{print}, @samp{output}, and +@samp{call}. In @code{gdbtk} only, there's a corresponding +@samp{gdb_eval} command. + +@subsubheading Example + +In the following example, the numbers that precede the commands are the +@dfn{tokens} described in @ref{GDB/MI Command Syntax, ,@sc{gdb/mi} +Command Syntax}. Notice how @sc{gdb/mi} returns the same tokens in its +output. + +@smallexample +211-data-evaluate-expression A +211^done,value="1" +(@value{GDBP}) +311-data-evaluate-expression &A +311^done,value="0xefffeb7c" +(@value{GDBP}) +411-data-evaluate-expression A+3 +411^done,value="4" +(@value{GDBP}) +511-data-evaluate-expression "A + 3" +511^done,value="4" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-data-list-changed-registers} Command +@findex -data-list-changed-registers + +@subsubheading Synopsis + +@smallexample + -data-list-changed-registers +@end smallexample + +Display a list of the registers that have changed. + +@subsubheading @value{GDBN} Command + +@value{GDBN} doesn't have a direct analog for this command; @code{gdbtk} +has the corresponding command @samp{gdb_changed_register_list}. + +@subsubheading Example + +On a PPC MBX board: + +@smallexample +(@value{GDBP}) +-exec-continue +^running + +(@value{GDBP}) +*stopped,reason="breakpoint-hit",bkptno="1",frame=@{func="main", +args=[],file="try.c",line="5"@} +(@value{GDBP}) +-data-list-changed-registers +^done,changed-registers=["0","1","2","4","5","6","7","8","9", +"10","11","13","14","15","16","17","18","19","20","21","22","23", +"24","25","26","27","28","30","31","64","65","66","67","69"] +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-data-list-register-names} Command +@findex -data-list-register-names + +@subsubheading Synopsis + +@smallexample + -data-list-register-names [ ( @var{regno} )+ ] +@end smallexample + +Show a list of register names for the current target. If no arguments +are given, it shows a list of the names of all the registers. If +integer numbers are given as arguments, it will print a list of the +names of the registers corresponding to the arguments. To ensure +consistency between a register name and its number, the output list may +include empty register names. + +@subsubheading @value{GDBN} Command + +@value{GDBN} does not have a command which corresponds to +@samp{-data-list-register-names}. In @code{gdbtk} there is a +corresponding command @samp{gdb_regnames}. + +@subsubheading Example + +For the PPC MBX board: +@smallexample +(@value{GDBP}) +-data-list-register-names +^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7", +"r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18", +"r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29", +"r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9", +"f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20", +"f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31", +"", "pc","ps","cr","lr","ctr","xer"] +(@value{GDBP}) +-data-list-register-names 1 2 3 +^done,register-names=["r1","r2","r3"] +(@value{GDBP}) +@end smallexample + +@subheading The @code{-data-list-register-values} Command +@findex -data-list-register-values + +@subsubheading Synopsis + +@smallexample + -data-list-register-values @var{fmt} [ ( @var{regno} )*] +@end smallexample + +Display the registers' contents. @var{fmt} is the format according to +which the registers' contents are to be returned, followed by an optional +list of numbers specifying the registers to display. A missing list of +numbers indicates that the contents of all the registers must be returned. + +Allowed formats for @var{fmt} are: + +@table @code +@item x +Hexadecimal +@item o +Octal +@item t +Binary +@item d +Decimal +@item r +Raw +@item N +Natural +@end table + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{info reg}, @samp{info +all-reg}, and (in @code{gdbtk}) @samp{gdb_fetch_registers}. + +@subsubheading Example + +For a PPC MBX board (note: line breaks are for readability only, they +don't appear in the actual output): + +@smallexample +(@value{GDBP}) +-data-list-register-values r 64 65 +^done,register-values=[@{number="64",value="0xfe00a300"@}, +@{number="65",value="0x00029002"@}] +(@value{GDBP}) +-data-list-register-values x +^done,register-values=[@{number="0",value="0xfe0043c8"@}, +@{number="1",value="0x3fff88"@},@{number="2",value="0xfffffffe"@}, +@{number="3",value="0x0"@},@{number="4",value="0xa"@}, +@{number="5",value="0x3fff68"@},@{number="6",value="0x3fff58"@}, +@{number="7",value="0xfe011e98"@},@{number="8",value="0x2"@}, +@{number="9",value="0xfa202820"@},@{number="10",value="0xfa202808"@}, +@{number="11",value="0x1"@},@{number="12",value="0x0"@}, +@{number="13",value="0x4544"@},@{number="14",value="0xffdfffff"@}, +@{number="15",value="0xffffffff"@},@{number="16",value="0xfffffeff"@}, +@{number="17",value="0xefffffed"@},@{number="18",value="0xfffffffe"@}, +@{number="19",value="0xffffffff"@},@{number="20",value="0xffffffff"@}, +@{number="21",value="0xffffffff"@},@{number="22",value="0xfffffff7"@}, +@{number="23",value="0xffffffff"@},@{number="24",value="0xffffffff"@}, +@{number="25",value="0xffffffff"@},@{number="26",value="0xfffffffb"@}, +@{number="27",value="0xffffffff"@},@{number="28",value="0xf7bfffff"@}, +@{number="29",value="0x0"@},@{number="30",value="0xfe010000"@}, +@{number="31",value="0x0"@},@{number="32",value="0x0"@}, +@{number="33",value="0x0"@},@{number="34",value="0x0"@}, +@{number="35",value="0x0"@},@{number="36",value="0x0"@}, +@{number="37",value="0x0"@},@{number="38",value="0x0"@}, +@{number="39",value="0x0"@},@{number="40",value="0x0"@}, +@{number="41",value="0x0"@},@{number="42",value="0x0"@}, +@{number="43",value="0x0"@},@{number="44",value="0x0"@}, +@{number="45",value="0x0"@},@{number="46",value="0x0"@}, +@{number="47",value="0x0"@},@{number="48",value="0x0"@}, +@{number="49",value="0x0"@},@{number="50",value="0x0"@}, +@{number="51",value="0x0"@},@{number="52",value="0x0"@}, +@{number="53",value="0x0"@},@{number="54",value="0x0"@}, +@{number="55",value="0x0"@},@{number="56",value="0x0"@}, +@{number="57",value="0x0"@},@{number="58",value="0x0"@}, +@{number="59",value="0x0"@},@{number="60",value="0x0"@}, +@{number="61",value="0x0"@},@{number="62",value="0x0"@}, +@{number="63",value="0x0"@},@{number="64",value="0xfe00a300"@}, +@{number="65",value="0x29002"@},@{number="66",value="0x202f04b5"@}, +@{number="67",value="0xfe0043b0"@},@{number="68",value="0xfe00b3e4"@}, +@{number="69",value="0x20002b03"@}] +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-data-read-memory} Command +@findex -data-read-memory + +@subsubheading Synopsis + +@smallexample + -data-read-memory [ -o @var{byte-offset} ] + @var{address} @var{word-format} @var{word-size} + @var{nr-rows} @var{nr-cols} [ @var{aschar} ] +@end smallexample + +@noindent +where: + +@table @samp +@item @var{address} +An expression specifying the address of the first memory word to be +read. Complex expressions containing embedded white space should be +quoted using the C convention. + +@item @var{word-format} +The format to be used to print the memory words. The notation is the +same as for @value{GDBN}'s @code{print} command (@pxref{Output Formats, +,Output formats}). + +@item @var{word-size} +The size of each memory word in bytes. + +@item @var{nr-rows} +The number of rows in the output table. + +@item @var{nr-cols} +The number of columns in the output table. + +@item @var{aschar} +If present, indicates that each row should include an @sc{ascii} dump. The +value of @var{aschar} is used as a padding character when a byte is not a +member of the printable @sc{ascii} character set (printable @sc{ascii} +characters are those whose code is between 32 and 126, inclusively). + +@item @var{byte-offset} +An offset to add to the @var{address} before fetching memory. +@end table + +This command displays memory contents as a table of @var{nr-rows} by +@var{nr-cols} words, each word being @var{word-size} bytes. In total, +@code{@var{nr-rows} * @var{nr-cols} * @var{word-size}} bytes are read +(returned as @samp{total-bytes}). Should less than the requested number +of bytes be returned by the target, the missing words are identified +using @samp{N/A}. The number of bytes read from the target is returned +in @samp{nr-bytes} and the starting address used to read memory in +@samp{addr}. + +The address of the next/previous row or page is available in +@samp{next-row} and @samp{prev-row}, @samp{next-page} and +@samp{prev-page}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{x}. @code{gdbtk} has +@samp{gdb_get_mem} memory read command. + +@subsubheading Example + +Read six bytes of memory starting at @code{bytes+6} but then offset by +@code{-6} bytes. Format as three rows of two columns. One byte per +word. Display each word in hex. + +@smallexample +(@value{GDBP}) +9-data-read-memory -o -6 -- bytes+6 x 1 3 2 +9^done,addr="0x00001390",nr-bytes="6",total-bytes="6", +next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396", +prev-page="0x0000138a",memory=[ +@{addr="0x00001390",data=["0x00","0x01"]@}, +@{addr="0x00001392",data=["0x02","0x03"]@}, +@{addr="0x00001394",data=["0x04","0x05"]@}] +(@value{GDBP}) +@end smallexample + +Read two bytes of memory starting at address @code{shorts + 64} and +display as a single word formatted in decimal. + +@smallexample +(@value{GDBP}) +5-data-read-memory shorts+64 d 2 1 1 +5^done,addr="0x00001510",nr-bytes="2",total-bytes="2", +next-row="0x00001512",prev-row="0x0000150e", +next-page="0x00001512",prev-page="0x0000150e",memory=[ +@{addr="0x00001510",data=["128"]@}] +(@value{GDBP}) +@end smallexample + +Read thirty two bytes of memory starting at @code{bytes+16} and format +as eight rows of four columns. Include a string encoding with @samp{x} +used as the non-printable character. + +@smallexample +(@value{GDBP}) +4-data-read-memory bytes+16 x 1 8 4 x +4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32", +next-row="0x000013c0",prev-row="0x0000139c", +next-page="0x000013c0",prev-page="0x00001380",memory=[ +@{addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"@}, +@{addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"@}, +@{addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"@}, +@{addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"@}, +@{addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"@}, +@{addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"@}, +@{addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"@}, +@{addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"@}] +(@value{GDBP}) +@end smallexample + +@subheading The @code{-display-delete} Command +@findex -display-delete + +@subsubheading Synopsis + +@smallexample + -display-delete @var{number} +@end smallexample + +Delete the display @var{number}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{delete display}. + +@subsubheading Example +N.A. + + +@subheading The @code{-display-disable} Command +@findex -display-disable + +@subsubheading Synopsis + +@smallexample + -display-disable @var{number} +@end smallexample + +Disable display @var{number}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{disable display}. + +@subsubheading Example +N.A. + + +@subheading The @code{-display-enable} Command +@findex -display-enable + +@subsubheading Synopsis + +@smallexample + -display-enable @var{number} +@end smallexample + +Enable display @var{number}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{enable display}. + +@subsubheading Example +N.A. + + +@subheading The @code{-display-insert} Command +@findex -display-insert + +@subsubheading Synopsis + +@smallexample + -display-insert @var{expression} +@end smallexample + +Display @var{expression} every time the program stops. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{display}. + +@subsubheading Example +N.A. + + +@subheading The @code{-display-list} Command +@findex -display-list + +@subsubheading Synopsis + +@smallexample + -display-list +@end smallexample + +List the displays. Do not show the current values. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info display}. + +@subsubheading Example +N.A. + + +@subheading The @code{-environment-cd} Command +@findex -environment-cd + +@subsubheading Synopsis + +@smallexample + -environment-cd @var{pathdir} +@end smallexample + +Set @value{GDBN}'s working directory. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{cd}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb +^done +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-environment-directory} Command +@findex -environment-directory + +@subsubheading Synopsis + +@smallexample + -environment-directory [ -r ] [ @var{pathdir} ]+ +@end smallexample + +Add directories @var{pathdir} to beginning of search path for source files. +If the @samp{-r} option is used, the search path is reset to the default +search path. If directories @var{pathdir} are supplied in addition to the +@samp{-r} option, the search path is first reset and then addition +occurs as normal. +Multiple directories may be specified, separated by blanks. Specifying +multiple directories in a single command +results in the directories added to the beginning of the +search path in the same order they were presented in the command. +If blanks are needed as +part of a directory name, double-quotes should be used around +the name. In the command output, the path will show up separated +by the system directory-separator character. The directory-seperator +character must not be used +in any directory name. +If no directories are specified, the current search path is displayed. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{dir}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" +(@value{GDBP}) +-environment-directory "" +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" +(@value{GDBP}) +-environment-directory -r /home/jjohnstn/src/gdb /usr/src +^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd" +(@value{GDBP}) +-environment-directory -r +^done,source-path="$cdir:$cwd" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-environment-path} Command +@findex -environment-path + +@subsubheading Synopsis + +@smallexample + -environment-path [ -r ] [ @var{pathdir} ]+ +@end smallexample + +Add directories @var{pathdir} to beginning of search path for object files. +If the @samp{-r} option is used, the search path is reset to the original +search path that existed at gdb start-up. If directories @var{pathdir} are +supplied in addition to the +@samp{-r} option, the search path is first reset and then addition +occurs as normal. +Multiple directories may be specified, separated by blanks. Specifying +multiple directories in a single command +results in the directories added to the beginning of the +search path in the same order they were presented in the command. +If blanks are needed as +part of a directory name, double-quotes should be used around +the name. In the command output, the path will show up separated +by the system directory-separator character. The directory-seperator +character must not be used +in any directory name. +If no directories are specified, the current path is displayed. + + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{path}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-environment-path +^done,path="/usr/bin" +(@value{GDBP}) +-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin" +(@value{GDBP}) +-environment-path -r /usr/local/bin +^done,path="/usr/local/bin:/usr/bin" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-environment-pwd} Command +@findex -environment-pwd + +@subsubheading Synopsis + +@smallexample + -environment-pwd +@end smallexample + +Show the current working directory. + +@subsubheading @value{GDBN} command + +The corresponding @value{GDBN} command is @samp{pwd}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-environment-pwd +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb" +(@value{GDBP}) +@end smallexample + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Program Control +@section @sc{gdb/mi} Program control + +@subsubheading Program termination + +As a result of execution, the inferior program can run to completion, if +it doesn't encounter any breakpoints. In this case the output will +include an exit code, if the program has exited exceptionally. + +@subsubheading Examples + +@noindent +Program exited normally: + +@smallexample +(@value{GDBP}) +-exec-run +^running +(@value{GDBP}) +x = 55 +*stopped,reason="exited-normally" +(@value{GDBP}) +@end smallexample + +@noindent +Program exited exceptionally: + +@smallexample +(@value{GDBP}) +-exec-run +^running +(@value{GDBP}) +x = 55 +*stopped,reason="exited",exit-code="01" +(@value{GDBP}) +@end smallexample + +Another way the program can terminate is if it receives a signal such as +@code{SIGINT}. In this case, @sc{gdb/mi} displays this: + +@smallexample +(@value{GDBP}) +*stopped,reason="exited-signalled",signal-name="SIGINT", +signal-meaning="Interrupt" +@end smallexample + + +@subheading The @code{-exec-abort} Command +@findex -exec-abort + +@subsubheading Synopsis + +@smallexample + -exec-abort +@end smallexample + +Kill the inferior running program. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{kill}. + +@subsubheading Example +N.A. + + +@subheading The @code{-exec-arguments} Command +@findex -exec-arguments + +@subsubheading Synopsis + +@smallexample + -exec-arguments @var{args} +@end smallexample + +Set the inferior program arguments, to be used in the next +@samp{-exec-run}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{set args}. + +@subsubheading Example + +@c FIXME! +Don't have one around. + + +@subheading The @code{-exec-continue} Command +@findex -exec-continue + +@subsubheading Synopsis + +@smallexample + -exec-continue +@end smallexample + +Asynchronous command. Resumes the execution of the inferior program +until a breakpoint is encountered, or until the inferior exits. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} corresponding is @samp{continue}. + +@subsubheading Example + +@smallexample +-exec-continue +^running +(@value{GDBP}) +@@Hello world +*stopped,reason="breakpoint-hit",bkptno="2",frame=@{func="foo",args=[], +file="hello.c",line="13"@} +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-finish} Command +@findex -exec-finish + +@subsubheading Synopsis + +@smallexample + -exec-finish +@end smallexample + +Asynchronous command. Resumes the execution of the inferior program +until the current function is exited. Displays the results returned by +the function. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{finish}. + +@subsubheading Example + +Function returning @code{void}. + +@smallexample +-exec-finish +^running +(@value{GDBP}) +@@hello from foo +*stopped,reason="function-finished",frame=@{func="main",args=[], +file="hello.c",line="7"@} +(@value{GDBP}) +@end smallexample + +Function returning other than @code{void}. The name of the internal +@value{GDBN} variable storing the result is printed, together with the +value itself. + +@smallexample +-exec-finish +^running +(@value{GDBP}) +*stopped,reason="function-finished",frame=@{addr="0x000107b0",func="foo", +args=[@{name="a",value="1"],@{name="b",value="9"@}@}, +file="recursive2.c",line="14"@}, +gdb-result-var="$1",return-value="0" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-interrupt} Command +@findex -exec-interrupt + +@subsubheading Synopsis + +@smallexample + -exec-interrupt +@end smallexample + +Asynchronous command. Interrupts the background execution of the target. +Note how the token associated with the stop message is the one for the +execution command that has been interrupted. The token for the interrupt +itself only appears in the @samp{^done} output. If the user is trying to +interrupt a non-running program, an error message will be printed. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{interrupt}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +111-exec-continue +111^running + +(@value{GDBP}) +222-exec-interrupt +222^done +(@value{GDBP}) +111*stopped,signal-name="SIGINT",signal-meaning="Interrupt", +frame=@{addr="0x00010140",func="foo",args=[],file="try.c",line="13"@} +(@value{GDBP}) + +(@value{GDBP}) +-exec-interrupt +^error,msg="mi_cmd_exec_interrupt: Inferior not executing." +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-next} Command +@findex -exec-next + +@subsubheading Synopsis + +@smallexample + -exec-next +@end smallexample + +Asynchronous command. Resumes execution of the inferior program, stopping +when the beginning of the next source line is reached. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{next}. + +@subsubheading Example + +@smallexample +-exec-next +^running +(@value{GDBP}) +*stopped,reason="end-stepping-range",line="8",file="hello.c" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-next-instruction} Command +@findex -exec-next-instruction + +@subsubheading Synopsis + +@smallexample + -exec-next-instruction +@end smallexample + +Asynchronous command. Executes one machine instruction. If the +instruction is a function call continues until the function returns. If +the program stops at an instruction in the middle of a source line, the +address will be printed as well. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{nexti}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-exec-next-instruction +^running + +(@value{GDBP}) +*stopped,reason="end-stepping-range", +addr="0x000100d4",line="5",file="hello.c" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-return} Command +@findex -exec-return + +@subsubheading Synopsis + +@smallexample + -exec-return +@end smallexample + +Makes current function return immediately. Doesn't execute the inferior. +Displays the new current frame. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{return}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +200-break-insert callee4 +200^done,bkpt=@{number="1",addr="0x00010734", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@} +(@value{GDBP}) +000-exec-run +000^running +(@value{GDBP}) +000*stopped,reason="breakpoint-hit",bkptno="1", +frame=@{func="callee4",args=[], +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@} +(@value{GDBP}) +205-break-delete +205^done +(@value{GDBP}) +111-exec-return +111^done,frame=@{level="0",func="callee3", +args=[@{name="strarg", +value="0x11940 \"A string argument.\""@}], +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="18"@} +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-run} Command +@findex -exec-run + +@subsubheading Synopsis + +@smallexample + -exec-run +@end smallexample + +Asynchronous command. Starts execution of the inferior from the +beginning. The inferior executes until either a breakpoint is +encountered or the program exits. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{run}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-break-insert main +^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@} +(@value{GDBP}) +-exec-run +^running +(@value{GDBP}) +*stopped,reason="breakpoint-hit",bkptno="1", +frame=@{func="main",args=[],file="recursive2.c",line="4"@} +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-show-arguments} Command +@findex -exec-show-arguments + +@subsubheading Synopsis + +@smallexample + -exec-show-arguments +@end smallexample + +Print the arguments of the program. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{show args}. + +@subsubheading Example +N.A. + +@c @subheading -exec-signal + +@subheading The @code{-exec-step} Command +@findex -exec-step + +@subsubheading Synopsis + +@smallexample + -exec-step +@end smallexample + +Asynchronous command. Resumes execution of the inferior program, stopping +when the beginning of the next source line is reached, if the next +source line is not a function call. If it is, stop at the first +instruction of the called function. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{step}. + +@subsubheading Example + +Stepping into a function: + +@smallexample +-exec-step +^running +(@value{GDBP}) +*stopped,reason="end-stepping-range", +frame=@{func="foo",args=[@{name="a",value="10"@}, +@{name="b",value="0"@}],file="recursive2.c",line="11"@} +(@value{GDBP}) +@end smallexample + +Regular stepping: + +@smallexample +-exec-step +^running +(@value{GDBP}) +*stopped,reason="end-stepping-range",line="14",file="recursive2.c" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-step-instruction} Command +@findex -exec-step-instruction + +@subsubheading Synopsis + +@smallexample + -exec-step-instruction +@end smallexample + +Asynchronous command. Resumes the inferior which executes one machine +instruction. The output, once @value{GDBN} has stopped, will vary depending on +whether we have stopped in the middle of a source line or not. In the +former case, the address at which the program stopped will be printed as +well. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{stepi}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-exec-step-instruction +^running + +(@value{GDBP}) +*stopped,reason="end-stepping-range", +frame=@{func="foo",args=[],file="try.c",line="10"@} +(@value{GDBP}) +-exec-step-instruction +^running + +(@value{GDBP}) +*stopped,reason="end-stepping-range", +frame=@{addr="0x000100f4",func="foo",args=[],file="try.c",line="10"@} +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-exec-until} Command +@findex -exec-until + +@subsubheading Synopsis + +@smallexample + -exec-until [ @var{location} ] +@end smallexample + +Asynchronous command. Executes the inferior until the @var{location} +specified in the argument is reached. If there is no argument, the inferior +executes until a source line greater than the current one is reached. +The reason for stopping in this case will be @samp{location-reached}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{until}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-exec-until recursive2.c:6 +^running +(@value{GDBP}) +x = 55 +*stopped,reason="location-reached",frame=@{func="main",args=[], +file="recursive2.c",line="6"@} +(@value{GDBP}) +@end smallexample + +@ignore +@subheading -file-clear +Is this going away???? +@end ignore + + +@subheading The @code{-file-exec-and-symbols} Command +@findex -file-exec-and-symbols + +@subsubheading Synopsis + +@smallexample + -file-exec-and-symbols @var{file} +@end smallexample + +Specify the executable file to be debugged. This file is the one from +which the symbol table is also read. If no file is specified, the +command clears the executable and symbol information. If breakpoints +are set when using this command with no arguments, @value{GDBN} will produce +error messages. Otherwise, no output is produced, except a completion +notification. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{file}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx +^done +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-file-exec-file} Command +@findex -file-exec-file + +@subsubheading Synopsis + +@smallexample + -file-exec-file @var{file} +@end smallexample + +Specify the executable file to be debugged. Unlike +@samp{-file-exec-and-symbols}, the symbol table is @emph{not} read +from this file. If used without argument, @value{GDBN} clears the information +about the executable file. No output is produced, except a completion +notification. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{exec-file}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx +^done +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-file-list-exec-sections} Command +@findex -file-list-exec-sections + +@subsubheading Synopsis + +@smallexample + -file-list-exec-sections +@end smallexample + +List the sections of the current executable file. + +@subsubheading @value{GDBN} Command + +The @value{GDBN} command @samp{info file} shows, among the rest, the same +information as this command. @code{gdbtk} has a corresponding command +@samp{gdb_load_info}. + +@subsubheading Example +N.A. + + +@subheading The @code{-file-list-exec-source-file} Command +@findex -file-list-exec-source-file + +@subsubheading Synopsis + +@smallexample + -file-list-exec-source-file +@end smallexample + +List the line number, the current source file, and the absolute path +to the current source file for the current executable. + +@subsubheading @value{GDBN} Command + +There's no @value{GDBN} command which directly corresponds to this one. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +123-file-list-exec-source-file +123^done,line="1",file="foo.c",fullname="/home/bar/foo.c" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-file-list-exec-source-files} Command +@findex -file-list-exec-source-files + +@subsubheading Synopsis + +@smallexample + -file-list-exec-source-files +@end smallexample + +List the source files for the current executable. + +@subsubheading @value{GDBN} Command + +There's no @value{GDBN} command which directly corresponds to this one. +@code{gdbtk} has an analogous command @samp{gdb_listfiles}. + +@subsubheading Example +N.A. + + +@subheading The @code{-file-list-shared-libraries} Command +@findex -file-list-shared-libraries + +@subsubheading Synopsis + +@smallexample + -file-list-shared-libraries +@end smallexample + +List the shared libraries in the program. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info shared}. + +@subsubheading Example +N.A. + + +@subheading The @code{-file-list-symbol-files} Command +@findex -file-list-symbol-files + +@subsubheading Synopsis + +@smallexample + -file-list-symbol-files +@end smallexample + +List symbol files. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info file} (part of it). + +@subsubheading Example +N.A. + + +@subheading The @code{-file-symbol-file} Command +@findex -file-symbol-file + +@subsubheading Synopsis + +@smallexample + -file-symbol-file @var{file} +@end smallexample + +Read symbol table info from the specified @var{file} argument. When +used without arguments, clears @value{GDBN}'s symbol table info. No output is +produced, except for a completion notification. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{symbol-file}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx +^done +(@value{GDBP}) +@end smallexample + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Miscellaneous Commands +@section Miscellaneous @value{GDBN} commands in @sc{gdb/mi} + +@c @subheading -gdb-complete + +@subheading The @code{-gdb-exit} Command +@findex -gdb-exit + +@subsubheading Synopsis + +@smallexample + -gdb-exit +@end smallexample + +Exit @value{GDBN} immediately. + +@subsubheading @value{GDBN} Command + +Approximately corresponds to @samp{quit}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-gdb-exit +@end smallexample + +@subheading The @code{-gdb-set} Command +@findex -gdb-set + +@subsubheading Synopsis + +@smallexample + -gdb-set +@end smallexample + +Set an internal @value{GDBN} variable. +@c IS THIS A DOLLAR VARIABLE? OR SOMETHING LIKE ANNOTATE ????? + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{set}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-gdb-set $foo=3 +^done +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-gdb-show} Command +@findex -gdb-show + +@subsubheading Synopsis + +@smallexample + -gdb-show +@end smallexample + +Show the current value of a @value{GDBN} variable. + +@subsubheading @value{GDBN} command + +The corresponding @value{GDBN} command is @samp{show}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-gdb-show annotate +^done,value="0" +(@value{GDBP}) +@end smallexample + +@c @subheading -gdb-source + + +@subheading The @code{-gdb-version} Command +@findex -gdb-version + +@subsubheading Synopsis + +@smallexample + -gdb-version +@end smallexample + +Show version information for @value{GDBN}. Used mostly in testing. + +@subsubheading @value{GDBN} Command + +There's no equivalent @value{GDBN} command. @value{GDBN} by default shows this +information when you start an interactive session. + +@subsubheading Example + +@c This example modifies the actual output from GDB to avoid overfull +@c box in TeX. +@smallexample +(@value{GDBP}) +-gdb-version +~GNU gdb 5.2.1 +~Copyright 2000 Free Software Foundation, Inc. +~GDB is free software, covered by the GNU General Public License, and +~you are welcome to change it and/or distribute copies of it under +~ certain conditions. +~Type "show copying" to see the conditions. +~There is absolutely no warranty for GDB. Type "show warranty" for +~ details. +~This GDB was configured as + "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi". +^done +(@value{GDBP}) +@end smallexample + +@subheading The @code{-interpreter-exec} Command +@findex -interpreter-exec + +@subheading Synopsis + +@smallexample +-interpreter-exec @var{interpreter} @var{command} +@end smallexample + +Execute the specified @var{command} in the given @var{interpreter}. + +@subheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{interpreter-exec}. + +@subheading Example + +@smallexample +(@value{GDBP}) +-interpreter-exec console "break main" +&"During symbol reading, couldn't parse type; debugger out of date?.\n" +&"During symbol reading, bad structure-type format.\n" +~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n" +^done +(@value{GDBP}) +@end smallexample + +@ignore +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Kod Commands +@section @sc{gdb/mi} Kod Commands + +The Kod commands are not implemented. + +@c @subheading -kod-info + +@c @subheading -kod-list + +@c @subheading -kod-list-object-types + +@c @subheading -kod-show + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Memory Overlay Commands +@section @sc{gdb/mi} Memory Overlay Commands + +The memory overlay commands are not implemented. + +@c @subheading -overlay-auto + +@c @subheading -overlay-list-mapping-state + +@c @subheading -overlay-list-overlays + +@c @subheading -overlay-map + +@c @subheading -overlay-off + +@c @subheading -overlay-on + +@c @subheading -overlay-unmap + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Signal Handling Commands +@section @sc{gdb/mi} Signal Handling Commands + +Signal handling commands are not implemented. + +@c @subheading -signal-handle + +@c @subheading -signal-list-handle-actions + +@c @subheading -signal-list-signal-types +@end ignore + + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Stack Manipulation +@section @sc{gdb/mi} Stack Manipulation Commands + + +@subheading The @code{-stack-info-frame} Command +@findex -stack-info-frame + +@subsubheading Synopsis + +@smallexample + -stack-info-frame +@end smallexample + +Get info on the current frame. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info frame} or @samp{frame} +(without arguments). + +@subsubheading Example +N.A. + +@subheading The @code{-stack-info-depth} Command +@findex -stack-info-depth + +@subsubheading Synopsis + +@smallexample + -stack-info-depth [ @var{max-depth} ] +@end smallexample + +Return the depth of the stack. If the integer argument @var{max-depth} +is specified, do not count beyond @var{max-depth} frames. + +@subsubheading @value{GDBN} Command + +There's no equivalent @value{GDBN} command. + +@subsubheading Example + +For a stack with frame levels 0 through 11: + +@smallexample +(@value{GDBP}) +-stack-info-depth +^done,depth="12" +(@value{GDBP}) +-stack-info-depth 4 +^done,depth="4" +(@value{GDBP}) +-stack-info-depth 12 +^done,depth="12" +(@value{GDBP}) +-stack-info-depth 11 +^done,depth="11" +(@value{GDBP}) +-stack-info-depth 13 +^done,depth="12" +(@value{GDBP}) +@end smallexample + +@subheading The @code{-stack-list-arguments} Command +@findex -stack-list-arguments + +@subsubheading Synopsis + +@smallexample + -stack-list-arguments @var{show-values} + [ @var{low-frame} @var{high-frame} ] +@end smallexample + +Display a list of the arguments for the frames between @var{low-frame} +and @var{high-frame} (inclusive). If @var{low-frame} and +@var{high-frame} are not provided, list the arguments for the whole call +stack. + +The @var{show-values} argument must have a value of 0 or 1. A value of +0 means that only the names of the arguments are listed, a value of 1 +means that both names and values of the arguments are printed. + +@subsubheading @value{GDBN} Command + +@value{GDBN} does not have an equivalent command. @code{gdbtk} has a +@samp{gdb_get_args} command which partially overlaps with the +functionality of @samp{-stack-list-arguments}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-stack-list-frames +^done, +stack=[ +frame=@{level="0",addr="0x00010734",func="callee4", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@}, +frame=@{level="1",addr="0x0001076c",func="callee3", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="17"@}, +frame=@{level="2",addr="0x0001078c",func="callee2", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="22"@}, +frame=@{level="3",addr="0x000107b4",func="callee1", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="27"@}, +frame=@{level="4",addr="0x000107e0",func="main", +file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="32"@}] +(@value{GDBP}) +-stack-list-arguments 0 +^done, +stack-args=[ +frame=@{level="0",args=[]@}, +frame=@{level="1",args=[name="strarg"]@}, +frame=@{level="2",args=[name="intarg",name="strarg"]@}, +frame=@{level="3",args=[name="intarg",name="strarg",name="fltarg"]@}, +frame=@{level="4",args=[]@}] +(@value{GDBP}) +-stack-list-arguments 1 +^done, +stack-args=[ +frame=@{level="0",args=[]@}, +frame=@{level="1", + args=[@{name="strarg",value="0x11940 \"A string argument.\""@}]@}, +frame=@{level="2",args=[ +@{name="intarg",value="2"@}, +@{name="strarg",value="0x11940 \"A string argument.\""@}]@}, +@{frame=@{level="3",args=[ +@{name="intarg",value="2"@}, +@{name="strarg",value="0x11940 \"A string argument.\""@}, +@{name="fltarg",value="3.5"@}]@}, +frame=@{level="4",args=[]@}] +(@value{GDBP}) +-stack-list-arguments 0 2 2 +^done,stack-args=[frame=@{level="2",args=[name="intarg",name="strarg"]@}] +(@value{GDBP}) +-stack-list-arguments 1 2 2 +^done,stack-args=[frame=@{level="2", +args=[@{name="intarg",value="2"@}, +@{name="strarg",value="0x11940 \"A string argument.\""@}]@}] +(@value{GDBP}) +@end smallexample + +@c @subheading -stack-list-exception-handlers + + +@subheading The @code{-stack-list-frames} Command +@findex -stack-list-frames + +@subsubheading Synopsis + +@smallexample + -stack-list-frames [ @var{low-frame} @var{high-frame} ] +@end smallexample + +List the frames currently on the stack. For each frame it displays the +following info: + +@table @samp +@item @var{level} +The frame number, 0 being the topmost frame, i.e. the innermost function. +@item @var{addr} +The @code{$pc} value for that frame. +@item @var{func} +Function name. +@item @var{file} +File name of the source file where the function lives. +@item @var{line} +Line number corresponding to the @code{$pc}. +@end table + +If invoked without arguments, this command prints a backtrace for the +whole stack. If given two integer arguments, it shows the frames whose +levels are between the two arguments (inclusive). If the two arguments +are equal, it shows the single frame at the corresponding level. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{backtrace} and @samp{where}. + +@subsubheading Example + +Full stack backtrace: + +@smallexample +(@value{GDBP}) +-stack-list-frames +^done,stack= +[frame=@{level="0",addr="0x0001076c",func="foo", + file="recursive2.c",line="11"@}, +frame=@{level="1",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="2",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="3",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="4",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="5",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="6",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="7",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="8",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="9",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="10",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="11",addr="0x00010738",func="main", + file="recursive2.c",line="4"@}] +(@value{GDBP}) +@end smallexample + +Show frames between @var{low_frame} and @var{high_frame}: + +@smallexample +(@value{GDBP}) +-stack-list-frames 3 5 +^done,stack= +[frame=@{level="3",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="4",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}, +frame=@{level="5",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}] +(@value{GDBP}) +@end smallexample + +Show a single frame: + +@smallexample +(@value{GDBP}) +-stack-list-frames 3 3 +^done,stack= +[frame=@{level="3",addr="0x000107a4",func="foo", + file="recursive2.c",line="14"@}] +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-stack-list-locals} Command +@findex -stack-list-locals + +@subsubheading Synopsis + +@smallexample + -stack-list-locals @var{print-values} +@end smallexample + +Display the local variable names for the current frame. With an +argument of 0 prints only the names of the variables, with argument of 1 +prints also their values. + +@subsubheading @value{GDBN} Command + +@samp{info locals} in @value{GDBN}, @samp{gdb_get_locals} in @code{gdbtk}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-stack-list-locals 0 +^done,locals=[name="A",name="B",name="C"] +(@value{GDBP}) +-stack-list-locals 1 +^done,locals=[@{name="A",value="1"@},@{name="B",value="2"@}, + @{name="C",value="3"@}] +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-stack-select-frame} Command +@findex -stack-select-frame + +@subsubheading Synopsis + +@smallexample + -stack-select-frame @var{framenum} +@end smallexample + +Change the current frame. Select a different frame @var{framenum} on +the stack. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{frame}, @samp{up}, +@samp{down}, @samp{select-frame}, @samp{up-silent}, and @samp{down-silent}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-stack-select-frame 2 +^done +(@value{GDBP}) +@end smallexample + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Symbol Query +@section @sc{gdb/mi} Symbol Query Commands + + +@subheading The @code{-symbol-info-address} Command +@findex -symbol-info-address + +@subsubheading Synopsis + +@smallexample + -symbol-info-address @var{symbol} +@end smallexample + +Describe where @var{symbol} is stored. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info address}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-info-file} Command +@findex -symbol-info-file + +@subsubheading Synopsis + +@smallexample + -symbol-info-file +@end smallexample + +Show the file for the symbol. + +@subsubheading @value{GDBN} Command + +There's no equivalent @value{GDBN} command. @code{gdbtk} has +@samp{gdb_find_file}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-info-function} Command +@findex -symbol-info-function + +@subsubheading Synopsis + +@smallexample + -symbol-info-function +@end smallexample + +Show which function the symbol lives in. + +@subsubheading @value{GDBN} Command + +@samp{gdb_get_function} in @code{gdbtk}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-info-line} Command +@findex -symbol-info-line + +@subsubheading Synopsis + +@smallexample + -symbol-info-line +@end smallexample + +Show the core addresses of the code for a source line. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} comamnd is @samp{info line}. +@code{gdbtk} has the @samp{gdb_get_line} and @samp{gdb_get_file} commands. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-info-symbol} Command +@findex -symbol-info-symbol + +@subsubheading Synopsis + +@smallexample + -symbol-info-symbol @var{addr} +@end smallexample + +Describe what symbol is at location @var{addr}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info symbol}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-list-functions} Command +@findex -symbol-list-functions + +@subsubheading Synopsis + +@smallexample + -symbol-list-functions +@end smallexample + +List the functions in the executable. + +@subsubheading @value{GDBN} Command + +@samp{info functions} in @value{GDBN}, @samp{gdb_listfunc} and +@samp{gdb_search} in @code{gdbtk}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-list-types} Command +@findex -symbol-list-types + +@subsubheading Synopsis + +@smallexample + -symbol-list-types +@end smallexample + +List all the type names. + +@subsubheading @value{GDBN} Command + +The corresponding commands are @samp{info types} in @value{GDBN}, +@samp{gdb_search} in @code{gdbtk}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-list-variables} Command +@findex -symbol-list-variables + +@subsubheading Synopsis + +@smallexample + -symbol-list-variables +@end smallexample + +List all the global and static variable names. + +@subsubheading @value{GDBN} Command + +@samp{info variables} in @value{GDBN}, @samp{gdb_search} in @code{gdbtk}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-locate} Command +@findex -symbol-locate + +@subsubheading Synopsis + +@smallexample + -symbol-locate +@end smallexample + +@subsubheading @value{GDBN} Command + +@samp{gdb_loc} in @code{gdbtk}. + +@subsubheading Example +N.A. + + +@subheading The @code{-symbol-type} Command +@findex -symbol-type + +@subsubheading Synopsis + +@smallexample + -symbol-type @var{variable} +@end smallexample + +Show type of @var{variable}. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{ptype}, @code{gdbtk} has +@samp{gdb_obj_variable}. + +@subsubheading Example +N.A. + + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Target Manipulation +@section @sc{gdb/mi} Target Manipulation Commands + + +@subheading The @code{-target-attach} Command +@findex -target-attach + +@subsubheading Synopsis + +@smallexample + -target-attach @var{pid} | @var{file} +@end smallexample + +Attach to a process @var{pid} or a file @var{file} outside of @value{GDBN}. + +@subsubheading @value{GDBN} command + +The corresponding @value{GDBN} command is @samp{attach}. + +@subsubheading Example +N.A. + + +@subheading The @code{-target-compare-sections} Command +@findex -target-compare-sections + +@subsubheading Synopsis + +@smallexample + -target-compare-sections [ @var{section} ] +@end smallexample + +Compare data of section @var{section} on target to the exec file. +Without the argument, all sections are compared. + +@subsubheading @value{GDBN} Command + +The @value{GDBN} equivalent is @samp{compare-sections}. + +@subsubheading Example +N.A. + + +@subheading The @code{-target-detach} Command +@findex -target-detach + +@subsubheading Synopsis + +@smallexample + -target-detach +@end smallexample + +Disconnect from the remote target. There's no output. + +@subsubheading @value{GDBN} command + +The corresponding @value{GDBN} command is @samp{detach}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-target-detach +^done +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-target-download} Command +@findex -target-download + +@subsubheading Synopsis + +@smallexample + -target-download +@end smallexample + +Loads the executable onto the remote target. +It prints out an update message every half second, which includes the fields: + +@table @samp +@item section +The name of the section. +@item section-sent +The size of what has been sent so far for that section. +@item section-size +The size of the section. +@item total-sent +The total size of what was sent so far (the current and the previous sections). +@item total-size +The size of the overall executable to download. +@end table + +@noindent +Each message is sent as status record (@pxref{GDB/MI Output Syntax, , +@sc{gdb/mi} Output Syntax}). + +In addition, it prints the name and size of the sections, as they are +downloaded. These messages include the following fields: + +@table @samp +@item section +The name of the section. +@item section-size +The size of the section. +@item total-size +The size of the overall executable to download. +@end table + +@noindent +At the end, a summary is printed. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{load}. + +@subsubheading Example + +Note: each status message appears on a single line. Here the messages +have been broken down so that they can fit onto a page. + +@smallexample +(@value{GDBP}) +-target-download ++download,@{section=".text",section-size="6668",total-size="9880"@} ++download,@{section=".text",section-sent="512",section-size="6668", +total-sent="512",total-size="9880"@} ++download,@{section=".text",section-sent="1024",section-size="6668", +total-sent="1024",total-size="9880"@} ++download,@{section=".text",section-sent="1536",section-size="6668", +total-sent="1536",total-size="9880"@} ++download,@{section=".text",section-sent="2048",section-size="6668", +total-sent="2048",total-size="9880"@} ++download,@{section=".text",section-sent="2560",section-size="6668", +total-sent="2560",total-size="9880"@} ++download,@{section=".text",section-sent="3072",section-size="6668", +total-sent="3072",total-size="9880"@} ++download,@{section=".text",section-sent="3584",section-size="6668", +total-sent="3584",total-size="9880"@} ++download,@{section=".text",section-sent="4096",section-size="6668", +total-sent="4096",total-size="9880"@} ++download,@{section=".text",section-sent="4608",section-size="6668", +total-sent="4608",total-size="9880"@} ++download,@{section=".text",section-sent="5120",section-size="6668", +total-sent="5120",total-size="9880"@} ++download,@{section=".text",section-sent="5632",section-size="6668", +total-sent="5632",total-size="9880"@} ++download,@{section=".text",section-sent="6144",section-size="6668", +total-sent="6144",total-size="9880"@} ++download,@{section=".text",section-sent="6656",section-size="6668", +total-sent="6656",total-size="9880"@} ++download,@{section=".init",section-size="28",total-size="9880"@} ++download,@{section=".fini",section-size="28",total-size="9880"@} ++download,@{section=".data",section-size="3156",total-size="9880"@} ++download,@{section=".data",section-sent="512",section-size="3156", +total-sent="7236",total-size="9880"@} ++download,@{section=".data",section-sent="1024",section-size="3156", +total-sent="7748",total-size="9880"@} ++download,@{section=".data",section-sent="1536",section-size="3156", +total-sent="8260",total-size="9880"@} ++download,@{section=".data",section-sent="2048",section-size="3156", +total-sent="8772",total-size="9880"@} ++download,@{section=".data",section-sent="2560",section-size="3156", +total-sent="9284",total-size="9880"@} ++download,@{section=".data",section-sent="3072",section-size="3156", +total-sent="9796",total-size="9880"@} +^done,address="0x10004",load-size="9880",transfer-rate="6586", +write-rate="429" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-target-exec-status} Command +@findex -target-exec-status + +@subsubheading Synopsis + +@smallexample + -target-exec-status +@end smallexample + +Provide information on the state of the target (whether it is running or +not, for instance). + +@subsubheading @value{GDBN} Command + +There's no equivalent @value{GDBN} command. + +@subsubheading Example +N.A. + + +@subheading The @code{-target-list-available-targets} Command +@findex -target-list-available-targets + +@subsubheading Synopsis + +@smallexample + -target-list-available-targets +@end smallexample + +List the possible targets to connect to. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{help target}. + +@subsubheading Example +N.A. + + +@subheading The @code{-target-list-current-targets} Command +@findex -target-list-current-targets + +@subsubheading Synopsis + +@smallexample + -target-list-current-targets +@end smallexample + +Describe the current target. + +@subsubheading @value{GDBN} Command + +The corresponding information is printed by @samp{info file} (among +other things). + +@subsubheading Example +N.A. + + +@subheading The @code{-target-list-parameters} Command +@findex -target-list-parameters + +@subsubheading Synopsis + +@smallexample + -target-list-parameters +@end smallexample + +@c ???? + +@subsubheading @value{GDBN} Command + +No equivalent. + +@subsubheading Example +N.A. + + +@subheading The @code{-target-select} Command +@findex -target-select + +@subsubheading Synopsis + +@smallexample + -target-select @var{type} @var{parameters @dots{}} +@end smallexample + +Connect @value{GDBN} to the remote target. This command takes two args: + +@table @samp +@item @var{type} +The type of target, for instance @samp{async}, @samp{remote}, etc. +@item @var{parameters} +Device names, host names and the like. @xref{Target Commands, , +Commands for managing targets}, for more details. +@end table + +The output is a connection notification, followed by the address at +which the target program is, in the following form: + +@smallexample +^connected,addr="@var{address}",func="@var{function name}", + args=[@var{arg list}] +@end smallexample + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{target}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-target-select async /dev/ttya +^connected,addr="0xfe00a300",func="??",args=[] +(@value{GDBP}) +@end smallexample + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Thread Commands +@section @sc{gdb/mi} Thread Commands + + +@subheading The @code{-thread-info} Command +@findex -thread-info + +@subsubheading Synopsis + +@smallexample + -thread-info +@end smallexample + +@subsubheading @value{GDBN} command + +No equivalent. + +@subsubheading Example +N.A. + + +@subheading The @code{-thread-list-all-threads} Command +@findex -thread-list-all-threads + +@subsubheading Synopsis + +@smallexample + -thread-list-all-threads +@end smallexample + +@subsubheading @value{GDBN} Command + +The equivalent @value{GDBN} command is @samp{info threads}. + +@subsubheading Example +N.A. + + +@subheading The @code{-thread-list-ids} Command +@findex -thread-list-ids + +@subsubheading Synopsis + +@smallexample + -thread-list-ids +@end smallexample + +Produces a list of the currently known @value{GDBN} thread ids. At the +end of the list it also prints the total number of such threads. + +@subsubheading @value{GDBN} Command + +Part of @samp{info threads} supplies the same information. + +@subsubheading Example + +No threads present, besides the main process: + +@smallexample +(@value{GDBP}) +-thread-list-ids +^done,thread-ids=@{@},number-of-threads="0" +(@value{GDBP}) +@end smallexample + + +Several threads: + +@smallexample +(@value{GDBP}) +-thread-list-ids +^done,thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@}, +number-of-threads="3" +(@value{GDBP}) +@end smallexample + + +@subheading The @code{-thread-select} Command +@findex -thread-select + +@subsubheading Synopsis + +@smallexample + -thread-select @var{threadnum} +@end smallexample + +Make @var{threadnum} the current thread. It prints the number of the new +current thread, and the topmost frame for that thread. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{thread}. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-exec-next +^running +(@value{GDBP}) +*stopped,reason="end-stepping-range",thread-id="2",line="187", +file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c" +(@value{GDBP}) +-thread-list-ids +^done, +thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@}, +number-of-threads="3" +(@value{GDBP}) +-thread-select 3 +^done,new-thread-id="3", +frame=@{level="0",func="vprintf", +args=[@{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""@}, +@{name="arg",value="0x2"@}],file="vprintf.c",line="31"@} +(@value{GDBP}) +@end smallexample + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Tracepoint Commands +@section @sc{gdb/mi} Tracepoint Commands + +The tracepoint commands are not yet implemented. + +@c @subheading -trace-actions + +@c @subheading -trace-delete + +@c @subheading -trace-disable + +@c @subheading -trace-dump + +@c @subheading -trace-enable + +@c @subheading -trace-exists + +@c @subheading -trace-find + +@c @subheading -trace-frame-number + +@c @subheading -trace-info + +@c @subheading -trace-insert + +@c @subheading -trace-list + +@c @subheading -trace-pass-count + +@c @subheading -trace-save + +@c @subheading -trace-start + +@c @subheading -trace-stop + + +@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@node GDB/MI Variable Objects +@section @sc{gdb/mi} Variable Objects + + +@subheading Motivation for Variable Objects in @sc{gdb/mi} + +For the implementation of a variable debugger window (locals, watched +expressions, etc.), we are proposing the adaptation of the existing code +used by @code{Insight}. + +The two main reasons for that are: + +@enumerate 1 +@item +It has been proven in practice (it is already on its second generation). + +@item +It will shorten development time (needless to say how important it is +now). +@end enumerate + +The original interface was designed to be used by Tcl code, so it was +slightly changed so it could be used through @sc{gdb/mi}. This section +describes the @sc{gdb/mi} operations that will be available and gives some +hints about their use. + +@emph{Note}: In addition to the set of operations described here, we +expect the @sc{gui} implementation of a variable window to require, at +least, the following operations: + +@itemize @bullet +@item @code{-gdb-show} @code{output-radix} +@item @code{-stack-list-arguments} +@item @code{-stack-list-locals} +@item @code{-stack-select-frame} +@end itemize + +@subheading Introduction to Variable Objects in @sc{gdb/mi} + +@cindex variable objects in @sc{gdb/mi} +The basic idea behind variable objects is the creation of a named object +to represent a variable, an expression, a memory location or even a CPU +register. For each object created, a set of operations is available for +examining or changing its properties. + +Furthermore, complex data types, such as C structures, are represented +in a tree format. For instance, the @code{struct} type variable is the +root and the children will represent the struct members. If a child +is itself of a complex type, it will also have children of its own. +Appropriate language differences are handled for C, C@t{++} and Java. + +When returning the actual values of the objects, this facility allows +for the individual selection of the display format used in the result +creation. It can be chosen among: binary, decimal, hexadecimal, octal +and natural. Natural refers to a default format automatically +chosen based on the variable type (like decimal for an @code{int}, hex +for pointers, etc.). + +The following is the complete set of @sc{gdb/mi} operations defined to +access this functionality: + +@multitable @columnfractions .4 .6 +@item @strong{Operation} +@tab @strong{Description} + +@item @code{-var-create} +@tab create a variable object +@item @code{-var-delete} +@tab delete the variable object and its children +@item @code{-var-set-format} +@tab set the display format of this variable +@item @code{-var-show-format} +@tab show the display format of this variable +@item @code{-var-info-num-children} +@tab tells how many children this object has +@item @code{-var-list-children} +@tab return a list of the object's children +@item @code{-var-info-type} +@tab show the type of this variable object +@item @code{-var-info-expression} +@tab print what this variable object represents +@item @code{-var-show-attributes} +@tab is this variable editable? does it exist here? +@item @code{-var-evaluate-expression} +@tab get the value of this variable +@item @code{-var-assign} +@tab set the value of this variable +@item @code{-var-update} +@tab update the variable and its children +@end multitable + +In the next subsection we describe each operation in detail and suggest +how it can be used. + +@subheading Description And Use of Operations on Variable Objects + +@subheading The @code{-var-create} Command +@findex -var-create + +@subsubheading Synopsis + +@smallexample + -var-create @{@var{name} | "-"@} + @{@var{frame-addr} | "*"@} @var{expression} +@end smallexample + +This operation creates a variable object, which allows the monitoring of +a variable, the result of an expression, a memory cell or a CPU +register. + +The @var{name} parameter is the string by which the object can be +referenced. It must be unique. If @samp{-} is specified, the varobj +system will generate a string ``varNNNNNN'' automatically. It will be +unique provided that one does not specify @var{name} on that format. +The command fails if a duplicate name is found. + +The frame under which the expression should be evaluated can be +specified by @var{frame-addr}. A @samp{*} indicates that the current +frame should be used. + +@var{expression} is any expression valid on the current language set (must not +begin with a @samp{*}), or one of the following: + +@itemize @bullet +@item +@samp{*@var{addr}}, where @var{addr} is the address of a memory cell + +@item +@samp{*@var{addr}-@var{addr}} --- a memory address range (TBD) + +@item +@samp{$@var{regname}} --- a CPU register name +@end itemize + +@subsubheading Result + +This operation returns the name, number of children and the type of the +object created. Type is returned as a string as the ones generated by +the @value{GDBN} CLI: + +@smallexample + name="@var{name}",numchild="N",type="@var{type}" +@end smallexample + + +@subheading The @code{-var-delete} Command +@findex -var-delete + +@subsubheading Synopsis + +@smallexample + -var-delete @var{name} +@end smallexample + +Deletes a previously created variable object and all of its children. + +Returns an error if the object @var{name} is not found. + + +@subheading The @code{-var-set-format} Command +@findex -var-set-format + +@subsubheading Synopsis + +@smallexample + -var-set-format @var{name} @var{format-spec} +@end smallexample + +Sets the output format for the value of the object @var{name} to be +@var{format-spec}. + +The syntax for the @var{format-spec} is as follows: + +@smallexample + @var{format-spec} @expansion{} + @{binary | decimal | hexadecimal | octal | natural@} +@end smallexample + + +@subheading The @code{-var-show-format} Command +@findex -var-show-format + +@subsubheading Synopsis + +@smallexample + -var-show-format @var{name} +@end smallexample + +Returns the format used to display the value of the object @var{name}. + +@smallexample + @var{format} @expansion{} + @var{format-spec} +@end smallexample + + +@subheading The @code{-var-info-num-children} Command +@findex -var-info-num-children + +@subsubheading Synopsis + +@smallexample + -var-info-num-children @var{name} +@end smallexample + +Returns the number of children of a variable object @var{name}: + +@smallexample + numchild=@var{n} +@end smallexample + + +@subheading The @code{-var-list-children} Command +@findex -var-list-children + +@subsubheading Synopsis + +@smallexample + -var-list-children @var{name} +@end smallexample + +Returns a list of the children of the specified variable object: + +@smallexample + numchild=@var{n},children=[@{name=@var{name}, + numchild=@var{n},type=@var{type}@},@r{(repeats N times)}] +@end smallexample + + +@subheading The @code{-var-info-type} Command +@findex -var-info-type + +@subsubheading Synopsis + +@smallexample + -var-info-type @var{name} +@end smallexample + +Returns the type of the specified variable @var{name}. The type is +returned as a string in the same format as it is output by the +@value{GDBN} CLI: + +@smallexample + type=@var{typename} +@end smallexample + + +@subheading The @code{-var-info-expression} Command +@findex -var-info-expression + +@subsubheading Synopsis + +@smallexample + -var-info-expression @var{name} +@end smallexample + +Returns what is represented by the variable object @var{name}: + +@smallexample + lang=@var{lang-spec},exp=@var{expression} +@end smallexample + +@noindent +where @var{lang-spec} is @code{@{"C" | "C++" | "Java"@}}. + +@subheading The @code{-var-show-attributes} Command +@findex -var-show-attributes + +@subsubheading Synopsis + +@smallexample + -var-show-attributes @var{name} +@end smallexample + +List attributes of the specified variable object @var{name}: + +@smallexample + status=@var{attr} [ ( ,@var{attr} )* ] +@end smallexample + +@noindent +where @var{attr} is @code{@{ @{ editable | noneditable @} | TBD @}}. + +@subheading The @code{-var-evaluate-expression} Command +@findex -var-evaluate-expression + +@subsubheading Synopsis + +@smallexample + -var-evaluate-expression @var{name} +@end smallexample + +Evaluates the expression that is represented by the specified variable +object and returns its value as a string in the current format specified +for the object: + +@smallexample + value=@var{value} +@end smallexample + +Note that one must invoke @code{-var-list-children} for a variable +before the value of a child variable can be evaluated. + +@subheading The @code{-var-assign} Command +@findex -var-assign + +@subsubheading Synopsis + +@smallexample + -var-assign @var{name} @var{expression} +@end smallexample + +Assigns the value of @var{expression} to the variable object specified +by @var{name}. The object must be @samp{editable}. If the variable's +value is altered by the assign, the variable will show up in any +subsequent @code{-var-update} list. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +-var-assign var1 3 +^done,value="3" +(@value{GDBP}) +-var-update * +^done,changelist=[@{name="var1",in_scope="true",type_changed="false"@}] +(@value{GDBP}) +@end smallexample + +@subheading The @code{-var-update} Command +@findex -var-update + +@subsubheading Synopsis + +@smallexample + -var-update @{@var{name} | "*"@} +@end smallexample + +Update the value of the variable object @var{name} by evaluating its +expression after fetching all the new values from memory or registers. +A @samp{*} causes all existing variable objects to be updated. + + +@node Annotations +@chapter @value{GDBN} Annotations + +This chapter describes annotations in @value{GDBN}. Annotations are +designed to interface @value{GDBN} to graphical user interfaces or +other similar programs which want to interact with @value{GDBN} at a +relatively high level. + +@ignore +This is Edition @value{EDITION}, @value{DATE}. +@end ignore + +@menu +* Annotations Overview:: What annotations are; the general syntax. +* Server Prefix:: Issuing a command without affecting user state. +* Value Annotations:: Values are marked as such. +* Frame Annotations:: Stack frames are annotated. +* Displays:: @value{GDBN} can be told to display something periodically. +* Prompting:: Annotations marking @value{GDBN}'s need for input. +* Errors:: Annotations for error messages. +* Breakpoint Info:: Information on breakpoints. +* Invalidation:: Some annotations describe things now invalid. +* Annotations for Running:: + Whether the program is running, how it stopped, etc. +* Source Annotations:: Annotations describing source code. +* TODO:: Annotations which might be added in the future. +@end menu + +@node Annotations Overview +@section What is an Annotation? +@cindex annotations + +To produce annotations, start @value{GDBN} with the @code{--annotate=2} option. + +Annotations start with a newline character, two @samp{control-z} +characters, and the name of the annotation. If there is no additional +information associated with this annotation, the name of the annotation +is followed immediately by a newline. If there is additional +information, the name of the annotation is followed by a space, the +additional information, and a newline. The additional information +cannot contain newline characters. + +Any output not beginning with a newline and two @samp{control-z} +characters denotes literal output from @value{GDBN}. Currently there is +no need for @value{GDBN} to output a newline followed by two +@samp{control-z} characters, but if there was such a need, the +annotations could be extended with an @samp{escape} annotation which +means those three characters as output. + +A simple example of starting up @value{GDBN} with annotations is: + +@smallexample +$ gdb --annotate=2 +GNU GDB 5.0 +Copyright 2000 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General Public License, +and you are welcome to change it and/or distribute copies of it +under certain conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show warranty" +for details. +This GDB was configured as "sparc-sun-sunos4.1.3" + +^Z^Zpre-prompt +(gdb) +^Z^Zprompt +quit + +^Z^Zpost-prompt +$ +@end smallexample + +Here @samp{quit} is input to @value{GDBN}; the rest is output from +@value{GDBN}. The three lines beginning @samp{^Z^Z} (where @samp{^Z} +denotes a @samp{control-z} character) are annotations; the rest is +output from @value{GDBN}. + +@node Server Prefix +@section The Server Prefix +@cindex server prefix for annotations + +To issue a command to @value{GDBN} without affecting certain aspects of +the state which is seen by users, prefix it with @samp{server }. This +means that this command will not affect the command history, nor will it +affect @value{GDBN}'s notion of which command to repeat if @key{RET} is +pressed on a line by itself. + +The server prefix does not affect the recording of values into the value +history; to print a value without recording it into the value history, +use the @code{output} command instead of the @code{print} command. + +@node Value Annotations +@section Values + +@cindex annotations for values +When a value is printed in various contexts, @value{GDBN} uses +annotations to delimit the value from the surrounding text. + +@findex value-history-begin +@findex value-history-value +@findex value-history-end +If a value is printed using @code{print} and added to the value history, +the annotation looks like + +@smallexample +^Z^Zvalue-history-begin @var{history-number} @var{value-flags} +@var{history-string} +^Z^Zvalue-history-value +@var{the-value} +^Z^Zvalue-history-end +@end smallexample + +@noindent +where @var{history-number} is the number it is getting in the value +history, @var{history-string} is a string, such as @samp{$5 = }, which +introduces the value to the user, @var{the-value} is the output +corresponding to the value itself, and @var{value-flags} is @samp{*} for +a value which can be dereferenced and @samp{-} for a value which cannot. + +@findex value-begin +@findex value-end +If the value is not added to the value history (it is an invalid float +or it is printed with the @code{output} command), the annotation is similar: + +@smallexample +^Z^Zvalue-begin @var{value-flags} +@var{the-value} +^Z^Zvalue-end +@end smallexample + +@findex arg-begin +@findex arg-name-end +@findex arg-value +@findex arg-end +When @value{GDBN} prints an argument to a function (for example, in the output +from the @code{backtrace} command), it annotates it as follows: + +@smallexample +^Z^Zarg-begin +@var{argument-name} +^Z^Zarg-name-end +@var{separator-string} +^Z^Zarg-value @var{value-flags} +@var{the-value} +^Z^Zarg-end +@end smallexample + +@noindent +where @var{argument-name} is the name of the argument, +@var{separator-string} is text which separates the name from the value +for the user's benefit (such as @samp{=}), and @var{value-flags} and +@var{the-value} have the same meanings as in a +@code{value-history-begin} annotation. + +@findex field-begin +@findex field-name-end +@findex field-value +@findex field-end +When printing a structure, @value{GDBN} annotates it as follows: + +@smallexample +^Z^Zfield-begin @var{value-flags} +@var{field-name} +^Z^Zfield-name-end +@var{separator-string} +^Z^Zfield-value +@var{the-value} +^Z^Zfield-end +@end smallexample + +@noindent +where @var{field-name} is the name of the field, @var{separator-string} +is text which separates the name from the value for the user's benefit +(such as @samp{=}), and @var{value-flags} and @var{the-value} have the +same meanings as in a @code{value-history-begin} annotation. + +When printing an array, @value{GDBN} annotates it as follows: + +@smallexample +^Z^Zarray-section-begin @var{array-index} @var{value-flags} +@end smallexample + +@noindent +where @var{array-index} is the index of the first element being +annotated and @var{value-flags} has the same meaning as in a +@code{value-history-begin} annotation. This is followed by any number +of elements, where is element can be either a single element: + +@findex elt +@smallexample +@samp{,} @var{whitespace} ; @r{omitted for the first element} +@var{the-value} +^Z^Zelt +@end smallexample + +or a repeated element + +@findex elt-rep +@findex elt-rep-end +@smallexample +@samp{,} @var{whitespace} ; @r{omitted for the first element} +@var{the-value} +^Z^Zelt-rep @var{number-of-repetitions} +@var{repetition-string} +^Z^Zelt-rep-end +@end smallexample + +In both cases, @var{the-value} is the output for the value of the +element and @var{whitespace} can contain spaces, tabs, and newlines. In +the repeated case, @var{number-of-repetitions} is the number of +consecutive array elements which contain that value, and +@var{repetition-string} is a string which is designed to convey to the +user that repetition is being depicted. + +@findex array-section-end +Once all the array elements have been output, the array annotation is +ended with + +@smallexample +^Z^Zarray-section-end +@end smallexample + +@node Frame Annotations +@section Frames + +@cindex annotations for frames +Whenever @value{GDBN} prints a frame, it annotates it. For example, this applies +to frames printed when @value{GDBN} stops, output from commands such as +@code{backtrace} or @code{up}, etc. + +@findex frame-begin +The frame annotation begins with + +@smallexample +^Z^Zframe-begin @var{level} @var{address} +@var{level-string} +@end smallexample + +@noindent +where @var{level} is the number of the frame (0 is the innermost frame, +and other frames have positive numbers), @var{address} is the address of +the code executing in that frame, and @var{level-string} is a string +designed to convey the level to the user. @var{address} is in the form +@samp{0x} followed by one or more lowercase hex digits (note that this +does not depend on the language). The frame ends with + +@findex frame-end +@smallexample +^Z^Zframe-end +@end smallexample + +Between these annotations is the main body of the frame, which can +consist of + +@itemize @bullet +@item +@findex function-call +@smallexample +^Z^Zfunction-call +@var{function-call-string} +@end smallexample + +where @var{function-call-string} is text designed to convey to the user +that this frame is associated with a function call made by @value{GDBN} to a +function in the program being debugged. + +@item +@findex signal-handler-caller +@smallexample +^Z^Zsignal-handler-caller +@var{signal-handler-caller-string} +@end smallexample + +where @var{signal-handler-caller-string} is text designed to convey to +the user that this frame is associated with whatever mechanism is used +by this operating system to call a signal handler (it is the frame which +calls the signal handler, not the frame for the signal handler itself). + +@item +A normal frame. + +@findex frame-address +@findex frame-address-end +This can optionally (depending on whether this is thought of as +interesting information for the user to see) begin with + +@smallexample +^Z^Zframe-address +@var{address} +^Z^Zframe-address-end +@var{separator-string} +@end smallexample + +where @var{address} is the address executing in the frame (the same +address as in the @code{frame-begin} annotation, but printed in a form +which is intended for user consumption---in particular, the syntax varies +depending on the language), and @var{separator-string} is a string +intended to separate this address from what follows for the user's +benefit. + +@findex frame-function-name +@findex frame-args +Then comes + +@smallexample +^Z^Zframe-function-name +@var{function-name} +^Z^Zframe-args +@var{arguments} +@end smallexample + +where @var{function-name} is the name of the function executing in the +frame, or @samp{??} if not known, and @var{arguments} are the arguments +to the frame, with parentheses around them (each argument is annotated +individually as well, @pxref{Value Annotations}). + +@findex frame-source-begin +@findex frame-source-file +@findex frame-source-file-end +@findex frame-source-line +@findex frame-source-end +If source information is available, a reference to it is then printed: + +@smallexample +^Z^Zframe-source-begin +@var{source-intro-string} +^Z^Zframe-source-file +@var{filename} +^Z^Zframe-source-file-end +: +^Z^Zframe-source-line +@var{line-number} +^Z^Zframe-source-end +@end smallexample + +where @var{source-intro-string} separates for the user's benefit the +reference from the text which precedes it, @var{filename} is the name of +the source file, and @var{line-number} is the line number within that +file (the first line is line 1). + +@findex frame-where +If @value{GDBN} prints some information about where the frame is from (which +library, which load segment, etc.; currently only done on the RS/6000), +it is annotated with + +@smallexample +^Z^Zframe-where +@var{information} +@end smallexample + +Then, if source is to actually be displayed for this frame (for example, +this is not true for output from the @code{backtrace} command), then a +@code{source} annotation (@pxref{Source Annotations}) is displayed. Unlike +most annotations, this is output instead of the normal text which would be +output, not in addition. +@end itemize + +@node Displays +@section Displays + +@findex display-begin +@findex display-number-end +@findex display-format +@findex display-expression +@findex display-expression-end +@findex display-value +@findex display-end +@cindex annotations for display +When @value{GDBN} is told to display something using the @code{display} command, +the results of the display are annotated: + +@smallexample +^Z^Zdisplay-begin +@var{number} +^Z^Zdisplay-number-end +@var{number-separator} +^Z^Zdisplay-format +@var{format} +^Z^Zdisplay-expression +@var{expression} +^Z^Zdisplay-expression-end +@var{expression-separator} +^Z^Zdisplay-value +@var{value} +^Z^Zdisplay-end +@end smallexample + +@noindent +where @var{number} is the number of the display, @var{number-separator} +is intended to separate the number from what follows for the user, +@var{format} includes information such as the size, format, or other +information about how the value is being displayed, @var{expression} is +the expression being displayed, @var{expression-separator} is intended +to separate the expression from the text that follows for the user, +and @var{value} is the actual value being displayed. + +@node Prompting +@section Annotation for @value{GDBN} Input + +@cindex annotations for prompts +When @value{GDBN} prompts for input, it annotates this fact so it is possible +to know when to send output, when the output from a given command is +over, etc. + +Different kinds of input each have a different @dfn{input type}. Each +input type has three annotations: a @code{pre-} annotation, which +denotes the beginning of any prompt which is being output, a plain +annotation, which denotes the end of the prompt, and then a @code{post-} +annotation which denotes the end of any echo which may (or may not) be +associated with the input. For example, the @code{prompt} input type +features the following annotations: + +@smallexample +^Z^Zpre-prompt +^Z^Zprompt +^Z^Zpost-prompt +@end smallexample + +The input types are + +@table @code +@findex pre-prompt +@findex prompt +@findex post-prompt +@item prompt +When @value{GDBN} is prompting for a command (the main @value{GDBN} prompt). + +@findex pre-commands +@findex commands +@findex post-commands +@item commands +When @value{GDBN} prompts for a set of commands, like in the @code{commands} +command. The annotations are repeated for each command which is input. + +@findex pre-overload-choice +@findex overload-choice +@findex post-overload-choice +@item overload-choice +When @value{GDBN} wants the user to select between various overloaded functions. + +@findex pre-query +@findex query +@findex post-query +@item query +When @value{GDBN} wants the user to confirm a potentially dangerous operation. + +@findex pre-prompt-for-continue +@findex prompt-for-continue +@findex post-prompt-for-continue +@item prompt-for-continue +When @value{GDBN} is asking the user to press return to continue. Note: Don't +expect this to work well; instead use @code{set height 0} to disable +prompting. This is because the counting of lines is buggy in the +presence of annotations. +@end table + +@node Errors +@section Errors +@cindex annotations for errors, warnings and interrupts + +@findex quit +@smallexample +^Z^Zquit +@end smallexample + +This annotation occurs right before @value{GDBN} responds to an interrupt. + +@findex error +@smallexample +^Z^Zerror +@end smallexample + +This annotation occurs right before @value{GDBN} responds to an error. + +Quit and error annotations indicate that any annotations which @value{GDBN} was +in the middle of may end abruptly. For example, if a +@code{value-history-begin} annotation is followed by a @code{error}, one +cannot expect to receive the matching @code{value-history-end}. One +cannot expect not to receive it either, however; an error annotation +does not necessarily mean that @value{GDBN} is immediately returning all the way +to the top level. + +@findex error-begin +A quit or error annotation may be preceded by + +@smallexample +^Z^Zerror-begin +@end smallexample + +Any output between that and the quit or error annotation is the error +message. + +Warning messages are not yet annotated. +@c If we want to change that, need to fix warning(), type_error(), +@c range_error(), and possibly other places. + +@node Breakpoint Info +@section Information on Breakpoints + +@cindex annotations for breakpoints +The output from the @code{info breakpoints} command is annotated as follows: + +@findex breakpoints-headers +@findex breakpoints-table +@smallexample +^Z^Zbreakpoints-headers +@var{header-entry} +^Z^Zbreakpoints-table +@end smallexample + +@noindent +where @var{header-entry} has the same syntax as an entry (see below) but +instead of containing data, it contains strings which are intended to +convey the meaning of each field to the user. This is followed by any +number of entries. If a field does not apply for this entry, it is +omitted. Fields may contain trailing whitespace. Each entry consists +of: + +@findex record +@findex field +@smallexample +^Z^Zrecord +^Z^Zfield 0 +@var{number} +^Z^Zfield 1 +@var{type} +^Z^Zfield 2 +@var{disposition} +^Z^Zfield 3 +@var{enable} +^Z^Zfield 4 +@var{address} +^Z^Zfield 5 +@var{what} +^Z^Zfield 6 +@var{frame} +^Z^Zfield 7 +@var{condition} +^Z^Zfield 8 +@var{ignore-count} +^Z^Zfield 9 +@var{commands} +@end smallexample + +Note that @var{address} is intended for user consumption---the syntax +varies depending on the language. + +The output ends with + +@findex breakpoints-table-end +@smallexample +^Z^Zbreakpoints-table-end +@end smallexample + +@node Invalidation +@section Invalidation Notices + +@cindex annotations for invalidation messages +The following annotations say that certain pieces of state may have +changed. + +@table @code +@findex frames-invalid +@item ^Z^Zframes-invalid + +The frames (for example, output from the @code{backtrace} command) may +have changed. + +@findex breakpoints-invalid +@item ^Z^Zbreakpoints-invalid + +The breakpoints may have changed. For example, the user just added or +deleted a breakpoint. +@end table + +@node Annotations for Running +@section Running the Program +@cindex annotations for running programs + +@findex starting +@findex stopping +When the program starts executing due to a @value{GDBN} command such as +@code{step} or @code{continue}, + +@smallexample +^Z^Zstarting +@end smallexample + +is output. When the program stops, + +@smallexample +^Z^Zstopped +@end smallexample + +is output. Before the @code{stopped} annotation, a variety of +annotations describe how the program stopped. + +@table @code +@findex exited +@item ^Z^Zexited @var{exit-status} +The program exited, and @var{exit-status} is the exit status (zero for +successful exit, otherwise nonzero). + +@findex signalled +@findex signal-name +@findex signal-name-end +@findex signal-string +@findex signal-string-end +@item ^Z^Zsignalled +The program exited with a signal. After the @code{^Z^Zsignalled}, the +annotation continues: + +@smallexample +@var{intro-text} +^Z^Zsignal-name +@var{name} +^Z^Zsignal-name-end +@var{middle-text} +^Z^Zsignal-string +@var{string} +^Z^Zsignal-string-end +@var{end-text} +@end smallexample + +@noindent +where @var{name} is the name of the signal, such as @code{SIGILL} or +@code{SIGSEGV}, and @var{string} is the explanation of the signal, such +as @code{Illegal Instruction} or @code{Segmentation fault}. +@var{intro-text}, @var{middle-text}, and @var{end-text} are for the +user's benefit and have no particular format. + +@findex signal +@item ^Z^Zsignal +The syntax of this annotation is just like @code{signalled}, but @value{GDBN} is +just saying that the program received the signal, not that it was +terminated with it. + +@findex breakpoint +@item ^Z^Zbreakpoint @var{number} +The program hit breakpoint number @var{number}. + +@findex watchpoint +@item ^Z^Zwatchpoint @var{number} +The program hit watchpoint number @var{number}. +@end table + +@node Source Annotations +@section Displaying Source +@cindex annotations for source display + +@findex source +The following annotation is used instead of displaying source code: + +@smallexample +^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr} +@end smallexample + +where @var{filename} is an absolute file name indicating which source +file, @var{line} is the line number within that file (where 1 is the +first line in the file), @var{character} is the character position +within the file (where 0 is the first character in the file) (for most +debug formats this will necessarily point to the beginning of a line), +@var{middle} is @samp{middle} if @var{addr} is in the middle of the +line, or @samp{beg} if @var{addr} is at the beginning of the line, and +@var{addr} is the address in the target program associated with the +source which is being displayed. @var{addr} is in the form @samp{0x} +followed by one or more lowercase hex digits (note that this does not +depend on the language). + +@node TODO +@section Annotations We Might Want in the Future + +@format + - target-invalid + the target might have changed (registers, heap contents, or + execution status). For performance, we might eventually want + to hit `registers-invalid' and `all-registers-invalid' with + greater precision + + - systematic annotation for set/show parameters (including + invalidation notices). + + - similarly, `info' returns a list of candidates for invalidation + notices. +@end format + +@node GDB Bugs +@chapter Reporting Bugs in @value{GDBN} +@cindex bugs in @value{GDBN} +@cindex reporting bugs in @value{GDBN} + +Your bug reports play an essential role in making @value{GDBN} reliable. + +Reporting a bug may help you by bringing a solution to your problem, or it +may not. But in any case the principal function of a bug report is to help +the entire community by making the next version of @value{GDBN} work better. Bug +reports are your contribution to the maintenance of @value{GDBN}. + +In order for a bug report to serve its purpose, you must include the +information that enables us to fix the bug. + +@menu +* Bug Criteria:: Have you found a bug? +* Bug Reporting:: How to report bugs +@end menu + +@node Bug Criteria +@section Have you found a bug? +@cindex bug criteria + +If you are not sure whether you have found a bug, here are some guidelines: + +@itemize @bullet +@cindex fatal signal +@cindex debugger crash +@cindex crash of debugger +@item +If the debugger gets a fatal signal, for any input whatever, that is a +@value{GDBN} bug. Reliable debuggers never crash. + +@cindex error on valid input +@item +If @value{GDBN} produces an error message for valid input, that is a +bug. (Note that if you're cross debugging, the problem may also be +somewhere in the connection to the target.) + +@cindex invalid input +@item +If @value{GDBN} does not produce an error message for invalid input, +that is a bug. However, you should note that your idea of +``invalid input'' might be our idea of ``an extension'' or ``support +for traditional practice''. + +@item +If you are an experienced user of debugging tools, your suggestions +for improvement of @value{GDBN} are welcome in any case. +@end itemize + +@node Bug Reporting +@section How to report bugs +@cindex bug reports +@cindex @value{GDBN} bugs, reporting + +A number of companies and individuals offer support for @sc{gnu} products. +If you obtained @value{GDBN} from a support organization, we recommend you +contact that organization first. + +You can find contact information for many support companies and +individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs +distribution. +@c should add a web page ref... + +In any event, we also recommend that you submit bug reports for +@value{GDBN}. The prefered method is to submit them directly using +@uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web +page}. Alternatively, the @email{bug-gdb@@gnu.org, e-mail gateway} can +be used. + +@strong{Do not send bug reports to @samp{info-gdb}, or to +@samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do +not want to receive bug reports. Those that do have arranged to receive +@samp{bug-gdb}. + +The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which +serves as a repeater. The mailing list and the newsgroup carry exactly +the same messages. Often people think of posting bug reports to the +newsgroup instead of mailing them. This appears to work, but it has one +problem which can be crucial: a newsgroup posting often lacks a mail +path back to the sender. Thus, if we need to ask for more information, +we may be unable to reach you. For this reason, it is better to send +bug reports to the mailing list. + +The fundamental principle of reporting bugs usefully is this: +@strong{report all the facts}. If you are not sure whether to state a +fact or leave it out, state it! + +Often people omit facts because they think they know what causes the +problem and assume that some details do not matter. Thus, you might +assume that the name of the variable you use in an example does not matter. +Well, probably it does not, but one cannot be sure. Perhaps the bug is a +stray memory reference which happens to fetch from the location where that +name is stored in memory; perhaps, if the name were different, the contents +of that location would fool the debugger into doing the right thing despite +the bug. Play it safe and give a specific, complete example. That is the +easiest thing for you to do, and the most helpful. + +Keep in mind that the purpose of a bug report is to enable us to fix the +bug. It may be that the bug has been reported previously, but neither +you nor we can know that unless your bug report is complete and +self-contained. + +Sometimes people give a few sketchy facts and ask, ``Does this ring a +bell?'' Those bug reports are useless, and we urge everyone to +@emph{refuse to respond to them} except to chide the sender to report +bugs properly. + +To enable us to fix the bug, you should include all these things: + +@itemize @bullet +@item +The version of @value{GDBN}. @value{GDBN} announces it if you start +with no arguments; you can also print it at any time using @code{show +version}. + +Without this, we will not know whether there is any point in looking for +the bug in the current version of @value{GDBN}. + +@item +The type of machine you are using, and the operating system name and +version number. + +@item +What compiler (and its version) was used to compile @value{GDBN}---e.g. +``@value{GCC}--2.8.1''. + +@item +What compiler (and its version) was used to compile the program you are +debugging---e.g. ``@value{GCC}--2.8.1'', or ``HP92453-01 A.10.32.03 HP +C Compiler''. For GCC, you can say @code{gcc --version} to get this +information; for other compilers, see the documentation for those +compilers. + +@item +The command arguments you gave the compiler to compile your example and +observe the bug. For example, did you use @samp{-O}? To guarantee +you will not omit something important, list them all. A copy of the +Makefile (or the output from make) is sufficient. + +If we were to try to guess the arguments, we would probably guess wrong +and then we might not encounter the bug. + +@item +A complete input script, and all necessary source files, that will +reproduce the bug. + +@item +A description of what behavior you observe that you believe is +incorrect. For example, ``It gets a fatal signal.'' + +Of course, if the bug is that @value{GDBN} gets a fatal signal, then we +will certainly notice it. But if the bug is incorrect output, we might +not notice unless it is glaringly wrong. You might as well not give us +a chance to make a mistake. + +Even if the problem you experience is a fatal signal, you should still +say so explicitly. Suppose something strange is going on, such as, your +copy of @value{GDBN} is out of synch, or you have encountered a bug in +the C library on your system. (This has happened!) Your copy might +crash and ours would not. If you told us to expect a crash, then when +ours fails to crash, we would know that the bug was not happening for +us. If you had not told us to expect a crash, then we would not be able +to draw any conclusion from our observations. + +@item +If you wish to suggest changes to the @value{GDBN} source, send us context +diffs. If you even discuss something in the @value{GDBN} source, refer to +it by context, not by line number. + +The line numbers in our development sources will not match those in your +sources. Your line numbers would convey no useful information to us. + +@end itemize + +Here are some things that are not necessary: + +@itemize @bullet +@item +A description of the envelope of the bug. + +Often people who encounter a bug spend a lot of time investigating +which changes to the input file will make the bug go away and which +changes will not affect it. + +This is often time consuming and not very useful, because the way we +will find the bug is by running a single example under the debugger +with breakpoints, not by pure deduction from a series of examples. +We recommend that you save your time for something else. + +Of course, if you can find a simpler example to report @emph{instead} +of the original one, that is a convenience for us. Errors in the +output will be easier to spot, running under the debugger will take +less time, and so on. + +However, simplification is not vital; if you do not want to do this, +report the bug anyway and send us the entire test case you used. + +@item +A patch for the bug. + +A patch for the bug does help us if it is a good one. But do not omit +the necessary information, such as the test case, on the assumption that +a patch is all we need. We might see problems with your patch and decide +to fix the problem another way, or we might not understand it at all. + +Sometimes with a program as complicated as @value{GDBN} it is very hard to +construct an example that will make the program follow a certain path +through the code. If you do not send us the example, we will not be able +to construct one, so we will not be able to verify that the bug is fixed. + +And if we cannot understand what bug you are trying to fix, or why your +patch should be an improvement, we will not install it. A test case will +help us to understand. + +@item +A guess about what the bug is or what it depends on. + +Such guesses are usually wrong. Even we cannot guess right about such +things without first using the debugger to find the facts. +@end itemize + +@c The readline documentation is distributed with the readline code +@c and consists of the two following files: +@c rluser.texinfo +@c inc-hist.texinfo +@c Use -I with makeinfo to point to the appropriate directory, +@c environment var TEXINPUTS with TeX. +@include rluser.texinfo +@include inc-hist.texinfo + + +@node Formatting Documentation +@appendix Formatting Documentation + +@cindex @value{GDBN} reference card +@cindex reference card +The @value{GDBN} 4 release includes an already-formatted reference card, ready +for printing with PostScript or Ghostscript, in the @file{gdb} +subdirectory of the main source directory@footnote{In +@file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN} +release.}. If you can use PostScript or Ghostscript with your printer, +you can print the reference card immediately with @file{refcard.ps}. + +The release also includes the source for the reference card. You +can format it, using @TeX{}, by typing: + +@smallexample +make refcard.dvi +@end smallexample + +The @value{GDBN} reference card is designed to print in @dfn{landscape} +mode on US ``letter'' size paper; +that is, on a sheet 11 inches wide by 8.5 inches +high. You will need to specify this form of printing as an option to +your @sc{dvi} output program. + +@cindex documentation + +All the documentation for @value{GDBN} comes as part of the machine-readable +distribution. The documentation is written in Texinfo format, which is +a documentation system that uses a single source file to produce both +on-line information and a printed manual. You can use one of the Info +formatting commands to create the on-line version of the documentation +and @TeX{} (or @code{texi2roff}) to typeset the printed version. + +@value{GDBN} includes an already formatted copy of the on-line Info +version of this manual in the @file{gdb} subdirectory. The main Info +file is @file{gdb-@value{GDBVN}/gdb/gdb.info}, and it refers to +subordinate files matching @samp{gdb.info*} in the same directory. If +necessary, you can print out these files, or read them with any editor; +but they are easier to read using the @code{info} subsystem in @sc{gnu} +Emacs or the standalone @code{info} program, available as part of the +@sc{gnu} Texinfo distribution. + +If you want to format these Info files yourself, you need one of the +Info formatting programs, such as @code{texinfo-format-buffer} or +@code{makeinfo}. + +If you have @code{makeinfo} installed, and are in the top level +@value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of +version @value{GDBVN}), you can make the Info file by typing: + +@smallexample +cd gdb +make gdb.info +@end smallexample + +If you want to typeset and print copies of this manual, you need @TeX{}, +a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the +Texinfo definitions file. + +@TeX{} is a typesetting program; it does not print files directly, but +produces output files called @sc{dvi} files. To print a typeset +document, you need a program to print @sc{dvi} files. If your system +has @TeX{} installed, chances are it has such a program. The precise +command to use depends on your system; @kbd{lpr -d} is common; another +(for PostScript devices) is @kbd{dvips}. The @sc{dvi} print command may +require a file name without any extension or a @samp{.dvi} extension. + +@TeX{} also requires a macro definitions file called +@file{texinfo.tex}. This file tells @TeX{} how to typeset a document +written in Texinfo format. On its own, @TeX{} cannot either read or +typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB +and is located in the @file{gdb-@var{version-number}/texinfo} +directory. + +If you have @TeX{} and a @sc{dvi} printer program installed, you can +typeset and print this manual. First switch to the the @file{gdb} +subdirectory of the main source directory (for example, to +@file{gdb-@value{GDBVN}/gdb}) and type: + +@smallexample +make gdb.dvi +@end smallexample + +Then give @file{gdb.dvi} to your @sc{dvi} printing program. + +@node Installing GDB +@appendix Installing @value{GDBN} +@cindex configuring @value{GDBN} +@cindex installation +@cindex configuring @value{GDBN}, and source tree subdirectories + +@value{GDBN} comes with a @code{configure} script that automates the process +of preparing @value{GDBN} for installation; you can then use @code{make} to +build the @code{gdb} program. +@iftex +@c irrelevant in info file; it's as current as the code it lives with. +@footnote{If you have a more recent version of @value{GDBN} than @value{GDBVN}, +look at the @file{README} file in the sources; we may have improved the +installation procedures since publishing this manual.} +@end iftex + +The @value{GDBN} distribution includes all the source code you need for +@value{GDBN} in a single directory, whose name is usually composed by +appending the version number to @samp{gdb}. + +For example, the @value{GDBN} version @value{GDBVN} distribution is in the +@file{gdb-@value{GDBVN}} directory. That directory contains: + +@table @code +@item gdb-@value{GDBVN}/configure @r{(and supporting files)} +script for configuring @value{GDBN} and all its supporting libraries + +@item gdb-@value{GDBVN}/gdb +the source specific to @value{GDBN} itself + +@item gdb-@value{GDBVN}/bfd +source for the Binary File Descriptor library + +@item gdb-@value{GDBVN}/include +@sc{gnu} include files + +@item gdb-@value{GDBVN}/libiberty +source for the @samp{-liberty} free software library + +@item gdb-@value{GDBVN}/opcodes +source for the library of opcode tables and disassemblers + +@item gdb-@value{GDBVN}/readline +source for the @sc{gnu} command-line interface + +@item gdb-@value{GDBVN}/glob +source for the @sc{gnu} filename pattern-matching subroutine + +@item gdb-@value{GDBVN}/mmalloc +source for the @sc{gnu} memory-mapped malloc package +@end table + +The simplest way to configure and build @value{GDBN} is to run @code{configure} +from the @file{gdb-@var{version-number}} source directory, which in +this example is the @file{gdb-@value{GDBVN}} directory. + +First switch to the @file{gdb-@var{version-number}} source directory +if you are not already in it; then run @code{configure}. Pass the +identifier for the platform on which @value{GDBN} will run as an +argument. + +For example: + +@smallexample +cd gdb-@value{GDBVN} +./configure @var{host} +make +@end smallexample + +@noindent +where @var{host} is an identifier such as @samp{sun4} or +@samp{decstation}, that identifies the platform where @value{GDBN} will run. +(You can often leave off @var{host}; @code{configure} tries to guess the +correct value by examining your system.) + +Running @samp{configure @var{host}} and then running @code{make} builds the +@file{bfd}, @file{readline}, @file{mmalloc}, and @file{libiberty} +libraries, then @code{gdb} itself. The configured source files, and the +binaries, are left in the corresponding source directories. + +@need 750 +@code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your +system does not recognize this automatically when you run a different +shell, you may need to run @code{sh} on it explicitly: + +@smallexample +sh configure @var{host} +@end smallexample + +If you run @code{configure} from a directory that contains source +directories for multiple libraries or programs, such as the +@file{gdb-@value{GDBVN}} source directory for version @value{GDBVN}, @code{configure} +creates configuration files for every directory level underneath (unless +you tell it not to, with the @samp{--norecursion} option). + +You should run the @code{configure} script from the top directory in the +source tree, the @file{gdb-@var{version-number}} directory. If you run +@code{configure} from one of the subdirectories, you will configure only +that subdirectory. That is usually not what you want. In particular, +if you run the first @code{configure} from the @file{gdb} subdirectory +of the @file{gdb-@var{version-number}} directory, you will omit the +configuration of @file{bfd}, @file{readline}, and other sibling +directories of the @file{gdb} subdirectory. This leads to build errors +about missing include files such as @file{bfd/bfd.h}. + +You can install @code{@value{GDBP}} anywhere; it has no hardwired paths. +However, you should make sure that the shell on your path (named by +the @samp{SHELL} environment variable) is publicly readable. Remember +that @value{GDBN} uses the shell to start your program---some systems refuse to +let @value{GDBN} debug child processes whose programs are not readable. + +@menu +* Separate Objdir:: Compiling @value{GDBN} in another directory +* Config Names:: Specifying names for hosts and targets +* Configure Options:: Summary of options for configure +@end menu + +@node Separate Objdir +@section Compiling @value{GDBN} in another directory + +If you want to run @value{GDBN} versions for several host or target machines, +you need a different @code{gdb} compiled for each combination of +host and target. @code{configure} is designed to make this easy by +allowing you to generate each configuration in a separate subdirectory, +rather than in the source directory. If your @code{make} program +handles the @samp{VPATH} feature (@sc{gnu} @code{make} does), running +@code{make} in each of these directories builds the @code{gdb} +program specified there. + +To build @code{gdb} in a separate directory, run @code{configure} +with the @samp{--srcdir} option to specify where to find the source. +(You also need to specify a path to find @code{configure} +itself from your working directory. If the path to @code{configure} +would be the same as the argument to @samp{--srcdir}, you can leave out +the @samp{--srcdir} option; it is assumed.) + +For example, with version @value{GDBVN}, you can build @value{GDBN} in a +separate directory for a Sun 4 like this: + +@smallexample +@group +cd gdb-@value{GDBVN} +mkdir ../gdb-sun4 +cd ../gdb-sun4 +../gdb-@value{GDBVN}/configure sun4 +make +@end group +@end smallexample + +When @code{configure} builds a configuration using a remote source +directory, it creates a tree for the binaries with the same structure +(and using the same names) as the tree under the source directory. In +the example, you'd find the Sun 4 library @file{libiberty.a} in the +directory @file{gdb-sun4/libiberty}, and @value{GDBN} itself in +@file{gdb-sun4/gdb}. + +Make sure that your path to the @file{configure} script has just one +instance of @file{gdb} in it. If your path to @file{configure} looks +like @file{../gdb-@value{GDBVN}/gdb/configure}, you are configuring only +one subdirectory of @value{GDBN}, not the whole package. This leads to +build errors about missing include files such as @file{bfd/bfd.h}. + +One popular reason to build several @value{GDBN} configurations in separate +directories is to configure @value{GDBN} for cross-compiling (where +@value{GDBN} runs on one machine---the @dfn{host}---while debugging +programs that run on another machine---the @dfn{target}). +You specify a cross-debugging target by +giving the @samp{--target=@var{target}} option to @code{configure}. + +When you run @code{make} to build a program or library, you must run +it in a configured directory---whatever directory you were in when you +called @code{configure} (or one of its subdirectories). + +The @code{Makefile} that @code{configure} generates in each source +directory also runs recursively. If you type @code{make} in a source +directory such as @file{gdb-@value{GDBVN}} (or in a separate configured +directory configured with @samp{--srcdir=@var{dirname}/gdb-@value{GDBVN}}), you +will build all the required libraries, and then build GDB. + +When you have multiple hosts or targets configured in separate +directories, you can run @code{make} on them in parallel (for example, +if they are NFS-mounted on each of the hosts); they will not interfere +with each other. + +@node Config Names +@section Specifying names for hosts and targets + +The specifications used for hosts and targets in the @code{configure} +script are based on a three-part naming scheme, but some short predefined +aliases are also supported. The full naming scheme encodes three pieces +of information in the following pattern: + +@smallexample +@var{architecture}-@var{vendor}-@var{os} +@end smallexample + +For example, you can use the alias @code{sun4} as a @var{host} argument, +or as the value for @var{target} in a @code{--target=@var{target}} +option. The equivalent full name is @samp{sparc-sun-sunos4}. + +The @code{configure} script accompanying @value{GDBN} does not provide +any query facility to list all supported host and target names or +aliases. @code{configure} calls the Bourne shell script +@code{config.sub} to map abbreviations to full names; you can read the +script, if you wish, or you can use it to test your guesses on +abbreviations---for example: + +@smallexample +% sh config.sub i386-linux +i386-pc-linux-gnu +% sh config.sub alpha-linux +alpha-unknown-linux-gnu +% sh config.sub hp9k700 +hppa1.1-hp-hpux +% sh config.sub sun4 +sparc-sun-sunos4.1.1 +% sh config.sub sun3 +m68k-sun-sunos4.1.1 +% sh config.sub i986v +Invalid configuration `i986v': machine `i986v' not recognized +@end smallexample + +@noindent +@code{config.sub} is also distributed in the @value{GDBN} source +directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}). + +@node Configure Options +@section @code{configure} options + +Here is a summary of the @code{configure} options and arguments that +are most often useful for building @value{GDBN}. @code{configure} also has +several other options not listed here. @inforef{What Configure +Does,,configure.info}, for a full explanation of @code{configure}. + +@smallexample +configure @r{[}--help@r{]} + @r{[}--prefix=@var{dir}@r{]} + @r{[}--exec-prefix=@var{dir}@r{]} + @r{[}--srcdir=@var{dirname}@r{]} + @r{[}--norecursion@r{]} @r{[}--rm@r{]} + @r{[}--target=@var{target}@r{]} + @var{host} +@end smallexample + +@noindent +You may introduce options with a single @samp{-} rather than +@samp{--} if you prefer; but you may abbreviate option names if you use +@samp{--}. + +@table @code +@item --help +Display a quick summary of how to invoke @code{configure}. + +@item --prefix=@var{dir} +Configure the source to install programs and files under directory +@file{@var{dir}}. + +@item --exec-prefix=@var{dir} +Configure the source to install programs under directory +@file{@var{dir}}. + +@c avoid splitting the warning from the explanation: +@need 2000 +@item --srcdir=@var{dirname} +@strong{Warning: using this option requires @sc{gnu} @code{make}, or another +@code{make} that implements the @code{VPATH} feature.}@* +Use this option to make configurations in directories separate from the +@value{GDBN} source directories. Among other things, you can use this to +build (or maintain) several configurations simultaneously, in separate +directories. @code{configure} writes configuration specific files in +the current directory, but arranges for them to use the source in the +directory @var{dirname}. @code{configure} creates directories under +the working directory in parallel to the source directories below +@var{dirname}. + +@item --norecursion +Configure only the directory level where @code{configure} is executed; do not +propagate configuration to subdirectories. + +@item --target=@var{target} +Configure @value{GDBN} for cross-debugging programs running on the specified +@var{target}. Without this option, @value{GDBN} is configured to debug +programs that run on the same machine (@var{host}) as @value{GDBN} itself. + +There is no convenient way to generate a list of all available targets. + +@item @var{host} @dots{} +Configure @value{GDBN} to run on the specified @var{host}. + +There is no convenient way to generate a list of all available hosts. +@end table + +There are many other options available as well, but they are generally +needed for special purposes only. + +@node Maintenance Commands +@appendix Maintenance Commands +@cindex maintenance commands +@cindex internal commands + +In addition to commands intended for @value{GDBN} users, @value{GDBN} +includes a number of commands intended for @value{GDBN} developers. +These commands are provided here for reference. + +@table @code +@kindex maint info breakpoints +@item @anchor{maint info breakpoints}maint info breakpoints +Using the same format as @samp{info breakpoints}, display both the +breakpoints you've set explicitly, and those @value{GDBN} is using for +internal purposes. Internal breakpoints are shown with negative +breakpoint numbers. The type column identifies what kind of breakpoint +is shown: + +@table @code +@item breakpoint +Normal, explicitly set breakpoint. + +@item watchpoint +Normal, explicitly set watchpoint. + +@item longjmp +Internal breakpoint, used to handle correctly stepping through +@code{longjmp} calls. + +@item longjmp resume +Internal breakpoint at the target of a @code{longjmp}. + +@item until +Temporary internal breakpoint used by the @value{GDBN} @code{until} command. + +@item finish +Temporary internal breakpoint used by the @value{GDBN} @code{finish} command. + +@item shlib events +Shared library events. + +@end table + +@kindex maint internal-error +@kindex maint internal-warning +@item maint internal-error +@itemx maint internal-warning +Cause @value{GDBN} to call the internal function @code{internal_error} +or @code{internal_warning} and hence behave as though an internal error +or internal warning has been detected. In addition to reporting the +internal problem, these functions give the user the opportunity to +either quit @value{GDBN} or create a core file of the current +@value{GDBN} session. + +@smallexample +(gdb) @kbd{maint internal-error testing, 1, 2} +@dots{}/maint.c:121: internal-error: testing, 1, 2 +A problem internal to GDB has been detected. Further +debugging may prove unreliable. +Quit this debugging session? (y or n) @kbd{n} +Create a core file? (y or n) @kbd{n} +(gdb) +@end smallexample + +Takes an optional parameter that is used as the text of the error or +warning message. + +@kindex maint print registers +@kindex maint print raw-registers +@kindex maint print cooked-registers +@kindex maint print register-groups +@item maint print registers +@itemx maint print raw-registers +@itemx maint print cooked-registers +@itemx maint print register-groups +Print @value{GDBN}'s internal register data structures. + +The command @code{maint print raw-registers} includes the contents of +the raw register cache; the command @code{maint print cooked-registers} +includes the (cooked) value of all registers; and the command +@code{maint print register-groups} includes the groups that each +register is a member of. @xref{Registers,, Registers, gdbint, +@value{GDBN} Internals}. + +Takes an optional file parameter. + +@kindex maint print reggroups +@item maint print reggroups +Print @value{GDBN}'s internal register group data structures. + +Takes an optional file parameter. + +@smallexample +(gdb) @kbd{maint print reggroups} + Group Type + general user + float user + all user + vector user + system user + save internal + restore internal +@end smallexample + +@kindex maint set profile +@kindex maint show profile +@cindex profiling GDB +@item maint set profile +@itemx maint show profile +Control profiling of @value{GDBN}. + +Profiling will be disabled until you use the @samp{maint set profile} +command to enable it. When you enable profiling, the system will begin +collecting timing and execution count data; when you disable profiling or +exit @value{GDBN}, the results will be written to a log file. Remember that +if you use profiling, @value{GDBN} will overwrite the profiling log file +(often called @file{gmon.out}). If you have a record of important profiling +data in a @file{gmon.out} file, be sure to move it to a safe location. + +Configuring with @samp{--enable-profiling} arranges for @value{GDBN} to be +compiled with the @samp{-pg} compiler option. + +@end table + + +@node Remote Protocol +@appendix @value{GDBN} Remote Serial Protocol + +@menu +* Overview:: +* Packets:: +* Stop Reply Packets:: +* General Query Packets:: +* Register Packet Format:: +* Examples:: +* File-I/O remote protocol extension:: +@end menu + +@node Overview +@section Overview + +There may be occasions when you need to know something about the +protocol---for example, if there is only one serial port to your target +machine, you might want your program to do something special if it +recognizes a packet meant for @value{GDBN}. + +In the examples below, @samp{->} and @samp{<-} are used to indicate +transmitted and received data respectfully. + +@cindex protocol, @value{GDBN} remote serial +@cindex serial protocol, @value{GDBN} remote +@cindex remote serial protocol +All @value{GDBN} commands and responses (other than acknowledgments) are +sent as a @var{packet}. A @var{packet} is introduced with the character +@samp{$}, the actual @var{packet-data}, and the terminating character +@samp{#} followed by a two-digit @var{checksum}: + +@smallexample +@code{$}@var{packet-data}@code{#}@var{checksum} +@end smallexample +@noindent + +@cindex checksum, for @value{GDBN} remote +@noindent +The two-digit @var{checksum} is computed as the modulo 256 sum of all +characters between the leading @samp{$} and the trailing @samp{#} (an +eight bit unsigned checksum). + +Implementors should note that prior to @value{GDBN} 5.0 the protocol +specification also included an optional two-digit @var{sequence-id}: + +@smallexample +@code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum} +@end smallexample + +@cindex sequence-id, for @value{GDBN} remote +@noindent +That @var{sequence-id} was appended to the acknowledgment. @value{GDBN} +has never output @var{sequence-id}s. Stubs that handle packets added +since @value{GDBN} 5.0 must not accept @var{sequence-id}. + +@cindex acknowledgment, for @value{GDBN} remote +When either the host or the target machine receives a packet, the first +response expected is an acknowledgment: either @samp{+} (to indicate +the package was received correctly) or @samp{-} (to request +retransmission): + +@smallexample +-> @code{$}@var{packet-data}@code{#}@var{checksum} +<- @code{+} +@end smallexample +@noindent + +The host (@value{GDBN}) sends @var{command}s, and the target (the +debugging stub incorporated in your program) sends a @var{response}. In +the case of step and continue @var{command}s, the response is only sent +when the operation has completed (the target has again stopped). + +@var{packet-data} consists of a sequence of characters with the +exception of @samp{#} and @samp{$} (see @samp{X} packet for additional +exceptions). + +Fields within the packet should be separated using @samp{,} @samp{;} or +@cindex remote protocol, field separator +@samp{:}. Except where otherwise noted all numbers are represented in +@sc{hex} with leading zeros suppressed. + +Implementors should note that prior to @value{GDBN} 5.0, the character +@samp{:} could not appear as the third character in a packet (as it +would potentially conflict with the @var{sequence-id}). + +Response @var{data} can be run-length encoded to save space. A @samp{*} +means that the next character is an @sc{ascii} encoding giving a repeat count +which stands for that many repetitions of the character preceding the +@samp{*}. The encoding is @code{n+29}, yielding a printable character +where @code{n >=3} (which is where rle starts to win). The printable +characters @samp{$}, @samp{#}, @samp{+} and @samp{-} or with a numeric +value greater than 126 should not be used. + +Some remote systems have used a different run-length encoding mechanism +loosely refered to as the cisco encoding. Following the @samp{*} +character are two hex digits that indicate the size of the packet. + +So: +@smallexample +"@code{0* }" +@end smallexample +@noindent +means the same as "0000". + +The error response returned for some packets includes a two character +error number. That number is not well defined. + +For any @var{command} not supported by the stub, an empty response +(@samp{$#00}) should be returned. That way it is possible to extend the +protocol. A newer @value{GDBN} can tell if a packet is supported based +on that response. + +A stub is required to support the @samp{g}, @samp{G}, @samp{m}, @samp{M}, +@samp{c}, and @samp{s} @var{command}s. All other @var{command}s are +optional. + +@node Packets +@section Packets + +The following table provides a complete list of all currently defined +@var{command}s and their corresponding response @var{data}. + +@table @r + +@item @code{!} --- extended mode +@cindex @code{!} packet + +Enable extended mode. In extended mode, the remote server is made +persistent. The @samp{R} packet is used to restart the program being +debugged. + +Reply: +@table @samp +@item OK +The remote target both supports and has enabled extended mode. +@end table + +@item @code{?} --- last signal +@cindex @code{?} packet + +Indicate the reason the target halted. The reply is the same as for +step and continue. + +Reply: +@xref{Stop Reply Packets}, for the reply specifications. + +@item @code{a} --- reserved + +Reserved for future use. + +@item @code{A}@var{arglen}@code{,}@var{argnum}@code{,}@var{arg}@code{,@dots{}} --- set program arguments @strong{(reserved)} +@cindex @code{A} packet + +Initialized @samp{argv[]} array passed into program. @var{arglen} +specifies the number of bytes in the hex encoded byte stream @var{arg}. +See @code{gdbserver} for more details. + +Reply: +@table @samp +@item OK +@item E@var{NN} +@end table + +@item @code{b}@var{baud} --- set baud @strong{(deprecated)} +@cindex @code{b} packet + +Change the serial line speed to @var{baud}. + +JTC: @emph{When does the transport layer state change? When it's +received, or after the ACK is transmitted. In either case, there are +problems if the command or the acknowledgment packet is dropped.} + +Stan: @emph{If people really wanted to add something like this, and get +it working for the first time, they ought to modify ser-unix.c to send +some kind of out-of-band message to a specially-setup stub and have the +switch happen "in between" packets, so that from remote protocol's point +of view, nothing actually happened.} + +@item @code{B}@var{addr},@var{mode} --- set breakpoint @strong{(deprecated)} +@cindex @code{B} packet + +Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a +breakpoint at @var{addr}. + +This packet has been replaced by the @samp{Z} and @samp{z} packets +(@pxref{insert breakpoint or watchpoint packet}). + +@item @code{c}@var{addr} --- continue +@cindex @code{c} packet + +@var{addr} is address to resume. If @var{addr} is omitted, resume at +current address. + +Reply: +@xref{Stop Reply Packets}, for the reply specifications. + +@item @code{C}@var{sig}@code{;}@var{addr} --- continue with signal +@cindex @code{C} packet + +Continue with signal @var{sig} (hex signal number). If +@code{;}@var{addr} is omitted, resume at same address. + +Reply: +@xref{Stop Reply Packets}, for the reply specifications. + +@item @code{d} --- toggle debug @strong{(deprecated)} +@cindex @code{d} packet + +Toggle debug flag. + +@item @code{D} --- detach +@cindex @code{D} packet + +Detach @value{GDBN} from the remote system. Sent to the remote target +before @value{GDBN} disconnects. + +Reply: +@table @samp +@item @emph{no response} +@value{GDBN} does not check for any response after sending this packet. +@end table + +@item @code{e} --- reserved + +Reserved for future use. + +@item @code{E} --- reserved + +Reserved for future use. + +@item @code{f} --- reserved + +Reserved for future use. + +@item @code{F}@var{RC}@code{,}@var{EE}@code{,}@var{CF}@code{;}@var{XX} --- Reply to target's F packet. +@cindex @code{F} packet + +This packet is send by @value{GDBN} as reply to a @code{F} request packet +sent by the target. This is part of the File-I/O protocol extension. +@xref{File-I/O remote protocol extension}, for the specification. + +@item @code{g} --- read registers +@anchor{read registers packet} +@cindex @code{g} packet + +Read general registers. + +Reply: +@table @samp +@item @var{XX@dots{}} +Each byte of register data is described by two hex digits. The bytes +with the register are transmitted in target byte order. The size of +each register and their position within the @samp{g} @var{packet} are +determined by the @value{GDBN} internal macros @var{REGISTER_RAW_SIZE} +and @var{REGISTER_NAME} macros. The specification of several standard +@code{g} packets is specified below. +@item E@var{NN} +for an error. +@end table + +@item @code{G}@var{XX@dots{}} --- write regs +@cindex @code{G} packet + +@xref{read registers packet}, for a description of the @var{XX@dots{}} +data. + +Reply: +@table @samp +@item OK +for success +@item E@var{NN} +for an error +@end table + +@item @code{h} --- reserved + +Reserved for future use. + +@item @code{H}@var{c}@var{t@dots{}} --- set thread +@cindex @code{H} packet + +Set thread for subsequent operations (@samp{m}, @samp{M}, @samp{g}, +@samp{G}, et.al.). @var{c} depends on the operation to be performed: it +should be @samp{c} for step and continue operations, @samp{g} for other +operations. The thread designator @var{t@dots{}} may be -1, meaning all +the threads, a thread number, or zero which means pick any thread. + +Reply: +@table @samp +@item OK +for success +@item E@var{NN} +for an error +@end table + +@c FIXME: JTC: +@c 'H': How restrictive (or permissive) is the thread model. If a +@c thread is selected and stopped, are other threads allowed +@c to continue to execute? As I mentioned above, I think the +@c semantics of each command when a thread is selected must be +@c described. For example: +@c +@c 'g': If the stub supports threads and a specific thread is +@c selected, returns the register block from that thread; +@c otherwise returns current registers. +@c +@c 'G' If the stub supports threads and a specific thread is +@c selected, sets the registers of the register block of +@c that thread; otherwise sets current registers. + +@item @code{i}@var{addr}@code{,}@var{nnn} --- cycle step @strong{(draft)} +@anchor{cycle step packet} +@cindex @code{i} packet + +Step the remote target by a single clock cycle. If @code{,}@var{nnn} is +present, cycle step @var{nnn} cycles. If @var{addr} is present, cycle +step starting at that address. + +@item @code{I} --- signal then cycle step @strong{(reserved)} +@cindex @code{I} packet + +@xref{step with signal packet}. @xref{cycle step packet}. + +@item @code{j} --- reserved + +Reserved for future use. + +@item @code{J} --- reserved + +Reserved for future use. + +@item @code{k} --- kill request +@cindex @code{k} packet + +FIXME: @emph{There is no description of how to operate when a specific +thread context has been selected (i.e.@: does 'k' kill only that +thread?)}. + +@item @code{K} --- reserved + +Reserved for future use. + +@item @code{l} --- reserved + +Reserved for future use. + +@item @code{L} --- reserved + +Reserved for future use. + +@item @code{m}@var{addr}@code{,}@var{length} --- read memory +@cindex @code{m} packet + +Read @var{length} bytes of memory starting at address @var{addr}. +Neither @value{GDBN} nor the stub assume that sized memory transfers are +assumed using word aligned accesses. FIXME: @emph{A word aligned memory +transfer mechanism is needed.} + +Reply: +@table @samp +@item @var{XX@dots{}} +@var{XX@dots{}} is mem contents. Can be fewer bytes than requested if able +to read only part of the data. Neither @value{GDBN} nor the stub assume +that sized memory transfers are assumed using word aligned +accesses. FIXME: @emph{A word aligned memory transfer mechanism is +needed.} +@item E@var{NN} +@var{NN} is errno +@end table + +@item @code{M}@var{addr},@var{length}@code{:}@var{XX@dots{}} --- write mem +@cindex @code{M} packet + +Write @var{length} bytes of memory starting at address @var{addr}. +@var{XX@dots{}} is the data. + +Reply: +@table @samp +@item OK +for success +@item E@var{NN} +for an error (this includes the case where only part of the data was +written). +@end table + +@item @code{n} --- reserved + +Reserved for future use. + +@item @code{N} --- reserved + +Reserved for future use. + +@item @code{o} --- reserved + +Reserved for future use. + +@item @code{O} --- reserved + +Reserved for future use. + +@item @code{p}@var{n@dots{}} --- read reg @strong{(reserved)} +@cindex @code{p} packet + +@xref{write register packet}. + +Reply: +@table @samp +@item @var{r@dots{}.} +The hex encoded value of the register in target byte order. +@end table + +@item @code{P}@var{n@dots{}}@code{=}@var{r@dots{}} --- write register +@anchor{write register packet} +@cindex @code{P} packet + +Write register @var{n@dots{}} with value @var{r@dots{}}, which contains two hex +digits for each byte in the register (target byte order). + +Reply: +@table @samp +@item OK +for success +@item E@var{NN} +for an error +@end table + +@item @code{q}@var{query} --- general query +@anchor{general query packet} +@cindex @code{q} packet + +Request info about @var{query}. In general @value{GDBN} queries have a +leading upper case letter. Custom vendor queries should use a company +prefix (in lower case) ex: @samp{qfsf.var}. @var{query} may optionally +be followed by a @samp{,} or @samp{;} separated list. Stubs must ensure +that they match the full @var{query} name. + +Reply: +@table @samp +@item @var{XX@dots{}} +Hex encoded data from query. The reply can not be empty. +@item E@var{NN} +error reply +@item +Indicating an unrecognized @var{query}. +@end table + +@item @code{Q}@var{var}@code{=}@var{val} --- general set +@cindex @code{Q} packet + +Set value of @var{var} to @var{val}. + +@xref{general query packet}, for a discussion of naming conventions. + +@item @code{r} --- reset @strong{(deprecated)} +@cindex @code{r} packet + +Reset the entire system. + +@item @code{R}@var{XX} --- remote restart +@cindex @code{R} packet + +Restart the program being debugged. @var{XX}, while needed, is ignored. +This packet is only available in extended mode. + +Reply: +@table @samp +@item @emph{no reply} +The @samp{R} packet has no reply. +@end table + +@item @code{s}@var{addr} --- step +@cindex @code{s} packet + +@var{addr} is address to resume. If @var{addr} is omitted, resume at +same address. + +Reply: +@xref{Stop Reply Packets}, for the reply specifications. + +@item @code{S}@var{sig}@code{;}@var{addr} --- step with signal +@anchor{step with signal packet} +@cindex @code{S} packet + +Like @samp{C} but step not continue. + +Reply: +@xref{Stop Reply Packets}, for the reply specifications. + +@item @code{t}@var{addr}@code{:}@var{PP}@code{,}@var{MM} --- search +@cindex @code{t} packet + +Search backwards starting at address @var{addr} for a match with pattern +@var{PP} and mask @var{MM}. @var{PP} and @var{MM} are 4 bytes. +@var{addr} must be at least 3 digits. + +@item @code{T}@var{XX} --- thread alive +@cindex @code{T} packet + +Find out if the thread XX is alive. + +Reply: +@table @samp +@item OK +thread is still alive +@item E@var{NN} +thread is dead +@end table + +@item @code{u} --- reserved + +Reserved for future use. + +@item @code{U} --- reserved + +Reserved for future use. + +@item @code{v} --- reserved + +Reserved for future use. + +@item @code{V} --- reserved + +Reserved for future use. + +@item @code{w} --- reserved + +Reserved for future use. + +@item @code{W} --- reserved + +Reserved for future use. + +@item @code{x} --- reserved + +Reserved for future use. + +@item @code{X}@var{addr}@code{,}@var{length}@var{:}@var{XX@dots{}} --- write mem (binary) +@cindex @code{X} packet + +@var{addr} is address, @var{length} is number of bytes, @var{XX@dots{}} +is binary data. The characters @code{$}, @code{#}, and @code{0x7d} are +escaped using @code{0x7d}. + +Reply: +@table @samp +@item OK +for success +@item E@var{NN} +for an error +@end table + +@item @code{y} --- reserved + +Reserved for future use. + +@item @code{Y} reserved + +Reserved for future use. + +@item @code{z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- remove breakpoint or watchpoint @strong{(draft)} +@itemx @code{Z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- insert breakpoint or watchpoint @strong{(draft)} +@anchor{insert breakpoint or watchpoint packet} +@cindex @code{z} packet +@cindex @code{Z} packets + +Insert (@code{Z}) or remove (@code{z}) a @var{type} breakpoint or +watchpoint starting at address @var{address} and covering the next +@var{length} bytes. + +Each breakpoint and watchpoint packet @var{type} is documented +separately. + +@emph{Implementation notes: A remote target shall return an empty string +for an unrecognized breakpoint or watchpoint packet @var{type}. A +remote target shall support either both or neither of a given +@code{Z}@var{type}@dots{} and @code{z}@var{type}@dots{} packet pair. To +avoid potential problems with duplicate packets, the operations should +be implemented in an idempotent way.} + +@item @code{z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- remove memory breakpoint @strong{(draft)} +@item @code{Z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- insert memory breakpoint @strong{(draft)} +@cindex @code{z0} packet +@cindex @code{Z0} packet + +Insert (@code{Z0}) or remove (@code{z0}) a memory breakpoint at address +@code{addr} of size @code{length}. + +A memory breakpoint is implemented by replacing the instruction at +@var{addr} with a software breakpoint or trap instruction. The +@code{length} is used by targets that indicates the size of the +breakpoint (in bytes) that should be inserted (e.g., the @sc{arm} and +@sc{mips} can insert either a 2 or 4 byte breakpoint). + +@emph{Implementation note: It is possible for a target to copy or move +code that contains memory breakpoints (e.g., when implementing +overlays). The behavior of this packet, in the presence of such a +target, is not defined.} + +Reply: +@table @samp +@item OK +success +@item +not supported +@item E@var{NN} +for an error +@end table + +@item @code{z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- remove hardware breakpoint @strong{(draft)} +@item @code{Z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- insert hardware breakpoint @strong{(draft)} +@cindex @code{z1} packet +@cindex @code{Z1} packet + +Insert (@code{Z1}) or remove (@code{z1}) a hardware breakpoint at +address @code{addr} of size @code{length}. + +A hardware breakpoint is implemented using a mechanism that is not +dependant on being able to modify the target's memory. + +@emph{Implementation note: A hardware breakpoint is not affected by code +movement.} + +Reply: +@table @samp +@item OK +success +@item +not supported +@item E@var{NN} +for an error +@end table + +@item @code{z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- remove write watchpoint @strong{(draft)} +@item @code{Z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- insert write watchpoint @strong{(draft)} +@cindex @code{z2} packet +@cindex @code{Z2} packet + +Insert (@code{Z2}) or remove (@code{z2}) a write watchpoint. + +Reply: +@table @samp +@item OK +success +@item +not supported +@item E@var{NN} +for an error +@end table + +@item @code{z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- remove read watchpoint @strong{(draft)} +@item @code{Z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- insert read watchpoint @strong{(draft)} +@cindex @code{z3} packet +@cindex @code{Z3} packet + +Insert (@code{Z3}) or remove (@code{z3}) a read watchpoint. + +Reply: +@table @samp +@item OK +success +@item +not supported +@item E@var{NN} +for an error +@end table + +@item @code{z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- remove access watchpoint @strong{(draft)} +@item @code{Z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- insert access watchpoint @strong{(draft)} +@cindex @code{z4} packet +@cindex @code{Z4} packet + +Insert (@code{Z4}) or remove (@code{z4}) an access watchpoint. + +Reply: +@table @samp +@item OK +success +@item +not supported +@item E@var{NN} +for an error +@end table + +@end table + +@node Stop Reply Packets +@section Stop Reply Packets +@cindex stop reply packets + +The @samp{C}, @samp{c}, @samp{S}, @samp{s} and @samp{?} packets can +receive any of the below as a reply. In the case of the @samp{C}, +@samp{c}, @samp{S} and @samp{s} packets, that reply is only returned +when the target halts. In the below the exact meaning of @samp{signal +number} is poorly defined. In general one of the UNIX signal numbering +conventions is used. + +@table @samp + +@item S@var{AA} +@var{AA} is the signal number + +@item @code{T}@var{AA}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;} +@cindex @code{T} packet reply + +@var{AA} = two hex digit signal number; @var{n...} = register number +(hex), @var{r...} = target byte ordered register contents, size defined +by @code{REGISTER_RAW_SIZE}; @var{n...} = @samp{thread}, @var{r...} = +thread process ID, this is a hex integer; @var{n...} = (@samp{watch} | +@samp{rwatch} | @samp{awatch}, @var{r...} = data address, this is a hex +integer; @var{n...} = other string not starting with valid hex digit. +@value{GDBN} should ignore this @var{n...}, @var{r...} pair and go on +to the next. This way we can extend the protocol. + +@item W@var{AA} + +The process exited, and @var{AA} is the exit status. This is only +applicable to certain targets. + +@item X@var{AA} + +The process terminated with signal @var{AA}. + +@item N@var{AA};@var{t@dots{}};@var{d@dots{}};@var{b@dots{}} @strong{(obsolete)} + +@var{AA} = signal number; @var{t@dots{}} = address of symbol +@code{_start}; @var{d@dots{}} = base of data section; @var{b@dots{}} = +base of bss section. @emph{Note: only used by Cisco Systems targets. +The difference between this reply and the @samp{qOffsets} query is that +the @samp{N} packet may arrive spontaneously whereas the @samp{qOffsets} +is a query initiated by the host debugger.} + +@item O@var{XX@dots{}} + +@var{XX@dots{}} is hex encoding of @sc{ascii} data. This can happen at +any time while the program is running and the debugger should continue +to wait for @samp{W}, @samp{T}, etc. + +@item F@var{call-id}@code{,}@var{parameter@dots{}} + +@var{call-id} is the identifier which says which host system call should +be called. This is just the name of the function. Translation into the +correct system call is only applicable as it's defined in @value{GDBN}. +@xref{File-I/O remote protocol extension}, for a list of implemented +system calls. + +@var{parameter@dots{}} is a list of parameters as defined for this very +system call. + +The target replies with this packet when it expects @value{GDBN} to call +a host system call on behalf of the target. @value{GDBN} replies with +an appropriate @code{F} packet and keeps up waiting for the next reply +packet from the target. The latest @samp{C}, @samp{c}, @samp{S} or +@samp{s} action is expected to be continued. +@xref{File-I/O remote protocol extension}, for more details. + +@end table + +@node General Query Packets +@section General Query Packets + +The following set and query packets have already been defined. + +@table @r + +@item @code{q}@code{C} --- current thread + +Return the current thread id. + +Reply: +@table @samp +@item @code{QC}@var{pid} +Where @var{pid} is a HEX encoded 16 bit process id. +@item * +Any other reply implies the old pid. +@end table + +@item @code{q}@code{fThreadInfo} -- all thread ids + +@code{q}@code{sThreadInfo} + +Obtain a list of active thread ids from the target (OS). Since there +may be too many active threads to fit into one reply packet, this query +works iteratively: it may require more than one query/reply sequence to +obtain the entire list of threads. The first query of the sequence will +be the @code{qf}@code{ThreadInfo} query; subsequent queries in the +sequence will be the @code{qs}@code{ThreadInfo} query. + +NOTE: replaces the @code{qL} query (see below). + +Reply: +@table @samp +@item @code{m}@var{id} +A single thread id +@item @code{m}@var{id},@var{id}@dots{} +a comma-separated list of thread ids +@item @code{l} +(lower case 'el') denotes end of list. +@end table + +In response to each query, the target will reply with a list of one or +more thread ids, in big-endian hex, separated by commas. @value{GDBN} +will respond to each reply with a request for more thread ids (using the +@code{qs} form of the query), until the target responds with @code{l} +(lower-case el, for @code{'last'}). + +@item @code{q}@code{ThreadExtraInfo}@code{,}@var{id} --- extra thread info + +Where @var{id} is a thread-id in big-endian hex. Obtain a printable +string description of a thread's attributes from the target OS. This +string may contain anything that the target OS thinks is interesting for +@value{GDBN} to tell the user about the thread. The string is displayed +in @value{GDBN}'s @samp{info threads} display. Some examples of +possible thread extra info strings are ``Runnable'', or ``Blocked on +Mutex''. + +Reply: +@table @samp +@item @var{XX@dots{}} +Where @var{XX@dots{}} is a hex encoding of @sc{ascii} data, comprising +the printable string containing the extra information about the thread's +attributes. +@end table + +@item @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread} --- query @var{LIST} or @var{threadLIST} @strong{(deprecated)} + +Obtain thread information from RTOS. Where: @var{startflag} (one hex +digit) is one to indicate the first query and zero to indicate a +subsequent query; @var{threadcount} (two hex digits) is the maximum +number of threads the response packet can contain; and @var{nextthread} +(eight hex digits), for subsequent queries (@var{startflag} is zero), is +returned in the response as @var{argthread}. + +NOTE: this query is replaced by the @code{q}@code{fThreadInfo} query +(see above). + +Reply: +@table @samp +@item @code{q}@code{M}@var{count}@var{done}@var{argthread}@var{thread@dots{}} +Where: @var{count} (two hex digits) is the number of threads being +returned; @var{done} (one hex digit) is zero to indicate more threads +and one indicates no further threads; @var{argthreadid} (eight hex +digits) is @var{nextthread} from the request packet; @var{thread@dots{}} +is a sequence of thread IDs from the target. @var{threadid} (eight hex +digits). See @code{remote.c:parse_threadlist_response()}. +@end table + +@item @code{q}@code{CRC:}@var{addr}@code{,}@var{length} --- compute CRC of memory block + +Reply: +@table @samp +@item @code{E}@var{NN} +An error (such as memory fault) +@item @code{C}@var{CRC32} +A 32 bit cyclic redundancy check of the specified memory region. +@end table + +@item @code{q}@code{Offsets} --- query sect offs + +Get section offsets that the target used when re-locating the downloaded +image. @emph{Note: while a @code{Bss} offset is included in the +response, @value{GDBN} ignores this and instead applies the @code{Data} +offset to the @code{Bss} section.} + +Reply: +@table @samp +@item @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz} +@end table + +@item @code{q}@code{P}@var{mode}@var{threadid} --- thread info request + +Returns information on @var{threadid}. Where: @var{mode} is a hex +encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID. + +Reply: +@table @samp +@item * +@end table + +See @code{remote.c:remote_unpack_thread_info_response()}. + +@item @code{q}@code{Rcmd,}@var{command} --- remote command + +@var{command} (hex encoded) is passed to the local interpreter for +execution. Invalid commands should be reported using the output string. +Before the final result packet, the target may also respond with a +number of intermediate @code{O}@var{output} console output packets. +@emph{Implementors should note that providing access to a stubs's +interpreter may have security implications}. + +Reply: +@table @samp +@item OK +A command response with no output. +@item @var{OUTPUT} +A command response with the hex encoded output string @var{OUTPUT}. +@item @code{E}@var{NN} +Indicate a badly formed request. +@item @samp{} +When @samp{q}@samp{Rcmd} is not recognized. +@end table + +@item @code{qSymbol::} --- symbol lookup + +Notify the target that @value{GDBN} is prepared to serve symbol lookup +requests. Accept requests from the target for the values of symbols. + +Reply: +@table @samp +@item @code{OK} +The target does not need to look up any (more) symbols. +@item @code{qSymbol:}@var{sym_name} +The target requests the value of symbol @var{sym_name} (hex encoded). +@value{GDBN} may provide the value by using the +@code{qSymbol:}@var{sym_value}:@var{sym_name} message, described below. +@end table + +@item @code{qSymbol:}@var{sym_value}:@var{sym_name} --- symbol value + +Set the value of @var{sym_name} to @var{sym_value}. + +@var{sym_name} (hex encoded) is the name of a symbol whose value the +target has previously requested. + +@var{sym_value} (hex) is the value for symbol @var{sym_name}. If +@value{GDBN} cannot supply a value for @var{sym_name}, then this field +will be empty. + +Reply: +@table @samp +@item @code{OK} +The target does not need to look up any (more) symbols. +@item @code{qSymbol:}@var{sym_name} +The target requests the value of a new symbol @var{sym_name} (hex +encoded). @value{GDBN} will continue to supply the values of symbols +(if available), until the target ceases to request them. +@end table + +@end table + +@node Register Packet Format +@section Register Packet Format + +The following @samp{g}/@samp{G} packets have previously been defined. +In the below, some thirty-two bit registers are transferred as +sixty-four bits. Those registers should be zero/sign extended (which?) +to fill the space allocated. Register bytes are transfered in target +byte order. The two nibbles within a register byte are transfered +most-significant - least-significant. + +@table @r + +@item MIPS32 + +All registers are transfered as thirty-two bit quantities in the order: +32 general-purpose; sr; lo; hi; bad; cause; pc; 32 floating-point +registers; fsr; fir; fp. + +@item MIPS64 + +All registers are transfered as sixty-four bit quantities (including +thirty-two bit registers such as @code{sr}). The ordering is the same +as @code{MIPS32}. + +@end table + +@node Examples +@section Examples + +Example sequence of a target being re-started. Notice how the restart +does not get any direct output: + +@smallexample +-> @code{R00} +<- @code{+} +@emph{target restarts} +-> @code{?} +<- @code{+} +<- @code{T001:1234123412341234} +-> @code{+} +@end smallexample + +Example sequence of a target being stepped by a single instruction: + +@smallexample +-> @code{G1445@dots{}} +<- @code{+} +-> @code{s} +<- @code{+} +@emph{time passes} +<- @code{T001:1234123412341234} +-> @code{+} +-> @code{g} +<- @code{+} +<- @code{1455@dots{}} +-> @code{+} +@end smallexample + +@node File-I/O remote protocol extension +@section File-I/O remote protocol extension +@cindex File-I/O remote protocol extension + +@menu +* File-I/O Overview:: +* Protocol basics:: +* The `F' request packet:: +* The `F' reply packet:: +* Memory transfer:: +* The Ctrl-C message:: +* Console I/O:: +* The isatty call:: +* The system call:: +* List of supported calls:: +* Protocol specific representation of datatypes:: +* Constants:: +* File-I/O Examples:: +@end menu + +@node File-I/O Overview +@subsection File-I/O Overview +@cindex file-i/o overview + +The File I/O remote protocol extension (short: File-I/O) allows the +target to use the hosts file system and console I/O when calling various +system calls. System calls on the target system are translated into a +remote protocol packet to the host system which then performs the needed +actions and returns with an adequate response packet to the target system. +This simulates file system operations even on targets that lack file systems. + +The protocol is defined host- and target-system independent. It uses +it's own independent representation of datatypes and values. Both, +@value{GDBN} and the target's @value{GDBN} stub are responsible for +translating the system dependent values into the unified protocol values +when data is transmitted. + +The communication is synchronous. A system call is possible only +when GDB is waiting for the @samp{C}, @samp{c}, @samp{S} or @samp{s} +packets. While @value{GDBN} handles the request for a system call, +the target is stopped to allow deterministic access to the target's +memory. Therefore File-I/O is not interuptible by target signals. It +is possible to interrupt File-I/O by a user interrupt (Ctrl-C), though. + +The target's request to perform a host system call does not finish +the latest @samp{C}, @samp{c}, @samp{S} or @samp{s} action. That means, +after finishing the system call, the target returns to continuing the +previous activity (continue, step). No additional continue or step +request from @value{GDBN} is required. + +@smallexample +(gdb) continue + <- target requests 'system call X' + target is stopped, @value{GDBN} executes system call + -> GDB returns result + ... target continues, GDB returns to wait for the target + <- target hits breakpoint and sends a Txx packet +@end smallexample + +The protocol is only used for files on the host file system and +for I/O on the console. Character or block special devices, pipes, +named pipes or sockets or any other communication method on the host +system are not supported by this protocol. + +@node Protocol basics +@subsection Protocol basics +@cindex protocol basics, file-i/o + +The File-I/O protocol uses the @code{F} packet, as request as well +as as reply packet. Since a File-I/O system call can only occur when +@value{GDBN} is waiting for the continuing or stepping target, the +File-I/O request is a reply that @value{GDBN} has to expect as a result +of a former @samp{C}, @samp{c}, @samp{S} or @samp{s} packet. +This @code{F} packet contains all information needed to allow @value{GDBN} +to call the appropriate host system call: + +@itemize @bullet +@item +A unique identifier for the requested system call. + +@item +All parameters to the system call. Pointers are given as addresses +in the target memory address space. Pointers to strings are given as +pointer/length pair. Numerical values are given as they are. +Numerical control values are given in a protocol specific representation. + +@end itemize + +At that point @value{GDBN} has to perform the following actions. + +@itemize @bullet +@item +If parameter pointer values are given, which point to data needed as input +to a system call, @value{GDBN} requests this data from the target with a +standard @code{m} packet request. This additional communication has to be +expected by the target implementation and is handled as any other @code{m} +packet. + +@item +@value{GDBN} translates all value from protocol representation to host +representation as needed. Datatypes are coerced into the host types. + +@item +@value{GDBN} calls the system call + +@item +It then coerces datatypes back to protocol representation. + +@item +If pointer parameters in the request packet point to buffer space in which +a system call is expected to copy data to, the data is transmitted to the +target using a @code{M} or @code{X} packet. This packet has to be expected +by the target implementation and is handled as any other @code{M} or @code{X} +packet. + +@end itemize + +Eventually @value{GDBN} replies with another @code{F} packet which contains all +necessary information for the target to continue. This at least contains + +@itemize @bullet +@item +Return value. + +@item +@code{errno}, if has been changed by the system call. + +@item +``Ctrl-C'' flag. + +@end itemize + +After having done the needed type and value coercion, the target continues +the latest continue or step action. + +@node The `F' request packet +@subsection The @code{F} request packet +@cindex file-i/o request packet +@cindex @code{F} request packet + +The @code{F} request packet has the following format: + +@table @samp -So: @smallexample -"@code{0* }" +@code{F}@var{call-id}@code{,}@var{parameter@dots{}} @end smallexample -@noindent -means the same as "0000". - -The error response returned for some packets includes a two character -error number. That number is not well defined. - -For any @var{command} not supported by the stub, an empty response -(@samp{$#00}) should be returned. That way it is possible to extend the -protocol. A newer @value{GDBN} can tell if a packet is supported based -on that response. -A stub is required to support the @samp{g}, @samp{G}, @samp{m}, @samp{M}, -@samp{c}, and @samp{s} @var{command}s. All other @var{command}s are -optional. +@var{call-id} is the identifier to indicate the host system call to be called. +This is just the name of the function. -@node Packets -@section Packets +@var{parameter@dots{}} are the parameters to the system call. -The following table provides a complete list of all currently defined -@var{command}s and their corresponding response @var{data}. +@end table -@table @r +Parameters are hexadecimal integer values, either the real values in case +of scalar datatypes, as pointers to target buffer space in case of compound +datatypes and unspecified memory areas or as pointer/length pairs in case +of string parameters. These are appended to the call-id, each separated +from its predecessor by a comma. All values are transmitted in ASCII +string representation, pointer/length pairs separated by a slash. -@item @code{!} --- extended mode -@cindex @code{!} packet +@node The `F' reply packet +@subsection The @code{F} reply packet +@cindex file-i/o reply packet +@cindex @code{F} reply packet -Enable extended mode. In extended mode, the remote server is made -persistent. The @samp{R} packet is used to restart the program being -debugged. +The @code{F} reply packet has the following format: -Reply: @table @samp -@item OK -The remote target both supports and has enabled extended mode. -@end table -@item @code{?} --- last signal -@cindex @code{?} packet +@smallexample +@code{F}@var{retcode}@code{,}@var{errno}@code{,}@var{Ctrl-C flag}@code{;}@var{call specific attachment} +@end smallexample -Indicate the reason the target halted. The reply is the same as for -step and continue. +@var{retcode} is the return code of the system call as hexadecimal value. -Reply: -@xref{Stop Reply Packets}, for the reply specifications. +@var{errno} is the errno set by the call, in protocol specific representation. +This parameter can be omitted if the call was successful. -@item @code{a} --- reserved +@var{Ctrl-C flag} is only send if the user requested a break. In this +case, @var{errno} must be send as well, even if the call was successful. +The @var{Ctrl-C flag} itself consists of the character 'C': -Reserved for future use. +@smallexample +F0,0,C +@end smallexample -@item @code{A}@var{arglen}@code{,}@var{argnum}@code{,}@var{arg}@code{,@dots{}} --- set program arguments @strong{(reserved)} -@cindex @code{A} packet +@noindent +or, if the call was interupted before the host call has been performed: -Initialized @samp{argv[]} array passed into program. @var{arglen} -specifies the number of bytes in the hex encoded byte stream @var{arg}. -See @code{gdbserver} for more details. +@smallexample +F-1,4,C +@end smallexample + +@noindent +assuming 4 is the protocol specific representation of @code{EINTR}. -Reply: -@table @samp -@item OK -@item E@var{NN} @end table -@item @code{b}@var{baud} --- set baud @strong{(deprecated)} -@cindex @code{b} packet +@node Memory transfer +@subsection Memory transfer +@cindex memory transfer, in file-i/o protocol + +Structured data which is transferred using a memory read or write as e.g.@: +a @code{struct stat} is expected to be in a protocol specific format with +all scalar multibyte datatypes being big endian. This should be done by +the target before the @code{F} packet is sent resp.@: by @value{GDBN} before +it transfers memory to the target. Transferred pointers to structured +data should point to the already coerced data at any time. + +@node The Ctrl-C message +@subsection The Ctrl-C message +@cindex ctrl-c message, in file-i/o protocol + +A special case is, if the @var{Ctrl-C flag} is set in the @value{GDBN} +reply packet. In this case the target should behave, as if it had +gotten a break message. The meaning for the target is ``system call +interupted by @code{SIGINT}''. Consequentially, the target should actually stop +(as with a break message) and return to @value{GDBN} with a @code{T02} +packet. In this case, it's important for the target to know, in which +state the system call was interrupted. Since this action is by design +not an atomic operation, we have to differ between two cases: -Change the serial line speed to @var{baud}. +@itemize @bullet +@item +The system call hasn't been performed on the host yet. -JTC: @emph{When does the transport layer state change? When it's -received, or after the ACK is transmitted. In either case, there are -problems if the command or the acknowledgment packet is dropped.} +@item +The system call on the host has been finished. -Stan: @emph{If people really wanted to add something like this, and get -it working for the first time, they ought to modify ser-unix.c to send -some kind of out-of-band message to a specially-setup stub and have the -switch happen "in between" packets, so that from remote protocol's point -of view, nothing actually happened.} +@end itemize -@item @code{B}@var{addr},@var{mode} --- set breakpoint @strong{(deprecated)} -@cindex @code{B} packet +These two states can be distinguished by the target by the value of the +returned @code{errno}. If it's the protocol representation of @code{EINTR}, the system +call hasn't been performed. This is equivalent to the @code{EINTR} handling +on POSIX systems. In any other case, the target may presume that the +system call has been finished --- successful or not --- and should behave +as if the break message arrived right after the system call. + +@value{GDBN} must behave reliable. If the system call has not been called +yet, @value{GDBN} may send the @code{F} reply immediately, setting @code{EINTR} as +@code{errno} in the packet. If the system call on the host has been finished +before the user requests a break, the full action must be finshed by +@value{GDBN}. This requires sending @code{M} or @code{X} packets as they fit. +The @code{F} packet may only be send when either nothing has happened +or the full action has been completed. + +@node Console I/O +@subsection Console I/O +@cindex console i/o as part of file-i/o + +By default and if not explicitely closed by the target system, the file +descriptors 0, 1 and 2 are connected to the @value{GDBN} console. Output +on the @value{GDBN} console is handled as any other file output operation +(@code{write(1, @dots{})} or @code{write(2, @dots{})}). Console input is handled +by @value{GDBN} so that after the target read request from file descriptor +0 all following typing is buffered until either one of the following +conditions is met: -Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a -breakpoint at @var{addr}. +@itemize @bullet +@item +The user presses @kbd{Ctrl-C}. The behaviour is as explained above, the +@code{read} +system call is treated as finished. -This packet has been replaced by the @samp{Z} and @samp{z} packets -(@pxref{insert breakpoint or watchpoint packet}). +@item +The user presses @kbd{Enter}. This is treated as end of input with a trailing +line feed. -@item @code{c}@var{addr} --- continue -@cindex @code{c} packet +@item +The user presses @kbd{Ctrl-D}. This is treated as end of input. No trailing +character, especially no Ctrl-D is appended to the input. -@var{addr} is address to resume. If @var{addr} is omitted, resume at -current address. +@end itemize -Reply: -@xref{Stop Reply Packets}, for the reply specifications. +If the user has typed more characters as fit in the buffer given to +the read call, the trailing characters are buffered in @value{GDBN} until +either another @code{read(0, @dots{})} is requested by the target or debugging +is stopped on users request. -@item @code{C}@var{sig}@code{;}@var{addr} --- continue with signal -@cindex @code{C} packet +@node The isatty call +@subsection The isatty(3) call +@cindex isatty call, file-i/o protocol -Continue with signal @var{sig} (hex signal number). If -@code{;}@var{addr} is omitted, resume at same address. +A special case in this protocol is the library call @code{isatty} which +is implemented as it's own call inside of this protocol. It returns +1 to the target if the file descriptor given as parameter is attached +to the @value{GDBN} console, 0 otherwise. Implementing through system calls +would require implementing @code{ioctl} and would be more complex than +needed. -Reply: -@xref{Stop Reply Packets}, for the reply specifications. +@node The system call +@subsection The system(3) call +@cindex system call, file-i/o protocol -@item @code{d} --- toggle debug @strong{(deprecated)} -@cindex @code{d} packet +The other special case in this protocol is the @code{system} call which +is implemented as it's own call, too. @value{GDBN} is taking over the full +task of calling the necessary host calls to perform the @code{system} +call. The return value of @code{system} is simplified before it's returned +to the target. Basically, the only signal transmitted back is @code{EINTR} +in case the user pressed @kbd{Ctrl-C}. Otherwise the return value consists +entirely of the exit status of the called command. -Toggle debug flag. +Due to security concerns, the @code{system} call is refused to be called +by @value{GDBN} by default. The user has to allow this call explicitly by +entering -@item @code{D} --- detach -@cindex @code{D} packet +@table @samp +@kindex set remote system-call-allowed 1 +@item @code{set remote system-call-allowed 1} +@end table -Detach @value{GDBN} from the remote system. Sent to the remote target -before @value{GDBN} disconnects. +Disabling the @code{system} call is done by -Reply: @table @samp -@item @emph{no response} -@value{GDBN} does not check for any response after sending this packet. +@kindex set remote system-call-allowed 0 +@item @code{set remote system-call-allowed 0} @end table -@item @code{e} --- reserved +The current setting is shown by typing -Reserved for future use. +@table @samp +@kindex show remote system-call-allowed +@item @code{show remote system-call-allowed} +@end table -@item @code{E} --- reserved +@node List of supported calls +@subsection List of supported calls +@cindex list of supported file-i/o calls -Reserved for future use. +@menu +* open:: +* close:: +* read:: +* write:: +* lseek:: +* rename:: +* unlink:: +* stat/fstat:: +* gettimeofday:: +* isatty:: +* system:: +@end menu -@item @code{f} --- reserved +@node open +@unnumberedsubsubsec open +@cindex open, file-i/o system call -Reserved for future use. +@smallexample +@exdent Synopsis: +int open(const char *pathname, int flags); +int open(const char *pathname, int flags, mode_t mode); -@item @code{F} --- reserved +@exdent Request: +Fopen,pathptr/len,flags,mode +@end smallexample -Reserved for future use. +@noindent +@code{flags} is the bitwise or of the following values: -@item @code{g} --- read registers -@anchor{read registers packet} -@cindex @code{g} packet +@table @code +@item O_CREAT +If the file does not exist it will be created. The host +rules apply as far as file ownership and time stamps +are concerned. -Read general registers. +@item O_EXCL +When used with O_CREAT, if the file already exists it is +an error and open() fails. -Reply: -@table @samp -@item @var{XX@dots{}} -Each byte of register data is described by two hex digits. The bytes -with the register are transmitted in target byte order. The size of -each register and their position within the @samp{g} @var{packet} are -determined by the @value{GDBN} internal macros @var{REGISTER_RAW_SIZE} -and @var{REGISTER_NAME} macros. The specification of several standard -@code{g} packets is specified below. -@item E@var{NN} -for an error. -@end table +@item O_TRUNC +If the file already exists and the open mode allows +writing (O_RDWR or O_WRONLY is given) it will be +truncated to length 0. -@item @code{G}@var{XX@dots{}} --- write regs -@cindex @code{G} packet +@item O_APPEND +The file is opened in append mode. -@xref{read registers packet}, for a description of the @var{XX@dots{}} -data. +@item O_RDONLY +The file is opened for reading only. + +@item O_WRONLY +The file is opened for writing only. + +@item O_RDWR +The file is opened for reading and writing. + +@noindent +Each other bit is silently ignored. -Reply: -@table @samp -@item OK -for success -@item E@var{NN} -for an error @end table -@item @code{h} --- reserved +@noindent +@code{mode} is the bitwise or of the following values: -Reserved for future use. +@table @code +@item S_IRUSR +User has read permission. -@item @code{H}@var{c}@var{t@dots{}} --- set thread -@cindex @code{H} packet +@item S_IWUSR +User has write permission. -Set thread for subsequent operations (@samp{m}, @samp{M}, @samp{g}, -@samp{G}, et.al.). @var{c} depends on the operation to be performed: it -should be @samp{c} for step and continue operations, @samp{g} for other -operations. The thread designator @var{t@dots{}} may be -1, meaning all -the threads, a thread number, or zero which means pick any thread. +@item S_IRGRP +Group has read permission. + +@item S_IWGRP +Group has write permission. + +@item S_IROTH +Others have read permission. + +@item S_IWOTH +Others have write permission. + +@noindent +Each other bit is silently ignored. -Reply: -@table @samp -@item OK -for success -@item E@var{NN} -for an error @end table -@c FIXME: JTC: -@c 'H': How restrictive (or permissive) is the thread model. If a -@c thread is selected and stopped, are other threads allowed -@c to continue to execute? As I mentioned above, I think the -@c semantics of each command when a thread is selected must be -@c described. For example: -@c -@c 'g': If the stub supports threads and a specific thread is -@c selected, returns the register block from that thread; -@c otherwise returns current registers. -@c -@c 'G' If the stub supports threads and a specific thread is -@c selected, sets the registers of the register block of -@c that thread; otherwise sets current registers. +@smallexample +@exdent Return value: +open returns the new file descriptor or -1 if an error +occured. -@item @code{i}@var{addr}@code{,}@var{nnn} --- cycle step @strong{(draft)} -@anchor{cycle step packet} -@cindex @code{i} packet +@exdent Errors: +@end smallexample -Step the remote target by a single clock cycle. If @code{,}@var{nnn} is -present, cycle step @var{nnn} cycles. If @var{addr} is present, cycle -step starting at that address. +@table @code +@item EEXIST +pathname already exists and O_CREAT and O_EXCL were used. -@item @code{I} --- signal then cycle step @strong{(reserved)} -@cindex @code{I} packet +@item EISDIR +pathname refers to a directory. -@xref{step with signal packet}. @xref{cycle step packet}. +@item EACCES +The requested access is not allowed. -@item @code{j} --- reserved +@item ENAMETOOLONG +pathname was too long. -Reserved for future use. +@item ENOENT +A directory component in pathname does not exist. -@item @code{J} --- reserved +@item ENODEV +pathname refers to a device, pipe, named pipe or socket. -Reserved for future use. +@item EROFS +pathname refers to a file on a read-only filesystem and +write access was requested. -@item @code{k} --- kill request -@cindex @code{k} packet +@item EFAULT +pathname is an invalid pointer value. -FIXME: @emph{There is no description of how to operate when a specific -thread context has been selected (i.e.@: does 'k' kill only that -thread?)}. +@item ENOSPC +No space on device to create the file. -@item @code{K} --- reserved +@item EMFILE +The process already has the maximum number of files open. -Reserved for future use. +@item ENFILE +The limit on the total number of files open on the system +has been reached. -@item @code{l} --- reserved +@item EINTR +The call was interrupted by the user. +@end table -Reserved for future use. +@node close +@unnumberedsubsubsec close +@cindex close, file-i/o system call -@item @code{L} --- reserved +@smallexample +@exdent Synopsis: +int close(int fd); -Reserved for future use. +@exdent Request: +Fclose,fd -@item @code{m}@var{addr}@code{,}@var{length} --- read memory -@cindex @code{m} packet +@exdent Return value: +close returns zero on success, or -1 if an error occurred. -Read @var{length} bytes of memory starting at address @var{addr}. -Neither @value{GDBN} nor the stub assume that sized memory transfers are -assumed using word aligned accesses. FIXME: @emph{A word aligned memory -transfer mechanism is needed.} +@exdent Errors: +@end smallexample -Reply: -@table @samp -@item @var{XX@dots{}} -@var{XX@dots{}} is mem contents. Can be fewer bytes than requested if able -to read only part of the data. Neither @value{GDBN} nor the stub assume -that sized memory transfers are assumed using word aligned -accesses. FIXME: @emph{A word aligned memory transfer mechanism is -needed.} -@item E@var{NN} -@var{NN} is errno +@table @code +@item EBADF +fd isn't a valid open file descriptor. + +@item EINTR +The call was interrupted by the user. @end table -@item @code{M}@var{addr},@var{length}@code{:}@var{XX@dots{}} --- write mem -@cindex @code{M} packet +@node read +@unnumberedsubsubsec read +@cindex read, file-i/o system call -Write @var{length} bytes of memory starting at address @var{addr}. -@var{XX@dots{}} is the data. +@smallexample +@exdent Synopsis: +int read(int fd, void *buf, unsigned int count); -Reply: -@table @samp -@item OK -for success -@item E@var{NN} -for an error (this includes the case where only part of the data was -written). -@end table +@exdent Request: +Fread,fd,bufptr,count + +@exdent Return value: +On success, the number of bytes read is returned. +Zero indicates end of file. If count is zero, read +returns zero as well. On error, -1 is returned. + +@exdent Errors: +@end smallexample + +@table @code +@item EBADF +fd is not a valid file descriptor or is not open for +reading. + +@item EFAULT +buf is an invalid pointer value. -@item @code{n} --- reserved +@item EINTR +The call was interrupted by the user. +@end table -Reserved for future use. +@node write +@unnumberedsubsubsec write +@cindex write, file-i/o system call -@item @code{N} --- reserved +@smallexample +@exdent Synopsis: +int write(int fd, const void *buf, unsigned int count); -Reserved for future use. +@exdent Request: +Fwrite,fd,bufptr,count -@item @code{o} --- reserved +@exdent Return value: +On success, the number of bytes written are returned. +Zero indicates nothing was written. On error, -1 +is returned. -Reserved for future use. +@exdent Errors: +@end smallexample -@item @code{O} --- reserved +@table @code +@item EBADF +fd is not a valid file descriptor or is not open for +writing. -Reserved for future use. +@item EFAULT +buf is an invalid pointer value. -@item @code{p}@var{n@dots{}} --- read reg @strong{(reserved)} -@cindex @code{p} packet +@item EFBIG +An attempt was made to write a file that exceeds the +host specific maximum file size allowed. -@xref{write register packet}. +@item ENOSPC +No space on device to write the data. -Reply: -@table @samp -@item @var{r@dots{}.} -The hex encoded value of the register in target byte order. +@item EINTR +The call was interrupted by the user. @end table -@item @code{P}@var{n@dots{}}@code{=}@var{r@dots{}} --- write register -@anchor{write register packet} -@cindex @code{P} packet +@node lseek +@unnumberedsubsubsec lseek +@cindex lseek, file-i/o system call -Write register @var{n@dots{}} with value @var{r@dots{}}, which contains two hex -digits for each byte in the register (target byte order). +@smallexample +@exdent Synopsis: +long lseek (int fd, long offset, int flag); -Reply: -@table @samp -@item OK -for success -@item E@var{NN} -for an error -@end table +@exdent Request: +Flseek,fd,offset,flag +@end smallexample -@item @code{q}@var{query} --- general query -@anchor{general query packet} -@cindex @code{q} packet +@code{flag} is one of: -Request info about @var{query}. In general @value{GDBN} queries have a -leading upper case letter. Custom vendor queries should use a company -prefix (in lower case) ex: @samp{qfsf.var}. @var{query} may optionally -be followed by a @samp{,} or @samp{;} separated list. Stubs must ensure -that they match the full @var{query} name. +@table @code +@item SEEK_SET +The offset is set to offset bytes. -Reply: -@table @samp -@item @var{XX@dots{}} -Hex encoded data from query. The reply can not be empty. -@item E@var{NN} -error reply -@item -Indicating an unrecognized @var{query}. +@item SEEK_CUR +The offset is set to its current location plus offset +bytes. + +@item SEEK_END +The offset is set to the size of the file plus offset +bytes. @end table -@item @code{Q}@var{var}@code{=}@var{val} --- general set -@cindex @code{Q} packet +@smallexample +@exdent Return value: +On success, the resulting unsigned offset in bytes from +the beginning of the file is returned. Otherwise, a +value of -1 is returned. -Set value of @var{var} to @var{val}. +@exdent Errors: +@end smallexample -@xref{general query packet}, for a discussion of naming conventions. +@table @code +@item EBADF +fd is not a valid open file descriptor. -@item @code{r} --- reset @strong{(deprecated)} -@cindex @code{r} packet +@item ESPIPE +fd is associated with the @value{GDBN} console. -Reset the entire system. +@item EINVAL +flag is not a proper value. -@item @code{R}@var{XX} --- remote restart -@cindex @code{R} packet +@item EINTR +The call was interrupted by the user. +@end table -Restart the program being debugged. @var{XX}, while needed, is ignored. -This packet is only available in extended mode. +@node rename +@unnumberedsubsubsec rename +@cindex rename, file-i/o system call -Reply: -@table @samp -@item @emph{no reply} -The @samp{R} packet has no reply. -@end table +@smallexample +@exdent Synopsis: +int rename(const char *oldpath, const char *newpath); -@item @code{s}@var{addr} --- step -@cindex @code{s} packet +@exdent Request: +Frename,oldpathptr/len,newpathptr/len -@var{addr} is address to resume. If @var{addr} is omitted, resume at -same address. +@exdent Return value: +On success, zero is returned. On error, -1 is returned. -Reply: -@xref{Stop Reply Packets}, for the reply specifications. +@exdent Errors: +@end smallexample -@item @code{S}@var{sig}@code{;}@var{addr} --- step with signal -@anchor{step with signal packet} -@cindex @code{S} packet +@table @code +@item EISDIR +newpath is an existing directory, but oldpath is not a +directory. -Like @samp{C} but step not continue. +@item EEXIST +newpath is a non-empty directory. -Reply: -@xref{Stop Reply Packets}, for the reply specifications. +@item EBUSY +oldpath or newpath is a directory that is in use by some +process. -@item @code{t}@var{addr}@code{:}@var{PP}@code{,}@var{MM} --- search -@cindex @code{t} packet +@item EINVAL +An attempt was made to make a directory a subdirectory +of itself. -Search backwards starting at address @var{addr} for a match with pattern -@var{PP} and mask @var{MM}. @var{PP} and @var{MM} are 4 bytes. -@var{addr} must be at least 3 digits. +@item ENOTDIR +A component used as a directory in oldpath or new +path is not a directory. Or oldpath is a directory +and newpath exists but is not a directory. -@item @code{T}@var{XX} --- thread alive -@cindex @code{T} packet +@item EFAULT +oldpathptr or newpathptr are invalid pointer values. -Find out if the thread XX is alive. +@item EACCES +No access to the file or the path of the file. -Reply: -@table @samp -@item OK -thread is still alive -@item E@var{NN} -thread is dead -@end table +@item ENAMETOOLONG + +oldpath or newpath was too long. -@item @code{u} --- reserved +@item ENOENT +A directory component in oldpath or newpath does not exist. -Reserved for future use. +@item EROFS +The file is on a read-only filesystem. -@item @code{U} --- reserved +@item ENOSPC +The device containing the file has no room for the new +directory entry. -Reserved for future use. +@item EINTR +The call was interrupted by the user. +@end table -@item @code{v} --- reserved +@node unlink +@unnumberedsubsubsec unlink +@cindex unlink, file-i/o system call -Reserved for future use. +@smallexample +@exdent Synopsis: +int unlink(const char *pathname); -@item @code{V} --- reserved +@exdent Request: +Funlink,pathnameptr/len -Reserved for future use. +@exdent Return value: +On success, zero is returned. On error, -1 is returned. -@item @code{w} --- reserved +@exdent Errors: +@end smallexample -Reserved for future use. +@table @code +@item EACCES +No access to the file or the path of the file. -@item @code{W} --- reserved +@item EPERM +The system does not allow unlinking of directories. -Reserved for future use. +@item EBUSY +The file pathname cannot be unlinked because it's +being used by another process. -@item @code{x} --- reserved +@item EFAULT +pathnameptr is an invalid pointer value. -Reserved for future use. +@item ENAMETOOLONG +pathname was too long. -@item @code{X}@var{addr}@code{,}@var{length}@var{:}@var{XX@dots{}} --- write mem (binary) -@cindex @code{X} packet +@item ENOENT +A directory component in pathname does not exist. -@var{addr} is address, @var{length} is number of bytes, @var{XX@dots{}} -is binary data. The characters @code{$}, @code{#}, and @code{0x7d} are -escaped using @code{0x7d}. +@item ENOTDIR +A component of the path is not a directory. -Reply: -@table @samp -@item OK -for success -@item E@var{NN} -for an error -@end table +@item EROFS +The file is on a read-only filesystem. -@item @code{y} --- reserved +@item EINTR +The call was interrupted by the user. +@end table -Reserved for future use. +@node stat/fstat +@unnumberedsubsubsec stat/fstat +@cindex fstat, file-i/o system call +@cindex stat, file-i/o system call -@item @code{Y} reserved +@smallexample +@exdent Synopsis: +int stat(const char *pathname, struct stat *buf); +int fstat(int fd, struct stat *buf); -Reserved for future use. +@exdent Request: +Fstat,pathnameptr/len,bufptr +Ffstat,fd,bufptr -@item @code{z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- remove breakpoint or watchpoint @strong{(draft)} -@itemx @code{Z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- insert breakpoint or watchpoint @strong{(draft)} -@anchor{insert breakpoint or watchpoint packet} -@cindex @code{z} packet -@cindex @code{Z} packets +@exdent Return value: +On success, zero is returned. On error, -1 is returned. -Insert (@code{Z}) or remove (@code{z}) a @var{type} breakpoint or -watchpoint starting at address @var{address} and covering the next -@var{length} bytes. +@exdent Errors: +@end smallexample -Each breakpoint and watchpoint packet @var{type} is documented -separately. +@table @code +@item EBADF +fd is not a valid open file. -@emph{Implementation notes: A remote target shall return an empty string -for an unrecognized breakpoint or watchpoint packet @var{type}. A -remote target shall support either both or neither of a given -@code{Z}@var{type}@dots{} and @code{z}@var{type}@dots{} packet pair. To -avoid potential problems with duplicate packets, the operations should -be implemented in an idempotent way.} +@item ENOENT +A directory component in pathname does not exist or the +path is an empty string. -@item @code{z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- remove memory breakpoint @strong{(draft)} -@item @code{Z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- insert memory breakpoint @strong{(draft)} -@cindex @code{z0} packet -@cindex @code{Z0} packet +@item ENOTDIR +A component of the path is not a directory. -Insert (@code{Z0}) or remove (@code{z0}) a memory breakpoint at address -@code{addr} of size @code{length}. +@item EFAULT +pathnameptr is an invalid pointer value. -A memory breakpoint is implemented by replacing the instruction at -@var{addr} with a software breakpoint or trap instruction. The -@code{length} is used by targets that indicates the size of the -breakpoint (in bytes) that should be inserted (e.g., the @sc{arm} and -@sc{mips} can insert either a 2 or 4 byte breakpoint). +@item EACCES +No access to the file or the path of the file. -@emph{Implementation note: It is possible for a target to copy or move -code that contains memory breakpoints (e.g., when implementing -overlays). The behavior of this packet, in the presence of such a -target, is not defined.} +@item ENAMETOOLONG +pathname was too long. -Reply: -@table @samp -@item OK -success -@item -not supported -@item E@var{NN} -for an error +@item EINTR +The call was interrupted by the user. @end table -@item @code{z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- remove hardware breakpoint @strong{(draft)} -@item @code{Z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- insert hardware breakpoint @strong{(draft)} -@cindex @code{z1} packet -@cindex @code{Z1} packet - -Insert (@code{Z1}) or remove (@code{z1}) a hardware breakpoint at -address @code{addr} of size @code{length}. +@node gettimeofday +@unnumberedsubsubsec gettimeofday +@cindex gettimeofday, file-i/o system call -A hardware breakpoint is implemented using a mechanism that is not -dependant on being able to modify the target's memory. +@smallexample +@exdent Synopsis: +int gettimeofday(struct timeval *tv, void *tz); -@emph{Implementation note: A hardware breakpoint is not affected by code -movement.} +@exdent Request: +Fgettimeofday,tvptr,tzptr -Reply: -@table @samp -@item OK -success -@item -not supported -@item E@var{NN} -for an error -@end table +@exdent Return value: +On success, 0 is returned, -1 otherwise. -@item @code{z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- remove write watchpoint @strong{(draft)} -@item @code{Z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- insert write watchpoint @strong{(draft)} -@cindex @code{z2} packet -@cindex @code{Z2} packet +@exdent Errors: +@end smallexample -Insert (@code{Z2}) or remove (@code{z2}) a write watchpoint. +@table @code +@item EINVAL +tz is a non-NULL pointer. -Reply: -@table @samp -@item OK -success -@item -not supported -@item E@var{NN} -for an error +@item EFAULT +tvptr and/or tzptr is an invalid pointer value. @end table -@item @code{z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- remove read watchpoint @strong{(draft)} -@item @code{Z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- insert read watchpoint @strong{(draft)} -@cindex @code{z3} packet -@cindex @code{Z3} packet - -Insert (@code{Z3}) or remove (@code{z3}) a read watchpoint. +@node isatty +@unnumberedsubsubsec isatty +@cindex isatty, file-i/o system call -Reply: -@table @samp -@item OK -success -@item -not supported -@item E@var{NN} -for an error -@end table +@smallexample +@exdent Synopsis: +int isatty(int fd); -@item @code{z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- remove access watchpoint @strong{(draft)} -@item @code{Z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- insert access watchpoint @strong{(draft)} -@cindex @code{z4} packet -@cindex @code{Z4} packet +@exdent Request: +Fisatty,fd -Insert (@code{Z4}) or remove (@code{z4}) an access watchpoint. +@exdent Return value: +Returns 1 if fd refers to the @value{GDBN} console, 0 otherwise. -Reply: -@table @samp -@item OK -success -@item -not supported -@item E@var{NN} -for an error -@end table +@exdent Errors: +@end smallexample +@table @code +@item EINTR +The call was interrupted by the user. @end table -@node Stop Reply Packets -@section Stop Reply Packets -@cindex stop reply packets +@node system +@unnumberedsubsubsec system +@cindex system, file-i/o system call -The @samp{C}, @samp{c}, @samp{S}, @samp{s} and @samp{?} packets can -receive any of the below as a reply. In the case of the @samp{C}, -@samp{c}, @samp{S} and @samp{s} packets, that reply is only returned -when the target halts. In the below the exact meaning of @samp{signal -number} is poorly defined. In general one of the UNIX signal numbering -conventions is used. +@smallexample +@exdent Synopsis: +int system(const char *command); -@table @samp +@exdent Request: +Fsystem,commandptr/len -@item S@var{AA} -@var{AA} is the signal number +@exdent Return value: +The value returned is -1 on error and the return status +of the command otherwise. Only the exit status of the +command is returned, which is extracted from the hosts +system return value by calling WEXITSTATUS(retval). +In case /bin/sh could not be executed, 127 is returned. -@item @code{T}@var{AA}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;} -@cindex @code{T} packet reply +@exdent Errors: +@end smallexample -@var{AA} = two hex digit signal number; @var{n...} = register number -(hex), @var{r...} = target byte ordered register contents, size defined -by @code{REGISTER_RAW_SIZE}; @var{n...} = @samp{thread}, @var{r...} = -thread process ID, this is a hex integer; @var{n...} = (@samp{watch} | -@samp{rwatch} | @samp{awatch}, @var{r...} = data address, this is a hex -integer; @var{n...} = other string not starting with valid hex digit. -@value{GDBN} should ignore this @var{n...}, @var{r...} pair and go on -to the next. This way we can extend the protocol. +@table @code +@item EINTR +The call was interrupted by the user. +@end table -@item W@var{AA} +@node Protocol specific representation of datatypes +@subsection Protocol specific representation of datatypes +@cindex protocol specific representation of datatypes, in file-i/o protocol -The process exited, and @var{AA} is the exit status. This is only -applicable to certain targets. +@menu +* Integral datatypes:: +* Pointer values:: +* struct stat:: +* struct timeval:: +@end menu -@item X@var{AA} +@node Integral datatypes +@unnumberedsubsubsec Integral datatypes +@cindex integral datatypes, in file-i/o protocol -The process terminated with signal @var{AA}. +The integral datatypes used in the system calls are -@item N@var{AA};@var{t@dots{}};@var{d@dots{}};@var{b@dots{}} @strong{(obsolete)} +@smallexample +int@r{,} unsigned int@r{,} long@r{,} unsigned long@r{,} mode_t @r{and} time_t +@end smallexample -@var{AA} = signal number; @var{t@dots{}} = address of symbol -@code{_start}; @var{d@dots{}} = base of data section; @var{b@dots{}} = -base of bss section. @emph{Note: only used by Cisco Systems targets. -The difference between this reply and the @samp{qOffsets} query is that -the @samp{N} packet may arrive spontaneously whereas the @samp{qOffsets} -is a query initiated by the host debugger.} +@code{Int}, @code{unsigned int}, @code{mode_t} and @code{time_t} are +implemented as 32 bit values in this protocol. -@item O@var{XX@dots{}} +@code{Long} and @code{unsigned long} are implemented as 64 bit types. + +@xref{Limits}, for corresponding MIN and MAX values (similar to those +in @file{limits.h}) to allow range checking on host and target. -@var{XX@dots{}} is hex encoding of @sc{ascii} data. This can happen at -any time while the program is running and the debugger should continue -to wait for @samp{W}, @samp{T}, etc. +@code{time_t} datatypes are defined as seconds since the Epoch. -@end table +All integral datatypes transferred as part of a memory read or write of a +structured datatype e.g.@: a @code{struct stat} have to be given in big endian +byte order. -@node General Query Packets -@section General Query Packets +@node Pointer values +@unnumberedsubsubsec Pointer values +@cindex pointer values, in file-i/o protocol -The following set and query packets have already been defined. +Pointers to target data are transmitted as they are. An exception +is made for pointers to buffers for which the length isn't +transmitted as part of the function call, namely strings. Strings +are transmitted as a pointer/length pair, both as hex values, e.g.@: -@table @r +@smallexample +@code{1aaf/12} +@end smallexample -@item @code{q}@code{C} --- current thread +@noindent +which is a pointer to data of length 18 bytes at position 0x1aaf. +The length is defined as the full string length in bytes, including +the trailing null byte. Example: -Return the current thread id. +@smallexample +``hello, world'' at address 0x123456 +@end smallexample -Reply: -@table @samp -@item @code{QC}@var{pid} -Where @var{pid} is a HEX encoded 16 bit process id. -@item * -Any other reply implies the old pid. -@end table +@noindent +is transmitted as -@item @code{q}@code{fThreadInfo} -- all thread ids +@smallexample +@code{123456/d} +@end smallexample -@code{q}@code{sThreadInfo} +@node struct stat +@unnumberedsubsubsec struct stat +@cindex struct stat, in file-i/o protocol -Obtain a list of active thread ids from the target (OS). Since there -may be too many active threads to fit into one reply packet, this query -works iteratively: it may require more than one query/reply sequence to -obtain the entire list of threads. The first query of the sequence will -be the @code{qf}@code{ThreadInfo} query; subsequent queries in the -sequence will be the @code{qs}@code{ThreadInfo} query. +The buffer of type struct stat used by the target and @value{GDBN} is defined +as follows: -NOTE: replaces the @code{qL} query (see below). +@smallexample +struct stat @{ + unsigned int st_dev; /* device */ + unsigned int st_ino; /* inode */ + mode_t st_mode; /* protection */ + unsigned int st_nlink; /* number of hard links */ + unsigned int st_uid; /* user ID of owner */ + unsigned int st_gid; /* group ID of owner */ + unsigned int st_rdev; /* device type (if inode device) */ + unsigned long st_size; /* total size, in bytes */ + unsigned long st_blksize; /* blocksize for filesystem I/O */ + unsigned long st_blocks; /* number of blocks allocated */ + time_t st_atime; /* time of last access */ + time_t st_mtime; /* time of last modification */ + time_t st_ctime; /* time of last change */ +@}; +@end smallexample -Reply: -@table @samp -@item @code{m}@var{id} -A single thread id -@item @code{m}@var{id},@var{id}@dots{} -a comma-separated list of thread ids -@item @code{l} -(lower case 'el') denotes end of list. -@end table +The integral datatypes are conforming to the definitions given in the +approriate section (see @ref{Integral datatypes}, for details) so this +structure is of size 64 bytes. -In response to each query, the target will reply with a list of one or -more thread ids, in big-endian hex, separated by commas. @value{GDBN} -will respond to each reply with a request for more thread ids (using the -@code{qs} form of the query), until the target responds with @code{l} -(lower-case el, for @code{'last'}). +The values of several fields have a restricted meaning and/or +range of values. -@item @code{q}@code{ThreadExtraInfo}@code{,}@var{id} --- extra thread info +@smallexample +st_dev: 0 file + 1 console -Where @var{id} is a thread-id in big-endian hex. Obtain a printable -string description of a thread's attributes from the target OS. This -string may contain anything that the target OS thinks is interesting for -@value{GDBN} to tell the user about the thread. The string is displayed -in @value{GDBN}'s @samp{info threads} display. Some examples of -possible thread extra info strings are ``Runnable'', or ``Blocked on -Mutex''. +st_ino: No valid meaning for the target. Transmitted unchanged. -Reply: -@table @samp -@item @var{XX@dots{}} -Where @var{XX@dots{}} is a hex encoding of @sc{ascii} data, comprising -the printable string containing the extra information about the thread's -attributes. -@end table +st_mode: Valid mode bits are described in Appendix C. Any other + bits have currently no meaning for the target. -@item @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread} --- query @var{LIST} or @var{threadLIST} @strong{(deprecated)} +st_uid: No valid meaning for the target. Transmitted unchanged. -Obtain thread information from RTOS. Where: @var{startflag} (one hex -digit) is one to indicate the first query and zero to indicate a -subsequent query; @var{threadcount} (two hex digits) is the maximum -number of threads the response packet can contain; and @var{nextthread} -(eight hex digits), for subsequent queries (@var{startflag} is zero), is -returned in the response as @var{argthread}. +st_gid: No valid meaning for the target. Transmitted unchanged. -NOTE: this query is replaced by the @code{q}@code{fThreadInfo} query -(see above). +st_rdev: No valid meaning for the target. Transmitted unchanged. -Reply: -@table @samp -@item @code{q}@code{M}@var{count}@var{done}@var{argthread}@var{thread@dots{}} -Where: @var{count} (two hex digits) is the number of threads being -returned; @var{done} (one hex digit) is zero to indicate more threads -and one indicates no further threads; @var{argthreadid} (eight hex -digits) is @var{nextthread} from the request packet; @var{thread@dots{}} -is a sequence of thread IDs from the target. @var{threadid} (eight hex -digits). See @code{remote.c:parse_threadlist_response()}. -@end table +st_atime, st_mtime, st_ctime: + These values have a host and file system dependent + accuracy. Especially on Windows hosts the file systems + don't support exact timing values. +@end smallexample -@item @code{q}@code{CRC:}@var{addr}@code{,}@var{length} --- compute CRC of memory block +The target gets a struct stat of the above representation and is +responsible to coerce it to the target representation before +continuing. -Reply: -@table @samp -@item @code{E}@var{NN} -An error (such as memory fault) -@item @code{C}@var{CRC32} -A 32 bit cyclic redundancy check of the specified memory region. -@end table +Note that due to size differences between the host and target +representation of stat members, these members could eventually +get truncated on the target. -@item @code{q}@code{Offsets} --- query sect offs +@node struct timeval +@unnumberedsubsubsec struct timeval +@cindex struct timeval, in file-i/o protocol -Get section offsets that the target used when re-locating the downloaded -image. @emph{Note: while a @code{Bss} offset is included in the -response, @value{GDBN} ignores this and instead applies the @code{Data} -offset to the @code{Bss} section.} +The buffer of type struct timeval used by the target and @value{GDBN} +is defined as follows: -Reply: -@table @samp -@item @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz} -@end table +@smallexample +struct timeval @{ + time_t tv_sec; /* second */ + long tv_usec; /* microsecond */ +@}; +@end smallexample -@item @code{q}@code{P}@var{mode}@var{threadid} --- thread info request +The integral datatypes are conforming to the definitions given in the +approriate section (see @ref{Integral datatypes}, for details) so this +structure is of size 8 bytes. -Returns information on @var{threadid}. Where: @var{mode} is a hex -encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID. +@node Constants +@subsection Constants +@cindex constants, in file-i/o protocol -Reply: -@table @samp -@item * -@end table +The following values are used for the constants inside of the +protocol. @value{GDBN} and target are resposible to translate these +values before and after the call as needed. -See @code{remote.c:remote_unpack_thread_info_response()}. +@menu +* Open flags:: +* mode_t values:: +* Errno values:: +* Lseek flags:: +* Limits:: +@end menu -@item @code{q}@code{Rcmd,}@var{command} --- remote command +@node Open flags +@unnumberedsubsubsec Open flags +@cindex open flags, in file-i/o protocol -@var{command} (hex encoded) is passed to the local interpreter for -execution. Invalid commands should be reported using the output string. -Before the final result packet, the target may also respond with a -number of intermediate @code{O}@var{output} console output packets. -@emph{Implementors should note that providing access to a stubs's -interpreter may have security implications}. +All values are given in hexadecimal representation. -Reply: -@table @samp -@item OK -A command response with no output. -@item @var{OUTPUT} -A command response with the hex encoded output string @var{OUTPUT}. -@item @code{E}@var{NN} -Indicate a badly formed request. -@item @samp{} -When @samp{q}@samp{Rcmd} is not recognized. -@end table +@smallexample + O_RDONLY 0x0 + O_WRONLY 0x1 + O_RDWR 0x2 + O_APPEND 0x8 + O_CREAT 0x200 + O_TRUNC 0x400 + O_EXCL 0x800 +@end smallexample -@item @code{qSymbol::} --- symbol lookup +@node mode_t values +@unnumberedsubsubsec mode_t values +@cindex mode_t values, in file-i/o protocol -Notify the target that @value{GDBN} is prepared to serve symbol lookup -requests. Accept requests from the target for the values of symbols. +All values are given in octal representation. -Reply: -@table @samp -@item @code{OK} -The target does not need to look up any (more) symbols. -@item @code{qSymbol:}@var{sym_name} -The target requests the value of symbol @var{sym_name} (hex encoded). -@value{GDBN} may provide the value by using the -@code{qSymbol:}@var{sym_value}:@var{sym_name} message, described below. -@end table +@smallexample + S_IFREG 0100000 + S_IFDIR 040000 + S_IRUSR 0400 + S_IWUSR 0200 + S_IXUSR 0100 + S_IRGRP 040 + S_IWGRP 020 + S_IXGRP 010 + S_IROTH 04 + S_IWOTH 02 + S_IXOTH 01 +@end smallexample -@item @code{qSymbol:}@var{sym_value}:@var{sym_name} --- symbol value +@node Errno values +@unnumberedsubsubsec Errno values +@cindex errno values, in file-i/o protocol -Set the value of @var{sym_name} to @var{sym_value}. +All values are given in decimal representation. -@var{sym_name} (hex encoded) is the name of a symbol whose value the -target has previously requested. +@smallexample + EPERM 1 + ENOENT 2 + EINTR 4 + EBADF 9 + EACCES 13 + EFAULT 14 + EBUSY 16 + EEXIST 17 + ENODEV 19 + ENOTDIR 20 + EISDIR 21 + EINVAL 22 + ENFILE 23 + EMFILE 24 + EFBIG 27 + ENOSPC 28 + ESPIPE 29 + EROFS 30 + ENAMETOOLONG 91 + EUNKNOWN 9999 +@end smallexample -@var{sym_value} (hex) is the value for symbol @var{sym_name}. If -@value{GDBN} cannot supply a value for @var{sym_name}, then this field -will be empty. + EUNKNOWN is used as a fallback error value if a host system returns + any error value not in the list of supported error numbers. -Reply: -@table @samp -@item @code{OK} -The target does not need to look up any (more) symbols. -@item @code{qSymbol:}@var{sym_name} -The target requests the value of a new symbol @var{sym_name} (hex -encoded). @value{GDBN} will continue to supply the values of symbols -(if available), until the target ceases to request them. -@end table +@node Lseek flags +@unnumberedsubsubsec Lseek flags +@cindex lseek flags, in file-i/o protocol -@end table +@smallexample + SEEK_SET 0 + SEEK_CUR 1 + SEEK_END 2 +@end smallexample -@node Register Packet Format -@section Register Packet Format +@node Limits +@unnumberedsubsubsec Limits +@cindex limits, in file-i/o protocol -The following @samp{g}/@samp{G} packets have previously been defined. -In the below, some thirty-two bit registers are transferred as -sixty-four bits. Those registers should be zero/sign extended (which?) -to fill the space allocated. Register bytes are transfered in target -byte order. The two nibbles within a register byte are transfered -most-significant - least-significant. +All values are given in decimal representation. -@table @r +@smallexample + INT_MIN -2147483648 + INT_MAX 2147483647 + UINT_MAX 4294967295 + LONG_MIN -9223372036854775808 + LONG_MAX 9223372036854775807 + ULONG_MAX 18446744073709551615 +@end smallexample -@item MIPS32 +@node File-I/O Examples +@subsection File-I/O Examples +@cindex file-i/o examples -All registers are transfered as thirty-two bit quantities in the order: -32 general-purpose; sr; lo; hi; bad; cause; pc; 32 floating-point -registers; fsr; fir; fp. +Example sequence of a write call, file descriptor 3, buffer is at target +address 0x1234, 6 bytes should be written: -@item MIPS64 +@smallexample +<- @code{Fwrite,3,1234,6} +@emph{request memory read from target} +-> @code{m1234,6} +<- XXXXXX +@emph{return "6 bytes written"} +-> @code{F6} +@end smallexample -All registers are transfered as sixty-four bit quantities (including -thirty-two bit registers such as @code{sr}). The ordering is the same -as @code{MIPS32}. +Example sequence of a read call, file descriptor 3, buffer is at target +address 0x1234, 6 bytes should be read: -@end table +@smallexample +<- @code{Fread,3,1234,6} +@emph{request memory write to target} +-> @code{X1234,6:XXXXXX} +@emph{return "6 bytes read"} +-> @code{F6} +@end smallexample -@node Examples -@section Examples +Example sequence of a read call, call fails on the host due to invalid +file descriptor (EBADF): -Example sequence of a target being re-started. Notice how the restart -does not get any direct output: +@smallexample +<- @code{Fread,3,1234,6} +-> @code{F-1,9} +@end smallexample + +Example sequence of a read call, user presses Ctrl-C before syscall on +host is called: @smallexample --> @code{R00} -<- @code{+} -@emph{target restarts} --> @code{?} -<- @code{+} -<- @code{T001:1234123412341234} --> @code{+} +<- @code{Fread,3,1234,6} +-> @code{F-1,4,C} +<- @code{T02} @end smallexample -Example sequence of a target being stepped by a single instruction: +Example sequence of a read call, user presses Ctrl-C after syscall on +host is called: @smallexample --> @code{G1445@dots{}} -<- @code{+} --> @code{s} -<- @code{+} -@emph{time passes} -<- @code{T001:1234123412341234} --> @code{+} --> @code{g} -<- @code{+} -<- @code{1455@dots{}} --> @code{+} +<- @code{Fread,3,1234,6} +-> @code{X1234,6:XXXXXX} +<- @code{T02} @end smallexample @include gpl.texi