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