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