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
This commit is contained in:
Simon Marchi
2020-05-27 11:13:54 -04:00
committed by Simon Marchi
parent 1859c670e9
commit c3699833af
6 changed files with 51 additions and 28 deletions

View File

@@ -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)