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