Change dwarf2_frame_state_reg_info::reg to be std::vector
[deliverable/binutils-gdb.git] / gdb / annotate.c
CommitLineData
c906108c 1/* Annotation routines for GDB.
e2882c85 2 Copyright (C) 1986-2018 Free Software Foundation, Inc.
c906108c 3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
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
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
c5aa993b 9 (at your option) any later version.
c906108c 10
c5aa993b
JM
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.
c906108c 15
c5aa993b 16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
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"
76727919 25#include "observable.h"
bd00c694 26#include "inferior.h"
45741a9c 27#include "infrun.h"
3b12939d 28#include "top.h"
c906108c
SS
29\f
30
0e2de366 31/* Prototypes for local functions. */
c906108c 32
a14ed312 33static void print_value_flags (struct type *);
c906108c 34
8d3788bd 35static void breakpoint_changed (struct breakpoint *b);
7f4b89d1 36
c906108c 37
9a4105ab
AC
38void (*deprecated_annotate_signalled_hook) (void);
39void (*deprecated_annotate_signal_hook) (void);
c906108c 40
bd00c694
PA
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
c906108c 48static void
fba45db2 49print_value_flags (struct type *t)
c906108c
SS
50{
51 if (can_dereference (t))
a3f17187 52 printf_filtered (("*"));
c906108c 53 else
a3f17187 54 printf_filtered (("-"));
c906108c 55}
9c97429f
PA
56
57static void
58annotate_breakpoints_invalid (void)
c906108c 59{
bd00c694
PA
60 if (annotation_level == 2
61 && (!breakpoints_invalid_emitted
3b12939d 62 || current_ui->prompt_state != PROMPT_BLOCKED))
c906108c 63 {
6fdebc3d
PA
64 /* If the inferior owns the terminal (e.g., we're resuming),
65 make sure to leave with the inferior still owning it. */
223ffa71 66 int was_inferior = target_terminal::is_inferior ();
6fdebc3d 67
223ffa71 68 target_terminal::ours_for_output ();
6fdebc3d 69
a3f17187 70 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
6fdebc3d
PA
71
72 if (was_inferior)
223ffa71 73 target_terminal::inferior ();
6fdebc3d 74
bd00c694 75 breakpoints_invalid_emitted = 1;
c906108c
SS
76 }
77}
78
79void
fba45db2 80annotate_breakpoint (int num)
c906108c
SS
81{
82 if (annotation_level > 1)
a3f17187 83 printf_filtered (("\n\032\032breakpoint %d\n"), num);
c906108c
SS
84}
85
86void
fba45db2 87annotate_catchpoint (int num)
c906108c
SS
88{
89 if (annotation_level > 1)
a3f17187 90 printf_filtered (("\n\032\032catchpoint %d\n"), num);
c906108c
SS
91}
92
93void
fba45db2 94annotate_watchpoint (int num)
c906108c
SS
95{
96 if (annotation_level > 1)
a3f17187 97 printf_filtered (("\n\032\032watchpoint %d\n"), num);
c906108c
SS
98}
99
100void
fba45db2 101annotate_starting (void)
c906108c 102{
7f4b89d1
TT
103 if (annotation_level > 1)
104 printf_filtered (("\n\032\032starting\n"));
c906108c
SS
105}
106
107void
fba45db2 108annotate_stopped (void)
c906108c 109{
7f4b89d1
TT
110 if (annotation_level > 1)
111 printf_filtered (("\n\032\032stopped\n"));
c906108c
SS
112}
113
114void
fba45db2 115annotate_exited (int exitstatus)
c906108c 116{
7f4b89d1
TT
117 if (annotation_level > 1)
118 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
c906108c
SS
119}
120
121void
fba45db2 122annotate_signalled (void)
c906108c 123{
9a4105ab
AC
124 if (deprecated_annotate_signalled_hook)
125 deprecated_annotate_signalled_hook ();
c906108c
SS
126
127 if (annotation_level > 1)
a3f17187 128 printf_filtered (("\n\032\032signalled\n"));
c906108c
SS
129}
130
131void
fba45db2 132annotate_signal_name (void)
c906108c 133{
e5c113a1 134 if (annotation_level == 2)
a3f17187 135 printf_filtered (("\n\032\032signal-name\n"));
c906108c
SS
136}
137
138void
fba45db2 139annotate_signal_name_end (void)
c906108c 140{
e5c113a1 141 if (annotation_level == 2)
a3f17187 142 printf_filtered (("\n\032\032signal-name-end\n"));
c906108c
SS
143}
144
145void
fba45db2 146annotate_signal_string (void)
c906108c 147{
e5c113a1 148 if (annotation_level == 2)
a3f17187 149 printf_filtered (("\n\032\032signal-string\n"));
c906108c
SS
150}
151
152void
fba45db2 153annotate_signal_string_end (void)
c906108c 154{
e5c113a1 155 if (annotation_level == 2)
a3f17187 156 printf_filtered (("\n\032\032signal-string-end\n"));
c906108c
SS
157}
158
159void
fba45db2 160annotate_signal (void)
c906108c 161{
9a4105ab
AC
162 if (deprecated_annotate_signal_hook)
163 deprecated_annotate_signal_hook ();
7a292a7a 164
c906108c 165 if (annotation_level > 1)
a3f17187 166 printf_filtered (("\n\032\032signal\n"));
c906108c
SS
167}
168\f
169void
fba45db2 170annotate_breakpoints_headers (void)
c906108c 171{
e5c113a1 172 if (annotation_level == 2)
a3f17187 173 printf_filtered (("\n\032\032breakpoints-headers\n"));
c906108c
SS
174}
175
176void
fba45db2 177annotate_field (int num)
c906108c 178{
e5c113a1 179 if (annotation_level == 2)
a3f17187 180 printf_filtered (("\n\032\032field %d\n"), num);
c906108c
SS
181}
182
183void
fba45db2 184annotate_breakpoints_table (void)
c906108c 185{
e5c113a1 186 if (annotation_level == 2)
a3f17187 187 printf_filtered (("\n\032\032breakpoints-table\n"));
c906108c
SS
188}
189
190void
fba45db2 191annotate_record (void)
c906108c 192{
e5c113a1 193 if (annotation_level == 2)
a3f17187 194 printf_filtered (("\n\032\032record\n"));
c906108c
SS
195}
196
197void
fba45db2 198annotate_breakpoints_table_end (void)
c906108c 199{
e5c113a1 200 if (annotation_level == 2)
a3f17187 201 printf_filtered (("\n\032\032breakpoints-table-end\n"));
c906108c
SS
202}
203
204void
fba45db2 205annotate_frames_invalid (void)
c906108c 206{
bd00c694
PA
207 if (annotation_level == 2
208 && (!frames_invalid_emitted
3b12939d 209 || current_ui->prompt_state != PROMPT_BLOCKED))
c906108c 210 {
6fdebc3d
PA
211 /* If the inferior owns the terminal (e.g., we're resuming),
212 make sure to leave with the inferior still owning it. */
223ffa71 213 int was_inferior = target_terminal::is_inferior ();
6fdebc3d 214
223ffa71 215 target_terminal::ours_for_output ();
6fdebc3d 216
a3f17187 217 printf_unfiltered (("\n\032\032frames-invalid\n"));
6fdebc3d
PA
218
219 if (was_inferior)
223ffa71 220 target_terminal::inferior ();
6fdebc3d 221
bd00c694 222 frames_invalid_emitted = 1;
c906108c
SS
223 }
224}
225
d17d4947
NR
226void
227annotate_new_thread (void)
228{
229 if (annotation_level > 1)
230 {
231 printf_unfiltered (("\n\032\032new-thread\n"));
232 }
233}
234
b8fa951a
NR
235void
236annotate_thread_changed (void)
237{
238 if (annotation_level > 1)
239 {
240 printf_unfiltered (("\n\032\032thread-changed\n"));
241 }
242}
243
c906108c 244void
fba45db2 245annotate_field_begin (struct type *type)
c906108c 246{
e5c113a1 247 if (annotation_level == 2)
c906108c 248 {
a3f17187 249 printf_filtered (("\n\032\032field-begin "));
c906108c 250 print_value_flags (type);
a3f17187 251 printf_filtered (("\n"));
c906108c
SS
252 }
253}
254
255void
fba45db2 256annotate_field_name_end (void)
c906108c 257{
e5c113a1 258 if (annotation_level == 2)
a3f17187 259 printf_filtered (("\n\032\032field-name-end\n"));
c906108c
SS
260}
261
262void
fba45db2 263annotate_field_value (void)
c906108c 264{
e5c113a1 265 if (annotation_level == 2)
a3f17187 266 printf_filtered (("\n\032\032field-value\n"));
c906108c
SS
267}
268
269void
fba45db2 270annotate_field_end (void)
c906108c 271{
e5c113a1 272 if (annotation_level == 2)
a3f17187 273 printf_filtered (("\n\032\032field-end\n"));
c906108c
SS
274}
275\f
276void
fba45db2 277annotate_quit (void)
c906108c
SS
278{
279 if (annotation_level > 1)
a3f17187 280 printf_filtered (("\n\032\032quit\n"));
c906108c
SS
281}
282
283void
fba45db2 284annotate_error (void)
c906108c
SS
285{
286 if (annotation_level > 1)
a3f17187 287 printf_filtered (("\n\032\032error\n"));
c906108c
SS
288}
289
290void
fba45db2 291annotate_error_begin (void)
c906108c
SS
292{
293 if (annotation_level > 1)
294 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
295}
296
297void
fba45db2 298annotate_value_history_begin (int histindex, struct type *type)
c906108c 299{
e5c113a1 300 if (annotation_level == 2)
c906108c 301 {
a3f17187 302 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
c906108c 303 print_value_flags (type);
a3f17187 304 printf_filtered (("\n"));
c906108c
SS
305 }
306}
307
308void
fba45db2 309annotate_value_begin (struct type *type)
c906108c 310{
e5c113a1 311 if (annotation_level == 2)
c906108c 312 {
a3f17187 313 printf_filtered (("\n\032\032value-begin "));
c906108c 314 print_value_flags (type);
a3f17187 315 printf_filtered (("\n"));
c906108c
SS
316 }
317}
318
319void
fba45db2 320annotate_value_history_value (void)
c906108c 321{
e5c113a1 322 if (annotation_level == 2)
a3f17187 323 printf_filtered (("\n\032\032value-history-value\n"));
c906108c
SS
324}
325
326void
fba45db2 327annotate_value_history_end (void)
c906108c 328{
e5c113a1 329 if (annotation_level == 2)
a3f17187 330 printf_filtered (("\n\032\032value-history-end\n"));
c906108c
SS
331}
332
333void
fba45db2 334annotate_value_end (void)
c906108c 335{
e5c113a1 336 if (annotation_level == 2)
a3f17187 337 printf_filtered (("\n\032\032value-end\n"));
c906108c
SS
338}
339
340void
fba45db2 341annotate_display_begin (void)
c906108c 342{
e5c113a1 343 if (annotation_level == 2)
a3f17187 344 printf_filtered (("\n\032\032display-begin\n"));
c906108c
SS
345}
346
347void
fba45db2 348annotate_display_number_end (void)
c906108c 349{
e5c113a1 350 if (annotation_level == 2)
a3f17187 351 printf_filtered (("\n\032\032display-number-end\n"));
c906108c
SS
352}
353
354void
fba45db2 355annotate_display_format (void)
c906108c 356{
e5c113a1 357 if (annotation_level == 2)
a3f17187 358 printf_filtered (("\n\032\032display-format\n"));
c906108c
SS
359}
360
361void
fba45db2 362annotate_display_expression (void)
c906108c 363{
e5c113a1 364 if (annotation_level == 2)
a3f17187 365 printf_filtered (("\n\032\032display-expression\n"));
c906108c
SS
366}
367
368void
fba45db2 369annotate_display_expression_end (void)
c906108c 370{
e5c113a1 371 if (annotation_level == 2)
a3f17187 372 printf_filtered (("\n\032\032display-expression-end\n"));
c906108c
SS
373}
374
375void
fba45db2 376annotate_display_value (void)
c906108c 377{
e5c113a1 378 if (annotation_level == 2)
a3f17187 379 printf_filtered (("\n\032\032display-value\n"));
c906108c
SS
380}
381
382void
fba45db2 383annotate_display_end (void)
c906108c 384{
e5c113a1 385 if (annotation_level == 2)
a3f17187 386 printf_filtered (("\n\032\032display-end\n"));
c906108c
SS
387}
388
389void
fba45db2 390annotate_arg_begin (void)
c906108c 391{
e5c113a1 392 if (annotation_level == 2)
a3f17187 393 printf_filtered (("\n\032\032arg-begin\n"));
c906108c
SS
394}
395
396void
fba45db2 397annotate_arg_name_end (void)
c906108c 398{
e5c113a1 399 if (annotation_level == 2)
a3f17187 400 printf_filtered (("\n\032\032arg-name-end\n"));
c906108c
SS
401}
402
403void
fba45db2 404annotate_arg_value (struct type *type)
c906108c 405{
e5c113a1 406 if (annotation_level == 2)
c906108c 407 {
a3f17187 408 printf_filtered (("\n\032\032arg-value "));
c906108c 409 print_value_flags (type);
a3f17187 410 printf_filtered (("\n"));
c906108c
SS
411 }
412}
413
414void
fba45db2 415annotate_arg_end (void)
c906108c 416{
e5c113a1 417 if (annotation_level == 2)
a3f17187 418 printf_filtered (("\n\032\032arg-end\n"));
c906108c
SS
419}
420
421void
5af949e3
UW
422annotate_source (char *filename, int line, int character, int mid,
423 struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c
SS
424{
425 if (annotation_level > 1)
a3f17187 426 printf_filtered (("\n\032\032source "));
c906108c 427 else
a3f17187 428 printf_filtered (("\032\032"));
c906108c 429
50ee7535 430 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
5af949e3 431 mid ? "middle" : "beg", paddress (gdbarch, pc));
c906108c
SS
432}
433
434void
5af949e3 435annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c 436{
24ca4723 437 if (annotation_level > 1)
5af949e3
UW
438 printf_filtered (("\n\032\032frame-begin %d %s\n"),
439 level, paddress (gdbarch, pc));
c906108c
SS
440}
441
442void
fba45db2 443annotate_function_call (void)
c906108c 444{
e5c113a1 445 if (annotation_level == 2)
a3f17187 446 printf_filtered (("\n\032\032function-call\n"));
c906108c
SS
447}
448
449void
fba45db2 450annotate_signal_handler_caller (void)
c906108c 451{
e5c113a1 452 if (annotation_level == 2)
a3f17187 453 printf_filtered (("\n\032\032signal-handler-caller\n"));
c906108c
SS
454}
455
456void
fba45db2 457annotate_frame_address (void)
c906108c 458{
e5c113a1 459 if (annotation_level == 2)
a3f17187 460 printf_filtered (("\n\032\032frame-address\n"));
c906108c
SS
461}
462
463void
fba45db2 464annotate_frame_address_end (void)
c906108c 465{
e5c113a1 466 if (annotation_level == 2)
a3f17187 467 printf_filtered (("\n\032\032frame-address-end\n"));
c906108c
SS
468}
469
470void
fba45db2 471annotate_frame_function_name (void)
c906108c 472{
e5c113a1 473 if (annotation_level == 2)
a3f17187 474 printf_filtered (("\n\032\032frame-function-name\n"));
c906108c
SS
475}
476
477void
fba45db2 478annotate_frame_args (void)
c906108c 479{
e5c113a1 480 if (annotation_level == 2)
a3f17187 481 printf_filtered (("\n\032\032frame-args\n"));
c906108c
SS
482}
483
484void
fba45db2 485annotate_frame_source_begin (void)
c906108c 486{
e5c113a1 487 if (annotation_level == 2)
a3f17187 488 printf_filtered (("\n\032\032frame-source-begin\n"));
c906108c
SS
489}
490
491void
fba45db2 492annotate_frame_source_file (void)
c906108c 493{
e5c113a1 494 if (annotation_level == 2)
a3f17187 495 printf_filtered (("\n\032\032frame-source-file\n"));
c906108c
SS
496}
497
498void
fba45db2 499annotate_frame_source_file_end (void)
c906108c 500{
e5c113a1 501 if (annotation_level == 2)
a3f17187 502 printf_filtered (("\n\032\032frame-source-file-end\n"));
c906108c
SS
503}
504
505void
fba45db2 506annotate_frame_source_line (void)
c906108c 507{
e5c113a1 508 if (annotation_level == 2)
a3f17187 509 printf_filtered (("\n\032\032frame-source-line\n"));
c906108c
SS
510}
511
512void
fba45db2 513annotate_frame_source_end (void)
c906108c 514{
e5c113a1 515 if (annotation_level == 2)
a3f17187 516 printf_filtered (("\n\032\032frame-source-end\n"));
c906108c
SS
517}
518
519void
fba45db2 520annotate_frame_where (void)
c906108c 521{
e5c113a1 522 if (annotation_level == 2)
a3f17187 523 printf_filtered (("\n\032\032frame-where\n"));
c906108c
SS
524}
525
526void
fba45db2 527annotate_frame_end (void)
c906108c 528{
e5c113a1 529 if (annotation_level == 2)
a3f17187 530 printf_filtered (("\n\032\032frame-end\n"));
c906108c
SS
531}
532\f
533void
917793af 534annotate_array_section_begin (int idx, struct type *elttype)
c906108c 535{
e5c113a1 536 if (annotation_level == 2)
c906108c 537 {
917793af 538 printf_filtered (("\n\032\032array-section-begin %d "), idx);
c906108c 539 print_value_flags (elttype);
a3f17187 540 printf_filtered (("\n"));
c906108c
SS
541 }
542}
543
544void
fba45db2 545annotate_elt_rep (unsigned int repcount)
c906108c 546{
e5c113a1 547 if (annotation_level == 2)
a3f17187 548 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
c906108c
SS
549}
550
551void
fba45db2 552annotate_elt_rep_end (void)
c906108c 553{
e5c113a1 554 if (annotation_level == 2)
a3f17187 555 printf_filtered (("\n\032\032elt-rep-end\n"));
c906108c
SS
556}
557
558void
fba45db2 559annotate_elt (void)
c906108c 560{
e5c113a1 561 if (annotation_level == 2)
a3f17187 562 printf_filtered (("\n\032\032elt\n"));
c906108c
SS
563}
564
565void
fba45db2 566annotate_array_section_end (void)
c906108c 567{
e5c113a1 568 if (annotation_level == 2)
a3f17187 569 printf_filtered (("\n\032\032array-section-end\n"));
c906108c
SS
570}
571
bd00c694
PA
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
c906108c 583static void
8d3788bd 584breakpoint_changed (struct breakpoint *b)
c906108c 585{
0928e93d
PA
586 if (b->number <= 0)
587 return;
588
9c97429f 589 annotate_breakpoints_invalid ();
c906108c
SS
590}
591
592void
fba45db2 593_initialize_annotate (void)
c906108c 594{
76727919
TT
595 gdb::observers::breakpoint_created.attach (breakpoint_changed);
596 gdb::observers::breakpoint_deleted.attach (breakpoint_changed);
597 gdb::observers::breakpoint_modified.attach (breakpoint_changed);
c906108c 598}
This page took 1.387689 seconds and 4 git commands to generate.