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