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