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