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