1 /* Debug logging for the symbol file functions for the GNU debugger, GDB.
3 Copyright (C) 2013-2024 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
30 #include "observable.h"
35 #include "filenames.h"
36 #include "cli/cli-style.h"
38 #include "debuginfod-support.h"
40 /* We need to save a pointer to the real symbol functions.
41 Plus, the debug versions are malloc'd because we have to NULL out the
42 ones that are NULL in the real copy. */
44 struct debug_sym_fns_data
46 const struct sym_fns
*real_sf
= nullptr;
47 struct sym_fns debug_sf
{};
50 /* We need to record a pointer to the real set of functions for each
52 static const registry
<objfile
>::key
<debug_sym_fns_data
>
53 symfile_debug_objfile_data_key
;
55 /* If true all calls to the symfile functions are logged. */
56 static bool debug_symfile
= false;
58 /* Return non-zero if symfile debug logging is installed. */
61 symfile_debug_installed (struct objfile
*objfile
)
63 return (objfile
->sf
!= NULL
64 && symfile_debug_objfile_data_key
.get (objfile
) != NULL
);
67 /* Utility return the name to print for SYMTAB. */
70 debug_symtab_name (struct symtab
*symtab
)
72 return symtab_to_filename_for_display (symtab
);
79 objfile::has_partial_symbols ()
83 /* If we have not read psymbols, but we have a function capable of reading
84 them, then that is an indication that they are in fact available. Without
85 this function the symbols may have been already read in but they also may
86 not be present in this objfile. */
87 for (const auto &iter
: qf
)
89 retval
= iter
->has_symbols (this);
95 gdb_printf (gdb_stdlog
, "qf->has_symbols (%s) = %d\n",
96 objfile_debug_name (this), retval
);
101 /* See objfiles.h. */
103 objfile::has_unexpanded_symtabs ()
106 gdb_printf (gdb_stdlog
, "qf->has_unexpanded_symtabs (%s)\n",
107 objfile_debug_name (this));
110 for (const auto &iter
: qf
)
112 if (iter
->has_unexpanded_symtabs (this))
120 gdb_printf (gdb_stdlog
, "qf->has_unexpanded_symtabs (%s) = %d\n",
121 objfile_debug_name (this), (result
? 1 : 0));
127 objfile::find_last_source_symtab ()
129 struct symtab
*retval
= nullptr;
132 gdb_printf (gdb_stdlog
, "qf->find_last_source_symtab (%s)\n",
133 objfile_debug_name (this));
135 for (const auto &iter
: qf
)
137 retval
= iter
->find_last_source_symtab (this);
138 if (retval
!= nullptr)
143 gdb_printf (gdb_stdlog
, "qf->find_last_source_symtab (...) = %s\n",
144 retval
? debug_symtab_name (retval
) : "NULL");
150 objfile::forget_cached_source_info ()
153 gdb_printf (gdb_stdlog
, "qf->forget_cached_source_info (%s)\n",
154 objfile_debug_name (this));
156 for (compunit_symtab
*cu
: compunits ())
158 for (symtab
*s
: cu
->filetabs ())
160 if (s
->fullname
!= NULL
)
168 for (const auto &iter
: qf
)
169 iter
->forget_cached_source_info (this);
173 objfile::map_symtabs_matching_filename
174 (const char *name
, const char *real_path
,
175 gdb::function_view
<bool (symtab
*)> callback
)
178 gdb_printf (gdb_stdlog
,
179 "qf->map_symtabs_matching_filename (%s, \"%s\", "
181 objfile_debug_name (this), name
,
182 real_path
? real_path
: NULL
,
183 host_address_to_string (&callback
));
186 const char *name_basename
= lbasename (name
);
188 auto match_one_filename
= [&] (const char *filename
, bool basenames
)
190 if (compare_filenames_for_search (filename
, name
))
192 if (basenames
&& FILENAME_CMP (name_basename
, filename
) == 0)
194 if (real_path
!= nullptr && IS_ABSOLUTE_PATH (filename
)
195 && IS_ABSOLUTE_PATH (real_path
))
196 return filename_cmp (filename
, real_path
) == 0;
200 compunit_symtab
*last_made
= this->compunit_symtabs
;
202 auto on_expansion
= [&] (compunit_symtab
*symtab
)
204 /* The callback to iterate_over_some_symtabs returns false to keep
205 going and true to continue, so we have to invert the result
206 here, for expand_symtabs_matching. */
207 bool result
= !iterate_over_some_symtabs (name
, real_path
,
208 this->compunit_symtabs
,
211 last_made
= this->compunit_symtabs
;
215 for (const auto &iter
: qf
)
217 if (!iter
->expand_symtabs_matching (this,
223 | SEARCH_STATIC_BLOCK
),
232 gdb_printf (gdb_stdlog
,
233 "qf->map_symtabs_matching_filename (...) = %d\n",
236 /* We must re-invert the return value here to match the caller's
241 struct compunit_symtab
*
242 objfile::lookup_symbol (block_enum kind
, const lookup_name_info
&name
,
243 domain_search_flags domain
)
245 struct compunit_symtab
*retval
= nullptr;
248 gdb_printf (gdb_stdlog
,
249 "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
250 objfile_debug_name (this), kind
, name
.c_str (),
251 domain_name (domain
).c_str ());
253 auto search_one_symtab
= [&] (compunit_symtab
*stab
)
255 struct symbol
*sym
, *with_opaque
= NULL
;
256 const struct blockvector
*bv
= stab
->blockvector ();
257 const struct block
*block
= bv
->block (kind
);
259 sym
= block_find_symbol (block
, name
, domain
, &with_opaque
);
261 /* Some caution must be observed with overloaded functions
262 and methods, since the index will not contain any overload
263 information (but NAME might contain it). */
271 if (with_opaque
!= nullptr)
274 /* Keep looking through other psymtabs. */
278 for (const auto &iter
: qf
)
280 if (!iter
->expand_symtabs_matching (this,
286 ? SEARCH_GLOBAL_BLOCK
287 : SEARCH_STATIC_BLOCK
,
293 gdb_printf (gdb_stdlog
, "qf->lookup_symbol (...) = %s\n",
295 ? debug_symtab_name (retval
->primary_filetab ())
302 objfile::print_stats (bool print_bcache
)
305 gdb_printf (gdb_stdlog
, "qf->print_stats (%s, %d)\n",
306 objfile_debug_name (this), print_bcache
);
308 for (const auto &iter
: qf
)
309 iter
->print_stats (this, print_bcache
);
316 gdb_printf (gdb_stdlog
, "qf->dump (%s)\n",
317 objfile_debug_name (this));
319 for (const auto &iter
: qf
)
324 objfile::expand_symtabs_for_function (const char *func_name
)
327 gdb_printf (gdb_stdlog
,
328 "qf->expand_symtabs_for_function (%s, \"%s\")\n",
329 objfile_debug_name (this), func_name
);
331 lookup_name_info
base_lookup (func_name
, symbol_name_match_type::FULL
);
332 lookup_name_info lookup_name
= base_lookup
.make_ignore_params ();
334 for (const auto &iter
: qf
)
335 iter
->expand_symtabs_matching (this,
341 | SEARCH_STATIC_BLOCK
),
342 SEARCH_FUNCTION_DOMAIN
);
346 objfile::expand_all_symtabs ()
349 gdb_printf (gdb_stdlog
, "qf->expand_all_symtabs (%s)\n",
350 objfile_debug_name (this));
352 for (const auto &iter
: qf
)
353 iter
->expand_all_symtabs (this);
357 objfile::expand_symtabs_with_fullname (const char *fullname
)
360 gdb_printf (gdb_stdlog
,
361 "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
362 objfile_debug_name (this), fullname
);
364 const char *basename
= lbasename (fullname
);
365 auto file_matcher
= [&] (const char *filename
, bool basenames
)
367 return filename_cmp (basenames
? basename
: fullname
, filename
) == 0;
370 for (const auto &iter
: qf
)
371 iter
->expand_symtabs_matching (this,
377 | SEARCH_STATIC_BLOCK
),
382 objfile::expand_symtabs_matching
383 (gdb::function_view
<expand_symtabs_file_matcher_ftype
> file_matcher
,
384 const lookup_name_info
*lookup_name
,
385 gdb::function_view
<expand_symtabs_symbol_matcher_ftype
> symbol_matcher
,
386 gdb::function_view
<expand_symtabs_exp_notify_ftype
> expansion_notify
,
387 block_search_flags search_flags
,
388 domain_search_flags domain
)
390 /* This invariant is documented in quick-functions.h. */
391 gdb_assert (lookup_name
!= nullptr || symbol_matcher
== nullptr);
394 gdb_printf (gdb_stdlog
,
395 "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
396 objfile_debug_name (this),
397 host_address_to_string (&file_matcher
),
398 host_address_to_string (&symbol_matcher
),
399 host_address_to_string (&expansion_notify
),
400 domain_name (domain
).c_str ());
402 for (const auto &iter
: qf
)
403 if (!iter
->expand_symtabs_matching (this, file_matcher
, lookup_name
,
404 symbol_matcher
, expansion_notify
,
405 search_flags
, domain
))
410 struct compunit_symtab
*
411 objfile::find_pc_sect_compunit_symtab (struct bound_minimal_symbol msymbol
,
413 struct obj_section
*section
,
416 struct compunit_symtab
*retval
= nullptr;
419 gdb_printf (gdb_stdlog
,
420 "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
421 objfile_debug_name (this),
422 host_address_to_string (msymbol
.minsym
),
424 host_address_to_string (section
),
427 for (const auto &iter
: qf
)
429 retval
= iter
->find_pc_sect_compunit_symtab (this, msymbol
, pc
, section
,
431 if (retval
!= nullptr)
436 gdb_printf (gdb_stdlog
,
437 "qf->find_pc_sect_compunit_symtab (...) = %s\n",
439 ? debug_symtab_name (retval
->primary_filetab ())
446 objfile::map_symbol_filenames (gdb::function_view
<symbol_filename_ftype
> fun
,
450 gdb_printf (gdb_stdlog
,
451 "qf->map_symbol_filenames (%s, ..., %d)\n",
452 objfile_debug_name (this),
455 for (const auto &iter
: qf
)
456 iter
->map_symbol_filenames (this, fun
, need_fullname
);
460 objfile::compute_main_name ()
463 gdb_printf (gdb_stdlog
,
464 "qf->compute_main_name (%s)\n",
465 objfile_debug_name (this));
467 for (const auto &iter
: qf
)
468 iter
->compute_main_name (this);
471 struct compunit_symtab
*
472 objfile::find_compunit_symtab_by_address (CORE_ADDR address
)
475 gdb_printf (gdb_stdlog
,
476 "qf->find_compunit_symtab_by_address (%s, %s)\n",
477 objfile_debug_name (this),
478 hex_string (address
));
480 struct compunit_symtab
*result
= NULL
;
481 for (const auto &iter
: qf
)
483 result
= iter
->find_compunit_symtab_by_address (this, address
);
484 if (result
!= nullptr)
489 gdb_printf (gdb_stdlog
,
490 "qf->find_compunit_symtab_by_address (...) = %s\n",
492 ? debug_symtab_name (result
->primary_filetab ())
499 objfile::lookup_global_symbol_language (const char *name
,
500 domain_search_flags domain
,
501 bool *symbol_found_p
)
503 enum language result
= language_unknown
;
504 *symbol_found_p
= false;
506 for (const auto &iter
: qf
)
508 result
= iter
->lookup_global_symbol_language (this, name
, domain
,
517 /* Call LOOKUP_FUNC to find the filename of a file containing the separate
518 debug information matching OBJFILE. If LOOKUP_FUNC does return a
519 filename then open this file and return a std::pair containing the
520 gdb_bfd_ref_ptr of the open file and the filename returned by
521 LOOKUP_FUNC, otherwise this function returns an empty pair; the first
522 item will be nullptr, and the second will be an empty string.
524 Any warnings generated by this function, or by calling LOOKUP_FUNC are
525 placed into WARNINGS, these warnings are only displayed to the user if
526 GDB is unable to find the separate debug information via any route. */
527 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
528 simple_find_and_open_separate_symbol_file
529 (struct objfile
*objfile
,
530 std::string (*lookup_func
) (struct objfile
*, deferred_warnings
*),
531 deferred_warnings
*warnings
)
533 std::string filename
= lookup_func (objfile
, warnings
);
535 if (!filename
.empty ())
537 gdb_bfd_ref_ptr symfile_bfd
538 = symfile_bfd_open_no_error (filename
.c_str ());
539 if (symfile_bfd
!= nullptr)
540 return { symfile_bfd
, filename
};
546 /* Lookup separate debug information for OBJFILE via debuginfod. If
547 successful the debug information will be have been downloaded into the
548 debuginfod cache and this function will return a std::pair containing a
549 gdb_bfd_ref_ptr of the open debug information file and the filename for
550 the file within the debuginfod cache. If no debug information could be
551 found then this function returns an empty pair; the first item will be
552 nullptr, and the second will be an empty string. */
554 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
555 debuginfod_find_and_open_separate_symbol_file (struct objfile
* objfile
)
557 const struct bfd_build_id
*build_id
558 = build_id_bfd_get (objfile
->obfd
.get ());
559 const char *filename
= bfd_get_filename (objfile
->obfd
.get ());
561 if (build_id
!= nullptr)
563 gdb::unique_xmalloc_ptr
<char> symfile_path
;
564 scoped_fd
fd (debuginfod_debuginfo_query (build_id
->data
, build_id
->size
,
565 filename
, &symfile_path
));
569 /* File successfully retrieved from server. */
570 gdb_bfd_ref_ptr debug_bfd
571 (symfile_bfd_open_no_error (symfile_path
.get ()));
573 if (debug_bfd
!= nullptr
574 && build_id_verify (debug_bfd
.get (),
575 build_id
->size
, build_id
->data
))
576 return { debug_bfd
, std::string (symfile_path
.get ()) };
583 /* See objfiles.h. */
586 objfile::find_and_add_separate_symbol_file (symfile_add_flags symfile_flags
)
588 bool has_dwarf2
= false;
590 /* Usually we only make a single pass when looking for separate debug
591 information. However, it is possible for an extension language hook
592 to request that GDB make a second pass, in which case max_attempts
593 will be updated, and the loop restarted. */
594 for (unsigned attempt
= 0, max_attempts
= 1;
595 attempt
< max_attempts
&& !has_dwarf2
;
598 gdb_assert (max_attempts
<= 2);
600 deferred_warnings warnings
;
601 gdb_bfd_ref_ptr debug_bfd
;
602 std::string filename
;
604 std::tie (debug_bfd
, filename
)
605 = simple_find_and_open_separate_symbol_file
606 (this, find_separate_debug_file_by_buildid
, &warnings
);
608 if (debug_bfd
== nullptr)
609 std::tie (debug_bfd
, filename
)
610 = simple_find_and_open_separate_symbol_file
611 (this, find_separate_debug_file_by_debuglink
, &warnings
);
613 /* Only try debuginfod on the first attempt. Sure, we could imagine
614 an extension that somehow adds the required debug info to the
615 debuginfod server but, at least for now, we don't support this
616 scenario. Better for the extension to return new debug info
617 directly to GDB. Plus, going to the debuginfod server might be
618 slow, so that's a good argument for only doing this once. */
619 if (debug_bfd
== nullptr && attempt
== 0)
620 std::tie (debug_bfd
, filename
)
621 = debuginfod_find_and_open_separate_symbol_file (this);
623 if (debug_bfd
!= nullptr)
625 /* We found a separate debug info symbol file. If this is our
626 first attempt then setting HAS_DWARF2 will cause us to break
627 from the attempt loop. */
628 symbol_file_add_separate (debug_bfd
, filename
.c_str (),
629 symfile_flags
, this);
632 else if (attempt
== 0)
634 /* Failed to find a separate debug info symbol file. Call out to
635 the extension languages. The user might have registered an
636 extension that can find the debug info for us, or maybe give
637 the user a system specific message that guides them to finding
638 the missing debug info. */
640 ext_lang_missing_debuginfo_result ext_result
641 = ext_lang_handle_missing_debuginfo (this);
642 if (!ext_result
.filename ().empty ())
644 /* Extension found a suitable debug file for us. */
646 = symfile_bfd_open_no_error (ext_result
.filename ().c_str ());
648 if (debug_bfd
!= nullptr)
650 symbol_file_add_separate (debug_bfd
,
651 ext_result
.filename ().c_str (),
652 symfile_flags
, this);
656 else if (ext_result
.try_again ())
663 /* If we still have not got a separate debug symbol file, then
664 emit any warnings we've collected so far. */
673 /* Debugging version of struct sym_probe_fns. */
675 static const std::vector
<std::unique_ptr
<probe
>> &
676 debug_sym_get_probes (struct objfile
*objfile
)
678 const struct debug_sym_fns_data
*debug_data
679 = symfile_debug_objfile_data_key
.get (objfile
);
681 const std::vector
<std::unique_ptr
<probe
>> &retval
682 = debug_data
->real_sf
->sym_probe_fns
->sym_get_probes (objfile
);
684 gdb_printf (gdb_stdlog
,
685 "probes->sym_get_probes (%s) = %s\n",
686 objfile_debug_name (objfile
),
687 host_address_to_string (retval
.data ()));
692 static const struct sym_probe_fns debug_sym_probe_fns
=
694 debug_sym_get_probes
,
697 /* Debugging version of struct sym_fns. */
700 debug_sym_new_init (struct objfile
*objfile
)
702 const struct debug_sym_fns_data
*debug_data
703 = symfile_debug_objfile_data_key
.get (objfile
);
705 gdb_printf (gdb_stdlog
, "sf->sym_new_init (%s)\n",
706 objfile_debug_name (objfile
));
708 debug_data
->real_sf
->sym_new_init (objfile
);
712 debug_sym_init (struct objfile
*objfile
)
714 const struct debug_sym_fns_data
*debug_data
715 = symfile_debug_objfile_data_key
.get (objfile
);
717 gdb_printf (gdb_stdlog
, "sf->sym_init (%s)\n",
718 objfile_debug_name (objfile
));
720 debug_data
->real_sf
->sym_init (objfile
);
724 debug_sym_read (struct objfile
*objfile
, symfile_add_flags symfile_flags
)
726 const struct debug_sym_fns_data
*debug_data
727 = symfile_debug_objfile_data_key
.get (objfile
);
729 gdb_printf (gdb_stdlog
, "sf->sym_read (%s, 0x%x)\n",
730 objfile_debug_name (objfile
), (unsigned) symfile_flags
);
732 debug_data
->real_sf
->sym_read (objfile
, symfile_flags
);
736 debug_sym_finish (struct objfile
*objfile
)
738 const struct debug_sym_fns_data
*debug_data
739 = symfile_debug_objfile_data_key
.get (objfile
);
741 gdb_printf (gdb_stdlog
, "sf->sym_finish (%s)\n",
742 objfile_debug_name (objfile
));
744 debug_data
->real_sf
->sym_finish (objfile
);
748 debug_sym_offsets (struct objfile
*objfile
,
749 const section_addr_info
&info
)
751 const struct debug_sym_fns_data
*debug_data
752 = symfile_debug_objfile_data_key
.get (objfile
);
754 gdb_printf (gdb_stdlog
, "sf->sym_offsets (%s, %s)\n",
755 objfile_debug_name (objfile
),
756 host_address_to_string (&info
));
758 debug_data
->real_sf
->sym_offsets (objfile
, info
);
761 static symfile_segment_data_up
762 debug_sym_segments (bfd
*abfd
)
764 /* This API function is annoying, it doesn't take a "this" pointer.
765 Fortunately it is only used in one place where we (re-)lookup the
766 sym_fns table to use. Thus we will never be called. */
767 gdb_assert_not_reached ("debug_sym_segments called");
771 debug_sym_read_linetable (struct objfile
*objfile
)
773 const struct debug_sym_fns_data
*debug_data
774 = symfile_debug_objfile_data_key
.get (objfile
);
776 gdb_printf (gdb_stdlog
, "sf->sym_read_linetable (%s)\n",
777 objfile_debug_name (objfile
));
779 debug_data
->real_sf
->sym_read_linetable (objfile
);
783 debug_sym_relocate (struct objfile
*objfile
, asection
*sectp
, bfd_byte
*buf
)
785 const struct debug_sym_fns_data
*debug_data
786 = symfile_debug_objfile_data_key
.get (objfile
);
789 retval
= debug_data
->real_sf
->sym_relocate (objfile
, sectp
, buf
);
791 gdb_printf (gdb_stdlog
,
792 "sf->sym_relocate (%s, %s, %s) = %s\n",
793 objfile_debug_name (objfile
),
794 host_address_to_string (sectp
),
795 host_address_to_string (buf
),
796 host_address_to_string (retval
));
801 /* Template of debugging version of struct sym_fns.
802 A copy is made, with sym_flavour updated, and a pointer to the real table
803 installed in real_sf, and then a pointer to the copy is installed in the
806 static const struct sym_fns debug_sym_fns
=
814 debug_sym_read_linetable
,
816 &debug_sym_probe_fns
,
819 /* Install the debugging versions of the symfile functions for OBJFILE.
820 Do not call this if the debug versions are already installed. */
823 install_symfile_debug_logging (struct objfile
*objfile
)
825 const struct sym_fns
*real_sf
;
826 struct debug_sym_fns_data
*debug_data
;
828 /* The debug versions should not already be installed. */
829 gdb_assert (!symfile_debug_installed (objfile
));
831 real_sf
= objfile
->sf
;
833 /* Alas we have to preserve NULL entries in REAL_SF. */
834 debug_data
= new struct debug_sym_fns_data
;
836 #define COPY_SF_PTR(from, to, name, func) \
839 (to)->debug_sf.name = func; \
842 COPY_SF_PTR (real_sf
, debug_data
, sym_new_init
, debug_sym_new_init
);
843 COPY_SF_PTR (real_sf
, debug_data
, sym_init
, debug_sym_init
);
844 COPY_SF_PTR (real_sf
, debug_data
, sym_read
, debug_sym_read
);
845 COPY_SF_PTR (real_sf
, debug_data
, sym_finish
, debug_sym_finish
);
846 COPY_SF_PTR (real_sf
, debug_data
, sym_offsets
, debug_sym_offsets
);
847 COPY_SF_PTR (real_sf
, debug_data
, sym_segments
, debug_sym_segments
);
848 COPY_SF_PTR (real_sf
, debug_data
, sym_read_linetable
,
849 debug_sym_read_linetable
);
850 COPY_SF_PTR (real_sf
, debug_data
, sym_relocate
, debug_sym_relocate
);
851 if (real_sf
->sym_probe_fns
)
852 debug_data
->debug_sf
.sym_probe_fns
= &debug_sym_probe_fns
;
856 debug_data
->real_sf
= real_sf
;
857 symfile_debug_objfile_data_key
.set (objfile
, debug_data
);
858 objfile
->sf
= &debug_data
->debug_sf
;
861 /* Uninstall the debugging versions of the symfile functions for OBJFILE.
862 Do not call this if the debug versions are not installed. */
865 uninstall_symfile_debug_logging (struct objfile
*objfile
)
867 struct debug_sym_fns_data
*debug_data
;
869 /* The debug versions should be currently installed. */
870 gdb_assert (symfile_debug_installed (objfile
));
872 debug_data
= symfile_debug_objfile_data_key
.get (objfile
);
874 objfile
->sf
= debug_data
->real_sf
;
875 symfile_debug_objfile_data_key
.clear (objfile
);
878 /* Call this function to set OBJFILE->SF.
879 Do not set OBJFILE->SF directly. */
882 objfile_set_sym_fns (struct objfile
*objfile
, const struct sym_fns
*sf
)
884 if (symfile_debug_installed (objfile
))
886 gdb_assert (debug_symfile
);
887 /* Remove the current one, and reinstall a new one later. */
888 uninstall_symfile_debug_logging (objfile
);
891 /* Assume debug logging is disabled. */
894 /* Turn debug logging on if enabled. */
896 install_symfile_debug_logging (objfile
);
900 set_debug_symfile (const char *args
, int from_tty
, struct cmd_list_element
*c
)
902 for (struct program_space
*pspace
: program_spaces
)
903 for (objfile
*objfile
: pspace
->objfiles ())
907 if (!symfile_debug_installed (objfile
))
908 install_symfile_debug_logging (objfile
);
912 if (symfile_debug_installed (objfile
))
913 uninstall_symfile_debug_logging (objfile
);
919 show_debug_symfile (struct ui_file
*file
, int from_tty
,
920 struct cmd_list_element
*c
, const char *value
)
922 gdb_printf (file
, _("Symfile debugging is %s.\n"), value
);
925 void _initialize_symfile_debug ();
927 _initialize_symfile_debug ()
929 add_setshow_boolean_cmd ("symfile", no_class
, &debug_symfile
, _("\
930 Set debugging of the symfile functions."), _("\
931 Show debugging of the symfile functions."), _("\
932 When enabled, all calls to the symfile functions are logged."),
933 set_debug_symfile
, show_debug_symfile
,
934 &setdebuglist
, &showdebuglist
);
936 /* Note: We don't need a new-objfile observer because debug logging
937 will be installed when objfile init'n calls objfile_set_sym_fns. */