* gas/cgen feature
[binutils-gdb.git] / gdb / annotate.c
blobc5879e3b9f28782756a975ccc7dfbb1db83e3cdf
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 (struct type *t)
48 if (can_dereference (t))
49 printf_filtered ("*");
50 else
51 printf_filtered ("-");
54 void
55 breakpoints_changed (void)
57 if (annotation_level > 1)
59 target_terminal_ours ();
60 printf_unfiltered ("\n\032\032breakpoints-invalid\n");
61 if (ignore_count_changed)
62 ignore_count_changed = 0; /* Avoid multiple break annotations. */
66 /* The GUI needs to be informed of ignore_count changes, but we don't
67 want to provide successive multiple breakpoints-invalid messages
68 that are all caused by the fact that the ignore count is changing
69 (which could keep the GUI very busy). One is enough, after the
70 target actually "stops". */
72 void
73 annotate_ignore_count_change (void)
75 if (annotation_level > 1)
76 ignore_count_changed = 1;
79 void
80 annotate_breakpoint (int num)
82 if (annotation_level > 1)
83 printf_filtered ("\n\032\032breakpoint %d\n", num);
86 void
87 annotate_catchpoint (int num)
89 if (annotation_level > 1)
90 printf_filtered ("\n\032\032catchpoint %d\n", num);
93 void
94 annotate_watchpoint (int num)
96 if (annotation_level > 1)
97 printf_filtered ("\n\032\032watchpoint %d\n", num);
100 void
101 annotate_starting (void)
104 if (annotate_starting_hook)
105 annotate_starting_hook ();
106 else
108 if (annotation_level > 1)
110 printf_filtered ("\n\032\032starting\n");
115 void
116 annotate_stopped (void)
118 if (annotate_stopped_hook)
119 annotate_stopped_hook ();
120 else
122 if (annotation_level > 1)
123 printf_filtered ("\n\032\032stopped\n");
125 if (annotation_level > 1 && ignore_count_changed)
127 ignore_count_changed = 0;
128 breakpoints_changed ();
132 void
133 annotate_exited (int exitstatus)
135 if (annotate_exited_hook)
136 annotate_exited_hook ();
137 else
139 if (annotation_level > 1)
140 printf_filtered ("\n\032\032exited %d\n", exitstatus);
144 void
145 annotate_signalled (void)
147 if (annotate_signalled_hook)
148 annotate_signalled_hook ();
150 if (annotation_level > 1)
151 printf_filtered ("\n\032\032signalled\n");
154 void
155 annotate_signal_name (void)
157 if (annotation_level > 1)
158 printf_filtered ("\n\032\032signal-name\n");
161 void
162 annotate_signal_name_end (void)
164 if (annotation_level > 1)
165 printf_filtered ("\n\032\032signal-name-end\n");
168 void
169 annotate_signal_string (void)
171 if (annotation_level > 1)
172 printf_filtered ("\n\032\032signal-string\n");
175 void
176 annotate_signal_string_end (void)
178 if (annotation_level > 1)
179 printf_filtered ("\n\032\032signal-string-end\n");
182 void
183 annotate_signal (void)
185 if (annotate_signal_hook)
186 annotate_signal_hook ();
188 if (annotation_level > 1)
189 printf_filtered ("\n\032\032signal\n");
192 void
193 annotate_breakpoints_headers (void)
195 if (annotation_level > 1)
196 printf_filtered ("\n\032\032breakpoints-headers\n");
199 void
200 annotate_field (int num)
202 if (annotation_level > 1)
203 printf_filtered ("\n\032\032field %d\n", num);
206 void
207 annotate_breakpoints_table (void)
209 if (annotation_level > 1)
210 printf_filtered ("\n\032\032breakpoints-table\n");
213 void
214 annotate_record (void)
216 if (annotation_level > 1)
217 printf_filtered ("\n\032\032record\n");
220 void
221 annotate_breakpoints_table_end (void)
223 if (annotation_level > 1)
224 printf_filtered ("\n\032\032breakpoints-table-end\n");
227 void
228 annotate_frames_invalid (void)
230 if (annotation_level > 1)
232 target_terminal_ours ();
233 printf_unfiltered ("\n\032\032frames-invalid\n");
237 void
238 annotate_field_begin (struct type *type)
240 if (annotation_level > 1)
242 printf_filtered ("\n\032\032field-begin ");
243 print_value_flags (type);
244 printf_filtered ("\n");
248 void
249 annotate_field_name_end (void)
251 if (annotation_level > 1)
252 printf_filtered ("\n\032\032field-name-end\n");
255 void
256 annotate_field_value (void)
258 if (annotation_level > 1)
259 printf_filtered ("\n\032\032field-value\n");
262 void
263 annotate_field_end (void)
265 if (annotation_level > 1)
266 printf_filtered ("\n\032\032field-end\n");
269 void
270 annotate_quit (void)
272 if (annotation_level > 1)
273 printf_filtered ("\n\032\032quit\n");
276 void
277 annotate_error (void)
279 if (annotation_level > 1)
280 printf_filtered ("\n\032\032error\n");
283 void
284 annotate_error_begin (void)
286 if (annotation_level > 1)
287 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
290 void
291 annotate_value_history_begin (int histindex, struct type *type)
293 if (annotation_level > 1)
295 printf_filtered ("\n\032\032value-history-begin %d ", histindex);
296 print_value_flags (type);
297 printf_filtered ("\n");
301 void
302 annotate_value_begin (struct type *type)
304 if (annotation_level > 1)
306 printf_filtered ("\n\032\032value-begin ");
307 print_value_flags (type);
308 printf_filtered ("\n");
312 void
313 annotate_value_history_value (void)
315 if (annotation_level > 1)
316 printf_filtered ("\n\032\032value-history-value\n");
319 void
320 annotate_value_history_end (void)
322 if (annotation_level > 1)
323 printf_filtered ("\n\032\032value-history-end\n");
326 void
327 annotate_value_end (void)
329 if (annotation_level > 1)
330 printf_filtered ("\n\032\032value-end\n");
333 void
334 annotate_display_begin (void)
336 if (annotation_level > 1)
337 printf_filtered ("\n\032\032display-begin\n");
340 void
341 annotate_display_number_end (void)
343 if (annotation_level > 1)
344 printf_filtered ("\n\032\032display-number-end\n");
347 void
348 annotate_display_format (void)
350 if (annotation_level > 1)
351 printf_filtered ("\n\032\032display-format\n");
354 void
355 annotate_display_expression (void)
357 if (annotation_level > 1)
358 printf_filtered ("\n\032\032display-expression\n");
361 void
362 annotate_display_expression_end (void)
364 if (annotation_level > 1)
365 printf_filtered ("\n\032\032display-expression-end\n");
368 void
369 annotate_display_value (void)
371 if (annotation_level > 1)
372 printf_filtered ("\n\032\032display-value\n");
375 void
376 annotate_display_end (void)
378 if (annotation_level > 1)
379 printf_filtered ("\n\032\032display-end\n");
382 void
383 annotate_arg_begin (void)
385 if (annotation_level > 1)
386 printf_filtered ("\n\032\032arg-begin\n");
389 void
390 annotate_arg_name_end (void)
392 if (annotation_level > 1)
393 printf_filtered ("\n\032\032arg-name-end\n");
396 void
397 annotate_arg_value (struct type *type)
399 if (annotation_level > 1)
401 printf_filtered ("\n\032\032arg-value ");
402 print_value_flags (type);
403 printf_filtered ("\n");
407 void
408 annotate_arg_end (void)
410 if (annotation_level > 1)
411 printf_filtered ("\n\032\032arg-end\n");
414 void
415 annotate_source (char *filename, int line, int character, int mid, CORE_ADDR pc)
417 if (annotation_level > 1)
418 printf_filtered ("\n\032\032source ");
419 else
420 printf_filtered ("\032\032");
422 printf_filtered ("%s:%d:%d:%s:0x", filename,
423 line, character,
424 mid ? "middle" : "beg");
425 print_address_numeric (pc, 0, gdb_stdout);
426 printf_filtered ("\n");
429 void
430 annotate_frame_begin (int level, CORE_ADDR pc)
432 if (annotation_level > 1)
434 printf_filtered ("\n\032\032frame-begin %d 0x", level);
435 print_address_numeric (pc, 0, gdb_stdout);
436 printf_filtered ("\n");
440 void
441 annotate_function_call (void)
443 if (annotation_level > 1)
444 printf_filtered ("\n\032\032function-call\n");
447 void
448 annotate_signal_handler_caller (void)
450 if (annotation_level > 1)
451 printf_filtered ("\n\032\032signal-handler-caller\n");
454 void
455 annotate_frame_address (void)
457 if (annotation_level > 1)
458 printf_filtered ("\n\032\032frame-address\n");
461 void
462 annotate_frame_address_end (void)
464 if (annotation_level > 1)
465 printf_filtered ("\n\032\032frame-address-end\n");
468 void
469 annotate_frame_function_name (void)
471 if (annotation_level > 1)
472 printf_filtered ("\n\032\032frame-function-name\n");
475 void
476 annotate_frame_args (void)
478 if (annotation_level > 1)
479 printf_filtered ("\n\032\032frame-args\n");
482 void
483 annotate_frame_source_begin (void)
485 if (annotation_level > 1)
486 printf_filtered ("\n\032\032frame-source-begin\n");
489 void
490 annotate_frame_source_file (void)
492 if (annotation_level > 1)
493 printf_filtered ("\n\032\032frame-source-file\n");
496 void
497 annotate_frame_source_file_end (void)
499 if (annotation_level > 1)
500 printf_filtered ("\n\032\032frame-source-file-end\n");
503 void
504 annotate_frame_source_line (void)
506 if (annotation_level > 1)
507 printf_filtered ("\n\032\032frame-source-line\n");
510 void
511 annotate_frame_source_end (void)
513 if (annotation_level > 1)
514 printf_filtered ("\n\032\032frame-source-end\n");
517 void
518 annotate_frame_where (void)
520 if (annotation_level > 1)
521 printf_filtered ("\n\032\032frame-where\n");
524 void
525 annotate_frame_end (void)
527 if (annotation_level > 1)
528 printf_filtered ("\n\032\032frame-end\n");
531 void
532 annotate_array_section_begin (int index, struct type *elttype)
534 if (annotation_level > 1)
536 printf_filtered ("\n\032\032array-section-begin %d ", index);
537 print_value_flags (elttype);
538 printf_filtered ("\n");
542 void
543 annotate_elt_rep (unsigned int repcount)
545 if (annotation_level > 1)
546 printf_filtered ("\n\032\032elt-rep %u\n", repcount);
549 void
550 annotate_elt_rep_end (void)
552 if (annotation_level > 1)
553 printf_filtered ("\n\032\032elt-rep-end\n");
556 void
557 annotate_elt (void)
559 if (annotation_level > 1)
560 printf_filtered ("\n\032\032elt\n");
563 void
564 annotate_array_section_end (void)
566 if (annotation_level > 1)
567 printf_filtered ("\n\032\032array-section-end\n");
570 static void
571 breakpoint_changed (struct breakpoint *b)
573 breakpoints_changed ();
576 void
577 _initialize_annotate (void)
579 if (annotation_level > 1)
581 delete_breakpoint_hook = breakpoint_changed;
582 modify_breakpoint_hook = breakpoint_changed;