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