ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / annotate.c
blob3e257c44feabe72cbcad67654602cea03d7b3652
1 /* Annotation routines for GDB.
2 Copyright (C) 1986-2015 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/>. */
19 #include "defs.h"
20 #include "annotate.h"
21 #include "value.h"
22 #include "target.h"
23 #include "gdbtypes.h"
24 #include "breakpoint.h"
25 #include "observer.h"
26 #include "inferior.h"
27 #include "infrun.h"
30 /* Prototypes for local functions. */
32 extern void _initialize_annotate (void);
34 static void print_value_flags (struct type *);
36 static void breakpoint_changed (struct breakpoint *b);
39 void (*deprecated_annotate_signalled_hook) (void);
40 void (*deprecated_annotate_signal_hook) (void);
42 /* Booleans indicating whether we've emitted certain notifications.
43 Used to suppress useless repeated notifications until the next time
44 we're ready to accept more commands. Reset whenever a prompt is
45 displayed. */
46 static int frames_invalid_emitted;
47 static int breakpoints_invalid_emitted;
49 /* True if the target can async, and a synchronous execution command
50 is not in progress. If true, input is accepted, so don't suppress
51 annotations. */
53 static int
54 async_background_execution_p (void)
56 return (target_can_async_p () && !sync_execution);
59 static void
60 print_value_flags (struct type *t)
62 if (can_dereference (t))
63 printf_filtered (("*"));
64 else
65 printf_filtered (("-"));
68 static void
69 annotate_breakpoints_invalid (void)
71 if (annotation_level == 2
72 && (!breakpoints_invalid_emitted
73 || async_background_execution_p ()))
75 /* If the inferior owns the terminal (e.g., we're resuming),
76 make sure to leave with the inferior still owning it. */
77 int was_inferior = target_terminal_is_inferior ();
79 target_terminal_ours_for_output ();
81 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
83 if (was_inferior)
84 target_terminal_inferior ();
86 breakpoints_invalid_emitted = 1;
90 void
91 annotate_breakpoint (int num)
93 if (annotation_level > 1)
94 printf_filtered (("\n\032\032breakpoint %d\n"), num);
97 void
98 annotate_catchpoint (int num)
100 if (annotation_level > 1)
101 printf_filtered (("\n\032\032catchpoint %d\n"), num);
104 void
105 annotate_watchpoint (int num)
107 if (annotation_level > 1)
108 printf_filtered (("\n\032\032watchpoint %d\n"), num);
111 void
112 annotate_starting (void)
114 if (annotation_level > 1)
115 printf_filtered (("\n\032\032starting\n"));
118 void
119 annotate_stopped (void)
121 if (annotation_level > 1)
122 printf_filtered (("\n\032\032stopped\n"));
125 void
126 annotate_exited (int exitstatus)
128 if (annotation_level > 1)
129 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
132 void
133 annotate_signalled (void)
135 if (deprecated_annotate_signalled_hook)
136 deprecated_annotate_signalled_hook ();
138 if (annotation_level > 1)
139 printf_filtered (("\n\032\032signalled\n"));
142 void
143 annotate_signal_name (void)
145 if (annotation_level == 2)
146 printf_filtered (("\n\032\032signal-name\n"));
149 void
150 annotate_signal_name_end (void)
152 if (annotation_level == 2)
153 printf_filtered (("\n\032\032signal-name-end\n"));
156 void
157 annotate_signal_string (void)
159 if (annotation_level == 2)
160 printf_filtered (("\n\032\032signal-string\n"));
163 void
164 annotate_signal_string_end (void)
166 if (annotation_level == 2)
167 printf_filtered (("\n\032\032signal-string-end\n"));
170 void
171 annotate_signal (void)
173 if (deprecated_annotate_signal_hook)
174 deprecated_annotate_signal_hook ();
176 if (annotation_level > 1)
177 printf_filtered (("\n\032\032signal\n"));
180 void
181 annotate_breakpoints_headers (void)
183 if (annotation_level == 2)
184 printf_filtered (("\n\032\032breakpoints-headers\n"));
187 void
188 annotate_field (int num)
190 if (annotation_level == 2)
191 printf_filtered (("\n\032\032field %d\n"), num);
194 void
195 annotate_breakpoints_table (void)
197 if (annotation_level == 2)
198 printf_filtered (("\n\032\032breakpoints-table\n"));
201 void
202 annotate_record (void)
204 if (annotation_level == 2)
205 printf_filtered (("\n\032\032record\n"));
208 void
209 annotate_breakpoints_table_end (void)
211 if (annotation_level == 2)
212 printf_filtered (("\n\032\032breakpoints-table-end\n"));
215 void
216 annotate_frames_invalid (void)
218 if (annotation_level == 2
219 && (!frames_invalid_emitted
220 || async_background_execution_p ()))
222 /* If the inferior owns the terminal (e.g., we're resuming),
223 make sure to leave with the inferior still owning it. */
224 int was_inferior = target_terminal_is_inferior ();
226 target_terminal_ours_for_output ();
228 printf_unfiltered (("\n\032\032frames-invalid\n"));
230 if (was_inferior)
231 target_terminal_inferior ();
233 frames_invalid_emitted = 1;
237 void
238 annotate_new_thread (void)
240 if (annotation_level > 1)
242 printf_unfiltered (("\n\032\032new-thread\n"));
246 void
247 annotate_thread_changed (void)
249 if (annotation_level > 1)
251 printf_unfiltered (("\n\032\032thread-changed\n"));
255 void
256 annotate_field_begin (struct type *type)
258 if (annotation_level == 2)
260 printf_filtered (("\n\032\032field-begin "));
261 print_value_flags (type);
262 printf_filtered (("\n"));
266 void
267 annotate_field_name_end (void)
269 if (annotation_level == 2)
270 printf_filtered (("\n\032\032field-name-end\n"));
273 void
274 annotate_field_value (void)
276 if (annotation_level == 2)
277 printf_filtered (("\n\032\032field-value\n"));
280 void
281 annotate_field_end (void)
283 if (annotation_level == 2)
284 printf_filtered (("\n\032\032field-end\n"));
287 void
288 annotate_quit (void)
290 if (annotation_level > 1)
291 printf_filtered (("\n\032\032quit\n"));
294 void
295 annotate_error (void)
297 if (annotation_level > 1)
298 printf_filtered (("\n\032\032error\n"));
301 void
302 annotate_error_begin (void)
304 if (annotation_level > 1)
305 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
308 void
309 annotate_value_history_begin (int histindex, struct type *type)
311 if (annotation_level == 2)
313 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
314 print_value_flags (type);
315 printf_filtered (("\n"));
319 void
320 annotate_value_begin (struct type *type)
322 if (annotation_level == 2)
324 printf_filtered (("\n\032\032value-begin "));
325 print_value_flags (type);
326 printf_filtered (("\n"));
330 void
331 annotate_value_history_value (void)
333 if (annotation_level == 2)
334 printf_filtered (("\n\032\032value-history-value\n"));
337 void
338 annotate_value_history_end (void)
340 if (annotation_level == 2)
341 printf_filtered (("\n\032\032value-history-end\n"));
344 void
345 annotate_value_end (void)
347 if (annotation_level == 2)
348 printf_filtered (("\n\032\032value-end\n"));
351 void
352 annotate_display_begin (void)
354 if (annotation_level == 2)
355 printf_filtered (("\n\032\032display-begin\n"));
358 void
359 annotate_display_number_end (void)
361 if (annotation_level == 2)
362 printf_filtered (("\n\032\032display-number-end\n"));
365 void
366 annotate_display_format (void)
368 if (annotation_level == 2)
369 printf_filtered (("\n\032\032display-format\n"));
372 void
373 annotate_display_expression (void)
375 if (annotation_level == 2)
376 printf_filtered (("\n\032\032display-expression\n"));
379 void
380 annotate_display_expression_end (void)
382 if (annotation_level == 2)
383 printf_filtered (("\n\032\032display-expression-end\n"));
386 void
387 annotate_display_value (void)
389 if (annotation_level == 2)
390 printf_filtered (("\n\032\032display-value\n"));
393 void
394 annotate_display_end (void)
396 if (annotation_level == 2)
397 printf_filtered (("\n\032\032display-end\n"));
400 void
401 annotate_arg_begin (void)
403 if (annotation_level == 2)
404 printf_filtered (("\n\032\032arg-begin\n"));
407 void
408 annotate_arg_name_end (void)
410 if (annotation_level == 2)
411 printf_filtered (("\n\032\032arg-name-end\n"));
414 void
415 annotate_arg_value (struct type *type)
417 if (annotation_level == 2)
419 printf_filtered (("\n\032\032arg-value "));
420 print_value_flags (type);
421 printf_filtered (("\n"));
425 void
426 annotate_arg_end (void)
428 if (annotation_level == 2)
429 printf_filtered (("\n\032\032arg-end\n"));
432 void
433 annotate_source (char *filename, int line, int character, int mid,
434 struct gdbarch *gdbarch, CORE_ADDR pc)
436 if (annotation_level > 1)
437 printf_filtered (("\n\032\032source "));
438 else
439 printf_filtered (("\032\032"));
441 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
442 mid ? "middle" : "beg", paddress (gdbarch, pc));
445 void
446 annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
448 if (annotation_level > 1)
449 printf_filtered (("\n\032\032frame-begin %d %s\n"),
450 level, paddress (gdbarch, pc));
453 void
454 annotate_function_call (void)
456 if (annotation_level == 2)
457 printf_filtered (("\n\032\032function-call\n"));
460 void
461 annotate_signal_handler_caller (void)
463 if (annotation_level == 2)
464 printf_filtered (("\n\032\032signal-handler-caller\n"));
467 void
468 annotate_frame_address (void)
470 if (annotation_level == 2)
471 printf_filtered (("\n\032\032frame-address\n"));
474 void
475 annotate_frame_address_end (void)
477 if (annotation_level == 2)
478 printf_filtered (("\n\032\032frame-address-end\n"));
481 void
482 annotate_frame_function_name (void)
484 if (annotation_level == 2)
485 printf_filtered (("\n\032\032frame-function-name\n"));
488 void
489 annotate_frame_args (void)
491 if (annotation_level == 2)
492 printf_filtered (("\n\032\032frame-args\n"));
495 void
496 annotate_frame_source_begin (void)
498 if (annotation_level == 2)
499 printf_filtered (("\n\032\032frame-source-begin\n"));
502 void
503 annotate_frame_source_file (void)
505 if (annotation_level == 2)
506 printf_filtered (("\n\032\032frame-source-file\n"));
509 void
510 annotate_frame_source_file_end (void)
512 if (annotation_level == 2)
513 printf_filtered (("\n\032\032frame-source-file-end\n"));
516 void
517 annotate_frame_source_line (void)
519 if (annotation_level == 2)
520 printf_filtered (("\n\032\032frame-source-line\n"));
523 void
524 annotate_frame_source_end (void)
526 if (annotation_level == 2)
527 printf_filtered (("\n\032\032frame-source-end\n"));
530 void
531 annotate_frame_where (void)
533 if (annotation_level == 2)
534 printf_filtered (("\n\032\032frame-where\n"));
537 void
538 annotate_frame_end (void)
540 if (annotation_level == 2)
541 printf_filtered (("\n\032\032frame-end\n"));
544 void
545 annotate_array_section_begin (int idx, struct type *elttype)
547 if (annotation_level == 2)
549 printf_filtered (("\n\032\032array-section-begin %d "), idx);
550 print_value_flags (elttype);
551 printf_filtered (("\n"));
555 void
556 annotate_elt_rep (unsigned int repcount)
558 if (annotation_level == 2)
559 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
562 void
563 annotate_elt_rep_end (void)
565 if (annotation_level == 2)
566 printf_filtered (("\n\032\032elt-rep-end\n"));
569 void
570 annotate_elt (void)
572 if (annotation_level == 2)
573 printf_filtered (("\n\032\032elt\n"));
576 void
577 annotate_array_section_end (void)
579 if (annotation_level == 2)
580 printf_filtered (("\n\032\032array-section-end\n"));
583 /* Called when GDB is about to display the prompt. Used to reset
584 annotation suppression whenever we're ready to accept new
585 frontend/user commands. */
587 void
588 annotate_display_prompt (void)
590 frames_invalid_emitted = 0;
591 breakpoints_invalid_emitted = 0;
594 static void
595 breakpoint_changed (struct breakpoint *b)
597 if (b->number <= 0)
598 return;
600 annotate_breakpoints_invalid ();
603 void
604 _initialize_annotate (void)
606 observer_attach_breakpoint_created (breakpoint_changed);
607 observer_attach_breakpoint_deleted (breakpoint_changed);
608 observer_attach_breakpoint_modified (breakpoint_changed);