[gdb/symtab] Read CU base address for enqueued CU
Consider the test-case contained in this patch. It consists of
two CUs:
- cu1, containing a DW_TAG_variable DIE foo
- cu2, containing a DW_TAG_base_type DIE int
where the variable foo has type int, in other words, there's an inter-CU
reference.
When expanding the symtab for cu1, expansion of the symtab for cu2 is
enqueued, and later processed by process_full_comp_unit. However, processing
of .debug_ranges fails because the range is specified relative to a base
address which is considered not to be present because
!cu->base_address.has_value (), and we run into this case in
dwarf2_ranges_process:
...
if (!base.has_value ())
{
/* We have no valid base address for the ranges
data. */
complaint (_("Invalid .debug_ranges data (no base address)"));
return 0;
}
...
Fix this in process_full_comp_unit by setting cu->base_address.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-10-26 Tom de Vries <tdevries@suse.de>
* dwarf2/read.c (process_full_comp_unit): Call
dwarf2_find_base_address.
gdb/testsuite/ChangeLog:
2020-10-26 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/enqueued-cu-base-addr.exp: New file.