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