Update years in copyright notice for the GDB files.
[deliverable/binutils-gdb.git] / gdb / annotate.c
CommitLineData
c906108c 1/* Annotation routines for GDB.
28e7fd62 2 Copyright (C) 1986-2013 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"
c906108c
SS
26\f
27
0e2de366 28/* Prototypes for local functions. */
c906108c 29
a14ed312 30extern void _initialize_annotate (void);
392a587b 31
a14ed312 32static void print_value_flags (struct type *);
c906108c 33
8d3788bd 34static void breakpoint_changed (struct breakpoint *b);
7f4b89d1 35
c906108c 36
9a4105ab
AC
37void (*deprecated_annotate_signalled_hook) (void);
38void (*deprecated_annotate_signal_hook) (void);
c906108c 39
5c44784c
JM
40static int ignore_count_changed = 0;
41
c906108c 42static void
fba45db2 43print_value_flags (struct type *t)
c906108c
SS
44{
45 if (can_dereference (t))
a3f17187 46 printf_filtered (("*"));
c906108c 47 else
a3f17187 48 printf_filtered (("-"));
c906108c
SS
49}
50\f
51void
ef37bb07 52annotate_breakpoints_changed (void)
c906108c 53{
3ca42dbe 54 if (annotation_level == 2)
c906108c
SS
55 {
56 target_terminal_ours ();
a3f17187 57 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
5c44784c 58 if (ignore_count_changed)
0e2de366 59 ignore_count_changed = 0; /* Avoid multiple break annotations. */
c906108c
SS
60 }
61}
62
5c44784c
JM
63/* The GUI needs to be informed of ignore_count changes, but we don't
64 want to provide successive multiple breakpoints-invalid messages
65 that are all caused by the fact that the ignore count is changing
66 (which could keep the GUI very busy). One is enough, after the
0e2de366 67 target actually "stops". */
5c44784c
JM
68
69void
70annotate_ignore_count_change (void)
71{
72 if (annotation_level > 1)
73 ignore_count_changed = 1;
74}
75
c906108c 76void
fba45db2 77annotate_breakpoint (int num)
c906108c
SS
78{
79 if (annotation_level > 1)
a3f17187 80 printf_filtered (("\n\032\032breakpoint %d\n"), num);
c906108c
SS
81}
82
83void
fba45db2 84annotate_catchpoint (int num)
c906108c
SS
85{
86 if (annotation_level > 1)
a3f17187 87 printf_filtered (("\n\032\032catchpoint %d\n"), num);
c906108c
SS
88}
89
90void
fba45db2 91annotate_watchpoint (int num)
c906108c
SS
92{
93 if (annotation_level > 1)
a3f17187 94 printf_filtered (("\n\032\032watchpoint %d\n"), num);
c906108c
SS
95}
96
97void
fba45db2 98annotate_starting (void)
c906108c 99{
7f4b89d1
TT
100 if (annotation_level > 1)
101 printf_filtered (("\n\032\032starting\n"));
c906108c
SS
102}
103
104void
fba45db2 105annotate_stopped (void)
c906108c 106{
7f4b89d1
TT
107 if (annotation_level > 1)
108 printf_filtered (("\n\032\032stopped\n"));
5c44784c
JM
109 if (annotation_level > 1 && ignore_count_changed)
110 {
111 ignore_count_changed = 0;
ef37bb07 112 annotate_breakpoints_changed ();
5c44784c 113 }
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{
3ca42dbe 209 if (annotation_level == 2)
c906108c
SS
210 {
211 target_terminal_ours ();
a3f17187 212 printf_unfiltered (("\n\032\032frames-invalid\n"));
c906108c
SS
213 }
214}
215
d17d4947
NR
216void
217annotate_new_thread (void)
218{
219 if (annotation_level > 1)
220 {
221 printf_unfiltered (("\n\032\032new-thread\n"));
222 }
223}
224
b8fa951a
NR
225void
226annotate_thread_changed (void)
227{
228 if (annotation_level > 1)
229 {
230 printf_unfiltered (("\n\032\032thread-changed\n"));
231 }
232}
233
c906108c 234void
fba45db2 235annotate_field_begin (struct type *type)
c906108c 236{
e5c113a1 237 if (annotation_level == 2)
c906108c 238 {
a3f17187 239 printf_filtered (("\n\032\032field-begin "));
c906108c 240 print_value_flags (type);
a3f17187 241 printf_filtered (("\n"));
c906108c
SS
242 }
243}
244
245void
fba45db2 246annotate_field_name_end (void)
c906108c 247{
e5c113a1 248 if (annotation_level == 2)
a3f17187 249 printf_filtered (("\n\032\032field-name-end\n"));
c906108c
SS
250}
251
252void
fba45db2 253annotate_field_value (void)
c906108c 254{
e5c113a1 255 if (annotation_level == 2)
a3f17187 256 printf_filtered (("\n\032\032field-value\n"));
c906108c
SS
257}
258
259void
fba45db2 260annotate_field_end (void)
c906108c 261{
e5c113a1 262 if (annotation_level == 2)
a3f17187 263 printf_filtered (("\n\032\032field-end\n"));
c906108c
SS
264}
265\f
266void
fba45db2 267annotate_quit (void)
c906108c
SS
268{
269 if (annotation_level > 1)
a3f17187 270 printf_filtered (("\n\032\032quit\n"));
c906108c
SS
271}
272
273void
fba45db2 274annotate_error (void)
c906108c
SS
275{
276 if (annotation_level > 1)
a3f17187 277 printf_filtered (("\n\032\032error\n"));
c906108c
SS
278}
279
280void
fba45db2 281annotate_error_begin (void)
c906108c
SS
282{
283 if (annotation_level > 1)
284 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
285}
286
287void
fba45db2 288annotate_value_history_begin (int histindex, struct type *type)
c906108c 289{
e5c113a1 290 if (annotation_level == 2)
c906108c 291 {
a3f17187 292 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
c906108c 293 print_value_flags (type);
a3f17187 294 printf_filtered (("\n"));
c906108c
SS
295 }
296}
297
298void
fba45db2 299annotate_value_begin (struct type *type)
c906108c 300{
e5c113a1 301 if (annotation_level == 2)
c906108c 302 {
a3f17187 303 printf_filtered (("\n\032\032value-begin "));
c906108c 304 print_value_flags (type);
a3f17187 305 printf_filtered (("\n"));
c906108c
SS
306 }
307}
308
309void
fba45db2 310annotate_value_history_value (void)
c906108c 311{
e5c113a1 312 if (annotation_level == 2)
a3f17187 313 printf_filtered (("\n\032\032value-history-value\n"));
c906108c
SS
314}
315
316void
fba45db2 317annotate_value_history_end (void)
c906108c 318{
e5c113a1 319 if (annotation_level == 2)
a3f17187 320 printf_filtered (("\n\032\032value-history-end\n"));
c906108c
SS
321}
322
323void
fba45db2 324annotate_value_end (void)
c906108c 325{
e5c113a1 326 if (annotation_level == 2)
a3f17187 327 printf_filtered (("\n\032\032value-end\n"));
c906108c
SS
328}
329
330void
fba45db2 331annotate_display_begin (void)
c906108c 332{
e5c113a1 333 if (annotation_level == 2)
a3f17187 334 printf_filtered (("\n\032\032display-begin\n"));
c906108c
SS
335}
336
337void
fba45db2 338annotate_display_number_end (void)
c906108c 339{
e5c113a1 340 if (annotation_level == 2)
a3f17187 341 printf_filtered (("\n\032\032display-number-end\n"));
c906108c
SS
342}
343
344void
fba45db2 345annotate_display_format (void)
c906108c 346{
e5c113a1 347 if (annotation_level == 2)
a3f17187 348 printf_filtered (("\n\032\032display-format\n"));
c906108c
SS
349}
350
351void
fba45db2 352annotate_display_expression (void)
c906108c 353{
e5c113a1 354 if (annotation_level == 2)
a3f17187 355 printf_filtered (("\n\032\032display-expression\n"));
c906108c
SS
356}
357
358void
fba45db2 359annotate_display_expression_end (void)
c906108c 360{
e5c113a1 361 if (annotation_level == 2)
a3f17187 362 printf_filtered (("\n\032\032display-expression-end\n"));
c906108c
SS
363}
364
365void
fba45db2 366annotate_display_value (void)
c906108c 367{
e5c113a1 368 if (annotation_level == 2)
a3f17187 369 printf_filtered (("\n\032\032display-value\n"));
c906108c
SS
370}
371
372void
fba45db2 373annotate_display_end (void)
c906108c 374{
e5c113a1 375 if (annotation_level == 2)
a3f17187 376 printf_filtered (("\n\032\032display-end\n"));
c906108c
SS
377}
378
379void
fba45db2 380annotate_arg_begin (void)
c906108c 381{
e5c113a1 382 if (annotation_level == 2)
a3f17187 383 printf_filtered (("\n\032\032arg-begin\n"));
c906108c
SS
384}
385
386void
fba45db2 387annotate_arg_name_end (void)
c906108c 388{
e5c113a1 389 if (annotation_level == 2)
a3f17187 390 printf_filtered (("\n\032\032arg-name-end\n"));
c906108c
SS
391}
392
393void
fba45db2 394annotate_arg_value (struct type *type)
c906108c 395{
e5c113a1 396 if (annotation_level == 2)
c906108c 397 {
a3f17187 398 printf_filtered (("\n\032\032arg-value "));
c906108c 399 print_value_flags (type);
a3f17187 400 printf_filtered (("\n"));
c906108c
SS
401 }
402}
403
404void
fba45db2 405annotate_arg_end (void)
c906108c 406{
e5c113a1 407 if (annotation_level == 2)
a3f17187 408 printf_filtered (("\n\032\032arg-end\n"));
c906108c
SS
409}
410
411void
5af949e3
UW
412annotate_source (char *filename, int line, int character, int mid,
413 struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c
SS
414{
415 if (annotation_level > 1)
a3f17187 416 printf_filtered (("\n\032\032source "));
c906108c 417 else
a3f17187 418 printf_filtered (("\032\032"));
c906108c 419
50ee7535 420 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
5af949e3 421 mid ? "middle" : "beg", paddress (gdbarch, pc));
c906108c
SS
422}
423
424void
5af949e3 425annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c 426{
24ca4723 427 if (annotation_level > 1)
5af949e3
UW
428 printf_filtered (("\n\032\032frame-begin %d %s\n"),
429 level, paddress (gdbarch, pc));
c906108c
SS
430}
431
432void
fba45db2 433annotate_function_call (void)
c906108c 434{
e5c113a1 435 if (annotation_level == 2)
a3f17187 436 printf_filtered (("\n\032\032function-call\n"));
c906108c
SS
437}
438
439void
fba45db2 440annotate_signal_handler_caller (void)
c906108c 441{
e5c113a1 442 if (annotation_level == 2)
a3f17187 443 printf_filtered (("\n\032\032signal-handler-caller\n"));
c906108c
SS
444}
445
446void
fba45db2 447annotate_frame_address (void)
c906108c 448{
e5c113a1 449 if (annotation_level == 2)
a3f17187 450 printf_filtered (("\n\032\032frame-address\n"));
c906108c
SS
451}
452
453void
fba45db2 454annotate_frame_address_end (void)
c906108c 455{
e5c113a1 456 if (annotation_level == 2)
a3f17187 457 printf_filtered (("\n\032\032frame-address-end\n"));
c906108c
SS
458}
459
460void
fba45db2 461annotate_frame_function_name (void)
c906108c 462{
e5c113a1 463 if (annotation_level == 2)
a3f17187 464 printf_filtered (("\n\032\032frame-function-name\n"));
c906108c
SS
465}
466
467void
fba45db2 468annotate_frame_args (void)
c906108c 469{
e5c113a1 470 if (annotation_level == 2)
a3f17187 471 printf_filtered (("\n\032\032frame-args\n"));
c906108c
SS
472}
473
474void
fba45db2 475annotate_frame_source_begin (void)
c906108c 476{
e5c113a1 477 if (annotation_level == 2)
a3f17187 478 printf_filtered (("\n\032\032frame-source-begin\n"));
c906108c
SS
479}
480
481void
fba45db2 482annotate_frame_source_file (void)
c906108c 483{
e5c113a1 484 if (annotation_level == 2)
a3f17187 485 printf_filtered (("\n\032\032frame-source-file\n"));
c906108c
SS
486}
487
488void
fba45db2 489annotate_frame_source_file_end (void)
c906108c 490{
e5c113a1 491 if (annotation_level == 2)
a3f17187 492 printf_filtered (("\n\032\032frame-source-file-end\n"));
c906108c
SS
493}
494
495void
fba45db2 496annotate_frame_source_line (void)
c906108c 497{
e5c113a1 498 if (annotation_level == 2)
a3f17187 499 printf_filtered (("\n\032\032frame-source-line\n"));
c906108c
SS
500}
501
502void
fba45db2 503annotate_frame_source_end (void)
c906108c 504{
e5c113a1 505 if (annotation_level == 2)
a3f17187 506 printf_filtered (("\n\032\032frame-source-end\n"));
c906108c
SS
507}
508
509void
fba45db2 510annotate_frame_where (void)
c906108c 511{
e5c113a1 512 if (annotation_level == 2)
a3f17187 513 printf_filtered (("\n\032\032frame-where\n"));
c906108c
SS
514}
515
516void
fba45db2 517annotate_frame_end (void)
c906108c 518{
e5c113a1 519 if (annotation_level == 2)
a3f17187 520 printf_filtered (("\n\032\032frame-end\n"));
c906108c
SS
521}
522\f
523void
917793af 524annotate_array_section_begin (int idx, struct type *elttype)
c906108c 525{
e5c113a1 526 if (annotation_level == 2)
c906108c 527 {
917793af 528 printf_filtered (("\n\032\032array-section-begin %d "), idx);
c906108c 529 print_value_flags (elttype);
a3f17187 530 printf_filtered (("\n"));
c906108c
SS
531 }
532}
533
534void
fba45db2 535annotate_elt_rep (unsigned int repcount)
c906108c 536{
e5c113a1 537 if (annotation_level == 2)
a3f17187 538 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
c906108c
SS
539}
540
541void
fba45db2 542annotate_elt_rep_end (void)
c906108c 543{
e5c113a1 544 if (annotation_level == 2)
a3f17187 545 printf_filtered (("\n\032\032elt-rep-end\n"));
c906108c
SS
546}
547
548void
fba45db2 549annotate_elt (void)
c906108c 550{
e5c113a1 551 if (annotation_level == 2)
a3f17187 552 printf_filtered (("\n\032\032elt\n"));
c906108c
SS
553}
554
555void
fba45db2 556annotate_array_section_end (void)
c906108c 557{
e5c113a1 558 if (annotation_level == 2)
a3f17187 559 printf_filtered (("\n\032\032array-section-end\n"));
c906108c
SS
560}
561
562static void
8d3788bd 563breakpoint_changed (struct breakpoint *b)
c906108c 564{
ef37bb07 565 annotate_breakpoints_changed ();
c906108c
SS
566}
567
568void
fba45db2 569_initialize_annotate (void)
c906108c 570{
3ca42dbe 571 if (annotation_level == 2)
c906108c 572 {
7f4b89d1
TT
573 observer_attach_breakpoint_deleted (breakpoint_changed);
574 observer_attach_breakpoint_modified (breakpoint_changed);
c906108c
SS
575 }
576}
This page took 0.954365 seconds and 4 git commands to generate.