*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / annotate.c
CommitLineData
c906108c 1/* Annotation routines for GDB.
197e01b6 2 Copyright (C) 1986, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999,
9b254dd1 3 2000, 2007, 2008 Free Software Foundation, Inc.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b 10 (at your option) any later version.
c906108c 11
c5aa993b
JM
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
c906108c 16
c5aa993b 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20#include "defs.h"
21#include "annotate.h"
22#include "value.h"
23#include "target.h"
24#include "gdbtypes.h"
25#include "breakpoint.h"
26\f
27
28/* Prototypes for local functions. */
29
a14ed312 30extern void _initialize_annotate (void);
392a587b 31
a14ed312 32static void print_value_flags (struct type *);
c906108c 33
a14ed312 34static void breakpoint_changed (struct breakpoint *);
c906108c 35
9a4105ab
AC
36void (*deprecated_annotate_starting_hook) (void);
37void (*deprecated_annotate_stopped_hook) (void);
38void (*deprecated_annotate_signalled_hook) (void);
39void (*deprecated_annotate_signal_hook) (void);
40void (*deprecated_annotate_exited_hook) (void);
c906108c 41
5c44784c
JM
42static int ignore_count_changed = 0;
43
c906108c 44static void
fba45db2 45print_value_flags (struct type *t)
c906108c
SS
46{
47 if (can_dereference (t))
a3f17187 48 printf_filtered (("*"));
c906108c 49 else
a3f17187 50 printf_filtered (("-"));
c906108c
SS
51}
52\f
53void
fba45db2 54breakpoints_changed (void)
c906108c 55{
3ca42dbe 56 if (annotation_level == 2)
c906108c
SS
57 {
58 target_terminal_ours ();
a3f17187 59 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
5c44784c
JM
60 if (ignore_count_changed)
61 ignore_count_changed = 0; /* Avoid multiple break annotations. */
c906108c
SS
62 }
63}
64
5c44784c
JM
65/* The GUI needs to be informed of ignore_count changes, but we don't
66 want to provide successive multiple breakpoints-invalid messages
67 that are all caused by the fact that the ignore count is changing
68 (which could keep the GUI very busy). One is enough, after the
69 target actually "stops". */
70
71void
72annotate_ignore_count_change (void)
73{
74 if (annotation_level > 1)
75 ignore_count_changed = 1;
76}
77
c906108c 78void
fba45db2 79annotate_breakpoint (int num)
c906108c
SS
80{
81 if (annotation_level > 1)
a3f17187 82 printf_filtered (("\n\032\032breakpoint %d\n"), num);
c906108c
SS
83}
84
85void
fba45db2 86annotate_catchpoint (int num)
c906108c
SS
87{
88 if (annotation_level > 1)
a3f17187 89 printf_filtered (("\n\032\032catchpoint %d\n"), num);
c906108c
SS
90}
91
92void
fba45db2 93annotate_watchpoint (int num)
c906108c
SS
94{
95 if (annotation_level > 1)
a3f17187 96 printf_filtered (("\n\032\032watchpoint %d\n"), num);
c906108c
SS
97}
98
99void
fba45db2 100annotate_starting (void)
c906108c
SS
101{
102
9a4105ab
AC
103 if (deprecated_annotate_starting_hook)
104 deprecated_annotate_starting_hook ();
c906108c
SS
105 else
106 {
107 if (annotation_level > 1)
c5aa993b 108 {
a3f17187 109 printf_filtered (("\n\032\032starting\n"));
c5aa993b 110 }
c906108c
SS
111 }
112}
113
114void
fba45db2 115annotate_stopped (void)
c906108c 116{
9a4105ab
AC
117 if (deprecated_annotate_stopped_hook)
118 deprecated_annotate_stopped_hook ();
c906108c
SS
119 else
120 {
121 if (annotation_level > 1)
a3f17187 122 printf_filtered (("\n\032\032stopped\n"));
c906108c 123 }
5c44784c
JM
124 if (annotation_level > 1 && ignore_count_changed)
125 {
126 ignore_count_changed = 0;
127 breakpoints_changed ();
128 }
c906108c
SS
129}
130
131void
fba45db2 132annotate_exited (int exitstatus)
c906108c 133{
9a4105ab
AC
134 if (deprecated_annotate_exited_hook)
135 deprecated_annotate_exited_hook ();
c906108c
SS
136 else
137 {
138 if (annotation_level > 1)
a3f17187 139 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
c906108c
SS
140 }
141}
142
143void
fba45db2 144annotate_signalled (void)
c906108c 145{
9a4105ab
AC
146 if (deprecated_annotate_signalled_hook)
147 deprecated_annotate_signalled_hook ();
c906108c
SS
148
149 if (annotation_level > 1)
a3f17187 150 printf_filtered (("\n\032\032signalled\n"));
c906108c
SS
151}
152
153void
fba45db2 154annotate_signal_name (void)
c906108c 155{
e5c113a1 156 if (annotation_level == 2)
a3f17187 157 printf_filtered (("\n\032\032signal-name\n"));
c906108c
SS
158}
159
160void
fba45db2 161annotate_signal_name_end (void)
c906108c 162{
e5c113a1 163 if (annotation_level == 2)
a3f17187 164 printf_filtered (("\n\032\032signal-name-end\n"));
c906108c
SS
165}
166
167void
fba45db2 168annotate_signal_string (void)
c906108c 169{
e5c113a1 170 if (annotation_level == 2)
a3f17187 171 printf_filtered (("\n\032\032signal-string\n"));
c906108c
SS
172}
173
174void
fba45db2 175annotate_signal_string_end (void)
c906108c 176{
e5c113a1 177 if (annotation_level == 2)
a3f17187 178 printf_filtered (("\n\032\032signal-string-end\n"));
c906108c
SS
179}
180
181void
fba45db2 182annotate_signal (void)
c906108c 183{
9a4105ab
AC
184 if (deprecated_annotate_signal_hook)
185 deprecated_annotate_signal_hook ();
7a292a7a 186
c906108c 187 if (annotation_level > 1)
a3f17187 188 printf_filtered (("\n\032\032signal\n"));
c906108c
SS
189}
190\f
191void
fba45db2 192annotate_breakpoints_headers (void)
c906108c 193{
e5c113a1 194 if (annotation_level == 2)
a3f17187 195 printf_filtered (("\n\032\032breakpoints-headers\n"));
c906108c
SS
196}
197
198void
fba45db2 199annotate_field (int num)
c906108c 200{
e5c113a1 201 if (annotation_level == 2)
a3f17187 202 printf_filtered (("\n\032\032field %d\n"), num);
c906108c
SS
203}
204
205void
fba45db2 206annotate_breakpoints_table (void)
c906108c 207{
e5c113a1 208 if (annotation_level == 2)
a3f17187 209 printf_filtered (("\n\032\032breakpoints-table\n"));
c906108c
SS
210}
211
212void
fba45db2 213annotate_record (void)
c906108c 214{
e5c113a1 215 if (annotation_level == 2)
a3f17187 216 printf_filtered (("\n\032\032record\n"));
c906108c
SS
217}
218
219void
fba45db2 220annotate_breakpoints_table_end (void)
c906108c 221{
e5c113a1 222 if (annotation_level == 2)
a3f17187 223 printf_filtered (("\n\032\032breakpoints-table-end\n"));
c906108c
SS
224}
225
226void
fba45db2 227annotate_frames_invalid (void)
c906108c 228{
3ca42dbe 229 if (annotation_level == 2)
c906108c
SS
230 {
231 target_terminal_ours ();
a3f17187 232 printf_unfiltered (("\n\032\032frames-invalid\n"));
c906108c
SS
233 }
234}
235
d17d4947
NR
236void
237annotate_new_thread (void)
238{
239 if (annotation_level > 1)
240 {
241 printf_unfiltered (("\n\032\032new-thread\n"));
242 }
243}
244
c906108c 245void
fba45db2 246annotate_field_begin (struct type *type)
c906108c 247{
e5c113a1 248 if (annotation_level == 2)
c906108c 249 {
a3f17187 250 printf_filtered (("\n\032\032field-begin "));
c906108c 251 print_value_flags (type);
a3f17187 252 printf_filtered (("\n"));
c906108c
SS
253 }
254}
255
256void
fba45db2 257annotate_field_name_end (void)
c906108c 258{
e5c113a1 259 if (annotation_level == 2)
a3f17187 260 printf_filtered (("\n\032\032field-name-end\n"));
c906108c
SS
261}
262
263void
fba45db2 264annotate_field_value (void)
c906108c 265{
e5c113a1 266 if (annotation_level == 2)
a3f17187 267 printf_filtered (("\n\032\032field-value\n"));
c906108c
SS
268}
269
270void
fba45db2 271annotate_field_end (void)
c906108c 272{
e5c113a1 273 if (annotation_level == 2)
a3f17187 274 printf_filtered (("\n\032\032field-end\n"));
c906108c
SS
275}
276\f
277void
fba45db2 278annotate_quit (void)
c906108c
SS
279{
280 if (annotation_level > 1)
a3f17187 281 printf_filtered (("\n\032\032quit\n"));
c906108c
SS
282}
283
284void
fba45db2 285annotate_error (void)
c906108c
SS
286{
287 if (annotation_level > 1)
a3f17187 288 printf_filtered (("\n\032\032error\n"));
c906108c
SS
289}
290
291void
fba45db2 292annotate_error_begin (void)
c906108c
SS
293{
294 if (annotation_level > 1)
295 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
296}
297
298void
fba45db2 299annotate_value_history_begin (int histindex, struct type *type)
c906108c 300{
e5c113a1 301 if (annotation_level == 2)
c906108c 302 {
a3f17187 303 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
c906108c 304 print_value_flags (type);
a3f17187 305 printf_filtered (("\n"));
c906108c
SS
306 }
307}
308
309void
fba45db2 310annotate_value_begin (struct type *type)
c906108c 311{
e5c113a1 312 if (annotation_level == 2)
c906108c 313 {
a3f17187 314 printf_filtered (("\n\032\032value-begin "));
c906108c 315 print_value_flags (type);
a3f17187 316 printf_filtered (("\n"));
c906108c
SS
317 }
318}
319
320void
fba45db2 321annotate_value_history_value (void)
c906108c 322{
e5c113a1 323 if (annotation_level == 2)
a3f17187 324 printf_filtered (("\n\032\032value-history-value\n"));
c906108c
SS
325}
326
327void
fba45db2 328annotate_value_history_end (void)
c906108c 329{
e5c113a1 330 if (annotation_level == 2)
a3f17187 331 printf_filtered (("\n\032\032value-history-end\n"));
c906108c
SS
332}
333
334void
fba45db2 335annotate_value_end (void)
c906108c 336{
e5c113a1 337 if (annotation_level == 2)
a3f17187 338 printf_filtered (("\n\032\032value-end\n"));
c906108c
SS
339}
340
341void
fba45db2 342annotate_display_begin (void)
c906108c 343{
e5c113a1 344 if (annotation_level == 2)
a3f17187 345 printf_filtered (("\n\032\032display-begin\n"));
c906108c
SS
346}
347
348void
fba45db2 349annotate_display_number_end (void)
c906108c 350{
e5c113a1 351 if (annotation_level == 2)
a3f17187 352 printf_filtered (("\n\032\032display-number-end\n"));
c906108c
SS
353}
354
355void
fba45db2 356annotate_display_format (void)
c906108c 357{
e5c113a1 358 if (annotation_level == 2)
a3f17187 359 printf_filtered (("\n\032\032display-format\n"));
c906108c
SS
360}
361
362void
fba45db2 363annotate_display_expression (void)
c906108c 364{
e5c113a1 365 if (annotation_level == 2)
a3f17187 366 printf_filtered (("\n\032\032display-expression\n"));
c906108c
SS
367}
368
369void
fba45db2 370annotate_display_expression_end (void)
c906108c 371{
e5c113a1 372 if (annotation_level == 2)
a3f17187 373 printf_filtered (("\n\032\032display-expression-end\n"));
c906108c
SS
374}
375
376void
fba45db2 377annotate_display_value (void)
c906108c 378{
e5c113a1 379 if (annotation_level == 2)
a3f17187 380 printf_filtered (("\n\032\032display-value\n"));
c906108c
SS
381}
382
383void
fba45db2 384annotate_display_end (void)
c906108c 385{
e5c113a1 386 if (annotation_level == 2)
a3f17187 387 printf_filtered (("\n\032\032display-end\n"));
c906108c
SS
388}
389
390void
fba45db2 391annotate_arg_begin (void)
c906108c 392{
e5c113a1 393 if (annotation_level == 2)
a3f17187 394 printf_filtered (("\n\032\032arg-begin\n"));
c906108c
SS
395}
396
397void
fba45db2 398annotate_arg_name_end (void)
c906108c 399{
e5c113a1 400 if (annotation_level == 2)
a3f17187 401 printf_filtered (("\n\032\032arg-name-end\n"));
c906108c
SS
402}
403
404void
fba45db2 405annotate_arg_value (struct type *type)
c906108c 406{
e5c113a1 407 if (annotation_level == 2)
c906108c 408 {
a3f17187 409 printf_filtered (("\n\032\032arg-value "));
c906108c 410 print_value_flags (type);
a3f17187 411 printf_filtered (("\n"));
c906108c
SS
412 }
413}
414
415void
fba45db2 416annotate_arg_end (void)
c906108c 417{
e5c113a1 418 if (annotation_level == 2)
a3f17187 419 printf_filtered (("\n\032\032arg-end\n"));
c906108c
SS
420}
421
422void
fba45db2 423annotate_source (char *filename, int line, int character, int mid, 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
MD
430 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
431 mid ? "middle" : "beg", paddress (pc));
c906108c
SS
432}
433
434void
fba45db2 435annotate_frame_begin (int level, CORE_ADDR pc)
c906108c 436{
24ca4723 437 if (annotation_level > 1)
50ee7535 438 printf_filtered (("\n\032\032frame-begin %d %s\n"), level, paddress (pc));
c906108c
SS
439}
440
441void
fba45db2 442annotate_function_call (void)
c906108c 443{
e5c113a1 444 if (annotation_level == 2)
a3f17187 445 printf_filtered (("\n\032\032function-call\n"));
c906108c
SS
446}
447
448void
fba45db2 449annotate_signal_handler_caller (void)
c906108c 450{
e5c113a1 451 if (annotation_level == 2)
a3f17187 452 printf_filtered (("\n\032\032signal-handler-caller\n"));
c906108c
SS
453}
454
455void
fba45db2 456annotate_frame_address (void)
c906108c 457{
e5c113a1 458 if (annotation_level == 2)
a3f17187 459 printf_filtered (("\n\032\032frame-address\n"));
c906108c
SS
460}
461
462void
fba45db2 463annotate_frame_address_end (void)
c906108c 464{
e5c113a1 465 if (annotation_level == 2)
a3f17187 466 printf_filtered (("\n\032\032frame-address-end\n"));
c906108c
SS
467}
468
469void
fba45db2 470annotate_frame_function_name (void)
c906108c 471{
e5c113a1 472 if (annotation_level == 2)
a3f17187 473 printf_filtered (("\n\032\032frame-function-name\n"));
c906108c
SS
474}
475
476void
fba45db2 477annotate_frame_args (void)
c906108c 478{
e5c113a1 479 if (annotation_level == 2)
a3f17187 480 printf_filtered (("\n\032\032frame-args\n"));
c906108c
SS
481}
482
483void
fba45db2 484annotate_frame_source_begin (void)
c906108c 485{
e5c113a1 486 if (annotation_level == 2)
a3f17187 487 printf_filtered (("\n\032\032frame-source-begin\n"));
c906108c
SS
488}
489
490void
fba45db2 491annotate_frame_source_file (void)
c906108c 492{
e5c113a1 493 if (annotation_level == 2)
a3f17187 494 printf_filtered (("\n\032\032frame-source-file\n"));
c906108c
SS
495}
496
497void
fba45db2 498annotate_frame_source_file_end (void)
c906108c 499{
e5c113a1 500 if (annotation_level == 2)
a3f17187 501 printf_filtered (("\n\032\032frame-source-file-end\n"));
c906108c
SS
502}
503
504void
fba45db2 505annotate_frame_source_line (void)
c906108c 506{
e5c113a1 507 if (annotation_level == 2)
a3f17187 508 printf_filtered (("\n\032\032frame-source-line\n"));
c906108c
SS
509}
510
511void
fba45db2 512annotate_frame_source_end (void)
c906108c 513{
e5c113a1 514 if (annotation_level == 2)
a3f17187 515 printf_filtered (("\n\032\032frame-source-end\n"));
c906108c
SS
516}
517
518void
fba45db2 519annotate_frame_where (void)
c906108c 520{
e5c113a1 521 if (annotation_level == 2)
a3f17187 522 printf_filtered (("\n\032\032frame-where\n"));
c906108c
SS
523}
524
525void
fba45db2 526annotate_frame_end (void)
c906108c 527{
e5c113a1 528 if (annotation_level == 2)
a3f17187 529 printf_filtered (("\n\032\032frame-end\n"));
c906108c
SS
530}
531\f
532void
fba45db2 533annotate_array_section_begin (int index, struct type *elttype)
c906108c 534{
e5c113a1 535 if (annotation_level == 2)
c906108c 536 {
a3f17187 537 printf_filtered (("\n\032\032array-section-begin %d "), index);
c906108c 538 print_value_flags (elttype);
a3f17187 539 printf_filtered (("\n"));
c906108c
SS
540 }
541}
542
543void
fba45db2 544annotate_elt_rep (unsigned int repcount)
c906108c 545{
e5c113a1 546 if (annotation_level == 2)
a3f17187 547 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
c906108c
SS
548}
549
550void
fba45db2 551annotate_elt_rep_end (void)
c906108c 552{
e5c113a1 553 if (annotation_level == 2)
a3f17187 554 printf_filtered (("\n\032\032elt-rep-end\n"));
c906108c
SS
555}
556
557void
fba45db2 558annotate_elt (void)
c906108c 559{
e5c113a1 560 if (annotation_level == 2)
a3f17187 561 printf_filtered (("\n\032\032elt\n"));
c906108c
SS
562}
563
564void
fba45db2 565annotate_array_section_end (void)
c906108c 566{
e5c113a1 567 if (annotation_level == 2)
a3f17187 568 printf_filtered (("\n\032\032array-section-end\n"));
c906108c
SS
569}
570
571static void
fba45db2 572breakpoint_changed (struct breakpoint *b)
c906108c
SS
573{
574 breakpoints_changed ();
575}
576
577void
fba45db2 578_initialize_annotate (void)
c906108c 579{
3ca42dbe 580 if (annotation_level == 2)
c906108c 581 {
9a4105ab
AC
582 deprecated_delete_breakpoint_hook = breakpoint_changed;
583 deprecated_modify_breakpoint_hook = breakpoint_changed;
c906108c
SS
584 }
585}
This page took 0.497067 seconds and 4 git commands to generate.