Replace SYMBOLIC_BIND with SYMBOL_REFERENCES_LOCAL
[deliverable/binutils-gdb.git] / gdb / annotate.c
... / ...
CommitLineData
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\f
29
30/* Prototypes for local functions. */
31
32extern void _initialize_annotate (void);
33
34static void print_value_flags (struct type *);
35
36static void breakpoint_changed (struct breakpoint *b);
37
38
39void (*deprecated_annotate_signalled_hook) (void);
40void (*deprecated_annotate_signal_hook) (void);
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. */
46static int frames_invalid_emitted;
47static int breakpoints_invalid_emitted;
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
53static int
54async_background_execution_p (void)
55{
56 return (target_can_async_p () && !sync_execution);
57}
58
59static void
60print_value_flags (struct type *t)
61{
62 if (can_dereference (t))
63 printf_filtered (("*"));
64 else
65 printf_filtered (("-"));
66}
67
68static void
69annotate_breakpoints_invalid (void)
70{
71 if (annotation_level == 2
72 && (!breakpoints_invalid_emitted
73 || async_background_execution_p ()))
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
79 target_terminal_ours_for_output ();
80
81 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
82
83 if (was_inferior)
84 target_terminal_inferior ();
85
86 breakpoints_invalid_emitted = 1;
87 }
88}
89
90void
91annotate_breakpoint (int num)
92{
93 if (annotation_level > 1)
94 printf_filtered (("\n\032\032breakpoint %d\n"), num);
95}
96
97void
98annotate_catchpoint (int num)
99{
100 if (annotation_level > 1)
101 printf_filtered (("\n\032\032catchpoint %d\n"), num);
102}
103
104void
105annotate_watchpoint (int num)
106{
107 if (annotation_level > 1)
108 printf_filtered (("\n\032\032watchpoint %d\n"), num);
109}
110
111void
112annotate_starting (void)
113{
114 if (annotation_level > 1)
115 printf_filtered (("\n\032\032starting\n"));
116}
117
118void
119annotate_stopped (void)
120{
121 if (annotation_level > 1)
122 printf_filtered (("\n\032\032stopped\n"));
123}
124
125void
126annotate_exited (int exitstatus)
127{
128 if (annotation_level > 1)
129 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
130}
131
132void
133annotate_signalled (void)
134{
135 if (deprecated_annotate_signalled_hook)
136 deprecated_annotate_signalled_hook ();
137
138 if (annotation_level > 1)
139 printf_filtered (("\n\032\032signalled\n"));
140}
141
142void
143annotate_signal_name (void)
144{
145 if (annotation_level == 2)
146 printf_filtered (("\n\032\032signal-name\n"));
147}
148
149void
150annotate_signal_name_end (void)
151{
152 if (annotation_level == 2)
153 printf_filtered (("\n\032\032signal-name-end\n"));
154}
155
156void
157annotate_signal_string (void)
158{
159 if (annotation_level == 2)
160 printf_filtered (("\n\032\032signal-string\n"));
161}
162
163void
164annotate_signal_string_end (void)
165{
166 if (annotation_level == 2)
167 printf_filtered (("\n\032\032signal-string-end\n"));
168}
169
170void
171annotate_signal (void)
172{
173 if (deprecated_annotate_signal_hook)
174 deprecated_annotate_signal_hook ();
175
176 if (annotation_level > 1)
177 printf_filtered (("\n\032\032signal\n"));
178}
179\f
180void
181annotate_breakpoints_headers (void)
182{
183 if (annotation_level == 2)
184 printf_filtered (("\n\032\032breakpoints-headers\n"));
185}
186
187void
188annotate_field (int num)
189{
190 if (annotation_level == 2)
191 printf_filtered (("\n\032\032field %d\n"), num);
192}
193
194void
195annotate_breakpoints_table (void)
196{
197 if (annotation_level == 2)
198 printf_filtered (("\n\032\032breakpoints-table\n"));
199}
200
201void
202annotate_record (void)
203{
204 if (annotation_level == 2)
205 printf_filtered (("\n\032\032record\n"));
206}
207
208void
209annotate_breakpoints_table_end (void)
210{
211 if (annotation_level == 2)
212 printf_filtered (("\n\032\032breakpoints-table-end\n"));
213}
214
215void
216annotate_frames_invalid (void)
217{
218 if (annotation_level == 2
219 && (!frames_invalid_emitted
220 || async_background_execution_p ()))
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
226 target_terminal_ours_for_output ();
227
228 printf_unfiltered (("\n\032\032frames-invalid\n"));
229
230 if (was_inferior)
231 target_terminal_inferior ();
232
233 frames_invalid_emitted = 1;
234 }
235}
236
237void
238annotate_new_thread (void)
239{
240 if (annotation_level > 1)
241 {
242 printf_unfiltered (("\n\032\032new-thread\n"));
243 }
244}
245
246void
247annotate_thread_changed (void)
248{
249 if (annotation_level > 1)
250 {
251 printf_unfiltered (("\n\032\032thread-changed\n"));
252 }
253}
254
255void
256annotate_field_begin (struct type *type)
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
266void
267annotate_field_name_end (void)
268{
269 if (annotation_level == 2)
270 printf_filtered (("\n\032\032field-name-end\n"));
271}
272
273void
274annotate_field_value (void)
275{
276 if (annotation_level == 2)
277 printf_filtered (("\n\032\032field-value\n"));
278}
279
280void
281annotate_field_end (void)
282{
283 if (annotation_level == 2)
284 printf_filtered (("\n\032\032field-end\n"));
285}
286\f
287void
288annotate_quit (void)
289{
290 if (annotation_level > 1)
291 printf_filtered (("\n\032\032quit\n"));
292}
293
294void
295annotate_error (void)
296{
297 if (annotation_level > 1)
298 printf_filtered (("\n\032\032error\n"));
299}
300
301void
302annotate_error_begin (void)
303{
304 if (annotation_level > 1)
305 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
306}
307
308void
309annotate_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
319void
320annotate_value_begin (struct type *type)
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
330void
331annotate_value_history_value (void)
332{
333 if (annotation_level == 2)
334 printf_filtered (("\n\032\032value-history-value\n"));
335}
336
337void
338annotate_value_history_end (void)
339{
340 if (annotation_level == 2)
341 printf_filtered (("\n\032\032value-history-end\n"));
342}
343
344void
345annotate_value_end (void)
346{
347 if (annotation_level == 2)
348 printf_filtered (("\n\032\032value-end\n"));
349}
350
351void
352annotate_display_begin (void)
353{
354 if (annotation_level == 2)
355 printf_filtered (("\n\032\032display-begin\n"));
356}
357
358void
359annotate_display_number_end (void)
360{
361 if (annotation_level == 2)
362 printf_filtered (("\n\032\032display-number-end\n"));
363}
364
365void
366annotate_display_format (void)
367{
368 if (annotation_level == 2)
369 printf_filtered (("\n\032\032display-format\n"));
370}
371
372void
373annotate_display_expression (void)
374{
375 if (annotation_level == 2)
376 printf_filtered (("\n\032\032display-expression\n"));
377}
378
379void
380annotate_display_expression_end (void)
381{
382 if (annotation_level == 2)
383 printf_filtered (("\n\032\032display-expression-end\n"));
384}
385
386void
387annotate_display_value (void)
388{
389 if (annotation_level == 2)
390 printf_filtered (("\n\032\032display-value\n"));
391}
392
393void
394annotate_display_end (void)
395{
396 if (annotation_level == 2)
397 printf_filtered (("\n\032\032display-end\n"));
398}
399
400void
401annotate_arg_begin (void)
402{
403 if (annotation_level == 2)
404 printf_filtered (("\n\032\032arg-begin\n"));
405}
406
407void
408annotate_arg_name_end (void)
409{
410 if (annotation_level == 2)
411 printf_filtered (("\n\032\032arg-name-end\n"));
412}
413
414void
415annotate_arg_value (struct type *type)
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
425void
426annotate_arg_end (void)
427{
428 if (annotation_level == 2)
429 printf_filtered (("\n\032\032arg-end\n"));
430}
431
432void
433annotate_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
445void
446annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
447{
448 if (annotation_level > 1)
449 printf_filtered (("\n\032\032frame-begin %d %s\n"),
450 level, paddress (gdbarch, pc));
451}
452
453void
454annotate_function_call (void)
455{
456 if (annotation_level == 2)
457 printf_filtered (("\n\032\032function-call\n"));
458}
459
460void
461annotate_signal_handler_caller (void)
462{
463 if (annotation_level == 2)
464 printf_filtered (("\n\032\032signal-handler-caller\n"));
465}
466
467void
468annotate_frame_address (void)
469{
470 if (annotation_level == 2)
471 printf_filtered (("\n\032\032frame-address\n"));
472}
473
474void
475annotate_frame_address_end (void)
476{
477 if (annotation_level == 2)
478 printf_filtered (("\n\032\032frame-address-end\n"));
479}
480
481void
482annotate_frame_function_name (void)
483{
484 if (annotation_level == 2)
485 printf_filtered (("\n\032\032frame-function-name\n"));
486}
487
488void
489annotate_frame_args (void)
490{
491 if (annotation_level == 2)
492 printf_filtered (("\n\032\032frame-args\n"));
493}
494
495void
496annotate_frame_source_begin (void)
497{
498 if (annotation_level == 2)
499 printf_filtered (("\n\032\032frame-source-begin\n"));
500}
501
502void
503annotate_frame_source_file (void)
504{
505 if (annotation_level == 2)
506 printf_filtered (("\n\032\032frame-source-file\n"));
507}
508
509void
510annotate_frame_source_file_end (void)
511{
512 if (annotation_level == 2)
513 printf_filtered (("\n\032\032frame-source-file-end\n"));
514}
515
516void
517annotate_frame_source_line (void)
518{
519 if (annotation_level == 2)
520 printf_filtered (("\n\032\032frame-source-line\n"));
521}
522
523void
524annotate_frame_source_end (void)
525{
526 if (annotation_level == 2)
527 printf_filtered (("\n\032\032frame-source-end\n"));
528}
529
530void
531annotate_frame_where (void)
532{
533 if (annotation_level == 2)
534 printf_filtered (("\n\032\032frame-where\n"));
535}
536
537void
538annotate_frame_end (void)
539{
540 if (annotation_level == 2)
541 printf_filtered (("\n\032\032frame-end\n"));
542}
543\f
544void
545annotate_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
555void
556annotate_elt_rep (unsigned int repcount)
557{
558 if (annotation_level == 2)
559 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
560}
561
562void
563annotate_elt_rep_end (void)
564{
565 if (annotation_level == 2)
566 printf_filtered (("\n\032\032elt-rep-end\n"));
567}
568
569void
570annotate_elt (void)
571{
572 if (annotation_level == 2)
573 printf_filtered (("\n\032\032elt\n"));
574}
575
576void
577annotate_array_section_end (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
587void
588annotate_display_prompt (void)
589{
590 frames_invalid_emitted = 0;
591 breakpoints_invalid_emitted = 0;
592}
593
594static void
595breakpoint_changed (struct breakpoint *b)
596{
597 if (b->number <= 0)
598 return;
599
600 annotate_breakpoints_invalid ();
601}
602
603void
604_initialize_annotate (void)
605{
606 observer_attach_breakpoint_created (breakpoint_changed);
607 observer_attach_breakpoint_deleted (breakpoint_changed);
608 observer_attach_breakpoint_modified (breakpoint_changed);
609}
This page took 0.029144 seconds and 4 git commands to generate.