Fix dw2-ifort-parameter.exp on PPC64
[binutils-gdb.git] / gdb / annotate.c
blob135573316c2a624c6cd23b5782847b82233a7523
1 /* Annotation routines for GDB.
2 Copyright (C) 1986-2014 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"
29 /* Prototypes for local functions. */
31 extern void _initialize_annotate (void);
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
44 displayed. */
45 static int frames_invalid_emitted;
46 static int breakpoints_invalid_emitted;
48 /* True if the target can async, and a synchronous execution command
49 is not in progress. If true, input is accepted, so don't suppress
50 annotations. */
52 static int
53 async_background_execution_p (void)
55 return (target_can_async_p () && !sync_execution);
58 static void
59 print_value_flags (struct type *t)
61 if (can_dereference (t))
62 printf_filtered (("*"));
63 else
64 printf_filtered (("-"));
67 static void
68 annotate_breakpoints_invalid (void)
70 if (annotation_level == 2
71 && (!breakpoints_invalid_emitted
72 || async_background_execution_p ()))
74 target_terminal_ours ();
75 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
76 breakpoints_invalid_emitted = 1;
80 void
81 annotate_breakpoint (int num)
83 if (annotation_level > 1)
84 printf_filtered (("\n\032\032breakpoint %d\n"), num);
87 void
88 annotate_catchpoint (int num)
90 if (annotation_level > 1)
91 printf_filtered (("\n\032\032catchpoint %d\n"), num);
94 void
95 annotate_watchpoint (int num)
97 if (annotation_level > 1)
98 printf_filtered (("\n\032\032watchpoint %d\n"), num);
101 void
102 annotate_starting (void)
104 if (annotation_level > 1)
105 printf_filtered (("\n\032\032starting\n"));
108 void
109 annotate_stopped (void)
111 if (annotation_level > 1)
112 printf_filtered (("\n\032\032stopped\n"));
115 void
116 annotate_exited (int exitstatus)
118 if (annotation_level > 1)
119 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
122 void
123 annotate_signalled (void)
125 if (deprecated_annotate_signalled_hook)
126 deprecated_annotate_signalled_hook ();
128 if (annotation_level > 1)
129 printf_filtered (("\n\032\032signalled\n"));
132 void
133 annotate_signal_name (void)
135 if (annotation_level == 2)
136 printf_filtered (("\n\032\032signal-name\n"));
139 void
140 annotate_signal_name_end (void)
142 if (annotation_level == 2)
143 printf_filtered (("\n\032\032signal-name-end\n"));
146 void
147 annotate_signal_string (void)
149 if (annotation_level == 2)
150 printf_filtered (("\n\032\032signal-string\n"));
153 void
154 annotate_signal_string_end (void)
156 if (annotation_level == 2)
157 printf_filtered (("\n\032\032signal-string-end\n"));
160 void
161 annotate_signal (void)
163 if (deprecated_annotate_signal_hook)
164 deprecated_annotate_signal_hook ();
166 if (annotation_level > 1)
167 printf_filtered (("\n\032\032signal\n"));
170 void
171 annotate_breakpoints_headers (void)
173 if (annotation_level == 2)
174 printf_filtered (("\n\032\032breakpoints-headers\n"));
177 void
178 annotate_field (int num)
180 if (annotation_level == 2)
181 printf_filtered (("\n\032\032field %d\n"), num);
184 void
185 annotate_breakpoints_table (void)
187 if (annotation_level == 2)
188 printf_filtered (("\n\032\032breakpoints-table\n"));
191 void
192 annotate_record (void)
194 if (annotation_level == 2)
195 printf_filtered (("\n\032\032record\n"));
198 void
199 annotate_breakpoints_table_end (void)
201 if (annotation_level == 2)
202 printf_filtered (("\n\032\032breakpoints-table-end\n"));
205 void
206 annotate_frames_invalid (void)
208 if (annotation_level == 2
209 && (!frames_invalid_emitted
210 || async_background_execution_p ()))
212 target_terminal_ours ();
213 printf_unfiltered (("\n\032\032frames-invalid\n"));
214 frames_invalid_emitted = 1;
218 void
219 annotate_new_thread (void)
221 if (annotation_level > 1)
223 printf_unfiltered (("\n\032\032new-thread\n"));
227 void
228 annotate_thread_changed (void)
230 if (annotation_level > 1)
232 printf_unfiltered (("\n\032\032thread-changed\n"));
236 void
237 annotate_field_begin (struct type *type)
239 if (annotation_level == 2)
241 printf_filtered (("\n\032\032field-begin "));
242 print_value_flags (type);
243 printf_filtered (("\n"));
247 void
248 annotate_field_name_end (void)
250 if (annotation_level == 2)
251 printf_filtered (("\n\032\032field-name-end\n"));
254 void
255 annotate_field_value (void)
257 if (annotation_level == 2)
258 printf_filtered (("\n\032\032field-value\n"));
261 void
262 annotate_field_end (void)
264 if (annotation_level == 2)
265 printf_filtered (("\n\032\032field-end\n"));
268 void
269 annotate_quit (void)
271 if (annotation_level > 1)
272 printf_filtered (("\n\032\032quit\n"));
275 void
276 annotate_error (void)
278 if (annotation_level > 1)
279 printf_filtered (("\n\032\032error\n"));
282 void
283 annotate_error_begin (void)
285 if (annotation_level > 1)
286 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
289 void
290 annotate_value_history_begin (int histindex, struct type *type)
292 if (annotation_level == 2)
294 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
295 print_value_flags (type);
296 printf_filtered (("\n"));
300 void
301 annotate_value_begin (struct type *type)
303 if (annotation_level == 2)
305 printf_filtered (("\n\032\032value-begin "));
306 print_value_flags (type);
307 printf_filtered (("\n"));
311 void
312 annotate_value_history_value (void)
314 if (annotation_level == 2)
315 printf_filtered (("\n\032\032value-history-value\n"));
318 void
319 annotate_value_history_end (void)
321 if (annotation_level == 2)
322 printf_filtered (("\n\032\032value-history-end\n"));
325 void
326 annotate_value_end (void)
328 if (annotation_level == 2)
329 printf_filtered (("\n\032\032value-end\n"));
332 void
333 annotate_display_begin (void)
335 if (annotation_level == 2)
336 printf_filtered (("\n\032\032display-begin\n"));
339 void
340 annotate_display_number_end (void)
342 if (annotation_level == 2)
343 printf_filtered (("\n\032\032display-number-end\n"));
346 void
347 annotate_display_format (void)
349 if (annotation_level == 2)
350 printf_filtered (("\n\032\032display-format\n"));
353 void
354 annotate_display_expression (void)
356 if (annotation_level == 2)
357 printf_filtered (("\n\032\032display-expression\n"));
360 void
361 annotate_display_expression_end (void)
363 if (annotation_level == 2)
364 printf_filtered (("\n\032\032display-expression-end\n"));
367 void
368 annotate_display_value (void)
370 if (annotation_level == 2)
371 printf_filtered (("\n\032\032display-value\n"));
374 void
375 annotate_display_end (void)
377 if (annotation_level == 2)
378 printf_filtered (("\n\032\032display-end\n"));
381 void
382 annotate_arg_begin (void)
384 if (annotation_level == 2)
385 printf_filtered (("\n\032\032arg-begin\n"));
388 void
389 annotate_arg_name_end (void)
391 if (annotation_level == 2)
392 printf_filtered (("\n\032\032arg-name-end\n"));
395 void
396 annotate_arg_value (struct type *type)
398 if (annotation_level == 2)
400 printf_filtered (("\n\032\032arg-value "));
401 print_value_flags (type);
402 printf_filtered (("\n"));
406 void
407 annotate_arg_end (void)
409 if (annotation_level == 2)
410 printf_filtered (("\n\032\032arg-end\n"));
413 void
414 annotate_source (char *filename, int line, int character, int mid,
415 struct gdbarch *gdbarch, CORE_ADDR pc)
417 if (annotation_level > 1)
418 printf_filtered (("\n\032\032source "));
419 else
420 printf_filtered (("\032\032"));
422 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
423 mid ? "middle" : "beg", paddress (gdbarch, pc));
426 void
427 annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
429 if (annotation_level > 1)
430 printf_filtered (("\n\032\032frame-begin %d %s\n"),
431 level, paddress (gdbarch, pc));
434 void
435 annotate_function_call (void)
437 if (annotation_level == 2)
438 printf_filtered (("\n\032\032function-call\n"));
441 void
442 annotate_signal_handler_caller (void)
444 if (annotation_level == 2)
445 printf_filtered (("\n\032\032signal-handler-caller\n"));
448 void
449 annotate_frame_address (void)
451 if (annotation_level == 2)
452 printf_filtered (("\n\032\032frame-address\n"));
455 void
456 annotate_frame_address_end (void)
458 if (annotation_level == 2)
459 printf_filtered (("\n\032\032frame-address-end\n"));
462 void
463 annotate_frame_function_name (void)
465 if (annotation_level == 2)
466 printf_filtered (("\n\032\032frame-function-name\n"));
469 void
470 annotate_frame_args (void)
472 if (annotation_level == 2)
473 printf_filtered (("\n\032\032frame-args\n"));
476 void
477 annotate_frame_source_begin (void)
479 if (annotation_level == 2)
480 printf_filtered (("\n\032\032frame-source-begin\n"));
483 void
484 annotate_frame_source_file (void)
486 if (annotation_level == 2)
487 printf_filtered (("\n\032\032frame-source-file\n"));
490 void
491 annotate_frame_source_file_end (void)
493 if (annotation_level == 2)
494 printf_filtered (("\n\032\032frame-source-file-end\n"));
497 void
498 annotate_frame_source_line (void)
500 if (annotation_level == 2)
501 printf_filtered (("\n\032\032frame-source-line\n"));
504 void
505 annotate_frame_source_end (void)
507 if (annotation_level == 2)
508 printf_filtered (("\n\032\032frame-source-end\n"));
511 void
512 annotate_frame_where (void)
514 if (annotation_level == 2)
515 printf_filtered (("\n\032\032frame-where\n"));
518 void
519 annotate_frame_end (void)
521 if (annotation_level == 2)
522 printf_filtered (("\n\032\032frame-end\n"));
525 void
526 annotate_array_section_begin (int idx, struct type *elttype)
528 if (annotation_level == 2)
530 printf_filtered (("\n\032\032array-section-begin %d "), idx);
531 print_value_flags (elttype);
532 printf_filtered (("\n"));
536 void
537 annotate_elt_rep (unsigned int repcount)
539 if (annotation_level == 2)
540 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
543 void
544 annotate_elt_rep_end (void)
546 if (annotation_level == 2)
547 printf_filtered (("\n\032\032elt-rep-end\n"));
550 void
551 annotate_elt (void)
553 if (annotation_level == 2)
554 printf_filtered (("\n\032\032elt\n"));
557 void
558 annotate_array_section_end (void)
560 if (annotation_level == 2)
561 printf_filtered (("\n\032\032array-section-end\n"));
564 /* Called when GDB is about to display the prompt. Used to reset
565 annotation suppression whenever we're ready to accept new
566 frontend/user commands. */
568 void
569 annotate_display_prompt (void)
571 frames_invalid_emitted = 0;
572 breakpoints_invalid_emitted = 0;
575 static void
576 breakpoint_changed (struct breakpoint *b)
578 if (b->number <= 0)
579 return;
581 annotate_breakpoints_invalid ();
584 void
585 _initialize_annotate (void)
587 observer_attach_breakpoint_created (breakpoint_changed);
588 observer_attach_breakpoint_deleted (breakpoint_changed);
589 observer_attach_breakpoint_modified (breakpoint_changed);