[1/2] gdb/dwarf: change signatured_type_up to include deleter type
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
From: Simon Marchi <simon.marchi@polymtl.ca>
We currently have:
using dwarf2_per_cu_up = std::unique_ptr<dwarf2_per_cu, dwarf2_per_cu_deleter>;
using signatured_type_up = std::unique_ptr<signatured_type>;
Meaning that it's not possible to pass a signatured_type_up as a
dwarf2_per_cu_up, even though the target types are related (it is
possible to pass a `signatured_type *` as a `dwarf2_per_cu *`).
If we give signatured_type_up the same deleter as dwarf2_per_cu_up, then
it becomes possible to pass a signatured_type_up as a dwarf2_per_cu_up.
This lets us avoid releasing a signatured_type_up only to create a
dwarf2dwarf2_per_cu_up immediately after in some spots. The only
downside is that we can't use make_unique anymore, but it's already the
case for dwarf2_per_cu_up.
Swap the order of things in add_type_unit so that we don't need a
special holder variable.
Change-Id: Iee34e5d1711d601297f109e58cbaeccb5a0c6cde
---
gdb/dwarf2/read-debug-names.c | 2 +-
gdb/dwarf2/read-gdb-index.c | 2 +-
gdb/dwarf2/read.c | 19 ++++++++-----------
gdb/dwarf2/read.h | 3 ++-
4 files changed, 12 insertions(+), 14 deletions(-)
base-commit: ba415df8ba3817ab6eb5c9ec441ed2d979abe3b1
Comments
>>>>> "Simon" == simon marchi <simon.marchi@polymtl.ca> writes:
Simon> If we give signatured_type_up the same deleter as dwarf2_per_cu_up, then
Simon> it becomes possible to pass a signatured_type_up as a dwarf2_per_cu_up.
Simon> This lets us avoid releasing a signatured_type_up only to create a
Simon> dwarf2dwarf2_per_cu_up immediately after in some spots. The only
Simon> downside is that we can't use make_unique anymore, but it's already the
Simon> case for dwarf2_per_cu_up.
Simon> Swap the order of things in add_type_unit so that we don't need a
Simon> special holder variable.
Looks reasonable to me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
@@ -1036,7 +1036,7 @@ create_foreign_type_units_from_debug_names (dwarf2_per_bfd *per_bfd,
map.foreign_type_units.emplace_back (sig_type.get ());
per_bfd->signatured_types.emplace (sig_type.get ());
- per_bfd->all_units.emplace_back (sig_type.release ());
+ per_bfd->all_units.emplace_back (std::move (sig_type));
}
}
@@ -584,7 +584,7 @@ create_signatured_type_table_from_gdb_index
sig_types_hash.emplace (sig_type.get ());
units.emplace_back (sig_type.get ());
- per_bfd->all_units.emplace_back (sig_type.release ());
+ per_bfd->all_units.emplace_back (std::move (sig_type));
}
per_bfd->signatured_types = std::move (sig_types_hash);
@@ -1440,9 +1440,8 @@ dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section,
ULONGEST signature)
{
gdb_assert (section != nullptr);
- auto result
- = std::make_unique<signatured_type> (this, section, sect_off, length,
- is_dwz, signature);
+ signatured_type_up result (new signatured_type (this, section, sect_off,
+ length, is_dwz, signature));
result->index = all_units.size ();
this->num_type_units++;
return result;
@@ -1453,10 +1452,9 @@ dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section,
signatured_type_up
dwarf2_per_bfd::allocate_signatured_type (ULONGEST signature)
{
- auto result
- = std::make_unique<signatured_type> (this, nullptr,
- invalid_sect_offset,
- 0, false, signature);
+ signatured_type_up result (new signatured_type (this, nullptr,
+ invalid_sect_offset, 0,
+ false, signature));
result->index = all_units.size ();
this->num_type_units++;
return result;
@@ -2244,13 +2242,12 @@ add_type_unit (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section,
if (per_bfd->all_units.size () == per_bfd->all_units.capacity ())
++per_bfd->tu_stats.nr_all_type_units_reallocs;
- signatured_type_up sig_type_holder
+ signatured_type_up sig_type
= per_bfd->allocate_signatured_type (section, sect_off, length,
false /* is_dwz */, sig);
- signatured_type *sig_type = sig_type_holder.get ();
- per_bfd->all_units.emplace_back (sig_type_holder.release ());
- auto emplace_ret = per_bfd->signatured_types.emplace (sig_type);
+ auto emplace_ret = per_bfd->signatured_types.emplace (sig_type.get ());
+ per_bfd->all_units.emplace_back (std::move (sig_type));
/* Assert that an insertion took place - that there wasn't a type unit with
that signature already. */
@@ -504,7 +504,8 @@ struct signatured_type : public dwarf2_per_cu
dwarf2_per_cu *hint_per_cu = nullptr;
};
-using signatured_type_up = std::unique_ptr<signatured_type>;
+using signatured_type_up
+ = std::unique_ptr<signatured_type, dwarf2_per_cu_deleter>;
/* See dwarf2_per_cu declaration. */