gdb/
[deliverable/binutils-gdb.git] / gdb / annotate.c
... / ...
CommitLineData
1/* Annotation routines for GDB.
2 Copyright (C) 1986, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999,
3 2000, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "annotate.h"
22#include "value.h"
23#include "target.h"
24#include "gdbtypes.h"
25#include "breakpoint.h"
26#include "observer.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
41static int ignore_count_changed = 0;
42
43static void
44print_value_flags (struct type *t)
45{
46 if (can_dereference (t))
47 printf_filtered (("*"));
48 else
49 printf_filtered (("-"));
50}
51\f
52void
53breakpoints_changed (void)
54{
55 if (annotation_level == 2)
56 {
57 target_terminal_ours ();
58 printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
59 if (ignore_count_changed)
60 ignore_count_changed = 0; /* Avoid multiple break annotations. */
61 }
62}
63
64/* The GUI needs to be informed of ignore_count changes, but we don't
65 want to provide successive multiple breakpoints-invalid messages
66 that are all caused by the fact that the ignore count is changing
67 (which could keep the GUI very busy). One is enough, after the
68 target actually "stops". */
69
70void
71annotate_ignore_count_change (void)
72{
73 if (annotation_level > 1)
74 ignore_count_changed = 1;
75}
76
77void
78annotate_breakpoint (int num)
79{
80 if (annotation_level > 1)
81 printf_filtered (("\n\032\032breakpoint %d\n"), num);
82}
83
84void
85annotate_catchpoint (int num)
86{
87 if (annotation_level > 1)
88 printf_filtered (("\n\032\032catchpoint %d\n"), num);
89}
90
91void
92annotate_watchpoint (int num)
93{
94 if (annotation_level > 1)
95 printf_filtered (("\n\032\032watchpoint %d\n"), num);
96}
97
98void
99annotate_starting (void)
100{
101 if (annotation_level > 1)
102 printf_filtered (("\n\032\032starting\n"));
103}
104
105void
106annotate_stopped (void)
107{
108 if (annotation_level > 1)
109 printf_filtered (("\n\032\032stopped\n"));
110 if (annotation_level > 1 && ignore_count_changed)
111 {
112 ignore_count_changed = 0;
113 breakpoints_changed ();
114 }
115}
116
117void
118annotate_exited (int exitstatus)
119{
120 if (annotation_level > 1)
121 printf_filtered (("\n\032\032exited %d\n"), exitstatus);
122}
123
124void
125annotate_signalled (void)
126{
127 if (deprecated_annotate_signalled_hook)
128 deprecated_annotate_signalled_hook ();
129
130 if (annotation_level > 1)
131 printf_filtered (("\n\032\032signalled\n"));
132}
133
134void
135annotate_signal_name (void)
136{
137 if (annotation_level == 2)
138 printf_filtered (("\n\032\032signal-name\n"));
139}
140
141void
142annotate_signal_name_end (void)
143{
144 if (annotation_level == 2)
145 printf_filtered (("\n\032\032signal-name-end\n"));
146}
147
148void
149annotate_signal_string (void)
150{
151 if (annotation_level == 2)
152 printf_filtered (("\n\032\032signal-string\n"));
153}
154
155void
156annotate_signal_string_end (void)
157{
158 if (annotation_level == 2)
159 printf_filtered (("\n\032\032signal-string-end\n"));
160}
161
162void
163annotate_signal (void)
164{
165 if (deprecated_annotate_signal_hook)
166 deprecated_annotate_signal_hook ();
167
168 if (annotation_level > 1)
169 printf_filtered (("\n\032\032signal\n"));
170}
171\f
172void
173annotate_breakpoints_headers (void)
174{
175 if (annotation_level == 2)
176 printf_filtered (("\n\032\032breakpoints-headers\n"));
177}
178
179void
180annotate_field (int num)
181{
182 if (annotation_level == 2)
183 printf_filtered (("\n\032\032field %d\n"), num);
184}
185
186void
187annotate_breakpoints_table (void)
188{
189 if (annotation_level == 2)
190 printf_filtered (("\n\032\032breakpoints-table\n"));
191}
192
193void
194annotate_record (void)
195{
196 if (annotation_level == 2)
197 printf_filtered (("\n\032\032record\n"));
198}
199
200void
201annotate_breakpoints_table_end (void)
202{
203 if (annotation_level == 2)
204 printf_filtered (("\n\032\032breakpoints-table-end\n"));
205}
206
207void
208annotate_frames_invalid (void)
209{
210 if (annotation_level == 2)
211 {
212 target_terminal_ours ();
213 printf_unfiltered (("\n\032\032frames-invalid\n"));
214 }
215}
216
217void
218annotate_new_thread (void)
219{
220 if (annotation_level > 1)
221 {
222 printf_unfiltered (("\n\032\032new-thread\n"));
223 }
224}
225
226void
227annotate_thread_changed (void)
228{
229 if (annotation_level > 1)
230 {
231 printf_unfiltered (("\n\032\032thread-changed\n"));
232 }
233}
234
235void
236annotate_field_begin (struct type *type)
237{
238 if (annotation_level == 2)
239 {
240 printf_filtered (("\n\032\032field-begin "));
241 print_value_flags (type);
242 printf_filtered (("\n"));
243 }
244}
245
246void
247annotate_field_name_end (void)
248{
249 if (annotation_level == 2)
250 printf_filtered (("\n\032\032field-name-end\n"));
251}
252
253void
254annotate_field_value (void)
255{
256 if (annotation_level == 2)
257 printf_filtered (("\n\032\032field-value\n"));
258}
259
260void
261annotate_field_end (void)
262{
263 if (annotation_level == 2)
264 printf_filtered (("\n\032\032field-end\n"));
265}
266\f
267void
268annotate_quit (void)
269{
270 if (annotation_level > 1)
271 printf_filtered (("\n\032\032quit\n"));
272}
273
274void
275annotate_error (void)
276{
277 if (annotation_level > 1)
278 printf_filtered (("\n\032\032error\n"));
279}
280
281void
282annotate_error_begin (void)
283{
284 if (annotation_level > 1)
285 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
286}
287
288void
289annotate_value_history_begin (int histindex, struct type *type)
290{
291 if (annotation_level == 2)
292 {
293 printf_filtered (("\n\032\032value-history-begin %d "), histindex);
294 print_value_flags (type);
295 printf_filtered (("\n"));
296 }
297}
298
299void
300annotate_value_begin (struct type *type)
301{
302 if (annotation_level == 2)
303 {
304 printf_filtered (("\n\032\032value-begin "));
305 print_value_flags (type);
306 printf_filtered (("\n"));
307 }
308}
309
310void
311annotate_value_history_value (void)
312{
313 if (annotation_level == 2)
314 printf_filtered (("\n\032\032value-history-value\n"));
315}
316
317void
318annotate_value_history_end (void)
319{
320 if (annotation_level == 2)
321 printf_filtered (("\n\032\032value-history-end\n"));
322}
323
324void
325annotate_value_end (void)
326{
327 if (annotation_level == 2)
328 printf_filtered (("\n\032\032value-end\n"));
329}
330
331void
332annotate_display_begin (void)
333{
334 if (annotation_level == 2)
335 printf_filtered (("\n\032\032display-begin\n"));
336}
337
338void
339annotate_display_number_end (void)
340{
341 if (annotation_level == 2)
342 printf_filtered (("\n\032\032display-number-end\n"));
343}
344
345void
346annotate_display_format (void)
347{
348 if (annotation_level == 2)
349 printf_filtered (("\n\032\032display-format\n"));
350}
351
352void
353annotate_display_expression (void)
354{
355 if (annotation_level == 2)
356 printf_filtered (("\n\032\032display-expression\n"));
357}
358
359void
360annotate_display_expression_end (void)
361{
362 if (annotation_level == 2)
363 printf_filtered (("\n\032\032display-expression-end\n"));
364}
365
366void
367annotate_display_value (void)
368{
369 if (annotation_level == 2)
370 printf_filtered (("\n\032\032display-value\n"));
371}
372
373void
374annotate_display_end (void)
375{
376 if (annotation_level == 2)
377 printf_filtered (("\n\032\032display-end\n"));
378}
379
380void
381annotate_arg_begin (void)
382{
383 if (annotation_level == 2)
384 printf_filtered (("\n\032\032arg-begin\n"));
385}
386
387void
388annotate_arg_name_end (void)
389{
390 if (annotation_level == 2)
391 printf_filtered (("\n\032\032arg-name-end\n"));
392}
393
394void
395annotate_arg_value (struct type *type)
396{
397 if (annotation_level == 2)
398 {
399 printf_filtered (("\n\032\032arg-value "));
400 print_value_flags (type);
401 printf_filtered (("\n"));
402 }
403}
404
405void
406annotate_arg_end (void)
407{
408 if (annotation_level == 2)
409 printf_filtered (("\n\032\032arg-end\n"));
410}
411
412void
413annotate_source (char *filename, int line, int character, int mid,
414 struct gdbarch *gdbarch, CORE_ADDR pc)
415{
416 if (annotation_level > 1)
417 printf_filtered (("\n\032\032source "));
418 else
419 printf_filtered (("\032\032"));
420
421 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
422 mid ? "middle" : "beg", paddress (gdbarch, pc));
423}
424
425void
426annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
427{
428 if (annotation_level > 1)
429 printf_filtered (("\n\032\032frame-begin %d %s\n"),
430 level, paddress (gdbarch, pc));
431}
432
433void
434annotate_function_call (void)
435{
436 if (annotation_level == 2)
437 printf_filtered (("\n\032\032function-call\n"));
438}
439
440void
441annotate_signal_handler_caller (void)
442{
443 if (annotation_level == 2)
444 printf_filtered (("\n\032\032signal-handler-caller\n"));
445}
446
447void
448annotate_frame_address (void)
449{
450 if (annotation_level == 2)
451 printf_filtered (("\n\032\032frame-address\n"));
452}
453
454void
455annotate_frame_address_end (void)
456{
457 if (annotation_level == 2)
458 printf_filtered (("\n\032\032frame-address-end\n"));
459}
460
461void
462annotate_frame_function_name (void)
463{
464 if (annotation_level == 2)
465 printf_filtered (("\n\032\032frame-function-name\n"));
466}
467
468void
469annotate_frame_args (void)
470{
471 if (annotation_level == 2)
472 printf_filtered (("\n\032\032frame-args\n"));
473}
474
475void
476annotate_frame_source_begin (void)
477{
478 if (annotation_level == 2)
479 printf_filtered (("\n\032\032frame-source-begin\n"));
480}
481
482void
483annotate_frame_source_file (void)
484{
485 if (annotation_level == 2)
486 printf_filtered (("\n\032\032frame-source-file\n"));
487}
488
489void
490annotate_frame_source_file_end (void)
491{
492 if (annotation_level == 2)
493 printf_filtered (("\n\032\032frame-source-file-end\n"));
494}
495
496void
497annotate_frame_source_line (void)
498{
499 if (annotation_level == 2)
500 printf_filtered (("\n\032\032frame-source-line\n"));
501}
502
503void
504annotate_frame_source_end (void)
505{
506 if (annotation_level == 2)
507 printf_filtered (("\n\032\032frame-source-end\n"));
508}
509
510void
511annotate_frame_where (void)
512{
513 if (annotation_level == 2)
514 printf_filtered (("\n\032\032frame-where\n"));
515}
516
517void
518annotate_frame_end (void)
519{
520 if (annotation_level == 2)
521 printf_filtered (("\n\032\032frame-end\n"));
522}
523\f
524void
525annotate_array_section_begin (int index, struct type *elttype)
526{
527 if (annotation_level == 2)
528 {
529 printf_filtered (("\n\032\032array-section-begin %d "), index);
530 print_value_flags (elttype);
531 printf_filtered (("\n"));
532 }
533}
534
535void
536annotate_elt_rep (unsigned int repcount)
537{
538 if (annotation_level == 2)
539 printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
540}
541
542void
543annotate_elt_rep_end (void)
544{
545 if (annotation_level == 2)
546 printf_filtered (("\n\032\032elt-rep-end\n"));
547}
548
549void
550annotate_elt (void)
551{
552 if (annotation_level == 2)
553 printf_filtered (("\n\032\032elt\n"));
554}
555
556void
557annotate_array_section_end (void)
558{
559 if (annotation_level == 2)
560 printf_filtered (("\n\032\032array-section-end\n"));
561}
562
563static void
564breakpoint_changed (struct breakpoint *b)
565{
566 breakpoints_changed ();
567}
568
569void
570_initialize_annotate (void)
571{
572 if (annotation_level == 2)
573 {
574 observer_attach_breakpoint_deleted (breakpoint_changed);
575 observer_attach_breakpoint_modified (breakpoint_changed);
576 }
577}
This page took 0.02685 seconds and 4 git commands to generate.