URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Subversion Repositories or1k_old
[/] [or1k_old/] [trunk/] [insight/] [gdb/] [doc/] [gdb.info-10] - Rev 1782
Compare with Previous | Blame | View Log
This is ./gdb.info, produced by makeinfo version 4.0 from gdb.texinfo.INFO-DIR-SECTION Programming & development tools.START-INFO-DIR-ENTRY* Gdb: (gdb). The GNU debugger.END-INFO-DIR-ENTRYThis file documents the GNU debugger GDB.This is the Ninth Edition, April 2001, of `Debugging with GDB: theGNU Source-Level Debugger' for GDB Version 20010707.Copyright (C)1988,1989,1990,1991,1992,1993,1994,1995,1996,1998,1999,2000,2001Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.1 orany later version published by the Free Software Foundation; with theInvariant Sections being "A Sample GDB Session" and "Free Software",with the Front-Cover texts being "A GNU Manual," and with theBack-Cover Texts as in (a) below.(a) The FSF's Back-Cover Text is: "You have freedom to copy andmodify this GNU Manual, like GNU software. Copies published by the FreeSoftware Foundation raise funds for GNU development."File: gdb.info, Node: Define, Next: Hooks, Up: SequencesUser-defined commands=====================A "user-defined command" is a sequence of GDB commands to which youassign a new name as a command. This is done with the `define'command. User commands may accept up to 10 arguments separated bywhitespace. Arguments are accessed within the user command via$ARG0...$ARG9. A trivial example:define adderprint $arg0 + $arg1 + $arg2To execute the command use:adder 1 2 3This defines the command `adder', which prints the sum of its threearguments. Note the arguments are text substitutions, so they mayreference variables, use complex expressions, or even perform inferiorfunctions calls.`define COMMANDNAME'Define a command named COMMANDNAME. If there is already a commandby that name, you are asked to confirm that you want to redefineit.The definition of the command is made up of other GDB commandlines, which are given following the `define' command. The end ofthese commands is marked by a line containing `end'.`if'Takes a single argument, which is an expression to evaluate. Itis followed by a series of commands that are executed only if theexpression is true (nonzero). There can then optionally be a line`else', followed by a series of commands that are only executed ifthe expression was false. The end of the list is marked by a linecontaining `end'.`while'The syntax is similar to `if': the command takes a single argument,which is an expression to evaluate, and must be followed by thecommands to execute, one per line, terminated by an `end'. Thecommands are executed repeatedly as long as the expressionevaluates to true.`document COMMANDNAME'Document the user-defined command COMMANDNAME, so that it can beaccessed by `help'. The command COMMANDNAME must already bedefined. This command reads lines of documentation just as`define' reads the lines of the command definition, ending with`end'. After the `document' command is finished, `help' on commandCOMMANDNAME displays the documentation you have written.You may use the `document' command again to change thedocumentation of a command. Redefining the command with `define'does not change the documentation.`help user-defined'List all user-defined commands, with the first line of thedocumentation (if any) for each.`show user'`show user COMMANDNAME'Display the GDB commands used to define COMMANDNAME (but not itsdocumentation). If no COMMANDNAME is given, display thedefinitions for all user-defined commands.When user-defined commands are executed, the commands of thedefinition are not printed. An error in any command stops execution ofthe user-defined command.If used interactively, commands that would ask for confirmationproceed without asking when used inside a user-defined command. ManyGDB commands that normally print messages to say what they are doingomit the messages when used in a user-defined command.File: gdb.info, Node: Hooks, Next: Command Files, Prev: Define, Up: SequencesUser-defined command hooks==========================You may define "hooks", which are a special kind of user-definedcommand. Whenever you run the command `foo', if the user-definedcommand `hook-foo' exists, it is executed (with no arguments) beforethat command.A hook may also be defined which is run after the command youexecuted. Whenever you run the command `foo', if the user-definedcommand `hookpost-foo' exists, it is executed (with no arguments) afterthat command. Post-execution hooks may exist simultaneously withpre-execution hooks, for the same command.It is valid for a hook to call the command which it hooks. If thisoccurs, the hook is not re-executed, thereby avoiding infinte recursion.In addition, a pseudo-command, `stop' exists. Defining(`hook-stop') makes the associated commands execute every timeexecution stops in your program: before breakpoint commands are run,displays are printed, or the stack frame is printed.For example, to ignore `SIGALRM' signals while single-stepping, buttreat them normally during normal execution, you could define:define hook-stophandle SIGALRM nopassenddefine hook-runhandle SIGALRM passenddefine hook-continuehandle SIGLARM passendAs a further example, to hook at the begining and end of the `echo'command, and to add extra text to the beginning and end of the message,you could define:define hook-echoecho <<<---enddefine hookpost-echoecho --->>>\nend(gdb) echo Hello World<<<---Hello World--->>>(gdb)You can define a hook for any single-word command in GDB, but notfor command aliases; you should define a hook for the basic commandname, e.g. `backtrace' rather than `bt'. If an error occurs duringthe execution of your hook, execution of GDB commands stops and GDBissues a prompt (before the command that you actually typed had achance to run).If you try to define a hook which does not match any known command,you get a warning from the `define' command.File: gdb.info, Node: Command Files, Next: Output, Prev: Hooks, Up: SequencesCommand files=============A command file for GDB is a file of lines that are GDB commands.Comments (lines starting with `#') may also be included. An empty linein a command file does nothing; it does not mean to repeat the lastcommand, as it would from the terminal.When you start GDB, it automatically executes commands from its"init files". These are files named `.gdbinit' on Unix and `gdb.ini'on DOS/Windows. During startup, GDB does the following:1. Reads the init file (if any) in your home directory(1).2. Processes command line options and operands.3. Reads the init file (if any) in the current working directory.4. Reads command files specified by the `-x' option.The init file in your home directory can set options (such as `setcomplaints') that affect subsequent processing of command line optionsand operands. Init files are not executed if you use the `-nx' option(*note Choosing modes: Mode Options.).On some configurations of GDB, the init file is known by a differentname (these are typically environments where a specialized form of GDBmay need to coexist with other forms, hence a different name for thespecialized version's init file). These are the environments withspecial init file names:* VxWorks (Wind River Systems real-time OS): `.vxgdbinit'* OS68K (Enea Data Systems real-time OS): `.os68gdbinit'* ES-1800 (Ericsson Telecom AB M68000 emulator): `.esgdbinit'You can also request the execution of a command file with the`source' command:`source FILENAME'Execute the command file FILENAME.The lines in a command file are executed sequentially. They are notprinted as they are executed. An error in any command terminatesexecution of the command file.Commands that would ask for confirmation if used interactivelyproceed without asking when used in a command file. Many GDB commandsthat normally print messages to say what they are doing omit themessages when called from command files.---------- Footnotes ----------(1) On DOS/Windows systems, the home directory is the one pointed toby the `HOME' environment variable.File: gdb.info, Node: Output, Prev: Command Files, Up: SequencesCommands for controlled output==============================During the execution of a command file or a user-defined command,normal GDB output is suppressed; the only output that appears is what isexplicitly printed by the commands in the definition. This sectiondescribes three commands useful for generating exactly the output youwant.`echo TEXT'Print TEXT. Nonprinting characters can be included in TEXT usingC escape sequences, such as `\n' to print a newline. *No newlineis printed unless you specify one.* In addition to the standard Cescape sequences, a backslash followed by a space stands for aspace. This is useful for displaying a string with spaces at thebeginning or the end, since leading and trailing spaces areotherwise trimmed from all arguments. To print ` and foo = ', usethe command `echo \ and foo = \ '.A backslash at the end of TEXT can be used, as in C, to continuethe command onto subsequent lines. For example,echo This is some text\n\which is continued\n\onto several lines.\nproduces the same output asecho This is some text\necho which is continued\necho onto several lines.\n`output EXPRESSION'Print the value of EXPRESSION and nothing but that value: nonewlines, no `$NN = '. The value is not entered in the valuehistory either. *Note Expressions: Expressions, for moreinformation on expressions.`output/FMT EXPRESSION'Print the value of EXPRESSION in format FMT. You can use the sameformats as for `print'. *Note Output formats: Output Formats, formore information.`printf STRING, EXPRESSIONS...'Print the values of the EXPRESSIONS under the control of STRING.The EXPRESSIONS are separated by commas and may be either numbersor pointers. Their values are printed as specified by STRING,exactly as if your program were to execute the C subroutineprintf (STRING, EXPRESSIONS...);For example, you can print two values in hex like this:printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-fooThe only backslash-escape sequences that you can use in the formatstring are the simple ones that consist of backslash followed by aletter.File: gdb.info, Node: Emacs, Next: Annotations, Prev: Sequences, Up: TopUsing GDB under GNU Emacs*************************A special interface allows you to use GNU Emacs to view (and edit)the source files for the program you are debugging with GDB.To use this interface, use the command `M-x gdb' in Emacs. Give theexecutable file you want to debug as an argument. This command startsGDB as a subprocess of Emacs, with input and output through a newlycreated Emacs buffer.Using GDB under Emacs is just like using GDB normally except for twothings:* All "terminal" input and output goes through the Emacs buffer.This applies both to GDB commands and their output, and to the inputand output done by the program you are debugging.This is useful because it means that you can copy the text ofprevious commands and input them again; you can even use parts of theoutput in this way.All the facilities of Emacs' Shell mode are available for interactingwith your program. In particular, you can send signals the usualway--for example, `C-c C-c' for an interrupt, `C-c C-z' for a stop.* GDB displays source code through Emacs.Each time GDB displays a stack frame, Emacs automatically finds thesource file for that frame and puts an arrow (`=>') at the left marginof the current line. Emacs uses a separate buffer for source display,and splits the screen to show both your GDB session and the source.Explicit GDB `list' or search commands still produce output asusual, but you probably have no reason to use them from Emacs._Warning:_ If the directory where your program resides is not yourcurrent directory, it can be easy to confuse Emacs about thelocation of the source files, in which case the auxiliary displaybuffer does not appear to show your source. GDB can find programsby searching your environment's `PATH' variable, so the GDB inputand output session proceeds normally; but Emacs does not getenough information back from GDB to locate the source files inthis situation. To avoid this problem, either start GDB mode fromthe directory where your program resides, or specify an absolutefile name when prompted for the `M-x gdb' argument.A similar confusion can result if you use the GDB `file' command toswitch to debugging a program in some other location, from anexisting GDB buffer in Emacs.By default, `M-x gdb' calls the program called `gdb'. If you needto call GDB by a different name (for example, if you keep severalconfigurations around, with different names) you can set the Emacsvariable `gdb-command-name'; for example,(setq gdb-command-name "mygdb")(preceded by `M-:' or `ESC :', or typed in the `*scratch*' buffer, orin your `.emacs' file) makes Emacs call the program named "`mygdb'"instead.In the GDB I/O buffer, you can use these special Emacs commands inaddition to the standard Shell mode commands:`C-h m'Describe the features of Emacs' GDB Mode.`M-s'Execute to another source line, like the GDB `step' command; alsoupdate the display window to show the current file and location.`M-n'Execute to next source line in this function, skipping all functioncalls, like the GDB `next' command. Then update the display windowto show the current file and location.`M-i'Execute one instruction, like the GDB `stepi' command; updatedisplay window accordingly.`M-x gdb-nexti'Execute to next instruction, using the GDB `nexti' command; updatedisplay window accordingly.`C-c C-f'Execute until exit from the selected stack frame, like the GDB`finish' command.`M-c'Continue execution of your program, like the GDB `continue'command._Warning:_ In Emacs v19, this command is `C-c C-p'.`M-u'Go up the number of frames indicated by the numeric argument(*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'command._Warning:_ In Emacs v19, this command is `C-c C-u'.`M-d'Go down the number of frames indicated by the numeric argument,like the GDB `down' command._Warning:_ In Emacs v19, this command is `C-c C-d'.`C-x &'Read the number where the cursor is positioned, and insert it atthe end of the GDB I/O buffer. For example, if you wish todisassemble code around an address that was displayed earlier,type `disassemble'; then move the cursor to the address display,and pick up the argument for `disassemble' by typing `C-x &'.You can customize this further by defining elements of the list`gdb-print-command'; once it is defined, you can format orotherwise process numbers picked up by `C-x &' before they areinserted. A numeric argument to `C-x &' indicates that you wishspecial formatting, and also acts as an index to pick an elementof the list. If the list element is a string, the number to beinserted is formatted using the Emacs function `format'; otherwisethe number is passed as an argument to the corresponding listelement.In any source file, the Emacs command `C-x SPC' (`gdb-break') tellsGDB to set a breakpoint on the source line point is on.If you accidentally delete the source-display buffer, an easy way toget it back is to type the command `f' in the GDB buffer, to request aframe display; when you run under Emacs, this recreates the sourcebuffer if necessary to show you the context of the current frame.The source files displayed in Emacs are in ordinary Emacs bufferswhich are visiting the source files in the usual way. You can edit thefiles with these buffers if you wish; but keep in mind that GDBcommunicates with Emacs in terms of line numbers. If you add or deletelines from the text, the line numbers that GDB knows cease tocorrespond properly with the code.File: gdb.info, Node: Annotations, Next: GDB/MI, Prev: Emacs, Up: TopGDB Annotations***************This chapter describes annotations in GDB. Annotations are designedto interface GDB to graphical user interfaces or other similar programswhich want to interact with GDB at a relatively high level.* 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:: GDB can be told to display something periodically.* Prompting:: Annotations marking GDB'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.File: gdb.info, Node: Annotations Overview, Next: Server Prefix, Up: AnnotationsWhat is an Annotation?======================To produce annotations, start GDB with the `--annotate=2' option.Annotations start with a newline character, two `control-z'characters, and the name of the annotation. If there is no additionalinformation associated with this annotation, the name of the annotationis followed immediately by a newline. If there is additionalinformation, the name of the annotation is followed by a space, theadditional information, and a newline. The additional informationcannot contain newline characters.Any output not beginning with a newline and two `control-z'characters denotes literal output from GDB. Currently there is no needfor GDB to output a newline followed by two `control-z' characters, butif there was such a need, the annotations could be extended with an`escape' annotation which means those three characters as output.A simple example of starting up GDB with annotations is:$ gdb --annotate=2GNU GDB 5.0Copyright 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 itunder 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^Zpromptquit^Z^Zpost-prompt$Here `quit' is input to GDB; the rest is output from GDB. The threelines beginning `^Z^Z' (where `^Z' denotes a `control-z' character) areannotations; the rest is output from GDB.File: gdb.info, Node: Server Prefix, Next: Value Annotations, Prev: Annotations Overview, Up: AnnotationsThe Server Prefix=================To issue a command to GDB without affecting certain aspects of thestate which is seen by users, prefix it with `server '. This meansthat this command will not affect the command history, nor will itaffect GDB's notion of which command to repeat if <RET> is pressed on aline by itself.The server prefix does not affect the recording of values into thevalue history; to print a value without recording it into the valuehistory, use the `output' command instead of the `print' command.File: gdb.info, Node: Value Annotations, Next: Frame Annotations, Prev: Server Prefix, Up: AnnotationsValues======When a value is printed in various contexts, GDB uses annotations todelimit the value from the surrounding text.If a value is printed using `print' and added to the value history,the annotation looks like^Z^Zvalue-history-begin HISTORY-NUMBER VALUE-FLAGSHISTORY-STRING^Z^Zvalue-history-valueTHE-VALUE^Z^Zvalue-history-endwhere HISTORY-NUMBER is the number it is getting in the value history,HISTORY-STRING is a string, such as `$5 = ', which introduces the valueto the user, THE-VALUE is the output corresponding to the value itself,and VALUE-FLAGS is `*' for a value which can be dereferenced and `-'for a value which cannot.If the value is not added to the value history (it is an invalidfloat or it is printed with the `output' command), the annotation issimilar:^Z^Zvalue-begin VALUE-FLAGSTHE-VALUE^Z^Zvalue-endWhen GDB prints an argument to a function (for example, in the outputfrom the `backtrace' command), it annotates it as follows:^Z^Zarg-beginARGUMENT-NAME^Z^Zarg-name-endSEPARATOR-STRING^Z^Zarg-value VALUE-FLAGSTHE-VALUE^Z^Zarg-endwhere ARGUMENT-NAME is the name of the argument, SEPARATOR-STRING istext which separates the name from the value for the user's benefit(such as `='), and VALUE-FLAGS and THE-VALUE have the same meanings asin a `value-history-begin' annotation.When printing a structure, GDB annotates it as follows:^Z^Zfield-begin VALUE-FLAGSFIELD-NAME^Z^Zfield-name-endSEPARATOR-STRING^Z^Zfield-valueTHE-VALUE^Z^Zfield-endwhere FIELD-NAME is the name of the field, SEPARATOR-STRING is textwhich separates the name from the value for the user's benefit (such as`='), and VALUE-FLAGS and THE-VALUE have the same meanings as in a`value-history-begin' annotation.When printing an array, GDB annotates it as follows:^Z^Zarray-section-begin ARRAY-INDEX VALUE-FLAGSwhere ARRAY-INDEX is the index of the first element being annotated andVALUE-FLAGS has the same meaning as in a `value-history-begin'annotation. This is followed by any number of elements, where iselement can be either a single element:`,' WHITESPACE ; omitted for the first elementTHE-VALUE^Z^Zeltor a repeated element`,' WHITESPACE ; omitted for the first elementTHE-VALUE^Z^Zelt-rep NUMBER-OF-REPITITIONSREPETITION-STRING^Z^Zelt-rep-endIn both cases, THE-VALUE is the output for the value of the elementand WHITESPACE can contain spaces, tabs, and newlines. In the repeatedcase, NUMBER-OF-REPITITONS is the number of consecutive array elementswhich contain that value, and REPETITION-STRING is a string which isdesigned to convey to the user that repitition is being depicted.Once all the array elements have been output, the array annotation isended with^Z^Zarray-section-endFile: gdb.info, Node: Frame Annotations, Next: Displays, Prev: Value Annotations, Up: AnnotationsFrames======Whenever GDB prints a frame, it annotates it. For example, thisapplies to frames printed when GDB stops, output from commands such as`backtrace' or `up', etc.The frame annotation begins with^Z^Zframe-begin LEVEL ADDRESSLEVEL-STRINGwhere LEVEL is the number of the frame (0 is the innermost frame, andother frames have positive numbers), ADDRESS is the address of the codeexecuting in that frame, and LEVEL-STRING is a string designed toconvey the level to the user. ADDRESS is in the form `0x' followed byone or more lowercase hex digits (note that this does not depend on thelanguage). The frame ends with^Z^Zframe-endBetween these annotations is the main body of the frame, which canconsist of* ^Z^Zfunction-callFUNCTION-CALL-STRINGwhere FUNCTION-CALL-STRING is text designed to convey to the userthat this frame is associated with a function call made by GDB to afunction in the program being debugged.* ^Z^Zsignal-handler-callerSIGNAL-HANDLER-CALLER-STRINGwhere SIGNAL-HANDLER-CALLER-STRING is text designed to convey tothe user that this frame is associated with whatever mechanism isused by this operating system to call a signal handler (it is theframe which calls the signal handler, not the frame for the signalhandler itself).* A normal frame.This can optionally (depending on whether this is thought of asinteresting information for the user to see) begin with^Z^Zframe-addressADDRESS^Z^Zframe-address-endSEPARATOR-STRINGwhere ADDRESS is the address executing in the frame (the sameaddress as in the `frame-begin' annotation, but printed in a formwhich is intended for user consumption--in particular, the syntaxvaries depending on the language), and SEPARATOR-STRING is a stringintended to separate this address from what follows for the user'sbenefit.Then comes^Z^Zframe-function-nameFUNCTION-NAME^Z^Zframe-argsARGUMENTSwhere FUNCTION-NAME is the name of the function executing in theframe, or `??' if not known, and ARGUMENTS are the arguments tothe frame, with parentheses around them (each argument is annotatedindividually as well, *note Value Annotations::).If source information is available, a reference to it is thenprinted:^Z^Zframe-source-beginSOURCE-INTRO-STRING^Z^Zframe-source-fileFILENAME^Z^Zframe-source-file-end:^Z^Zframe-source-lineLINE-NUMBER^Z^Zframe-source-endwhere SOURCE-INTRO-STRING separates for the user's benefit thereference from the text which precedes it, FILENAME is the name ofthe source file, and LINE-NUMBER is the line number within thatfile (the first line is line 1).If GDB prints some information about where the frame is from (whichlibrary, which load segment, etc.; currently only done on theRS/6000), it is annotated with^Z^Zframe-whereINFORMATIONThen, if source is to actually be displayed for this frame (forexample, this is not true for output from the `backtrace'command), then a `source' annotation (*note Source Annotations::)is displayed. Unlike most annotations, this is output instead ofthe normal text which would be output, not in addition.File: gdb.info, Node: Displays, Next: Prompting, Prev: Frame Annotations, Up: AnnotationsDisplays========When GDB is told to display something using the `display' command,the results of the display are annotated:^Z^Zdisplay-beginNUMBER^Z^Zdisplay-number-endNUMBER-SEPARATOR^Z^Zdisplay-formatFORMAT^Z^Zdisplay-expressionEXPRESSION^Z^Zdisplay-expression-endEXPRESSION-SEPARATOR^Z^Zdisplay-valueVALUE^Z^Zdisplay-endwhere NUMBER is the number of the display, NUMBER-SEPARATOR is intendedto separate the number from what follows for the user, FORMAT includesinformation such as the size, format, or other information about howthe value is being displayed, EXPRESSION is the expression beingdisplayed, EXPRESSION-SEPARATOR is intended to separate the expressionfrom the text that follows for the user, and VALUE is the actual valuebeing displayed.File: gdb.info, Node: Prompting, Next: Errors, Prev: Displays, Up: AnnotationsAnnotation for GDB Input========================When GDB prompts for input, it annotates this fact so it is possibleto know when to send output, when the output from a given command isover, etc.Different kinds of input each have a different "input type". Eachinput type has three annotations: a `pre-' annotation, which denotesthe beginning of any prompt which is being output, a plain annotation,which denotes the end of the prompt, and then a `post-' annotationwhich denotes the end of any echo which may (or may not) be associatedwith the input. For example, the `prompt' input type features thefollowing annotations:^Z^Zpre-prompt^Z^Zprompt^Z^Zpost-promptThe input types are`prompt'When GDB is prompting for a command (the main GDB prompt).`commands'When GDB prompts for a set of commands, like in the `commands'command. The annotations are repeated for each command which isinput.`overload-choice'When GDB wants the user to select between various overloadedfunctions.`query'When GDB wants the user to confirm a potentially dangerousoperation.`prompt-for-continue'When GDB is asking the user to press return to continue. Note:Don't expect this to work well; instead use `set height 0' todisable prompting. This is because the counting of lines is buggyin the presence of annotations.File: gdb.info, Node: Errors, Next: Breakpoint Info, Prev: Prompting, Up: AnnotationsErrors======^Z^ZquitThis annotation occurs right before GDB responds to an interrupt.^Z^ZerrorThis annotation occurs right before GDB responds to an error.Quit and error annotations indicate that any annotations which GDBwas in the middle of may end abruptly. For example, if a`value-history-begin' annotation is followed by a `error', one cannotexpect to receive the matching `value-history-end'. One cannot expectnot to receive it either, however; an error annotation does notnecessarily mean that GDB is immediately returning all the way to thetop level.A quit or error annotation may be preceded by^Z^Zerror-beginAny output between that and the quit or error annotation is the errormessage.Warning messages are not yet annotated.File: gdb.info, Node: Breakpoint Info, Next: Invalidation, Prev: Errors, Up: AnnotationsInformation on Breakpoints==========================The output from the `info breakpoints' command is annotated asfollows:^Z^Zbreakpoints-headersHEADER-ENTRY^Z^Zbreakpoints-tablewhere HEADER-ENTRY has the same syntax as an entry (see below) butinstead of containing data, it contains strings which are intended toconvey the meaning of each field to the user. This is followed by anynumber of entries. If a field does not apply for this entry, it isomitted. Fields may contain trailing whitespace. Each entry consistsof:^Z^Zrecord^Z^Zfield 0NUMBER^Z^Zfield 1TYPE^Z^Zfield 2DISPOSITION^Z^Zfield 3ENABLE^Z^Zfield 4ADDRESS^Z^Zfield 5WHAT^Z^Zfield 6FRAME^Z^Zfield 7CONDITION^Z^Zfield 8IGNORE-COUNT^Z^Zfield 9COMMANDSNote that ADDRESS is intended for user consumption--the syntaxvaries depending on the language.The output ends with^Z^Zbreakpoints-table-endFile: gdb.info, Node: Invalidation, Next: Annotations for Running, Prev: Breakpoint Info, Up: AnnotationsInvalidation Notices====================The following annotations say that certain pieces of state may havechanged.`^Z^Zframes-invalid'The frames (for example, output from the `backtrace' command) mayhave changed.`^Z^Zbreakpoints-invalid'The breakpoints may have changed. For example, the user justadded or deleted a breakpoint.File: gdb.info, Node: Annotations for Running, Next: Source Annotations, Prev: Invalidation, Up: AnnotationsRunning the Program===================When the program starts executing due to a GDB command such as`step' or `continue',^Z^Zstartingis output. When the program stops,^Z^Zstoppedis output. Before the `stopped' annotation, a variety ofannotations describe how the program stopped.`^Z^Zexited EXIT-STATUS'The program exited, and EXIT-STATUS is the exit status (zero forsuccessful exit, otherwise nonzero).`^Z^Zsignalled'The program exited with a signal. After the `^Z^Zsignalled', theannotation continues:INTRO-TEXT^Z^Zsignal-nameNAME^Z^Zsignal-name-endMIDDLE-TEXT^Z^Zsignal-stringSTRING^Z^Zsignal-string-endEND-TEXTwhere NAME is the name of the signal, such as `SIGILL' or`SIGSEGV', and STRING is the explanation of the signal, such as`Illegal Instruction' or `Segmentation fault'. INTRO-TEXT,MIDDLE-TEXT, and END-TEXT are for the user's benefit and have noparticular format.`^Z^Zsignal'The syntax of this annotation is just like `signalled', but GDB isjust saying that the program received the signal, not that it wasterminated with it.`^Z^Zbreakpoint NUMBER'The program hit breakpoint number NUMBER.`^Z^Zwatchpoint NUMBER'The program hit watchpoint number NUMBER.File: gdb.info, Node: Source Annotations, Next: TODO, Prev: Annotations for Running, Up: AnnotationsDisplaying Source=================The following annotation is used instead of displaying source code:^Z^Zsource FILENAME:LINE:CHARACTER:MIDDLE:ADDRwhere FILENAME is an absolute file name indicating which sourcefile, LINE is the line number within that file (where 1 is the firstline in the file), CHARACTER is the character position within the file(where 0 is the first character in the file) (for most debug formatsthis will necessarily point to the beginning of a line), MIDDLE is`middle' if ADDR is in the middle of the line, or `beg' if ADDR is atthe beginning of the line, and ADDR is the address in the targetprogram associated with the source which is being displayed. ADDR isin the form `0x' followed by one or more lowercase hex digits (notethat this does not depend on the language).File: gdb.info, Node: TODO, Prev: Source Annotations, Up: AnnotationsAnnotations We Might Want in the Future=======================================- target-invalidthe target might have changed (registers, heap contents, orexecution status). For performance, we might eventually wantto hit `registers-invalid' and `all-registers-invalid' withgreater precision- systematic annotation for set/show parameters (includinginvalidation notices).- similarly, `info' returns a list of candidates for invalidationnotices.File: gdb.info, Node: GDB/MI, Next: GDB Bugs, Prev: Annotations, Up: TopThe GDB/MI Interface********************Function and Purpose====================GDB/MI is a line based machine oriented text interface to GDB. It isspecifically intended to support the development of systems which usethe debugger as just one small component of a larger system.This chapter is a specification of the GDB/MI interface. It iswritten in the form of a reference manual.Note that GDB/MI is still under construction, so some of thefeatures described below are incomplete and subject to change.Notation and Terminology========================This chapter uses the following notation:* `|' separates two alternatives.* `[ SOMETHING ]' indicates that SOMETHING is optional: it may ormay not be given.* `( GROUP )*' means that GROUP inside the parentheses may repeatzero or more times.* `( GROUP )+' means that GROUP inside the parentheses may repeatone or more times.* `"STRING"' means a literal STRING.Acknowledgments===============In alphabetic order: Andrew Cagney, Fernando Nasser, Stan Shebs andElena Zannoni.* 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::* GDB/MI Stack Manipulation::* GDB/MI Symbol Query::* GDB/MI Target Manipulation::* GDB/MI Thread Commands::* GDB/MI Tracepoint Commands::* GDB/MI Variable Objects::File: gdb.info, Node: GDB/MI Command Syntax, Next: GDB/MI Compatibility with CLI, Up: GDB/MIGDB/MI Command Syntax=====================* Menu:* GDB/MI Input Syntax::* GDB/MI Output Syntax::* GDB/MI Simple Examples::File: gdb.info, Node: GDB/MI Input Syntax, Next: GDB/MI Output Syntax, Up: GDB/MI Command SyntaxGDB/MI Input Syntax-------------------`COMMAND ==>'`CLI-COMMAND | MI-COMMAND'`CLI-COMMAND ==>'`[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDBCLI command.`MI-COMMAND ==>'`[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " "PARAMETER )* NL'`TOKEN ==>'"any sequence of digits"`OPTION ==>'`"-" PARAMETER [ " " PARAMETER ]'`PARAMETER ==>'`NON-BLANK-SEQUENCE | C-STRING'`OPERATION ==>'_any of the operations described in this chapter_`NON-BLANK-SEQUENCE ==>'_anything, provided it doesn't contain special characters such as"-", NL, """ and of course " "_`C-STRING ==>'`""" SEVEN-BIT-ISO-C-STRING-CONTENT """'`NL ==>'`CR | CR-LF'Notes:* The CLI commands are still handled by the MI interpreter; theiroutput is described below.* The `TOKEN', when present, is passed back when the commandfinishes.* Some MI commands accept optional arguments as part of the parameterlist. Each option is identified by a leading `-' (dash) and may befollowed by an optional argument parameter. Options occur firstin the parameter list and can be delimited from normal parametersusing `--' (this is useful when some parameters begin with a dash).Pragmatics:* We want easy access to the existing CLI syntax (for debugging).* We want it to be easy to spot a MI operation.File: gdb.info, Node: GDB/MI Output Syntax, Next: GDB/MI Simple Examples, Prev: GDB/MI Input Syntax, Up: GDB/MI Command SyntaxGDB/MI Output Syntax--------------------The output from GDB/MI consists of zero or more out-of-band recordsfollowed, optionally, by a single result record. This result record isfor the most recent command. The sequence of output records isterminated by `(gdb)'.If an input command was prefixed with a `TOKEN' then thecorresponding output for that command will also be prefixed by that sameTOKEN.`OUTPUT ==>'`( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'`RESULT-RECORD ==>'` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'`OUT-OF-BAND-RECORD ==>'`ASYNC-RECORD | STREAM-RECORD'`ASYNC-RECORD ==>'`EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'`EXEC-ASYNC-OUTPUT ==>'`[ TOKEN ] "*" ASYNC-OUTPUT'`STATUS-ASYNC-OUTPUT ==>'`[ TOKEN ] "+" ASYNC-OUTPUT'`NOTIFY-ASYNC-OUTPUT ==>'`[ TOKEN ] "=" ASYNC-OUTPUT'`ASYNC-OUTPUT ==>'`ASYNC-CLASS ( "," RESULT )* NL'`RESULT-CLASS ==>'`"done" | "running" | "connected" | "error" | "exit"'`ASYNC-CLASS ==>'`"stopped" | OTHERS' (where OTHERS will be added depending on theneeds--this is still in development).`RESULT ==>'` VARIABLE "=" VALUE'`VARIABLE ==>'` STRING '`VALUE ==>'` CONST | TUPLE | LIST '`CONST ==>'`C-STRING'`TUPLE ==>'` "{}" | "{" RESULT ( "," RESULT )* "}" '`LIST ==>'` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*"]" '`STREAM-RECORD ==>'`CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'`CONSOLE-STREAM-OUTPUT ==>'`"~" C-STRING'`TARGET-STREAM-OUTPUT ==>'`"@" C-STRING'`LOG-STREAM-OUTPUT ==>'`"&" C-STRING'`NL ==>'`CR | CR-LF'`TOKEN ==>'_any sequence of digits_.Notes:* All output sequences end in a single line containing a period.* The `TOKEN' is from the corresponding request. If an executioncommand is interrupted by the `-exec-interrupt' command, the TOKENassociated with the `*stopped' message is the one of the originalexecution command, not the one of the interrupt command.* STATUS-ASYNC-OUTPUT contains on-going status information about theprogress of a slow operation. It can be discarded. All statusoutput is prefixed by `+'.* EXEC-ASYNC-OUTPUT contains asynchronous state change on the target(stopped, started, disappeared). All async output is prefixed by`*'.* NOTIFY-ASYNC-OUTPUT contains supplementary information that theclient should handle (e.g., a new breakpoint information). Allnotify output is prefixed by `='.* CONSOLE-STREAM-OUTPUT is output that should be displayed as is inthe console. It is the textual response to a CLI command. Allthe console output is prefixed by `~'.* TARGET-STREAM-OUTPUT is the output produced by the target program.All the target output is prefixed by `@'.* LOG-STREAM-OUTPUT is output text coming from GDB's internals, forinstance messages that should be displayed as part of an errorlog. All the log output is prefixed by `&'.* New GDB/MI commands should only output LISTS containing VALUES.*Note GDB/MI Stream Records: GDB/MI Stream Records, for more detailsabout the various output records.File: gdb.info, Node: GDB/MI Simple Examples, Prev: GDB/MI Output Syntax, Up: GDB/MI Command SyntaxSimple Examples of GDB/MI Interaction-------------------------------------This subsection presents several simple examples of interaction usingthe GDB/MI interface. In these examples, `->' means that the followingline is passed to GDB/MI as input, while `<-' means the output receivedfrom GDB/MI.Target Stop...........Here's an example of stopping the inferior process:-> -stop<- (gdb)and later:<- *stop,reason="stop",address="0x123",source="a.c:123"<- (gdb)Simple CLI Command..................Here's an example of a simple CLI command being passed throughGDB/MI and on to the CLI.-> print 1+2<- ~3\n<- (gdb)Command With Side Effects.........................-> -symbol-file xyz.exe<- *breakpoint,nr="3",address="0x123",source="a.c:123"<- (gdb)A Bad Command.............Here's what happens if you pass a non-existent command:-> -rubbish<- error,"Rubbish not found"<- (gdb)File: gdb.info, Node: GDB/MI Compatibility with CLI, Next: GDB/MI Output Records, Prev: GDB/MI Command Syntax, Up: GDB/MIGDB/MI Compatibility with CLI=============================To help users familiar with GDB's existing CLI interface, GDB/MIaccepts existing CLI commands. As specified by the syntax, suchcommands can be directly entered into the GDB/MI interface and GDB willrespond.This mechanism is provided as an aid to developers of GDB/MI clientsand not as a reliable interface into the CLI. Since the command isbeing interpreteted in an environment that assumes GDB/MI behaviour,the exact output of such commands is likely to end up being anun-supported hybrid of GDB/MI and CLI output.File: gdb.info, Node: GDB/MI Output Records, Next: GDB/MI Command Description Format, Prev: GDB/MI Compatibility with CLI, Up: GDB/MIGDB/MI Output Records=====================* Menu:* GDB/MI Result Records::* GDB/MI Stream Records::* GDB/MI Out-of-band Records::File: gdb.info, Node: GDB/MI Result Records, Next: GDB/MI Stream Records, Up: GDB/MI Output RecordsGDB/MI Result Records---------------------In addition to a number of out-of-band notifications, the responseto a GDB/MI command includes one of the following result indications:`"^done" [ "," RESULTS ]'The synchronous operation was successful, `RESULTS' are the returnvalues.`"^running"'The asynchronous operation was successfully started. The target isrunning.`"^error" "," C-STRING'The operation failed. The `C-STRING' contains the correspondingerror message.File: gdb.info, Node: GDB/MI Stream Records, Next: GDB/MI Out-of-band Records, Prev: GDB/MI Result Records, Up: GDB/MI Output RecordsGDB/MI Stream Records---------------------GDB internally maintains a number of output streams: the console, thetarget, and the log. The output intended for each of these streams isfunneled through the GDB/MI interface using "stream records".Each stream record begins with a unique "prefix character" whichidentifies its stream (*note GDB/MI Output Syntax: GDB/MI OutputSyntax.). In addition to the prefix, each stream record contains a`STRING-OUTPUT'. This is either raw text (with an implicit new line)or a quoted C string (which does not contain an implicit newline).`"~" STRING-OUTPUT'The console output stream contains text that should be displayedin the CLI console window. It contains the textual responses toCLI commands.`"@" STRING-OUTPUT'The target output stream contains any textual output from therunning target.`"&" STRING-OUTPUT'The log stream contains debugging messages being produced by GDB'sinternals.File: gdb.info, Node: GDB/MI Out-of-band Records, Prev: GDB/MI Stream Records, Up: GDB/MI Output RecordsGDB/MI Out-of-band Records--------------------------"Out-of-band" records are used to notify the GDB/MI client ofadditional changes that have occurred. Those changes can either be aconsequence of GDB/MI (e.g., a breakpoint modified) or a result oftarget activity (e.g., target stopped).The following is a preliminary list of possible out-of-band records.`"*" "stop"'File: gdb.info, Node: GDB/MI Command Description Format, Next: GDB/MI Breakpoint Table Commands, Prev: GDB/MI Output Records, Up: GDB/MIGDB/MI Command Description Format=================================The remaining sections describe blocks of commands. Each block ofcommands is laid out in a fashion similar to this section.Note the the line breaks shown in the examples are here only forreadability. They don't appear in the real output. Also note that thecommands with a non-available example (N.A.) are not yet implemented.Motivation----------The motivation for this collection of commands.Introduction------------A brief introduction to this collection of commands as a whole.Commands--------For each command in the block, the following is described:Synopsis........-command ARGS...GDB Command...........The corresponding GDB CLI command.Result......Out-of-band...........Notes.....Example.......
