[1/2,gdb/symtab] Fix dwarf version of DWO TU
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
When running test-case gdb.ada/access_tagged_param.exp with target board
fission, we run into:
...
(gdb) break pck.adb:19^M
gdb/dwarf2/read.h:289: internal-error: version: \
Assertion `m_dwarf_version != 0' failed.^M
...
The assertion happens when calling cu->per_cu->version () in this workaround
in read_subroutine_type:
...
/* PR gas/29517 occurs in 2.39, and is fixed in 2.40, but it's only fixed
for dwarf version >= 3 which supports DW_TAG_unspecified_type. */
if (type->code () == TYPE_CODE_VOID
&& !type->is_stub ()
&& die->child == nullptr
&& (cu->per_cu->version () == 2
|| producer_is_gas_2_39 (cu)))
{
...
for a TU in a dwo file.
Fix this by:
- adding a dwarf_version field to struct dwo_unit,
- initializing the new field in create_debug_type_hash_table, and
- using the new field in fill_in_sig_entry_from_dwo_entry to set the sig_entry
dwarf version.
Tested on aarch64-linux.
PR symtab/32309
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32309
---
gdb/dwarf2/read.c | 5 +++++
1 file changed, 5 insertions(+)
base-commit: 917ed12066382c48459f85124cbeca1286c3bb53
Comments
On 10/28/24 13:40, Tom de Vries wrote:
> When running test-case gdb.ada/access_tagged_param.exp with target board
> fission, we run into:
> ...
> (gdb) break pck.adb:19^M
> gdb/dwarf2/read.h:289: internal-error: version: \
> Assertion `m_dwarf_version != 0' failed.^M
> ...
>
> The assertion happens when calling cu->per_cu->version () in this workaround
> in read_subroutine_type:
> ...
> /* PR gas/29517 occurs in 2.39, and is fixed in 2.40, but it's only fixed
> for dwarf version >= 3 which supports DW_TAG_unspecified_type. */
> if (type->code () == TYPE_CODE_VOID
> && !type->is_stub ()
> && die->child == nullptr
> && (cu->per_cu->version () == 2
> || producer_is_gas_2_39 (cu)))
> {
> ...
> for a TU in a dwo file.
>
> Fix this by:
> - adding a dwarf_version field to struct dwo_unit,
> - initializing the new field in create_debug_type_hash_table, and
> - using the new field in fill_in_sig_entry_from_dwo_entry to set the sig_entry
> dwarf version.
>
I've submitted a v2 of this patch (
https://sourceware.org/pipermail/gdb-patches/2025-January/214885.html )
, which uses a simpler approach: just use cu->header.version.
Thanks,
- Tom
> Tested on aarch64-linux.
>
> PR symtab/32309
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32309
> ---
> gdb/dwarf2/read.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 6ac6f7c6a39..b407f0a47aa 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -324,6 +324,9 @@ struct dwo_unit
>
> /* For types, offset in the type's DIE of the type defined by this TU. */
> cu_offset type_offset_in_tu;
> +
> + /* DWARF standard version of this DWO unit. */
> + unsigned char dwarf_version;
> };
>
> /* include/dwarf2.h defines the DWP section codes.
> @@ -3449,6 +3452,7 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile,
> dwo_tu->section = section;
> dwo_tu->sect_off = sect_off;
> dwo_tu->length = length;
> + dwo_tu->dwarf_version = header.version;
>
> slot = htab_find_slot (types_htab.get (), dwo_tu, INSERT);
> gdb_assert (slot != NULL);
> @@ -3545,6 +3549,7 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile,
> sig_entry->per_bfd = per_bfd;
> sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
> sig_entry->dwo_unit = dwo_entry;
> + sig_entry->set_version (dwo_entry->dwarf_version);
> }
>
> /* Subroutine of lookup_signatured_type.
>
> base-commit: 917ed12066382c48459f85124cbeca1286c3bb53
@@ -324,6 +324,9 @@ struct dwo_unit
/* For types, offset in the type's DIE of the type defined by this TU. */
cu_offset type_offset_in_tu;
+
+ /* DWARF standard version of this DWO unit. */
+ unsigned char dwarf_version;
};
/* include/dwarf2.h defines the DWP section codes.
@@ -3449,6 +3452,7 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile,
dwo_tu->section = section;
dwo_tu->sect_off = sect_off;
dwo_tu->length = length;
+ dwo_tu->dwarf_version = header.version;
slot = htab_find_slot (types_htab.get (), dwo_tu, INSERT);
gdb_assert (slot != NULL);
@@ -3545,6 +3549,7 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile,
sig_entry->per_bfd = per_bfd;
sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
sig_entry->dwo_unit = dwo_entry;
+ sig_entry->set_version (dwo_entry->dwarf_version);
}
/* Subroutine of lookup_signatured_type.