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