]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/annotate.c
x86: Move x86-specific linker options to elf_linker_x86_params
[thirdparty/binutils-gdb.git] / gdb / annotate.c
CommitLineData
c906108c 1/* Annotation routines for GDB.
42a4f53d 2 Copyright (C) 1986-2019 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"
d55e5aa6
TT
20
21/* Local non-gdb includes. */
c906108c 22#include "annotate.h"
c906108c 23#include "breakpoint.h"
d55e5aa6 24#include "gdbtypes.h"
bd00c694 25#include "inferior.h"
45741a9c 26#include "infrun.h"
d55e5aa6
TT
27#include "observable.h"
28#include "target.h"
3b12939d 29#include "top.h"
d55e5aa6
TT
30#include "value.h"
31
c906108c
SS
32\f
33
0e2de366 34/* Prototypes for local functions. */
c906108c 35
a14ed312 36static void print_value_flags (struct type *);
c906108c 37
8d3788bd 38static void breakpoint_changed (struct breakpoint *b);
7f4b89d1 39
c906108c 40
9a4105ab
AC
41void (*deprecated_annotate_signalled_hook) (void);
42void (*deprecated_annotate_signal_hook) (void);
c906108c 43
bd00c694
PA
44/* Booleans indicating whether we've emitted certain notifications.
45 Used to suppress useless repeated notifications until the next time
46 we're ready to accept more commands. Reset whenever a prompt is
47 displayed. */
48static int frames_invalid_emitted;
49static int breakpoints_invalid_emitted;
50
c906108c 51static void
fba45db2 52print_value_flags (struct type *t)
c906108c
SS
53{
54 if (can_dereference (t))
a3f17187 55 printf_filtered (("*"));
c906108c 56 else
a3f17187 57 printf_filtered (("-"));
c906108c 58}
9c97429f
PA
59
60static void
61annotate_breakpoints_invalid (void)
c906108c 62{
bd00c694
PA
63 if (annotation_level == 2
64 && (!breakpoints_invalid_emitted
3b12939d 65 || current_ui->prompt_state != PROMPT_BLOCKED))
c906108c 66 {
6fdebc3d
PA
67 /* If the inferior owns the terminal (e.g., we're resuming),
68 make sure to leave with the inferior still owning it. */
223ffa71 69 int was_inferior = target_terminal::is_inferior ();
6fdebc3d 70
223ffa71 71 target_terminal::ours_for_output ();
6fdebc3d 72
a3f17187 73 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
6fdebc3d
PA
74
75 if (was_inferior)
223ffa71 76 target_terminal::inferior ();
6fdebc3d 77
bd00c694 78 breakpoints_invalid_emitted = 1;
c906108c
SS
79 }
80}
81
82void
fba45db2 83annotate_breakpoint (int num)
c906108c
SS
84{
85 if (annotation_level > 1)
a3f17187 86 printf_filtered (("\n\032\032breakpoint %d\n"), num);
c906108c
SS
87}
88
89void
fba45db2 90annotate_catchpoint (int num)
c906108c
SS
91{
92 if (annotation_level > 1)
a3f17187 93 printf_filtered (("\n\032\032catchpoint %d\n"), num);
c906108c
SS
94}
95
96void
fba45db2 97annotate_watchpoint (int num)
c906108c
SS
98{
99 if (annotation_level > 1)
a3f17187 100 printf_filtered (("\n\032\032watchpoint %d\n"), num);
c906108c
SS
101}
102
103void
fba45db2 104annotate_starting (void)
c906108c 105{
7f4b89d1
TT
106 if (annotation_level > 1)
107 printf_filtered (("\n\032\032starting\n"));
c906108c
SS
108}
109
110void
fba45db2 111annotate_stopped (void)
c906108c 112{
7f4b89d1
TT
113 if (annotation_level > 1)
114 printf_filtered (("\n\032\032stopped\n"));
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{
bd00c694
PA
210 if (annotation_level == 2
211 && (!frames_invalid_emitted
3b12939d 212 || current_ui->prompt_state != PROMPT_BLOCKED))
c906108c 213 {
6fdebc3d
PA
214 /* If the inferior owns the terminal (e.g., we're resuming),
215 make sure to leave with the inferior still owning it. */
223ffa71 216 int was_inferior = target_terminal::is_inferior ();
6fdebc3d 217
223ffa71 218 target_terminal::ours_for_output ();
6fdebc3d 219
a3f17187 220 printf_unfiltered (("\n\032\032frames-invalid\n"));
6fdebc3d
PA
221
222 if (was_inferior)
223ffa71 223 target_terminal::inferior ();
6fdebc3d 224
bd00c694 225 frames_invalid_emitted = 1;
c906108c
SS
226 }
227}
228
d17d4947
NR
229void
230annotate_new_thread (void)
231{
232 if (annotation_level > 1)
233 {
234 printf_unfiltered (("\n\032\032new-thread\n"));
235 }
236}
237
b8fa951a
NR
238void
239annotate_thread_changed (void)
240{
241 if (annotation_level > 1)
242 {
243 printf_unfiltered (("\n\032\032thread-changed\n"));
244 }
245}
246
c906108c 247void
fba45db2 248annotate_field_begin (struct type *type)
c906108c 249{
e5c113a1 250 if (annotation_level == 2)
c906108c 251 {
a3f17187 252 printf_filtered (("\n\032\032field-begin "));
c906108c 253 print_value_flags (type);
a3f17187 254 printf_filtered (("\n"));
c906108c
SS
255 }
256}
257
258void
fba45db2 259annotate_field_name_end (void)
c906108c 260{
e5c113a1 261 if (annotation_level == 2)
a3f17187 262 printf_filtered (("\n\032\032field-name-end\n"));
c906108c
SS
263}
264
265void
fba45db2 266annotate_field_value (void)
c906108c 267{
e5c113a1 268 if (annotation_level == 2)
a3f17187 269 printf_filtered (("\n\032\032field-value\n"));
c906108c
SS
270}
271
272void
fba45db2 273annotate_field_end (void)
c906108c 274{
e5c113a1 275 if (annotation_level == 2)
a3f17187 276 printf_filtered (("\n\032\032field-end\n"));
c906108c
SS
277}
278\f
279void
fba45db2 280annotate_quit (void)
c906108c
SS
281{
282 if (annotation_level > 1)
a3f17187 283 printf_filtered (("\n\032\032quit\n"));
c906108c
SS
284}
285
286void
fba45db2 287annotate_error (void)
c906108c
SS
288{
289 if (annotation_level > 1)
a3f17187 290 printf_filtered (("\n\032\032error\n"));
c906108c
SS
291}
292
293void
fba45db2 294annotate_error_begin (void)
c906108c
SS
295{
296 if (annotation_level > 1)
297 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
298}
299
300void
fba45db2 301annotate_value_history_begin (int histindex, struct type *type)
c906108c 302{
e5c113a1 303 if (annotation_level == 2)
c906108c 304 {
a3f17187 305 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
c906108c 306 print_value_flags (type);
a3f17187 307 printf_filtered (("\n"));
c906108c
SS
308 }
309}
310
311void
fba45db2 312annotate_value_begin (struct type *type)
c906108c 313{
e5c113a1 314 if (annotation_level == 2)
c906108c 315 {
a3f17187 316 printf_filtered (("\n\032\032value-begin "));
c906108c 317 print_value_flags (type);
a3f17187 318 printf_filtered (("\n"));
c906108c
SS
319 }
320}
321
322void
fba45db2 323annotate_value_history_value (void)
c906108c 324{
e5c113a1 325 if (annotation_level == 2)
a3f17187 326 printf_filtered (("\n\032\032value-history-value\n"));
c906108c
SS
327}
328
329void
fba45db2 330annotate_value_history_end (void)
c906108c 331{
e5c113a1 332 if (annotation_level == 2)
a3f17187 333 printf_filtered (("\n\032\032value-history-end\n"));
c906108c
SS
334}
335
336void
fba45db2 337annotate_value_end (void)
c906108c 338{
e5c113a1 339 if (annotation_level == 2)
a3f17187 340 printf_filtered (("\n\032\032value-end\n"));
c906108c
SS
341}
342
343void
fba45db2 344annotate_display_begin (void)
c906108c 345{
e5c113a1 346 if (annotation_level == 2)
a3f17187 347 printf_filtered (("\n\032\032display-begin\n"));
c906108c
SS
348}
349
350void
fba45db2 351annotate_display_number_end (void)
c906108c 352{
e5c113a1 353 if (annotation_level == 2)
a3f17187 354 printf_filtered (("\n\032\032display-number-end\n"));
c906108c
SS
355}
356
357void
fba45db2 358annotate_display_format (void)
c906108c 359{
e5c113a1 360 if (annotation_level == 2)
a3f17187 361 printf_filtered (("\n\032\032display-format\n"));
c906108c
SS
362}
363
364void
fba45db2 365annotate_display_expression (void)
c906108c 366{
e5c113a1 367 if (annotation_level == 2)
a3f17187 368 printf_filtered (("\n\032\032display-expression\n"));
c906108c
SS
369}
370
371void
fba45db2 372annotate_display_expression_end (void)
c906108c 373{
e5c113a1 374 if (annotation_level == 2)
a3f17187 375 printf_filtered (("\n\032\032display-expression-end\n"));
c906108c
SS
376}
377
378void
fba45db2 379annotate_display_value (void)
c906108c 380{
e5c113a1 381 if (annotation_level == 2)
a3f17187 382 printf_filtered (("\n\032\032display-value\n"));
c906108c
SS
383}
384
385void
fba45db2 386annotate_display_end (void)
c906108c 387{
e5c113a1 388 if (annotation_level == 2)
a3f17187 389 printf_filtered (("\n\032\032display-end\n"));
c906108c
SS
390}
391
392void
fba45db2 393annotate_arg_begin (void)
c906108c 394{
e5c113a1 395 if (annotation_level == 2)
a3f17187 396 printf_filtered (("\n\032\032arg-begin\n"));
c906108c
SS
397}
398
399void
fba45db2 400annotate_arg_name_end (void)
c906108c 401{
e5c113a1 402 if (annotation_level == 2)
a3f17187 403 printf_filtered (("\n\032\032arg-name-end\n"));
c906108c
SS
404}
405
406void
fba45db2 407annotate_arg_value (struct type *type)
c906108c 408{
e5c113a1 409 if (annotation_level == 2)
c906108c 410 {
a3f17187 411 printf_filtered (("\n\032\032arg-value "));
c906108c 412 print_value_flags (type);
a3f17187 413 printf_filtered (("\n"));
c906108c
SS
414 }
415}
416
417void
fba45db2 418annotate_arg_end (void)
c906108c 419{
e5c113a1 420 if (annotation_level == 2)
a3f17187 421 printf_filtered (("\n\032\032arg-end\n"));
c906108c
SS
422}
423
424void
5af949e3
UW
425annotate_source (char *filename, int line, int character, int mid,
426 struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c
SS
427{
428 if (annotation_level > 1)
a3f17187 429 printf_filtered (("\n\032\032source "));
c906108c 430 else
a3f17187 431 printf_filtered (("\032\032"));
c906108c 432
50ee7535 433 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
5af949e3 434 mid ? "middle" : "beg", paddress (gdbarch, pc));
c906108c
SS
435}
436
437void
5af949e3 438annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c 439{
24ca4723 440 if (annotation_level > 1)
5af949e3
UW
441 printf_filtered (("\n\032\032frame-begin %d %s\n"),
442 level, paddress (gdbarch, pc));
c906108c
SS
443}
444
445void
fba45db2 446annotate_function_call (void)
c906108c 447{
e5c113a1 448 if (annotation_level == 2)
a3f17187 449 printf_filtered (("\n\032\032function-call\n"));
c906108c
SS
450}
451
452void
fba45db2 453annotate_signal_handler_caller (void)
c906108c 454{
e5c113a1 455 if (annotation_level == 2)
a3f17187 456 printf_filtered (("\n\032\032signal-handler-caller\n"));
c906108c
SS
457}
458
459void
fba45db2 460annotate_frame_address (void)
c906108c 461{
e5c113a1 462 if (annotation_level == 2)
a3f17187 463 printf_filtered (("\n\032\032frame-address\n"));
c906108c
SS
464}
465
466void
fba45db2 467annotate_frame_address_end (void)
c906108c 468{
e5c113a1 469 if (annotation_level == 2)
a3f17187 470 printf_filtered (("\n\032\032frame-address-end\n"));
c906108c
SS
471}
472
473void
fba45db2 474annotate_frame_function_name (void)
c906108c 475{
e5c113a1 476 if (annotation_level == 2)
a3f17187 477 printf_filtered (("\n\032\032frame-function-name\n"));
c906108c
SS
478}
479
480void
fba45db2 481annotate_frame_args (void)
c906108c 482{
e5c113a1 483 if (annotation_level == 2)
a3f17187 484 printf_filtered (("\n\032\032frame-args\n"));
c906108c
SS
485}
486
487void
fba45db2 488annotate_frame_source_begin (void)
c906108c 489{
e5c113a1 490 if (annotation_level == 2)
a3f17187 491 printf_filtered (("\n\032\032frame-source-begin\n"));
c906108c
SS
492}
493
494void
fba45db2 495annotate_frame_source_file (void)
c906108c 496{
e5c113a1 497 if (annotation_level == 2)
a3f17187 498 printf_filtered (("\n\032\032frame-source-file\n"));
c906108c
SS
499}
500
501void
fba45db2 502annotate_frame_source_file_end (void)
c906108c 503{
e5c113a1 504 if (annotation_level == 2)
a3f17187 505 printf_filtered (("\n\032\032frame-source-file-end\n"));
c906108c
SS
506}
507
508void
fba45db2 509annotate_frame_source_line (void)
c906108c 510{
e5c113a1 511 if (annotation_level == 2)
a3f17187 512 printf_filtered (("\n\032\032frame-source-line\n"));
c906108c
SS
513}
514
515void
fba45db2 516annotate_frame_source_end (void)
c906108c 517{
e5c113a1 518 if (annotation_level == 2)
a3f17187 519 printf_filtered (("\n\032\032frame-source-end\n"));
c906108c
SS
520}
521
522void
fba45db2 523annotate_frame_where (void)
c906108c 524{
e5c113a1 525 if (annotation_level == 2)
a3f17187 526 printf_filtered (("\n\032\032frame-where\n"));
c906108c
SS
527}
528
529void
fba45db2 530annotate_frame_end (void)
c906108c 531{
e5c113a1 532 if (annotation_level == 2)
a3f17187 533 printf_filtered (("\n\032\032frame-end\n"));
c906108c
SS
534}
535\f
536void
917793af 537annotate_array_section_begin (int idx, struct type *elttype)
c906108c 538{
e5c113a1 539 if (annotation_level == 2)
c906108c 540 {
917793af 541 printf_filtered (("\n\032\032array-section-begin %d "), idx);
c906108c 542 print_value_flags (elttype);
a3f17187 543 printf_filtered (("\n"));
c906108c
SS
544 }
545}
546
547void
fba45db2 548annotate_elt_rep (unsigned int repcount)
c906108c 549{
e5c113a1 550 if (annotation_level == 2)
a3f17187 551 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
c906108c
SS
552}
553
554void
fba45db2 555annotate_elt_rep_end (void)
c906108c 556{
e5c113a1 557 if (annotation_level == 2)
a3f17187 558 printf_filtered (("\n\032\032elt-rep-end\n"));
c906108c
SS
559}
560
561void
fba45db2 562annotate_elt (void)
c906108c 563{
e5c113a1 564 if (annotation_level == 2)
a3f17187 565 printf_filtered (("\n\032\032elt\n"));
c906108c
SS
566}
567
568void
fba45db2 569annotate_array_section_end (void)
c906108c 570{
e5c113a1 571 if (annotation_level == 2)
a3f17187 572 printf_filtered (("\n\032\032array-section-end\n"));
c906108c
SS
573}
574
bd00c694
PA
575/* Called when GDB is about to display the prompt. Used to reset
576 annotation suppression whenever we're ready to accept new
577 frontend/user commands. */
578
579void
580annotate_display_prompt (void)
581{
582 frames_invalid_emitted = 0;
583 breakpoints_invalid_emitted = 0;
584}
585
c906108c 586static void
8d3788bd 587breakpoint_changed (struct breakpoint *b)
c906108c 588{
0928e93d
PA
589 if (b->number <= 0)
590 return;
591
9c97429f 592 annotate_breakpoints_invalid ();
c906108c
SS
593}
594
595void
fba45db2 596_initialize_annotate (void)
c906108c 597{
76727919
TT
598 gdb::observers::breakpoint_created.attach (breakpoint_changed);
599 gdb::observers::breakpoint_deleted.attach (breakpoint_changed);
600 gdb::observers::breakpoint_modified.attach (breakpoint_changed);
c906108c 601}