ld: Set non_ir_ref_regular for --undefined SYMBOL
[deliverable/binutils-gdb.git] / gdb / annotate.c
... / ...
CommitLineData
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 "observable.h"
26#include "inferior.h"
27#include "infrun.h"
28#include "top.h"
29\f
30
31/* Prototypes for local functions. */
32
33static void print_value_flags (struct type *);
34
35static void breakpoint_changed (struct breakpoint *b);
36
37
38void (*deprecated_annotate_signalled_hook) (void);
39void (*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. */
45static int frames_invalid_emitted;
46static int breakpoints_invalid_emitted;
47
48static void
49print_value_flags (struct type *t)
50{
51 if (can_dereference (t))
52 printf_filtered (("*"));
53 else
54 printf_filtered (("-"));
55}
56
57static void
58annotate_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
79void
80annotate_breakpoint (int num)
81{
82 if (annotation_level > 1)
83 printf_filtered (("\n\032\032breakpoint %d\n"), num);
84}
85
86void
87annotate_catchpoint (int num)
88{
89 if (annotation_level > 1)
90 printf_filtered (("\n\032\032catchpoint %d\n"), num);
91}
92
93void
94annotate_watchpoint (int num)
95{
96 if (annotation_level > 1)
97 printf_filtered (("\n\032\032watchpoint %d\n"), num);
98}
99
100void
101annotate_starting (void)
102{
103 if (annotation_level > 1)
104 printf_filtered (("\n\032\032starting\n"));
105}
106
107void
108annotate_stopped (void)
109{
110 if (annotation_level > 1)
111 printf_filtered (("\n\032\032stopped\n"));
112}
113
114void
115annotate_exited (int exitstatus)
116{
117 if (annotation_level > 1)
118 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
119}
120
121void
122annotate_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
131void
132annotate_signal_name (void)
133{
134 if (annotation_level == 2)
135 printf_filtered (("\n\032\032signal-name\n"));
136}
137
138void
139annotate_signal_name_end (void)
140{
141 if (annotation_level == 2)
142 printf_filtered (("\n\032\032signal-name-end\n"));
143}
144
145void
146annotate_signal_string (void)
147{
148 if (annotation_level == 2)
149 printf_filtered (("\n\032\032signal-string\n"));
150}
151
152void
153annotate_signal_string_end (void)
154{
155 if (annotation_level == 2)
156 printf_filtered (("\n\032\032signal-string-end\n"));
157}
158
159void
160annotate_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\f
169void
170annotate_breakpoints_headers (void)
171{
172 if (annotation_level == 2)
173 printf_filtered (("\n\032\032breakpoints-headers\n"));
174}
175
176void
177annotate_field (int num)
178{
179 if (annotation_level == 2)
180 printf_filtered (("\n\032\032field %d\n"), num);
181}
182
183void
184annotate_breakpoints_table (void)
185{
186 if (annotation_level == 2)
187 printf_filtered (("\n\032\032breakpoints-table\n"));
188}
189
190void
191annotate_record (void)
192{
193 if (annotation_level == 2)
194 printf_filtered (("\n\032\032record\n"));
195}
196
197void
198annotate_breakpoints_table_end (void)
199{
200 if (annotation_level == 2)
201 printf_filtered (("\n\032\032breakpoints-table-end\n"));
202}
203
204void
205annotate_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
226void
227annotate_new_thread (void)
228{
229 if (annotation_level > 1)
230 {
231 printf_unfiltered (("\n\032\032new-thread\n"));
232 }
233}
234
235void
236annotate_thread_changed (void)
237{
238 if (annotation_level > 1)
239 {
240 printf_unfiltered (("\n\032\032thread-changed\n"));
241 }
242}
243
244void
245annotate_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
255void
256annotate_field_name_end (void)
257{
258 if (annotation_level == 2)
259 printf_filtered (("\n\032\032field-name-end\n"));
260}
261
262void
263annotate_field_value (void)
264{
265 if (annotation_level == 2)
266 printf_filtered (("\n\032\032field-value\n"));
267}
268
269void
270annotate_field_end (void)
271{
272 if (annotation_level == 2)
273 printf_filtered (("\n\032\032field-end\n"));
274}
275\f
276void
277annotate_quit (void)
278{
279 if (annotation_level > 1)
280 printf_filtered (("\n\032\032quit\n"));
281}
282
283void
284annotate_error (void)
285{
286 if (annotation_level > 1)
287 printf_filtered (("\n\032\032error\n"));
288}
289
290void
291annotate_error_begin (void)
292{
293 if (annotation_level > 1)
294 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
295}
296
297void
298annotate_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
308void
309annotate_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
319void
320annotate_value_history_value (void)
321{
322 if (annotation_level == 2)
323 printf_filtered (("\n\032\032value-history-value\n"));
324}
325
326void
327annotate_value_history_end (void)
328{
329 if (annotation_level == 2)
330 printf_filtered (("\n\032\032value-history-end\n"));
331}
332
333void
334annotate_value_end (void)
335{
336 if (annotation_level == 2)
337 printf_filtered (("\n\032\032value-end\n"));
338}
339
340void
341annotate_display_begin (void)
342{
343 if (annotation_level == 2)
344 printf_filtered (("\n\032\032display-begin\n"));
345}
346
347void
348annotate_display_number_end (void)
349{
350 if (annotation_level == 2)
351 printf_filtered (("\n\032\032display-number-end\n"));
352}
353
354void
355annotate_display_format (void)
356{
357 if (annotation_level == 2)
358 printf_filtered (("\n\032\032display-format\n"));
359}
360
361void
362annotate_display_expression (void)
363{
364 if (annotation_level == 2)
365 printf_filtered (("\n\032\032display-expression\n"));
366}
367
368void
369annotate_display_expression_end (void)
370{
371 if (annotation_level == 2)
372 printf_filtered (("\n\032\032display-expression-end\n"));
373}
374
375void
376annotate_display_value (void)
377{
378 if (annotation_level == 2)
379 printf_filtered (("\n\032\032display-value\n"));
380}
381
382void
383annotate_display_end (void)
384{
385 if (annotation_level == 2)
386 printf_filtered (("\n\032\032display-end\n"));
387}
388
389void
390annotate_arg_begin (void)
391{
392 if (annotation_level == 2)
393 printf_filtered (("\n\032\032arg-begin\n"));
394}
395
396void
397annotate_arg_name_end (void)
398{
399 if (annotation_level == 2)
400 printf_filtered (("\n\032\032arg-name-end\n"));
401}
402
403void
404annotate_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
414void
415annotate_arg_end (void)
416{
417 if (annotation_level == 2)
418 printf_filtered (("\n\032\032arg-end\n"));
419}
420
421void
422annotate_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
434void
435annotate_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
442void
443annotate_function_call (void)
444{
445 if (annotation_level == 2)
446 printf_filtered (("\n\032\032function-call\n"));
447}
448
449void
450annotate_signal_handler_caller (void)
451{
452 if (annotation_level == 2)
453 printf_filtered (("\n\032\032signal-handler-caller\n"));
454}
455
456void
457annotate_frame_address (void)
458{
459 if (annotation_level == 2)
460 printf_filtered (("\n\032\032frame-address\n"));
461}
462
463void
464annotate_frame_address_end (void)
465{
466 if (annotation_level == 2)
467 printf_filtered (("\n\032\032frame-address-end\n"));
468}
469
470void
471annotate_frame_function_name (void)
472{
473 if (annotation_level == 2)
474 printf_filtered (("\n\032\032frame-function-name\n"));
475}
476
477void
478annotate_frame_args (void)
479{
480 if (annotation_level == 2)
481 printf_filtered (("\n\032\032frame-args\n"));
482}
483
484void
485annotate_frame_source_begin (void)
486{
487 if (annotation_level == 2)
488 printf_filtered (("\n\032\032frame-source-begin\n"));
489}
490
491void
492annotate_frame_source_file (void)
493{
494 if (annotation_level == 2)
495 printf_filtered (("\n\032\032frame-source-file\n"));
496}
497
498void
499annotate_frame_source_file_end (void)
500{
501 if (annotation_level == 2)
502 printf_filtered (("\n\032\032frame-source-file-end\n"));
503}
504
505void
506annotate_frame_source_line (void)
507{
508 if (annotation_level == 2)
509 printf_filtered (("\n\032\032frame-source-line\n"));
510}
511
512void
513annotate_frame_source_end (void)
514{
515 if (annotation_level == 2)
516 printf_filtered (("\n\032\032frame-source-end\n"));
517}
518
519void
520annotate_frame_where (void)
521{
522 if (annotation_level == 2)
523 printf_filtered (("\n\032\032frame-where\n"));
524}
525
526void
527annotate_frame_end (void)
528{
529 if (annotation_level == 2)
530 printf_filtered (("\n\032\032frame-end\n"));
531}
532\f
533void
534annotate_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
544void
545annotate_elt_rep (unsigned int repcount)
546{
547 if (annotation_level == 2)
548 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
549}
550
551void
552annotate_elt_rep_end (void)
553{
554 if (annotation_level == 2)
555 printf_filtered (("\n\032\032elt-rep-end\n"));
556}
557
558void
559annotate_elt (void)
560{
561 if (annotation_level == 2)
562 printf_filtered (("\n\032\032elt\n"));
563}
564
565void
566annotate_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
576void
577annotate_display_prompt (void)
578{
579 frames_invalid_emitted = 0;
580 breakpoints_invalid_emitted = 0;
581}
582
583static void
584breakpoint_changed (struct breakpoint *b)
585{
586 if (b->number <= 0)
587 return;
588
589 annotate_breakpoints_invalid ();
590}
591
592void
593_initialize_annotate (void)
594{
595 gdb::observers::breakpoint_created.attach (breakpoint_changed);
596 gdb::observers::breakpoint_deleted.attach (breakpoint_changed);
597 gdb::observers::breakpoint_modified.attach (breakpoint_changed);
598}
This page took 0.023561 seconds and 4 git commands to generate.