1 /* Annotation routines for GDB.
2 Copyright (C) 1986, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999,
3 2000, 2007, 2008 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include "breakpoint.h"
28 /* Prototypes for local functions. */
30 extern void _initialize_annotate (void);
32 static void print_value_flags (struct type
*);
34 static void breakpoint_changed (struct breakpoint
*);
36 void (*deprecated_annotate_starting_hook
) (void);
37 void (*deprecated_annotate_stopped_hook
) (void);
38 void (*deprecated_annotate_signalled_hook
) (void);
39 void (*deprecated_annotate_signal_hook
) (void);
40 void (*deprecated_annotate_exited_hook
) (void);
42 static int ignore_count_changed
= 0;
45 print_value_flags (struct type
*t
)
47 if (can_dereference (t
))
48 printf_filtered (("*"));
50 printf_filtered (("-"));
54 breakpoints_changed (void)
56 if (annotation_level
== 2)
58 target_terminal_ours ();
59 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
60 if (ignore_count_changed
)
61 ignore_count_changed
= 0; /* Avoid multiple break annotations. */
65 /* The GUI needs to be informed of ignore_count changes, but we don't
66 want to provide successive multiple breakpoints-invalid messages
67 that are all caused by the fact that the ignore count is changing
68 (which could keep the GUI very busy). One is enough, after the
69 target actually "stops". */
72 annotate_ignore_count_change (void)
74 if (annotation_level
> 1)
75 ignore_count_changed
= 1;
79 annotate_breakpoint (int num
)
81 if (annotation_level
> 1)
82 printf_filtered (("\n\032\032breakpoint %d\n"), num
);
86 annotate_catchpoint (int num
)
88 if (annotation_level
> 1)
89 printf_filtered (("\n\032\032catchpoint %d\n"), num
);
93 annotate_watchpoint (int num
)
95 if (annotation_level
> 1)
96 printf_filtered (("\n\032\032watchpoint %d\n"), num
);
100 annotate_starting (void)
103 if (deprecated_annotate_starting_hook
)
104 deprecated_annotate_starting_hook ();
107 if (annotation_level
> 1)
109 printf_filtered (("\n\032\032starting\n"));
115 annotate_stopped (void)
117 if (deprecated_annotate_stopped_hook
)
118 deprecated_annotate_stopped_hook ();
121 if (annotation_level
> 1)
122 printf_filtered (("\n\032\032stopped\n"));
124 if (annotation_level
> 1 && ignore_count_changed
)
126 ignore_count_changed
= 0;
127 breakpoints_changed ();
132 annotate_exited (int exitstatus
)
134 if (deprecated_annotate_exited_hook
)
135 deprecated_annotate_exited_hook ();
138 if (annotation_level
> 1)
139 printf_filtered (("\n\032\032exited %d\n"), exitstatus
);
144 annotate_signalled (void)
146 if (deprecated_annotate_signalled_hook
)
147 deprecated_annotate_signalled_hook ();
149 if (annotation_level
> 1)
150 printf_filtered (("\n\032\032signalled\n"));
154 annotate_signal_name (void)
156 if (annotation_level
== 2)
157 printf_filtered (("\n\032\032signal-name\n"));
161 annotate_signal_name_end (void)
163 if (annotation_level
== 2)
164 printf_filtered (("\n\032\032signal-name-end\n"));
168 annotate_signal_string (void)
170 if (annotation_level
== 2)
171 printf_filtered (("\n\032\032signal-string\n"));
175 annotate_signal_string_end (void)
177 if (annotation_level
== 2)
178 printf_filtered (("\n\032\032signal-string-end\n"));
182 annotate_signal (void)
184 if (deprecated_annotate_signal_hook
)
185 deprecated_annotate_signal_hook ();
187 if (annotation_level
> 1)
188 printf_filtered (("\n\032\032signal\n"));
192 annotate_breakpoints_headers (void)
194 if (annotation_level
== 2)
195 printf_filtered (("\n\032\032breakpoints-headers\n"));
199 annotate_field (int num
)
201 if (annotation_level
== 2)
202 printf_filtered (("\n\032\032field %d\n"), num
);
206 annotate_breakpoints_table (void)
208 if (annotation_level
== 2)
209 printf_filtered (("\n\032\032breakpoints-table\n"));
213 annotate_record (void)
215 if (annotation_level
== 2)
216 printf_filtered (("\n\032\032record\n"));
220 annotate_breakpoints_table_end (void)
222 if (annotation_level
== 2)
223 printf_filtered (("\n\032\032breakpoints-table-end\n"));
227 annotate_frames_invalid (void)
229 if (annotation_level
== 2)
231 target_terminal_ours ();
232 printf_unfiltered (("\n\032\032frames-invalid\n"));
237 annotate_new_thread (void)
239 if (annotation_level
> 1)
241 printf_unfiltered (("\n\032\032new-thread\n"));
246 annotate_field_begin (struct type
*type
)
248 if (annotation_level
== 2)
250 printf_filtered (("\n\032\032field-begin "));
251 print_value_flags (type
);
252 printf_filtered (("\n"));
257 annotate_field_name_end (void)
259 if (annotation_level
== 2)
260 printf_filtered (("\n\032\032field-name-end\n"));
264 annotate_field_value (void)
266 if (annotation_level
== 2)
267 printf_filtered (("\n\032\032field-value\n"));
271 annotate_field_end (void)
273 if (annotation_level
== 2)
274 printf_filtered (("\n\032\032field-end\n"));
280 if (annotation_level
> 1)
281 printf_filtered (("\n\032\032quit\n"));
285 annotate_error (void)
287 if (annotation_level
> 1)
288 printf_filtered (("\n\032\032error\n"));
292 annotate_error_begin (void)
294 if (annotation_level
> 1)
295 fprintf_filtered (gdb_stderr
, "\n\032\032error-begin\n");
299 annotate_value_history_begin (int histindex
, struct type
*type
)
301 if (annotation_level
== 2)
303 printf_filtered (("\n\032\032value-history-begin %d "), histindex
);
304 print_value_flags (type
);
305 printf_filtered (("\n"));
310 annotate_value_begin (struct type
*type
)
312 if (annotation_level
== 2)
314 printf_filtered (("\n\032\032value-begin "));
315 print_value_flags (type
);
316 printf_filtered (("\n"));
321 annotate_value_history_value (void)
323 if (annotation_level
== 2)
324 printf_filtered (("\n\032\032value-history-value\n"));
328 annotate_value_history_end (void)
330 if (annotation_level
== 2)
331 printf_filtered (("\n\032\032value-history-end\n"));
335 annotate_value_end (void)
337 if (annotation_level
== 2)
338 printf_filtered (("\n\032\032value-end\n"));
342 annotate_display_begin (void)
344 if (annotation_level
== 2)
345 printf_filtered (("\n\032\032display-begin\n"));
349 annotate_display_number_end (void)
351 if (annotation_level
== 2)
352 printf_filtered (("\n\032\032display-number-end\n"));
356 annotate_display_format (void)
358 if (annotation_level
== 2)
359 printf_filtered (("\n\032\032display-format\n"));
363 annotate_display_expression (void)
365 if (annotation_level
== 2)
366 printf_filtered (("\n\032\032display-expression\n"));
370 annotate_display_expression_end (void)
372 if (annotation_level
== 2)
373 printf_filtered (("\n\032\032display-expression-end\n"));
377 annotate_display_value (void)
379 if (annotation_level
== 2)
380 printf_filtered (("\n\032\032display-value\n"));
384 annotate_display_end (void)
386 if (annotation_level
== 2)
387 printf_filtered (("\n\032\032display-end\n"));
391 annotate_arg_begin (void)
393 if (annotation_level
== 2)
394 printf_filtered (("\n\032\032arg-begin\n"));
398 annotate_arg_name_end (void)
400 if (annotation_level
== 2)
401 printf_filtered (("\n\032\032arg-name-end\n"));
405 annotate_arg_value (struct type
*type
)
407 if (annotation_level
== 2)
409 printf_filtered (("\n\032\032arg-value "));
410 print_value_flags (type
);
411 printf_filtered (("\n"));
416 annotate_arg_end (void)
418 if (annotation_level
== 2)
419 printf_filtered (("\n\032\032arg-end\n"));
423 annotate_source (char *filename
, int line
, int character
, int mid
, CORE_ADDR pc
)
425 if (annotation_level
> 1)
426 printf_filtered (("\n\032\032source "));
428 printf_filtered (("\032\032"));
430 printf_filtered (("%s:%d:%d:%s:0x"), filename
,
432 mid
? "middle" : "beg");
433 deprecated_print_address_numeric (pc
, 0, gdb_stdout
);
434 printf_filtered (("\n"));
438 annotate_frame_begin (int level
, CORE_ADDR pc
)
440 if (annotation_level
> 1)
442 printf_filtered (("\n\032\032frame-begin %d 0x"), level
);
443 deprecated_print_address_numeric (pc
, 0, gdb_stdout
);
444 printf_filtered (("\n"));
449 annotate_function_call (void)
451 if (annotation_level
== 2)
452 printf_filtered (("\n\032\032function-call\n"));
456 annotate_signal_handler_caller (void)
458 if (annotation_level
== 2)
459 printf_filtered (("\n\032\032signal-handler-caller\n"));
463 annotate_frame_address (void)
465 if (annotation_level
== 2)
466 printf_filtered (("\n\032\032frame-address\n"));
470 annotate_frame_address_end (void)
472 if (annotation_level
== 2)
473 printf_filtered (("\n\032\032frame-address-end\n"));
477 annotate_frame_function_name (void)
479 if (annotation_level
== 2)
480 printf_filtered (("\n\032\032frame-function-name\n"));
484 annotate_frame_args (void)
486 if (annotation_level
== 2)
487 printf_filtered (("\n\032\032frame-args\n"));
491 annotate_frame_source_begin (void)
493 if (annotation_level
== 2)
494 printf_filtered (("\n\032\032frame-source-begin\n"));
498 annotate_frame_source_file (void)
500 if (annotation_level
== 2)
501 printf_filtered (("\n\032\032frame-source-file\n"));
505 annotate_frame_source_file_end (void)
507 if (annotation_level
== 2)
508 printf_filtered (("\n\032\032frame-source-file-end\n"));
512 annotate_frame_source_line (void)
514 if (annotation_level
== 2)
515 printf_filtered (("\n\032\032frame-source-line\n"));
519 annotate_frame_source_end (void)
521 if (annotation_level
== 2)
522 printf_filtered (("\n\032\032frame-source-end\n"));
526 annotate_frame_where (void)
528 if (annotation_level
== 2)
529 printf_filtered (("\n\032\032frame-where\n"));
533 annotate_frame_end (void)
535 if (annotation_level
== 2)
536 printf_filtered (("\n\032\032frame-end\n"));
540 annotate_array_section_begin (int index
, struct type
*elttype
)
542 if (annotation_level
== 2)
544 printf_filtered (("\n\032\032array-section-begin %d "), index
);
545 print_value_flags (elttype
);
546 printf_filtered (("\n"));
551 annotate_elt_rep (unsigned int repcount
)
553 if (annotation_level
== 2)
554 printf_filtered (("\n\032\032elt-rep %u\n"), repcount
);
558 annotate_elt_rep_end (void)
560 if (annotation_level
== 2)
561 printf_filtered (("\n\032\032elt-rep-end\n"));
567 if (annotation_level
== 2)
568 printf_filtered (("\n\032\032elt\n"));
572 annotate_array_section_end (void)
574 if (annotation_level
== 2)
575 printf_filtered (("\n\032\032array-section-end\n"));
579 breakpoint_changed (struct breakpoint
*b
)
581 breakpoints_changed ();
585 _initialize_annotate (void)
587 if (annotation_level
== 2)
589 deprecated_delete_breakpoint_hook
= breakpoint_changed
;
590 deprecated_modify_breakpoint_hook
= breakpoint_changed
;