* annotate.texi: New file, to document annotations.
[deliverable/binutils-gdb.git] / gdb / doc / annotate.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename annotate.info
4 @settitle GDB Annotations
5 @setchapternewpage off
6 @c %**end of header
7
8 @set EDITION 0.4
9 @set DATE April 1994
10
11 @ifinfo
12 This file documents GDB annotations.
13
14 This is Edition @value{EDITION}, @value{DATE}, of @cite{GDB
15 Annotations}. Copyright 1994 Free Software Foundation
16
17 Permission is granted to make and distribute verbatim copies of
18 this manual provided the copyright notice and this permission notice
19 are preserved on all copies.
20
21 @ignore
22 Permission is granted to process this file through TeX and print the
23 results, provided the printed document carries copying permission
24 notice identical to this one except for the removal of this paragraph
25 (this paragraph not being relevant to the printed manual).
26
27 @end ignore
28 Permission is granted to copy and distribute modified versions of this
29 manual under the conditions for verbatim copying, provided also that the
30 entire resulting derived work is distributed under the terms of a
31 permission notice identical to this one.
32
33 Permission is granted to copy and distribute translations of this manual
34 into another language, under the above conditions for modified versions.
35 @end ifinfo
36
37 @titlepage
38 @title GDB Annotations
39 @subtitle Edition @value{EDITION}
40 @subtitle @value{DATE}
41 @author Cygnus Support
42 @page
43 @vskip 0pt plus 1filll
44 Permission is granted to make and distribute verbatim copies of
45 this manual provided the copyright notice and this permission notice
46 are preserved on all copies.
47
48 Copyright @copyright{} 1994 Free Software Foundation
49 @end titlepage
50
51 @ifinfo
52 @node Top
53 @top GDB Annotations
54
55 This file describes annotations in GDB, the GNU symbolic debugger.
56 Annotations are designed to interface GDB to graphical user interfaces
57 or other similar programs which want to interact with GDB at a
58 relatively high level.
59
60 This is Edition @value{EDITION}, @value{DATE}.
61
62 @menu
63 * General:: What annotations are; the general syntax.
64 * Server:: Issuing a command without affecting user state.
65 * Values:: Values are marked as such.
66 * Prompting:: GDB annotations marking GDB's need for input.
67 * Breakpoint Info:: Information on breakpoints.
68 * Invalidation:: Some annotations describe things now invalid.
69 * Source:: Annotations describing source code.
70 @end menu
71 @end ifinfo
72
73 @node General
74 @chapter What is an Annotation?
75
76 To produce annotations, start GDB with the @code{--annotate=2} option.
77
78 Annotations start with a newline character, two @samp{control-z}
79 characters, and the name of the annotation. If there is no additional
80 information associated with this annotation, the name of the annotation
81 is followed immediately by a newline. If there is additional
82 information, the name of the annotation is followed by a space, the
83 additional information, and a newline. The additional information
84 cannot contain newline characters.
85
86 Any output not beginning with a newline and two @samp{control-z}
87 characters denotes literal output from GDB. Currently there is no need
88 for GDB to output a newline followed by two @samp{control-z} characters,
89 but if there was such a need, the annotations could be extended with an
90 @samp{escape} annotation which means those three characters as output.
91
92 A simple example of starting up GDB with annotations is:
93
94 @example
95 $ gdb --annotate=2
96 GDB is free software and you are welcome to distribute copies of it
97 under certain conditions; type "show copying" to see the conditions.
98 There is absolutely no warranty for GDB; type "show warranty" for details.
99 GDB 4.12.3 (sparc-sun-sunos4.1.3),
100 Copyright 1994 Free Software Foundation, Inc.
101
102 ^Z^Zpre-prompt
103 (gdb)
104 ^Z^Zprompt
105 quit
106
107 ^Z^Zpost-prompt
108 $
109 @end example
110
111 Here @samp{quit} is input to GDB; the rest is output from GDB. The three
112 lines beginning @samp{^Z^Z} (where @samp{^Z} denotes a @samp{control-z}
113 character) are annotations; the rest is output from GDB.
114
115 @node Server
116 @chapter The Server Prefix
117
118 To issue a command to GDB without affecting certain aspects of the state
119 which is seen by users, prefix it with @samp{server }. This means that
120 this command will not affect the command history, nor will it affect
121 GDB's notion of which command to repeat if @key{RET} is pressed on a
122 line by itself.
123
124 The server prefix does not affect the recording of values into the value
125 history; to print a value without recording it into the value history,
126 use the @code{output} command instead of the @code{print} command.
127
128 @node Values
129 @chapter Values
130
131 When a value is printed in various contexts, GDB uses annotations to
132 delimit the value from the surrounding text.
133
134 If a value is printed using @code{print} and added to the value history,
135 the annotation looks like
136
137 @example
138 ^Z^Zvalue-history-begin @var{history-number} @var{value-flags}
139 @var{history-string}
140 ^Z^Zvalue-history-value
141 @var{the-value}
142 ^Z^Zvalue-history-end
143 @end example
144
145 where @var{history-number} is the number it is getting in the value
146 history, @var{history-string} is a string, such as @samp{$5 = }, which
147 introduces the value to the user, @var{the-value} is the output
148 corresponding to the value itself, and @var{value-flags} is @samp{*} for
149 a value which can be dereferenced and @samp{-} for a value which cannot.
150
151 If the value is not added to the value history (it is an invalid float
152 or it is printed with the @code{output} command), the annotation is similar:
153
154 @example
155 ^Z^Zvalue-begin @var{value-flags}
156 @var{the-value}
157 ^Z^Zvalue-end
158 @end example
159
160 When GDB prints an argument to a function (for example, in the output
161 from the @code{backtrace} command), it annotates it as follows:
162
163 @example
164 ^Z^Zarg-begin
165 @var{argument-name}
166 ^Z^Zarg-name-end
167 @var{separator-string}
168 ^Z^Zarg-value @var{value-flags}
169 @var{the-value}
170 ^Z^Zarg-end
171 @end example
172
173 where @var{argument-name} is the name of the argument,
174 @var{separator-string} is text which separates the name from the value
175 for the user's benefit (such as @samp{=}), and @var{value-flags} and
176 @var{the-value} have the same meanings as in a
177 @code{value-history-begin} annotation.
178
179 When printing a structure, GDB annotates it as follows:
180
181 @example
182 ^Z^Zfield-begin @var{value-flags}
183 @var{field-name}
184 ^Z^Zfield-name-end
185 @var{separator-string}
186 ^Z^Zfield-value
187 @var{the-value}
188 ^Z^Zfield-end
189 @end example
190
191 where @var{field-name} is the name of the field, @var{separator-string}
192 is text which separates the name from the value for the user's benefit
193 (such as @samp{=}), and @var{value-flags} and @var{the-value} have the
194 same meanings as in a @code{value-history-begin} annotation.
195
196 When printing an array, GDB annotates it as follows:
197
198 @example
199 ^Z^Zarray-section-begin @var{array-index} @var{value-flags}
200 @end example
201
202 where @var{array-index} is the index of the first element being
203 annotated and @var{value-flags} has the same meaning as in a
204 @code{value-history-begin} annotation. This is followed by any number
205 of elements, where is element can be either a single element:
206
207 @example
208 @samp{,} @var{whitespace} ; @r{omitted for the first element}
209 @var{the-value}
210 ^Z^Zelt
211 @end example
212
213 or a repeated element
214
215 @example
216 @samp{,} @var{whitespace} ; @r{omitted for the first element}
217 @var{the-value}
218 ^Z^Zelt-rep @var{number-of-repititions}
219 @var{repetition-string}
220 ^Z^Zelt-rep-end
221 @end example
222
223 In both cases, @var{the-value} is the output for the value of the
224 element and @var{whitespace} can contain spaces, tabs, and newlines. In
225 the repeated case, @var{number-of-repititons} is the number of
226 consecutive array elements which contain that value, and
227 @var{repetition-string} is a string which is designed to convey to the
228 user that repitition is being depicted.
229
230 Once all the array elements have been output, the array annotation is
231 ended with
232
233 @example
234 ^Z^Zarray-section-end
235 @end example
236
237 @node Prompting
238 @chapter Annotation for GDB Input
239
240 When GDB prompts for input, it annotates this fact so it is possible
241 to know when to send output, when the output from a given command is
242 over, etc.
243
244 Different kinds of input each have a different @dfn{input type}. Each
245 input type has three annotations: a @code{pre-} annotation, which
246 denotes the beginning of any prompt which is being output, a plain
247 annotation, which denotes the end of the prompt, and then a @code{post-}
248 annotation which denotes the end of any echo which may (or may not) be
249 associated with the input. For example, the @code{prompt} input type
250 features the following annotations:
251
252 @example
253 ^Z^Zpre-prompt
254 ^Z^Zprompt
255 ^Z^Zpost-prompt
256 @end example
257
258 The input types are
259
260 @table @code
261 @item prompt
262 When GDB is prompting for a command (the main GDB prompt).
263
264 @item commands
265 When GDB prompts for a set of commands, like in the @code{commands}
266 command. The annotations are repeated for each command which is input.
267
268 @item overload-choice
269 When GDB wants the user to select between various overloaded functions.
270
271 @item query
272 When GDB wants the user to confirm a potentially dangerous operation.
273
274 @item prompt-for-continue
275 When GDB is asking the user to press return to continue. Note: Don't
276 expect this to work well; instead use @code{set height 0} to disable
277 prompting. This is because the counting of lines is buggy in the
278 presence of annotations.
279 @end table
280
281 @node Breakpoint Info
282 @chapter Information on Breakpoints
283
284 The output from the @code{info breakpoints} command is annotated as follows:
285
286 @example
287 ^Z^Zbreakpoints-headers
288 @var{headers}
289 ^Z^Zbreakpoints-table
290 @end example
291
292 where @var{headers} is a string which is designed to convey to the user
293 the order and significance of the fields. This is followed by any
294 number of entries. Each entry beings with a @code{field 0} annotation.
295 Some fields can be omitted if they don't apply for this entry. Fields
296 have trailing whitespace so that if they are printed in order in a
297 fixed-width font, they match up with the headers. The fields for an
298 entry are:
299
300 @example
301 ^Z^Zfield 0
302 @var{number}
303 ^Z^Zfield 1
304 @var{type}
305 ^Z^Zfield 2
306 @var{disposition}
307 ^Z^Zfield 3
308 @var{enable}
309 ^Z^Zfield 4
310 @var{address}
311 ^Z^Zfield 5
312 @var{what}
313 ^Z^Zfield 6
314 @var{frame}
315 ^Z^Zfield 7
316 @var{condition}
317 ^Z^Zfield 8
318 @var{ignore-count}
319 ^Z^Zfield 9
320 @var{commands}
321 @end example
322
323 The output ends with
324
325 @example
326 ^Z^Zbreakpoints-table-end
327 @end example
328
329 @node Invalidation
330 @chapter Invalidation Notices
331
332 The following annotations say that certain pieces of state may have
333 changed.
334
335 @table @code
336 @item ^Z^Zframes-invalid
337
338 The frames (for example, output from the @code{backtrace} command) may
339 have changed.
340
341 @item ^Z^Zbreakpoints-invalid
342
343 The breakpoints may have changed. For example, the user just added or
344 deleted a breakpoint.
345 @end table
346
347 @node Source
348 @chapter Displaying Source
349
350 The following annotation is used instead of displaying source code:
351
352 @example
353 ^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr}
354 @end example
355
356 where @var{filename} is an absolute file name indicating which source
357 file, @var{line} is the line number within that file (where 1 is the
358 first line in the file), @var{character} is the character position
359 within the file (where 0 is the first character in the file) (for most
360 debug formats this will necessarily point to the beginning of a line),
361 @var{middle} is @samp{middle} if @var{addr} is in the middle of the
362 line, or @samp{beg} if @var{addr} is at the beginning of the line, and
363 @var{addr} is the address in the target program associated with the
364 source which is being displayed.
365
366 @bye
This page took 0.042439 seconds and 5 git commands to generate.