* testsuite/regress-demangle (failed test): Show result and
[binutils-gdb.git] / gdb / annotate.c
blobee26290a95ec0d58915325316c55a0f01009aeae
1 /* Annotation routines for GDB.
2 Copyright 1986, 89, 90, 91, 92, 95, 98, 1999 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #include "defs.h"
22 #include "annotate.h"
23 #include "value.h"
24 #include "target.h"
25 #include "gdbtypes.h"
26 #include "breakpoint.h"
29 /* Prototypes for local functions. */
31 extern void _initialize_annotate (void);
33 static void print_value_flags (struct type *);
35 static void breakpoint_changed (struct breakpoint *);
37 void (*annotate_starting_hook) (void);
38 void (*annotate_stopped_hook) (void);
39 void (*annotate_signalled_hook) (void);
40 void (*annotate_signal_hook) (void);
41 void (*annotate_exited_hook) (void);
43 static int ignore_count_changed = 0;
45 static void
46 print_value_flags (t)
47 struct type *t;
49 if (can_dereference (t))
50 printf_filtered ("*");
51 else
52 printf_filtered ("-");
55 void
56 breakpoints_changed ()
58 if (annotation_level > 1)
60 target_terminal_ours ();
61 printf_unfiltered ("\n\032\032breakpoints-invalid\n");
62 if (ignore_count_changed)
63 ignore_count_changed = 0; /* Avoid multiple break annotations. */
67 /* The GUI needs to be informed of ignore_count changes, but we don't
68 want to provide successive multiple breakpoints-invalid messages
69 that are all caused by the fact that the ignore count is changing
70 (which could keep the GUI very busy). One is enough, after the
71 target actually "stops". */
73 void
74 annotate_ignore_count_change (void)
76 if (annotation_level > 1)
77 ignore_count_changed = 1;
80 void
81 annotate_breakpoint (num)
82 int num;
84 if (annotation_level > 1)
85 printf_filtered ("\n\032\032breakpoint %d\n", num);
88 void
89 annotate_catchpoint (num)
90 int num;
92 if (annotation_level > 1)
93 printf_filtered ("\n\032\032catchpoint %d\n", num);
96 void
97 annotate_watchpoint (num)
98 int num;
100 if (annotation_level > 1)
101 printf_filtered ("\n\032\032watchpoint %d\n", num);
104 void
105 annotate_starting ()
108 if (annotate_starting_hook)
109 annotate_starting_hook ();
110 else
112 if (annotation_level > 1)
114 printf_filtered ("\n\032\032starting\n");
119 void
120 annotate_stopped ()
122 if (annotate_stopped_hook)
123 annotate_stopped_hook ();
124 else
126 if (annotation_level > 1)
127 printf_filtered ("\n\032\032stopped\n");
129 if (annotation_level > 1 && ignore_count_changed)
131 ignore_count_changed = 0;
132 breakpoints_changed ();
136 void
137 annotate_exited (exitstatus)
138 int exitstatus;
140 if (annotate_exited_hook)
141 annotate_exited_hook ();
142 else
144 if (annotation_level > 1)
145 printf_filtered ("\n\032\032exited %d\n", exitstatus);
149 void
150 annotate_signalled ()
152 if (annotate_signalled_hook)
153 annotate_signalled_hook ();
155 if (annotation_level > 1)
156 printf_filtered ("\n\032\032signalled\n");
159 void
160 annotate_signal_name ()
162 if (annotation_level > 1)
163 printf_filtered ("\n\032\032signal-name\n");
166 void
167 annotate_signal_name_end ()
169 if (annotation_level > 1)
170 printf_filtered ("\n\032\032signal-name-end\n");
173 void
174 annotate_signal_string ()
176 if (annotation_level > 1)
177 printf_filtered ("\n\032\032signal-string\n");
180 void
181 annotate_signal_string_end ()
183 if (annotation_level > 1)
184 printf_filtered ("\n\032\032signal-string-end\n");
187 void
188 annotate_signal ()
190 if (annotate_signal_hook)
191 annotate_signal_hook ();
193 if (annotation_level > 1)
194 printf_filtered ("\n\032\032signal\n");
197 void
198 annotate_breakpoints_headers ()
200 if (annotation_level > 1)
201 printf_filtered ("\n\032\032breakpoints-headers\n");
204 void
205 annotate_field (num)
206 int num;
208 if (annotation_level > 1)
209 printf_filtered ("\n\032\032field %d\n", num);
212 void
213 annotate_breakpoints_table ()
215 if (annotation_level > 1)
216 printf_filtered ("\n\032\032breakpoints-table\n");
219 void
220 annotate_record ()
222 if (annotation_level > 1)
223 printf_filtered ("\n\032\032record\n");
226 void
227 annotate_breakpoints_table_end ()
229 if (annotation_level > 1)
230 printf_filtered ("\n\032\032breakpoints-table-end\n");
233 void
234 annotate_frames_invalid ()
236 if (annotation_level > 1)
238 target_terminal_ours ();
239 printf_unfiltered ("\n\032\032frames-invalid\n");
243 void
244 annotate_field_begin (type)
245 struct type *type;
247 if (annotation_level > 1)
249 printf_filtered ("\n\032\032field-begin ");
250 print_value_flags (type);
251 printf_filtered ("\n");
255 void
256 annotate_field_name_end ()
258 if (annotation_level > 1)
259 printf_filtered ("\n\032\032field-name-end\n");
262 void
263 annotate_field_value ()
265 if (annotation_level > 1)
266 printf_filtered ("\n\032\032field-value\n");
269 void
270 annotate_field_end ()
272 if (annotation_level > 1)
273 printf_filtered ("\n\032\032field-end\n");
276 void
277 annotate_quit ()
279 if (annotation_level > 1)
280 printf_filtered ("\n\032\032quit\n");
283 void
284 annotate_error ()
286 if (annotation_level > 1)
287 printf_filtered ("\n\032\032error\n");
290 void
291 annotate_error_begin ()
293 if (annotation_level > 1)
294 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
297 void
298 annotate_value_history_begin (histindex, type)
299 int histindex;
300 struct type *type;
302 if (annotation_level > 1)
304 printf_filtered ("\n\032\032value-history-begin %d ", histindex);
305 print_value_flags (type);
306 printf_filtered ("\n");
310 void
311 annotate_value_begin (type)
312 struct type *type;
314 if (annotation_level > 1)
316 printf_filtered ("\n\032\032value-begin ");
317 print_value_flags (type);
318 printf_filtered ("\n");
322 void
323 annotate_value_history_value ()
325 if (annotation_level > 1)
326 printf_filtered ("\n\032\032value-history-value\n");
329 void
330 annotate_value_history_end ()
332 if (annotation_level > 1)
333 printf_filtered ("\n\032\032value-history-end\n");
336 void
337 annotate_value_end ()
339 if (annotation_level > 1)
340 printf_filtered ("\n\032\032value-end\n");
343 void
344 annotate_display_begin ()
346 if (annotation_level > 1)
347 printf_filtered ("\n\032\032display-begin\n");
350 void
351 annotate_display_number_end ()
353 if (annotation_level > 1)
354 printf_filtered ("\n\032\032display-number-end\n");
357 void
358 annotate_display_format ()
360 if (annotation_level > 1)
361 printf_filtered ("\n\032\032display-format\n");
364 void
365 annotate_display_expression ()
367 if (annotation_level > 1)
368 printf_filtered ("\n\032\032display-expression\n");
371 void
372 annotate_display_expression_end ()
374 if (annotation_level > 1)
375 printf_filtered ("\n\032\032display-expression-end\n");
378 void
379 annotate_display_value ()
381 if (annotation_level > 1)
382 printf_filtered ("\n\032\032display-value\n");
385 void
386 annotate_display_end ()
388 if (annotation_level > 1)
389 printf_filtered ("\n\032\032display-end\n");
392 void
393 annotate_arg_begin ()
395 if (annotation_level > 1)
396 printf_filtered ("\n\032\032arg-begin\n");
399 void
400 annotate_arg_name_end ()
402 if (annotation_level > 1)
403 printf_filtered ("\n\032\032arg-name-end\n");
406 void
407 annotate_arg_value (type)
408 struct type *type;
410 if (annotation_level > 1)
412 printf_filtered ("\n\032\032arg-value ");
413 print_value_flags (type);
414 printf_filtered ("\n");
418 void
419 annotate_arg_end ()
421 if (annotation_level > 1)
422 printf_filtered ("\n\032\032arg-end\n");
425 void
426 annotate_source (filename, line, character, mid, pc)
427 char *filename;
428 int line;
429 int character;
430 int mid;
431 CORE_ADDR pc;
433 if (annotation_level > 1)
434 printf_filtered ("\n\032\032source ");
435 else
436 printf_filtered ("\032\032");
438 printf_filtered ("%s:%d:%d:%s:0x", filename,
439 line, character,
440 mid ? "middle" : "beg");
441 print_address_numeric (pc, 0, gdb_stdout);
442 printf_filtered ("\n");
445 void
446 annotate_frame_begin (level, pc)
447 int level;
448 CORE_ADDR pc;
450 if (annotation_level > 1)
452 printf_filtered ("\n\032\032frame-begin %d 0x", level);
453 print_address_numeric (pc, 0, gdb_stdout);
454 printf_filtered ("\n");
458 void
459 annotate_function_call ()
461 if (annotation_level > 1)
462 printf_filtered ("\n\032\032function-call\n");
465 void
466 annotate_signal_handler_caller ()
468 if (annotation_level > 1)
469 printf_filtered ("\n\032\032signal-handler-caller\n");
472 void
473 annotate_frame_address ()
475 if (annotation_level > 1)
476 printf_filtered ("\n\032\032frame-address\n");
479 void
480 annotate_frame_address_end ()
482 if (annotation_level > 1)
483 printf_filtered ("\n\032\032frame-address-end\n");
486 void
487 annotate_frame_function_name ()
489 if (annotation_level > 1)
490 printf_filtered ("\n\032\032frame-function-name\n");
493 void
494 annotate_frame_args ()
496 if (annotation_level > 1)
497 printf_filtered ("\n\032\032frame-args\n");
500 void
501 annotate_frame_source_begin ()
503 if (annotation_level > 1)
504 printf_filtered ("\n\032\032frame-source-begin\n");
507 void
508 annotate_frame_source_file ()
510 if (annotation_level > 1)
511 printf_filtered ("\n\032\032frame-source-file\n");
514 void
515 annotate_frame_source_file_end ()
517 if (annotation_level > 1)
518 printf_filtered ("\n\032\032frame-source-file-end\n");
521 void
522 annotate_frame_source_line ()
524 if (annotation_level > 1)
525 printf_filtered ("\n\032\032frame-source-line\n");
528 void
529 annotate_frame_source_end ()
531 if (annotation_level > 1)
532 printf_filtered ("\n\032\032frame-source-end\n");
535 void
536 annotate_frame_where ()
538 if (annotation_level > 1)
539 printf_filtered ("\n\032\032frame-where\n");
542 void
543 annotate_frame_end ()
545 if (annotation_level > 1)
546 printf_filtered ("\n\032\032frame-end\n");
549 void
550 annotate_array_section_begin (index, elttype)
551 int index;
552 struct type *elttype;
554 if (annotation_level > 1)
556 printf_filtered ("\n\032\032array-section-begin %d ", index);
557 print_value_flags (elttype);
558 printf_filtered ("\n");
562 void
563 annotate_elt_rep (repcount)
564 unsigned int repcount;
566 if (annotation_level > 1)
567 printf_filtered ("\n\032\032elt-rep %u\n", repcount);
570 void
571 annotate_elt_rep_end ()
573 if (annotation_level > 1)
574 printf_filtered ("\n\032\032elt-rep-end\n");
577 void
578 annotate_elt ()
580 if (annotation_level > 1)
581 printf_filtered ("\n\032\032elt\n");
584 void
585 annotate_array_section_end ()
587 if (annotation_level > 1)
588 printf_filtered ("\n\032\032array-section-end\n");
591 static void
592 breakpoint_changed (b)
593 struct breakpoint *b;
595 breakpoints_changed ();
598 void
599 _initialize_annotate ()
601 if (annotation_level > 1)
603 delete_breakpoint_hook = breakpoint_changed;
604 modify_breakpoint_hook = breakpoint_changed;