1 /* Debug logging for the symbol file functions for the GNU debugger, GDB. 2 3 Copyright (C) 2013-2019 Free Software Foundation, Inc. 4 5 Contributed by Cygnus Support, using pieces from other GDB modules. 6 7 This file is part of GDB. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 21 22 /* Note: Be careful with functions that can throw errors. 23 We want to see a logging message regardless of whether an error was thrown. 24 This typically means printing a message before calling the real function 25 and then if the function returns a result printing a message after it 26 returns. */ 27 28 #include "defs.h" 29 #include "gdbcmd.h" 30 #include "objfiles.h" 31 #include "observable.h" 32 #include "source.h" 33 #include "symtab.h" 34 #include "symfile.h" 35 36 /* We need to save a pointer to the real symbol functions. 37 Plus, the debug versions are malloc'd because we have to NULL out the 38 ones that are NULL in the real copy. */ 39 40 struct debug_sym_fns_data 41 { 42 const struct sym_fns *real_sf; 43 struct sym_fns debug_sf; 44 }; 45 46 /* We need to record a pointer to the real set of functions for each 47 objfile. */ 48 static const struct objfile_data *symfile_debug_objfile_data_key; 49 50 /* If non-zero all calls to the symfile functions are logged. */ 51 static int debug_symfile = 0; 52 53 /* Return non-zero if symfile debug logging is installed. */ 54 55 static int 56 symfile_debug_installed (struct objfile *objfile) 57 { 58 return (objfile->sf != NULL 59 && objfile_data (objfile, symfile_debug_objfile_data_key) != NULL); 60 } 61 62 /* Utility return the name to print for SYMTAB. */ 63 64 static const char * 65 debug_symtab_name (struct symtab *symtab) 66 { 67 return symtab_to_filename_for_display (symtab); 68 } 69 70 /* Debugging version of struct quick_symbol_functions. */ 71 72 static int 73 debug_qf_has_symbols (struct objfile *objfile) 74 { 75 const struct debug_sym_fns_data *debug_data 76 = ((const struct debug_sym_fns_data *) 77 objfile_data (objfile, symfile_debug_objfile_data_key)); 78 int retval; 79 80 retval = debug_data->real_sf->qf->has_symbols (objfile); 81 82 fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n", 83 objfile_debug_name (objfile), retval); 84 85 return retval; 86 } 87 88 static struct symtab * 89 debug_qf_find_last_source_symtab (struct objfile *objfile) 90 { 91 const struct debug_sym_fns_data *debug_data 92 = ((const struct debug_sym_fns_data *) 93 objfile_data (objfile, symfile_debug_objfile_data_key)); 94 struct symtab *retval; 95 96 fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n", 97 objfile_debug_name (objfile)); 98 99 retval = debug_data->real_sf->qf->find_last_source_symtab (objfile); 100 101 fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n", 102 retval ? debug_symtab_name (retval) : "NULL"); 103 104 return retval; 105 } 106 107 static void 108 debug_qf_forget_cached_source_info (struct objfile *objfile) 109 { 110 const struct debug_sym_fns_data *debug_data 111 = ((const struct debug_sym_fns_data *) 112 objfile_data (objfile, symfile_debug_objfile_data_key)); 113 114 fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n", 115 objfile_debug_name (objfile)); 116 117 debug_data->real_sf->qf->forget_cached_source_info (objfile); 118 } 119 120 static bool 121 debug_qf_map_symtabs_matching_filename 122 (struct objfile *objfile, const char *name, const char *real_path, 123 gdb::function_view<bool (symtab *)> callback) 124 { 125 const struct debug_sym_fns_data *debug_data 126 = ((const struct debug_sym_fns_data *) 127 objfile_data (objfile, symfile_debug_objfile_data_key)); 128 129 fprintf_filtered (gdb_stdlog, 130 "qf->map_symtabs_matching_filename (%s, \"%s\", \"%s\", %s)\n", 131 objfile_debug_name (objfile), name, 132 real_path ? real_path : NULL, 133 host_address_to_string (&callback)); 134 135 bool retval = (debug_data->real_sf->qf->map_symtabs_matching_filename 136 (objfile, name, real_path, callback)); 137 138 fprintf_filtered (gdb_stdlog, 139 "qf->map_symtabs_matching_filename (...) = %d\n", 140 retval); 141 142 return retval; 143 } 144 145 static struct compunit_symtab * 146 debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name, 147 domain_enum domain) 148 { 149 const struct debug_sym_fns_data *debug_data 150 = ((const struct debug_sym_fns_data *) 151 objfile_data (objfile, symfile_debug_objfile_data_key)); 152 struct compunit_symtab *retval; 153 154 fprintf_filtered (gdb_stdlog, 155 "qf->lookup_symbol (%s, %d, \"%s\", %s)\n", 156 objfile_debug_name (objfile), kind, name, 157 domain_name (domain)); 158 159 retval = debug_data->real_sf->qf->lookup_symbol (objfile, kind, name, 160 domain); 161 162 fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n", 163 retval 164 ? debug_symtab_name (compunit_primary_filetab (retval)) 165 : "NULL"); 166 167 return retval; 168 } 169 170 static void 171 debug_qf_print_stats (struct objfile *objfile) 172 { 173 const struct debug_sym_fns_data *debug_data 174 = ((const struct debug_sym_fns_data *) 175 objfile_data (objfile, symfile_debug_objfile_data_key)); 176 177 fprintf_filtered (gdb_stdlog, "qf->print_stats (%s)\n", 178 objfile_debug_name (objfile)); 179 180 debug_data->real_sf->qf->print_stats (objfile); 181 } 182 183 static void 184 debug_qf_dump (struct objfile *objfile) 185 { 186 const struct debug_sym_fns_data *debug_data 187 = ((const struct debug_sym_fns_data *) 188 objfile_data (objfile, symfile_debug_objfile_data_key)); 189 190 fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n", 191 objfile_debug_name (objfile)); 192 193 debug_data->real_sf->qf->dump (objfile); 194 } 195 196 static void 197 debug_qf_expand_symtabs_for_function (struct objfile *objfile, 198 const char *func_name) 199 { 200 const struct debug_sym_fns_data *debug_data 201 = ((const struct debug_sym_fns_data *) 202 objfile_data (objfile, symfile_debug_objfile_data_key)); 203 204 fprintf_filtered (gdb_stdlog, 205 "qf->expand_symtabs_for_function (%s, \"%s\")\n", 206 objfile_debug_name (objfile), func_name); 207 208 debug_data->real_sf->qf->expand_symtabs_for_function (objfile, func_name); 209 } 210 211 static void 212 debug_qf_expand_all_symtabs (struct objfile *objfile) 213 { 214 const struct debug_sym_fns_data *debug_data 215 = ((const struct debug_sym_fns_data *) 216 objfile_data (objfile, symfile_debug_objfile_data_key)); 217 218 fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n", 219 objfile_debug_name (objfile)); 220 221 debug_data->real_sf->qf->expand_all_symtabs (objfile); 222 } 223 224 static void 225 debug_qf_expand_symtabs_with_fullname (struct objfile *objfile, 226 const char *fullname) 227 { 228 const struct debug_sym_fns_data *debug_data 229 = ((const struct debug_sym_fns_data *) 230 objfile_data (objfile, symfile_debug_objfile_data_key)); 231 232 fprintf_filtered (gdb_stdlog, 233 "qf->expand_symtabs_with_fullname (%s, \"%s\")\n", 234 objfile_debug_name (objfile), fullname); 235 236 debug_data->real_sf->qf->expand_symtabs_with_fullname (objfile, fullname); 237 } 238 239 static void 240 debug_qf_map_matching_symbols (struct objfile *objfile, 241 const char *name, domain_enum domain, 242 int global, 243 int (*callback) (struct block *, 244 struct symbol *, void *), 245 void *data, 246 symbol_name_match_type match, 247 symbol_compare_ftype *ordered_compare) 248 { 249 const struct debug_sym_fns_data *debug_data 250 = ((const struct debug_sym_fns_data *) 251 objfile_data (objfile, symfile_debug_objfile_data_key)); 252 253 fprintf_filtered (gdb_stdlog, 254 "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n", 255 objfile_debug_name (objfile), name, 256 domain_name (domain), global, 257 host_address_to_string (callback), 258 host_address_to_string (data), 259 plongest ((LONGEST) match), 260 host_address_to_string (ordered_compare)); 261 262 debug_data->real_sf->qf->map_matching_symbols (objfile, name, 263 domain, global, 264 callback, data, 265 match, 266 ordered_compare); 267 } 268 269 static void 270 debug_qf_expand_symtabs_matching 271 (struct objfile *objfile, 272 gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, 273 const lookup_name_info &lookup_name, 274 gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, 275 gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, 276 enum search_domain kind) 277 { 278 const struct debug_sym_fns_data *debug_data 279 = ((const struct debug_sym_fns_data *) 280 objfile_data (objfile, symfile_debug_objfile_data_key)); 281 282 fprintf_filtered (gdb_stdlog, 283 "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n", 284 objfile_debug_name (objfile), 285 host_address_to_string (&file_matcher), 286 host_address_to_string (&symbol_matcher), 287 host_address_to_string (&expansion_notify), 288 search_domain_name (kind)); 289 290 debug_data->real_sf->qf->expand_symtabs_matching (objfile, 291 file_matcher, 292 lookup_name, 293 symbol_matcher, 294 expansion_notify, 295 kind); 296 } 297 298 static struct compunit_symtab * 299 debug_qf_find_pc_sect_compunit_symtab (struct objfile *objfile, 300 struct bound_minimal_symbol msymbol, 301 CORE_ADDR pc, 302 struct obj_section *section, 303 int warn_if_readin) 304 { 305 const struct debug_sym_fns_data *debug_data 306 = ((const struct debug_sym_fns_data *) 307 objfile_data (objfile, symfile_debug_objfile_data_key)); 308 struct compunit_symtab *retval; 309 310 fprintf_filtered (gdb_stdlog, 311 "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n", 312 objfile_debug_name (objfile), 313 host_address_to_string (msymbol.minsym), 314 hex_string (pc), 315 host_address_to_string (section), 316 warn_if_readin); 317 318 retval 319 = debug_data->real_sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol, 320 pc, section, 321 warn_if_readin); 322 323 fprintf_filtered (gdb_stdlog, 324 "qf->find_pc_sect_compunit_symtab (...) = %s\n", 325 retval 326 ? debug_symtab_name (compunit_primary_filetab (retval)) 327 : "NULL"); 328 329 return retval; 330 } 331 332 static void 333 debug_qf_map_symbol_filenames (struct objfile *objfile, 334 symbol_filename_ftype *fun, void *data, 335 int need_fullname) 336 { 337 const struct debug_sym_fns_data *debug_data 338 = ((const struct debug_sym_fns_data *) 339 objfile_data (objfile, symfile_debug_objfile_data_key)); 340 fprintf_filtered (gdb_stdlog, 341 "qf->map_symbol_filenames (%s, %s, %s, %d)\n", 342 objfile_debug_name (objfile), 343 host_address_to_string (fun), 344 host_address_to_string (data), 345 need_fullname); 346 347 debug_data->real_sf->qf->map_symbol_filenames (objfile, fun, data, 348 need_fullname); 349 } 350 351 static struct compunit_symtab * 352 debug_qf_find_compunit_symtab_by_address (struct objfile *objfile, 353 CORE_ADDR address) 354 { 355 const struct debug_sym_fns_data *debug_data 356 = ((const struct debug_sym_fns_data *) 357 objfile_data (objfile, symfile_debug_objfile_data_key)); 358 fprintf_filtered (gdb_stdlog, 359 "qf->find_compunit_symtab_by_address (%s, %s)\n", 360 objfile_debug_name (objfile), 361 hex_string (address)); 362 363 struct compunit_symtab *result = NULL; 364 if (debug_data->real_sf->qf->map_symbol_filenames != NULL) 365 result 366 = debug_data->real_sf->qf->find_compunit_symtab_by_address (objfile, 367 address); 368 369 fprintf_filtered (gdb_stdlog, 370 "qf->find_compunit_symtab_by_address (...) = %s\n", 371 result 372 ? debug_symtab_name (compunit_primary_filetab (result)) 373 : "NULL"); 374 375 return result; 376 } 377 378 static const struct quick_symbol_functions debug_sym_quick_functions = 379 { 380 debug_qf_has_symbols, 381 debug_qf_find_last_source_symtab, 382 debug_qf_forget_cached_source_info, 383 debug_qf_map_symtabs_matching_filename, 384 debug_qf_lookup_symbol, 385 debug_qf_print_stats, 386 debug_qf_dump, 387 debug_qf_expand_symtabs_for_function, 388 debug_qf_expand_all_symtabs, 389 debug_qf_expand_symtabs_with_fullname, 390 debug_qf_map_matching_symbols, 391 debug_qf_expand_symtabs_matching, 392 debug_qf_find_pc_sect_compunit_symtab, 393 debug_qf_find_compunit_symtab_by_address, 394 debug_qf_map_symbol_filenames 395 }; 396 397 /* Debugging version of struct sym_probe_fns. */ 398 399 static const std::vector<probe *> & 400 debug_sym_get_probes (struct objfile *objfile) 401 { 402 const struct debug_sym_fns_data *debug_data 403 = ((const struct debug_sym_fns_data *) 404 objfile_data (objfile, symfile_debug_objfile_data_key)); 405 406 const std::vector<probe *> &retval 407 = debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile); 408 409 fprintf_filtered (gdb_stdlog, 410 "probes->sym_get_probes (%s) = %s\n", 411 objfile_debug_name (objfile), 412 host_address_to_string (retval.data ())); 413 414 return retval; 415 } 416 417 static const struct sym_probe_fns debug_sym_probe_fns = 418 { 419 debug_sym_get_probes, 420 }; 421 422 /* Debugging version of struct sym_fns. */ 423 424 static void 425 debug_sym_new_init (struct objfile *objfile) 426 { 427 const struct debug_sym_fns_data *debug_data 428 = ((const struct debug_sym_fns_data *) 429 objfile_data (objfile, symfile_debug_objfile_data_key)); 430 431 fprintf_filtered (gdb_stdlog, "sf->sym_new_init (%s)\n", 432 objfile_debug_name (objfile)); 433 434 debug_data->real_sf->sym_new_init (objfile); 435 } 436 437 static void 438 debug_sym_init (struct objfile *objfile) 439 { 440 const struct debug_sym_fns_data *debug_data 441 = ((const struct debug_sym_fns_data *) 442 objfile_data (objfile, symfile_debug_objfile_data_key)); 443 444 fprintf_filtered (gdb_stdlog, "sf->sym_init (%s)\n", 445 objfile_debug_name (objfile)); 446 447 debug_data->real_sf->sym_init (objfile); 448 } 449 450 static void 451 debug_sym_read (struct objfile *objfile, symfile_add_flags symfile_flags) 452 { 453 const struct debug_sym_fns_data *debug_data 454 = ((const struct debug_sym_fns_data *) 455 objfile_data (objfile, symfile_debug_objfile_data_key)); 456 457 fprintf_filtered (gdb_stdlog, "sf->sym_read (%s, 0x%x)\n", 458 objfile_debug_name (objfile), (unsigned) symfile_flags); 459 460 debug_data->real_sf->sym_read (objfile, symfile_flags); 461 } 462 463 static void 464 debug_sym_read_psymbols (struct objfile *objfile) 465 { 466 const struct debug_sym_fns_data *debug_data 467 = ((const struct debug_sym_fns_data *) 468 objfile_data (objfile, symfile_debug_objfile_data_key)); 469 470 fprintf_filtered (gdb_stdlog, "sf->sym_read_psymbols (%s)\n", 471 objfile_debug_name (objfile)); 472 473 debug_data->real_sf->sym_read_psymbols (objfile); 474 } 475 476 static void 477 debug_sym_finish (struct objfile *objfile) 478 { 479 const struct debug_sym_fns_data *debug_data 480 = ((const struct debug_sym_fns_data *) 481 objfile_data (objfile, symfile_debug_objfile_data_key)); 482 483 fprintf_filtered (gdb_stdlog, "sf->sym_finish (%s)\n", 484 objfile_debug_name (objfile)); 485 486 debug_data->real_sf->sym_finish (objfile); 487 } 488 489 static void 490 debug_sym_offsets (struct objfile *objfile, 491 const section_addr_info &info) 492 { 493 const struct debug_sym_fns_data *debug_data 494 = ((const struct debug_sym_fns_data *) 495 objfile_data (objfile, symfile_debug_objfile_data_key)); 496 497 fprintf_filtered (gdb_stdlog, "sf->sym_offsets (%s, %s)\n", 498 objfile_debug_name (objfile), 499 host_address_to_string (&info)); 500 501 debug_data->real_sf->sym_offsets (objfile, info); 502 } 503 504 static struct symfile_segment_data * 505 debug_sym_segments (bfd *abfd) 506 { 507 /* This API function is annoying, it doesn't take a "this" pointer. 508 Fortunately it is only used in one place where we (re-)lookup the 509 sym_fns table to use. Thus we will never be called. */ 510 gdb_assert_not_reached ("debug_sym_segments called"); 511 } 512 513 static void 514 debug_sym_read_linetable (struct objfile *objfile) 515 { 516 const struct debug_sym_fns_data *debug_data 517 = ((const struct debug_sym_fns_data *) 518 objfile_data (objfile, symfile_debug_objfile_data_key)); 519 520 fprintf_filtered (gdb_stdlog, "sf->sym_read_linetable (%s)\n", 521 objfile_debug_name (objfile)); 522 523 debug_data->real_sf->sym_read_linetable (objfile); 524 } 525 526 static bfd_byte * 527 debug_sym_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf) 528 { 529 const struct debug_sym_fns_data *debug_data 530 = ((const struct debug_sym_fns_data *) 531 objfile_data (objfile, symfile_debug_objfile_data_key)); 532 bfd_byte *retval; 533 534 retval = debug_data->real_sf->sym_relocate (objfile, sectp, buf); 535 536 fprintf_filtered (gdb_stdlog, 537 "sf->sym_relocate (%s, %s, %s) = %s\n", 538 objfile_debug_name (objfile), 539 host_address_to_string (sectp), 540 host_address_to_string (buf), 541 host_address_to_string (retval)); 542 543 return retval; 544 } 545 546 /* Template of debugging version of struct sym_fns. 547 A copy is made, with sym_flavour updated, and a pointer to the real table 548 installed in real_sf, and then a pointer to the copy is installed in the 549 objfile. */ 550 551 static const struct sym_fns debug_sym_fns = 552 { 553 debug_sym_new_init, 554 debug_sym_init, 555 debug_sym_read, 556 debug_sym_read_psymbols, 557 debug_sym_finish, 558 debug_sym_offsets, 559 debug_sym_segments, 560 debug_sym_read_linetable, 561 debug_sym_relocate, 562 &debug_sym_probe_fns, 563 &debug_sym_quick_functions 564 }; 565 566 /* Free the copy of sym_fns recorded in the registry. */ 567 568 static void 569 symfile_debug_free_objfile (struct objfile *objfile, void *datum) 570 { 571 xfree (datum); 572 } 573 574 /* Install the debugging versions of the symfile functions for OBJFILE. 575 Do not call this if the debug versions are already installed. */ 576 577 static void 578 install_symfile_debug_logging (struct objfile *objfile) 579 { 580 const struct sym_fns *real_sf; 581 struct debug_sym_fns_data *debug_data; 582 583 /* The debug versions should not already be installed. */ 584 gdb_assert (!symfile_debug_installed (objfile)); 585 586 real_sf = objfile->sf; 587 588 /* Alas we have to preserve NULL entries in REAL_SF. */ 589 debug_data = XCNEW (struct debug_sym_fns_data); 590 591 #define COPY_SF_PTR(from, to, name, func) \ 592 do { \ 593 if ((from)->name) \ 594 (to)->debug_sf.name = func; \ 595 } while (0) 596 597 COPY_SF_PTR (real_sf, debug_data, sym_new_init, debug_sym_new_init); 598 COPY_SF_PTR (real_sf, debug_data, sym_init, debug_sym_init); 599 COPY_SF_PTR (real_sf, debug_data, sym_read, debug_sym_read); 600 COPY_SF_PTR (real_sf, debug_data, sym_read_psymbols, 601 debug_sym_read_psymbols); 602 COPY_SF_PTR (real_sf, debug_data, sym_finish, debug_sym_finish); 603 COPY_SF_PTR (real_sf, debug_data, sym_offsets, debug_sym_offsets); 604 COPY_SF_PTR (real_sf, debug_data, sym_segments, debug_sym_segments); 605 COPY_SF_PTR (real_sf, debug_data, sym_read_linetable, 606 debug_sym_read_linetable); 607 COPY_SF_PTR (real_sf, debug_data, sym_relocate, debug_sym_relocate); 608 if (real_sf->sym_probe_fns) 609 debug_data->debug_sf.sym_probe_fns = &debug_sym_probe_fns; 610 debug_data->debug_sf.qf = &debug_sym_quick_functions; 611 612 #undef COPY_SF_PTR 613 614 debug_data->real_sf = real_sf; 615 set_objfile_data (objfile, symfile_debug_objfile_data_key, debug_data); 616 objfile->sf = &debug_data->debug_sf; 617 } 618 619 /* Uninstall the debugging versions of the symfile functions for OBJFILE. 620 Do not call this if the debug versions are not installed. */ 621 622 static void 623 uninstall_symfile_debug_logging (struct objfile *objfile) 624 { 625 struct debug_sym_fns_data *debug_data; 626 627 /* The debug versions should be currently installed. */ 628 gdb_assert (symfile_debug_installed (objfile)); 629 630 debug_data = ((struct debug_sym_fns_data *) 631 objfile_data (objfile, symfile_debug_objfile_data_key)); 632 633 objfile->sf = debug_data->real_sf; 634 xfree (debug_data); 635 set_objfile_data (objfile, symfile_debug_objfile_data_key, NULL); 636 } 637 638 /* Call this function to set OBJFILE->SF. 639 Do not set OBJFILE->SF directly. */ 640 641 void 642 objfile_set_sym_fns (struct objfile *objfile, const struct sym_fns *sf) 643 { 644 if (symfile_debug_installed (objfile)) 645 { 646 gdb_assert (debug_symfile); 647 /* Remove the current one, and reinstall a new one later. */ 648 uninstall_symfile_debug_logging (objfile); 649 } 650 651 /* Assume debug logging is disabled. */ 652 objfile->sf = sf; 653 654 /* Turn debug logging on if enabled. */ 655 if (debug_symfile) 656 install_symfile_debug_logging (objfile); 657 } 658 659 static void 660 set_debug_symfile (const char *args, int from_tty, struct cmd_list_element *c) 661 { 662 struct program_space *pspace; 663 664 ALL_PSPACES (pspace) 665 for (objfile *objfile : pspace->objfiles ()) 666 { 667 if (debug_symfile) 668 { 669 if (!symfile_debug_installed (objfile)) 670 install_symfile_debug_logging (objfile); 671 } 672 else 673 { 674 if (symfile_debug_installed (objfile)) 675 uninstall_symfile_debug_logging (objfile); 676 } 677 } 678 } 679 680 static void 681 show_debug_symfile (struct ui_file *file, int from_tty, 682 struct cmd_list_element *c, const char *value) 683 { 684 fprintf_filtered (file, _("Symfile debugging is %s.\n"), value); 685 } 686 687 void 688 _initialize_symfile_debug (void) 689 { 690 symfile_debug_objfile_data_key 691 = register_objfile_data_with_cleanup (NULL, symfile_debug_free_objfile); 692 693 add_setshow_boolean_cmd ("symfile", no_class, &debug_symfile, _("\ 694 Set debugging of the symfile functions."), _("\ 695 Show debugging of the symfile functions."), _("\ 696 When enabled, all calls to the symfile functions are logged."), 697 set_debug_symfile, show_debug_symfile, 698 &setdebuglist, &showdebuglist); 699 700 /* Note: We don't need a new-objfile observer because debug logging 701 will be installed when objfile init'n calls objfile_set_sym_fns. */ 702 } 703