@@ -272,20 +272,3 @@ dwarf2_read_dwz_file (dwarf2_per_objfile *per_objfile)
per_bfd->dwz_file = std::move (result);
}
-
-/* See dwz.h. */
-
-struct dwz_file *
-dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require)
-{
- gdb_assert (!require || per_bfd->dwz_file.has_value ());
-
- dwz_file *result = nullptr;
- if (per_bfd->dwz_file.has_value ())
- {
- result = per_bfd->dwz_file->get ();
- if (require && result == nullptr)
- error (_("could not read '.gnu_debugaltlink' section"));
- }
- return result;
-}
@@ -68,14 +68,6 @@ struct dwz_file
using dwz_file_up = std::unique_ptr<dwz_file>;
-/* Return the separate '.dwz' debug file. If there is no
- .gnu_debugaltlink section in the file, then the result depends on
- REQUIRE: if REQUIRE is true, then error; if REQUIRE is false,
- return NULL. */
-
-extern dwz_file *dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd,
- bool require = false);
-
/* Open the separate '.dwz' debug file, if needed. This just sets the
appropriate field in the per-BFD structure. If the DWZ file
exists, the relevant sections are read in as well. Throws an error
@@ -110,7 +110,7 @@ index_cache_store_context::index_cache_store_context (const index_cache &ic,
m_build_id_str = build_id_to_string (build_id);
/* Get build id of dwz file, if present. */
- const dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
+ const dwz_file *dwz = per_bfd->get_dwz_file ();
if (dwz != nullptr)
{
@@ -1681,7 +1681,7 @@ save_gdb_index_command (const char *args, int from_tty)
try
{
const char *basename = lbasename (objfile_name (objfile));
- const dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+ const dwz_file *dwz = per_objfile->per_bfd->get_dwz_file ();
const char *dwz_basename = NULL;
if (dwz != NULL)
@@ -503,8 +503,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
|| macinfo_type == DW_MACRO_undef_sup
|| section_is_dwz)
{
- dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd,
- true);
+ dwz_file *dwz = per_objfile->per_bfd->get_dwz_file (true);
body = dwz->read_string (objfile, str_offset);
}
@@ -710,8 +709,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
if (macinfo_type == DW_MACRO_import_sup)
{
- dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd,
- true);
+ dwz_file *dwz = per_objfile->per_bfd->get_dwz_file (true);
include_section = &dwz->macro;
include_bfd = include_section->get_bfd_owner ();
@@ -777,7 +777,7 @@ check_cus_from_debug_names (dwarf2_per_bfd *per_bfd,
if (dwz_map.cu_count == 0)
return true;
- dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
+ dwz_file *dwz = per_bfd->get_dwz_file ();
return check_cus_from_debug_names_list (per_bfd, dwz_map, dwz->info,
true /* is_dwz */);
}
@@ -803,7 +803,7 @@ do_dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
+ dwz_file *dwz = per_bfd->get_dwz_file ();
if (dwz != NULL)
{
if (!read_debug_names_from_section (per_objfile,
@@ -1348,7 +1348,7 @@ create_cus_from_gdb_index (dwarf2_per_bfd *per_bfd,
if (dwz_elements == 0)
return;
- dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
+ dwz_file *dwz = per_bfd->get_dwz_file ();
create_cus_from_gdb_index_list (per_bfd, dwz_list, dwz_elements,
&dwz->info, 1);
}
@@ -1480,7 +1480,6 @@ dwarf2_read_gdb_index
{
const gdb_byte *cu_list, *types_list, *dwz_list = NULL;
offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
- struct dwz_file *dwz;
struct objfile *objfile = per_objfile->objfile;
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
@@ -1504,7 +1503,7 @@ dwarf2_read_gdb_index
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz = dwarf2_get_dwz_file (per_bfd);
+ dwz_file *dwz = per_bfd->get_dwz_file ();
if (dwz != NULL)
{
mapped_gdb_index dwz_map;
@@ -2516,7 +2516,7 @@ get_abbrev_section_for_cu (dwarf2_per_cu *this_cu)
dwarf2_per_bfd *per_bfd = this_cu->per_bfd;
if (this_cu->is_dwz)
- abbrev = &dwarf2_get_dwz_file (per_bfd, true)->abbrev;
+ abbrev = &per_bfd->get_dwz_file (true)->abbrev;
else
abbrev = &per_bfd->abbrev;
@@ -4328,7 +4328,7 @@ create_all_units (dwarf2_per_objfile *per_objfile)
&per_objfile->per_bfd->abbrev, 0, sig_types,
rcuh_kind::TYPE);
- dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+ dwz_file *dwz = per_objfile->per_bfd->get_dwz_file ();
if (dwz != NULL)
{
read_comp_units_from_section (per_objfile, &dwz->info, &dwz->abbrev, 1,
@@ -16467,7 +16467,7 @@ read_attribute_value (const struct die_reader_specs *reader,
[[fallthrough]];
case DW_FORM_GNU_strp_alt:
{
- dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd, true);
+ dwz_file *dwz = per_objfile->per_bfd->get_dwz_file (true);
LONGEST str_offset = cu_header->read_offset (abfd, info_ptr,
&bytes_read);
@@ -17156,11 +17156,7 @@ get_debug_line_section (struct dwarf2_cu *cu)
if (cu->dwo_unit && cu->per_cu->is_debug_types)
section = &cu->dwo_unit->dwo_file->sections.line;
else if (cu->per_cu->is_dwz)
- {
- dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd, true);
-
- section = &dwz->line;
- }
+ section = &per_objfile->per_bfd->get_dwz_file (true)->line;
else
section = &per_objfile->per_bfd->line;
@@ -491,6 +491,26 @@ struct dwarf2_per_bfd
return this->all_comp_units_index_tus[index];
}
+ /* Return the separate '.dwz' debug file. If there is no
+ .gnu_debugaltlink section in the file, then the result depends on
+ REQUIRE: if REQUIRE is true, error out; if REQUIRE is false,
+ return nullptr. */
+ struct dwz_file *get_dwz_file (bool require = false)
+ {
+ gdb_assert (!require || this->dwz_file.has_value ());
+
+ struct dwz_file *result = nullptr;
+
+ if (this->dwz_file.has_value ())
+ {
+ result = this->dwz_file->get ();
+ if (require && result == nullptr)
+ error (_("could not read '.gnu_debugaltlink' section"));
+ }
+
+ return result;
+ }
+
/* A convenience function to allocate a dwarf2_per_cu. The returned object
has its "index" field set properly. The object is allocated on the
dwarf2_per_bfd obstack. */