1 /* Annotation routines for GDB.
2 Copyright (C) 1986-2013 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"
28 /* Prototypes for local functions. */
30 extern void _initialize_annotate (void);
32 static void print_value_flags (struct type
*);
34 static void breakpoint_changed (struct breakpoint
*b
);
37 void (*deprecated_annotate_signalled_hook
) (void);
38 void (*deprecated_annotate_signal_hook
) (void);
40 static int ignore_count_changed
= 0;
43 print_value_flags (struct type
*t
)
45 if (can_dereference (t
))
46 printf_filtered (("*"));
48 printf_filtered (("-"));
52 annotate_breakpoints_changed (void)
54 if (annotation_level
== 2)
56 target_terminal_ours ();
57 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
58 if (ignore_count_changed
)
59 ignore_count_changed
= 0; /* Avoid multiple break annotations. */
63 /* The GUI needs to be informed of ignore_count changes, but we don't
64 want to provide successive multiple breakpoints-invalid messages
65 that are all caused by the fact that the ignore count is changing
66 (which could keep the GUI very busy). One is enough, after the
67 target actually "stops". */
70 annotate_ignore_count_change (void)
72 if (annotation_level
> 1)
73 ignore_count_changed
= 1;
77 annotate_breakpoint (int num
)
79 if (annotation_level
> 1)
80 printf_filtered (("\n\032\032breakpoint %d\n"), num
);
84 annotate_catchpoint (int num
)
86 if (annotation_level
> 1)
87 printf_filtered (("\n\032\032catchpoint %d\n"), num
);
91 annotate_watchpoint (int num
)
93 if (annotation_level
> 1)
94 printf_filtered (("\n\032\032watchpoint %d\n"), num
);
98 annotate_starting (void)
100 if (annotation_level
> 1)
101 printf_filtered (("\n\032\032starting\n"));
105 annotate_stopped (void)
107 if (annotation_level
> 1)
108 printf_filtered (("\n\032\032stopped\n"));
109 if (annotation_level
> 1 && ignore_count_changed
)
111 ignore_count_changed
= 0;
112 annotate_breakpoints_changed ();
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)
211 target_terminal_ours ();
212 printf_unfiltered (("\n\032\032frames-invalid\n"));
217 annotate_new_thread (void)
219 if (annotation_level
> 1)
221 printf_unfiltered (("\n\032\032new-thread\n"));
226 annotate_thread_changed (void)
228 if (annotation_level
> 1)
230 printf_unfiltered (("\n\032\032thread-changed\n"));
235 annotate_field_begin (struct type
*type
)
237 if (annotation_level
== 2)
239 printf_filtered (("\n\032\032field-begin "));
240 print_value_flags (type
);
241 printf_filtered (("\n"));
246 annotate_field_name_end (void)
248 if (annotation_level
== 2)
249 printf_filtered (("\n\032\032field-name-end\n"));
253 annotate_field_value (void)
255 if (annotation_level
== 2)
256 printf_filtered (("\n\032\032field-value\n"));
260 annotate_field_end (void)
262 if (annotation_level
== 2)
263 printf_filtered (("\n\032\032field-end\n"));
269 if (annotation_level
> 1)
270 printf_filtered (("\n\032\032quit\n"));
274 annotate_error (void)
276 if (annotation_level
> 1)
277 printf_filtered (("\n\032\032error\n"));
281 annotate_error_begin (void)
283 if (annotation_level
> 1)
284 fprintf_filtered (gdb_stderr
, "\n\032\032error-begin\n");
288 annotate_value_history_begin (int histindex
, struct type
*type
)
290 if (annotation_level
== 2)
292 printf_filtered (("\n\032\032value-history-begin %d "), histindex
);
293 print_value_flags (type
);
294 printf_filtered (("\n"));
299 annotate_value_begin (struct type
*type
)
301 if (annotation_level
== 2)
303 printf_filtered (("\n\032\032value-begin "));
304 print_value_flags (type
);
305 printf_filtered (("\n"));
310 annotate_value_history_value (void)
312 if (annotation_level
== 2)
313 printf_filtered (("\n\032\032value-history-value\n"));
317 annotate_value_history_end (void)
319 if (annotation_level
== 2)
320 printf_filtered (("\n\032\032value-history-end\n"));
324 annotate_value_end (void)
326 if (annotation_level
== 2)
327 printf_filtered (("\n\032\032value-end\n"));
331 annotate_display_begin (void)
333 if (annotation_level
== 2)
334 printf_filtered (("\n\032\032display-begin\n"));
338 annotate_display_number_end (void)
340 if (annotation_level
== 2)
341 printf_filtered (("\n\032\032display-number-end\n"));
345 annotate_display_format (void)
347 if (annotation_level
== 2)
348 printf_filtered (("\n\032\032display-format\n"));
352 annotate_display_expression (void)
354 if (annotation_level
== 2)
355 printf_filtered (("\n\032\032display-expression\n"));
359 annotate_display_expression_end (void)
361 if (annotation_level
== 2)
362 printf_filtered (("\n\032\032display-expression-end\n"));
366 annotate_display_value (void)
368 if (annotation_level
== 2)
369 printf_filtered (("\n\032\032display-value\n"));
373 annotate_display_end (void)
375 if (annotation_level
== 2)
376 printf_filtered (("\n\032\032display-end\n"));
380 annotate_arg_begin (void)
382 if (annotation_level
== 2)
383 printf_filtered (("\n\032\032arg-begin\n"));
387 annotate_arg_name_end (void)
389 if (annotation_level
== 2)
390 printf_filtered (("\n\032\032arg-name-end\n"));
394 annotate_arg_value (struct type
*type
)
396 if (annotation_level
== 2)
398 printf_filtered (("\n\032\032arg-value "));
399 print_value_flags (type
);
400 printf_filtered (("\n"));
405 annotate_arg_end (void)
407 if (annotation_level
== 2)
408 printf_filtered (("\n\032\032arg-end\n"));
412 annotate_source (char *filename
, int line
, int character
, int mid
,
413 struct gdbarch
*gdbarch
, CORE_ADDR pc
)
415 if (annotation_level
> 1)
416 printf_filtered (("\n\032\032source "));
418 printf_filtered (("\032\032"));
420 printf_filtered (("%s:%d:%d:%s:%s\n"), filename
, line
, character
,
421 mid
? "middle" : "beg", paddress (gdbarch
, pc
));
425 annotate_frame_begin (int level
, struct gdbarch
*gdbarch
, CORE_ADDR pc
)
427 if (annotation_level
> 1)
428 printf_filtered (("\n\032\032frame-begin %d %s\n"),
429 level
, paddress (gdbarch
, pc
));
433 annotate_function_call (void)
435 if (annotation_level
== 2)
436 printf_filtered (("\n\032\032function-call\n"));
440 annotate_signal_handler_caller (void)
442 if (annotation_level
== 2)
443 printf_filtered (("\n\032\032signal-handler-caller\n"));
447 annotate_frame_address (void)
449 if (annotation_level
== 2)
450 printf_filtered (("\n\032\032frame-address\n"));
454 annotate_frame_address_end (void)
456 if (annotation_level
== 2)
457 printf_filtered (("\n\032\032frame-address-end\n"));
461 annotate_frame_function_name (void)
463 if (annotation_level
== 2)
464 printf_filtered (("\n\032\032frame-function-name\n"));
468 annotate_frame_args (void)
470 if (annotation_level
== 2)
471 printf_filtered (("\n\032\032frame-args\n"));
475 annotate_frame_source_begin (void)
477 if (annotation_level
== 2)
478 printf_filtered (("\n\032\032frame-source-begin\n"));
482 annotate_frame_source_file (void)
484 if (annotation_level
== 2)
485 printf_filtered (("\n\032\032frame-source-file\n"));
489 annotate_frame_source_file_end (void)
491 if (annotation_level
== 2)
492 printf_filtered (("\n\032\032frame-source-file-end\n"));
496 annotate_frame_source_line (void)
498 if (annotation_level
== 2)
499 printf_filtered (("\n\032\032frame-source-line\n"));
503 annotate_frame_source_end (void)
505 if (annotation_level
== 2)
506 printf_filtered (("\n\032\032frame-source-end\n"));
510 annotate_frame_where (void)
512 if (annotation_level
== 2)
513 printf_filtered (("\n\032\032frame-where\n"));
517 annotate_frame_end (void)
519 if (annotation_level
== 2)
520 printf_filtered (("\n\032\032frame-end\n"));
524 annotate_array_section_begin (int idx
, struct type
*elttype
)
526 if (annotation_level
== 2)
528 printf_filtered (("\n\032\032array-section-begin %d "), idx
);
529 print_value_flags (elttype
);
530 printf_filtered (("\n"));
535 annotate_elt_rep (unsigned int repcount
)
537 if (annotation_level
== 2)
538 printf_filtered (("\n\032\032elt-rep %u\n"), repcount
);
542 annotate_elt_rep_end (void)
544 if (annotation_level
== 2)
545 printf_filtered (("\n\032\032elt-rep-end\n"));
551 if (annotation_level
== 2)
552 printf_filtered (("\n\032\032elt\n"));
556 annotate_array_section_end (void)
558 if (annotation_level
== 2)
559 printf_filtered (("\n\032\032array-section-end\n"));
563 breakpoint_changed (struct breakpoint
*b
)
565 annotate_breakpoints_changed ();
569 _initialize_annotate (void)
571 if (annotation_level
== 2)
573 observer_attach_breakpoint_deleted (breakpoint_changed
);
574 observer_attach_breakpoint_modified (breakpoint_changed
);