* annotate.texi (Frame Annotations): Fix a cross-reference.
[deliverable/binutils-gdb.git] / gdb / doc / annotate.texi
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
6 @c @c %**end of header
7
8 @c @set EDITION 0.5
9 @c @set DATE May 1994
10
11 @c @ifinfo
12 @c This file documents GDB annotations.
13
14 @c This is Edition @value{EDITION}, @value{DATE}, of @cite{GDB
15 @c Annotations}. Copyright 1994 Free Software Foundation
16
17 @c Permission is granted to make and distribute verbatim copies of
18 @c this manual provided the copyright notice and this permission notice
19 @c are preserved on all copies.
20 @c @end ignore
21
22 @c @ignore
23 @c Permission is granted to process this file through TeX and print the
24 @c results, provided the printed document carries copying permission
25 @c notice identical to this one except for the removal of this paragraph
26 @c (this paragraph not being relevant to the printed manual).
27
28 @c @end ignore
29 @c Permission is granted to copy and distribute modified versions of this
30 @c manual under the conditions for verbatim copying, provided also that the
31 @c entire resulting derived work is distributed under the terms of a
32 @c permission notice identical to this one.
33
34 @c Permission is granted to copy and distribute translations of this manual
35 @c into another language, under the above conditions for modified versions.
36 @c @end ifinfo
37
38 @c @titlepage
39 @c @title GDB Annotations
40 @c @subtitle Edition @value{EDITION}
41 @c @subtitle @value{DATE}
42 @c @author Cygnus Support
43 @c @page
44 @c @vskip 0pt plus 1filll
45 @c Permission is granted to make and distribute verbatim copies of
46 @c this manual provided the copyright notice and this permission notice
47 @c are preserved on all copies.
48
49 @c Copyright @copyright{} 1994 Free Software Foundation
50 @c @end titlepage
51
52 @c @ifinfo
53 @c @node Top
54 @c @top GDB Annotations
55
56 @syncodeindex fn cp
57
58 @node Annotations
59 @chapter @value{GDBN} Annotations
60
61 This chapter describes annotations in @value{GDBN}. Annotations are
62 designed to interface @value{GDBN} to graphical user interfaces or other
63 similar programs which want to interact with @value{GDBN} at a
64 relatively high level.
65
66 @ignore
67 This is Edition @value{EDITION}, @value{DATE}.
68 @end ignore
69
70 @menu
71 * Annotations Overview:: What annotations are; the general syntax.
72 * Server Prefix:: Issuing a command without affecting user state.
73 * Value Annotations:: Values are marked as such.
74 * Frame Annotations:: Stack frames are annotated.
75 * Displays:: @value{GDBN} can be told to display something periodically.
76 * Prompting:: Annotations marking @value{GDBN}'s need for input.
77 * Errors:: Annotations for error messages.
78 * Breakpoint Info:: Information on breakpoints.
79 * Invalidation:: Some annotations describe things now invalid.
80 * Annotations for Running::
81 Whether the program is running, how it stopped, etc.
82 * Source Annotations:: Annotations describing source code.
83 * TODO:: Annotations which might be added in the future.
84 @end menu
85
86 @node Annotations Overview
87 @section What is an Annotation?
88 @cindex annotations
89
90 To produce annotations, start @value{GDBN} with the @code{--annotate=2} option.
91
92 Annotations start with a newline character, two @samp{control-z}
93 characters, and the name of the annotation. If there is no additional
94 information associated with this annotation, the name of the annotation
95 is followed immediately by a newline. If there is additional
96 information, the name of the annotation is followed by a space, the
97 additional information, and a newline. The additional information
98 cannot contain newline characters.
99
100 Any output not beginning with a newline and two @samp{control-z}
101 characters denotes literal output from @value{GDBN}. Currently there is
102 no need for @value{GDBN} to output a newline followed by two
103 @samp{control-z} characters, but if there was such a need, the
104 annotations could be extended with an @samp{escape} annotation which
105 means those three characters as output.
106
107 A simple example of starting up @value{GDBN} with annotations is:
108
109 @smallexample
110 $ gdb --annotate=2
111 GNU GDB 5.0
112 Copyright 2000 Free Software Foundation, Inc.
113 GDB is free software, covered by the GNU General Public License,
114 and you are welcome to change it and/or distribute copies of it
115 under certain conditions.
116 Type "show copying" to see the conditions.
117 There is absolutely no warranty for GDB. Type "show warranty"
118 for details.
119 This GDB was configured as "sparc-sun-sunos4.1.3"
120
121 ^Z^Zpre-prompt
122 (gdb)
123 ^Z^Zprompt
124 quit
125
126 ^Z^Zpost-prompt
127 $
128 @end smallexample
129
130 Here @samp{quit} is input to @value{GDBN}; the rest is output from
131 @value{GDBN}. The three lines beginning @samp{^Z^Z} (where @samp{^Z}
132 denotes a @samp{control-z} character) are annotations; the rest is
133 output from @value{GDBN}.
134
135 @node Server Prefix
136 @section The Server Prefix
137 @cindex server prefix for annotations
138
139 To issue a command to @value{GDBN} without affecting certain aspects of
140 the state which is seen by users, prefix it with @samp{server }. This
141 means that this command will not affect the command history, nor will it
142 affect @value{GDBN}'s notion of which command to repeat if @key{RET} is
143 pressed on a line by itself.
144
145 The server prefix does not affect the recording of values into the value
146 history; to print a value without recording it into the value history,
147 use the @code{output} command instead of the @code{print} command.
148
149 @node Value Annotations
150 @section Values
151
152 @cindex annotations for values
153 When a value is printed in various contexts, @value{GDBN} uses
154 annotations to delimit the value from the surrounding text.
155
156 @findex value-history-begin
157 @findex value-history-value
158 @findex value-history-end
159 If a value is printed using @code{print} and added to the value history,
160 the annotation looks like
161
162 @smallexample
163 ^Z^Zvalue-history-begin @var{history-number} @var{value-flags}
164 @var{history-string}
165 ^Z^Zvalue-history-value
166 @var{the-value}
167 ^Z^Zvalue-history-end
168 @end smallexample
169
170 where @var{history-number} is the number it is getting in the value
171 history, @var{history-string} is a string, such as @samp{$5 = }, which
172 introduces the value to the user, @var{the-value} is the output
173 corresponding to the value itself, and @var{value-flags} is @samp{*} for
174 a value which can be dereferenced and @samp{-} for a value which cannot.
175
176 @findex value-begin
177 @findex value-end
178 If the value is not added to the value history (it is an invalid float
179 or it is printed with the @code{output} command), the annotation is similar:
180
181 @smallexample
182 ^Z^Zvalue-begin @var{value-flags}
183 @var{the-value}
184 ^Z^Zvalue-end
185 @end smallexample
186
187 @findex arg-begin
188 @findex arg-name-end
189 @findex arg-value
190 @findex arg-end
191 When @value{GDBN} prints an argument to a function (for example, in the output
192 from the @code{backtrace} command), it annotates it as follows:
193
194 @smallexample
195 ^Z^Zarg-begin
196 @var{argument-name}
197 ^Z^Zarg-name-end
198 @var{separator-string}
199 ^Z^Zarg-value @var{value-flags}
200 @var{the-value}
201 ^Z^Zarg-end
202 @end smallexample
203
204 where @var{argument-name} is the name of the argument,
205 @var{separator-string} is text which separates the name from the value
206 for the user's benefit (such as @samp{=}), and @var{value-flags} and
207 @var{the-value} have the same meanings as in a
208 @code{value-history-begin} annotation.
209
210 @findex field-begin
211 @findex field-name-end
212 @findex field-value
213 @findex field-end
214 When printing a structure, @value{GDBN} annotates it as follows:
215
216 @smallexample
217 ^Z^Zfield-begin @var{value-flags}
218 @var{field-name}
219 ^Z^Zfield-name-end
220 @var{separator-string}
221 ^Z^Zfield-value
222 @var{the-value}
223 ^Z^Zfield-end
224 @end smallexample
225
226 where @var{field-name} is the name of the field, @var{separator-string}
227 is text which separates the name from the value for the user's benefit
228 (such as @samp{=}), and @var{value-flags} and @var{the-value} have the
229 same meanings as in a @code{value-history-begin} annotation.
230
231 When printing an array, @value{GDBN} annotates it as follows:
232
233 @smallexample
234 ^Z^Zarray-section-begin @var{array-index} @var{value-flags}
235 @end smallexample
236
237 where @var{array-index} is the index of the first element being
238 annotated and @var{value-flags} has the same meaning as in a
239 @code{value-history-begin} annotation. This is followed by any number
240 of elements, where is element can be either a single element:
241
242 @findex elt
243 @smallexample
244 @samp{,} @var{whitespace} ; @r{omitted for the first element}
245 @var{the-value}
246 ^Z^Zelt
247 @end smallexample
248
249 or a repeated element
250
251 @findex elt-rep
252 @findex elt-rep-end
253 @smallexample
254 @samp{,} @var{whitespace} ; @r{omitted for the first element}
255 @var{the-value}
256 ^Z^Zelt-rep @var{number-of-repititions}
257 @var{repetition-string}
258 ^Z^Zelt-rep-end
259 @end smallexample
260
261 In both cases, @var{the-value} is the output for the value of the
262 element and @var{whitespace} can contain spaces, tabs, and newlines. In
263 the repeated case, @var{number-of-repititons} is the number of
264 consecutive array elements which contain that value, and
265 @var{repetition-string} is a string which is designed to convey to the
266 user that repitition is being depicted.
267
268 @findex array-section-end
269 Once all the array elements have been output, the array annotation is
270 ended with
271
272 @smallexample
273 ^Z^Zarray-section-end
274 @end smallexample
275
276 @node Frame Annotations
277 @section Frames
278
279 @cindex annotations for frames
280 Whenever @value{GDBN} prints a frame, it annotates it. For example, this applies
281 to frames printed when @value{GDBN} stops, output from commands such as
282 @code{backtrace} or @code{up}, etc.
283
284 @findex frame-begin
285 The frame annotation begins with
286
287 @smallexample
288 ^Z^Zframe-begin @var{level} @var{address}
289 @var{level-string}
290 @end smallexample
291
292 where @var{level} is the number of the frame (0 is the innermost frame,
293 and other frames have positive numbers), @var{address} is the address of
294 the code executing in that frame, and @var{level-string} is a string
295 designed to convey the level to the user. @var{address} is in the form
296 @samp{0x} followed by one or more lowercase hex digits (note that this
297 does not depend on the language). The frame ends with
298
299 @findex frame-end
300 @smallexample
301 ^Z^Zframe-end
302 @end smallexample
303
304 Between these annotations is the main body of the frame, which can
305 consist of
306
307 @itemize @bullet
308 @item
309 @findex function-call
310 @smallexample
311 ^Z^Zfunction-call
312 @var{function-call-string}
313 @end smallexample
314
315 where @var{function-call-string} is text designed to convey to the user
316 that this frame is associated with a function call made by @value{GDBN} to a
317 function in the program being debugged.
318
319 @item
320 @findex signal-handler-caller
321 @smallexample
322 ^Z^Zsignal-handler-caller
323 @var{signal-handler-caller-string}
324 @end smallexample
325
326 where @var{signal-handler-caller-string} is text designed to convey to
327 the user that this frame is associated with whatever mechanism is used
328 by this operating system to call a signal handler (it is the frame which
329 calls the signal handler, not the frame for the signal handler itself).
330
331 @item
332 A normal frame.
333
334 @findex frame-address
335 @findex frame-address-end
336 This can optionally (depending on whether this is thought of as
337 interesting information for the user to see) begin with
338
339 @smallexample
340 ^Z^Zframe-address
341 @var{address}
342 ^Z^Zframe-address-end
343 @var{separator-string}
344 @end smallexample
345
346 where @var{address} is the address executing in the frame (the same
347 address as in the @code{frame-begin} annotation, but printed in a form
348 which is intended for user consumption---in particular, the syntax varies
349 depending on the language), and @var{separator-string} is a string
350 intended to separate this address from what follows for the user's
351 benefit.
352
353 @findex frame-function-name
354 @findex frame-args
355 Then comes
356
357 @smallexample
358 ^Z^Zframe-function-name
359 @var{function-name}
360 ^Z^Zframe-args
361 @var{arguments}
362 @end smallexample
363
364 where @var{function-name} is the name of the function executing in the
365 frame, or @samp{??} if not known, and @var{arguments} are the arguments
366 to the frame, with parentheses around them (each argument is annotated
367 individually as well, @pxref{Value Annotations}).
368
369 @findex frame-source-begin
370 @findex frame-source-file
371 @findex frame-source-file-end
372 @findex frame-source-line
373 @findex frame-source-end
374 If source information is available, a reference to it is then printed:
375
376 @smallexample
377 ^Z^Zframe-source-begin
378 @var{source-intro-string}
379 ^Z^Zframe-source-file
380 @var{filename}
381 ^Z^Zframe-source-file-end
382 :
383 ^Z^Zframe-source-line
384 @var{line-number}
385 ^Z^Zframe-source-end
386 @end smallexample
387
388 where @var{source-intro-string} separates for the user's benefit the
389 reference from the text which precedes it, @var{filename} is the name of
390 the source file, and @var{line-number} is the line number within that
391 file (the first line is line 1).
392
393 @findex frame-where
394 If @value{GDBN} prints some information about where the frame is from (which
395 library, which load segment, etc.; currently only done on the RS/6000),
396 it is annotated with
397
398 @smallexample
399 ^Z^Zframe-where
400 @var{information}
401 @end smallexample
402
403 Then, if source is to actually be displayed for this frame (for example,
404 this is not true for output from the @code{backtrace} command), then a
405 @code{source} annotation (@pxref{Source Annotations}) is displayed. Unlike
406 most annotations, this is output instead of the normal text which would be
407 output, not in addition.
408 @end itemize
409
410 @node Displays
411 @section Displays
412
413 @findex display-begin
414 @findex display-number-end
415 @findex display-format
416 @findex display-expression
417 @findex display-expression-end
418 @findex display-value
419 @findex display-end
420 @cindex annotations for display
421 When @value{GDBN} is told to display something using the @code{display} command,
422 the results of the display are annotated:
423
424 @smallexample
425 ^Z^Zdisplay-begin
426 @var{number}
427 ^Z^Zdisplay-number-end
428 @var{number-separator}
429 ^Z^Zdisplay-format
430 @var{format}
431 ^Z^Zdisplay-expression
432 @var{expression}
433 ^Z^Zdisplay-expression-end
434 @var{expression-separator}
435 ^Z^Zdisplay-value
436 @var{value}
437 ^Z^Zdisplay-end
438 @end smallexample
439
440 where @var{number} is the number of the display, @var{number-separator}
441 is intended to separate the number from what follows for the user,
442 @var{format} includes information such as the size, format, or other
443 information about how the value is being displayed, @var{expression} is
444 the expression being displayed, @var{expression-separator} is intended
445 to separate the expression from the text that follows for the user,
446 and @var{value} is the actual value being displayed.
447
448 @node Prompting
449 @section Annotation for @value{GDBN} Input
450
451 @cindex annotations for prompts
452 When @value{GDBN} prompts for input, it annotates this fact so it is possible
453 to know when to send output, when the output from a given command is
454 over, etc.
455
456 Different kinds of input each have a different @dfn{input type}. Each
457 input type has three annotations: a @code{pre-} annotation, which
458 denotes the beginning of any prompt which is being output, a plain
459 annotation, which denotes the end of the prompt, and then a @code{post-}
460 annotation which denotes the end of any echo which may (or may not) be
461 associated with the input. For example, the @code{prompt} input type
462 features the following annotations:
463
464 @smallexample
465 ^Z^Zpre-prompt
466 ^Z^Zprompt
467 ^Z^Zpost-prompt
468 @end smallexample
469
470 The input types are
471
472 @table @code
473 @findex pre-prompt
474 @findex prompt
475 @findex post-prompt
476 @item prompt
477 When @value{GDBN} is prompting for a command (the main @value{GDBN} prompt).
478
479 @findex pre-commands
480 @findex commands
481 @findex post-commands
482 @item commands
483 When @value{GDBN} prompts for a set of commands, like in the @code{commands}
484 command. The annotations are repeated for each command which is input.
485
486 @findex pre-overload-choice
487 @findex overload-choice
488 @findex post-overload-choice
489 @item overload-choice
490 When @value{GDBN} wants the user to select between various overloaded functions.
491
492 @findex pre-query
493 @findex query
494 @findex post-query
495 @item query
496 When @value{GDBN} wants the user to confirm a potentially dangerous operation.
497
498 @findex pre-prompt-for-continue
499 @findex prompt-for-continue
500 @findex post-prompt-for-continue
501 @item prompt-for-continue
502 When @value{GDBN} is asking the user to press return to continue. Note: Don't
503 expect this to work well; instead use @code{set height 0} to disable
504 prompting. This is because the counting of lines is buggy in the
505 presence of annotations.
506 @end table
507
508 @node Errors
509 @section Errors
510 @cindex annotations for errors, warnings and interrupts
511
512 @findex quit
513 @smallexample
514 ^Z^Zquit
515 @end smallexample
516
517 This annotation occurs right before @value{GDBN} responds to an interrupt.
518
519 @findex error
520 @smallexample
521 ^Z^Zerror
522 @end smallexample
523
524 This annotation occurs right before @value{GDBN} responds to an error.
525
526 Quit and error annotations indicate that any annotations which @value{GDBN} was
527 in the middle of may end abruptly. For example, if a
528 @code{value-history-begin} annotation is followed by a @code{error}, one
529 cannot expect to receive the matching @code{value-history-end}. One
530 cannot expect not to receive it either, however; an error annotation
531 does not necessarily mean that @value{GDBN} is immediately returning all the way
532 to the top level.
533
534 @findex error-begin
535 A quit or error annotation may be preceded by
536
537 @smallexample
538 ^Z^Zerror-begin
539 @end smallexample
540
541 Any output between that and the quit or error annotation is the error
542 message.
543
544 Warning messages are not yet annotated.
545 @c If we want to change that, need to fix warning(), type_error(),
546 @c range_error(), and possibly other places.
547
548 @node Breakpoint Info
549 @section Information on Breakpoints
550
551 @cindex annotations for breakpoints
552 The output from the @code{info breakpoints} command is annotated as follows:
553
554 @findex breakpoints-headers
555 @findex breakpoints-table
556 @smallexample
557 ^Z^Zbreakpoints-headers
558 @var{header-entry}
559 ^Z^Zbreakpoints-table
560 @end smallexample
561
562 where @var{header-entry} has the same syntax as an entry (see below) but
563 instead of containing data, it contains strings which are intended to
564 convey the meaning of each field to the user. This is followed by any
565 number of entries. If a field does not apply for this entry, it is
566 omitted. Fields may contain trailing whitespace. Each entry consists
567 of:
568
569 @findex record
570 @findex field
571 @smallexample
572 ^Z^Zrecord
573 ^Z^Zfield 0
574 @var{number}
575 ^Z^Zfield 1
576 @var{type}
577 ^Z^Zfield 2
578 @var{disposition}
579 ^Z^Zfield 3
580 @var{enable}
581 ^Z^Zfield 4
582 @var{address}
583 ^Z^Zfield 5
584 @var{what}
585 ^Z^Zfield 6
586 @var{frame}
587 ^Z^Zfield 7
588 @var{condition}
589 ^Z^Zfield 8
590 @var{ignore-count}
591 ^Z^Zfield 9
592 @var{commands}
593 @end smallexample
594
595 Note that @var{address} is intended for user consumption---the syntax
596 varies depending on the language.
597
598 The output ends with
599
600 @findex breakpoints-table-end
601 @smallexample
602 ^Z^Zbreakpoints-table-end
603 @end smallexample
604
605 @node Invalidation
606 @section Invalidation Notices
607
608 @cindex annotations for invalidation messages
609 The following annotations say that certain pieces of state may have
610 changed.
611
612 @table @code
613 @findex frames-invalid
614 @item ^Z^Zframes-invalid
615
616 The frames (for example, output from the @code{backtrace} command) may
617 have changed.
618
619 @findex breakpoints-invalid
620 @item ^Z^Zbreakpoints-invalid
621
622 The breakpoints may have changed. For example, the user just added or
623 deleted a breakpoint.
624 @end table
625
626 @node Annotations for Running
627 @section Running the Program
628 @cindex annotations for running programs
629
630 @findex starting
631 @findex stopping
632 When the program starts executing due to a @value{GDBN} command such as
633 @code{step} or @code{continue},
634
635 @smallexample
636 ^Z^Zstarting
637 @end smallexample
638
639 is output. When the program stops,
640
641 @smallexample
642 ^Z^Zstopped
643 @end smallexample
644
645 is output. Before the @code{stopped} annotation, a variety of
646 annotations describe how the program stopped.
647
648 @table @code
649 @findex exited
650 @item ^Z^Zexited @var{exit-status}
651 The program exited, and @var{exit-status} is the exit status (zero for
652 successful exit, otherwise nonzero).
653
654 @findex signalled
655 @findex signal-name
656 @findex signal-name-end
657 @findex signal-string
658 @findex signal-string-end
659 @item ^Z^Zsignalled
660 The program exited with a signal. After the @code{^Z^Zsignalled}, the
661 annotation continues:
662
663 @smallexample
664 @var{intro-text}
665 ^Z^Zsignal-name
666 @var{name}
667 ^Z^Zsignal-name-end
668 @var{middle-text}
669 ^Z^Zsignal-string
670 @var{string}
671 ^Z^Zsignal-string-end
672 @var{end-text}
673 @end smallexample
674
675 where @var{name} is the name of the signal, such as @code{SIGILL} or
676 @code{SIGSEGV}, and @var{string} is the explanation of the signal, such
677 as @code{Illegal Instruction} or @code{Segmentation fault}.
678 @var{intro-text}, @var{middle-text}, and @var{end-text} are for the
679 user's benefit and have no particular format.
680
681 @findex signal
682 @item ^Z^Zsignal
683 The syntax of this annotation is just like @code{signalled}, but @value{GDBN} is
684 just saying that the program received the signal, not that it was
685 terminated with it.
686
687 @findex breakpoint
688 @item ^Z^Zbreakpoint @var{number}
689 The program hit breakpoint number @var{number}.
690
691 @findex watchpoint
692 @item ^Z^Zwatchpoint @var{number}
693 The program hit watchpoint number @var{number}.
694 @end table
695
696 @node Source Annotations
697 @section Displaying Source
698 @cindex annotations for source display
699
700 @findex source
701 The following annotation is used instead of displaying source code:
702
703 @smallexample
704 ^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr}
705 @end smallexample
706
707 where @var{filename} is an absolute file name indicating which source
708 file, @var{line} is the line number within that file (where 1 is the
709 first line in the file), @var{character} is the character position
710 within the file (where 0 is the first character in the file) (for most
711 debug formats this will necessarily point to the beginning of a line),
712 @var{middle} is @samp{middle} if @var{addr} is in the middle of the
713 line, or @samp{beg} if @var{addr} is at the beginning of the line, and
714 @var{addr} is the address in the target program associated with the
715 source which is being displayed. @var{addr} is in the form @samp{0x}
716 followed by one or more lowercase hex digits (note that this does not
717 depend on the language).
718
719 @node TODO
720 @section Annotations We Might Want in the Future
721
722 @format
723 - target-invalid
724 the target might have changed (registers, heap contents, or
725 execution status). For performance, we might eventually want
726 to hit `registers-invalid' and `all-registers-invalid' with
727 greater precision
728
729 - systematic annotation for set/show parameters (including
730 invalidation notices).
731
732 - similarly, `info' returns a list of candidates for invalidation
733 notices.
734 @end format
735
736 @ignore
737 @node Index
738 @unnumbered Index
739
740 @printindex fn
741 @end ignore
742
743 @c @bye
This page took 0.045568 seconds and 5 git commands to generate.