windows-nat: Don't change current_event.dwThreadId in handle_output_debug_string()
[deliverable/binutils-gdb.git] / gdb / annotate.c
CommitLineData
c906108c 1/* Annotation routines for GDB.
32d0add0 2 Copyright (C) 1986-2015 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"
45741a9c 27#include "infrun.h"
c906108c
SS
28\f
29
0e2de366 30/* Prototypes for local functions. */
c906108c 31
a14ed312 32extern void _initialize_annotate (void);
392a587b 33
a14ed312 34static void print_value_flags (struct type *);
c906108c 35
8d3788bd 36static void breakpoint_changed (struct breakpoint *b);
7f4b89d1 37
c906108c 38
9a4105ab
AC
39void (*deprecated_annotate_signalled_hook) (void);
40void (*deprecated_annotate_signal_hook) (void);
c906108c 41
bd00c694
PA
42/* Booleans indicating whether we've emitted certain notifications.
43 Used to suppress useless repeated notifications until the next time
44 we're ready to accept more commands. Reset whenever a prompt is
45 displayed. */
46static int frames_invalid_emitted;
47static int breakpoints_invalid_emitted;
48
49/* True if the target can async, and a synchronous execution command
50 is not in progress. If true, input is accepted, so don't suppress
51 annotations. */
52
53static int
54async_background_execution_p (void)
55{
56 return (target_can_async_p () && !sync_execution);
57}
58
c906108c 59static void
fba45db2 60print_value_flags (struct type *t)
c906108c
SS
61{
62 if (can_dereference (t))
a3f17187 63 printf_filtered (("*"));
c906108c 64 else
a3f17187 65 printf_filtered (("-"));
c906108c 66}
9c97429f
PA
67
68static void
69annotate_breakpoints_invalid (void)
c906108c 70{
bd00c694
PA
71 if (annotation_level == 2
72 && (!breakpoints_invalid_emitted
73 || async_background_execution_p ()))
c906108c 74 {
6fdebc3d
PA
75 /* If the inferior owns the terminal (e.g., we're resuming),
76 make sure to leave with the inferior still owning it. */
77 int was_inferior = target_terminal_is_inferior ();
78
79 target_terminal_ours_for_output ();
80
a3f17187 81 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
6fdebc3d
PA
82
83 if (was_inferior)
84 target_terminal_inferior ();
85
bd00c694 86 breakpoints_invalid_emitted = 1;
c906108c
SS
87 }
88}
89
90void
fba45db2 91annotate_breakpoint (int num)
c906108c
SS
92{
93 if (annotation_level > 1)
a3f17187 94 printf_filtered (("\n\032\032breakpoint %d\n"), num);
c906108c
SS
95}
96
97void
fba45db2 98annotate_catchpoint (int num)
c906108c
SS
99{
100 if (annotation_level > 1)
a3f17187 101 printf_filtered (("\n\032\032catchpoint %d\n"), num);
c906108c
SS
102}
103
104void
fba45db2 105annotate_watchpoint (int num)
c906108c
SS
106{
107 if (annotation_level > 1)
a3f17187 108 printf_filtered (("\n\032\032watchpoint %d\n"), num);
c906108c
SS
109}
110
111void
fba45db2 112annotate_starting (void)
c906108c 113{
7f4b89d1
TT
114 if (annotation_level > 1)
115 printf_filtered (("\n\032\032starting\n"));
c906108c
SS
116}
117
118void
fba45db2 119annotate_stopped (void)
c906108c 120{
7f4b89d1
TT
121 if (annotation_level > 1)
122 printf_filtered (("\n\032\032stopped\n"));
c906108c
SS
123}
124
125void
fba45db2 126annotate_exited (int exitstatus)
c906108c 127{
7f4b89d1
TT
128 if (annotation_level > 1)
129 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
c906108c
SS
130}
131
132void
fba45db2 133annotate_signalled (void)
c906108c 134{
9a4105ab
AC
135 if (deprecated_annotate_signalled_hook)
136 deprecated_annotate_signalled_hook ();
c906108c
SS
137
138 if (annotation_level > 1)
a3f17187 139 printf_filtered (("\n\032\032signalled\n"));
c906108c
SS
140}
141
142void
fba45db2 143annotate_signal_name (void)
c906108c 144{
e5c113a1 145 if (annotation_level == 2)
a3f17187 146 printf_filtered (("\n\032\032signal-name\n"));
c906108c
SS
147}
148
149void
fba45db2 150annotate_signal_name_end (void)
c906108c 151{
e5c113a1 152 if (annotation_level == 2)
a3f17187 153 printf_filtered (("\n\032\032signal-name-end\n"));
c906108c
SS
154}
155
156void
fba45db2 157annotate_signal_string (void)
c906108c 158{
e5c113a1 159 if (annotation_level == 2)
a3f17187 160 printf_filtered (("\n\032\032signal-string\n"));
c906108c
SS
161}
162
163void
fba45db2 164annotate_signal_string_end (void)
c906108c 165{
e5c113a1 166 if (annotation_level == 2)
a3f17187 167 printf_filtered (("\n\032\032signal-string-end\n"));
c906108c
SS
168}
169
170void
fba45db2 171annotate_signal (void)
c906108c 172{
9a4105ab
AC
173 if (deprecated_annotate_signal_hook)
174 deprecated_annotate_signal_hook ();
7a292a7a 175
c906108c 176 if (annotation_level > 1)
a3f17187 177 printf_filtered (("\n\032\032signal\n"));
c906108c
SS
178}
179\f
180void
fba45db2 181annotate_breakpoints_headers (void)
c906108c 182{
e5c113a1 183 if (annotation_level == 2)
a3f17187 184 printf_filtered (("\n\032\032breakpoints-headers\n"));
c906108c
SS
185}
186
187void
fba45db2 188annotate_field (int num)
c906108c 189{
e5c113a1 190 if (annotation_level == 2)
a3f17187 191 printf_filtered (("\n\032\032field %d\n"), num);
c906108c
SS
192}
193
194void
fba45db2 195annotate_breakpoints_table (void)
c906108c 196{
e5c113a1 197 if (annotation_level == 2)
a3f17187 198 printf_filtered (("\n\032\032breakpoints-table\n"));
c906108c
SS
199}
200
201void
fba45db2 202annotate_record (void)
c906108c 203{
e5c113a1 204 if (annotation_level == 2)
a3f17187 205 printf_filtered (("\n\032\032record\n"));
c906108c
SS
206}
207
208void
fba45db2 209annotate_breakpoints_table_end (void)
c906108c 210{
e5c113a1 211 if (annotation_level == 2)
a3f17187 212 printf_filtered (("\n\032\032breakpoints-table-end\n"));
c906108c
SS
213}
214
215void
fba45db2 216annotate_frames_invalid (void)
c906108c 217{
bd00c694
PA
218 if (annotation_level == 2
219 && (!frames_invalid_emitted
220 || async_background_execution_p ()))
c906108c 221 {
6fdebc3d
PA
222 /* If the inferior owns the terminal (e.g., we're resuming),
223 make sure to leave with the inferior still owning it. */
224 int was_inferior = target_terminal_is_inferior ();
225
226 target_terminal_ours_for_output ();
227
a3f17187 228 printf_unfiltered (("\n\032\032frames-invalid\n"));
6fdebc3d
PA
229
230 if (was_inferior)
231 target_terminal_inferior ();
232
bd00c694 233 frames_invalid_emitted = 1;
c906108c
SS
234 }
235}
236
d17d4947
NR
237void
238annotate_new_thread (void)
239{
240 if (annotation_level > 1)
241 {
242 printf_unfiltered (("\n\032\032new-thread\n"));
243 }
244}
245
b8fa951a
NR
246void
247annotate_thread_changed (void)
248{
249 if (annotation_level > 1)
250 {
251 printf_unfiltered (("\n\032\032thread-changed\n"));
252 }
253}
254
c906108c 255void
fba45db2 256annotate_field_begin (struct type *type)
c906108c 257{
e5c113a1 258 if (annotation_level == 2)
c906108c 259 {
a3f17187 260 printf_filtered (("\n\032\032field-begin "));
c906108c 261 print_value_flags (type);
a3f17187 262 printf_filtered (("\n"));
c906108c
SS
263 }
264}
265
266void
fba45db2 267annotate_field_name_end (void)
c906108c 268{
e5c113a1 269 if (annotation_level == 2)
a3f17187 270 printf_filtered (("\n\032\032field-name-end\n"));
c906108c
SS
271}
272
273void
fba45db2 274annotate_field_value (void)
c906108c 275{
e5c113a1 276 if (annotation_level == 2)
a3f17187 277 printf_filtered (("\n\032\032field-value\n"));
c906108c
SS
278}
279
280void
fba45db2 281annotate_field_end (void)
c906108c 282{
e5c113a1 283 if (annotation_level == 2)
a3f17187 284 printf_filtered (("\n\032\032field-end\n"));
c906108c
SS
285}
286\f
287void
fba45db2 288annotate_quit (void)
c906108c
SS
289{
290 if (annotation_level > 1)
a3f17187 291 printf_filtered (("\n\032\032quit\n"));
c906108c
SS
292}
293
294void
fba45db2 295annotate_error (void)
c906108c
SS
296{
297 if (annotation_level > 1)
a3f17187 298 printf_filtered (("\n\032\032error\n"));
c906108c
SS
299}
300
301void
fba45db2 302annotate_error_begin (void)
c906108c
SS
303{
304 if (annotation_level > 1)
305 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
306}
307
308void
fba45db2 309annotate_value_history_begin (int histindex, struct type *type)
c906108c 310{
e5c113a1 311 if (annotation_level == 2)
c906108c 312 {
a3f17187 313 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
c906108c 314 print_value_flags (type);
a3f17187 315 printf_filtered (("\n"));
c906108c
SS
316 }
317}
318
319void
fba45db2 320annotate_value_begin (struct type *type)
c906108c 321{
e5c113a1 322 if (annotation_level == 2)
c906108c 323 {
a3f17187 324 printf_filtered (("\n\032\032value-begin "));
c906108c 325 print_value_flags (type);
a3f17187 326 printf_filtered (("\n"));
c906108c
SS
327 }
328}
329
330void
fba45db2 331annotate_value_history_value (void)
c906108c 332{
e5c113a1 333 if (annotation_level == 2)
a3f17187 334 printf_filtered (("\n\032\032value-history-value\n"));
c906108c
SS
335}
336
337void
fba45db2 338annotate_value_history_end (void)
c906108c 339{
e5c113a1 340 if (annotation_level == 2)
a3f17187 341 printf_filtered (("\n\032\032value-history-end\n"));
c906108c
SS
342}
343
344void
fba45db2 345annotate_value_end (void)
c906108c 346{
e5c113a1 347 if (annotation_level == 2)
a3f17187 348 printf_filtered (("\n\032\032value-end\n"));
c906108c
SS
349}
350
351void
fba45db2 352annotate_display_begin (void)
c906108c 353{
e5c113a1 354 if (annotation_level == 2)
a3f17187 355 printf_filtered (("\n\032\032display-begin\n"));
c906108c
SS
356}
357
358void
fba45db2 359annotate_display_number_end (void)
c906108c 360{
e5c113a1 361 if (annotation_level == 2)
a3f17187 362 printf_filtered (("\n\032\032display-number-end\n"));
c906108c
SS
363}
364
365void
fba45db2 366annotate_display_format (void)
c906108c 367{
e5c113a1 368 if (annotation_level == 2)
a3f17187 369 printf_filtered (("\n\032\032display-format\n"));
c906108c
SS
370}
371
372void
fba45db2 373annotate_display_expression (void)
c906108c 374{
e5c113a1 375 if (annotation_level == 2)
a3f17187 376 printf_filtered (("\n\032\032display-expression\n"));
c906108c
SS
377}
378
379void
fba45db2 380annotate_display_expression_end (void)
c906108c 381{
e5c113a1 382 if (annotation_level == 2)
a3f17187 383 printf_filtered (("\n\032\032display-expression-end\n"));
c906108c
SS
384}
385
386void
fba45db2 387annotate_display_value (void)
c906108c 388{
e5c113a1 389 if (annotation_level == 2)
a3f17187 390 printf_filtered (("\n\032\032display-value\n"));
c906108c
SS
391}
392
393void
fba45db2 394annotate_display_end (void)
c906108c 395{
e5c113a1 396 if (annotation_level == 2)
a3f17187 397 printf_filtered (("\n\032\032display-end\n"));
c906108c
SS
398}
399
400void
fba45db2 401annotate_arg_begin (void)
c906108c 402{
e5c113a1 403 if (annotation_level == 2)
a3f17187 404 printf_filtered (("\n\032\032arg-begin\n"));
c906108c
SS
405}
406
407void
fba45db2 408annotate_arg_name_end (void)
c906108c 409{
e5c113a1 410 if (annotation_level == 2)
a3f17187 411 printf_filtered (("\n\032\032arg-name-end\n"));
c906108c
SS
412}
413
414void
fba45db2 415annotate_arg_value (struct type *type)
c906108c 416{
e5c113a1 417 if (annotation_level == 2)
c906108c 418 {
a3f17187 419 printf_filtered (("\n\032\032arg-value "));
c906108c 420 print_value_flags (type);
a3f17187 421 printf_filtered (("\n"));
c906108c
SS
422 }
423}
424
425void
fba45db2 426annotate_arg_end (void)
c906108c 427{
e5c113a1 428 if (annotation_level == 2)
a3f17187 429 printf_filtered (("\n\032\032arg-end\n"));
c906108c
SS
430}
431
432void
5af949e3
UW
433annotate_source (char *filename, int line, int character, int mid,
434 struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c
SS
435{
436 if (annotation_level > 1)
a3f17187 437 printf_filtered (("\n\032\032source "));
c906108c 438 else
a3f17187 439 printf_filtered (("\032\032"));
c906108c 440
50ee7535 441 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
5af949e3 442 mid ? "middle" : "beg", paddress (gdbarch, pc));
c906108c
SS
443}
444
445void
5af949e3 446annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
c906108c 447{
24ca4723 448 if (annotation_level > 1)
5af949e3
UW
449 printf_filtered (("\n\032\032frame-begin %d %s\n"),
450 level, paddress (gdbarch, pc));
c906108c
SS
451}
452
453void
fba45db2 454annotate_function_call (void)
c906108c 455{
e5c113a1 456 if (annotation_level == 2)
a3f17187 457 printf_filtered (("\n\032\032function-call\n"));
c906108c
SS
458}
459
460void
fba45db2 461annotate_signal_handler_caller (void)
c906108c 462{
e5c113a1 463 if (annotation_level == 2)
a3f17187 464 printf_filtered (("\n\032\032signal-handler-caller\n"));
c906108c
SS
465}
466
467void
fba45db2 468annotate_frame_address (void)
c906108c 469{
e5c113a1 470 if (annotation_level == 2)
a3f17187 471 printf_filtered (("\n\032\032frame-address\n"));
c906108c
SS
472}
473
474void
fba45db2 475annotate_frame_address_end (void)
c906108c 476{
e5c113a1 477 if (annotation_level == 2)
a3f17187 478 printf_filtered (("\n\032\032frame-address-end\n"));
c906108c
SS
479}
480
481void
fba45db2 482annotate_frame_function_name (void)
c906108c 483{
e5c113a1 484 if (annotation_level == 2)
a3f17187 485 printf_filtered (("\n\032\032frame-function-name\n"));
c906108c
SS
486}
487
488void
fba45db2 489annotate_frame_args (void)
c906108c 490{
e5c113a1 491 if (annotation_level == 2)
a3f17187 492 printf_filtered (("\n\032\032frame-args\n"));
c906108c
SS
493}
494
495void
fba45db2 496annotate_frame_source_begin (void)
c906108c 497{
e5c113a1 498 if (annotation_level == 2)
a3f17187 499 printf_filtered (("\n\032\032frame-source-begin\n"));
c906108c
SS
500}
501
502void
fba45db2 503annotate_frame_source_file (void)
c906108c 504{
e5c113a1 505 if (annotation_level == 2)
a3f17187 506 printf_filtered (("\n\032\032frame-source-file\n"));
c906108c
SS
507}
508
509void
fba45db2 510annotate_frame_source_file_end (void)
c906108c 511{
e5c113a1 512 if (annotation_level == 2)
a3f17187 513 printf_filtered (("\n\032\032frame-source-file-end\n"));
c906108c
SS
514}
515
516void
fba45db2 517annotate_frame_source_line (void)
c906108c 518{
e5c113a1 519 if (annotation_level == 2)
a3f17187 520 printf_filtered (("\n\032\032frame-source-line\n"));
c906108c
SS
521}
522
523void
fba45db2 524annotate_frame_source_end (void)
c906108c 525{
e5c113a1 526 if (annotation_level == 2)
a3f17187 527 printf_filtered (("\n\032\032frame-source-end\n"));
c906108c
SS
528}
529
530void
fba45db2 531annotate_frame_where (void)
c906108c 532{
e5c113a1 533 if (annotation_level == 2)
a3f17187 534 printf_filtered (("\n\032\032frame-where\n"));
c906108c
SS
535}
536
537void
fba45db2 538annotate_frame_end (void)
c906108c 539{
e5c113a1 540 if (annotation_level == 2)
a3f17187 541 printf_filtered (("\n\032\032frame-end\n"));
c906108c
SS
542}
543\f
544void
917793af 545annotate_array_section_begin (int idx, struct type *elttype)
c906108c 546{
e5c113a1 547 if (annotation_level == 2)
c906108c 548 {
917793af 549 printf_filtered (("\n\032\032array-section-begin %d "), idx);
c906108c 550 print_value_flags (elttype);
a3f17187 551 printf_filtered (("\n"));
c906108c
SS
552 }
553}
554
555void
fba45db2 556annotate_elt_rep (unsigned int repcount)
c906108c 557{
e5c113a1 558 if (annotation_level == 2)
a3f17187 559 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
c906108c
SS
560}
561
562void
fba45db2 563annotate_elt_rep_end (void)
c906108c 564{
e5c113a1 565 if (annotation_level == 2)
a3f17187 566 printf_filtered (("\n\032\032elt-rep-end\n"));
c906108c
SS
567}
568
569void
fba45db2 570annotate_elt (void)
c906108c 571{
e5c113a1 572 if (annotation_level == 2)
a3f17187 573 printf_filtered (("\n\032\032elt\n"));
c906108c
SS
574}
575
576void
fba45db2 577annotate_array_section_end (void)
c906108c 578{
e5c113a1 579 if (annotation_level == 2)
a3f17187 580 printf_filtered (("\n\032\032array-section-end\n"));
c906108c
SS
581}
582
bd00c694
PA
583/* Called when GDB is about to display the prompt. Used to reset
584 annotation suppression whenever we're ready to accept new
585 frontend/user commands. */
586
587void
588annotate_display_prompt (void)
589{
590 frames_invalid_emitted = 0;
591 breakpoints_invalid_emitted = 0;
592}
593
c906108c 594static void
8d3788bd 595breakpoint_changed (struct breakpoint *b)
c906108c 596{
0928e93d
PA
597 if (b->number <= 0)
598 return;
599
9c97429f 600 annotate_breakpoints_invalid ();
c906108c
SS
601}
602
603void
fba45db2 604_initialize_annotate (void)
c906108c 605{
9c97429f
PA
606 observer_attach_breakpoint_created (breakpoint_changed);
607 observer_attach_breakpoint_deleted (breakpoint_changed);
608 observer_attach_breakpoint_modified (breakpoint_changed);
c906108c 609}
This page took 0.97338 seconds and 4 git commands to generate.