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