1 /* Annotation routines for GDB.
2 Copyright (C) 1986-2018 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"
31 /* Prototypes for local functions. */
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;
49 print_value_flags (struct type *t)
51 if (can_dereference (t))
52 printf_filtered (("*"));
54 printf_filtered (("-"));
58 annotate_breakpoints_invalid (void)
60 if (annotation_level == 2
61 && (!breakpoints_invalid_emitted
62 || current_ui->prompt_state != PROMPT_BLOCKED))
64 /* If the inferior owns the terminal (e.g., we're resuming),
65 make sure to leave with the inferior still owning it. */
66 int was_inferior = target_terminal::is_inferior ();
68 target_terminal::ours_for_output ();
70 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
73 target_terminal::inferior ();
75 breakpoints_invalid_emitted = 1;
80 annotate_breakpoint (int num)
82 if (annotation_level > 1)
83 printf_filtered (("\n\032\032breakpoint %d\n"), num);
87 annotate_catchpoint (int num)
89 if (annotation_level > 1)
90 printf_filtered (("\n\032\032catchpoint %d\n"), num);
94 annotate_watchpoint (int num)
96 if (annotation_level > 1)
97 printf_filtered (("\n\032\032watchpoint %d\n"), num);
101 annotate_starting (void)
103 if (annotation_level > 1)
104 printf_filtered (("\n\032\032starting\n"));
108 annotate_stopped (void)
110 if (annotation_level > 1)
111 printf_filtered (("\n\032\032stopped\n"));
115 annotate_exited (int exitstatus)
117 if (annotation_level > 1)
118 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
122 annotate_signalled (void)
124 if (deprecated_annotate_signalled_hook)
125 deprecated_annotate_signalled_hook ();
127 if (annotation_level > 1)
128 printf_filtered (("\n\032\032signalled\n"));
132 annotate_signal_name (void)
134 if (annotation_level == 2)
135 printf_filtered (("\n\032\032signal-name\n"));
139 annotate_signal_name_end (void)
141 if (annotation_level == 2)
142 printf_filtered (("\n\032\032signal-name-end\n"));
146 annotate_signal_string (void)
148 if (annotation_level == 2)
149 printf_filtered (("\n\032\032signal-string\n"));
153 annotate_signal_string_end (void)
155 if (annotation_level == 2)
156 printf_filtered (("\n\032\032signal-string-end\n"));
160 annotate_signal (void)
162 if (deprecated_annotate_signal_hook)
163 deprecated_annotate_signal_hook ();
165 if (annotation_level > 1)
166 printf_filtered (("\n\032\032signal\n"));
170 annotate_breakpoints_headers (void)
172 if (annotation_level == 2)
173 printf_filtered (("\n\032\032breakpoints-headers\n"));
177 annotate_field (int num)
179 if (annotation_level == 2)
180 printf_filtered (("\n\032\032field %d\n"), num);
184 annotate_breakpoints_table (void)
186 if (annotation_level == 2)
187 printf_filtered (("\n\032\032breakpoints-table\n"));
191 annotate_record (void)
193 if (annotation_level == 2)
194 printf_filtered (("\n\032\032record\n"));
198 annotate_breakpoints_table_end (void)
200 if (annotation_level == 2)
201 printf_filtered (("\n\032\032breakpoints-table-end\n"));
205 annotate_frames_invalid (void)
207 if (annotation_level == 2
208 && (!frames_invalid_emitted
209 || current_ui->prompt_state != PROMPT_BLOCKED))
211 /* If the inferior owns the terminal (e.g., we're resuming),
212 make sure to leave with the inferior still owning it. */
213 int was_inferior = target_terminal::is_inferior ();
215 target_terminal::ours_for_output ();
217 printf_unfiltered (("\n\032\032frames-invalid\n"));
220 target_terminal::inferior ();
222 frames_invalid_emitted = 1;
227 annotate_new_thread (void)
229 if (annotation_level > 1)
231 printf_unfiltered (("\n\032\032new-thread\n"));
236 annotate_thread_changed (void)
238 if (annotation_level > 1)
240 printf_unfiltered (("\n\032\032thread-changed\n"));
245 annotate_field_begin (struct type *type)
247 if (annotation_level == 2)
249 printf_filtered (("\n\032\032field-begin "));
250 print_value_flags (type);
251 printf_filtered (("\n"));
256 annotate_field_name_end (void)
258 if (annotation_level == 2)
259 printf_filtered (("\n\032\032field-name-end\n"));
263 annotate_field_value (void)
265 if (annotation_level == 2)
266 printf_filtered (("\n\032\032field-value\n"));
270 annotate_field_end (void)
272 if (annotation_level == 2)
273 printf_filtered (("\n\032\032field-end\n"));
279 if (annotation_level > 1)
280 printf_filtered (("\n\032\032quit\n"));
284 annotate_error (void)
286 if (annotation_level > 1)
287 printf_filtered (("\n\032\032error\n"));
291 annotate_error_begin (void)
293 if (annotation_level > 1)
294 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
298 annotate_value_history_begin (int histindex, struct type *type)
300 if (annotation_level == 2)
302 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
303 print_value_flags (type);
304 printf_filtered (("\n"));
309 annotate_value_begin (struct type *type)
311 if (annotation_level == 2)
313 printf_filtered (("\n\032\032value-begin "));
314 print_value_flags (type);
315 printf_filtered (("\n"));
320 annotate_value_history_value (void)
322 if (annotation_level == 2)
323 printf_filtered (("\n\032\032value-history-value\n"));
327 annotate_value_history_end (void)
329 if (annotation_level == 2)
330 printf_filtered (("\n\032\032value-history-end\n"));
334 annotate_value_end (void)
336 if (annotation_level == 2)
337 printf_filtered (("\n\032\032value-end\n"));
341 annotate_display_begin (void)
343 if (annotation_level == 2)
344 printf_filtered (("\n\032\032display-begin\n"));
348 annotate_display_number_end (void)
350 if (annotation_level == 2)
351 printf_filtered (("\n\032\032display-number-end\n"));
355 annotate_display_format (void)
357 if (annotation_level == 2)
358 printf_filtered (("\n\032\032display-format\n"));
362 annotate_display_expression (void)
364 if (annotation_level == 2)
365 printf_filtered (("\n\032\032display-expression\n"));
369 annotate_display_expression_end (void)
371 if (annotation_level == 2)
372 printf_filtered (("\n\032\032display-expression-end\n"));
376 annotate_display_value (void)
378 if (annotation_level == 2)
379 printf_filtered (("\n\032\032display-value\n"));
383 annotate_display_end (void)
385 if (annotation_level == 2)
386 printf_filtered (("\n\032\032display-end\n"));
390 annotate_arg_begin (void)
392 if (annotation_level == 2)
393 printf_filtered (("\n\032\032arg-begin\n"));
397 annotate_arg_name_end (void)
399 if (annotation_level == 2)
400 printf_filtered (("\n\032\032arg-name-end\n"));
404 annotate_arg_value (struct type *type)
406 if (annotation_level == 2)
408 printf_filtered (("\n\032\032arg-value "));
409 print_value_flags (type);
410 printf_filtered (("\n"));
415 annotate_arg_end (void)
417 if (annotation_level == 2)
418 printf_filtered (("\n\032\032arg-end\n"));
422 annotate_source (char *filename, int line, int character, int mid,
423 struct gdbarch *gdbarch, 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:%s\n"), filename, line, character,
431 mid ? "middle" : "beg", paddress (gdbarch, pc));
435 annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
437 if (annotation_level > 1)
438 printf_filtered (("\n\032\032frame-begin %d %s\n"),
439 level, paddress (gdbarch, pc));
443 annotate_function_call (void)
445 if (annotation_level == 2)
446 printf_filtered (("\n\032\032function-call\n"));
450 annotate_signal_handler_caller (void)
452 if (annotation_level == 2)
453 printf_filtered (("\n\032\032signal-handler-caller\n"));
457 annotate_frame_address (void)
459 if (annotation_level == 2)
460 printf_filtered (("\n\032\032frame-address\n"));
464 annotate_frame_address_end (void)
466 if (annotation_level == 2)
467 printf_filtered (("\n\032\032frame-address-end\n"));
471 annotate_frame_function_name (void)
473 if (annotation_level == 2)
474 printf_filtered (("\n\032\032frame-function-name\n"));
478 annotate_frame_args (void)
480 if (annotation_level == 2)
481 printf_filtered (("\n\032\032frame-args\n"));
485 annotate_frame_source_begin (void)
487 if (annotation_level == 2)
488 printf_filtered (("\n\032\032frame-source-begin\n"));
492 annotate_frame_source_file (void)
494 if (annotation_level == 2)
495 printf_filtered (("\n\032\032frame-source-file\n"));
499 annotate_frame_source_file_end (void)
501 if (annotation_level == 2)
502 printf_filtered (("\n\032\032frame-source-file-end\n"));
506 annotate_frame_source_line (void)
508 if (annotation_level == 2)
509 printf_filtered (("\n\032\032frame-source-line\n"));
513 annotate_frame_source_end (void)
515 if (annotation_level == 2)
516 printf_filtered (("\n\032\032frame-source-end\n"));
520 annotate_frame_where (void)
522 if (annotation_level == 2)
523 printf_filtered (("\n\032\032frame-where\n"));
527 annotate_frame_end (void)
529 if (annotation_level == 2)
530 printf_filtered (("\n\032\032frame-end\n"));
534 annotate_array_section_begin (int idx, struct type *elttype)
536 if (annotation_level == 2)
538 printf_filtered (("\n\032\032array-section-begin %d "), idx);
539 print_value_flags (elttype);
540 printf_filtered (("\n"));
545 annotate_elt_rep (unsigned int repcount)
547 if (annotation_level == 2)
548 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
552 annotate_elt_rep_end (void)
554 if (annotation_level == 2)
555 printf_filtered (("\n\032\032elt-rep-end\n"));
561 if (annotation_level == 2)
562 printf_filtered (("\n\032\032elt\n"));
566 annotate_array_section_end (void)
568 if (annotation_level == 2)
569 printf_filtered (("\n\032\032array-section-end\n"));
572 /* Called when GDB is about to display the prompt. Used to reset
573 annotation suppression whenever we're ready to accept new
574 frontend/user commands. */
577 annotate_display_prompt (void)
579 frames_invalid_emitted = 0;
580 breakpoints_invalid_emitted = 0;
584 breakpoint_changed (struct breakpoint *b)
589 annotate_breakpoints_invalid ();
593 _initialize_annotate (void)
595 observer_attach_breakpoint_created (breakpoint_changed);
596 observer_attach_breakpoint_deleted (breakpoint_changed);
597 observer_attach_breakpoint_modified (breakpoint_changed);