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