GDB (API)
|
00001 /* Annotation routines for GDB. 00002 Copyright (C) 1986-2013 Free Software Foundation, Inc. 00003 00004 This file is part of GDB. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00018 00019 #include "defs.h" 00020 #include "annotate.h" 00021 #include "value.h" 00022 #include "target.h" 00023 #include "gdbtypes.h" 00024 #include "breakpoint.h" 00025 #include "observer.h" 00026 #include "inferior.h" 00027 00028 00029 /* Prototypes for local functions. */ 00030 00031 extern void _initialize_annotate (void); 00032 00033 static void print_value_flags (struct type *); 00034 00035 static void breakpoint_changed (struct breakpoint *b); 00036 00037 00038 void (*deprecated_annotate_signalled_hook) (void); 00039 void (*deprecated_annotate_signal_hook) (void); 00040 00041 /* Booleans indicating whether we've emitted certain notifications. 00042 Used to suppress useless repeated notifications until the next time 00043 we're ready to accept more commands. Reset whenever a prompt is 00044 displayed. */ 00045 static int frames_invalid_emitted; 00046 static int breakpoints_invalid_emitted; 00047 00048 /* True if the target can async, and a synchronous execution command 00049 is not in progress. If true, input is accepted, so don't suppress 00050 annotations. */ 00051 00052 static int 00053 async_background_execution_p (void) 00054 { 00055 return (target_can_async_p () && !sync_execution); 00056 } 00057 00058 static void 00059 print_value_flags (struct type *t) 00060 { 00061 if (can_dereference (t)) 00062 printf_filtered (("*")); 00063 else 00064 printf_filtered (("-")); 00065 } 00066 00067 static void 00068 annotate_breakpoints_invalid (void) 00069 { 00070 if (annotation_level == 2 00071 && (!breakpoints_invalid_emitted 00072 || async_background_execution_p ())) 00073 { 00074 target_terminal_ours (); 00075 printf_unfiltered (("\n\032\032breakpoints-invalid\n")); 00076 breakpoints_invalid_emitted = 1; 00077 } 00078 } 00079 00080 void 00081 annotate_breakpoint (int num) 00082 { 00083 if (annotation_level > 1) 00084 printf_filtered (("\n\032\032breakpoint %d\n"), num); 00085 } 00086 00087 void 00088 annotate_catchpoint (int num) 00089 { 00090 if (annotation_level > 1) 00091 printf_filtered (("\n\032\032catchpoint %d\n"), num); 00092 } 00093 00094 void 00095 annotate_watchpoint (int num) 00096 { 00097 if (annotation_level > 1) 00098 printf_filtered (("\n\032\032watchpoint %d\n"), num); 00099 } 00100 00101 void 00102 annotate_starting (void) 00103 { 00104 if (annotation_level > 1) 00105 printf_filtered (("\n\032\032starting\n")); 00106 } 00107 00108 void 00109 annotate_stopped (void) 00110 { 00111 if (annotation_level > 1) 00112 printf_filtered (("\n\032\032stopped\n")); 00113 } 00114 00115 void 00116 annotate_exited (int exitstatus) 00117 { 00118 if (annotation_level > 1) 00119 printf_filtered (("\n\032\032exited %d\n"), exitstatus); 00120 } 00121 00122 void 00123 annotate_signalled (void) 00124 { 00125 if (deprecated_annotate_signalled_hook) 00126 deprecated_annotate_signalled_hook (); 00127 00128 if (annotation_level > 1) 00129 printf_filtered (("\n\032\032signalled\n")); 00130 } 00131 00132 void 00133 annotate_signal_name (void) 00134 { 00135 if (annotation_level == 2) 00136 printf_filtered (("\n\032\032signal-name\n")); 00137 } 00138 00139 void 00140 annotate_signal_name_end (void) 00141 { 00142 if (annotation_level == 2) 00143 printf_filtered (("\n\032\032signal-name-end\n")); 00144 } 00145 00146 void 00147 annotate_signal_string (void) 00148 { 00149 if (annotation_level == 2) 00150 printf_filtered (("\n\032\032signal-string\n")); 00151 } 00152 00153 void 00154 annotate_signal_string_end (void) 00155 { 00156 if (annotation_level == 2) 00157 printf_filtered (("\n\032\032signal-string-end\n")); 00158 } 00159 00160 void 00161 annotate_signal (void) 00162 { 00163 if (deprecated_annotate_signal_hook) 00164 deprecated_annotate_signal_hook (); 00165 00166 if (annotation_level > 1) 00167 printf_filtered (("\n\032\032signal\n")); 00168 } 00169 00170 void 00171 annotate_breakpoints_headers (void) 00172 { 00173 if (annotation_level == 2) 00174 printf_filtered (("\n\032\032breakpoints-headers\n")); 00175 } 00176 00177 void 00178 annotate_field (int num) 00179 { 00180 if (annotation_level == 2) 00181 printf_filtered (("\n\032\032field %d\n"), num); 00182 } 00183 00184 void 00185 annotate_breakpoints_table (void) 00186 { 00187 if (annotation_level == 2) 00188 printf_filtered (("\n\032\032breakpoints-table\n")); 00189 } 00190 00191 void 00192 annotate_record (void) 00193 { 00194 if (annotation_level == 2) 00195 printf_filtered (("\n\032\032record\n")); 00196 } 00197 00198 void 00199 annotate_breakpoints_table_end (void) 00200 { 00201 if (annotation_level == 2) 00202 printf_filtered (("\n\032\032breakpoints-table-end\n")); 00203 } 00204 00205 void 00206 annotate_frames_invalid (void) 00207 { 00208 if (annotation_level == 2 00209 && (!frames_invalid_emitted 00210 || async_background_execution_p ())) 00211 { 00212 target_terminal_ours (); 00213 printf_unfiltered (("\n\032\032frames-invalid\n")); 00214 frames_invalid_emitted = 1; 00215 } 00216 } 00217 00218 void 00219 annotate_new_thread (void) 00220 { 00221 if (annotation_level > 1) 00222 { 00223 printf_unfiltered (("\n\032\032new-thread\n")); 00224 } 00225 } 00226 00227 void 00228 annotate_thread_changed (void) 00229 { 00230 if (annotation_level > 1) 00231 { 00232 printf_unfiltered (("\n\032\032thread-changed\n")); 00233 } 00234 } 00235 00236 void 00237 annotate_field_begin (struct type *type) 00238 { 00239 if (annotation_level == 2) 00240 { 00241 printf_filtered (("\n\032\032field-begin ")); 00242 print_value_flags (type); 00243 printf_filtered (("\n")); 00244 } 00245 } 00246 00247 void 00248 annotate_field_name_end (void) 00249 { 00250 if (annotation_level == 2) 00251 printf_filtered (("\n\032\032field-name-end\n")); 00252 } 00253 00254 void 00255 annotate_field_value (void) 00256 { 00257 if (annotation_level == 2) 00258 printf_filtered (("\n\032\032field-value\n")); 00259 } 00260 00261 void 00262 annotate_field_end (void) 00263 { 00264 if (annotation_level == 2) 00265 printf_filtered (("\n\032\032field-end\n")); 00266 } 00267 00268 void 00269 annotate_quit (void) 00270 { 00271 if (annotation_level > 1) 00272 printf_filtered (("\n\032\032quit\n")); 00273 } 00274 00275 void 00276 annotate_error (void) 00277 { 00278 if (annotation_level > 1) 00279 printf_filtered (("\n\032\032error\n")); 00280 } 00281 00282 void 00283 annotate_error_begin (void) 00284 { 00285 if (annotation_level > 1) 00286 fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n"); 00287 } 00288 00289 void 00290 annotate_value_history_begin (int histindex, struct type *type) 00291 { 00292 if (annotation_level == 2) 00293 { 00294 printf_filtered (("\n\032\032value-history-begin %d "), histindex); 00295 print_value_flags (type); 00296 printf_filtered (("\n")); 00297 } 00298 } 00299 00300 void 00301 annotate_value_begin (struct type *type) 00302 { 00303 if (annotation_level == 2) 00304 { 00305 printf_filtered (("\n\032\032value-begin ")); 00306 print_value_flags (type); 00307 printf_filtered (("\n")); 00308 } 00309 } 00310 00311 void 00312 annotate_value_history_value (void) 00313 { 00314 if (annotation_level == 2) 00315 printf_filtered (("\n\032\032value-history-value\n")); 00316 } 00317 00318 void 00319 annotate_value_history_end (void) 00320 { 00321 if (annotation_level == 2) 00322 printf_filtered (("\n\032\032value-history-end\n")); 00323 } 00324 00325 void 00326 annotate_value_end (void) 00327 { 00328 if (annotation_level == 2) 00329 printf_filtered (("\n\032\032value-end\n")); 00330 } 00331 00332 void 00333 annotate_display_begin (void) 00334 { 00335 if (annotation_level == 2) 00336 printf_filtered (("\n\032\032display-begin\n")); 00337 } 00338 00339 void 00340 annotate_display_number_end (void) 00341 { 00342 if (annotation_level == 2) 00343 printf_filtered (("\n\032\032display-number-end\n")); 00344 } 00345 00346 void 00347 annotate_display_format (void) 00348 { 00349 if (annotation_level == 2) 00350 printf_filtered (("\n\032\032display-format\n")); 00351 } 00352 00353 void 00354 annotate_display_expression (void) 00355 { 00356 if (annotation_level == 2) 00357 printf_filtered (("\n\032\032display-expression\n")); 00358 } 00359 00360 void 00361 annotate_display_expression_end (void) 00362 { 00363 if (annotation_level == 2) 00364 printf_filtered (("\n\032\032display-expression-end\n")); 00365 } 00366 00367 void 00368 annotate_display_value (void) 00369 { 00370 if (annotation_level == 2) 00371 printf_filtered (("\n\032\032display-value\n")); 00372 } 00373 00374 void 00375 annotate_display_end (void) 00376 { 00377 if (annotation_level == 2) 00378 printf_filtered (("\n\032\032display-end\n")); 00379 } 00380 00381 void 00382 annotate_arg_begin (void) 00383 { 00384 if (annotation_level == 2) 00385 printf_filtered (("\n\032\032arg-begin\n")); 00386 } 00387 00388 void 00389 annotate_arg_name_end (void) 00390 { 00391 if (annotation_level == 2) 00392 printf_filtered (("\n\032\032arg-name-end\n")); 00393 } 00394 00395 void 00396 annotate_arg_value (struct type *type) 00397 { 00398 if (annotation_level == 2) 00399 { 00400 printf_filtered (("\n\032\032arg-value ")); 00401 print_value_flags (type); 00402 printf_filtered (("\n")); 00403 } 00404 } 00405 00406 void 00407 annotate_arg_end (void) 00408 { 00409 if (annotation_level == 2) 00410 printf_filtered (("\n\032\032arg-end\n")); 00411 } 00412 00413 void 00414 annotate_source (char *filename, int line, int character, int mid, 00415 struct gdbarch *gdbarch, CORE_ADDR pc) 00416 { 00417 if (annotation_level > 1) 00418 printf_filtered (("\n\032\032source ")); 00419 else 00420 printf_filtered (("\032\032")); 00421 00422 printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character, 00423 mid ? "middle" : "beg", paddress (gdbarch, pc)); 00424 } 00425 00426 void 00427 annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc) 00428 { 00429 if (annotation_level > 1) 00430 printf_filtered (("\n\032\032frame-begin %d %s\n"), 00431 level, paddress (gdbarch, pc)); 00432 } 00433 00434 void 00435 annotate_function_call (void) 00436 { 00437 if (annotation_level == 2) 00438 printf_filtered (("\n\032\032function-call\n")); 00439 } 00440 00441 void 00442 annotate_signal_handler_caller (void) 00443 { 00444 if (annotation_level == 2) 00445 printf_filtered (("\n\032\032signal-handler-caller\n")); 00446 } 00447 00448 void 00449 annotate_frame_address (void) 00450 { 00451 if (annotation_level == 2) 00452 printf_filtered (("\n\032\032frame-address\n")); 00453 } 00454 00455 void 00456 annotate_frame_address_end (void) 00457 { 00458 if (annotation_level == 2) 00459 printf_filtered (("\n\032\032frame-address-end\n")); 00460 } 00461 00462 void 00463 annotate_frame_function_name (void) 00464 { 00465 if (annotation_level == 2) 00466 printf_filtered (("\n\032\032frame-function-name\n")); 00467 } 00468 00469 void 00470 annotate_frame_args (void) 00471 { 00472 if (annotation_level == 2) 00473 printf_filtered (("\n\032\032frame-args\n")); 00474 } 00475 00476 void 00477 annotate_frame_source_begin (void) 00478 { 00479 if (annotation_level == 2) 00480 printf_filtered (("\n\032\032frame-source-begin\n")); 00481 } 00482 00483 void 00484 annotate_frame_source_file (void) 00485 { 00486 if (annotation_level == 2) 00487 printf_filtered (("\n\032\032frame-source-file\n")); 00488 } 00489 00490 void 00491 annotate_frame_source_file_end (void) 00492 { 00493 if (annotation_level == 2) 00494 printf_filtered (("\n\032\032frame-source-file-end\n")); 00495 } 00496 00497 void 00498 annotate_frame_source_line (void) 00499 { 00500 if (annotation_level == 2) 00501 printf_filtered (("\n\032\032frame-source-line\n")); 00502 } 00503 00504 void 00505 annotate_frame_source_end (void) 00506 { 00507 if (annotation_level == 2) 00508 printf_filtered (("\n\032\032frame-source-end\n")); 00509 } 00510 00511 void 00512 annotate_frame_where (void) 00513 { 00514 if (annotation_level == 2) 00515 printf_filtered (("\n\032\032frame-where\n")); 00516 } 00517 00518 void 00519 annotate_frame_end (void) 00520 { 00521 if (annotation_level == 2) 00522 printf_filtered (("\n\032\032frame-end\n")); 00523 } 00524 00525 void 00526 annotate_array_section_begin (int idx, struct type *elttype) 00527 { 00528 if (annotation_level == 2) 00529 { 00530 printf_filtered (("\n\032\032array-section-begin %d "), idx); 00531 print_value_flags (elttype); 00532 printf_filtered (("\n")); 00533 } 00534 } 00535 00536 void 00537 annotate_elt_rep (unsigned int repcount) 00538 { 00539 if (annotation_level == 2) 00540 printf_filtered (("\n\032\032elt-rep %u\n"), repcount); 00541 } 00542 00543 void 00544 annotate_elt_rep_end (void) 00545 { 00546 if (annotation_level == 2) 00547 printf_filtered (("\n\032\032elt-rep-end\n")); 00548 } 00549 00550 void 00551 annotate_elt (void) 00552 { 00553 if (annotation_level == 2) 00554 printf_filtered (("\n\032\032elt\n")); 00555 } 00556 00557 void 00558 annotate_array_section_end (void) 00559 { 00560 if (annotation_level == 2) 00561 printf_filtered (("\n\032\032array-section-end\n")); 00562 } 00563 00564 /* Called when GDB is about to display the prompt. Used to reset 00565 annotation suppression whenever we're ready to accept new 00566 frontend/user commands. */ 00567 00568 void 00569 annotate_display_prompt (void) 00570 { 00571 frames_invalid_emitted = 0; 00572 breakpoints_invalid_emitted = 0; 00573 } 00574 00575 static void 00576 breakpoint_changed (struct breakpoint *b) 00577 { 00578 if (b->number <= 0) 00579 return; 00580 00581 annotate_breakpoints_invalid (); 00582 } 00583 00584 void 00585 _initialize_annotate (void) 00586 { 00587 observer_attach_breakpoint_created (breakpoint_changed); 00588 observer_attach_breakpoint_deleted (breakpoint_changed); 00589 observer_attach_breakpoint_modified (breakpoint_changed); 00590 }