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
31 #include "observable.h"
36 #include "filenames.h"
37 #include "cli/cli-style.h"
39 #include "debuginfod-support.h"
41 /* We need to save a pointer to the real symbol functions.
42 Plus, the debug versions are malloc'd because we have to NULL out the
43 ones that are NULL in the real copy. */
45 struct debug_sym_fns_data
47 const struct sym_fns
*real_sf
= nullptr;
48 struct sym_fns debug_sf
{};
51 /* We need to record a pointer to the real set of functions for each
53 static const registry
<objfile
>::key
<debug_sym_fns_data
>
54 symfile_debug_objfile_data_key
;
56 /* If true all calls to the symfile functions are logged. */
57 static bool debug_symfile
= false;
59 /* Return non-zero if symfile debug logging is installed. */
62 symfile_debug_installed (struct objfile
*objfile
)
64 return (objfile
->sf
!= NULL
65 && symfile_debug_objfile_data_key
.get (objfile
) != NULL
);
68 /* Utility return the name to print for SYMTAB. */
71 debug_symtab_name (struct symtab
*symtab
)
73 return symtab_to_filename_for_display (symtab
);
80 objfile::has_partial_symbols ()
84 /* If we have not read psymbols, but we have a function capable of reading
85 them, then that is an indication that they are in fact available. Without
86 this function the symbols may have been already read in but they also may
87 not be present in this objfile. */
88 for (const auto &iter
: qf
)
90 retval
= iter
->has_symbols (this);
96 gdb_printf (gdb_stdlog
, "qf->has_symbols (%s) = %d\n",
97 objfile_debug_name (this), retval
);
102 /* See objfiles.h. */
104 objfile::has_unexpanded_symtabs ()
107 gdb_printf (gdb_stdlog
, "qf->has_unexpanded_symtabs (%s)\n",
108 objfile_debug_name (this));
111 for (const auto &iter
: qf
)
113 if (iter
->has_unexpanded_symtabs (this))
121 gdb_printf (gdb_stdlog
, "qf->has_unexpanded_symtabs (%s) = %d\n",
122 objfile_debug_name (this), (result
? 1 : 0));
128 objfile::find_last_source_symtab ()
130 struct symtab
*retval
= nullptr;
133 gdb_printf (gdb_stdlog
, "qf->find_last_source_symtab (%s)\n",
134 objfile_debug_name (this));
136 for (const auto &iter
: qf
)
138 retval
= iter
->find_last_source_symtab (this);
139 if (retval
!= nullptr)
144 gdb_printf (gdb_stdlog
, "qf->find_last_source_symtab (...) = %s\n",
145 retval
? debug_symtab_name (retval
) : "NULL");
151 objfile::forget_cached_source_info ()
154 gdb_printf (gdb_stdlog
, "qf->forget_cached_source_info (%s)\n",
155 objfile_debug_name (this));
157 for (compunit_symtab
*cu
: compunits ())
159 for (symtab
*s
: cu
->filetabs ())
161 if (s
->fullname
!= NULL
)
169 for (const auto &iter
: qf
)
170 iter
->forget_cached_source_info (this);
174 objfile::map_symtabs_matching_filename
175 (const char *name
, const char *real_path
,
176 gdb::function_view
<bool (symtab
*)> callback
)
179 gdb_printf (gdb_stdlog
,
180 "qf->map_symtabs_matching_filename (%s, \"%s\", "
182 objfile_debug_name (this), name
,
183 real_path
? real_path
: NULL
,
184 host_address_to_string (&callback
));
187 const char *name_basename
= lbasename (name
);
189 auto match_one_filename
= [&] (const char *filename
, bool basenames
)
191 if (compare_filenames_for_search (filename
, name
))
193 if (basenames
&& FILENAME_CMP (name_basename
, filename
) == 0)
195 if (real_path
!= nullptr && IS_ABSOLUTE_PATH (filename
)
196 && IS_ABSOLUTE_PATH (real_path
))
197 return filename_cmp (filename
, real_path
) == 0;
201 compunit_symtab
*last_made
= this->compunit_symtabs
;
203 auto on_expansion
= [&] (compunit_symtab
*symtab
)
205 /* The callback to iterate_over_some_symtabs returns false to keep
206 going and true to continue, so we have to invert the result
207 here, for expand_symtabs_matching. */
208 bool result
= !iterate_over_some_symtabs (name
, real_path
,
209 this->compunit_symtabs
,
212 last_made
= this->compunit_symtabs
;
216 for (const auto &iter
: qf
)
218 if (!iter
->expand_symtabs_matching (this,
224 | SEARCH_STATIC_BLOCK
),
234 gdb_printf (gdb_stdlog
,
235 "qf->map_symtabs_matching_filename (...) = %d\n",
238 /* We must re-invert the return value here to match the caller's
243 struct compunit_symtab
*
244 objfile::lookup_symbol (block_enum kind
, const char *name
, domain_enum domain
)
246 struct compunit_symtab
*retval
= nullptr;
249 gdb_printf (gdb_stdlog
,
250 "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
251 objfile_debug_name (this), kind
, name
,
252 domain_name (domain
));
254 lookup_name_info
lookup_name (name
, symbol_name_match_type::FULL
);
256 auto search_one_symtab
= [&] (compunit_symtab
*stab
)
258 struct symbol
*sym
, *with_opaque
= NULL
;
259 const struct blockvector
*bv
= stab
->blockvector ();
260 const struct block
*block
= bv
->block (kind
);
262 sym
= block_find_symbol (block
, lookup_name
, domain
, &with_opaque
);
264 /* Some caution must be observed with overloaded functions
265 and methods, since the index will not contain any overload
266 information (but NAME might contain it). */
274 if (with_opaque
!= nullptr)
277 /* Keep looking through other psymtabs. */
281 for (const auto &iter
: qf
)
283 if (!iter
->expand_symtabs_matching (this,
289 ? SEARCH_GLOBAL_BLOCK
290 : SEARCH_STATIC_BLOCK
,
297 gdb_printf (gdb_stdlog
, "qf->lookup_symbol (...) = %s\n",
299 ? debug_symtab_name (retval
->primary_filetab ())
306 objfile::print_stats (bool print_bcache
)
309 gdb_printf (gdb_stdlog
, "qf->print_stats (%s, %d)\n",
310 objfile_debug_name (this), print_bcache
);
312 for (const auto &iter
: qf
)
313 iter
->print_stats (this, print_bcache
);
320 gdb_printf (gdb_stdlog
, "qf->dump (%s)\n",
321 objfile_debug_name (this));
323 for (const auto &iter
: qf
)
328 objfile::expand_symtabs_for_function (const char *func_name
)
331 gdb_printf (gdb_stdlog
,
332 "qf->expand_symtabs_for_function (%s, \"%s\")\n",
333 objfile_debug_name (this), func_name
);
335 lookup_name_info
base_lookup (func_name
, symbol_name_match_type::FULL
);
336 lookup_name_info lookup_name
= base_lookup
.make_ignore_params ();
338 for (const auto &iter
: qf
)
339 iter
->expand_symtabs_matching (this,
345 | SEARCH_STATIC_BLOCK
),
351 objfile::expand_all_symtabs ()
354 gdb_printf (gdb_stdlog
, "qf->expand_all_symtabs (%s)\n",
355 objfile_debug_name (this));
357 for (const auto &iter
: qf
)
358 iter
->expand_all_symtabs (this);
362 objfile::expand_symtabs_with_fullname (const char *fullname
)
365 gdb_printf (gdb_stdlog
,
366 "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
367 objfile_debug_name (this), fullname
);
369 const char *basename
= lbasename (fullname
);
370 auto file_matcher
= [&] (const char *filename
, bool basenames
)
372 return filename_cmp (basenames
? basename
: fullname
, filename
) == 0;
375 for (const auto &iter
: qf
)
376 iter
->expand_symtabs_matching (this,
382 | SEARCH_STATIC_BLOCK
),
388 objfile::expand_symtabs_matching
389 (gdb::function_view
<expand_symtabs_file_matcher_ftype
> file_matcher
,
390 const lookup_name_info
*lookup_name
,
391 gdb::function_view
<expand_symtabs_symbol_matcher_ftype
> symbol_matcher
,
392 gdb::function_view
<expand_symtabs_exp_notify_ftype
> expansion_notify
,
393 block_search_flags search_flags
,
395 enum search_domain kind
)
397 /* This invariant is documented in quick-functions.h. */
398 gdb_assert (lookup_name
!= nullptr || symbol_matcher
== nullptr);
401 gdb_printf (gdb_stdlog
,
402 "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
403 objfile_debug_name (this),
404 host_address_to_string (&file_matcher
),
405 host_address_to_string (&symbol_matcher
),
406 host_address_to_string (&expansion_notify
),
407 search_domain_name (kind
));
409 for (const auto &iter
: qf
)
410 if (!iter
->expand_symtabs_matching (this, file_matcher
, lookup_name
,
411 symbol_matcher
, expansion_notify
,
412 search_flags
, domain
, kind
))
417 struct compunit_symtab
*
418 objfile::find_pc_sect_compunit_symtab (struct bound_minimal_symbol msymbol
,
420 struct obj_section
*section
,
423 struct compunit_symtab
*retval
= nullptr;
426 gdb_printf (gdb_stdlog
,
427 "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
428 objfile_debug_name (this),
429 host_address_to_string (msymbol
.minsym
),
431 host_address_to_string (section
),
434 for (const auto &iter
: qf
)
436 retval
= iter
->find_pc_sect_compunit_symtab (this, msymbol
, pc
, section
,
438 if (retval
!= nullptr)
443 gdb_printf (gdb_stdlog
,
444 "qf->find_pc_sect_compunit_symtab (...) = %s\n",
446 ? debug_symtab_name (retval
->primary_filetab ())
453 objfile::map_symbol_filenames (gdb::function_view
<symbol_filename_ftype
> fun
,
457 gdb_printf (gdb_stdlog
,
458 "qf->map_symbol_filenames (%s, ..., %d)\n",
459 objfile_debug_name (this),
462 for (const auto &iter
: qf
)
463 iter
->map_symbol_filenames (this, fun
, need_fullname
);
467 objfile::compute_main_name ()
470 gdb_printf (gdb_stdlog
,
471 "qf->compute_main_name (%s)\n",
472 objfile_debug_name (this));
474 for (const auto &iter
: qf
)
475 iter
->compute_main_name (this);
478 struct compunit_symtab
*
479 objfile::find_compunit_symtab_by_address (CORE_ADDR address
)
482 gdb_printf (gdb_stdlog
,
483 "qf->find_compunit_symtab_by_address (%s, %s)\n",
484 objfile_debug_name (this),
485 hex_string (address
));
487 struct compunit_symtab
*result
= NULL
;
488 for (const auto &iter
: qf
)
490 result
= iter
->find_compunit_symtab_by_address (this, address
);
491 if (result
!= nullptr)
496 gdb_printf (gdb_stdlog
,
497 "qf->find_compunit_symtab_by_address (...) = %s\n",
499 ? debug_symtab_name (result
->primary_filetab ())
506 objfile::lookup_global_symbol_language (const char *name
,
508 bool *symbol_found_p
)
510 enum language result
= language_unknown
;
511 *symbol_found_p
= false;
513 for (const auto &iter
: qf
)
515 result
= iter
->lookup_global_symbol_language (this, name
, domain
,
524 /* Call LOOKUP_FUNC to find the filename of a file containing the separate
525 debug information matching OBJFILE. If LOOKUP_FUNC does return a
526 filename then open this file and return a std::pair containing the
527 gdb_bfd_ref_ptr of the open file and the filename returned by
528 LOOKUP_FUNC, otherwise this function returns an empty pair; the first
529 item will be nullptr, and the second will be an empty string.
531 Any warnings generated by this function, or by calling LOOKUP_FUNC are
532 placed into WARNINGS, these warnings are only displayed to the user if
533 GDB is unable to find the separate debug information via any route. */
534 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
535 simple_find_and_open_separate_symbol_file
536 (struct objfile
*objfile
,
537 std::string (*lookup_func
) (struct objfile
*, deferred_warnings
*),
538 deferred_warnings
*warnings
)
540 std::string filename
= lookup_func (objfile
, warnings
);
542 if (!filename
.empty ())
544 gdb_bfd_ref_ptr symfile_bfd
545 = symfile_bfd_open_no_error (filename
.c_str ());
546 if (symfile_bfd
!= nullptr)
547 return { symfile_bfd
, filename
};
553 /* Lookup separate debug information for OBJFILE via debuginfod. If
554 successful the debug information will be have been downloaded into the
555 debuginfod cache and this function will return a std::pair containing a
556 gdb_bfd_ref_ptr of the open debug information file and the filename for
557 the file within the debuginfod cache. If no debug information could be
558 found then this function returns an empty pair; the first item will be
559 nullptr, and the second will be an empty string. */
561 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
562 debuginfod_find_and_open_separate_symbol_file (struct objfile
* objfile
)
564 const struct bfd_build_id
*build_id
565 = build_id_bfd_get (objfile
->obfd
.get ());
566 const char *filename
= bfd_get_filename (objfile
->obfd
.get ());
568 if (build_id
!= nullptr)
570 gdb::unique_xmalloc_ptr
<char> symfile_path
;
571 scoped_fd
fd (debuginfod_debuginfo_query (build_id
->data
, build_id
->size
,
572 filename
, &symfile_path
));
576 /* File successfully retrieved from server. */
577 gdb_bfd_ref_ptr debug_bfd
578 (symfile_bfd_open_no_error (symfile_path
.get ()));
580 if (debug_bfd
!= nullptr
581 && build_id_verify (debug_bfd
.get (),
582 build_id
->size
, build_id
->data
))
583 return { debug_bfd
, std::string (symfile_path
.get ()) };
590 /* See objfiles.h. */
593 objfile::find_and_add_separate_symbol_file (symfile_add_flags symfile_flags
)
595 bool has_dwarf2
= false;
597 /* Usually we only make a single pass when looking for separate debug
598 information. However, it is possible for an extension language hook
599 to request that GDB make a second pass, in which case max_attempts
600 will be updated, and the loop restarted. */
601 for (unsigned attempt
= 0, max_attempts
= 1;
602 attempt
< max_attempts
&& !has_dwarf2
;
605 gdb_assert (max_attempts
<= 2);
607 deferred_warnings warnings
;
608 gdb_bfd_ref_ptr debug_bfd
;
609 std::string filename
;
611 std::tie (debug_bfd
, filename
)
612 = simple_find_and_open_separate_symbol_file
613 (this, find_separate_debug_file_by_buildid
, &warnings
);
615 if (debug_bfd
== nullptr)
616 std::tie (debug_bfd
, filename
)
617 = simple_find_and_open_separate_symbol_file
618 (this, find_separate_debug_file_by_debuglink
, &warnings
);
620 /* Only try debuginfod on the first attempt. Sure, we could imagine
621 an extension that somehow adds the required debug info to the
622 debuginfod server but, at least for now, we don't support this
623 scenario. Better for the extension to return new debug info
624 directly to GDB. Plus, going to the debuginfod server might be
625 slow, so that's a good argument for only doing this once. */
626 if (debug_bfd
== nullptr && attempt
== 0)
627 std::tie (debug_bfd
, filename
)
628 = debuginfod_find_and_open_separate_symbol_file (this);
630 if (debug_bfd
!= nullptr)
632 /* We found a separate debug info symbol file. If this is our
633 first attempt then setting HAS_DWARF2 will cause us to break
634 from the attempt loop. */
635 symbol_file_add_separate (debug_bfd
, filename
.c_str (),
636 symfile_flags
, this);
639 else if (attempt
== 0)
641 /* Failed to find a separate debug info symbol file. Call out to
642 the extension languages. The user might have registered an
643 extension that can find the debug info for us, or maybe give
644 the user a system specific message that guides them to finding
645 the missing debug info. */
647 ext_lang_missing_debuginfo_result ext_result
648 = ext_lang_handle_missing_debuginfo (this);
649 if (!ext_result
.filename ().empty ())
651 /* Extension found a suitable debug file for us. */
653 = symfile_bfd_open_no_error (ext_result
.filename ().c_str ());
655 if (debug_bfd
!= nullptr)
657 symbol_file_add_separate (debug_bfd
,
658 ext_result
.filename ().c_str (),
659 symfile_flags
, this);
663 else if (ext_result
.try_again ())
670 /* If we still have not got a separate debug symbol file, then
671 emit any warnings we've collected so far. */
680 /* Debugging version of struct sym_probe_fns. */
682 static const std::vector
<std::unique_ptr
<probe
>> &
683 debug_sym_get_probes (struct objfile
*objfile
)
685 const struct debug_sym_fns_data
*debug_data
686 = symfile_debug_objfile_data_key
.get (objfile
);
688 const std::vector
<std::unique_ptr
<probe
>> &retval
689 = debug_data
->real_sf
->sym_probe_fns
->sym_get_probes (objfile
);
691 gdb_printf (gdb_stdlog
,
692 "probes->sym_get_probes (%s) = %s\n",
693 objfile_debug_name (objfile
),
694 host_address_to_string (retval
.data ()));
699 static const struct sym_probe_fns debug_sym_probe_fns
=
701 debug_sym_get_probes
,
704 /* Debugging version of struct sym_fns. */
707 debug_sym_new_init (struct objfile
*objfile
)
709 const struct debug_sym_fns_data
*debug_data
710 = symfile_debug_objfile_data_key
.get (objfile
);
712 gdb_printf (gdb_stdlog
, "sf->sym_new_init (%s)\n",
713 objfile_debug_name (objfile
));
715 debug_data
->real_sf
->sym_new_init (objfile
);
719 debug_sym_init (struct objfile
*objfile
)
721 const struct debug_sym_fns_data
*debug_data
722 = symfile_debug_objfile_data_key
.get (objfile
);
724 gdb_printf (gdb_stdlog
, "sf->sym_init (%s)\n",
725 objfile_debug_name (objfile
));
727 debug_data
->real_sf
->sym_init (objfile
);
731 debug_sym_read (struct objfile
*objfile
, symfile_add_flags symfile_flags
)
733 const struct debug_sym_fns_data
*debug_data
734 = symfile_debug_objfile_data_key
.get (objfile
);
736 gdb_printf (gdb_stdlog
, "sf->sym_read (%s, 0x%x)\n",
737 objfile_debug_name (objfile
), (unsigned) symfile_flags
);
739 debug_data
->real_sf
->sym_read (objfile
, symfile_flags
);
743 debug_sym_finish (struct objfile
*objfile
)
745 const struct debug_sym_fns_data
*debug_data
746 = symfile_debug_objfile_data_key
.get (objfile
);
748 gdb_printf (gdb_stdlog
, "sf->sym_finish (%s)\n",
749 objfile_debug_name (objfile
));
751 debug_data
->real_sf
->sym_finish (objfile
);
755 debug_sym_offsets (struct objfile
*objfile
,
756 const section_addr_info
&info
)
758 const struct debug_sym_fns_data
*debug_data
759 = symfile_debug_objfile_data_key
.get (objfile
);
761 gdb_printf (gdb_stdlog
, "sf->sym_offsets (%s, %s)\n",
762 objfile_debug_name (objfile
),
763 host_address_to_string (&info
));
765 debug_data
->real_sf
->sym_offsets (objfile
, info
);
768 static symfile_segment_data_up
769 debug_sym_segments (bfd
*abfd
)
771 /* This API function is annoying, it doesn't take a "this" pointer.
772 Fortunately it is only used in one place where we (re-)lookup the
773 sym_fns table to use. Thus we will never be called. */
774 gdb_assert_not_reached ("debug_sym_segments called");
778 debug_sym_read_linetable (struct objfile
*objfile
)
780 const struct debug_sym_fns_data
*debug_data
781 = symfile_debug_objfile_data_key
.get (objfile
);
783 gdb_printf (gdb_stdlog
, "sf->sym_read_linetable (%s)\n",
784 objfile_debug_name (objfile
));
786 debug_data
->real_sf
->sym_read_linetable (objfile
);
790 debug_sym_relocate (struct objfile
*objfile
, asection
*sectp
, bfd_byte
*buf
)
792 const struct debug_sym_fns_data
*debug_data
793 = symfile_debug_objfile_data_key
.get (objfile
);
796 retval
= debug_data
->real_sf
->sym_relocate (objfile
, sectp
, buf
);
798 gdb_printf (gdb_stdlog
,
799 "sf->sym_relocate (%s, %s, %s) = %s\n",
800 objfile_debug_name (objfile
),
801 host_address_to_string (sectp
),
802 host_address_to_string (buf
),
803 host_address_to_string (retval
));
808 /* Template of debugging version of struct sym_fns.
809 A copy is made, with sym_flavour updated, and a pointer to the real table
810 installed in real_sf, and then a pointer to the copy is installed in the
813 static const struct sym_fns debug_sym_fns
=
821 debug_sym_read_linetable
,
823 &debug_sym_probe_fns
,
826 /* Install the debugging versions of the symfile functions for OBJFILE.
827 Do not call this if the debug versions are already installed. */
830 install_symfile_debug_logging (struct objfile
*objfile
)
832 const struct sym_fns
*real_sf
;
833 struct debug_sym_fns_data
*debug_data
;
835 /* The debug versions should not already be installed. */
836 gdb_assert (!symfile_debug_installed (objfile
));
838 real_sf
= objfile
->sf
;
840 /* Alas we have to preserve NULL entries in REAL_SF. */
841 debug_data
= new struct debug_sym_fns_data
;
843 #define COPY_SF_PTR(from, to, name, func) \
846 (to)->debug_sf.name = func; \
849 COPY_SF_PTR (real_sf
, debug_data
, sym_new_init
, debug_sym_new_init
);
850 COPY_SF_PTR (real_sf
, debug_data
, sym_init
, debug_sym_init
);
851 COPY_SF_PTR (real_sf
, debug_data
, sym_read
, debug_sym_read
);
852 COPY_SF_PTR (real_sf
, debug_data
, sym_finish
, debug_sym_finish
);
853 COPY_SF_PTR (real_sf
, debug_data
, sym_offsets
, debug_sym_offsets
);
854 COPY_SF_PTR (real_sf
, debug_data
, sym_segments
, debug_sym_segments
);
855 COPY_SF_PTR (real_sf
, debug_data
, sym_read_linetable
,
856 debug_sym_read_linetable
);
857 COPY_SF_PTR (real_sf
, debug_data
, sym_relocate
, debug_sym_relocate
);
858 if (real_sf
->sym_probe_fns
)
859 debug_data
->debug_sf
.sym_probe_fns
= &debug_sym_probe_fns
;
863 debug_data
->real_sf
= real_sf
;
864 symfile_debug_objfile_data_key
.set (objfile
, debug_data
);
865 objfile
->sf
= &debug_data
->debug_sf
;
868 /* Uninstall the debugging versions of the symfile functions for OBJFILE.
869 Do not call this if the debug versions are not installed. */
872 uninstall_symfile_debug_logging (struct objfile
*objfile
)
874 struct debug_sym_fns_data
*debug_data
;
876 /* The debug versions should be currently installed. */
877 gdb_assert (symfile_debug_installed (objfile
));
879 debug_data
= symfile_debug_objfile_data_key
.get (objfile
);
881 objfile
->sf
= debug_data
->real_sf
;
882 symfile_debug_objfile_data_key
.clear (objfile
);
885 /* Call this function to set OBJFILE->SF.
886 Do not set OBJFILE->SF directly. */
889 objfile_set_sym_fns (struct objfile
*objfile
, const struct sym_fns
*sf
)
891 if (symfile_debug_installed (objfile
))
893 gdb_assert (debug_symfile
);
894 /* Remove the current one, and reinstall a new one later. */
895 uninstall_symfile_debug_logging (objfile
);
898 /* Assume debug logging is disabled. */
901 /* Turn debug logging on if enabled. */
903 install_symfile_debug_logging (objfile
);
907 set_debug_symfile (const char *args
, int from_tty
, struct cmd_list_element
*c
)
909 for (struct program_space
*pspace
: program_spaces
)
910 for (objfile
*objfile
: pspace
->objfiles ())
914 if (!symfile_debug_installed (objfile
))
915 install_symfile_debug_logging (objfile
);
919 if (symfile_debug_installed (objfile
))
920 uninstall_symfile_debug_logging (objfile
);
926 show_debug_symfile (struct ui_file
*file
, int from_tty
,
927 struct cmd_list_element
*c
, const char *value
)
929 gdb_printf (file
, _("Symfile debugging is %s.\n"), value
);
932 void _initialize_symfile_debug ();
934 _initialize_symfile_debug ()
936 add_setshow_boolean_cmd ("symfile", no_class
, &debug_symfile
, _("\
937 Set debugging of the symfile functions."), _("\
938 Show debugging of the symfile functions."), _("\
939 When enabled, all calls to the symfile functions are logged."),
940 set_debug_symfile
, show_debug_symfile
,
941 &setdebuglist
, &showdebuglist
);
943 /* Note: We don't need a new-objfile observer because debug logging
944 will be installed when objfile init'n calls objfile_set_sym_fns. */