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
28 #include "cli/cli-cmds.h"
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 ())
157 cu
->forget_cached_source_info ();
159 for (const auto &iter
: qf
)
160 iter
->forget_cached_source_info (this);
164 objfile::map_symtabs_matching_filename
165 (const char *name
, const char *real_path
,
166 gdb::function_view
<bool (symtab
*)> callback
)
169 gdb_printf (gdb_stdlog
,
170 "qf->map_symtabs_matching_filename (%s, \"%s\", "
172 objfile_debug_name (this), name
,
173 real_path
? real_path
: NULL
,
174 host_address_to_string (&callback
));
177 const char *name_basename
= lbasename (name
);
179 auto match_one_filename
= [&] (const char *filename
, bool basenames
)
181 if (compare_filenames_for_search (filename
, name
))
183 if (basenames
&& FILENAME_CMP (name_basename
, filename
) == 0)
185 if (real_path
!= nullptr && IS_ABSOLUTE_PATH (filename
)
186 && IS_ABSOLUTE_PATH (real_path
))
187 return filename_cmp (filename
, real_path
) == 0;
191 compunit_symtab
*last_made
= this->compunit_symtabs
;
193 auto on_expansion
= [&] (compunit_symtab
*symtab
)
195 /* The callback to iterate_over_some_symtabs returns false to keep
196 going and true to continue, so we have to invert the result
197 here, for expand_symtabs_matching. */
198 bool result
= !iterate_over_some_symtabs (name
, real_path
,
199 this->compunit_symtabs
,
202 last_made
= this->compunit_symtabs
;
206 for (const auto &iter
: qf
)
208 if (!iter
->expand_symtabs_matching (this,
214 | SEARCH_STATIC_BLOCK
),
223 gdb_printf (gdb_stdlog
,
224 "qf->map_symtabs_matching_filename (...) = %d\n",
227 /* We must re-invert the return value here to match the caller's
232 struct compunit_symtab
*
233 objfile::lookup_symbol (block_enum kind
, const lookup_name_info
&name
,
234 domain_search_flags domain
)
236 struct compunit_symtab
*retval
= nullptr;
239 gdb_printf (gdb_stdlog
,
240 "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
241 objfile_debug_name (this), kind
, name
.c_str (),
242 domain_name (domain
).c_str ());
244 auto search_one_symtab
= [&] (compunit_symtab
*stab
)
246 struct symbol
*sym
, *with_opaque
= NULL
;
247 const struct blockvector
*bv
= stab
->blockvector ();
248 const struct block
*block
= bv
->block (kind
);
250 sym
= block_find_symbol (block
, name
, domain
, &with_opaque
);
252 /* Some caution must be observed with overloaded functions
253 and methods, since the index will not contain any overload
254 information (but NAME might contain it). */
262 if (with_opaque
!= nullptr)
265 /* Keep looking through other psymtabs. */
269 for (const auto &iter
: qf
)
271 if (!iter
->expand_symtabs_matching (this,
277 ? SEARCH_GLOBAL_BLOCK
278 : SEARCH_STATIC_BLOCK
,
284 gdb_printf (gdb_stdlog
, "qf->lookup_symbol (...) = %s\n",
286 ? debug_symtab_name (retval
->primary_filetab ())
293 objfile::print_stats (bool print_bcache
)
296 gdb_printf (gdb_stdlog
, "qf->print_stats (%s, %d)\n",
297 objfile_debug_name (this), print_bcache
);
299 for (const auto &iter
: qf
)
300 iter
->print_stats (this, print_bcache
);
307 gdb_printf (gdb_stdlog
, "qf->dump (%s)\n",
308 objfile_debug_name (this));
310 for (const auto &iter
: qf
)
315 objfile::expand_symtabs_for_function (const char *func_name
)
318 gdb_printf (gdb_stdlog
,
319 "qf->expand_symtabs_for_function (%s, \"%s\")\n",
320 objfile_debug_name (this), func_name
);
322 lookup_name_info
base_lookup (func_name
, symbol_name_match_type::FULL
);
323 lookup_name_info lookup_name
= base_lookup
.make_ignore_params ();
325 for (const auto &iter
: qf
)
326 iter
->expand_symtabs_matching (this,
332 | SEARCH_STATIC_BLOCK
),
333 SEARCH_FUNCTION_DOMAIN
);
337 objfile::expand_all_symtabs ()
340 gdb_printf (gdb_stdlog
, "qf->expand_all_symtabs (%s)\n",
341 objfile_debug_name (this));
343 for (const auto &iter
: qf
)
344 iter
->expand_all_symtabs (this);
348 objfile::expand_symtabs_with_fullname (const char *fullname
)
351 gdb_printf (gdb_stdlog
,
352 "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
353 objfile_debug_name (this), fullname
);
355 const char *basename
= lbasename (fullname
);
356 auto file_matcher
= [&] (const char *filename
, bool basenames
)
358 return filename_cmp (basenames
? basename
: fullname
, filename
) == 0;
361 for (const auto &iter
: qf
)
362 iter
->expand_symtabs_matching (this,
368 | SEARCH_STATIC_BLOCK
),
373 objfile::expand_symtabs_matching
374 (gdb::function_view
<expand_symtabs_file_matcher_ftype
> file_matcher
,
375 const lookup_name_info
*lookup_name
,
376 gdb::function_view
<expand_symtabs_symbol_matcher_ftype
> symbol_matcher
,
377 gdb::function_view
<expand_symtabs_exp_notify_ftype
> expansion_notify
,
378 block_search_flags search_flags
,
379 domain_search_flags domain
,
380 gdb::function_view
<expand_symtabs_lang_matcher_ftype
> lang_matcher
)
382 /* This invariant is documented in quick-functions.h. */
383 gdb_assert (lookup_name
!= nullptr || symbol_matcher
== nullptr);
386 gdb_printf (gdb_stdlog
,
387 "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
388 objfile_debug_name (this),
389 host_address_to_string (&file_matcher
),
390 host_address_to_string (&symbol_matcher
),
391 host_address_to_string (&expansion_notify
),
392 domain_name (domain
).c_str ());
394 for (const auto &iter
: qf
)
395 if (!iter
->expand_symtabs_matching (this, file_matcher
, lookup_name
,
396 symbol_matcher
, expansion_notify
,
397 search_flags
, domain
,
403 struct compunit_symtab
*
404 objfile::find_pc_sect_compunit_symtab (bound_minimal_symbol msymbol
,
406 struct obj_section
*section
,
409 struct compunit_symtab
*retval
= nullptr;
412 gdb_printf (gdb_stdlog
,
413 "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
414 objfile_debug_name (this),
415 host_address_to_string (msymbol
.minsym
),
417 host_address_to_string (section
),
420 for (const auto &iter
: qf
)
422 retval
= iter
->find_pc_sect_compunit_symtab (this, msymbol
, pc
, section
,
424 if (retval
!= nullptr)
429 gdb_printf (gdb_stdlog
,
430 "qf->find_pc_sect_compunit_symtab (...) = %s\n",
432 ? debug_symtab_name (retval
->primary_filetab ())
439 objfile::map_symbol_filenames (gdb::function_view
<symbol_filename_ftype
> fun
,
443 gdb_printf (gdb_stdlog
,
444 "qf->map_symbol_filenames (%s, ..., %d)\n",
445 objfile_debug_name (this),
448 for (const auto &iter
: qf
)
449 iter
->map_symbol_filenames (this, fun
, need_fullname
);
453 objfile::compute_main_name ()
456 gdb_printf (gdb_stdlog
,
457 "qf->compute_main_name (%s)\n",
458 objfile_debug_name (this));
460 for (const auto &iter
: qf
)
461 iter
->compute_main_name (this);
464 struct compunit_symtab
*
465 objfile::find_compunit_symtab_by_address (CORE_ADDR address
)
468 gdb_printf (gdb_stdlog
,
469 "qf->find_compunit_symtab_by_address (%s, %s)\n",
470 objfile_debug_name (this),
471 hex_string (address
));
473 struct compunit_symtab
*result
= NULL
;
474 for (const auto &iter
: qf
)
476 result
= iter
->find_compunit_symtab_by_address (this, address
);
477 if (result
!= nullptr)
482 gdb_printf (gdb_stdlog
,
483 "qf->find_compunit_symtab_by_address (...) = %s\n",
485 ? debug_symtab_name (result
->primary_filetab ())
492 objfile::lookup_global_symbol_language (const char *name
,
493 domain_search_flags domain
,
494 bool *symbol_found_p
)
496 enum language result
= language_unknown
;
497 *symbol_found_p
= false;
499 for (const auto &iter
: qf
)
501 result
= iter
->lookup_global_symbol_language (this, name
, domain
,
510 /* Call LOOKUP_FUNC to find the filename of a file containing the separate
511 debug information matching OBJFILE. If LOOKUP_FUNC does return a
512 filename then open this file and return a std::pair containing the
513 gdb_bfd_ref_ptr of the open file and the filename returned by
514 LOOKUP_FUNC, otherwise this function returns an empty pair; the first
515 item will be nullptr, and the second will be an empty string.
517 Any warnings generated by this function, or by calling LOOKUP_FUNC are
518 placed into WARNINGS, these warnings are only displayed to the user if
519 GDB is unable to find the separate debug information via any route. */
520 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
521 simple_find_and_open_separate_symbol_file
522 (struct objfile
*objfile
,
523 std::string (*lookup_func
) (struct objfile
*, deferred_warnings
*),
524 deferred_warnings
*warnings
)
526 std::string filename
= lookup_func (objfile
, warnings
);
528 if (!filename
.empty ())
530 gdb_bfd_ref_ptr symfile_bfd
531 = symfile_bfd_open_no_error (filename
.c_str ());
532 if (symfile_bfd
!= nullptr)
533 return { symfile_bfd
, filename
};
539 /* Lookup separate debug information for OBJFILE via debuginfod. If
540 successful the debug information will be have been downloaded into the
541 debuginfod cache and this function will return a std::pair containing a
542 gdb_bfd_ref_ptr of the open debug information file and the filename for
543 the file within the debuginfod cache. If no debug information could be
544 found then this function returns an empty pair; the first item will be
545 nullptr, and the second will be an empty string. */
547 static std::pair
<gdb_bfd_ref_ptr
, std::string
>
548 debuginfod_find_and_open_separate_symbol_file (struct objfile
* objfile
)
550 const struct bfd_build_id
*build_id
551 = build_id_bfd_get (objfile
->obfd
.get ());
552 const char *filename
= bfd_get_filename (objfile
->obfd
.get ());
554 if (build_id
!= nullptr)
556 gdb::unique_xmalloc_ptr
<char> symfile_path
;
557 scoped_fd
fd (debuginfod_debuginfo_query (build_id
->data
, build_id
->size
,
558 filename
, &symfile_path
));
562 /* File successfully retrieved from server. */
563 gdb_bfd_ref_ptr debug_bfd
564 (symfile_bfd_open_no_error (symfile_path
.get ()));
566 if (debug_bfd
!= nullptr
567 && build_id_verify (debug_bfd
.get (),
568 build_id
->size
, build_id
->data
))
569 return { debug_bfd
, std::string (symfile_path
.get ()) };
576 /* See objfiles.h. */
579 objfile::find_and_add_separate_symbol_file (symfile_add_flags symfile_flags
)
581 bool has_dwarf2
= false;
583 /* Usually we only make a single pass when looking for separate debug
584 information. However, it is possible for an extension language hook
585 to request that GDB make a second pass, in which case max_attempts
586 will be updated, and the loop restarted. */
587 for (unsigned attempt
= 0, max_attempts
= 1;
588 attempt
< max_attempts
&& !has_dwarf2
;
591 gdb_assert (max_attempts
<= 2);
593 deferred_warnings warnings
;
594 gdb_bfd_ref_ptr debug_bfd
;
595 std::string filename
;
597 std::tie (debug_bfd
, filename
)
598 = simple_find_and_open_separate_symbol_file
599 (this, find_separate_debug_file_by_buildid
, &warnings
);
601 if (debug_bfd
== nullptr)
602 std::tie (debug_bfd
, filename
)
603 = simple_find_and_open_separate_symbol_file
604 (this, find_separate_debug_file_by_debuglink
, &warnings
);
606 /* Only try debuginfod on the first attempt. Sure, we could imagine
607 an extension that somehow adds the required debug info to the
608 debuginfod server but, at least for now, we don't support this
609 scenario. Better for the extension to return new debug info
610 directly to GDB. Plus, going to the debuginfod server might be
611 slow, so that's a good argument for only doing this once. */
612 if (debug_bfd
== nullptr && attempt
== 0)
613 std::tie (debug_bfd
, filename
)
614 = debuginfod_find_and_open_separate_symbol_file (this);
616 if (debug_bfd
!= nullptr)
618 /* We found a separate debug info symbol file. If this is our
619 first attempt then setting HAS_DWARF2 will cause us to break
620 from the attempt loop. */
621 symbol_file_add_separate (debug_bfd
, filename
.c_str (),
622 symfile_flags
, this);
625 else if (attempt
== 0)
627 /* Failed to find a separate debug info symbol file. Call out to
628 the extension languages. The user might have registered an
629 extension that can find the debug info for us, or maybe give
630 the user a system specific message that guides them to finding
631 the missing debug info. */
633 ext_lang_missing_file_result ext_result
634 = ext_lang_handle_missing_debuginfo (this);
635 if (!ext_result
.filename ().empty ())
637 /* Extension found a suitable debug file for us. */
639 = symfile_bfd_open_no_error (ext_result
.filename ().c_str ());
641 if (debug_bfd
!= nullptr)
643 symbol_file_add_separate (debug_bfd
,
644 ext_result
.filename ().c_str (),
645 symfile_flags
, this);
649 else if (ext_result
.try_again ())
656 /* If we still have not got a separate debug symbol file, then
657 emit any warnings we've collected so far. */
666 /* Debugging version of struct sym_probe_fns. */
668 static const std::vector
<std::unique_ptr
<probe
>> &
669 debug_sym_get_probes (struct objfile
*objfile
)
671 const struct debug_sym_fns_data
*debug_data
672 = symfile_debug_objfile_data_key
.get (objfile
);
674 const std::vector
<std::unique_ptr
<probe
>> &retval
675 = debug_data
->real_sf
->sym_probe_fns
->sym_get_probes (objfile
);
677 gdb_printf (gdb_stdlog
,
678 "probes->sym_get_probes (%s) = %s\n",
679 objfile_debug_name (objfile
),
680 host_address_to_string (retval
.data ()));
685 static const struct sym_probe_fns debug_sym_probe_fns
=
687 debug_sym_get_probes
,
690 /* Debugging version of struct sym_fns. */
693 debug_sym_new_init (struct objfile
*objfile
)
695 const struct debug_sym_fns_data
*debug_data
696 = symfile_debug_objfile_data_key
.get (objfile
);
698 gdb_printf (gdb_stdlog
, "sf->sym_new_init (%s)\n",
699 objfile_debug_name (objfile
));
701 debug_data
->real_sf
->sym_new_init (objfile
);
705 debug_sym_init (struct objfile
*objfile
)
707 const struct debug_sym_fns_data
*debug_data
708 = symfile_debug_objfile_data_key
.get (objfile
);
710 gdb_printf (gdb_stdlog
, "sf->sym_init (%s)\n",
711 objfile_debug_name (objfile
));
713 debug_data
->real_sf
->sym_init (objfile
);
717 debug_sym_read (struct objfile
*objfile
, symfile_add_flags symfile_flags
)
719 const struct debug_sym_fns_data
*debug_data
720 = symfile_debug_objfile_data_key
.get (objfile
);
722 gdb_printf (gdb_stdlog
, "sf->sym_read (%s, 0x%x)\n",
723 objfile_debug_name (objfile
), (unsigned) symfile_flags
);
725 debug_data
->real_sf
->sym_read (objfile
, symfile_flags
);
729 debug_sym_finish (struct objfile
*objfile
)
731 const struct debug_sym_fns_data
*debug_data
732 = symfile_debug_objfile_data_key
.get (objfile
);
734 gdb_printf (gdb_stdlog
, "sf->sym_finish (%s)\n",
735 objfile_debug_name (objfile
));
737 debug_data
->real_sf
->sym_finish (objfile
);
741 debug_sym_offsets (struct objfile
*objfile
,
742 const section_addr_info
&info
)
744 const struct debug_sym_fns_data
*debug_data
745 = symfile_debug_objfile_data_key
.get (objfile
);
747 gdb_printf (gdb_stdlog
, "sf->sym_offsets (%s, %s)\n",
748 objfile_debug_name (objfile
),
749 host_address_to_string (&info
));
751 debug_data
->real_sf
->sym_offsets (objfile
, info
);
754 static symfile_segment_data_up
755 debug_sym_segments (bfd
*abfd
)
757 /* This API function is annoying, it doesn't take a "this" pointer.
758 Fortunately it is only used in one place where we (re-)lookup the
759 sym_fns table to use. Thus we will never be called. */
760 gdb_assert_not_reached ("debug_sym_segments called");
764 debug_sym_read_linetable (struct objfile
*objfile
)
766 const struct debug_sym_fns_data
*debug_data
767 = symfile_debug_objfile_data_key
.get (objfile
);
769 gdb_printf (gdb_stdlog
, "sf->sym_read_linetable (%s)\n",
770 objfile_debug_name (objfile
));
772 debug_data
->real_sf
->sym_read_linetable (objfile
);
776 debug_sym_relocate (struct objfile
*objfile
, asection
*sectp
, bfd_byte
*buf
)
778 const struct debug_sym_fns_data
*debug_data
779 = symfile_debug_objfile_data_key
.get (objfile
);
782 retval
= debug_data
->real_sf
->sym_relocate (objfile
, sectp
, buf
);
784 gdb_printf (gdb_stdlog
,
785 "sf->sym_relocate (%s, %s, %s) = %s\n",
786 objfile_debug_name (objfile
),
787 host_address_to_string (sectp
),
788 host_address_to_string (buf
),
789 host_address_to_string (retval
));
794 /* Template of debugging version of struct sym_fns.
795 A copy is made, with sym_flavour updated, and a pointer to the real table
796 installed in real_sf, and then a pointer to the copy is installed in the
799 static const struct sym_fns debug_sym_fns
=
807 debug_sym_read_linetable
,
809 &debug_sym_probe_fns
,
812 /* Install the debugging versions of the symfile functions for OBJFILE.
813 Do not call this if the debug versions are already installed. */
816 install_symfile_debug_logging (struct objfile
*objfile
)
818 const struct sym_fns
*real_sf
;
819 struct debug_sym_fns_data
*debug_data
;
821 /* The debug versions should not already be installed. */
822 gdb_assert (!symfile_debug_installed (objfile
));
824 real_sf
= objfile
->sf
;
826 /* Alas we have to preserve NULL entries in REAL_SF. */
827 debug_data
= new struct debug_sym_fns_data
;
829 #define COPY_SF_PTR(from, to, name, func) \
832 (to)->debug_sf.name = func; \
835 COPY_SF_PTR (real_sf
, debug_data
, sym_new_init
, debug_sym_new_init
);
836 COPY_SF_PTR (real_sf
, debug_data
, sym_init
, debug_sym_init
);
837 COPY_SF_PTR (real_sf
, debug_data
, sym_read
, debug_sym_read
);
838 COPY_SF_PTR (real_sf
, debug_data
, sym_finish
, debug_sym_finish
);
839 COPY_SF_PTR (real_sf
, debug_data
, sym_offsets
, debug_sym_offsets
);
840 COPY_SF_PTR (real_sf
, debug_data
, sym_segments
, debug_sym_segments
);
841 COPY_SF_PTR (real_sf
, debug_data
, sym_read_linetable
,
842 debug_sym_read_linetable
);
843 COPY_SF_PTR (real_sf
, debug_data
, sym_relocate
, debug_sym_relocate
);
844 if (real_sf
->sym_probe_fns
)
845 debug_data
->debug_sf
.sym_probe_fns
= &debug_sym_probe_fns
;
849 debug_data
->real_sf
= real_sf
;
850 symfile_debug_objfile_data_key
.set (objfile
, debug_data
);
851 objfile
->sf
= &debug_data
->debug_sf
;
854 /* Uninstall the debugging versions of the symfile functions for OBJFILE.
855 Do not call this if the debug versions are not installed. */
858 uninstall_symfile_debug_logging (struct objfile
*objfile
)
860 struct debug_sym_fns_data
*debug_data
;
862 /* The debug versions should be currently installed. */
863 gdb_assert (symfile_debug_installed (objfile
));
865 debug_data
= symfile_debug_objfile_data_key
.get (objfile
);
867 objfile
->sf
= debug_data
->real_sf
;
868 symfile_debug_objfile_data_key
.clear (objfile
);
871 /* Call this function to set OBJFILE->SF.
872 Do not set OBJFILE->SF directly. */
875 objfile_set_sym_fns (struct objfile
*objfile
, const struct sym_fns
*sf
)
877 if (symfile_debug_installed (objfile
))
879 gdb_assert (debug_symfile
);
880 /* Remove the current one, and reinstall a new one later. */
881 uninstall_symfile_debug_logging (objfile
);
884 /* Assume debug logging is disabled. */
887 /* Turn debug logging on if enabled. */
889 install_symfile_debug_logging (objfile
);
893 set_debug_symfile (const char *args
, int from_tty
, struct cmd_list_element
*c
)
895 for (struct program_space
*pspace
: program_spaces
)
896 for (objfile
*objfile
: pspace
->objfiles ())
900 if (!symfile_debug_installed (objfile
))
901 install_symfile_debug_logging (objfile
);
905 if (symfile_debug_installed (objfile
))
906 uninstall_symfile_debug_logging (objfile
);
912 show_debug_symfile (struct ui_file
*file
, int from_tty
,
913 struct cmd_list_element
*c
, const char *value
)
915 gdb_printf (file
, _("Symfile debugging is %s.\n"), value
);
918 void _initialize_symfile_debug ();
920 _initialize_symfile_debug ()
922 add_setshow_boolean_cmd ("symfile", no_class
, &debug_symfile
, _("\
923 Set debugging of the symfile functions."), _("\
924 Show debugging of the symfile functions."), _("\
925 When enabled, all calls to the symfile functions are logged."),
926 set_debug_symfile
, show_debug_symfile
,
927 &setdebuglist
, &showdebuglist
);
929 /* Note: We don't need a new-objfile observer because debug logging
930 will be installed when objfile init'n calls objfile_set_sym_fns. */