* buildsym.c (patch_subfile_name): Update last_source_file
[external/binutils.git] / gdb / annotate.c
1 /* Annotation routines for GDB.
2    Copyright 1986, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 #include "defs.h"
21 #include "annotate.h"
22 #include "value.h"
23 #include "target.h"
24 #include "gdbtypes.h"
25 #include "breakpoint.h"
26 \f
27 static void print_value_flags PARAMS ((struct type *));
28
29 static void
30 print_value_flags (t)
31      struct type *t;
32 {
33   if (can_dereference (t))
34     printf_filtered ("*");
35   else
36     printf_filtered ("-");
37 }
38 \f
39 void
40 breakpoints_changed ()
41 {
42   if (annotation_level > 1)
43     {
44       target_terminal_ours ();
45       printf_unfiltered ("\n\032\032breakpoints-invalid\n");
46     }
47 }
48
49 void
50 annotate_breakpoint (num)
51      int num;
52 {
53   if (annotation_level > 1)
54     printf_filtered ("\n\032\032breakpoint %d\n", num);
55 }
56
57 void
58 annotate_watchpoint (num)
59      int num;
60 {
61   if (annotation_level > 1)
62     printf_filtered ("\n\032\032watchpoint %d\n", num);
63 }
64
65 void
66 annotate_starting ()
67 {
68   if (annotation_level > 1)
69     {
70       printf_filtered ("\n\032\032starting\n");
71     }
72 }
73
74 void
75 annotate_stopped ()
76 {
77   if (annotation_level > 1)
78     printf_filtered ("\n\032\032stopped\n");
79 }
80
81 void
82 annotate_exited (exitstatus)
83      int exitstatus;
84 {
85   if (annotation_level > 1)
86     printf_filtered ("\n\032\032exited %d\n", exitstatus);
87 }
88
89 void
90 annotate_signalled ()
91 {
92   if (annotation_level > 1)
93     printf_filtered ("\n\032\032signalled\n");
94 }
95
96 void
97 annotate_signal_name ()
98 {
99   if (annotation_level > 1)
100     printf_filtered ("\n\032\032signal-name\n");
101 }
102
103 void
104 annotate_signal_name_end ()
105 {
106   if (annotation_level > 1)
107     printf_filtered ("\n\032\032signal-name-end\n");
108 }
109
110 void
111 annotate_signal_string ()
112 {
113   if (annotation_level > 1)
114     printf_filtered ("\n\032\032signal-string\n");
115 }
116
117 void
118 annotate_signal_string_end ()
119 {
120   if (annotation_level > 1)
121     printf_filtered ("\n\032\032signal-string-end\n");
122 }
123
124 void
125 annotate_signal ()
126 {
127   if (annotation_level > 1)
128     printf_filtered ("\n\032\032signal\n");
129 }
130 \f
131 void
132 annotate_breakpoints_headers ()
133 {
134   if (annotation_level > 1)
135     printf_filtered ("\n\032\032breakpoints-headers\n");
136 }
137
138 void
139 annotate_field (num)
140      int num;
141 {
142   if (annotation_level > 1)
143     printf_filtered ("\n\032\032field %d\n", num);
144 }
145
146 void
147 annotate_breakpoints_table ()
148 {
149   if (annotation_level > 1)
150     printf_filtered ("\n\032\032breakpoints-table\n");
151 }
152
153 void
154 annotate_record ()
155 {
156   if (annotation_level > 1)
157     printf_filtered ("\n\032\032record\n");
158 }
159
160 void
161 annotate_breakpoints_table_end ()
162 {
163   if (annotation_level > 1)
164     printf_filtered ("\n\032\032breakpoints-table-end\n");
165 }
166
167 void
168 annotate_frames_invalid ()
169 {
170   if (annotation_level > 1)
171     {
172       target_terminal_ours ();
173       printf_unfiltered ("\n\032\032frames-invalid\n");
174     }
175 }
176
177 void
178 annotate_field_begin (type)
179      struct type *type;
180 {
181   if (annotation_level > 1)
182     {
183       printf_filtered ("\n\032\032field-begin ");
184       print_value_flags (type);
185       printf_filtered ("\n");
186     }
187 }
188
189 void
190 annotate_field_name_end ()
191 {
192   if (annotation_level > 1)
193     printf_filtered ("\n\032\032field-name-end\n");
194 }
195
196 void
197 annotate_field_value ()
198 {
199   if (annotation_level > 1)
200     printf_filtered ("\n\032\032field-value\n");
201 }
202
203 void
204 annotate_field_end ()
205 {
206   if (annotation_level > 1)
207     printf_filtered ("\n\032\032field-end\n");
208 }
209 \f
210 void
211 annotate_quit ()
212 {
213   if (annotation_level > 1)
214     printf_filtered ("\n\032\032quit\n");
215 }
216
217 void
218 annotate_error ()
219 {
220   if (annotation_level > 1)
221     printf_filtered ("\n\032\032error\n");
222 }
223
224 void
225 annotate_error_begin ()
226 {
227   if (annotation_level > 1)
228     fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
229 }
230
231 void
232 annotate_value_history_begin (histindex, type)
233      int histindex;
234      struct type *type;
235 {
236   if (annotation_level > 1)
237     {
238       printf_filtered ("\n\032\032value-history-begin %d ", histindex);
239       print_value_flags (type);
240       printf_filtered ("\n");
241     }
242 }
243
244 void
245 annotate_value_begin (type)
246      struct type *type;
247 {
248   if (annotation_level > 1)
249     {
250       printf_filtered ("\n\032\032value-begin ");
251       print_value_flags (type);
252       printf_filtered ("\n");
253     }
254 }
255
256 void
257 annotate_value_history_value ()
258 {
259   if (annotation_level > 1)
260     printf_filtered ("\n\032\032value-history-value\n");
261 }
262
263 void
264 annotate_value_history_end ()
265 {
266   if (annotation_level > 1)
267     printf_filtered ("\n\032\032value-history-end\n");
268 }
269
270 void
271 annotate_value_end ()
272 {
273   if (annotation_level > 1)
274     printf_filtered ("\n\032\032value-end\n");
275 }
276
277 void
278 annotate_display_begin ()
279 {
280   if (annotation_level > 1)
281     printf_filtered ("\n\032\032display-begin\n");
282 }
283
284 void
285 annotate_display_number_end ()
286 {
287   if (annotation_level > 1)
288     printf_filtered ("\n\032\032display-number-end\n");
289 }
290
291 void
292 annotate_display_format ()
293 {
294   if (annotation_level > 1)
295     printf_filtered ("\n\032\032display-format\n");
296 }
297
298 void
299 annotate_display_expression ()
300 {
301   if (annotation_level > 1)
302     printf_filtered ("\n\032\032display-expression\n");
303 }
304
305 void
306 annotate_display_expression_end ()
307 {
308   if (annotation_level > 1)
309     printf_filtered ("\n\032\032display-expression-end\n");
310 }
311
312 void
313 annotate_display_value ()
314 {
315   if (annotation_level > 1)
316     printf_filtered ("\n\032\032display-value\n");
317 }
318
319 void
320 annotate_display_end ()
321 {
322   if (annotation_level > 1)
323     printf_filtered ("\n\032\032display-end\n");
324 }
325
326 void
327 annotate_arg_begin ()
328 {
329   if (annotation_level > 1)
330     printf_filtered ("\n\032\032arg-begin\n");
331 }
332
333 void
334 annotate_arg_name_end ()
335 {
336   if (annotation_level > 1)
337     printf_filtered ("\n\032\032arg-name-end\n");
338 }
339
340 void
341 annotate_arg_value (type)
342      struct type *type;
343 {
344   if (annotation_level > 1)
345     {
346       printf_filtered ("\n\032\032arg-value ");
347       print_value_flags (type);
348       printf_filtered ("\n");
349     }
350 }
351
352 void
353 annotate_arg_end ()
354 {
355   if (annotation_level > 1)
356     printf_filtered ("\n\032\032arg-end\n");
357 }
358
359 void
360 annotate_source (filename, line, character, mid, pc)
361      char *filename;
362      int line;
363      int character;
364      int mid;
365      CORE_ADDR pc;
366 {
367   if (annotation_level > 1)
368     printf_filtered ("\n\032\032source ");
369   else
370     printf_filtered ("\032\032");
371
372   printf_filtered ("%s:%d:%d:%s:", filename,
373                    line, character,
374                    mid ? "middle" : "beg");
375   print_address_numeric (pc, 0, gdb_stdout);
376   printf_filtered ("\n");
377 }
378
379 void
380 annotate_frame_begin (level, pc)
381      int level;
382      CORE_ADDR pc;
383 {
384   if (annotation_level > 1)
385     {
386       printf_filtered ("\n\032\032frame-begin %d ", level);
387       print_address_numeric (pc, 0, gdb_stdout);
388       printf_filtered ("\n");
389     }
390 }
391
392 void
393 annotate_function_call ()
394 {
395   if (annotation_level > 1)
396     printf_filtered ("\n\032\032function-call\n");
397 }
398
399 void
400 annotate_signal_handler_caller ()
401 {
402   if (annotation_level > 1)
403     printf_filtered ("\n\032\032signal-handler-caller\n");
404 }
405
406 void
407 annotate_frame_address ()
408 {
409   if (annotation_level > 1)
410     printf_filtered ("\n\032\032frame-address\n");
411 }
412
413 void
414 annotate_frame_address_end ()
415 {
416   if (annotation_level > 1)
417     printf_filtered ("\n\032\032frame-address-end\n");
418 }
419
420 void
421 annotate_frame_function_name ()
422 {
423   if (annotation_level > 1)
424     printf_filtered ("\n\032\032frame-function-name\n");
425 }
426
427 void
428 annotate_frame_args ()
429 {
430   if (annotation_level > 1)
431     printf_filtered ("\n\032\032frame-args\n");
432 }
433
434 void
435 annotate_frame_source_begin ()
436 {
437   if (annotation_level > 1)
438     printf_filtered ("\n\032\032frame-source-begin\n");
439 }
440
441 void
442 annotate_frame_source_file ()
443 {
444   if (annotation_level > 1)
445     printf_filtered ("\n\032\032frame-source-file\n");
446 }
447
448 void
449 annotate_frame_source_file_end ()
450 {
451   if (annotation_level > 1)
452     printf_filtered ("\n\032\032frame-source-file-end\n");
453 }
454
455 void
456 annotate_frame_source_line ()
457 {
458   if (annotation_level > 1)
459     printf_filtered ("\n\032\032frame-source-line\n");
460 }
461
462 void
463 annotate_frame_source_end ()
464 {
465   if (annotation_level > 1)
466     printf_filtered ("\n\032\032frame-source-end\n");
467 }
468
469 void
470 annotate_frame_where ()
471 {
472   if (annotation_level > 1)
473     printf_filtered ("\n\032\032frame-where\n");
474 }
475
476 void
477 annotate_frame_end ()
478 {
479   if (annotation_level > 1)
480     printf_filtered ("\n\032\032frame-end\n");
481 }
482 \f
483 void
484 annotate_array_section_begin (index, elttype)
485      int index;
486      struct type *elttype;
487 {
488   if (annotation_level > 1)
489     {
490       printf_filtered ("\n\032\032array-section-begin %d ", index);
491       print_value_flags (elttype);
492       printf_filtered ("\n");
493     }
494 }
495
496 void
497 annotate_elt_rep (repcount)
498      unsigned int repcount;
499 {
500   if (annotation_level > 1)
501     printf_filtered ("\n\032\032elt-rep %u\n", repcount);
502 }
503
504 void
505 annotate_elt_rep_end ()
506 {
507   if (annotation_level > 1)
508     printf_filtered ("\n\032\032elt-rep-end\n");
509 }
510
511 void
512 annotate_elt ()
513 {
514   if (annotation_level > 1)
515     printf_filtered ("\n\032\032elt\n");
516 }
517
518 void
519 annotate_array_section_end ()
520 {
521   if (annotation_level > 1)
522     printf_filtered ("\n\032\032array-section-end\n");
523 }
524
525 static void
526 breakpoint_changed (b)
527      struct breakpoint *b;
528 {
529   breakpoints_changed ();
530 }
531
532 void
533 _initialize_annotate ()
534 {
535   if (annotation_level > 1)
536     {
537       delete_breakpoint_hook = breakpoint_changed;
538       modify_breakpoint_hook = breakpoint_changed;
539     }
540 }