1 /* Debug logging for the symbol file functions for the GNU debugger, GDB.
3 Copyright (C) 2013-2025 Free Software Foundation, Inc.
5 Contributed by Cygnus Support, using pieces from other GDB modules.
7 This file is part of GDB.
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.
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.
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/>. */
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
28 #include "cli/cli-cmds.h"
30 #include "observable.h"
35 #include "filenames.h"
37 #include "debuginfod-support.h"
39 /* We need to save a pointer to the real symbol functions.
40 Plus, the debug versions are malloc'd because we have to NULL out the
41 ones that are NULL in the real copy. */
43 struct debug_sym_fns_data
45 const struct sym_fns
*real_sf
= nullptr;
46 struct sym_fns debug_sf
{};
49 /* We need to record a pointer to the real set of functions for each
51 static const registry
<objfile
>::key
<debug_sym_fns_data
>
52 symfile_debug_objfile_data_key
;
54 /* If true all calls to the symfile functions are logged. */
55 static bool debug_symfile
= false;
57 /* Return non-zero if symfile debug logging is installed. */
60 symfile_debug_installed (struct objfile
*objfile
)
62 return (objfile
->sf
!= NULL
63 && symfile_debug_objfile_data_key
.get (objfile
) != NULL
);
66 /* Utility return the name to print for SYMTAB. */
69 debug_symtab_name (struct symtab
*symtab
)
71 return symtab_to_filename_for_display (symtab
);
78 objfile::has_partial_symbols ()
82 /* If we have not read psymbols, but we have a function capable of reading
83 them, then that is an indication that they are in fact available. Without
84 this function the symbols may have been already read in but they also may
85 not be present in this objfile. */
86 for (const auto &iter
: qf
)
88 retval
= iter
->has_symbols (this);
94 gdb_printf (gdb_stdlog
, "qf->has_symbols (%s) = %d\n",
95 objfile_debug_name (this), retval
);
100 /* See objfiles.h. */
102 objfile::has_unexpanded_symtabs ()
105 gdb_printf (gdb_stdlog
, "qf->has_unexpanded_symtabs (%s)\n",
106 objfile_debug_name (this));
109 for (const auto &iter
: qf
)
111 if (iter
->has_unexpanded_symtabs (this))
119 gdb_printf (gdb_stdlog
, "qf->has_unexpanded_symtabs (%s) = %d\n",
120 objfile_debug_name (this), (result
? 1 : 0));
126 objfile::find_last_source_symtab ()
128 struct symtab
*retval
= nullptr;
131 gdb_printf (gdb_stdlog
, "qf->find_last_source_symtab (%s)\n",
132 objfile_debug_name (this));
134 for (const auto &iter
: qf
)
136 retval
= iter
->find_last_source_symtab (this);
137 if (retval
!= nullptr)
142 gdb_printf (gdb_stdlog
, "qf->find_last_source_symtab (...) = %s\n",
143 retval
? debug_symtab_name (retval
) : "NULL");
149 objfile::forget_cached_source_info ()
152 gdb_printf (gdb_stdlog
, "qf->forget_cached_source_info (%s)\n",
153 objfile_debug_name (this));
155 for (compunit_symtab
*cu
: compunits ())
156 cu
->forget_cached_source_info ();
158 for (const auto &iter
: qf
)
159 iter
->forget_cached_source_info (this);
163 objfile::map_symtabs_matching_filename
164 (const char *name
, const char *real_path
,
165 gdb::function_view
<bool (symtab
*)> callback
)
168 gdb_printf (gdb_stdlog
,
169 "qf->map_symtabs_matching_filename (%s, \"%s\", "
171 objfile_debug_name (this), name
,
172 real_path
? real_path
: NULL
,
173 host_address_to_string (&callback
));
176 const char *name_basename
= lbasename (name
);
178 auto match_one_filename
= [&] (const char *filename
, bool basenames
)
180 if (compare_filenames_for_search (filename
, name
))
182 if (basenames
&& FILENAME_CMP (name_basename
, filename
) == 0)
184 if (real_path
!= nullptr && IS_ABSOLUTE_PATH (filename
)
185 && IS_ABSOLUTE_PATH (real_path
))
186 return filename_cmp (filename
, real_path
) == 0;
190 compunit_symtab
*last_made
= this->compunit_symtabs
;
192 auto on_expansion
= [&] (compunit_symtab
*symtab
)
194 /* The callback to iterate_over_some_symtabs returns false to keep
195 going and true to continue, so we have to invert the result
196 here, for expand_symtabs_matching. */
197 bool result
= !iterate_over_some_symtabs (name
, real_path
,
198 this->compunit_symtabs
,
201 last_made
= this->compunit_symtabs
;
205 for (const auto &iter
: qf
)
207 if (!iter
->expand_symtabs_matching (this,
213 | SEARCH_STATIC_BLOCK
),
222 gdb_printf (gdb_stdlog
,
223 "qf->map_symtabs_matching_filename (...) = %d\n",
226 /* We must re-invert the return value here to match the caller's
231 struct compunit_symtab
*
232 objfile::lookup_symbol (block_enum kind
, const lookup_name_info
&name
,
233 domain_search_flags domain
)
235 struct compunit_symtab
*retval
= nullptr;
238 gdb_printf (gdb_stdlog
,
239 "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
240 objfile_debug_name (this), kind
, name
.c_str (),
241 domain_name (domain
).c_str ());
243 auto search_one_symtab
= [&] (compunit_symtab
*stab
)
245 struct symbol
*sym
, *with_opaque
= NULL
;
246 const struct blockvector
*bv
= stab
->blockvector ();
247 const struct block
*block
= bv
->block (kind
);
249 sym
= block_find_symbol (block
, name
, domain
, &with_opaque
);
251 /* Some caution must be observed with overloaded functions
252 and methods, since the index will not contain any overload
253 information (but NAME might contain it). */
261 if (with_opaque
!= nullptr)
264 /* Keep looking through other psymtabs. */
268 for (const auto &iter
: qf
)
270 if (!iter
->expand_symtabs_matching (this,
276 ? SEARCH_GLOBAL_BLOCK
277 : SEARCH_STATIC_BLOCK
,
283 gdb_printf (gdb_stdlog
, "qf->lookup_symbol (...) = %s\n",
285 ? debug_symtab_name (retval
->primary_filetab ())
292 objfile::print_stats (bool print_bcache
)
295 gdb_printf (gdb_stdlog
, "qf->print_stats (%s, %d)\n",
296 objfile_debug_name (this), print_bcache
);
298 for (const auto &iter
: qf
)
299 iter
->print_stats (this, print_bcache
);
306 gdb_printf (gdb_stdlog
, "qf->dump (%s)\n",
307 objfile_debug_name (this));
309 for (const auto &iter
: qf
)
314 objfile::expand_symtabs_for_function (const char *func_name
)
317 gdb_printf (gdb_stdlog
,
318 "qf->expand_symtabs_for_function (%s, \"%s\")\n",
319 objfile_debug_name (this), func_name
);
321 lookup_name_info
base_lookup (func_name
, symbol_name_match_type::FULL
);
322 lookup_name_info lookup_name
= base_lookup
.make_ignore_params ();
324 for (const auto &iter
: qf
)
325 iter
->expand_symtabs_matching (this,
331 | SEARCH_STATIC_BLOCK
),
332 SEARCH_FUNCTION_DOMAIN
);
336 objfile::expand_all_symtabs ()
339 gdb_printf (gdb_stdlog
, "qf->expand_all_symtabs (%s)\n",
340 objfile_debug_name (this));
342 for (const auto &iter
: qf
)
343 iter
->expand_all_symtabs (this);
347 objfile::expand_symtabs_with_fullname (const char *fullname
)
350 gdb_printf (gdb_stdlog
,
351 "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
352 objfile_debug_name (this), fullname
);
354 const char *basename
= lbasename (fullname
);
355 auto file_matcher
= [&] (const char *filename
, bool basenames
)
357 return filename_cmp (basenames
? basename
: fullname
, filename
) == 0;
360 for (const auto &iter
: qf
)
361 iter
->expand_symtabs_matching (this,
367 | SEARCH_STATIC_BLOCK
),
372 objfile::expand_symtabs_matching
373 (expand_symtabs_file_matcher file_matcher
,
374 const lookup_name_info
*lookup_name
,
375 expand_symtabs_symbol_matcher symbol_matcher
,
376 expand_symtabs_expansion_listener expansion_notify
,
377 block_search_flags search_flags
,
378 domain_search_flags domain
,
379 expand_symtabs_lang_matcher lang_matcher
)
381 /* This invariant is documented in quick-functions.h. */
382 gdb_assert (lookup_name
!= nullptr || symbol_matcher
== nullptr);
385 gdb_printf (gdb_stdlog
,
386 "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
387 objfile_debug_name (this),
388 host_address_to_string (&file_matcher
),
389 host_address_to_string (&symbol_matcher
),
390 host_address_to_string (&expansion_notify
),
391 domain_name (domain
).c_str ());
393 for (const auto &iter
: qf
)
394 if (!iter
->expand_symtabs_matching (this, file_matcher
, lookup_name
,
395 symbol_matcher
, expansion_notify
,
396 search_flags
, domain
,
402 struct compunit_symtab
*
403 objfile::find_pc_sect_compunit_symtab (bound_minimal_symbol msymbol
,
405 struct obj_section
*section
,
408 struct compunit_symtab
*retval
= nullptr;
411 gdb_printf (gdb_stdlog
,
412 "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
413 objfile_debug_name (this),
414 host_address_to_string (msymbol
.minsym
),
416 host_address_to_string (section
),
419 for (const auto &iter
: qf
)
421 retval
= iter
->find_pc_sect_compunit_symtab (this, msymbol
, pc
, section
,
423 if (retval
!= nullptr)
428 gdb_printf (gdb_stdlog
,
429 "qf->find_pc_sect_compunit_symtab (...) = %s\n",
431 ? debug_symtab_name (retval
->primary_filetab ())
438 objfile::map_symbol_filenames (symbol_filename_listener fun
, bool need_fullname
)
441 gdb_printf (gdb_stdlog
,
442 "qf->map_symbol_filenames (%s, ..., %d)\n",
443 objfile_debug_name (this),
446 for (const auto &iter
: qf
)
447 iter
->map_symbol_filenames (this, fun
, need_fullname
);
451 objfile::compute_main_name ()
454 gdb_printf (gdb_stdlog
,
455 "qf->compute_main_name (%s)\n",
456 objfile_debug_name (this));
458 for (const auto &iter
: qf
)
459 iter
->compute_main_name (this);
462 struct compunit_symtab
*
463 objfile::find_compunit_symtab_by_address (CORE_ADDR address
)
466 gdb_printf (gdb_stdlog
,
467 "qf->find_compunit_symtab_by_address (%s, %s)\n",
468 objfile_debug_name (this),
469 hex_string (address
));
471 struct compunit_symtab
*result
= NULL
;
472 for (const auto &iter
: qf
)
474 result
= iter
->find_compunit_symtab_by_address (this, address
);
475 if (result
!= nullptr)
480 gdb_printf (gdb_stdlog
,
481 "qf->find_compunit_symtab_by_address (...) = %s\n",
483 ? debug_symtab_name (result
->primary_filetab ())
490 objfile::lookup_global_symbol_language (const char *name
,
491 domain_search_flags domain
,
492 bool *symbol_found_p
)
494 enum language result
= language_unknown
;
495 *symbol_found_p
= false;
497 for (const auto &iter
: qf
)
499 result
= iter
->lookup_global_symbol_language (this, name
, domain
,
508 /* Call LOOKUP_FUNC to find the filename of a file containing the separate
509 debug information matching OBJFILE. If LOOKUP_FUNC does return a
510 filename then open this file and return a std::pair containing the
511 gdb_bfd_ref_ptr of the open file and the filename returned by
512 LOOKUP_FUNC, otherwise this function returns an empty pair; the first
513 item will be nullptr, and the second will be an empty string.
515 Any warnings generated by this function, or by calling LOOKUP_FUNC are
516 placed into WARNINGS, these warnings are only displayed to the user if
517 GDB is unable to find the separate debug information via any route. */
518 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
519 simple_find_and_open_separate_symbol_file
520 (struct objfile
*objfile
,
521 std::string (*lookup_func
) (struct objfile
*, deferred_warnings
*),
522 deferred_warnings
*warnings
)
524 std::string filename
= lookup_func (objfile
, warnings
);
526 if (!filename
.empty ())
528 gdb_bfd_ref_ptr symfile_bfd
529 = symfile_bfd_open_no_error (filename
.c_str ());
530 if (symfile_bfd
!= nullptr)
531 return { symfile_bfd
, filename
};
537 /* Lookup separate debug information for OBJFILE via debuginfod. If
538 successful the debug information will be have been downloaded into the
539 debuginfod cache and this function will return a std::pair containing a
540 gdb_bfd_ref_ptr of the open debug information file and the filename for
541 the file within the debuginfod cache. If no debug information could be
542 found then this function returns an empty pair; the first item will be
543 nullptr, and the second will be an empty string. */
545 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
546 debuginfod_find_and_open_separate_symbol_file (struct objfile
* objfile
)
548 const struct bfd_build_id
*build_id
549 = build_id_bfd_get (objfile
->obfd
.get ());
550 const char *filename
= bfd_get_filename (objfile
->obfd
.get ());
552 if (build_id
!= nullptr)
554 gdb::unique_xmalloc_ptr
<char> symfile_path
;
555 scoped_fd
fd (debuginfod_debuginfo_query (build_id
->data
, build_id
->size
,
556 filename
, &symfile_path
));
560 /* File successfully retrieved from server. */
561 gdb_bfd_ref_ptr debug_bfd
562 (symfile_bfd_open_no_error (symfile_path
.get ()));
564 if (debug_bfd
!= nullptr
565 && build_id_verify (debug_bfd
.get (),
566 build_id
->size
, build_id
->data
))
567 return { debug_bfd
, std::string (symfile_path
.get ()) };
574 /* See objfiles.h. */
577 objfile::find_and_add_separate_symbol_file (symfile_add_flags symfile_flags
)
579 bool has_dwarf2
= false;
581 /* Usually we only make a single pass when looking for separate debug
582 information. However, it is possible for an extension language hook
583 to request that GDB make a second pass, in which case max_attempts
584 will be updated, and the loop restarted. */
585 for (unsigned attempt
= 0, max_attempts
= 1;
586 attempt
< max_attempts
&& !has_dwarf2
;
589 gdb_assert (max_attempts
<= 2);
591 deferred_warnings warnings
;
592 gdb_bfd_ref_ptr debug_bfd
;
593 std::string filename
;
595 std::tie (debug_bfd
, filename
)
596 = simple_find_and_open_separate_symbol_file
597 (this, find_separate_debug_file_by_buildid
, &warnings
);
599 if (debug_bfd
== nullptr)
600 std::tie (debug_bfd
, filename
)
601 = simple_find_and_open_separate_symbol_file
602 (this, find_separate_debug_file_by_debuglink
, &warnings
);
604 /* Only try debuginfod on the first attempt. Sure, we could imagine
605 an extension that somehow adds the required debug info to the
606 debuginfod server but, at least for now, we don't support this
607 scenario. Better for the extension to return new debug info
608 directly to GDB. Plus, going to the debuginfod server might be
609 slow, so that's a good argument for only doing this once. */
610 if (debug_bfd
== nullptr && attempt
== 0)
611 std::tie (debug_bfd
, filename
)
612 = debuginfod_find_and_open_separate_symbol_file (this);
614 if (debug_bfd
!= nullptr)
616 /* We found a separate debug info symbol file. If this is our
617 first attempt then setting HAS_DWARF2 will cause us to break
618 from the attempt loop. */
619 symbol_file_add_separate (debug_bfd
, filename
.c_str (),
620 symfile_flags
, this);
623 else if (attempt
== 0)
625 /* Failed to find a separate debug info symbol file. Call out to
626 the extension languages. The user might have registered an
627 extension that can find the debug info for us, or maybe give
628 the user a system specific message that guides them to finding
629 the missing debug info. */
631 ext_lang_missing_file_result ext_result
632 = ext_lang_handle_missing_debuginfo (this);
633 if (!ext_result
.filename ().empty ())
635 /* Extension found a suitable debug file for us. */
637 = symfile_bfd_open_no_error (ext_result
.filename ().c_str ());
639 if (debug_bfd
!= nullptr)
641 symbol_file_add_separate (debug_bfd
,
642 ext_result
.filename ().c_str (),
643 symfile_flags
, this);
647 else if (ext_result
.try_again ())
654 /* If we still have not got a separate debug symbol file, then
655 emit any warnings we've collected so far. */
664 /* Debugging version of struct sym_probe_fns. */
666 static const std::vector
<std::unique_ptr
<probe
>> &
667 debug_sym_get_probes (struct objfile
*objfile
)
669 const struct debug_sym_fns_data
*debug_data
670 = symfile_debug_objfile_data_key
.get (objfile
);
672 const std::vector
<std::unique_ptr
<probe
>> &retval
673 = debug_data
->real_sf
->sym_probe_fns
->sym_get_probes (objfile
);
675 gdb_printf (gdb_stdlog
,
676 "probes->sym_get_probes (%s) = %s\n",
677 objfile_debug_name (objfile
),
678 host_address_to_string (retval
.data ()));
683 static const struct sym_probe_fns debug_sym_probe_fns
=
685 debug_sym_get_probes
,
688 /* Debugging version of struct sym_fns. */
691 debug_sym_new_init (struct objfile
*objfile
)
693 const struct debug_sym_fns_data
*debug_data
694 = symfile_debug_objfile_data_key
.get (objfile
);
696 gdb_printf (gdb_stdlog
, "sf->sym_new_init (%s)\n",
697 objfile_debug_name (objfile
));
699 debug_data
->real_sf
->sym_new_init (objfile
);
703 debug_sym_init (struct objfile
*objfile
)
705 const struct debug_sym_fns_data
*debug_data
706 = symfile_debug_objfile_data_key
.get (objfile
);
708 gdb_printf (gdb_stdlog
, "sf->sym_init (%s)\n",
709 objfile_debug_name (objfile
));
711 debug_data
->real_sf
->sym_init (objfile
);
715 debug_sym_read (struct objfile
*objfile
, symfile_add_flags symfile_flags
)
717 const struct debug_sym_fns_data
*debug_data
718 = symfile_debug_objfile_data_key
.get (objfile
);
720 gdb_printf (gdb_stdlog
, "sf->sym_read (%s, 0x%x)\n",
721 objfile_debug_name (objfile
), (unsigned) symfile_flags
);
723 debug_data
->real_sf
->sym_read (objfile
, symfile_flags
);
727 debug_sym_finish (struct objfile
*objfile
)
729 const struct debug_sym_fns_data
*debug_data
730 = symfile_debug_objfile_data_key
.get (objfile
);
732 gdb_printf (gdb_stdlog
, "sf->sym_finish (%s)\n",
733 objfile_debug_name (objfile
));
735 debug_data
->real_sf
->sym_finish (objfile
);
739 debug_sym_offsets (struct objfile
*objfile
,
740 const section_addr_info
&info
)
742 const struct debug_sym_fns_data
*debug_data
743 = symfile_debug_objfile_data_key
.get (objfile
);
745 gdb_printf (gdb_stdlog
, "sf->sym_offsets (%s, %s)\n",
746 objfile_debug_name (objfile
),
747 host_address_to_string (&info
));
749 debug_data
->real_sf
->sym_offsets (objfile
, info
);
752 static symfile_segment_data_up
753 debug_sym_segments (bfd
*abfd
)
755 /* This API function is annoying, it doesn't take a "this" pointer.
756 Fortunately it is only used in one place where we (re-)lookup the
757 sym_fns table to use. Thus we will never be called. */
758 gdb_assert_not_reached ("debug_sym_segments called");
762 debug_sym_read_linetable (struct objfile
*objfile
)
764 const struct debug_sym_fns_data
*debug_data
765 = symfile_debug_objfile_data_key
.get (objfile
);
767 gdb_printf (gdb_stdlog
, "sf->sym_read_linetable (%s)\n",
768 objfile_debug_name (objfile
));
770 debug_data
->real_sf
->sym_read_linetable (objfile
);
774 debug_sym_relocate (struct objfile
*objfile
, asection
*sectp
, bfd_byte
*buf
)
776 const struct debug_sym_fns_data
*debug_data
777 = symfile_debug_objfile_data_key
.get (objfile
);
780 retval
= debug_data
->real_sf
->sym_relocate (objfile
, sectp
, buf
);
782 gdb_printf (gdb_stdlog
,
783 "sf->sym_relocate (%s, %s, %s) = %s\n",
784 objfile_debug_name (objfile
),
785 host_address_to_string (sectp
),
786 host_address_to_string (buf
),
787 host_address_to_string (retval
));
792 /* Install the debugging versions of the symfile functions for OBJFILE.
793 Do not call this if the debug versions are already installed. */
796 install_symfile_debug_logging (struct objfile
*objfile
)
798 const struct sym_fns
*real_sf
;
799 struct debug_sym_fns_data
*debug_data
;
801 /* The debug versions should not already be installed. */
802 gdb_assert (!symfile_debug_installed (objfile
));
804 real_sf
= objfile
->sf
;
806 /* Alas we have to preserve NULL entries in REAL_SF. */
807 debug_data
= new struct debug_sym_fns_data
;
809 #define COPY_SF_PTR(from, to, name, func) \
812 (to)->debug_sf.name = func; \
815 COPY_SF_PTR (real_sf
, debug_data
, sym_new_init
, debug_sym_new_init
);
816 COPY_SF_PTR (real_sf
, debug_data
, sym_init
, debug_sym_init
);
817 COPY_SF_PTR (real_sf
, debug_data
, sym_read
, debug_sym_read
);
818 COPY_SF_PTR (real_sf
, debug_data
, sym_finish
, debug_sym_finish
);
819 COPY_SF_PTR (real_sf
, debug_data
, sym_offsets
, debug_sym_offsets
);
820 COPY_SF_PTR (real_sf
, debug_data
, sym_segments
, debug_sym_segments
);
821 COPY_SF_PTR (real_sf
, debug_data
, sym_read_linetable
,
822 debug_sym_read_linetable
);
823 COPY_SF_PTR (real_sf
, debug_data
, sym_relocate
, debug_sym_relocate
);
824 if (real_sf
->sym_probe_fns
)
825 debug_data
->debug_sf
.sym_probe_fns
= &debug_sym_probe_fns
;
829 debug_data
->real_sf
= real_sf
;
830 symfile_debug_objfile_data_key
.set (objfile
, debug_data
);
831 objfile
->sf
= &debug_data
->debug_sf
;
834 /* Uninstall the debugging versions of the symfile functions for OBJFILE.
835 Do not call this if the debug versions are not installed. */
838 uninstall_symfile_debug_logging (struct objfile
*objfile
)
840 struct debug_sym_fns_data
*debug_data
;
842 /* The debug versions should be currently installed. */
843 gdb_assert (symfile_debug_installed (objfile
));
845 debug_data
= symfile_debug_objfile_data_key
.get (objfile
);
847 objfile
->sf
= debug_data
->real_sf
;
848 symfile_debug_objfile_data_key
.clear (objfile
);
851 /* Call this function to set OBJFILE->SF.
852 Do not set OBJFILE->SF directly. */
855 objfile_set_sym_fns (struct objfile
*objfile
, const struct sym_fns
*sf
)
857 if (symfile_debug_installed (objfile
))
859 gdb_assert (debug_symfile
);
860 /* Remove the current one, and reinstall a new one later. */
861 uninstall_symfile_debug_logging (objfile
);
864 /* Assume debug logging is disabled. */
867 /* Turn debug logging on if enabled. */
869 install_symfile_debug_logging (objfile
);
873 set_debug_symfile (const char *args
, int from_tty
, struct cmd_list_element
*c
)
875 for (struct program_space
*pspace
: program_spaces
)
876 for (objfile
*objfile
: pspace
->objfiles ())
880 if (!symfile_debug_installed (objfile
))
881 install_symfile_debug_logging (objfile
);
885 if (symfile_debug_installed (objfile
))
886 uninstall_symfile_debug_logging (objfile
);
892 show_debug_symfile (struct ui_file
*file
, int from_tty
,
893 struct cmd_list_element
*c
, const char *value
)
895 gdb_printf (file
, _("Symfile debugging is %s.\n"), value
);
898 INIT_GDB_FILE (symfile_debug
)
900 add_setshow_boolean_cmd ("symfile", no_class
, &debug_symfile
, _("\
901 Set debugging of the symfile functions."), _("\
902 Show debugging of the symfile functions."), _("\
903 When enabled, all calls to the symfile functions are logged."),
904 set_debug_symfile
, show_debug_symfile
,
905 &setdebuglist
, &showdebuglist
);
907 /* Note: We don't need a new-objfile observer because debug logging
908 will be installed when objfile init'n calls objfile_set_sym_fns. */