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