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/>. */
24 #include "breakpoint.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
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
54 async_background_execution_p (void)
56 return (target_can_async_p () && !sync_execution
);
60 print_value_flags (struct type
*t
)
62 if (can_dereference (t
))
63 printf_filtered (("*"));
65 printf_filtered (("-"));
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"));
84 target_terminal_inferior ();
86 breakpoints_invalid_emitted
= 1;
91 annotate_breakpoint (int num
)
93 if (annotation_level
> 1)
94 printf_filtered (("\n\032\032breakpoint %d\n"), num
);
98 annotate_catchpoint (int num
)
100 if (annotation_level
> 1)
101 printf_filtered (("\n\032\032catchpoint %d\n"), num
);
105 annotate_watchpoint (int num
)
107 if (annotation_level
> 1)
108 printf_filtered (("\n\032\032watchpoint %d\n"), num
);
112 annotate_starting (void)
114 if (annotation_level
> 1)
115 printf_filtered (("\n\032\032starting\n"));
119 annotate_stopped (void)
121 if (annotation_level
> 1)
122 printf_filtered (("\n\032\032stopped\n"));
126 annotate_exited (int exitstatus
)
128 if (annotation_level
> 1)
129 printf_filtered (("\n\032\032exited %d\n"), exitstatus
);
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"));
143 annotate_signal_name (void)
145 if (annotation_level
== 2)
146 printf_filtered (("\n\032\032signal-name\n"));
150 annotate_signal_name_end (void)
152 if (annotation_level
== 2)
153 printf_filtered (("\n\032\032signal-name-end\n"));
157 annotate_signal_string (void)
159 if (annotation_level
== 2)
160 printf_filtered (("\n\032\032signal-string\n"));
164 annotate_signal_string_end (void)
166 if (annotation_level
== 2)
167 printf_filtered (("\n\032\032signal-string-end\n"));
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"));
181 annotate_breakpoints_headers (void)
183 if (annotation_level
== 2)
184 printf_filtered (("\n\032\032breakpoints-headers\n"));
188 annotate_field (int num
)
190 if (annotation_level
== 2)
191 printf_filtered (("\n\032\032field %d\n"), num
);
195 annotate_breakpoints_table (void)
197 if (annotation_level
== 2)
198 printf_filtered (("\n\032\032breakpoints-table\n"));
202 annotate_record (void)
204 if (annotation_level
== 2)
205 printf_filtered (("\n\032\032record\n"));
209 annotate_breakpoints_table_end (void)
211 if (annotation_level
== 2)
212 printf_filtered (("\n\032\032breakpoints-table-end\n"));
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"));
231 target_terminal_inferior ();
233 frames_invalid_emitted
= 1;
238 annotate_new_thread (void)
240 if (annotation_level
> 1)
242 printf_unfiltered (("\n\032\032new-thread\n"));
247 annotate_thread_changed (void)
249 if (annotation_level
> 1)
251 printf_unfiltered (("\n\032\032thread-changed\n"));
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"));
267 annotate_field_name_end (void)
269 if (annotation_level
== 2)
270 printf_filtered (("\n\032\032field-name-end\n"));
274 annotate_field_value (void)
276 if (annotation_level
== 2)
277 printf_filtered (("\n\032\032field-value\n"));
281 annotate_field_end (void)
283 if (annotation_level
== 2)
284 printf_filtered (("\n\032\032field-end\n"));
290 if (annotation_level
> 1)
291 printf_filtered (("\n\032\032quit\n"));
295 annotate_error (void)
297 if (annotation_level
> 1)
298 printf_filtered (("\n\032\032error\n"));
302 annotate_error_begin (void)
304 if (annotation_level
> 1)
305 fprintf_filtered (gdb_stderr
, "\n\032\032error-begin\n");
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"));
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"));
331 annotate_value_history_value (void)
333 if (annotation_level
== 2)
334 printf_filtered (("\n\032\032value-history-value\n"));
338 annotate_value_history_end (void)
340 if (annotation_level
== 2)
341 printf_filtered (("\n\032\032value-history-end\n"));
345 annotate_value_end (void)
347 if (annotation_level
== 2)
348 printf_filtered (("\n\032\032value-end\n"));
352 annotate_display_begin (void)
354 if (annotation_level
== 2)
355 printf_filtered (("\n\032\032display-begin\n"));
359 annotate_display_number_end (void)
361 if (annotation_level
== 2)
362 printf_filtered (("\n\032\032display-number-end\n"));
366 annotate_display_format (void)
368 if (annotation_level
== 2)
369 printf_filtered (("\n\032\032display-format\n"));
373 annotate_display_expression (void)
375 if (annotation_level
== 2)
376 printf_filtered (("\n\032\032display-expression\n"));
380 annotate_display_expression_end (void)
382 if (annotation_level
== 2)
383 printf_filtered (("\n\032\032display-expression-end\n"));
387 annotate_display_value (void)
389 if (annotation_level
== 2)
390 printf_filtered (("\n\032\032display-value\n"));
394 annotate_display_end (void)
396 if (annotation_level
== 2)
397 printf_filtered (("\n\032\032display-end\n"));
401 annotate_arg_begin (void)
403 if (annotation_level
== 2)
404 printf_filtered (("\n\032\032arg-begin\n"));
408 annotate_arg_name_end (void)
410 if (annotation_level
== 2)
411 printf_filtered (("\n\032\032arg-name-end\n"));
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"));
426 annotate_arg_end (void)
428 if (annotation_level
== 2)
429 printf_filtered (("\n\032\032arg-end\n"));
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 "));
439 printf_filtered (("\032\032"));
441 printf_filtered (("%s:%d:%d:%s:%s\n"), filename
, line
, character
,
442 mid
? "middle" : "beg", paddress (gdbarch
, pc
));
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
));
454 annotate_function_call (void)
456 if (annotation_level
== 2)
457 printf_filtered (("\n\032\032function-call\n"));
461 annotate_signal_handler_caller (void)
463 if (annotation_level
== 2)
464 printf_filtered (("\n\032\032signal-handler-caller\n"));
468 annotate_frame_address (void)
470 if (annotation_level
== 2)
471 printf_filtered (("\n\032\032frame-address\n"));
475 annotate_frame_address_end (void)
477 if (annotation_level
== 2)
478 printf_filtered (("\n\032\032frame-address-end\n"));
482 annotate_frame_function_name (void)
484 if (annotation_level
== 2)
485 printf_filtered (("\n\032\032frame-function-name\n"));
489 annotate_frame_args (void)
491 if (annotation_level
== 2)
492 printf_filtered (("\n\032\032frame-args\n"));
496 annotate_frame_source_begin (void)
498 if (annotation_level
== 2)
499 printf_filtered (("\n\032\032frame-source-begin\n"));
503 annotate_frame_source_file (void)
505 if (annotation_level
== 2)
506 printf_filtered (("\n\032\032frame-source-file\n"));
510 annotate_frame_source_file_end (void)
512 if (annotation_level
== 2)
513 printf_filtered (("\n\032\032frame-source-file-end\n"));
517 annotate_frame_source_line (void)
519 if (annotation_level
== 2)
520 printf_filtered (("\n\032\032frame-source-line\n"));
524 annotate_frame_source_end (void)
526 if (annotation_level
== 2)
527 printf_filtered (("\n\032\032frame-source-end\n"));
531 annotate_frame_where (void)
533 if (annotation_level
== 2)
534 printf_filtered (("\n\032\032frame-where\n"));
538 annotate_frame_end (void)
540 if (annotation_level
== 2)
541 printf_filtered (("\n\032\032frame-end\n"));
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"));
556 annotate_elt_rep (unsigned int repcount
)
558 if (annotation_level
== 2)
559 printf_filtered (("\n\032\032elt-rep %u\n"), repcount
);
563 annotate_elt_rep_end (void)
565 if (annotation_level
== 2)
566 printf_filtered (("\n\032\032elt-rep-end\n"));
572 if (annotation_level
== 2)
573 printf_filtered (("\n\032\032elt\n"));
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. */
588 annotate_display_prompt (void)
590 frames_invalid_emitted
= 0;
591 breakpoints_invalid_emitted
= 0;
595 breakpoint_changed (struct breakpoint
*b
)
600 annotate_breakpoints_invalid ();
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
);