aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2025-05-12 15:09:44 -0400
committerSimon Marchi <simon.marchi@efficios.com>2025-05-23 11:12:53 -0400
commite95749bd0d5579d1e87eaef0d667f23591bf3521 (patch)
tree6a5f8a0ec4aa2bc0e107efa69a2c972c234e6417
parente82c588969ab1542d7fb32f675e190897e28b64d (diff)
downloadbinutils-e95749bd0d5579d1e87eaef0d667f23591bf3521.zip
binutils-e95749bd0d5579d1e87eaef0d667f23591bf3521.tar.gz
binutils-e95749bd0d5579d1e87eaef0d667f23591bf3521.tar.bz2
gdb/dwarf: allocate DWP dwarf2_section_info with new
For the same reason as explained in the previous patch (allocations on obstacks aren't thread-safe), change the allocation of dwarf2_section_info object for dwo files within dwp files to use "new". The dwo_file::section object is not always owned by the dwo_file, so introduce a new "dwo_file::section_holder" object that is only set when the dwo_file owns the dwarf2_section_info. Change-Id: I74c4608573c7a435bf3dadb83f96a805d21798a2 Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r--gdb/dwarf2/read.c9
-rw-r--r--gdb/dwarf2/section.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3d4e4a0..b1849b9 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -299,6 +299,9 @@ struct dwo_unit
/* The section this CU/TU lives in, in the DWO file. */
dwarf2_section_info *section = nullptr;
+ /* This is set if SECTION is owned by this dwo_unit. */
+ dwarf2_section_info_up section_holder;
+
/* Same as dwarf2_per_cu::{sect_off,length} but in the DWO section. */
sect_offset sect_off {};
unsigned int length = 0;
@@ -6938,7 +6941,8 @@ create_dwo_unit_in_dwp_v1 (dwarf2_per_bfd *per_bfd,
auto dwo_unit = std::make_unique<struct dwo_unit> ();
dwo_unit->dwo_file = dwo_file;
dwo_unit->signature = signature;
- dwo_unit->section = XOBNEW (&per_bfd->obstack, struct dwarf2_section_info);
+ dwo_unit->section_holder = std::make_unique<dwarf2_section_info> ();
+ dwo_unit->section = dwo_unit->section_holder.get ();
*dwo_unit->section = sections.info_or_types;
/* dwo_unit->{offset,length,type_offset_in_tu} are set later. */
@@ -7143,7 +7147,8 @@ create_dwo_unit_in_dwp_v2 (dwarf2_per_bfd *per_bfd,
auto dwo_unit = std::make_unique<struct dwo_unit> ();
dwo_unit->dwo_file = dwo_file;
dwo_unit->signature = signature;
- dwo_unit->section = XOBNEW (&per_bfd->obstack, struct dwarf2_section_info);
+ dwo_unit->section_holder = std::make_unique<dwarf2_section_info> ();
+ dwo_unit->section = dwo_unit->section_holder.get ();
*dwo_unit->section = create_dwp_v2_or_v5_section
(per_bfd,
is_debug_types
diff --git a/gdb/dwarf2/section.h b/gdb/dwarf2/section.h
index b9d3c31..fd6e34d 100644
--- a/gdb/dwarf2/section.h
+++ b/gdb/dwarf2/section.h
@@ -112,4 +112,6 @@ struct dwarf2_section_info
bool is_virtual;
};
+using dwarf2_section_info_up = std::unique_ptr<dwarf2_section_info>;
+
#endif /* GDB_DWARF2_SECTION_H */