1 /* Annotation routines for GDB.
2 Copyright (C) 1986-2019 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/>. */
21 /* Local non-gdb includes. */
23 #include "breakpoint.h"
27 #include "observable.h"
34 /* Prototypes for local functions. */
36 static void print_value_flags (struct type
*);
38 static void breakpoint_changed (struct breakpoint
*b
);
41 void (*deprecated_annotate_signalled_hook
) (void);
42 void (*deprecated_annotate_signal_hook
) (void);
44 /* Booleans indicating whether we've emitted certain notifications.
45 Used to suppress useless repeated notifications until the next time
46 we're ready to accept more commands. Reset whenever a prompt is
48 static int frames_invalid_emitted
;
49 static int breakpoints_invalid_emitted
;
52 print_value_flags (struct type
*t
)
54 if (can_dereference (t
))
55 printf_filtered (("*"));
57 printf_filtered (("-"));
61 annotate_breakpoints_invalid (void)
63 if (annotation_level
== 2
64 && (!breakpoints_invalid_emitted
65 || current_ui
->prompt_state
!= PROMPT_BLOCKED
))
67 /* If the inferior owns the terminal (e.g., we're resuming),
68 make sure to leave with the inferior still owning it. */
69 int was_inferior
= target_terminal::is_inferior ();
71 target_terminal::ours_for_output ();
73 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
76 target_terminal::inferior ();
78 breakpoints_invalid_emitted
= 1;
83 annotate_breakpoint (int num
)
85 if (annotation_level
> 1)
86 printf_filtered (("\n\032\032breakpoint %d\n"), num
);
90 annotate_catchpoint (int num
)
92 if (annotation_level
> 1)
93 printf_filtered (("\n\032\032catchpoint %d\n"), num
);
97 annotate_watchpoint (int num
)
99 if (annotation_level
> 1)
100 printf_filtered (("\n\032\032watchpoint %d\n"), num
);
104 annotate_starting (void)
106 if (annotation_level
> 1)
107 printf_filtered (("\n\032\032starting\n"));
111 annotate_stopped (void)
113 if (annotation_level
> 1)
114 printf_filtered (("\n\032\032stopped\n"));
118 annotate_exited (int exitstatus
)
120 if (annotation_level
> 1)
121 printf_filtered (("\n\032\032exited %d\n"), exitstatus
);
125 annotate_signalled (void)
127 if (deprecated_annotate_signalled_hook
)
128 deprecated_annotate_signalled_hook ();
130 if (annotation_level
> 1)
131 printf_filtered (("\n\032\032signalled\n"));
135 annotate_signal_name (void)
137 if (annotation_level
== 2)
138 printf_filtered (("\n\032\032signal-name\n"));
142 annotate_signal_name_end (void)
144 if (annotation_level
== 2)
145 printf_filtered (("\n\032\032signal-name-end\n"));
149 annotate_signal_string (void)
151 if (annotation_level
== 2)
152 printf_filtered (("\n\032\032signal-string\n"));
156 annotate_signal_string_end (void)
158 if (annotation_level
== 2)
159 printf_filtered (("\n\032\032signal-string-end\n"));
163 annotate_signal (void)
165 if (deprecated_annotate_signal_hook
)
166 deprecated_annotate_signal_hook ();
168 if (annotation_level
> 1)
169 printf_filtered (("\n\032\032signal\n"));
173 annotate_breakpoints_headers (void)
175 if (annotation_level
== 2)
176 printf_filtered (("\n\032\032breakpoints-headers\n"));
180 annotate_field (int num
)
182 if (annotation_level
== 2)
183 printf_filtered (("\n\032\032field %d\n"), num
);
187 annotate_breakpoints_table (void)
189 if (annotation_level
== 2)
190 printf_filtered (("\n\032\032breakpoints-table\n"));
194 annotate_record (void)
196 if (annotation_level
== 2)
197 printf_filtered (("\n\032\032record\n"));
201 annotate_breakpoints_table_end (void)
203 if (annotation_level
== 2)
204 printf_filtered (("\n\032\032breakpoints-table-end\n"));
208 annotate_frames_invalid (void)
210 if (annotation_level
== 2
211 && (!frames_invalid_emitted
212 || current_ui
->prompt_state
!= PROMPT_BLOCKED
))
214 /* If the inferior owns the terminal (e.g., we're resuming),
215 make sure to leave with the inferior still owning it. */
216 int was_inferior
= target_terminal::is_inferior ();
218 target_terminal::ours_for_output ();
220 printf_unfiltered (("\n\032\032frames-invalid\n"));
223 target_terminal::inferior ();
225 frames_invalid_emitted
= 1;
230 annotate_new_thread (void)
232 if (annotation_level
> 1)
234 printf_unfiltered (("\n\032\032new-thread\n"));
239 annotate_thread_changed (void)
241 if (annotation_level
> 1)
243 printf_unfiltered (("\n\032\032thread-changed\n"));
248 annotate_field_begin (struct type
*type
)
250 if (annotation_level
== 2)
252 printf_filtered (("\n\032\032field-begin "));
253 print_value_flags (type
);
254 printf_filtered (("\n"));
259 annotate_field_name_end (void)
261 if (annotation_level
== 2)
262 printf_filtered (("\n\032\032field-name-end\n"));
266 annotate_field_value (void)
268 if (annotation_level
== 2)
269 printf_filtered (("\n\032\032field-value\n"));
273 annotate_field_end (void)
275 if (annotation_level
== 2)
276 printf_filtered (("\n\032\032field-end\n"));
282 if (annotation_level
> 1)
283 printf_filtered (("\n\032\032quit\n"));
287 annotate_error (void)
289 if (annotation_level
> 1)
290 printf_filtered (("\n\032\032error\n"));
294 annotate_error_begin (void)
296 if (annotation_level
> 1)
297 fprintf_filtered (gdb_stderr
, "\n\032\032error-begin\n");
301 annotate_value_history_begin (int histindex
, struct type
*type
)
303 if (annotation_level
== 2)
305 printf_filtered (("\n\032\032value-history-begin %d "), histindex
);
306 print_value_flags (type
);
307 printf_filtered (("\n"));
312 annotate_value_begin (struct type
*type
)
314 if (annotation_level
== 2)
316 printf_filtered (("\n\032\032value-begin "));
317 print_value_flags (type
);
318 printf_filtered (("\n"));
323 annotate_value_history_value (void)
325 if (annotation_level
== 2)
326 printf_filtered (("\n\032\032value-history-value\n"));
330 annotate_value_history_end (void)
332 if (annotation_level
== 2)
333 printf_filtered (("\n\032\032value-history-end\n"));
337 annotate_value_end (void)
339 if (annotation_level
== 2)
340 printf_filtered (("\n\032\032value-end\n"));
344 annotate_display_begin (void)
346 if (annotation_level
== 2)
347 printf_filtered (("\n\032\032display-begin\n"));
351 annotate_display_number_end (void)
353 if (annotation_level
== 2)
354 printf_filtered (("\n\032\032display-number-end\n"));
358 annotate_display_format (void)
360 if (annotation_level
== 2)
361 printf_filtered (("\n\032\032display-format\n"));
365 annotate_display_expression (void)
367 if (annotation_level
== 2)
368 printf_filtered (("\n\032\032display-expression\n"));
372 annotate_display_expression_end (void)
374 if (annotation_level
== 2)
375 printf_filtered (("\n\032\032display-expression-end\n"));
379 annotate_display_value (void)
381 if (annotation_level
== 2)
382 printf_filtered (("\n\032\032display-value\n"));
386 annotate_display_end (void)
388 if (annotation_level
== 2)
389 printf_filtered (("\n\032\032display-end\n"));
393 annotate_arg_begin (void)
395 if (annotation_level
== 2)
396 printf_filtered (("\n\032\032arg-begin\n"));
400 annotate_arg_name_end (void)
402 if (annotation_level
== 2)
403 printf_filtered (("\n\032\032arg-name-end\n"));
407 annotate_arg_value (struct type
*type
)
409 if (annotation_level
== 2)
411 printf_filtered (("\n\032\032arg-value "));
412 print_value_flags (type
);
413 printf_filtered (("\n"));
418 annotate_arg_end (void)
420 if (annotation_level
== 2)
421 printf_filtered (("\n\032\032arg-end\n"));
425 annotate_source (char *filename
, int line
, int character
, int mid
,
426 struct gdbarch
*gdbarch
, CORE_ADDR pc
)
428 if (annotation_level
> 1)
429 printf_filtered (("\n\032\032source "));
431 printf_filtered (("\032\032"));
433 printf_filtered (("%s:%d:%d:%s:%s\n"), filename
, line
, character
,
434 mid
? "middle" : "beg", paddress (gdbarch
, pc
));
438 annotate_frame_begin (int level
, struct gdbarch
*gdbarch
, CORE_ADDR pc
)
440 if (annotation_level
> 1)
441 printf_filtered (("\n\032\032frame-begin %d %s\n"),
442 level
, paddress (gdbarch
, pc
));
446 annotate_function_call (void)
448 if (annotation_level
== 2)
449 printf_filtered (("\n\032\032function-call\n"));
453 annotate_signal_handler_caller (void)
455 if (annotation_level
== 2)
456 printf_filtered (("\n\032\032signal-handler-caller\n"));
460 annotate_frame_address (void)
462 if (annotation_level
== 2)
463 printf_filtered (("\n\032\032frame-address\n"));
467 annotate_frame_address_end (void)
469 if (annotation_level
== 2)
470 printf_filtered (("\n\032\032frame-address-end\n"));
474 annotate_frame_function_name (void)
476 if (annotation_level
== 2)
477 printf_filtered (("\n\032\032frame-function-name\n"));
481 annotate_frame_args (void)
483 if (annotation_level
== 2)
484 printf_filtered (("\n\032\032frame-args\n"));
488 annotate_frame_source_begin (void)
490 if (annotation_level
== 2)
491 printf_filtered (("\n\032\032frame-source-begin\n"));
495 annotate_frame_source_file (void)
497 if (annotation_level
== 2)
498 printf_filtered (("\n\032\032frame-source-file\n"));
502 annotate_frame_source_file_end (void)
504 if (annotation_level
== 2)
505 printf_filtered (("\n\032\032frame-source-file-end\n"));
509 annotate_frame_source_line (void)
511 if (annotation_level
== 2)
512 printf_filtered (("\n\032\032frame-source-line\n"));
516 annotate_frame_source_end (void)
518 if (annotation_level
== 2)
519 printf_filtered (("\n\032\032frame-source-end\n"));
523 annotate_frame_where (void)
525 if (annotation_level
== 2)
526 printf_filtered (("\n\032\032frame-where\n"));
530 annotate_frame_end (void)
532 if (annotation_level
== 2)
533 printf_filtered (("\n\032\032frame-end\n"));
537 annotate_array_section_begin (int idx
, struct type
*elttype
)
539 if (annotation_level
== 2)
541 printf_filtered (("\n\032\032array-section-begin %d "), idx
);
542 print_value_flags (elttype
);
543 printf_filtered (("\n"));
548 annotate_elt_rep (unsigned int repcount
)
550 if (annotation_level
== 2)
551 printf_filtered (("\n\032\032elt-rep %u\n"), repcount
);
555 annotate_elt_rep_end (void)
557 if (annotation_level
== 2)
558 printf_filtered (("\n\032\032elt-rep-end\n"));
564 if (annotation_level
== 2)
565 printf_filtered (("\n\032\032elt\n"));
569 annotate_array_section_end (void)
571 if (annotation_level
== 2)
572 printf_filtered (("\n\032\032array-section-end\n"));
575 /* Called when GDB is about to display the prompt. Used to reset
576 annotation suppression whenever we're ready to accept new
577 frontend/user commands. */
580 annotate_display_prompt (void)
582 frames_invalid_emitted
= 0;
583 breakpoints_invalid_emitted
= 0;
587 breakpoint_changed (struct breakpoint
*b
)
592 annotate_breakpoints_invalid ();
596 _initialize_annotate (void)
598 gdb::observers::breakpoint_created
.attach (breakpoint_changed
);
599 gdb::observers::breakpoint_deleted
.attach (breakpoint_changed
);
600 gdb::observers::breakpoint_modified
.attach (breakpoint_changed
);