1 /* Annotation routines for GDB.
2 Copyright (C) 1986-2016 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 extern void _initialize_annotate (void);
35 static void print_value_flags (struct type
*);
37 static void breakpoint_changed (struct breakpoint
*b
);
40 void (*deprecated_annotate_signalled_hook
) (void);
41 void (*deprecated_annotate_signal_hook
) (void);
43 /* Booleans indicating whether we've emitted certain notifications.
44 Used to suppress useless repeated notifications until the next time
45 we're ready to accept more commands. Reset whenever a prompt is
47 static int frames_invalid_emitted
;
48 static int breakpoints_invalid_emitted
;
51 print_value_flags (struct type
*t
)
53 if (can_dereference (t
))
54 printf_filtered (("*"));
56 printf_filtered (("-"));
60 annotate_breakpoints_invalid (void)
62 if (annotation_level
== 2
63 && (!breakpoints_invalid_emitted
64 || current_ui
->prompt_state
!= PROMPT_BLOCKED
))
66 /* If the inferior owns the terminal (e.g., we're resuming),
67 make sure to leave with the inferior still owning it. */
68 int was_inferior
= target_terminal_is_inferior ();
70 target_terminal_ours_for_output ();
72 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
75 target_terminal_inferior ();
77 breakpoints_invalid_emitted
= 1;
82 annotate_breakpoint (int num
)
84 if (annotation_level
> 1)
85 printf_filtered (("\n\032\032breakpoint %d\n"), num
);
89 annotate_catchpoint (int num
)
91 if (annotation_level
> 1)
92 printf_filtered (("\n\032\032catchpoint %d\n"), num
);
96 annotate_watchpoint (int num
)
98 if (annotation_level
> 1)
99 printf_filtered (("\n\032\032watchpoint %d\n"), num
);
103 annotate_starting (void)
105 if (annotation_level
> 1)
106 printf_filtered (("\n\032\032starting\n"));
110 annotate_stopped (void)
112 if (annotation_level
> 1)
113 printf_filtered (("\n\032\032stopped\n"));
117 annotate_exited (int exitstatus
)
119 if (annotation_level
> 1)
120 printf_filtered (("\n\032\032exited %d\n"), exitstatus
);
124 annotate_signalled (void)
126 if (deprecated_annotate_signalled_hook
)
127 deprecated_annotate_signalled_hook ();
129 if (annotation_level
> 1)
130 printf_filtered (("\n\032\032signalled\n"));
134 annotate_signal_name (void)
136 if (annotation_level
== 2)
137 printf_filtered (("\n\032\032signal-name\n"));
141 annotate_signal_name_end (void)
143 if (annotation_level
== 2)
144 printf_filtered (("\n\032\032signal-name-end\n"));
148 annotate_signal_string (void)
150 if (annotation_level
== 2)
151 printf_filtered (("\n\032\032signal-string\n"));
155 annotate_signal_string_end (void)
157 if (annotation_level
== 2)
158 printf_filtered (("\n\032\032signal-string-end\n"));
162 annotate_signal (void)
164 if (deprecated_annotate_signal_hook
)
165 deprecated_annotate_signal_hook ();
167 if (annotation_level
> 1)
168 printf_filtered (("\n\032\032signal\n"));
172 annotate_breakpoints_headers (void)
174 if (annotation_level
== 2)
175 printf_filtered (("\n\032\032breakpoints-headers\n"));
179 annotate_field (int num
)
181 if (annotation_level
== 2)
182 printf_filtered (("\n\032\032field %d\n"), num
);
186 annotate_breakpoints_table (void)
188 if (annotation_level
== 2)
189 printf_filtered (("\n\032\032breakpoints-table\n"));
193 annotate_record (void)
195 if (annotation_level
== 2)
196 printf_filtered (("\n\032\032record\n"));
200 annotate_breakpoints_table_end (void)
202 if (annotation_level
== 2)
203 printf_filtered (("\n\032\032breakpoints-table-end\n"));
207 annotate_frames_invalid (void)
209 if (annotation_level
== 2
210 && (!frames_invalid_emitted
211 || current_ui
->prompt_state
!= PROMPT_BLOCKED
))
213 /* If the inferior owns the terminal (e.g., we're resuming),
214 make sure to leave with the inferior still owning it. */
215 int was_inferior
= target_terminal_is_inferior ();
217 target_terminal_ours_for_output ();
219 printf_unfiltered (("\n\032\032frames-invalid\n"));
222 target_terminal_inferior ();
224 frames_invalid_emitted
= 1;
229 annotate_new_thread (void)
231 if (annotation_level
> 1)
233 printf_unfiltered (("\n\032\032new-thread\n"));
238 annotate_thread_changed (void)
240 if (annotation_level
> 1)
242 printf_unfiltered (("\n\032\032thread-changed\n"));
247 annotate_field_begin (struct type
*type
)
249 if (annotation_level
== 2)
251 printf_filtered (("\n\032\032field-begin "));
252 print_value_flags (type
);
253 printf_filtered (("\n"));
258 annotate_field_name_end (void)
260 if (annotation_level
== 2)
261 printf_filtered (("\n\032\032field-name-end\n"));
265 annotate_field_value (void)
267 if (annotation_level
== 2)
268 printf_filtered (("\n\032\032field-value\n"));
272 annotate_field_end (void)
274 if (annotation_level
== 2)
275 printf_filtered (("\n\032\032field-end\n"));
281 if (annotation_level
> 1)
282 printf_filtered (("\n\032\032quit\n"));
286 annotate_error (void)
288 if (annotation_level
> 1)
289 printf_filtered (("\n\032\032error\n"));
293 annotate_error_begin (void)
295 if (annotation_level
> 1)
296 fprintf_filtered (gdb_stderr
, "\n\032\032error-begin\n");
300 annotate_value_history_begin (int histindex
, struct type
*type
)
302 if (annotation_level
== 2)
304 printf_filtered (("\n\032\032value-history-begin %d "), histindex
);
305 print_value_flags (type
);
306 printf_filtered (("\n"));
311 annotate_value_begin (struct type
*type
)
313 if (annotation_level
== 2)
315 printf_filtered (("\n\032\032value-begin "));
316 print_value_flags (type
);
317 printf_filtered (("\n"));
322 annotate_value_history_value (void)
324 if (annotation_level
== 2)
325 printf_filtered (("\n\032\032value-history-value\n"));
329 annotate_value_history_end (void)
331 if (annotation_level
== 2)
332 printf_filtered (("\n\032\032value-history-end\n"));
336 annotate_value_end (void)
338 if (annotation_level
== 2)
339 printf_filtered (("\n\032\032value-end\n"));
343 annotate_display_begin (void)
345 if (annotation_level
== 2)
346 printf_filtered (("\n\032\032display-begin\n"));
350 annotate_display_number_end (void)
352 if (annotation_level
== 2)
353 printf_filtered (("\n\032\032display-number-end\n"));
357 annotate_display_format (void)
359 if (annotation_level
== 2)
360 printf_filtered (("\n\032\032display-format\n"));
364 annotate_display_expression (void)
366 if (annotation_level
== 2)
367 printf_filtered (("\n\032\032display-expression\n"));
371 annotate_display_expression_end (void)
373 if (annotation_level
== 2)
374 printf_filtered (("\n\032\032display-expression-end\n"));
378 annotate_display_value (void)
380 if (annotation_level
== 2)
381 printf_filtered (("\n\032\032display-value\n"));
385 annotate_display_end (void)
387 if (annotation_level
== 2)
388 printf_filtered (("\n\032\032display-end\n"));
392 annotate_arg_begin (void)
394 if (annotation_level
== 2)
395 printf_filtered (("\n\032\032arg-begin\n"));
399 annotate_arg_name_end (void)
401 if (annotation_level
== 2)
402 printf_filtered (("\n\032\032arg-name-end\n"));
406 annotate_arg_value (struct type
*type
)
408 if (annotation_level
== 2)
410 printf_filtered (("\n\032\032arg-value "));
411 print_value_flags (type
);
412 printf_filtered (("\n"));
417 annotate_arg_end (void)
419 if (annotation_level
== 2)
420 printf_filtered (("\n\032\032arg-end\n"));
424 annotate_source (char *filename
, int line
, int character
, int mid
,
425 struct gdbarch
*gdbarch
, CORE_ADDR pc
)
427 if (annotation_level
> 1)
428 printf_filtered (("\n\032\032source "));
430 printf_filtered (("\032\032"));
432 printf_filtered (("%s:%d:%d:%s:%s\n"), filename
, line
, character
,
433 mid
? "middle" : "beg", paddress (gdbarch
, pc
));
437 annotate_frame_begin (int level
, struct gdbarch
*gdbarch
, CORE_ADDR pc
)
439 if (annotation_level
> 1)
440 printf_filtered (("\n\032\032frame-begin %d %s\n"),
441 level
, paddress (gdbarch
, pc
));
445 annotate_function_call (void)
447 if (annotation_level
== 2)
448 printf_filtered (("\n\032\032function-call\n"));
452 annotate_signal_handler_caller (void)
454 if (annotation_level
== 2)
455 printf_filtered (("\n\032\032signal-handler-caller\n"));
459 annotate_frame_address (void)
461 if (annotation_level
== 2)
462 printf_filtered (("\n\032\032frame-address\n"));
466 annotate_frame_address_end (void)
468 if (annotation_level
== 2)
469 printf_filtered (("\n\032\032frame-address-end\n"));
473 annotate_frame_function_name (void)
475 if (annotation_level
== 2)
476 printf_filtered (("\n\032\032frame-function-name\n"));
480 annotate_frame_args (void)
482 if (annotation_level
== 2)
483 printf_filtered (("\n\032\032frame-args\n"));
487 annotate_frame_source_begin (void)
489 if (annotation_level
== 2)
490 printf_filtered (("\n\032\032frame-source-begin\n"));
494 annotate_frame_source_file (void)
496 if (annotation_level
== 2)
497 printf_filtered (("\n\032\032frame-source-file\n"));
501 annotate_frame_source_file_end (void)
503 if (annotation_level
== 2)
504 printf_filtered (("\n\032\032frame-source-file-end\n"));
508 annotate_frame_source_line (void)
510 if (annotation_level
== 2)
511 printf_filtered (("\n\032\032frame-source-line\n"));
515 annotate_frame_source_end (void)
517 if (annotation_level
== 2)
518 printf_filtered (("\n\032\032frame-source-end\n"));
522 annotate_frame_where (void)
524 if (annotation_level
== 2)
525 printf_filtered (("\n\032\032frame-where\n"));
529 annotate_frame_end (void)
531 if (annotation_level
== 2)
532 printf_filtered (("\n\032\032frame-end\n"));
536 annotate_array_section_begin (int idx
, struct type
*elttype
)
538 if (annotation_level
== 2)
540 printf_filtered (("\n\032\032array-section-begin %d "), idx
);
541 print_value_flags (elttype
);
542 printf_filtered (("\n"));
547 annotate_elt_rep (unsigned int repcount
)
549 if (annotation_level
== 2)
550 printf_filtered (("\n\032\032elt-rep %u\n"), repcount
);
554 annotate_elt_rep_end (void)
556 if (annotation_level
== 2)
557 printf_filtered (("\n\032\032elt-rep-end\n"));
563 if (annotation_level
== 2)
564 printf_filtered (("\n\032\032elt\n"));
568 annotate_array_section_end (void)
570 if (annotation_level
== 2)
571 printf_filtered (("\n\032\032array-section-end\n"));
574 /* Called when GDB is about to display the prompt. Used to reset
575 annotation suppression whenever we're ready to accept new
576 frontend/user commands. */
579 annotate_display_prompt (void)
581 frames_invalid_emitted
= 0;
582 breakpoints_invalid_emitted
= 0;
586 breakpoint_changed (struct breakpoint
*b
)
591 annotate_breakpoints_invalid ();
595 _initialize_annotate (void)
597 observer_attach_breakpoint_created (breakpoint_changed
);
598 observer_attach_breakpoint_deleted (breakpoint_changed
);
599 observer_attach_breakpoint_modified (breakpoint_changed
);