[2/8] gdb/dwarf: remove unnecessary parameter of create_cus_hash_table
Checks
Commit Message
From: Simon Marchi <simon.marchi@efficios.com>
We can use `cu->per_objfile` instead of passing down a
dwarf2_per_objfile explicitly.
Change-Id: Ie1fd93d9e7a74d09b857f1f0909d7441b79ed893
---
gdb/dwarf2/read.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Comments
>>>>> "Simon" == simon marchi <simon.marchi@polymtl.ca> writes:
Simon> From: Simon Marchi <simon.marchi@efficios.com>
Simon> We can use `cu->per_objfile` instead of passing down a
Simon> dwarf2_per_objfile explicitly.
This seems fine but I don't really understand this function. Like, it
takes a CU argument but it loops over some contents and seems to read
multiple CUs? Weird stuff.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
On 3/5/25 10:33 AM, Tom Tromey wrote:
>>>>>> "Simon" == simon marchi <simon.marchi@polymtl.ca> writes:
>
> Simon> From: Simon Marchi <simon.marchi@efficios.com>
> Simon> We can use `cu->per_objfile` instead of passing down a
> Simon> dwarf2_per_objfile explicitly.
>
> This seems fine but I don't really understand this function. Like, it
> takes a CU argument but it loops over some contents and seems to read
> multiple CUs? Weird stuff.
My understanding is that the passed-in CU is a DWO stub from the main
file, therefore pointing to an external DWO file. This function reads
all the CUs present in the DWO file (hence the loop) to fill the
dwo_file::cus hash table. Typically, there will just be one CU in the
DWO file, but note the comment on dwo_file::cus:
Multiple CUs per DWO are supported as an extension to handle LLVM's Link
Time Optimization output (where multiple source files may be compiled into
a single object/dwo pair).
> Approved-By: Tom Tromey <tom@tromey.com>
Thanks,
Simon
@@ -7021,10 +7021,10 @@ create_dwo_cu_reader (const struct die_reader_specs *reader,
Note: This function processes DWO files only, not DWP files. */
static void
-create_cus_hash_table (dwarf2_per_objfile *per_objfile,
- dwarf2_cu *cu, struct dwo_file &dwo_file,
+create_cus_hash_table (dwarf2_cu *cu, struct dwo_file &dwo_file,
dwarf2_section_info §ion, htab_up &cus_htab)
{
+ dwarf2_per_objfile *per_objfile = cu->per_objfile;
struct objfile *objfile = per_objfile->objfile;
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
const gdb_byte *info_ptr, *end_ptr;
@@ -8353,8 +8353,7 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
dwarf2_locate_dwo_sections (per_objfile->objfile, dwo_file->dbfd.get (),
sec, &dwo_file->sections);
- create_cus_hash_table (per_objfile, cu, *dwo_file, dwo_file->sections.info,
- dwo_file->cus);
+ create_cus_hash_table (cu, *dwo_file, dwo_file->sections.info, dwo_file->cus);
if (cu->per_cu->version () < 5)
{