[binutils-gdb] gdb/dwarf: initialize fields of virtual_v2_or_v5_dwo_sections
Simon Marchi
simark@sourceware.org
Thu Jan 15 16:21:42 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bce4770105b6edc5808e8d5269e2d3fea9e0b961
commit bce4770105b6edc5808e8d5269e2d3fea9e0b961
Author: Simon Marchi <simon.marchi@efficios.com>
Date: Wed Jan 14 22:55:25 2026 -0500
gdb/dwarf: initialize fields of virtual_v2_or_v5_dwo_sections
I noticed that create_dwo_unit_in_dwp_v2 and create_dwo_unit_in_dwp_v5
initialized structure virtual_v2_or_v5_dwo_sections differently, one
with a memset and one with default initialization. Make that consistent
by moving the initialization in the struct itself, which is less
error-prone anyway.
Change-Id: I48a21a871601d076bbeeb19befd0ad62e9ba7f2a
Approved-By: Tom Tromey <tom@tromey.com>
Diff:
---
gdb/dwarf2/read.c | 44 ++++++++++++++++++++------------------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 2c0864aefd2..b223450914e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -495,34 +495,34 @@ struct virtual_v1_dwo_sections
struct virtual_v2_or_v5_dwo_sections
{
- bfd_size_type abbrev_offset;
- bfd_size_type abbrev_size;
+ bfd_size_type abbrev_offset = 0;
+ bfd_size_type abbrev_size = 0;
- bfd_size_type line_offset;
- bfd_size_type line_size;
+ bfd_size_type line_offset = 0;
+ bfd_size_type line_size = 0;
- bfd_size_type loc_offset;
- bfd_size_type loc_size;
+ bfd_size_type loc_offset = 0;
+ bfd_size_type loc_size = 0;
- bfd_size_type loclists_offset;
- bfd_size_type loclists_size;
+ bfd_size_type loclists_offset = 0;
+ bfd_size_type loclists_size = 0;
- bfd_size_type macinfo_offset;
- bfd_size_type macinfo_size;
+ bfd_size_type macinfo_offset = 0;
+ bfd_size_type macinfo_size = 0;
- bfd_size_type macro_offset;
- bfd_size_type macro_size;
+ bfd_size_type macro_offset = 0;
+ bfd_size_type macro_size = 0;
- bfd_size_type rnglists_offset;
- bfd_size_type rnglists_size;
+ bfd_size_type rnglists_offset = 0;
+ bfd_size_type rnglists_size = 0;
- bfd_size_type str_offsets_offset;
- bfd_size_type str_offsets_size;
+ bfd_size_type str_offsets_offset = 0;
+ bfd_size_type str_offsets_size = 0;
/* Each DWP hash table entry records one CU or one TU.
That is recorded here, and copied to dwo_unit.section. */
- bfd_size_type info_or_types_offset;
- bfd_size_type info_or_types_size;
+ bfd_size_type info_or_types_offset = 0;
+ bfd_size_type info_or_types_size = 0;
};
/* Contents of DWP hash tables. */
@@ -7145,7 +7145,7 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_bfd *per_bfd,
is_debug_types ? dwp_file->tus : dwp_file->cus;
bfd *dbfd = dwp_file->dbfd.get ();
const char *kind = is_debug_types ? "TU" : "CU";
- struct virtual_v2_or_v5_dwo_sections sections;
+ virtual_v2_or_v5_dwo_sections sections;
int i;
gdb_assert (dwp_file->version == 2);
@@ -7156,8 +7156,6 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_bfd *per_bfd,
/* Fetch the section offsets of this DWO unit. */
- memset (§ions, 0, sizeof (sections));
-
for (i = 0; i < dwp_htab->nr_columns; ++i)
{
uint32_t offset = read_4_bytes (dbfd,
@@ -7308,7 +7306,7 @@ create_dwo_unit_in_dwp_v5 (dwarf2_per_bfd *per_bfd,
= is_debug_types ? dwp_file->tus : dwp_file->cus;
bfd *dbfd = dwp_file->dbfd.get ();
const char *kind = is_debug_types ? "TU" : "CU";
- struct virtual_v2_or_v5_dwo_sections sections {};
+ virtual_v2_or_v5_dwo_sections sections;
gdb_assert (dwp_file->version == 5);
@@ -7318,8 +7316,6 @@ create_dwo_unit_in_dwp_v5 (dwarf2_per_bfd *per_bfd,
/* Fetch the section offsets of this DWO unit. */
- /* memset (§ions, 0, sizeof (sections)); */
-
for (int i = 0; i < dwp_htab->nr_columns; ++i)
{
uint32_t offset = read_4_bytes (dbfd,
More information about the Gdb-cvs
mailing list