1 /* Annotation routines for GDB.
2 Copyright (C) 1986-2013 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 3 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, see <http://www.gnu.org/licenses/>. */
24 #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 *b);
38 void (*deprecated_annotate_signalled_hook) (void);
39 void (*deprecated_annotate_signal_hook) (void);
41 /* Booleans indicating whether we've emitted certain notifications.
42 Used to suppress useless repeated notifications until the next time
43 we're ready to accept more commands. Reset whenever a prompt is
45 static int frames_invalid_emitted;
46 static int breakpoints_invalid_emitted;
48 /* True if the target can async, and a synchronous execution command
49 is not in progress. If true, input is accepted, so don't suppress
53 async_background_execution_p (void)
55 return (target_can_async_p () && !sync_execution);
59 print_value_flags (struct type *t)
61 if (can_dereference (t))
62 printf_filtered (("*"));
64 printf_filtered (("-"));
68 annotate_breakpoints_invalid (void)
70 if (annotation_level == 2
71 && (!breakpoints_invalid_emitted
72 || async_background_execution_p ()))
74 target_terminal_ours ();
75 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
76 breakpoints_invalid_emitted = 1;
81 annotate_breakpoint (int num)
83 if (annotation_level > 1)
84 printf_filtered (("\n\032\032breakpoint %d\n"), num);
88 annotate_catchpoint (int num)
90 if (annotation_level > 1)
91 printf_filtered (("\n\032\032catchpoint %d\n"), num);
95 annotate_watchpoint (int num)
97 if (annotation_level > 1)
98 printf_filtered (("\n\032\032watchpoint %d\n"), num);
102 annotate_starting (void)
104 if (annotation_level > 1)
105 printf_filtered (("\n\032\032starting\n"));
109 annotate_stopped (void)
111 if (annotation_level > 1)
112 printf_filtered (("\n\032\032stopped\n"));
116 annotate_exited (int exitstatus)
118 if (annotation_level > 1)
119 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
123 annotate_signalled (void)
125 if (deprecated_annotate_signalled_hook)
126 deprecated_annotate_signalled_hook ();
128 if (annotation_level > 1)
129 printf_filtered (("\n\032\032signalled\n"));
133 annotate_signal_name (void)
135 if (annotation_level == 2)
136 printf_filtered (("\n\032\032signal-name\n"));
140 annotate_signal_name_end (void)
142 if (annotation_level == 2)
143 printf_filtered (("\n\032\032signal-name-end\n"));
147 annotate_signal_string (void)
149 if (annotation_level == 2)
150 printf_filtered (("\n\032\032signal-string\n"));
154 annotate_signal_string_end (void)
156 if (annotation_level == 2)
157 printf_filtered (("\n\032\032signal-string-end\n"));
161 annotate_signal (void)
163 if (deprecated_annotate_signal_hook)
164 deprecated_annotate_signal_hook ();
166 if (annotation_level > 1)
167 printf_filtered (("\n\032\032signal\n"));
171 annotate_breakpoints_headers (void)
173 if (annotation_level == 2)
174 printf_filtered (("\n\032\032breakpoints-headers\n"));
178 annotate_field (int num)
180 if (annotation_level == 2)
181 printf_filtered (("\n\032\032field %d\n"), num);
185 annotate_breakpoints_table (void)
187 if (annotation_level == 2)
188 printf_filtered (("\n\032\032breakpoints-table\n"));
192 annotate_record (void)
194 if (annotation_level == 2)
195 printf_filtered (("\n\032\032record\n"));
199 annotate_breakpoints_table_end (void)
201 if (annotation_level == 2)
202 printf_filtered (("\n\032\032breakpoints-table-end\n"));
206 annotate_frames_invalid (void)
208 if (annotation_level == 2
209 && (!frames_invalid_emitted
210 || async_background_execution_p ()))
212 target_terminal_ours ();
213 printf_unfiltered (("\n\032\032frames-invalid\n"));
214 frames_invalid_emitted = 1;
219 annotate_new_thread (void)
221 if (annotation_level > 1)
223 printf_unfiltered (("\n\032\032new-thread\n"));
228 annotate_thread_changed (void)
230 if (annotation_level > 1)
232 printf_unfiltered (("\n\032\032thread-changed\n"));
237 annotate_field_begin (struct type *type)
239 if (annotation_level == 2)
241 printf_filtered (("\n\032\032field-begin "));
242 print_value_flags (type);
243 printf_filtered (("\n"));
248 annotate_field_name_end (void)
250 if (annotation_level == 2)
251 printf_filtered (("\n\032\032field-name-end\n"));
255 annotate_field_value (void)
257 if (annotation_level == 2)
258 printf_filtered (("\n\032\032field-value\n"));
262 annotate_field_end (void)
264 if (annotation_level == 2)
265 printf_filtered (("\n\032\032field-end\n"));
271 if (annotation_level > 1)
272 printf_filtered (("\n\032\032quit\n"));
276 annotate_error (void)
278 if (annotation_level > 1)
279 printf_filtered (("\n\032\032error\n"));
283 annotate_error_begin (void)
285 if (annotation_level > 1)
286 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
290 annotate_value_history_begin (int histindex, struct type *type)
292 if (annotation_level == 2)
294 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
295 print_value_flags (type);
296 printf_filtered (("\n"));
301 annotate_value_begin (struct type *type)
303 if (annotation_level == 2)
305 printf_filtered (("\n\032\032value-begin "));
306 print_value_flags (type);
307 printf_filtered (("\n"));
312 annotate_value_history_value (void)
314 if (annotation_level == 2)
315 printf_filtered (("\n\032\032value-history-value\n"));
319 annotate_value_history_end (void)
321 if (annotation_level == 2)
322 printf_filtered (("\n\032\032value-history-end\n"));
326 annotate_value_end (void)
328 if (annotation_level == 2)
329 printf_filtered (("\n\032\032value-end\n"));
333 annotate_display_begin (void)
335 if (annotation_level == 2)
336 printf_filtered (("\n\032\032display-begin\n"));
340 annotate_display_number_end (void)
342 if (annotation_level == 2)
343 printf_filtered (("\n\032\032display-number-end\n"));
347 annotate_display_format (void)
349 if (annotation_level == 2)
350 printf_filtered (("\n\032\032display-format\n"));
354 annotate_display_expression (void)
356 if (annotation_level == 2)
357 printf_filtered (("\n\032\032display-expression\n"));
361 annotate_display_expression_end (void)
363 if (annotation_level == 2)
364 printf_filtered (("\n\032\032display-expression-end\n"));
368 annotate_display_value (void)
370 if (annotation_level == 2)
371 printf_filtered (("\n\032\032display-value\n"));
375 annotate_display_end (void)
377 if (annotation_level == 2)
378 printf_filtered (("\n\032\032display-end\n"));
382 annotate_arg_begin (void)
384 if (annotation_level == 2)
385 printf_filtered (("\n\032\032arg-begin\n"));
389 annotate_arg_name_end (void)
391 if (annotation_level == 2)
392 printf_filtered (("\n\032\032arg-name-end\n"));
396 annotate_arg_value (struct type *type)
398 if (annotation_level == 2)
400 printf_filtered (("\n\032\032arg-value "));
401 print_value_flags (type);
402 printf_filtered (("\n"));
407 annotate_arg_end (void)
409 if (annotation_level == 2)
410 printf_filtered (("\n\032\032arg-end\n"));
414 annotate_source (char *filename, int line, int character, int mid,
415 struct gdbarch *gdbarch, CORE_ADDR pc)
417 if (annotation_level > 1)
418 printf_filtered (("\n\032\032source "));
420 printf_filtered (("\032\032"));
422 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
423 mid ? "middle" : "beg", paddress (gdbarch, pc));
427 annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
429 if (annotation_level > 1)
430 printf_filtered (("\n\032\032frame-begin %d %s\n"),
431 level, paddress (gdbarch, pc));
435 annotate_function_call (void)
437 if (annotation_level == 2)
438 printf_filtered (("\n\032\032function-call\n"));
442 annotate_signal_handler_caller (void)
444 if (annotation_level == 2)
445 printf_filtered (("\n\032\032signal-handler-caller\n"));
449 annotate_frame_address (void)
451 if (annotation_level == 2)
452 printf_filtered (("\n\032\032frame-address\n"));
456 annotate_frame_address_end (void)
458 if (annotation_level == 2)
459 printf_filtered (("\n\032\032frame-address-end\n"));
463 annotate_frame_function_name (void)
465 if (annotation_level == 2)
466 printf_filtered (("\n\032\032frame-function-name\n"));
470 annotate_frame_args (void)
472 if (annotation_level == 2)
473 printf_filtered (("\n\032\032frame-args\n"));
477 annotate_frame_source_begin (void)
479 if (annotation_level == 2)
480 printf_filtered (("\n\032\032frame-source-begin\n"));
484 annotate_frame_source_file (void)
486 if (annotation_level == 2)
487 printf_filtered (("\n\032\032frame-source-file\n"));
491 annotate_frame_source_file_end (void)
493 if (annotation_level == 2)
494 printf_filtered (("\n\032\032frame-source-file-end\n"));
498 annotate_frame_source_line (void)
500 if (annotation_level == 2)
501 printf_filtered (("\n\032\032frame-source-line\n"));
505 annotate_frame_source_end (void)
507 if (annotation_level == 2)
508 printf_filtered (("\n\032\032frame-source-end\n"));
512 annotate_frame_where (void)
514 if (annotation_level == 2)
515 printf_filtered (("\n\032\032frame-where\n"));
519 annotate_frame_end (void)
521 if (annotation_level == 2)
522 printf_filtered (("\n\032\032frame-end\n"));
526 annotate_array_section_begin (int idx, struct type *elttype)
528 if (annotation_level == 2)
530 printf_filtered (("\n\032\032array-section-begin %d "), idx);
531 print_value_flags (elttype);
532 printf_filtered (("\n"));
537 annotate_elt_rep (unsigned int repcount)
539 if (annotation_level == 2)
540 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
544 annotate_elt_rep_end (void)
546 if (annotation_level == 2)
547 printf_filtered (("\n\032\032elt-rep-end\n"));
553 if (annotation_level == 2)
554 printf_filtered (("\n\032\032elt\n"));
558 annotate_array_section_end (void)
560 if (annotation_level == 2)
561 printf_filtered (("\n\032\032array-section-end\n"));
564 /* Called when GDB is about to display the prompt. Used to reset
565 annotation suppression whenever we're ready to accept new
566 frontend/user commands. */
569 annotate_display_prompt (void)
571 frames_invalid_emitted = 0;
572 breakpoints_invalid_emitted = 0;
576 breakpoint_changed (struct breakpoint *b)
578 annotate_breakpoints_invalid ();
582 _initialize_annotate (void)
584 observer_attach_breakpoint_created (breakpoint_changed);
585 observer_attach_breakpoint_deleted (breakpoint_changed);
586 observer_attach_breakpoint_modified (breakpoint_changed);