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
38 void (*deprecated_annotate_signalled_hook) (void);
39 void (*deprecated_annotate_signal_hook) (void);
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. */
45 static int frames_invalid_emitted;
46 static int breakpoints_invalid_emitted;
47
48 static void
49 print_value_flags (struct type *t)
50 {
51 if (can_dereference (t))
52 printf_filtered (("*"));
53 else
54 printf_filtered (("-"));
55 }
56
57 static void
58 annotate_breakpoints_invalid (void)
59 {
60 if (annotation_level == 2
61 && (!breakpoints_invalid_emitted
62 || current_ui->prompt_state != PROMPT_BLOCKED))
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
68 target_terminal::ours_for_output ();
69
70 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
71
72 if (was_inferior)
73 target_terminal::inferior ();
74
75 breakpoints_invalid_emitted = 1;
76 }
77 }
78
79 void
80 annotate_breakpoint (int num)
81 {
82 if (annotation_level > 1)
83 printf_filtered (("\n\032\032breakpoint %d\n"), num);
84 }
85
86 void
87 annotate_catchpoint (int num)
88 {
89 if (annotation_level > 1)
90 printf_filtered (("\n\032\032catchpoint %d\n"), num);
91 }
92
93 void
94 annotate_watchpoint (int num)
95 {
96 if (annotation_level > 1)
97 printf_filtered (("\n\032\032watchpoint %d\n"), num);
98 }
99
100 void
101 annotate_starting (void)
102 {
103 if (annotation_level > 1)
104 printf_filtered (("\n\032\032starting\n"));
105 }
106
107 void
108 annotate_stopped (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
122 annotate_signalled (void)
123 {
124 if (deprecated_annotate_signalled_hook)
125 deprecated_annotate_signalled_hook ();
126
127 if (annotation_level > 1)
128 printf_filtered (("\n\032\032signalled\n"));
129 }
130
131 void
132 annotate_signal_name (void)
133 {
134 if (annotation_level == 2)
135 printf_filtered (("\n\032\032signal-name\n"));
136 }
137
138 void
139 annotate_signal_name_end (void)
140 {
141 if (annotation_level == 2)
142 printf_filtered (("\n\032\032signal-name-end\n"));
143 }
144
145 void
146 annotate_signal_string (void)
147 {
148 if (annotation_level == 2)
149 printf_filtered (("\n\032\032signal-string\n"));
150 }
151
152 void
153 annotate_signal_string_end (void)
154 {
155 if (annotation_level == 2)
156 printf_filtered (("\n\032\032signal-string-end\n"));
157 }
158
159 void
160 annotate_signal (void)
161 {
162 if (deprecated_annotate_signal_hook)
163 deprecated_annotate_signal_hook ();
164
165 if (annotation_level > 1)
166 printf_filtered (("\n\032\032signal\n"));
167 }
168
169 void
170 annotate_breakpoints_headers (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
184 annotate_breakpoints_table (void)
185 {
186 if (annotation_level == 2)
187 printf_filtered (("\n\032\032breakpoints-table\n"));
188 }
189
190 void
191 annotate_record (void)
192 {
193 if (annotation_level == 2)
194 printf_filtered (("\n\032\032record\n"));
195 }
196
197 void
198 annotate_breakpoints_table_end (void)
199 {
200 if (annotation_level == 2)
201 printf_filtered (("\n\032\032breakpoints-table-end\n"));
202 }
203
204 void
205 annotate_frames_invalid (void)
206 {
207 if (annotation_level == 2
208 && (!frames_invalid_emitted
209 || current_ui->prompt_state != PROMPT_BLOCKED))
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
215 target_terminal::ours_for_output ();
216
217 printf_unfiltered (("\n\032\032frames-invalid\n"));
218
219 if (was_inferior)
220 target_terminal::inferior ();
221
222 frames_invalid_emitted = 1;
223 }
224 }
225
226 void
227 annotate_new_thread (void)
228 {
229 if (annotation_level > 1)
230 {
231 printf_unfiltered (("\n\032\032new-thread\n"));
232 }
233 }
234
235 void
236 annotate_thread_changed (void)
237 {
238 if (annotation_level > 1)
239 {
240 printf_unfiltered (("\n\032\032thread-changed\n"));
241 }
242 }
243
244 void
245 annotate_field_begin (struct type *type)
246 {
247 if (annotation_level == 2)
248 {
249 printf_filtered (("\n\032\032field-begin "));
250 print_value_flags (type);
251 printf_filtered (("\n"));
252 }
253 }
254
255 void
256 annotate_field_name_end (void)
257 {
258 if (annotation_level == 2)
259 printf_filtered (("\n\032\032field-name-end\n"));
260 }
261
262 void
263 annotate_field_value (void)
264 {
265 if (annotation_level == 2)
266 printf_filtered (("\n\032\032field-value\n"));
267 }
268
269 void
270 annotate_field_end (void)
271 {
272 if (annotation_level == 2)
273 printf_filtered (("\n\032\032field-end\n"));
274 }
275
276 void
277 annotate_quit (void)
278 {
279 if (annotation_level > 1)
280 printf_filtered (("\n\032\032quit\n"));
281 }
282
283 void
284 annotate_error (void)
285 {
286 if (annotation_level > 1)
287 printf_filtered (("\n\032\032error\n"));
288 }
289
290 void
291 annotate_error_begin (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);
303 print_value_flags (type);
304 printf_filtered (("\n"));
305 }
306 }
307
308 void
309 annotate_value_begin (struct type *type)
310 {
311 if (annotation_level == 2)
312 {
313 printf_filtered (("\n\032\032value-begin "));
314 print_value_flags (type);
315 printf_filtered (("\n"));
316 }
317 }
318
319 void
320 annotate_value_history_value (void)
321 {
322 if (annotation_level == 2)
323 printf_filtered (("\n\032\032value-history-value\n"));
324 }
325
326 void
327 annotate_value_history_end (void)
328 {
329 if (annotation_level == 2)
330 printf_filtered (("\n\032\032value-history-end\n"));
331 }
332
333 void
334 annotate_value_end (void)
335 {
336 if (annotation_level == 2)
337 printf_filtered (("\n\032\032value-end\n"));
338 }
339
340 void
341 annotate_display_begin (void)
342 {
343 if (annotation_level == 2)
344 printf_filtered (("\n\032\032display-begin\n"));
345 }
346
347 void
348 annotate_display_number_end (void)
349 {
350 if (annotation_level == 2)
351 printf_filtered (("\n\032\032display-number-end\n"));
352 }
353
354 void
355 annotate_display_format (void)
356 {
357 if (annotation_level == 2)
358 printf_filtered (("\n\032\032display-format\n"));
359 }
360
361 void
362 annotate_display_expression (void)
363 {
364 if (annotation_level == 2)
365 printf_filtered (("\n\032\032display-expression\n"));
366 }
367
368 void
369 annotate_display_expression_end (void)
370 {
371 if (annotation_level == 2)
372 printf_filtered (("\n\032\032display-expression-end\n"));
373 }
374
375 void
376 annotate_display_value (void)
377 {
378 if (annotation_level == 2)
379 printf_filtered (("\n\032\032display-value\n"));
380 }
381
382 void
383 annotate_display_end (void)
384 {
385 if (annotation_level == 2)
386 printf_filtered (("\n\032\032display-end\n"));
387 }
388
389 void
390 annotate_arg_begin (void)
391 {
392 if (annotation_level == 2)
393 printf_filtered (("\n\032\032arg-begin\n"));
394 }
395
396 void
397 annotate_arg_name_end (void)
398 {
399 if (annotation_level == 2)
400 printf_filtered (("\n\032\032arg-name-end\n"));
401 }
402
403 void
404 annotate_arg_value (struct type *type)
405 {
406 if (annotation_level == 2)
407 {
408 printf_filtered (("\n\032\032arg-value "));
409 print_value_flags (type);
410 printf_filtered (("\n"));
411 }
412 }
413
414 void
415 annotate_arg_end (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
435 annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
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
443 annotate_function_call (void)
444 {
445 if (annotation_level == 2)
446 printf_filtered (("\n\032\032function-call\n"));
447 }
448
449 void
450 annotate_signal_handler_caller (void)
451 {
452 if (annotation_level == 2)
453 printf_filtered (("\n\032\032signal-handler-caller\n"));
454 }
455
456 void
457 annotate_frame_address (void)
458 {
459 if (annotation_level == 2)
460 printf_filtered (("\n\032\032frame-address\n"));
461 }
462
463 void
464 annotate_frame_address_end (void)
465 {
466 if (annotation_level == 2)
467 printf_filtered (("\n\032\032frame-address-end\n"));
468 }
469
470 void
471 annotate_frame_function_name (void)
472 {
473 if (annotation_level == 2)
474 printf_filtered (("\n\032\032frame-function-name\n"));
475 }
476
477 void
478 annotate_frame_args (void)
479 {
480 if (annotation_level == 2)
481 printf_filtered (("\n\032\032frame-args\n"));
482 }
483
484 void
485 annotate_frame_source_begin (void)
486 {
487 if (annotation_level == 2)
488 printf_filtered (("\n\032\032frame-source-begin\n"));
489 }
490
491 void
492 annotate_frame_source_file (void)
493 {
494 if (annotation_level == 2)
495 printf_filtered (("\n\032\032frame-source-file\n"));
496 }
497
498 void
499 annotate_frame_source_file_end (void)
500 {
501 if (annotation_level == 2)
502 printf_filtered (("\n\032\032frame-source-file-end\n"));
503 }
504
505 void
506 annotate_frame_source_line (void)
507 {
508 if (annotation_level == 2)
509 printf_filtered (("\n\032\032frame-source-line\n"));
510 }
511
512 void
513 annotate_frame_source_end (void)
514 {
515 if (annotation_level == 2)
516 printf_filtered (("\n\032\032frame-source-end\n"));
517 }
518
519 void
520 annotate_frame_where (void)
521 {
522 if (annotation_level == 2)
523 printf_filtered (("\n\032\032frame-where\n"));
524 }
525
526 void
527 annotate_frame_end (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
552 annotate_elt_rep_end (void)
553 {
554 if (annotation_level == 2)
555 printf_filtered (("\n\032\032elt-rep-end\n"));
556 }
557
558 void
559 annotate_elt (void)
560 {
561 if (annotation_level == 2)
562 printf_filtered (("\n\032\032elt\n"));
563 }
564
565 void
566 annotate_array_section_end (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
577 annotate_display_prompt (void)
578 {
579 frames_invalid_emitted = 0;
580 breakpoints_invalid_emitted = 0;
581 }
582
583 static void
584 breakpoint_changed (struct breakpoint *b)
585 {
586 if (b->number <= 0)
587 return;
588
589 annotate_breakpoints_invalid ();
590 }
591
592 void
593 _initialize_annotate (void)
594 {
595 observer_attach_breakpoint_created (breakpoint_changed);
596 observer_attach_breakpoint_deleted (breakpoint_changed);
597 observer_attach_breakpoint_modified (breakpoint_changed);
598 }
gdbarch
Definition: gdbarch.c:127
top.h
annotate_signalled
void annotate_signalled(void)
Definition: annotate.c:122
annotate_watchpoint
void annotate_watchpoint(int num)
Definition: annotate.c:94
annotate_frame_function_name
void annotate_frame_function_name(void)
Definition: annotate.c:471
annotate_field_value
void annotate_field_value(void)
Definition: annotate.c:263
annotate_breakpoints_table
void annotate_breakpoints_table(void)
Definition: annotate.c:184
observer_attach_breakpoint_deleted
struct observer * observer_attach_breakpoint_deleted(observer_breakpoint_deleted_ftype *f)
annotate_frame_source_file_end
void annotate_frame_source_file_end(void)
Definition: annotate.c:499
current_ui
struct ui * current_ui
Definition: event-top.c:453
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
deprecated_annotate_signalled_hook
void(* deprecated_annotate_signalled_hook)(void)
Definition: annotate.c:38
annotate_record
void annotate_record(void)
Definition: annotate.c:191
annotate_stopped
void annotate_stopped(void)
Definition: annotate.c:108
annotate_breakpoints_invalid
static void annotate_breakpoints_invalid(void)
Definition: annotate.c:58
annotate_signal_handler_caller
void annotate_signal_handler_caller(void)
Definition: annotate.c:450
target_terminal::is_inferior
static bool is_inferior()
Definition: target.h:130
annotate_arg_begin
void annotate_arg_begin(void)
Definition: annotate.c:390
annotate_field
void annotate_field(int num)
Definition: annotate.c:177
breakpoint::number
int number
Definition: breakpoint.h:699
deprecated_annotate_signal_hook
void(* deprecated_annotate_signal_hook)(void)
Definition: annotate.c:39
annotate_value_history_value
void annotate_value_history_value(void)
Definition: annotate.c:320
annotate_signal
void annotate_signal(void)
Definition: annotate.c:160
_initialize_annotate
void _initialize_annotate(void)
Definition: annotate.c:593
breakpoint_changed
static void breakpoint_changed(struct breakpoint *b)
Definition: annotate.c:584
annotate_field_name_end
void annotate_field_name_end(void)
Definition: annotate.c:256
defs.h
annotate_arg_value
void annotate_arg_value(struct type *type)
Definition: annotate.c:404
annotate_display_value
void annotate_display_value(void)
Definition: annotate.c:376
can_dereference
int can_dereference(struct type *t)
Definition: gdbtypes.c:3015
annotate_source
void annotate_source(char *filename, int line, int character, int mid, struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: annotate.c:422
target_terminal::inferior
static void inferior()
Definition: target.c:450
printf_filtered
void printf_filtered(const char *format,...)
Definition: utils.c:2045
paddress
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2745
observer.h
annotate_signal_name_end
void annotate_signal_name_end(void)
Definition: annotate.c:139
annotate_value_end
void annotate_value_end(void)
Definition: annotate.c:334
annotate_frame_address
void annotate_frame_address(void)
Definition: annotate.c:457
annotate_frame_args
void annotate_frame_args(void)
Definition: annotate.c:478
annotate_frame_source_file
void annotate_frame_source_file(void)
Definition: annotate.c:492
annotate_exited
void annotate_exited(int exitstatus)
Definition: annotate.c:115
fprintf_filtered
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2008
annotate_frame_source_end
void annotate_frame_source_end(void)
Definition: annotate.c:513
frames_invalid_emitted
static int frames_invalid_emitted
Definition: annotate.c:45
ui::prompt_state
enum prompt_state prompt_state
Definition: top.h:131
annotate_starting
void annotate_starting(void)
Definition: annotate.c:101
minimal_symbol::filename
const char * filename
Definition: symtab.h:640
annotate_elt_rep
void annotate_elt_rep(unsigned int repcount)
Definition: annotate.c:545
observer_attach_breakpoint_created
struct observer * observer_attach_breakpoint_created(observer_breakpoint_created_ftype *f)
breakpoint
Definition: breakpoint.h:684
inferior.h
infrun.h
type
Definition: gdbtypes.h:749
annotation_level
int annotation_level
Definition: stack.c:111
annotate_array_section_begin
void annotate_array_section_begin(int idx, struct type *elttype)
Definition: annotate.c:534
annotate_display_end
void annotate_display_end(void)
Definition: annotate.c:383
annotate_display_expression_end
void annotate_display_expression_end(void)
Definition: annotate.c:369
annotate_error_begin
void annotate_error_begin(void)
Definition: annotate.c:291
breakpoint.h
printf_unfiltered
void printf_unfiltered(const char *format,...)
Definition: utils.c:2056
annotate_thread_changed
void annotate_thread_changed(void)
Definition: annotate.c:236
annotate_elt_rep_end
void annotate_elt_rep_end(void)
Definition: annotate.c:552
target_terminal::ours_for_output
static void ours_for_output()
Definition: target.c:501
annotate_display_expression
void annotate_display_expression(void)
Definition: annotate.c:362
annotate_array_section_end
void annotate_array_section_end(void)
Definition: annotate.c:566
annotate_breakpoints_headers
void annotate_breakpoints_headers(void)
Definition: annotate.c:170
annotate_frame_begin
void annotate_frame_begin(int level, struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: annotate.c:435
annotate_signal_name
void annotate_signal_name(void)
Definition: annotate.c:132
annotate_signal_string_end
void annotate_signal_string_end(void)
Definition: annotate.c:153
PROMPT_BLOCKED
Definition: top.h:37
annotate_arg_end
void annotate_arg_end(void)
Definition: annotate.c:415
gdb_stderr
#define gdb_stderr
Definition: utils.h:344
annotate_frame_end
void annotate_frame_end(void)
Definition: annotate.c:527
annotate_frame_source_begin
void annotate_frame_source_begin(void)
Definition: annotate.c:485
annotate_frame_address_end
void annotate_frame_address_end(void)
Definition: annotate.c:464
observer_attach_breakpoint_modified
struct observer * observer_attach_breakpoint_modified(observer_breakpoint_modified_ftype *f)
annotate_display_format
void annotate_display_format(void)
Definition: annotate.c:355
annotate_value_begin
void annotate_value_begin(struct type *type)
Definition: annotate.c:309
annotate_quit
void annotate_quit(void)
Definition: annotate.c:277
annotate_value_history_end
void annotate_value_history_end(void)
Definition: annotate.c:327
print_value_flags
static void print_value_flags(struct type *)
Definition: annotate.c:49
annotate_frame_source_line
void annotate_frame_source_line(void)
Definition: annotate.c:506
annotate_display_begin
void annotate_display_begin(void)
Definition: annotate.c:341
target.h
value.h
annotate_elt
void annotate_elt(void)
Definition: annotate.c:559
annotate_display_number_end
void annotate_display_number_end(void)
Definition: annotate.c:348
annotate_field_end
void annotate_field_end(void)
Definition: annotate.c:270
gdbtypes.h
annotate_frame_where
void annotate_frame_where(void)
Definition: annotate.c:520
annotate_value_history_begin
void annotate_value_history_begin(int histindex, struct type *type)
Definition: annotate.c:298
annotate_breakpoints_table_end
void annotate_breakpoints_table_end(void)
Definition: annotate.c:198
annotate_function_call
void annotate_function_call(void)
Definition: annotate.c:443
annotate_error
void annotate_error(void)
Definition: annotate.c:284
annotate_breakpoint
void annotate_breakpoint(int num)
Definition: annotate.c:80
annotate_arg_name_end
void annotate_arg_name_end(void)
Definition: annotate.c:397
annotate_signal_string
void annotate_signal_string(void)
Definition: annotate.c:146
annotate_catchpoint
void annotate_catchpoint(int num)
Definition: annotate.c:87
annotate_frames_invalid
void annotate_frames_invalid(void)
Definition: annotate.c:205
annotate.h
annotate_new_thread
void annotate_new_thread(void)
Definition: annotate.c:227
annotate_display_prompt
void annotate_display_prompt(void)
Definition: annotate.c:577
annotate_field_begin
void annotate_field_begin(struct type *type)
Definition: annotate.c:245
breakpoints_invalid_emitted
static int breakpoints_invalid_emitted
Definition: annotate.c:46