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