*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / annotate.c
CommitLineData
c906108c 1/* Annotation routines for GDB.
b6ba6518
KB
2 Copyright 1986, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999,
3 2000 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
9 the Free Software Foundation; either version 2 of the License, or
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
JM
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
c906108c
SS
21
22#include "defs.h"
23#include "annotate.h"
24#include "value.h"
25#include "target.h"
26#include "gdbtypes.h"
27#include "breakpoint.h"
28\f
29
30/* Prototypes for local functions. */
31
a14ed312 32extern void _initialize_annotate (void);
392a587b 33
a14ed312 34static void print_value_flags (struct type *);
c906108c 35
a14ed312 36static void breakpoint_changed (struct breakpoint *);
c906108c 37
9a4105ab
AC
38void (*deprecated_annotate_starting_hook) (void);
39void (*deprecated_annotate_stopped_hook) (void);
40void (*deprecated_annotate_signalled_hook) (void);
41void (*deprecated_annotate_signal_hook) (void);
42void (*deprecated_annotate_exited_hook) (void);
c906108c 43
5c44784c
JM
44static int ignore_count_changed = 0;
45
c906108c 46static void
fba45db2 47print_value_flags (struct type *t)
c906108c
SS
48{
49 if (can_dereference (t))
a3f17187 50 printf_filtered (("*"));
c906108c 51 else
a3f17187 52 printf_filtered (("-"));
c906108c
SS
53}
54\f
55void
fba45db2 56breakpoints_changed (void)
c906108c
SS
57{
58 if (annotation_level > 1)
59 {
60 target_terminal_ours ();
a3f17187 61 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
5c44784c
JM
62 if (ignore_count_changed)
63 ignore_count_changed = 0; /* Avoid multiple break annotations. */
c906108c
SS
64 }
65}
66
5c44784c
JM
67/* The GUI needs to be informed of ignore_count changes, but we don't
68 want to provide successive multiple breakpoints-invalid messages
69 that are all caused by the fact that the ignore count is changing
70 (which could keep the GUI very busy). One is enough, after the
71 target actually "stops". */
72
73void
74annotate_ignore_count_change (void)
75{
76 if (annotation_level > 1)
77 ignore_count_changed = 1;
78}
79
c906108c 80void
fba45db2 81annotate_breakpoint (int num)
c906108c
SS
82{
83 if (annotation_level > 1)
a3f17187 84 printf_filtered (("\n\032\032breakpoint %d\n"), num);
c906108c
SS
85}
86
87void
fba45db2 88annotate_catchpoint (int num)
c906108c
SS
89{
90 if (annotation_level > 1)
a3f17187 91 printf_filtered (("\n\032\032catchpoint %d\n"), num);
c906108c
SS
92}
93
94void
fba45db2 95annotate_watchpoint (int num)
c906108c
SS
96{
97 if (annotation_level > 1)
a3f17187 98 printf_filtered (("\n\032\032watchpoint %d\n"), num);
c906108c
SS
99}
100
101void
fba45db2 102annotate_starting (void)
c906108c
SS
103{
104
9a4105ab
AC
105 if (deprecated_annotate_starting_hook)
106 deprecated_annotate_starting_hook ();
c906108c
SS
107 else
108 {
109 if (annotation_level > 1)
c5aa993b 110 {
a3f17187 111 printf_filtered (("\n\032\032starting\n"));
c5aa993b 112 }
c906108c
SS
113 }
114}
115
116void
fba45db2 117annotate_stopped (void)
c906108c 118{
9a4105ab
AC
119 if (deprecated_annotate_stopped_hook)
120 deprecated_annotate_stopped_hook ();
c906108c
SS
121 else
122 {
123 if (annotation_level > 1)
a3f17187 124 printf_filtered (("\n\032\032stopped\n"));
c906108c 125 }
5c44784c
JM
126 if (annotation_level > 1 && ignore_count_changed)
127 {
128 ignore_count_changed = 0;
129 breakpoints_changed ();
130 }
c906108c
SS
131}
132
133void
fba45db2 134annotate_exited (int exitstatus)
c906108c 135{
9a4105ab
AC
136 if (deprecated_annotate_exited_hook)
137 deprecated_annotate_exited_hook ();
c906108c
SS
138 else
139 {
140 if (annotation_level > 1)
a3f17187 141 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
c906108c
SS
142 }
143}
144
145void
fba45db2 146annotate_signalled (void)
c906108c 147{
9a4105ab
AC
148 if (deprecated_annotate_signalled_hook)
149 deprecated_annotate_signalled_hook ();
c906108c
SS
150
151 if (annotation_level > 1)
a3f17187 152 printf_filtered (("\n\032\032signalled\n"));
c906108c
SS
153}
154
155void
fba45db2 156annotate_signal_name (void)
c906108c 157{
e5c113a1 158 if (annotation_level == 2)
a3f17187 159 printf_filtered (("\n\032\032signal-name\n"));
c906108c
SS
160}
161
162void
fba45db2 163annotate_signal_name_end (void)
c906108c 164{
e5c113a1 165 if (annotation_level == 2)
a3f17187 166 printf_filtered (("\n\032\032signal-name-end\n"));
c906108c
SS
167}
168
169void
fba45db2 170annotate_signal_string (void)
c906108c 171{
e5c113a1 172 if (annotation_level == 2)
a3f17187 173 printf_filtered (("\n\032\032signal-string\n"));
c906108c
SS
174}
175
176void
fba45db2 177annotate_signal_string_end (void)
c906108c 178{
e5c113a1 179 if (annotation_level == 2)
a3f17187 180 printf_filtered (("\n\032\032signal-string-end\n"));
c906108c
SS
181}
182
183void
fba45db2 184annotate_signal (void)
c906108c 185{
9a4105ab
AC
186 if (deprecated_annotate_signal_hook)
187 deprecated_annotate_signal_hook ();
7a292a7a 188
c906108c 189 if (annotation_level > 1)
a3f17187 190 printf_filtered (("\n\032\032signal\n"));
c906108c
SS
191}
192\f
193void
fba45db2 194annotate_breakpoints_headers (void)
c906108c 195{
e5c113a1 196 if (annotation_level == 2)
a3f17187 197 printf_filtered (("\n\032\032breakpoints-headers\n"));
c906108c
SS
198}
199
200void
fba45db2 201annotate_field (int num)
c906108c 202{
e5c113a1 203 if (annotation_level == 2)
a3f17187 204 printf_filtered (("\n\032\032field %d\n"), num);
c906108c
SS
205}
206
207void
fba45db2 208annotate_breakpoints_table (void)
c906108c 209{
e5c113a1 210 if (annotation_level == 2)
a3f17187 211 printf_filtered (("\n\032\032breakpoints-table\n"));
c906108c
SS
212}
213
214void
fba45db2 215annotate_record (void)
c906108c 216{
e5c113a1 217 if (annotation_level == 2)
a3f17187 218 printf_filtered (("\n\032\032record\n"));
c906108c
SS
219}
220
221void
fba45db2 222annotate_breakpoints_table_end (void)
c906108c 223{
e5c113a1 224 if (annotation_level == 2)
a3f17187 225 printf_filtered (("\n\032\032breakpoints-table-end\n"));
c906108c
SS
226}
227
228void
fba45db2 229annotate_frames_invalid (void)
c906108c
SS
230{
231 if (annotation_level > 1)
232 {
233 target_terminal_ours ();
a3f17187 234 printf_unfiltered (("\n\032\032frames-invalid\n"));
c906108c
SS
235 }
236}
237
238void
fba45db2 239annotate_field_begin (struct type *type)
c906108c 240{
e5c113a1 241 if (annotation_level == 2)
c906108c 242 {
a3f17187 243 printf_filtered (("\n\032\032field-begin "));
c906108c 244 print_value_flags (type);
a3f17187 245 printf_filtered (("\n"));
c906108c
SS
246 }
247}
248
249void
fba45db2 250annotate_field_name_end (void)
c906108c 251{
e5c113a1 252 if (annotation_level == 2)
a3f17187 253 printf_filtered (("\n\032\032field-name-end\n"));
c906108c
SS
254}
255
256void
fba45db2 257annotate_field_value (void)
c906108c 258{
e5c113a1 259 if (annotation_level == 2)
a3f17187 260 printf_filtered (("\n\032\032field-value\n"));
c906108c
SS
261}
262
263void
fba45db2 264annotate_field_end (void)
c906108c 265{
e5c113a1 266 if (annotation_level == 2)
a3f17187 267 printf_filtered (("\n\032\032field-end\n"));
c906108c
SS
268}
269\f
270void
fba45db2 271annotate_quit (void)
c906108c
SS
272{
273 if (annotation_level > 1)
a3f17187 274 printf_filtered (("\n\032\032quit\n"));
c906108c
SS
275}
276
277void
fba45db2 278annotate_error (void)
c906108c
SS
279{
280 if (annotation_level > 1)
a3f17187 281 printf_filtered (("\n\032\032error\n"));
c906108c
SS
282}
283
284void
fba45db2 285annotate_error_begin (void)
c906108c
SS
286{
287 if (annotation_level > 1)
288 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
289}
290
291void
fba45db2 292annotate_value_history_begin (int histindex, struct type *type)
c906108c 293{
e5c113a1 294 if (annotation_level == 2)
c906108c 295 {
a3f17187 296 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
c906108c 297 print_value_flags (type);
a3f17187 298 printf_filtered (("\n"));
c906108c
SS
299 }
300}
301
302void
fba45db2 303annotate_value_begin (struct type *type)
c906108c 304{
e5c113a1 305 if (annotation_level == 2)
c906108c 306 {
a3f17187 307 printf_filtered (("\n\032\032value-begin "));
c906108c 308 print_value_flags (type);
a3f17187 309 printf_filtered (("\n"));
c906108c
SS
310 }
311}
312
313void
fba45db2 314annotate_value_history_value (void)
c906108c 315{
e5c113a1 316 if (annotation_level == 2)
a3f17187 317 printf_filtered (("\n\032\032value-history-value\n"));
c906108c
SS
318}
319
320void
fba45db2 321annotate_value_history_end (void)
c906108c 322{
e5c113a1 323 if (annotation_level == 2)
a3f17187 324 printf_filtered (("\n\032\032value-history-end\n"));
c906108c
SS
325}
326
327void
fba45db2 328annotate_value_end (void)
c906108c 329{
e5c113a1 330 if (annotation_level == 2)
a3f17187 331 printf_filtered (("\n\032\032value-end\n"));
c906108c
SS
332}
333
334void
fba45db2 335annotate_display_begin (void)
c906108c 336{
e5c113a1 337 if (annotation_level == 2)
a3f17187 338 printf_filtered (("\n\032\032display-begin\n"));
c906108c
SS
339}
340
341void
fba45db2 342annotate_display_number_end (void)
c906108c 343{
e5c113a1 344 if (annotation_level == 2)
a3f17187 345 printf_filtered (("\n\032\032display-number-end\n"));
c906108c
SS
346}
347
348void
fba45db2 349annotate_display_format (void)
c906108c 350{
e5c113a1 351 if (annotation_level == 2)
a3f17187 352 printf_filtered (("\n\032\032display-format\n"));
c906108c
SS
353}
354
355void
fba45db2 356annotate_display_expression (void)
c906108c 357{
e5c113a1 358 if (annotation_level == 2)
a3f17187 359 printf_filtered (("\n\032\032display-expression\n"));
c906108c
SS
360}
361
362void
fba45db2 363annotate_display_expression_end (void)
c906108c 364{
e5c113a1 365 if (annotation_level == 2)
a3f17187 366 printf_filtered (("\n\032\032display-expression-end\n"));
c906108c
SS
367}
368
369void
fba45db2 370annotate_display_value (void)
c906108c 371{
e5c113a1 372 if (annotation_level == 2)
a3f17187 373 printf_filtered (("\n\032\032display-value\n"));
c906108c
SS
374}
375
376void
fba45db2 377annotate_display_end (void)
c906108c 378{
e5c113a1 379 if (annotation_level == 2)
a3f17187 380 printf_filtered (("\n\032\032display-end\n"));
c906108c
SS
381}
382
383void
fba45db2 384annotate_arg_begin (void)
c906108c 385{
e5c113a1 386 if (annotation_level == 2)
a3f17187 387 printf_filtered (("\n\032\032arg-begin\n"));
c906108c
SS
388}
389
390void
fba45db2 391annotate_arg_name_end (void)
c906108c 392{
e5c113a1 393 if (annotation_level == 2)
a3f17187 394 printf_filtered (("\n\032\032arg-name-end\n"));
c906108c
SS
395}
396
397void
fba45db2 398annotate_arg_value (struct type *type)
c906108c 399{
e5c113a1 400 if (annotation_level == 2)
c906108c 401 {
a3f17187 402 printf_filtered (("\n\032\032arg-value "));
c906108c 403 print_value_flags (type);
a3f17187 404 printf_filtered (("\n"));
c906108c
SS
405 }
406}
407
408void
fba45db2 409annotate_arg_end (void)
c906108c 410{
e5c113a1 411 if (annotation_level == 2)
a3f17187 412 printf_filtered (("\n\032\032arg-end\n"));
c906108c
SS
413}
414
415void
fba45db2 416annotate_source (char *filename, int line, int character, int mid, 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
a3f17187 423 printf_filtered (("%s:%d:%d:%s:0x"), filename,
c906108c
SS
424 line, character,
425 mid ? "middle" : "beg");
66bf4b3a 426 deprecated_print_address_numeric (pc, 0, gdb_stdout);
a3f17187 427 printf_filtered (("\n"));
c906108c
SS
428}
429
430void
fba45db2 431annotate_frame_begin (int level, CORE_ADDR pc)
c906108c 432{
e5c113a1 433 if (annotation_level == 2)
c906108c 434 {
a3f17187 435 printf_filtered (("\n\032\032frame-begin %d 0x"), level);
66bf4b3a 436 deprecated_print_address_numeric (pc, 0, gdb_stdout);
a3f17187 437 printf_filtered (("\n"));
c906108c
SS
438 }
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
SS
579{
580 if (annotation_level > 1)
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.40341 seconds and 4 git commands to generate.