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