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/>. */
24 #include "breakpoint.h"
25 #include "observable.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 target_terminal::scoped_restore_terminal_state term_state
;
65 target_terminal::ours_for_output ();
67 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
68 breakpoints_invalid_emitted
= 1;
73 annotate_breakpoint (int num
)
75 if (annotation_level
> 1)
76 printf_filtered (("\n\032\032breakpoint %d\n"), num
);
80 annotate_catchpoint (int num
)
82 if (annotation_level
> 1)
83 printf_filtered (("\n\032\032catchpoint %d\n"), num
);
87 annotate_watchpoint (int num
)
89 if (annotation_level
> 1)
90 printf_filtered (("\n\032\032watchpoint %d\n"), num
);
94 annotate_starting (void)
96 if (annotation_level
> 1)
97 printf_filtered (("\n\032\032starting\n"));
101 annotate_stopped (void)
103 if (annotation_level
> 1)
104 printf_filtered (("\n\032\032stopped\n"));
108 annotate_exited (int exitstatus
)
110 if (annotation_level
> 1)
111 printf_filtered (("\n\032\032exited %d\n"), exitstatus
);
115 annotate_signalled (void)
117 if (deprecated_annotate_signalled_hook
)
118 deprecated_annotate_signalled_hook ();
120 if (annotation_level
> 1)
121 printf_filtered (("\n\032\032signalled\n"));
125 annotate_signal_name (void)
127 if (annotation_level
== 2)
128 printf_filtered (("\n\032\032signal-name\n"));
132 annotate_signal_name_end (void)
134 if (annotation_level
== 2)
135 printf_filtered (("\n\032\032signal-name-end\n"));
139 annotate_signal_string (void)
141 if (annotation_level
== 2)
142 printf_filtered (("\n\032\032signal-string\n"));
146 annotate_signal_string_end (void)
148 if (annotation_level
== 2)
149 printf_filtered (("\n\032\032signal-string-end\n"));
153 annotate_signal (void)
155 if (deprecated_annotate_signal_hook
)
156 deprecated_annotate_signal_hook ();
158 if (annotation_level
> 1)
159 printf_filtered (("\n\032\032signal\n"));
163 annotate_breakpoints_headers (void)
165 if (annotation_level
== 2)
166 printf_filtered (("\n\032\032breakpoints-headers\n"));
170 annotate_field (int num
)
172 if (annotation_level
== 2)
173 printf_filtered (("\n\032\032field %d\n"), num
);
177 annotate_breakpoints_table (void)
179 if (annotation_level
== 2)
180 printf_filtered (("\n\032\032breakpoints-table\n"));
184 annotate_record (void)
186 if (annotation_level
== 2)
187 printf_filtered (("\n\032\032record\n"));
191 annotate_breakpoints_table_end (void)
193 if (annotation_level
== 2)
194 printf_filtered (("\n\032\032breakpoints-table-end\n"));
198 annotate_frames_invalid (void)
200 if (annotation_level
== 2
201 && (!frames_invalid_emitted
202 || current_ui
->prompt_state
!= PROMPT_BLOCKED
))
204 target_terminal::scoped_restore_terminal_state term_state
;
205 target_terminal::ours_for_output ();
207 printf_unfiltered (("\n\032\032frames-invalid\n"));
208 frames_invalid_emitted
= 1;
213 annotate_new_thread (void)
215 if (annotation_level
> 1)
217 printf_unfiltered (("\n\032\032new-thread\n"));
222 annotate_thread_changed (void)
224 if (annotation_level
> 1)
226 printf_unfiltered (("\n\032\032thread-changed\n"));
230 /* Emit notification on thread exit. */
233 annotate_thread_exited (struct thread_info
*t
, int silent
)
235 if (annotation_level
> 1)
237 printf_filtered(("\n\032\032thread-exited,"
238 "id=\"%d\",group-id=\"i%d\"\n"),
239 t
->global_num
, t
->inf
->num
);
244 annotate_field_begin (struct type
*type
)
246 if (annotation_level
== 2)
248 printf_filtered (("\n\032\032field-begin "));
249 print_value_flags (type
);
250 printf_filtered (("\n"));
255 annotate_field_name_end (void)
257 if (annotation_level
== 2)
258 printf_filtered (("\n\032\032field-name-end\n"));
262 annotate_field_value (void)
264 if (annotation_level
== 2)
265 printf_filtered (("\n\032\032field-value\n"));
269 annotate_field_end (void)
271 if (annotation_level
== 2)
272 printf_filtered (("\n\032\032field-end\n"));
278 if (annotation_level
> 1)
279 printf_filtered (("\n\032\032quit\n"));
283 annotate_error (void)
285 if (annotation_level
> 1)
286 printf_filtered (("\n\032\032error\n"));
290 annotate_error_begin (void)
292 if (annotation_level
> 1)
293 fprintf_filtered (gdb_stderr
, "\n\032\032error-begin\n");
297 annotate_value_history_begin (int histindex
, struct type
*type
)
299 if (annotation_level
== 2)
301 printf_filtered (("\n\032\032value-history-begin %d "), histindex
);
302 print_value_flags (type
);
303 printf_filtered (("\n"));
308 annotate_value_begin (struct type
*type
)
310 if (annotation_level
== 2)
312 printf_filtered (("\n\032\032value-begin "));
313 print_value_flags (type
);
314 printf_filtered (("\n"));
319 annotate_value_history_value (void)
321 if (annotation_level
== 2)
322 printf_filtered (("\n\032\032value-history-value\n"));
326 annotate_value_history_end (void)
328 if (annotation_level
== 2)
329 printf_filtered (("\n\032\032value-history-end\n"));
333 annotate_value_end (void)
335 if (annotation_level
== 2)
336 printf_filtered (("\n\032\032value-end\n"));
340 annotate_display_begin (void)
342 if (annotation_level
== 2)
343 printf_filtered (("\n\032\032display-begin\n"));
347 annotate_display_number_end (void)
349 if (annotation_level
== 2)
350 printf_filtered (("\n\032\032display-number-end\n"));
354 annotate_display_format (void)
356 if (annotation_level
== 2)
357 printf_filtered (("\n\032\032display-format\n"));
361 annotate_display_expression (void)
363 if (annotation_level
== 2)
364 printf_filtered (("\n\032\032display-expression\n"));
368 annotate_display_expression_end (void)
370 if (annotation_level
== 2)
371 printf_filtered (("\n\032\032display-expression-end\n"));
375 annotate_display_value (void)
377 if (annotation_level
== 2)
378 printf_filtered (("\n\032\032display-value\n"));
382 annotate_display_end (void)
384 if (annotation_level
== 2)
385 printf_filtered (("\n\032\032display-end\n"));
389 annotate_arg_begin (void)
391 if (annotation_level
== 2)
392 printf_filtered (("\n\032\032arg-begin\n"));
396 annotate_arg_name_end (void)
398 if (annotation_level
== 2)
399 printf_filtered (("\n\032\032arg-name-end\n"));
403 annotate_arg_value (struct type
*type
)
405 if (annotation_level
== 2)
407 printf_filtered (("\n\032\032arg-value "));
408 print_value_flags (type
);
409 printf_filtered (("\n"));
414 annotate_arg_end (void)
416 if (annotation_level
== 2)
417 printf_filtered (("\n\032\032arg-end\n"));
421 annotate_source (const char *filename
, int line
, int character
, int mid
,
422 struct gdbarch
*gdbarch
, CORE_ADDR pc
)
424 if (annotation_level
> 1)
425 printf_filtered (("\n\032\032source "));
427 printf_filtered (("\032\032"));
429 printf_filtered (("%s:%d:%d:%s:%s\n"), filename
, line
, character
,
430 mid
? "middle" : "beg", paddress (gdbarch
, pc
));
434 annotate_frame_begin (int level
, struct gdbarch
*gdbarch
, CORE_ADDR pc
)
436 if (annotation_level
> 1)
437 printf_filtered (("\n\032\032frame-begin %d %s\n"),
438 level
, paddress (gdbarch
, pc
));
442 annotate_function_call (void)
444 if (annotation_level
== 2)
445 printf_filtered (("\n\032\032function-call\n"));
449 annotate_signal_handler_caller (void)
451 if (annotation_level
== 2)
452 printf_filtered (("\n\032\032signal-handler-caller\n"));
456 annotate_frame_address (void)
458 if (annotation_level
== 2)
459 printf_filtered (("\n\032\032frame-address\n"));
463 annotate_frame_address_end (void)
465 if (annotation_level
== 2)
466 printf_filtered (("\n\032\032frame-address-end\n"));
470 annotate_frame_function_name (void)
472 if (annotation_level
== 2)
473 printf_filtered (("\n\032\032frame-function-name\n"));
477 annotate_frame_args (void)
479 if (annotation_level
== 2)
480 printf_filtered (("\n\032\032frame-args\n"));
484 annotate_frame_source_begin (void)
486 if (annotation_level
== 2)
487 printf_filtered (("\n\032\032frame-source-begin\n"));
491 annotate_frame_source_file (void)
493 if (annotation_level
== 2)
494 printf_filtered (("\n\032\032frame-source-file\n"));
498 annotate_frame_source_file_end (void)
500 if (annotation_level
== 2)
501 printf_filtered (("\n\032\032frame-source-file-end\n"));
505 annotate_frame_source_line (void)
507 if (annotation_level
== 2)
508 printf_filtered (("\n\032\032frame-source-line\n"));
512 annotate_frame_source_end (void)
514 if (annotation_level
== 2)
515 printf_filtered (("\n\032\032frame-source-end\n"));
519 annotate_frame_where (void)
521 if (annotation_level
== 2)
522 printf_filtered (("\n\032\032frame-where\n"));
526 annotate_frame_end (void)
528 if (annotation_level
== 2)
529 printf_filtered (("\n\032\032frame-end\n"));
533 annotate_array_section_begin (int idx
, struct type
*elttype
)
535 if (annotation_level
== 2)
537 printf_filtered (("\n\032\032array-section-begin %d "), idx
);
538 print_value_flags (elttype
);
539 printf_filtered (("\n"));
544 annotate_elt_rep (unsigned int repcount
)
546 if (annotation_level
== 2)
547 printf_filtered (("\n\032\032elt-rep %u\n"), repcount
);
551 annotate_elt_rep_end (void)
553 if (annotation_level
== 2)
554 printf_filtered (("\n\032\032elt-rep-end\n"));
560 if (annotation_level
== 2)
561 printf_filtered (("\n\032\032elt\n"));
565 annotate_array_section_end (void)
567 if (annotation_level
== 2)
568 printf_filtered (("\n\032\032array-section-end\n"));
571 /* Called when GDB is about to display the prompt. Used to reset
572 annotation suppression whenever we're ready to accept new
573 frontend/user commands. */
576 annotate_display_prompt (void)
578 frames_invalid_emitted
= 0;
579 breakpoints_invalid_emitted
= 0;
583 breakpoint_changed (struct breakpoint
*b
)
588 annotate_breakpoints_invalid ();
592 _initialize_annotate (void)
594 gdb::observers::breakpoint_created
.attach (breakpoint_changed
);
595 gdb::observers::breakpoint_deleted
.attach (breakpoint_changed
);
596 gdb::observers::breakpoint_modified
.attach (breakpoint_changed
);
597 gdb::observers::thread_exit
.attach (annotate_thread_exited
);