aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-05-27 11:13:54 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-27 11:15:54 -0400
commitc3699833af0343d13d7d39b3c589d3ac5b930137 (patch)
treeea8bea180c24cb12ed0ce1e7a85dba2eeceb82d8 /gdb/dwarf2
parent1859c670e9979c1e58ed4e9d83085f732e6936f5 (diff)
downloadgdb-c3699833af0343d13d7d39b3c589d3ac5b930137.zip
gdb-c3699833af0343d13d7d39b3c589d3ac5b930137.tar.gz
gdb-c3699833af0343d13d7d39b3c589d3ac5b930137.tar.bz2
Make dwarf2_get_dwz_file take a dwarf2_per_bfd
This allows removing a per_bfd->dwarf2_per_objfile reference in get_abbrev_section_for_cu. This requires saving the bfd in dwarf2_per_bfd. The constructor of dwarf2_per_bfd already accepts the bfd, so it's just a matter of saving it in a field. I replaced uses of objfile_name with bfd_get_filename, which should be equivalent in this case. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_per_bfd) <obfd>: New member. (dwarf2_get_dwz_file): Replace parameter with dwarf2_per_bfd. * dwarf2/read.c (dwarf2_per_bfd::dwarf2_per_bfd): Assign obfd field. (dwarf2_get_dwz_file): Replace parameter with dwarf2_per_bfd. (create_cus_from_index): Update. (dwarf2_read_gdb_index): Update. (create_cus_from_debug_names): Update. (dwarf2_read_debug_names): Update. (get_abbrev_section_for_cu): Update. (create_all_comp_units): Update. (read_attribute_value): Update. (get_debug_line_section): Update. * dwarf2/index-cache.c (index_cache::store): Update. * dwarf2/index-write.c (save_gdb_index_command): Update. * dwarf2/macro.c (dwarf_decode_macro_bytes): Update. Change-Id: Ifb23f55dda93c499aae57b6a9aff9c6ff9d2f45f
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/index-cache.c2
-rw-r--r--gdb/dwarf2/index-write.c3
-rw-r--r--gdb/dwarf2/macro.c5
-rw-r--r--gdb/dwarf2/read.c44
-rw-r--r--gdb/dwarf2/read.h6
5 files changed, 32 insertions, 28 deletions
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
index 76e7ce6..cb79c87 100644
--- a/gdb/dwarf2/index-cache.c
+++ b/gdb/dwarf2/index-cache.c
@@ -108,7 +108,7 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile)
/* Get build id of dwz file, if present. */
gdb::optional<std::string> dwz_build_id_str;
- const dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ const dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
const char *dwz_build_id_ptr = NULL;
if (dwz != nullptr)
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index a9c6651..a113aa6 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -1761,7 +1761,8 @@ save_gdb_index_command (const char *arg, int from_tty)
try
{
const char *basename = lbasename (objfile_name (objfile));
- const dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ const dwz_file *dwz
+ = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
const char *dwz_basename = NULL;
if (dwz != NULL)
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index c258019..a44e2c7 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -507,7 +507,7 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
|| section_is_dwz)
{
struct dwz_file *dwz
- = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
body = dwz->read_string (objfile, str_offset);
}
@@ -644,7 +644,8 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
if (macinfo_type == DW_MACRO_import_sup)
{
- struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ struct dwz_file *dwz
+ = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
dwz->macro.read (objfile);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index da1638d..aa1c3f0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1752,7 +1752,8 @@ line_header_eq_voidp (const void *item_lhs, const void *item_rhs)
dwarf2_per_bfd::dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names,
bool can_copy_)
- : can_copy (can_copy_)
+ : obfd (obfd),
+ can_copy (can_copy_)
{
if (names == NULL)
names = &dwarf2_elf_names;
@@ -2112,19 +2113,19 @@ locate_dwz_sections (bfd *abfd, asection *sectp, void *arg)
/* See dwarf2read.h. */
struct dwz_file *
-dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
+dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd)
{
const char *filename;
bfd_size_type buildid_len_arg;
size_t buildid_len;
bfd_byte *buildid;
- if (dwarf2_per_objfile->per_bfd->dwz_file != NULL)
- return dwarf2_per_objfile->per_bfd->dwz_file.get ();
+ if (per_bfd->dwz_file != NULL)
+ return per_bfd->dwz_file.get ();
bfd_set_error (bfd_error_no_error);
gdb::unique_xmalloc_ptr<char> data
- (bfd_get_alt_debug_link_info (dwarf2_per_objfile->objfile->obfd,
+ (bfd_get_alt_debug_link_info (per_bfd->obfd,
&buildid_len_arg, &buildid));
if (data == NULL)
{
@@ -2144,7 +2145,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
if (!IS_ABSOLUTE_PATH (filename))
{
gdb::unique_xmalloc_ptr<char> abs
- = gdb_realpath (objfile_name (dwarf2_per_objfile->objfile));
+ = gdb_realpath (bfd_get_filename (per_bfd->obfd));
abs_storage = ldirname (abs.get ()) + SLASH_STRING + filename;
filename = abs_storage.c_str ();
@@ -2165,7 +2166,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
if (dwz_bfd == nullptr)
{
gdb::unique_xmalloc_ptr<char> alt_filename;
- const char *origname = dwarf2_per_objfile->objfile->original_name;
+ const char *origname = bfd_get_filename (per_bfd->obfd);
scoped_fd fd (debuginfod_debuginfo_query (buildid,
buildid_len,
@@ -2187,7 +2188,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
if (dwz_bfd == NULL)
error (_("could not find '.gnu_debugaltlink' file for %s"),
- objfile_name (dwarf2_per_objfile->objfile));
+ bfd_get_filename (per_bfd->obfd));
std::unique_ptr<struct dwz_file> result
(new struct dwz_file (std::move (dwz_bfd)));
@@ -2195,10 +2196,9 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
bfd_map_over_sections (result->dwz_bfd.get (), locate_dwz_sections,
result.get ());
- gdb_bfd_record_inclusion (dwarf2_per_objfile->objfile->obfd,
- result->dwz_bfd.get ());
- dwarf2_per_objfile->per_bfd->dwz_file = std::move (result);
- return dwarf2_per_objfile->per_bfd->dwz_file.get ();
+ gdb_bfd_record_inclusion (per_bfd->obfd, result->dwz_bfd.get ());
+ per_bfd->dwz_file = std::move (result);
+ return per_bfd->dwz_file.get ();
}
/* DWARF quick_symbols_functions support. */
@@ -2526,7 +2526,7 @@ create_cus_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
if (dwz_elements == 0)
return;
- dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
create_cus_from_index_list (dwarf2_per_objfile, dwz_list, dwz_elements,
&dwz->info, 1);
}
@@ -3073,7 +3073,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 (dwarf2_per_objfile);
+ dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
if (dwz != NULL)
{
struct mapped_index dwz_map;
@@ -5173,7 +5173,7 @@ create_cus_from_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
if (dwz_map.cu_count == 0)
return;
- dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
create_cus_from_debug_names_list (dwarf2_per_objfile, dwz_map, dwz->info,
true /* is_dwz */);
}
@@ -5200,7 +5200,7 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_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 (dwarf2_per_objfile);
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
if (dwz != NULL)
{
if (!read_debug_names_from_section (objfile,
@@ -6032,12 +6032,12 @@ static struct dwarf2_section_info *
get_abbrev_section_for_cu (struct dwarf2_per_cu_data *this_cu)
{
struct dwarf2_section_info *abbrev;
- struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
+ dwarf2_per_bfd *per_bfd = this_cu->per_bfd;
if (this_cu->is_dwz)
- abbrev = &dwarf2_get_dwz_file (dwarf2_per_objfile)->abbrev;
+ abbrev = &dwarf2_get_dwz_file (per_bfd)->abbrev;
else
- abbrev = &dwarf2_per_objfile->per_bfd->abbrev;
+ abbrev = &per_bfd->abbrev;
return abbrev;
}
@@ -8058,7 +8058,7 @@ create_all_comp_units (struct dwarf2_per_objfile *dwarf2_per_objfile)
read_comp_units_from_section (dwarf2_per_objfile, &dwarf2_per_objfile->per_bfd->info,
&dwarf2_per_objfile->per_bfd->abbrev, 0);
- dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
if (dwz != NULL)
read_comp_units_from_section (dwarf2_per_objfile, &dwz->info, &dwz->abbrev,
1);
@@ -19103,7 +19103,7 @@ read_attribute_value (const struct die_reader_specs *reader,
/* FALLTHROUGH */
case DW_FORM_GNU_strp_alt:
{
- struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
LONGEST str_offset = cu_header->read_offset (abfd, info_ptr,
&bytes_read);
@@ -19698,7 +19698,7 @@ get_debug_line_section (struct dwarf2_cu *cu)
section = &cu->dwo_unit->dwo_file->sections.line;
else if (cu->per_cu->is_dwz)
{
- struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
section = &dwz->line;
}
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 02478d1..e9c74a4 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -136,6 +136,9 @@ private:
const dwarf2_debug_sections &names);
public:
+ /* The corresponding BFD. */
+ bfd *obfd;
+
/* Objects that can be shared across objfiles are stored in this
obstack or on the psymtab obstack, while objects that are
objfile-specific are stored on the objfile obstack. */
@@ -578,8 +581,7 @@ struct signatured_type
there is no .gnu_debugaltlink section in the file. Error if there
is such a section but the file cannot be found. */
-extern struct dwz_file *dwarf2_get_dwz_file
- (struct dwarf2_per_objfile *dwarf2_per_objfile);
+extern dwz_file *dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd);
/* Return the type of the DIE at DIE_OFFSET in the CU named by
PER_CU. */