GDB (xrefs)
/tmp/gdb-7.10/gdb/annotate.c
Go to the documentation of this file.
1 /* Annotation routines for GDB.
2  Copyright (C) 1986-2015 Free Software Foundation, Inc.
3 
4  This file is part of GDB.
5 
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.
10 
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.
15 
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/>. */
18 
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"
28 
29 
30 /* Prototypes for local functions. */
31 
32 extern void _initialize_annotate (void);
33 
34 static void print_value_flags (struct type *);
35 
36 static void breakpoint_changed (struct breakpoint *b);
37 
38 
41 
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. */
48 
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. */
52 
53 static int
55 {
56  return (target_can_async_p () && !sync_execution);
57 }
58 
59 static void
61 {
62  if (can_dereference (t))
63  printf_filtered (("*"));
64  else
65  printf_filtered (("-"));
66 }
67 
68 static void
70 {
71  if (annotation_level == 2
74  {
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 ();
78 
80 
81  printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
82 
83  if (was_inferior)
85 
87  }
88 }
89 
90 void
92 {
93  if (annotation_level > 1)
94  printf_filtered (("\n\032\032breakpoint %d\n"), num);
95 }
96 
97 void
99 {
100  if (annotation_level > 1)
101  printf_filtered (("\n\032\032catchpoint %d\n"), num);
102 }
103 
104 void
106 {
107  if (annotation_level > 1)
108  printf_filtered (("\n\032\032watchpoint %d\n"), num);
109 }
110 
111 void
113 {
114  if (annotation_level > 1)
115  printf_filtered (("\n\032\032starting\n"));
116 }
117 
118 void
120 {
121  if (annotation_level > 1)
122  printf_filtered (("\n\032\032stopped\n"));
123 }
124 
125 void
126 annotate_exited (int exitstatus)
127 {
128  if (annotation_level > 1)
129  printf_filtered (("\n\032\032exited %d\n"), exitstatus);
130 }
131 
132 void
134 {
137 
138  if (annotation_level > 1)
139  printf_filtered (("\n\032\032signalled\n"));
140 }
141 
142 void
144 {
145  if (annotation_level == 2)
146  printf_filtered (("\n\032\032signal-name\n"));
147 }
148 
149 void
151 {
152  if (annotation_level == 2)
153  printf_filtered (("\n\032\032signal-name-end\n"));
154 }
155 
156 void
158 {
159  if (annotation_level == 2)
160  printf_filtered (("\n\032\032signal-string\n"));
161 }
162 
163 void
165 {
166  if (annotation_level == 2)
167  printf_filtered (("\n\032\032signal-string-end\n"));
168 }
169 
170 void
172 {
175 
176  if (annotation_level > 1)
177  printf_filtered (("\n\032\032signal\n"));
178 }
179 
180 void
182 {
183  if (annotation_level == 2)
184  printf_filtered (("\n\032\032breakpoints-headers\n"));
185 }
186 
187 void
188 annotate_field (int num)
189 {
190  if (annotation_level == 2)
191  printf_filtered (("\n\032\032field %d\n"), num);
192 }
193 
194 void
196 {
197  if (annotation_level == 2)
198  printf_filtered (("\n\032\032breakpoints-table\n"));
199 }
200 
201 void
203 {
204  if (annotation_level == 2)
205  printf_filtered (("\n\032\032record\n"));
206 }
207 
208 void
210 {
211  if (annotation_level == 2)
212  printf_filtered (("\n\032\032breakpoints-table-end\n"));
213 }
214 
215 void
217 {
218  if (annotation_level == 2
221  {
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 ();
225 
227 
228  printf_unfiltered (("\n\032\032frames-invalid\n"));
229 
230  if (was_inferior)
232 
234  }
235 }
236 
237 void
239 {
240  if (annotation_level > 1)
241  {
242  printf_unfiltered (("\n\032\032new-thread\n"));
243  }
244 }
245 
246 void
248 {
249  if (annotation_level > 1)
250  {
251  printf_unfiltered (("\n\032\032thread-changed\n"));
252  }
253 }
254 
255 void
257 {
258  if (annotation_level == 2)
259  {
260  printf_filtered (("\n\032\032field-begin "));
261  print_value_flags (type);
262  printf_filtered (("\n"));
263  }
264 }
265 
266 void
268 {
269  if (annotation_level == 2)
270  printf_filtered (("\n\032\032field-name-end\n"));
271 }
272 
273 void
275 {
276  if (annotation_level == 2)
277  printf_filtered (("\n\032\032field-value\n"));
278 }
279 
280 void
282 {
283  if (annotation_level == 2)
284  printf_filtered (("\n\032\032field-end\n"));
285 }
286 
287 void
289 {
290  if (annotation_level > 1)
291  printf_filtered (("\n\032\032quit\n"));
292 }
293 
294 void
296 {
297  if (annotation_level > 1)
298  printf_filtered (("\n\032\032error\n"));
299 }
300 
301 void
303 {
304  if (annotation_level > 1)
305  fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
306 }
307 
308 void
309 annotate_value_history_begin (int histindex, struct type *type)
310 {
311  if (annotation_level == 2)
312  {
313  printf_filtered (("\n\032\032value-history-begin %d "), histindex);
314  print_value_flags (type);
315  printf_filtered (("\n"));
316  }
317 }
318 
319 void
321 {
322  if (annotation_level == 2)
323  {
324  printf_filtered (("\n\032\032value-begin "));
325  print_value_flags (type);
326  printf_filtered (("\n"));
327  }
328 }
329 
330 void
332 {
333  if (annotation_level == 2)
334  printf_filtered (("\n\032\032value-history-value\n"));
335 }
336 
337 void
339 {
340  if (annotation_level == 2)
341  printf_filtered (("\n\032\032value-history-end\n"));
342 }
343 
344 void
346 {
347  if (annotation_level == 2)
348  printf_filtered (("\n\032\032value-end\n"));
349 }
350 
351 void
353 {
354  if (annotation_level == 2)
355  printf_filtered (("\n\032\032display-begin\n"));
356 }
357 
358 void
360 {
361  if (annotation_level == 2)
362  printf_filtered (("\n\032\032display-number-end\n"));
363 }
364 
365 void
367 {
368  if (annotation_level == 2)
369  printf_filtered (("\n\032\032display-format\n"));
370 }
371 
372 void
374 {
375  if (annotation_level == 2)
376  printf_filtered (("\n\032\032display-expression\n"));
377 }
378 
379 void
381 {
382  if (annotation_level == 2)
383  printf_filtered (("\n\032\032display-expression-end\n"));
384 }
385 
386 void
388 {
389  if (annotation_level == 2)
390  printf_filtered (("\n\032\032display-value\n"));
391 }
392 
393 void
395 {
396  if (annotation_level == 2)
397  printf_filtered (("\n\032\032display-end\n"));
398 }
399 
400 void
402 {
403  if (annotation_level == 2)
404  printf_filtered (("\n\032\032arg-begin\n"));
405 }
406 
407 void
409 {
410  if (annotation_level == 2)
411  printf_filtered (("\n\032\032arg-name-end\n"));
412 }
413 
414 void
416 {
417  if (annotation_level == 2)
418  {
419  printf_filtered (("\n\032\032arg-value "));
420  print_value_flags (type);
421  printf_filtered (("\n"));
422  }
423 }
424 
425 void
427 {
428  if (annotation_level == 2)
429  printf_filtered (("\n\032\032arg-end\n"));
430 }
431 
432 void
433 annotate_source (char *filename, int line, int character, int mid,
434  struct gdbarch *gdbarch, CORE_ADDR pc)
435 {
436  if (annotation_level > 1)
437  printf_filtered (("\n\032\032source "));
438  else
439  printf_filtered (("\032\032"));
440 
441  printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
442  mid ? "middle" : "beg", paddress (gdbarch, pc));
443 }
444 
445 void
447 {
448  if (annotation_level > 1)
449  printf_filtered (("\n\032\032frame-begin %d %s\n"),
450  level, paddress (gdbarch, pc));
451 }
452 
453 void
455 {
456  if (annotation_level == 2)
457  printf_filtered (("\n\032\032function-call\n"));
458 }
459 
460 void
462 {
463  if (annotation_level == 2)
464  printf_filtered (("\n\032\032signal-handler-caller\n"));
465 }
466 
467 void
469 {
470  if (annotation_level == 2)
471  printf_filtered (("\n\032\032frame-address\n"));
472 }
473 
474 void
476 {
477  if (annotation_level == 2)
478  printf_filtered (("\n\032\032frame-address-end\n"));
479 }
480 
481 void
483 {
484  if (annotation_level == 2)
485  printf_filtered (("\n\032\032frame-function-name\n"));
486 }
487 
488 void
490 {
491  if (annotation_level == 2)
492  printf_filtered (("\n\032\032frame-args\n"));
493 }
494 
495 void
497 {
498  if (annotation_level == 2)
499  printf_filtered (("\n\032\032frame-source-begin\n"));
500 }
501 
502 void
504 {
505  if (annotation_level == 2)
506  printf_filtered (("\n\032\032frame-source-file\n"));
507 }
508 
509 void
511 {
512  if (annotation_level == 2)
513  printf_filtered (("\n\032\032frame-source-file-end\n"));
514 }
515 
516 void
518 {
519  if (annotation_level == 2)
520  printf_filtered (("\n\032\032frame-source-line\n"));
521 }
522 
523 void
525 {
526  if (annotation_level == 2)
527  printf_filtered (("\n\032\032frame-source-end\n"));
528 }
529 
530 void
532 {
533  if (annotation_level == 2)
534  printf_filtered (("\n\032\032frame-where\n"));
535 }
536 
537 void
539 {
540  if (annotation_level == 2)
541  printf_filtered (("\n\032\032frame-end\n"));
542 }
543 
544 void
545 annotate_array_section_begin (int idx, struct type *elttype)
546 {
547  if (annotation_level == 2)
548  {
549  printf_filtered (("\n\032\032array-section-begin %d "), idx);
550  print_value_flags (elttype);
551  printf_filtered (("\n"));
552  }
553 }
554 
555 void
556 annotate_elt_rep (unsigned int repcount)
557 {
558  if (annotation_level == 2)
559  printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
560 }
561 
562 void
564 {
565  if (annotation_level == 2)
566  printf_filtered (("\n\032\032elt-rep-end\n"));
567 }
568 
569 void
571 {
572  if (annotation_level == 2)
573  printf_filtered (("\n\032\032elt\n"));
574 }
575 
576 void
578 {
579  if (annotation_level == 2)
580  printf_filtered (("\n\032\032array-section-end\n"));
581 }
582 
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. */
586 
587 void
589 {
592 }
593 
594 static void
596 {
597  if (b->number <= 0)
598  return;
599 
601 }
602 
603 void
605 {
609 }
void annotate_signalled(void)
Definition: annotate.c:133
#define target_can_async_p()
Definition: target.h:1748
void annotate_watchpoint(int num)
Definition: annotate.c:105
void annotate_frame_function_name(void)
Definition: annotate.c:482
void annotate_field_value(void)
Definition: annotate.c:274
void annotate_breakpoints_table(void)
Definition: annotate.c:195
struct observer * observer_attach_breakpoint_deleted(observer_breakpoint_deleted_ftype *f)
void annotate_frame_source_file_end(void)
Definition: annotate.c:510
bfd_vma CORE_ADDR
Definition: common-types.h:41
void(* deprecated_annotate_signalled_hook)(void)
Definition: annotate.c:39
void annotate_record(void)
Definition: annotate.c:202
void annotate_stopped(void)
Definition: annotate.c:119
static void annotate_breakpoints_invalid(void)
Definition: annotate.c:69
void annotate_signal_handler_caller(void)
Definition: annotate.c:461
static int async_background_execution_p(void)
Definition: annotate.c:54
void annotate_arg_begin(void)
Definition: annotate.c:401
void annotate_field(int num)
Definition: annotate.c:188
void(* deprecated_annotate_signal_hook)(void)
Definition: annotate.c:40
struct m32c_reg * pc
Definition: m32c-tdep.c:111
void annotate_value_history_value(void)
Definition: annotate.c:331
void annotate_signal(void)
Definition: annotate.c:171
void _initialize_annotate(void)
Definition: annotate.c:604
static void breakpoint_changed(struct breakpoint *b)
Definition: annotate.c:595
void annotate_field_name_end(void)
Definition: annotate.c:267
void annotate_arg_value(struct type *type)
Definition: annotate.c:415
void annotate_display_value(void)
Definition: annotate.c:387
int can_dereference(struct type *t)
Definition: gdbtypes.c:2678
void annotate_source(char *filename, int line, int character, int mid, struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: annotate.c:433
void printf_filtered(const char *format,...)
Definition: utils.c:2388
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2743
void annotate_signal_name_end(void)
Definition: annotate.c:150
void annotate_value_end(void)
Definition: annotate.c:345
void annotate_frame_address(void)
Definition: annotate.c:468
void annotate_frame_args(void)
Definition: annotate.c:489
void annotate_frame_source_file(void)
Definition: annotate.c:503
void annotate_exited(int exitstatus)
Definition: annotate.c:126
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2351
void annotate_frame_source_end(void)
Definition: annotate.c:524
static int frames_invalid_emitted
Definition: annotate.c:46
void annotate_starting(void)
Definition: annotate.c:112
void target_terminal_inferior(void)
Definition: target.c:470
void annotate_elt_rep(unsigned int repcount)
Definition: annotate.c:556
struct observer * observer_attach_breakpoint_created(observer_breakpoint_created_ftype *f)
int sync_execution
Definition: infrun.c:117
Definition: gdbtypes.h:749
int annotation_level
Definition: stack.c:109
void annotate_array_section_begin(int idx, struct type *elttype)
Definition: annotate.c:545
void annotate_display_end(void)
Definition: annotate.c:394
void annotate_display_expression_end(void)
Definition: annotate.c:380
void annotate_error_begin(void)
Definition: annotate.c:302
void printf_unfiltered(const char *format,...)
Definition: utils.c:2399
void annotate_thread_changed(void)
Definition: annotate.c:247
void annotate_elt_rep_end(void)
Definition: annotate.c:563
void annotate_display_expression(void)
Definition: annotate.c:373
void annotate_array_section_end(void)
Definition: annotate.c:577
void annotate_breakpoints_headers(void)
Definition: annotate.c:181
void annotate_frame_begin(int level, struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: annotate.c:446
void annotate_signal_name(void)
Definition: annotate.c:143
void annotate_signal_string_end(void)
Definition: annotate.c:164
void annotate_arg_end(void)
Definition: annotate.c:426
void annotate_frame_end(void)
Definition: annotate.c:538
int target_terminal_is_inferior(void)
Definition: target.c:462
void annotate_frame_source_begin(void)
Definition: annotate.c:496
void annotate_frame_address_end(void)
Definition: annotate.c:475
struct ui_file * gdb_stderr
Definition: main.c:72
struct observer * observer_attach_breakpoint_modified(observer_breakpoint_modified_ftype *f)
void annotate_display_format(void)
Definition: annotate.c:366
void annotate_value_begin(struct type *type)
Definition: annotate.c:320
void annotate_quit(void)
Definition: annotate.c:288
void annotate_value_history_end(void)
Definition: annotate.c:338
static void print_value_flags(struct type *)
Definition: annotate.c:60
int line
Definition: symtab.h:1570
void annotate_frame_source_line(void)
Definition: annotate.c:517
void annotate_display_begin(void)
Definition: annotate.c:352
void annotate_elt(void)
Definition: annotate.c:570
void annotate_display_number_end(void)
Definition: annotate.c:359
void annotate_field_end(void)
Definition: annotate.c:281
void annotate_frame_where(void)
Definition: annotate.c:531
void annotate_value_history_begin(int histindex, struct type *type)
Definition: annotate.c:309
void annotate_breakpoints_table_end(void)
Definition: annotate.c:209
void annotate_function_call(void)
Definition: annotate.c:454
void annotate_error(void)
Definition: annotate.c:295
void annotate_breakpoint(int num)
Definition: annotate.c:91
void annotate_arg_name_end(void)
Definition: annotate.c:408
void annotate_signal_string(void)
Definition: annotate.c:157
void target_terminal_ours_for_output(void)
Definition: target.c:503
void annotate_catchpoint(int num)
Definition: annotate.c:98
void annotate_frames_invalid(void)
Definition: annotate.c:216
void annotate_new_thread(void)
Definition: annotate.c:238
void annotate_display_prompt(void)
Definition: annotate.c:588
void annotate_field_begin(struct type *type)
Definition: annotate.c:256
static int breakpoints_invalid_emitted
Definition: annotate.c:47