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