1 @c \input texinfo @c -*-texinfo-*-
2 @c @c %**start of header
3 @c @setfilename annotate.info
4 @c @settitle GDB Annotations
5 @c @setchapternewpage off
12 @c This file documents GDB annotations.
14 @c This is Edition @value{EDITION}, @value{DATE}, of @cite{GDB
15 @c Annotations}. Copyright 1994,1995,2000,2001 Free Software Foundation, Inc.
17 @c Permission is granted to copy, distribute and/or modify this document
18 @c under the terms of the GNU Free Documentation License, Version 1.1 or
19 @c any later version published by the Free Software Foundation; with no
20 @c Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
21 @c and with the Back-Cover Texts as in (a) below.
23 @c (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
24 @c this GNU Manual, like GNU software. Copies published by the Free
25 @c Software Foundation raise funds for GNU development.''
29 @c @title GDB Annotations
30 @c @subtitle Edition @value{EDITION}
31 @c @subtitle @value{DATE}
32 @c @author Cygnus Support
34 @c @vskip 0pt plus 1filll
35 @c Permission is granted to make and distribute verbatim copies of
36 @c this manual provided the copyright notice and this permission notice
37 @c are preserved on all copies.
39 @c Copyright @copyright{} 1994,1995,2000,2001 Free Software Foundation
44 @c @top GDB Annotations
46 @c @syncodeindex fn cp
49 @chapter @value{GDBN} Annotations
51 This chapter describes annotations in @value{GDBN}. Annotations are
52 designed to interface @value{GDBN} to graphical user interfaces or
53 other similar programs which want to interact with @value{GDBN} at a
54 relatively high level.
57 This is Edition @value{EDITION}, @value{DATE}.
61 * Annotations Overview:: What annotations are; the general syntax.
62 * Server Prefix:: Issuing a command without affecting user state.
63 * Value Annotations:: Values are marked as such.
64 * Frame Annotations:: Stack frames are annotated.
65 * Displays:: @value{GDBN} can be told to display something periodically.
66 * Prompting:: Annotations marking @value{GDBN}'s need for input.
67 * Errors:: Annotations for error messages.
68 * Breakpoint Info:: Information on breakpoints.
69 * Invalidation:: Some annotations describe things now invalid.
70 * Annotations for Running::
71 Whether the program is running, how it stopped, etc.
72 * Source Annotations:: Annotations describing source code.
73 * TODO:: Annotations which might be added in the future.
76 @node Annotations Overview
77 @section What is an Annotation?
80 To produce annotations, start @value{GDBN} with the @code{--annotate=2} option.
82 Annotations start with a newline character, two @samp{control-z}
83 characters, and the name of the annotation. If there is no additional
84 information associated with this annotation, the name of the annotation
85 is followed immediately by a newline. If there is additional
86 information, the name of the annotation is followed by a space, the
87 additional information, and a newline. The additional information
88 cannot contain newline characters.
90 Any output not beginning with a newline and two @samp{control-z}
91 characters denotes literal output from @value{GDBN}. Currently there is
92 no need for @value{GDBN} to output a newline followed by two
93 @samp{control-z} characters, but if there was such a need, the
94 annotations could be extended with an @samp{escape} annotation which
95 means those three characters as output.
97 A simple example of starting up @value{GDBN} with annotations is:
102 Copyright 2000 Free Software Foundation, Inc.
103 GDB is free software, covered by the GNU General Public License,
104 and you are welcome to change it and/or distribute copies of it
105 under certain conditions.
106 Type "show copying" to see the conditions.
107 There is absolutely no warranty for GDB. Type "show warranty"
109 This GDB was configured as "sparc-sun-sunos4.1.3"
120 Here @samp{quit} is input to @value{GDBN}; the rest is output from
121 @value{GDBN}. The three lines beginning @samp{^Z^Z} (where @samp{^Z}
122 denotes a @samp{control-z} character) are annotations; the rest is
123 output from @value{GDBN}.
126 @section The Server Prefix
127 @cindex server prefix for annotations
129 To issue a command to @value{GDBN} without affecting certain aspects of
130 the state which is seen by users, prefix it with @samp{server }. This
131 means that this command will not affect the command history, nor will it
132 affect @value{GDBN}'s notion of which command to repeat if @key{RET} is
133 pressed on a line by itself.
135 The server prefix does not affect the recording of values into the value
136 history; to print a value without recording it into the value history,
137 use the @code{output} command instead of the @code{print} command.
139 @node Value Annotations
142 @cindex annotations for values
143 When a value is printed in various contexts, @value{GDBN} uses
144 annotations to delimit the value from the surrounding text.
146 @findex value-history-begin
147 @findex value-history-value
148 @findex value-history-end
149 If a value is printed using @code{print} and added to the value history,
150 the annotation looks like
153 ^Z^Zvalue-history-begin @var{history-number} @var{value-flags}
155 ^Z^Zvalue-history-value
157 ^Z^Zvalue-history-end
161 where @var{history-number} is the number it is getting in the value
162 history, @var{history-string} is a string, such as @samp{$5 = }, which
163 introduces the value to the user, @var{the-value} is the output
164 corresponding to the value itself, and @var{value-flags} is @samp{*} for
165 a value which can be dereferenced and @samp{-} for a value which cannot.
169 If the value is not added to the value history (it is an invalid float
170 or it is printed with the @code{output} command), the annotation is similar:
173 ^Z^Zvalue-begin @var{value-flags}
182 When @value{GDBN} prints an argument to a function (for example, in the output
183 from the @code{backtrace} command), it annotates it as follows:
189 @var{separator-string}
190 ^Z^Zarg-value @var{value-flags}
196 where @var{argument-name} is the name of the argument,
197 @var{separator-string} is text which separates the name from the value
198 for the user's benefit (such as @samp{=}), and @var{value-flags} and
199 @var{the-value} have the same meanings as in a
200 @code{value-history-begin} annotation.
203 @findex field-name-end
206 When printing a structure, @value{GDBN} annotates it as follows:
209 ^Z^Zfield-begin @var{value-flags}
212 @var{separator-string}
219 where @var{field-name} is the name of the field, @var{separator-string}
220 is text which separates the name from the value for the user's benefit
221 (such as @samp{=}), and @var{value-flags} and @var{the-value} have the
222 same meanings as in a @code{value-history-begin} annotation.
224 When printing an array, @value{GDBN} annotates it as follows:
227 ^Z^Zarray-section-begin @var{array-index} @var{value-flags}
231 where @var{array-index} is the index of the first element being
232 annotated and @var{value-flags} has the same meaning as in a
233 @code{value-history-begin} annotation. This is followed by any number
234 of elements, where is element can be either a single element:
238 @samp{,} @var{whitespace} ; @r{omitted for the first element}
243 or a repeated element
248 @samp{,} @var{whitespace} ; @r{omitted for the first element}
250 ^Z^Zelt-rep @var{number-of-repetitions}
251 @var{repetition-string}
255 In both cases, @var{the-value} is the output for the value of the
256 element and @var{whitespace} can contain spaces, tabs, and newlines. In
257 the repeated case, @var{number-of-repetitions} is the number of
258 consecutive array elements which contain that value, and
259 @var{repetition-string} is a string which is designed to convey to the
260 user that repetition is being depicted.
262 @findex array-section-end
263 Once all the array elements have been output, the array annotation is
267 ^Z^Zarray-section-end
270 @node Frame Annotations
273 @cindex annotations for frames
274 Whenever @value{GDBN} prints a frame, it annotates it. For example, this applies
275 to frames printed when @value{GDBN} stops, output from commands such as
276 @code{backtrace} or @code{up}, etc.
279 The frame annotation begins with
282 ^Z^Zframe-begin @var{level} @var{address}
287 where @var{level} is the number of the frame (0 is the innermost frame,
288 and other frames have positive numbers), @var{address} is the address of
289 the code executing in that frame, and @var{level-string} is a string
290 designed to convey the level to the user. @var{address} is in the form
291 @samp{0x} followed by one or more lowercase hex digits (note that this
292 does not depend on the language). The frame ends with
299 Between these annotations is the main body of the frame, which can
304 @findex function-call
307 @var{function-call-string}
310 where @var{function-call-string} is text designed to convey to the user
311 that this frame is associated with a function call made by @value{GDBN} to a
312 function in the program being debugged.
315 @findex signal-handler-caller
317 ^Z^Zsignal-handler-caller
318 @var{signal-handler-caller-string}
321 where @var{signal-handler-caller-string} is text designed to convey to
322 the user that this frame is associated with whatever mechanism is used
323 by this operating system to call a signal handler (it is the frame which
324 calls the signal handler, not the frame for the signal handler itself).
329 @findex frame-address
330 @findex frame-address-end
331 This can optionally (depending on whether this is thought of as
332 interesting information for the user to see) begin with
337 ^Z^Zframe-address-end
338 @var{separator-string}
341 where @var{address} is the address executing in the frame (the same
342 address as in the @code{frame-begin} annotation, but printed in a form
343 which is intended for user consumption---in particular, the syntax varies
344 depending on the language), and @var{separator-string} is a string
345 intended to separate this address from what follows for the user's
348 @findex frame-function-name
353 ^Z^Zframe-function-name
359 where @var{function-name} is the name of the function executing in the
360 frame, or @samp{??} if not known, and @var{arguments} are the arguments
361 to the frame, with parentheses around them (each argument is annotated
362 individually as well, @pxref{Value Annotations}).
364 @findex frame-source-begin
365 @findex frame-source-file
366 @findex frame-source-file-end
367 @findex frame-source-line
368 @findex frame-source-end
369 If source information is available, a reference to it is then printed:
372 ^Z^Zframe-source-begin
373 @var{source-intro-string}
374 ^Z^Zframe-source-file
376 ^Z^Zframe-source-file-end
378 ^Z^Zframe-source-line
383 where @var{source-intro-string} separates for the user's benefit the
384 reference from the text which precedes it, @var{filename} is the name of
385 the source file, and @var{line-number} is the line number within that
386 file (the first line is line 1).
389 If @value{GDBN} prints some information about where the frame is from (which
390 library, which load segment, etc.; currently only done on the RS/6000),
398 Then, if source is to actually be displayed for this frame (for example,
399 this is not true for output from the @code{backtrace} command), then a
400 @code{source} annotation (@pxref{Source Annotations}) is displayed. Unlike
401 most annotations, this is output instead of the normal text which would be
402 output, not in addition.
408 @findex display-begin
409 @findex display-number-end
410 @findex display-format
411 @findex display-expression
412 @findex display-expression-end
413 @findex display-value
415 @cindex annotations for display
416 When @value{GDBN} is told to display something using the @code{display} command,
417 the results of the display are annotated:
422 ^Z^Zdisplay-number-end
423 @var{number-separator}
426 ^Z^Zdisplay-expression
428 ^Z^Zdisplay-expression-end
429 @var{expression-separator}
436 where @var{number} is the number of the display, @var{number-separator}
437 is intended to separate the number from what follows for the user,
438 @var{format} includes information such as the size, format, or other
439 information about how the value is being displayed, @var{expression} is
440 the expression being displayed, @var{expression-separator} is intended
441 to separate the expression from the text that follows for the user,
442 and @var{value} is the actual value being displayed.
445 @section Annotation for @value{GDBN} Input
447 @cindex annotations for prompts
448 When @value{GDBN} prompts for input, it annotates this fact so it is possible
449 to know when to send output, when the output from a given command is
452 Different kinds of input each have a different @dfn{input type}. Each
453 input type has three annotations: a @code{pre-} annotation, which
454 denotes the beginning of any prompt which is being output, a plain
455 annotation, which denotes the end of the prompt, and then a @code{post-}
456 annotation which denotes the end of any echo which may (or may not) be
457 associated with the input. For example, the @code{prompt} input type
458 features the following annotations:
473 When @value{GDBN} is prompting for a command (the main @value{GDBN} prompt).
477 @findex post-commands
479 When @value{GDBN} prompts for a set of commands, like in the @code{commands}
480 command. The annotations are repeated for each command which is input.
482 @findex pre-overload-choice
483 @findex overload-choice
484 @findex post-overload-choice
485 @item overload-choice
486 When @value{GDBN} wants the user to select between various overloaded functions.
492 When @value{GDBN} wants the user to confirm a potentially dangerous operation.
494 @findex pre-prompt-for-continue
495 @findex prompt-for-continue
496 @findex post-prompt-for-continue
497 @item prompt-for-continue
498 When @value{GDBN} is asking the user to press return to continue. Note: Don't
499 expect this to work well; instead use @code{set height 0} to disable
500 prompting. This is because the counting of lines is buggy in the
501 presence of annotations.
506 @cindex annotations for errors, warnings and interrupts
513 This annotation occurs right before @value{GDBN} responds to an interrupt.
520 This annotation occurs right before @value{GDBN} responds to an error.
522 Quit and error annotations indicate that any annotations which @value{GDBN} was
523 in the middle of may end abruptly. For example, if a
524 @code{value-history-begin} annotation is followed by a @code{error}, one
525 cannot expect to receive the matching @code{value-history-end}. One
526 cannot expect not to receive it either, however; an error annotation
527 does not necessarily mean that @value{GDBN} is immediately returning all the way
531 A quit or error annotation may be preceded by
537 Any output between that and the quit or error annotation is the error
540 Warning messages are not yet annotated.
541 @c If we want to change that, need to fix warning(), type_error(),
542 @c range_error(), and possibly other places.
544 @node Breakpoint Info
545 @section Information on Breakpoints
547 @cindex annotations for breakpoints
548 The output from the @code{info breakpoints} command is annotated as follows:
550 @findex breakpoints-headers
551 @findex breakpoints-table
553 ^Z^Zbreakpoints-headers
555 ^Z^Zbreakpoints-table
559 where @var{header-entry} has the same syntax as an entry (see below) but
560 instead of containing data, it contains strings which are intended to
561 convey the meaning of each field to the user. This is followed by any
562 number of entries. If a field does not apply for this entry, it is
563 omitted. Fields may contain trailing whitespace. Each entry consists
592 Note that @var{address} is intended for user consumption---the syntax
593 varies depending on the language.
597 @findex breakpoints-table-end
599 ^Z^Zbreakpoints-table-end
603 @section Invalidation Notices
605 @cindex annotations for invalidation messages
606 The following annotations say that certain pieces of state may have
610 @findex frames-invalid
611 @item ^Z^Zframes-invalid
613 The frames (for example, output from the @code{backtrace} command) may
616 @findex breakpoints-invalid
617 @item ^Z^Zbreakpoints-invalid
619 The breakpoints may have changed. For example, the user just added or
620 deleted a breakpoint.
623 @node Annotations for Running
624 @section Running the Program
625 @cindex annotations for running programs
629 When the program starts executing due to a @value{GDBN} command such as
630 @code{step} or @code{continue},
636 is output. When the program stops,
642 is output. Before the @code{stopped} annotation, a variety of
643 annotations describe how the program stopped.
647 @item ^Z^Zexited @var{exit-status}
648 The program exited, and @var{exit-status} is the exit status (zero for
649 successful exit, otherwise nonzero).
653 @findex signal-name-end
654 @findex signal-string
655 @findex signal-string-end
657 The program exited with a signal. After the @code{^Z^Zsignalled}, the
658 annotation continues:
668 ^Z^Zsignal-string-end
673 where @var{name} is the name of the signal, such as @code{SIGILL} or
674 @code{SIGSEGV}, and @var{string} is the explanation of the signal, such
675 as @code{Illegal Instruction} or @code{Segmentation fault}.
676 @var{intro-text}, @var{middle-text}, and @var{end-text} are for the
677 user's benefit and have no particular format.
681 The syntax of this annotation is just like @code{signalled}, but @value{GDBN} is
682 just saying that the program received the signal, not that it was
686 @item ^Z^Zbreakpoint @var{number}
687 The program hit breakpoint number @var{number}.
690 @item ^Z^Zwatchpoint @var{number}
691 The program hit watchpoint number @var{number}.
694 @node Source Annotations
695 @section Displaying Source
696 @cindex annotations for source display
699 The following annotation is used instead of displaying source code:
702 ^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr}
705 where @var{filename} is an absolute file name indicating which source
706 file, @var{line} is the line number within that file (where 1 is the
707 first line in the file), @var{character} is the character position
708 within the file (where 0 is the first character in the file) (for most
709 debug formats this will necessarily point to the beginning of a line),
710 @var{middle} is @samp{middle} if @var{addr} is in the middle of the
711 line, or @samp{beg} if @var{addr} is at the beginning of the line, and
712 @var{addr} is the address in the target program associated with the
713 source which is being displayed. @var{addr} is in the form @samp{0x}
714 followed by one or more lowercase hex digits (note that this does not
715 depend on the language).
718 @section Annotations We Might Want in the Future
722 the target might have changed (registers, heap contents, or
723 execution status). For performance, we might eventually want
724 to hit `registers-invalid' and `all-registers-invalid' with
727 - systematic annotation for set/show parameters (including
728 invalidation notices).
730 - similarly, `info' returns a list of candidates for invalidation