]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/annotate.c
Switch the license of all .c files to GPLv3.
[thirdparty/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,
6aba47ca 3 2000, 2007 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
236void
fba45db2 237annotate_field_begin (struct type *type)
c906108c 238{
e5c113a1 239 if (annotation_level == 2)
c906108c 240 {
a3f17187 241 printf_filtered (("\n\032\032field-begin "));
c906108c 242 print_value_flags (type);
a3f17187 243 printf_filtered (("\n"));
c906108c
SS
244 }
245}
246
247void
fba45db2 248annotate_field_name_end (void)
c906108c 249{
e5c113a1 250 if (annotation_level == 2)
a3f17187 251 printf_filtered (("\n\032\032field-name-end\n"));
c906108c
SS
252}
253
254void
fba45db2 255annotate_field_value (void)
c906108c 256{
e5c113a1 257 if (annotation_level == 2)
a3f17187 258 printf_filtered (("\n\032\032field-value\n"));
c906108c
SS
259}
260
261void
fba45db2 262annotate_field_end (void)
c906108c 263{
e5c113a1 264 if (annotation_level == 2)
a3f17187 265 printf_filtered (("\n\032\032field-end\n"));
c906108c
SS
266}
267\f
268void
fba45db2 269annotate_quit (void)
c906108c
SS
270{
271 if (annotation_level > 1)
a3f17187 272 printf_filtered (("\n\032\032quit\n"));
c906108c
SS
273}
274
275void
fba45db2 276annotate_error (void)
c906108c
SS
277{
278 if (annotation_level > 1)
a3f17187 279 printf_filtered (("\n\032\032error\n"));
c906108c
SS
280}
281
282void
fba45db2 283annotate_error_begin (void)
c906108c
SS
284{
285 if (annotation_level > 1)
286 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
287}
288
289void
fba45db2 290annotate_value_history_begin (int histindex, struct type *type)
c906108c 291{
e5c113a1 292 if (annotation_level == 2)
c906108c 293 {
a3f17187 294 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
c906108c 295 print_value_flags (type);
a3f17187 296 printf_filtered (("\n"));
c906108c
SS
297 }
298}
299
300void
fba45db2 301annotate_value_begin (struct type *type)
c906108c 302{
e5c113a1 303 if (annotation_level == 2)
c906108c 304 {
a3f17187 305 printf_filtered (("\n\032\032value-begin "));
c906108c 306 print_value_flags (type);
a3f17187 307 printf_filtered (("\n"));
c906108c
SS
308 }
309}
310
311void
fba45db2 312annotate_value_history_value (void)
c906108c 313{
e5c113a1 314 if (annotation_level == 2)
a3f17187 315 printf_filtered (("\n\032\032value-history-value\n"));
c906108c
SS
316}
317
318void
fba45db2 319annotate_value_history_end (void)
c906108c 320{
e5c113a1 321 if (annotation_level == 2)
a3f17187 322 printf_filtered (("\n\032\032value-history-end\n"));
c906108c
SS
323}
324
325void
fba45db2 326annotate_value_end (void)
c906108c 327{
e5c113a1 328 if (annotation_level == 2)
a3f17187 329 printf_filtered (("\n\032\032value-end\n"));
c906108c
SS
330}
331
332void
fba45db2 333annotate_display_begin (void)
c906108c 334{
e5c113a1 335 if (annotation_level == 2)
a3f17187 336 printf_filtered (("\n\032\032display-begin\n"));
c906108c
SS
337}
338
339void
fba45db2 340annotate_display_number_end (void)
c906108c 341{
e5c113a1 342 if (annotation_level == 2)
a3f17187 343 printf_filtered (("\n\032\032display-number-end\n"));
c906108c
SS
344}
345
346void
fba45db2 347annotate_display_format (void)
c906108c 348{
e5c113a1 349 if (annotation_level == 2)
a3f17187 350 printf_filtered (("\n\032\032display-format\n"));
c906108c
SS
351}
352
353void
fba45db2 354annotate_display_expression (void)
c906108c 355{
e5c113a1 356 if (annotation_level == 2)
a3f17187 357 printf_filtered (("\n\032\032display-expression\n"));
c906108c
SS
358}
359
360void
fba45db2 361annotate_display_expression_end (void)
c906108c 362{
e5c113a1 363 if (annotation_level == 2)
a3f17187 364 printf_filtered (("\n\032\032display-expression-end\n"));
c906108c
SS
365}
366
367void
fba45db2 368annotate_display_value (void)
c906108c 369{
e5c113a1 370 if (annotation_level == 2)
a3f17187 371 printf_filtered (("\n\032\032display-value\n"));
c906108c
SS
372}
373
374void
fba45db2 375annotate_display_end (void)
c906108c 376{
e5c113a1 377 if (annotation_level == 2)
a3f17187 378 printf_filtered (("\n\032\032display-end\n"));
c906108c
SS
379}
380
381void
fba45db2 382annotate_arg_begin (void)
c906108c 383{
e5c113a1 384 if (annotation_level == 2)
a3f17187 385 printf_filtered (("\n\032\032arg-begin\n"));
c906108c
SS
386}
387
388void
fba45db2 389annotate_arg_name_end (void)
c906108c 390{
e5c113a1 391 if (annotation_level == 2)
a3f17187 392 printf_filtered (("\n\032\032arg-name-end\n"));
c906108c
SS
393}
394
395void
fba45db2 396annotate_arg_value (struct type *type)
c906108c 397{
e5c113a1 398 if (annotation_level == 2)
c906108c 399 {
a3f17187 400 printf_filtered (("\n\032\032arg-value "));
c906108c 401 print_value_flags (type);
a3f17187 402 printf_filtered (("\n"));
c906108c
SS
403 }
404}
405
406void
fba45db2 407annotate_arg_end (void)
c906108c 408{
e5c113a1 409 if (annotation_level == 2)
a3f17187 410 printf_filtered (("\n\032\032arg-end\n"));
c906108c
SS
411}
412
413void
fba45db2 414annotate_source (char *filename, int line, int character, int mid, CORE_ADDR pc)
c906108c
SS
415{
416 if (annotation_level > 1)
a3f17187 417 printf_filtered (("\n\032\032source "));
c906108c 418 else
a3f17187 419 printf_filtered (("\032\032"));
c906108c 420
a3f17187 421 printf_filtered (("%s:%d:%d:%s:0x"), filename,
c906108c
SS
422 line, character,
423 mid ? "middle" : "beg");
66bf4b3a 424 deprecated_print_address_numeric (pc, 0, gdb_stdout);
a3f17187 425 printf_filtered (("\n"));
c906108c
SS
426}
427
428void
fba45db2 429annotate_frame_begin (int level, CORE_ADDR pc)
c906108c 430{
24ca4723 431 if (annotation_level > 1)
c906108c 432 {
a3f17187 433 printf_filtered (("\n\032\032frame-begin %d 0x"), level);
66bf4b3a 434 deprecated_print_address_numeric (pc, 0, gdb_stdout);
a3f17187 435 printf_filtered (("\n"));
c906108c
SS
436 }
437}
438
439void
fba45db2 440annotate_function_call (void)
c906108c 441{
e5c113a1 442 if (annotation_level == 2)
a3f17187 443 printf_filtered (("\n\032\032function-call\n"));
c906108c
SS
444}
445
446void
fba45db2 447annotate_signal_handler_caller (void)
c906108c 448{
e5c113a1 449 if (annotation_level == 2)
a3f17187 450 printf_filtered (("\n\032\032signal-handler-caller\n"));
c906108c
SS
451}
452
453void
fba45db2 454annotate_frame_address (void)
c906108c 455{
e5c113a1 456 if (annotation_level == 2)
a3f17187 457 printf_filtered (("\n\032\032frame-address\n"));
c906108c
SS
458}
459
460void
fba45db2 461annotate_frame_address_end (void)
c906108c 462{
e5c113a1 463 if (annotation_level == 2)
a3f17187 464 printf_filtered (("\n\032\032frame-address-end\n"));
c906108c
SS
465}
466
467void
fba45db2 468annotate_frame_function_name (void)
c906108c 469{
e5c113a1 470 if (annotation_level == 2)
a3f17187 471 printf_filtered (("\n\032\032frame-function-name\n"));
c906108c
SS
472}
473
474void
fba45db2 475annotate_frame_args (void)
c906108c 476{
e5c113a1 477 if (annotation_level == 2)
a3f17187 478 printf_filtered (("\n\032\032frame-args\n"));
c906108c
SS
479}
480
481void
fba45db2 482annotate_frame_source_begin (void)
c906108c 483{
e5c113a1 484 if (annotation_level == 2)
a3f17187 485 printf_filtered (("\n\032\032frame-source-begin\n"));
c906108c
SS
486}
487
488void
fba45db2 489annotate_frame_source_file (void)
c906108c 490{
e5c113a1 491 if (annotation_level == 2)
a3f17187 492 printf_filtered (("\n\032\032frame-source-file\n"));
c906108c
SS
493}
494
495void
fba45db2 496annotate_frame_source_file_end (void)
c906108c 497{
e5c113a1 498 if (annotation_level == 2)
a3f17187 499 printf_filtered (("\n\032\032frame-source-file-end\n"));
c906108c
SS
500}
501
502void
fba45db2 503annotate_frame_source_line (void)
c906108c 504{
e5c113a1 505 if (annotation_level == 2)
a3f17187 506 printf_filtered (("\n\032\032frame-source-line\n"));
c906108c
SS
507}
508
509void
fba45db2 510annotate_frame_source_end (void)
c906108c 511{
e5c113a1 512 if (annotation_level == 2)
a3f17187 513 printf_filtered (("\n\032\032frame-source-end\n"));
c906108c
SS
514}
515
516void
fba45db2 517annotate_frame_where (void)
c906108c 518{
e5c113a1 519 if (annotation_level == 2)
a3f17187 520 printf_filtered (("\n\032\032frame-where\n"));
c906108c
SS
521}
522
523void
fba45db2 524annotate_frame_end (void)
c906108c 525{
e5c113a1 526 if (annotation_level == 2)
a3f17187 527 printf_filtered (("\n\032\032frame-end\n"));
c906108c
SS
528}
529\f
530void
fba45db2 531annotate_array_section_begin (int index, struct type *elttype)
c906108c 532{
e5c113a1 533 if (annotation_level == 2)
c906108c 534 {
a3f17187 535 printf_filtered (("\n\032\032array-section-begin %d "), index);
c906108c 536 print_value_flags (elttype);
a3f17187 537 printf_filtered (("\n"));
c906108c
SS
538 }
539}
540
541void
fba45db2 542annotate_elt_rep (unsigned int repcount)
c906108c 543{
e5c113a1 544 if (annotation_level == 2)
a3f17187 545 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
c906108c
SS
546}
547
548void
fba45db2 549annotate_elt_rep_end (void)
c906108c 550{
e5c113a1 551 if (annotation_level == 2)
a3f17187 552 printf_filtered (("\n\032\032elt-rep-end\n"));
c906108c
SS
553}
554
555void
fba45db2 556annotate_elt (void)
c906108c 557{
e5c113a1 558 if (annotation_level == 2)
a3f17187 559 printf_filtered (("\n\032\032elt\n"));
c906108c
SS
560}
561
562void
fba45db2 563annotate_array_section_end (void)
c906108c 564{
e5c113a1 565 if (annotation_level == 2)
a3f17187 566 printf_filtered (("\n\032\032array-section-end\n"));
c906108c
SS
567}
568
569static void
fba45db2 570breakpoint_changed (struct breakpoint *b)
c906108c
SS
571{
572 breakpoints_changed ();
573}
574
575void
fba45db2 576_initialize_annotate (void)
c906108c 577{
3ca42dbe 578 if (annotation_level == 2)
c906108c 579 {
9a4105ab
AC
580 deprecated_delete_breakpoint_hook = breakpoint_changed;
581 deprecated_modify_breakpoint_hook = breakpoint_changed;
c906108c
SS
582 }
583}