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