]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/annotate.c
Revise signal mapping function in GDB interface for RX sim.
[thirdparty/binutils-gdb.git] / gdb / annotate.c
CommitLineData
c906108c 1/* Annotation routines for GDB.
ecd75fc8 2 Copyright (C) 1986-2014 Free Software Foundation, Inc.
c906108c 3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
c5aa993b 9 (at your option) any later version.
c906108c 10
c5aa993b
JM
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
c906108c 15
c5aa993b 16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
18
19#include "defs.h"
20#include "annotate.h"
21#include "value.h"
22#include "target.h"
23#include "gdbtypes.h"
24#include "breakpoint.h"
7f4b89d1 25#include "observer.h"
bd00c694 26#include "inferior.h"
c906108c
SS
27\f
28
0e2de366 29/* Prototypes for local functions. */
c906108c 30
a14ed312 31extern void _initialize_annotate (void);
392a587b 32
a14ed312 33static void print_value_flags (struct type *);
c906108c 34
8d3788bd 35static void breakpoint_changed (struct breakpoint *b);
7f4b89d1 36
c906108c 37
9a4105ab
AC
38void (*deprecated_annotate_signalled_hook) (void);
39void (*deprecated_annotate_signal_hook) (void);
c906108c 40
bd00c694
PA
41/* Booleans indicating whether we've emitted certain notifications.
42 Used to suppress useless repeated notifications until the next time
43 we're ready to accept more commands. Reset whenever a prompt is
44 displayed. */
45static int frames_invalid_emitted;
46static int breakpoints_invalid_emitted;
47
48/* True if the target can async, and a synchronous execution command
49 is not in progress. If true, input is accepted, so don't suppress
50 annotations. */
51
52static int
53async_background_execution_p (void)
54{
55 return (target_can_async_p () && !sync_execution);
56}
57
c906108c 58static void
fba45db2 59print_value_flags (struct type *t)
c906108c
SS
60{
61 if (can_dereference (t))
a3f17187 62 printf_filtered (("*"));
c906108c 63 else
a3f17187 64 printf_filtered (("-"));
c906108c 65}
9c97429f
PA
66
67static void
68annotate_breakpoints_invalid (void)
c906108c 69{
bd00c694
PA
70 if (annotation_level == 2
71 && (!breakpoints_invalid_emitted
72 || async_background_execution_p ()))
c906108c
SS
73 {
74 target_terminal_ours ();
a3f17187 75 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
bd00c694 76 breakpoints_invalid_emitted = 1;
c906108c
SS
77 }
78}
79
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 103{
7f4b89d1
TT
104 if (annotation_level > 1)
105 printf_filtered (("\n\032\032starting\n"));
c906108c
SS
106}
107
108void
fba45db2 109annotate_stopped (void)
c906108c 110{
7f4b89d1
TT
111 if (annotation_level > 1)
112 printf_filtered (("\n\032\032stopped\n"));
c906108c
SS
113}
114
115void
fba45db2 116annotate_exited (int exitstatus)
c906108c 117{
7f4b89d1
TT
118 if (annotation_level > 1)
119 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
c906108c
SS
120}
121
122void
fba45db2 123annotate_signalled (void)
c906108c 124{
9a4105ab
AC
125 if (deprecated_annotate_signalled_hook)
126 deprecated_annotate_signalled_hook ();
c906108c
SS
127
128 if (annotation_level > 1)
a3f17187 129 printf_filtered (("\n\032\032signalled\n"));
c906108c
SS
130}
131
132void
fba45db2 133annotate_signal_name (void)
c906108c 134{
e5c113a1 135 if (annotation_level == 2)
a3f17187 136 printf_filtered (("\n\032\032signal-name\n"));
c906108c
SS
137}
138
139void
fba45db2 140annotate_signal_name_end (void)
c906108c 141{
e5c113a1 142 if (annotation_level == 2)
a3f17187 143 printf_filtered (("\n\032\032signal-name-end\n"));
c906108c
SS
144}
145
146void
fba45db2 147annotate_signal_string (void)
c906108c 148{
e5c113a1 149 if (annotation_level == 2)
a3f17187 150 printf_filtered (("\n\032\032signal-string\n"));
c906108c
SS
151}
152
153void
fba45db2 154annotate_signal_string_end (void)
c906108c 155{
e5c113a1 156 if (annotation_level == 2)
a3f17187 157 printf_filtered (("\n\032\032signal-string-end\n"));
c906108c
SS
158}
159
160void
fba45db2 161annotate_signal (void)
c906108c 162{
9a4105ab
AC
163 if (deprecated_annotate_signal_hook)
164 deprecated_annotate_signal_hook ();
7a292a7a 165
c906108c 166 if (annotation_level > 1)
a3f17187 167 printf_filtered (("\n\032\032signal\n"));
c906108c
SS
168}
169\f
170void
fba45db2 171annotate_breakpoints_headers (void)
c906108c 172{
e5c113a1 173 if (annotation_level == 2)
a3f17187 174 printf_filtered (("\n\032\032breakpoints-headers\n"));
c906108c
SS
175}
176
177void
fba45db2 178annotate_field (int num)
c906108c 179{
e5c113a1 180 if (annotation_level == 2)
a3f17187 181 printf_filtered (("\n\032\032field %d\n"), num);
c906108c
SS
182}
183
184void
fba45db2 185annotate_breakpoints_table (void)
c906108c 186{
e5c113a1 187 if (annotation_level == 2)
a3f17187 188 printf_filtered (("\n\032\032breakpoints-table\n"));
c906108c
SS
189}
190
191void
fba45db2 192annotate_record (void)
c906108c 193{
e5c113a1 194 if (annotation_level == 2)
a3f17187 195 printf_filtered (("\n\032\032record\n"));
c906108c
SS
196}
197
198void
fba45db2 199annotate_breakpoints_table_end (void)
c906108c 200{
e5c113a1 201 if (annotation_level == 2)
a3f17187 202 printf_filtered (("\n\032\032breakpoints-table-end\n"));
c906108c
SS
203}
204
205void
fba45db2 206annotate_frames_invalid (void)
c906108c 207{
bd00c694
PA
208 if (annotation_level == 2
209 && (!frames_invalid_emitted
210 || async_background_execution_p ()))
c906108c
SS
211 {
212 target_terminal_ours ();
a3f17187 213 printf_unfiltered (("\n\032\032frames-invalid\n"));
bd00c694 214 frames_invalid_emitted = 1;
c906108c
SS
215 }
216}
217
d17d4947
NR
218void
219annotate_new_thread (void)
220{
221 if (annotation_level > 1)
222 {
223 printf_unfiltered (("\n\032\032new-thread\n"));
224 }
225}
226
b8fa951a
NR
227void
228annotate_thread_changed (void)
229{
230 if (annotation_level > 1)
231 {
232 printf_unfiltered (("\n\032\032thread-changed\n"));
233 }
234}
235
c906108c 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
5af949e3
UW
414annotate_source (char *filename, int line, int character, int mid,
415 struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c
SS
416{
417 if (annotation_level > 1)
a3f17187 418 printf_filtered (("\n\032\032source "));
c906108c 419 else
a3f17187 420 printf_filtered (("\032\032"));
c906108c 421
50ee7535 422 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
5af949e3 423 mid ? "middle" : "beg", paddress (gdbarch, pc));
c906108c
SS
424}
425
426void
5af949e3 427annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c 428{
24ca4723 429 if (annotation_level > 1)
5af949e3
UW
430 printf_filtered (("\n\032\032frame-begin %d %s\n"),
431 level, paddress (gdbarch, pc));
c906108c
SS
432}
433
434void
fba45db2 435annotate_function_call (void)
c906108c 436{
e5c113a1 437 if (annotation_level == 2)
a3f17187 438 printf_filtered (("\n\032\032function-call\n"));
c906108c
SS
439}
440
441void
fba45db2 442annotate_signal_handler_caller (void)
c906108c 443{
e5c113a1 444 if (annotation_level == 2)
a3f17187 445 printf_filtered (("\n\032\032signal-handler-caller\n"));
c906108c
SS
446}
447
448void
fba45db2 449annotate_frame_address (void)
c906108c 450{
e5c113a1 451 if (annotation_level == 2)
a3f17187 452 printf_filtered (("\n\032\032frame-address\n"));
c906108c
SS
453}
454
455void
fba45db2 456annotate_frame_address_end (void)
c906108c 457{
e5c113a1 458 if (annotation_level == 2)
a3f17187 459 printf_filtered (("\n\032\032frame-address-end\n"));
c906108c
SS
460}
461
462void
fba45db2 463annotate_frame_function_name (void)
c906108c 464{
e5c113a1 465 if (annotation_level == 2)
a3f17187 466 printf_filtered (("\n\032\032frame-function-name\n"));
c906108c
SS
467}
468
469void
fba45db2 470annotate_frame_args (void)
c906108c 471{
e5c113a1 472 if (annotation_level == 2)
a3f17187 473 printf_filtered (("\n\032\032frame-args\n"));
c906108c
SS
474}
475
476void
fba45db2 477annotate_frame_source_begin (void)
c906108c 478{
e5c113a1 479 if (annotation_level == 2)
a3f17187 480 printf_filtered (("\n\032\032frame-source-begin\n"));
c906108c
SS
481}
482
483void
fba45db2 484annotate_frame_source_file (void)
c906108c 485{
e5c113a1 486 if (annotation_level == 2)
a3f17187 487 printf_filtered (("\n\032\032frame-source-file\n"));
c906108c
SS
488}
489
490void
fba45db2 491annotate_frame_source_file_end (void)
c906108c 492{
e5c113a1 493 if (annotation_level == 2)
a3f17187 494 printf_filtered (("\n\032\032frame-source-file-end\n"));
c906108c
SS
495}
496
497void
fba45db2 498annotate_frame_source_line (void)
c906108c 499{
e5c113a1 500 if (annotation_level == 2)
a3f17187 501 printf_filtered (("\n\032\032frame-source-line\n"));
c906108c
SS
502}
503
504void
fba45db2 505annotate_frame_source_end (void)
c906108c 506{
e5c113a1 507 if (annotation_level == 2)
a3f17187 508 printf_filtered (("\n\032\032frame-source-end\n"));
c906108c
SS
509}
510
511void
fba45db2 512annotate_frame_where (void)
c906108c 513{
e5c113a1 514 if (annotation_level == 2)
a3f17187 515 printf_filtered (("\n\032\032frame-where\n"));
c906108c
SS
516}
517
518void
fba45db2 519annotate_frame_end (void)
c906108c 520{
e5c113a1 521 if (annotation_level == 2)
a3f17187 522 printf_filtered (("\n\032\032frame-end\n"));
c906108c
SS
523}
524\f
525void
917793af 526annotate_array_section_begin (int idx, struct type *elttype)
c906108c 527{
e5c113a1 528 if (annotation_level == 2)
c906108c 529 {
917793af 530 printf_filtered (("\n\032\032array-section-begin %d "), idx);
c906108c 531 print_value_flags (elttype);
a3f17187 532 printf_filtered (("\n"));
c906108c
SS
533 }
534}
535
536void
fba45db2 537annotate_elt_rep (unsigned int repcount)
c906108c 538{
e5c113a1 539 if (annotation_level == 2)
a3f17187 540 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
c906108c
SS
541}
542
543void
fba45db2 544annotate_elt_rep_end (void)
c906108c 545{
e5c113a1 546 if (annotation_level == 2)
a3f17187 547 printf_filtered (("\n\032\032elt-rep-end\n"));
c906108c
SS
548}
549
550void
fba45db2 551annotate_elt (void)
c906108c 552{
e5c113a1 553 if (annotation_level == 2)
a3f17187 554 printf_filtered (("\n\032\032elt\n"));
c906108c
SS
555}
556
557void
fba45db2 558annotate_array_section_end (void)
c906108c 559{
e5c113a1 560 if (annotation_level == 2)
a3f17187 561 printf_filtered (("\n\032\032array-section-end\n"));
c906108c
SS
562}
563
bd00c694
PA
564/* Called when GDB is about to display the prompt. Used to reset
565 annotation suppression whenever we're ready to accept new
566 frontend/user commands. */
567
568void
569annotate_display_prompt (void)
570{
571 frames_invalid_emitted = 0;
572 breakpoints_invalid_emitted = 0;
573}
574
c906108c 575static void
8d3788bd 576breakpoint_changed (struct breakpoint *b)
c906108c 577{
0928e93d
PA
578 if (b->number <= 0)
579 return;
580
9c97429f 581 annotate_breakpoints_invalid ();
c906108c
SS
582}
583
584void
fba45db2 585_initialize_annotate (void)
c906108c 586{
9c97429f
PA
587 observer_attach_breakpoint_created (breakpoint_changed);
588 observer_attach_breakpoint_deleted (breakpoint_changed);
589 observer_attach_breakpoint_modified (breakpoint_changed);
c906108c 590}