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