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/>. */
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 target_terminal_ours ();
76 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
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 || async_background_execution_p ()))
213 target_terminal_ours ();
214 printf_unfiltered (("\n\032\032frames-invalid\n"));
215 frames_invalid_emitted
= 1;
220 annotate_new_thread (void)
222 if (annotation_level
> 1)
224 printf_unfiltered (("\n\032\032new-thread\n"));
229 annotate_thread_changed (void)
231 if (annotation_level
> 1)
233 printf_unfiltered (("\n\032\032thread-changed\n"));
238 annotate_field_begin (struct type
*type
)
240 if (annotation_level
== 2)
242 printf_filtered (("\n\032\032field-begin "));
243 print_value_flags (type
);
244 printf_filtered (("\n"));
249 annotate_field_name_end (void)
251 if (annotation_level
== 2)
252 printf_filtered (("\n\032\032field-name-end\n"));
256 annotate_field_value (void)
258 if (annotation_level
== 2)
259 printf_filtered (("\n\032\032field-value\n"));
263 annotate_field_end (void)
265 if (annotation_level
== 2)
266 printf_filtered (("\n\032\032field-end\n"));
272 if (annotation_level
> 1)
273 printf_filtered (("\n\032\032quit\n"));
277 annotate_error (void)
279 if (annotation_level
> 1)
280 printf_filtered (("\n\032\032error\n"));
284 annotate_error_begin (void)
286 if (annotation_level
> 1)
287 fprintf_filtered (gdb_stderr
, "\n\032\032error-begin\n");
291 annotate_value_history_begin (int histindex
, struct type
*type
)
293 if (annotation_level
== 2)
295 printf_filtered (("\n\032\032value-history-begin %d "), histindex
);
296 print_value_flags (type
);
297 printf_filtered (("\n"));
302 annotate_value_begin (struct type
*type
)
304 if (annotation_level
== 2)
306 printf_filtered (("\n\032\032value-begin "));
307 print_value_flags (type
);
308 printf_filtered (("\n"));
313 annotate_value_history_value (void)
315 if (annotation_level
== 2)
316 printf_filtered (("\n\032\032value-history-value\n"));
320 annotate_value_history_end (void)
322 if (annotation_level
== 2)
323 printf_filtered (("\n\032\032value-history-end\n"));
327 annotate_value_end (void)
329 if (annotation_level
== 2)
330 printf_filtered (("\n\032\032value-end\n"));
334 annotate_display_begin (void)
336 if (annotation_level
== 2)
337 printf_filtered (("\n\032\032display-begin\n"));
341 annotate_display_number_end (void)
343 if (annotation_level
== 2)
344 printf_filtered (("\n\032\032display-number-end\n"));
348 annotate_display_format (void)
350 if (annotation_level
== 2)
351 printf_filtered (("\n\032\032display-format\n"));
355 annotate_display_expression (void)
357 if (annotation_level
== 2)
358 printf_filtered (("\n\032\032display-expression\n"));
362 annotate_display_expression_end (void)
364 if (annotation_level
== 2)
365 printf_filtered (("\n\032\032display-expression-end\n"));
369 annotate_display_value (void)
371 if (annotation_level
== 2)
372 printf_filtered (("\n\032\032display-value\n"));
376 annotate_display_end (void)
378 if (annotation_level
== 2)
379 printf_filtered (("\n\032\032display-end\n"));
383 annotate_arg_begin (void)
385 if (annotation_level
== 2)
386 printf_filtered (("\n\032\032arg-begin\n"));
390 annotate_arg_name_end (void)
392 if (annotation_level
== 2)
393 printf_filtered (("\n\032\032arg-name-end\n"));
397 annotate_arg_value (struct type
*type
)
399 if (annotation_level
== 2)
401 printf_filtered (("\n\032\032arg-value "));
402 print_value_flags (type
);
403 printf_filtered (("\n"));
408 annotate_arg_end (void)
410 if (annotation_level
== 2)
411 printf_filtered (("\n\032\032arg-end\n"));
415 annotate_source (char *filename
, int line
, int character
, int mid
,
416 struct gdbarch
*gdbarch
, CORE_ADDR pc
)
418 if (annotation_level
> 1)
419 printf_filtered (("\n\032\032source "));
421 printf_filtered (("\032\032"));
423 printf_filtered (("%s:%d:%d:%s:%s\n"), filename
, line
, character
,
424 mid
? "middle" : "beg", paddress (gdbarch
, pc
));
428 annotate_frame_begin (int level
, struct gdbarch
*gdbarch
, CORE_ADDR pc
)
430 if (annotation_level
> 1)
431 printf_filtered (("\n\032\032frame-begin %d %s\n"),
432 level
, paddress (gdbarch
, pc
));
436 annotate_function_call (void)
438 if (annotation_level
== 2)
439 printf_filtered (("\n\032\032function-call\n"));
443 annotate_signal_handler_caller (void)
445 if (annotation_level
== 2)
446 printf_filtered (("\n\032\032signal-handler-caller\n"));
450 annotate_frame_address (void)
452 if (annotation_level
== 2)
453 printf_filtered (("\n\032\032frame-address\n"));
457 annotate_frame_address_end (void)
459 if (annotation_level
== 2)
460 printf_filtered (("\n\032\032frame-address-end\n"));
464 annotate_frame_function_name (void)
466 if (annotation_level
== 2)
467 printf_filtered (("\n\032\032frame-function-name\n"));
471 annotate_frame_args (void)
473 if (annotation_level
== 2)
474 printf_filtered (("\n\032\032frame-args\n"));
478 annotate_frame_source_begin (void)
480 if (annotation_level
== 2)
481 printf_filtered (("\n\032\032frame-source-begin\n"));
485 annotate_frame_source_file (void)
487 if (annotation_level
== 2)
488 printf_filtered (("\n\032\032frame-source-file\n"));
492 annotate_frame_source_file_end (void)
494 if (annotation_level
== 2)
495 printf_filtered (("\n\032\032frame-source-file-end\n"));
499 annotate_frame_source_line (void)
501 if (annotation_level
== 2)
502 printf_filtered (("\n\032\032frame-source-line\n"));
506 annotate_frame_source_end (void)
508 if (annotation_level
== 2)
509 printf_filtered (("\n\032\032frame-source-end\n"));
513 annotate_frame_where (void)
515 if (annotation_level
== 2)
516 printf_filtered (("\n\032\032frame-where\n"));
520 annotate_frame_end (void)
522 if (annotation_level
== 2)
523 printf_filtered (("\n\032\032frame-end\n"));
527 annotate_array_section_begin (int idx
, struct type
*elttype
)
529 if (annotation_level
== 2)
531 printf_filtered (("\n\032\032array-section-begin %d "), idx
);
532 print_value_flags (elttype
);
533 printf_filtered (("\n"));
538 annotate_elt_rep (unsigned int repcount
)
540 if (annotation_level
== 2)
541 printf_filtered (("\n\032\032elt-rep %u\n"), repcount
);
545 annotate_elt_rep_end (void)
547 if (annotation_level
== 2)
548 printf_filtered (("\n\032\032elt-rep-end\n"));
554 if (annotation_level
== 2)
555 printf_filtered (("\n\032\032elt\n"));
559 annotate_array_section_end (void)
561 if (annotation_level
== 2)
562 printf_filtered (("\n\032\032array-section-end\n"));
565 /* Called when GDB is about to display the prompt. Used to reset
566 annotation suppression whenever we're ready to accept new
567 frontend/user commands. */
570 annotate_display_prompt (void)
572 frames_invalid_emitted
= 0;
573 breakpoints_invalid_emitted
= 0;
577 breakpoint_changed (struct breakpoint
*b
)
582 annotate_breakpoints_invalid ();
586 _initialize_annotate (void)
588 observer_attach_breakpoint_created (breakpoint_changed
);
589 observer_attach_breakpoint_deleted (breakpoint_changed
);
590 observer_attach_breakpoint_modified (breakpoint_changed
);