From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 38/38] Remove "keep" parameter from cutu_reader constructor
Date: Thu, 23 Jan 2020 00:57:00 -0000 [thread overview]
Message-ID: <20200123005710.7978-39-tom@tromey.com> (raw)
In-Reply-To: <20200123005710.7978-1-tom@tromey.com>
cutu_reader has a "keep" parameter, which is used to decide what to do
with a new CU when the reader is destroyed. Most code does not try to
preserve the CU, so this patch removes this parameter and instead adds
a new method that users can call to preserve the CU on the chain.
2020-01-22 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (class cutu_reader) <cutu_reader,
init_tu_and_read_dwo_dies>: Remove "keep" parameter.
<keep>: Declare method.
<m_keep>: Remove member.
<~cutu_reader>: Default.
(cutu_reader::init_tu_and_read_dwo_dies): Update.
(cutu_reader::cutu_reader): Update.
(cutu_reader::keep): Rename from ~cutu_reader.
(process_psymtab_comp_unit, build_type_psymtabs_1)
(process_skeletonless_type_unit, load_partial_comp_unit)
(load_full_comp_unit, dwarf2_read_addr_index)
(read_signatured_type): Update.
Change-Id: I859b1c64313569d76d46317c14e9b077ebc3a27b
---
gdb/ChangeLog | 15 +++++++++++++
gdb/dwarf2/read.c | 55 +++++++++++++++++++++++++----------------------
2 files changed, 44 insertions(+), 26 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index d1a78afd8cf..754b752dc5d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -881,14 +881,14 @@ public:
cutu_reader (struct dwarf2_per_cu_data *this_cu,
struct abbrev_table *abbrev_table,
- int use_existing_cu, int keep,
+ int use_existing_cu,
bool skip_partial);
explicit cutu_reader (struct dwarf2_per_cu_data *this_cu,
struct dwarf2_cu *parent_cu = nullptr,
struct dwo_file *dwo_file = nullptr);
- ~cutu_reader ();
+ ~cutu_reader () = default;
DISABLE_COPY_AND_ASSIGN (cutu_reader);
@@ -896,12 +896,15 @@ public:
struct die_info *comp_unit_die = nullptr;
bool dummy_p = false;
+ /* Release the new CU, putting it on the chain. This cannot be done
+ for dummy CUs. */
+ void keep ();
+
private:
void init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
- int use_existing_cu, int keep);
+ int use_existing_cu);
struct dwarf2_per_cu_data *m_this_cu;
- int m_keep = 0;
std::unique_ptr<dwarf2_cu> m_new_cu;
/* The ordinary abbreviation table. */
@@ -6730,7 +6733,7 @@ lookup_dwo_unit (struct dwarf2_per_cu_data *this_cu,
void
cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
- int use_existing_cu, int keep)
+ int use_existing_cu)
{
struct signatured_type *sig_type;
struct die_reader_specs reader;
@@ -6778,19 +6781,14 @@ cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
This is an optimization for when we already have the abbrev table.
If USE_EXISTING_CU is non-zero, and THIS_CU->cu is non-NULL, then use it.
- Otherwise, a new CU is allocated with xmalloc.
-
- If KEEP is non-zero, then if we allocated a dwarf2_cu we add it to
- read_in_chain. Otherwise the dwarf2_cu data is freed at the
- end. */
+ Otherwise, a new CU is allocated with xmalloc. */
cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
struct abbrev_table *abbrev_table,
- int use_existing_cu, int keep,
+ int use_existing_cu,
bool skip_partial)
: die_reader_specs {},
- m_this_cu (this_cu),
- m_keep (keep)
+ m_this_cu (this_cu)
{
struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
@@ -6810,9 +6808,6 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
this_cu->is_debug_types ? "type" : "comp",
sect_offset_str (this_cu->sect_off));
- if (use_existing_cu)
- gdb_assert (keep);
-
/* If we're reading a TU directly from a DWO file, including a virtual DWO
file (instead of going through the stub), short-circuit all of this. */
if (this_cu->reading_dwo_directly)
@@ -6820,7 +6815,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
/* Narrow down the scope of possibilities to have to understand. */
gdb_assert (this_cu->is_debug_types);
gdb_assert (abbrev_table == NULL);
- init_tu_and_read_dwo_dies (this_cu, use_existing_cu, keep);
+ init_tu_and_read_dwo_dies (this_cu, use_existing_cu);
return;
}
@@ -6976,10 +6971,12 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
}
}
-cutu_reader::~cutu_reader ()
+void
+cutu_reader::keep ()
{
/* Done, clean up. */
- if (m_new_cu != NULL && m_keep && !dummy_p)
+ gdb_assert (!dummy_p);
+ if (m_new_cu != NULL)
{
struct dwarf2_per_objfile *dwarf2_per_objfile
= m_this_cu->dwarf2_per_objfile;
@@ -7384,7 +7381,7 @@ process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu,
if (this_cu->cu != NULL)
free_one_cached_comp_unit (this_cu);
- cutu_reader reader (this_cu, NULL, 0, 0, false);
+ cutu_reader reader (this_cu, NULL, 0, false);
if (reader.dummy_p)
{
@@ -7553,7 +7550,7 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
}
cutu_reader reader (&tu.sig_type->per_cu, abbrev_table.get (),
- 0, 0, false);
+ 0, false);
if (!reader.dummy_p)
build_type_psymtabs_reader (&reader, reader.info_ptr,
reader.comp_unit_die);
@@ -7661,7 +7658,7 @@ process_skeletonless_type_unit (void **slot, void *info)
*slot = entry;
/* This does the job that build_type_psymtabs_1 would have done. */
- cutu_reader reader (&entry->per_cu, NULL, 0, 0, false);
+ cutu_reader reader (&entry->per_cu, NULL, 0, false);
if (!reader.dummy_p)
build_type_psymtabs_reader (&reader, reader.info_ptr,
reader.comp_unit_die);
@@ -7790,7 +7787,7 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile)
static void
load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu)
{
- cutu_reader reader (this_cu, NULL, 1, 1, false);
+ cutu_reader reader (this_cu, NULL, 1, false);
if (!reader.dummy_p)
{
@@ -7802,6 +7799,8 @@ load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu)
If not, there's no more debug_info for this comp unit. */
if (reader.comp_unit_die->has_children)
load_partial_dies (&reader, reader.info_ptr, 0);
+
+ reader.keep ();
}
}
@@ -8937,7 +8936,7 @@ load_full_comp_unit (struct dwarf2_per_cu_data *this_cu,
{
gdb_assert (! this_cu->is_debug_types);
- cutu_reader reader (this_cu, NULL, 1, 1, skip_partial);
+ cutu_reader reader (this_cu, NULL, 1, skip_partial);
if (reader.dummy_p)
return;
@@ -8968,6 +8967,8 @@ load_full_comp_unit (struct dwarf2_per_cu_data *this_cu,
Similarly, if we do not read the producer, we can not apply
producer-specific interpretation. */
prepare_one_comp_unit (cu, cu->dies, pretend_language);
+
+ reader.keep ();
}
/* Add a DIE to the delayed physname list. */
@@ -18961,7 +18962,7 @@ dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu,
}
else
{
- cutu_reader reader (per_cu, NULL, 0, 0, false);
+ cutu_reader reader (per_cu, NULL, 0, false);
addr_base = reader.cu->addr_base;
addr_size = reader.cu->header.addr_size;
}
@@ -22791,7 +22792,7 @@ read_signatured_type (struct signatured_type *sig_type)
gdb_assert (per_cu->is_debug_types);
gdb_assert (per_cu->cu == NULL);
- cutu_reader reader (per_cu, NULL, 0, 1, false);
+ cutu_reader reader (per_cu, NULL, 0, false);
if (!reader.dummy_p)
{
@@ -22822,6 +22823,8 @@ read_signatured_type (struct signatured_type *sig_type)
correctly. Similarly, if we do not read the producer, we can
not apply producer-specific interpretation. */
prepare_one_comp_unit (cu, cu->dies, language_minimal);
+
+ reader.keep ();
}
sig_type->per_cu.tu_read = 1;
--
2.17.2
next prev parent reply other threads:[~2020-01-23 0:57 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-23 0:57 [PATCH 00/38] Start reorganization of DWARF code Tom Tromey
2020-01-23 0:57 ` [PATCH 14/38] Change dwarf2_per_objfile::signatured_types to be htab_up Tom Tromey
2020-02-08 16:55 ` Simon Marchi
2020-01-23 0:57 ` [PATCH 25/38] Change file_full_name and file_file_name methods Tom Tromey
2020-01-27 13:31 ` Christian Biesinger via gdb-patches
2020-01-23 0:57 ` [PATCH 18/38] Change dwp_file to use htab_up Tom Tromey
2020-01-23 0:57 ` [PATCH 12/38] Introduce die_info::has_children Tom Tromey
2020-01-23 0:57 ` [PATCH 04/38] Create dwarf2/abbrev.[ch] Tom Tromey
2020-01-23 0:57 ` [PATCH 10/38] Remove die_reader_specs::comp_dir Tom Tromey
2020-01-23 0:57 ` [PATCH 28/38] Move dwarf2_per_cu_data::imported_symtabs earlier Tom Tromey
2020-01-23 0:57 ` [PATCH 20/38] Minor cleanups in abbrev_table Tom Tromey
2020-01-23 0:57 ` [PATCH 30/38] Unify read_initial_length implementations Tom Tromey
2020-01-27 13:31 ` Christian Biesinger via gdb-patches
2020-01-28 0:54 ` Tom Tromey
2020-01-23 0:57 ` [PATCH 17/38] Don't allocate DWO file hash on obstack Tom Tromey
2020-01-23 0:57 ` [PATCH 24/38] Move dwarf_always_disassemble to dwarf2/loc.c Tom Tromey
2020-01-23 0:57 ` [PATCH 09/38] Don't declare die_info in dwarf2read.h Tom Tromey
2020-01-23 0:57 ` [PATCH 35/38] Convert read_address to a method on comp_unit_head Tom Tromey
2020-01-23 0:57 ` [PATCH 07/38] Change attr_form_is_block to be a method Tom Tromey
2020-01-23 0:57 ` [PATCH 16/38] Change dwarf2_per_objfile::line_header_hash to htab_up Tom Tromey
2020-01-23 0:57 ` [PATCH 19/38] Change dwarf2_per_objfile::die_type_hash " Tom Tromey
2020-01-23 0:57 ` [PATCH 31/38] Convert dwarf2_section_size to a method Tom Tromey
2020-01-23 0:57 ` [PATCH 27/38] Move DWARF line_header to new file Tom Tromey
2020-01-23 0:57 ` Tom Tromey [this message]
2020-02-08 17:36 ` [PATCH 38/38] Remove "keep" parameter from cutu_reader constructor Simon Marchi
2020-01-23 0:57 ` [PATCH 05/38] Create dwarf2/attribute.[ch] Tom Tromey
2020-01-23 0:57 ` [PATCH 32/38] Move read_offset_1 to leb.c Tom Tromey
2020-01-23 0:57 ` [PATCH 13/38] Remove DWARF queue-related globals Tom Tromey
2020-01-23 0:57 ` [PATCH 22/38] Minor simplification in abbrev_table::read Tom Tromey
2020-01-23 0:57 ` [PATCH 34/38] Convert read_offset to method on comp_unit_head Tom Tromey
2020-01-23 0:57 ` [PATCH 21/38] Use htab_up in abbrev_table Tom Tromey
2020-01-23 0:57 ` [PATCH 02/38] Create dwarf2/section.[ch] Tom Tromey
2020-01-23 0:57 ` [PATCH 15/38] Change dwarf2_per_objfile::type_unit_groups to htab_up Tom Tromey
2020-01-23 0:57 ` [PATCH 36/38] Move two more functions to dwarf2/leb.h Tom Tromey
2020-01-23 0:57 ` [PATCH 33/38] Create dwarf2/comp-unit.[ch] Tom Tromey
2020-01-23 0:57 ` [PATCH 23/38] Change dwarf2_per_objfile::quick_file_names_table to htab_up Tom Tromey
2020-01-23 0:57 ` [PATCH 08/38] Remove die_info_ptr typedef Tom Tromey
2020-01-23 0:57 ` [PATCH 01/38] Create dwarf2/leb.[ch] Tom Tromey
2020-01-23 0:57 ` [PATCH 11/38] Move DWARF code to dwarf2/ subdirectory Tom Tromey
2020-01-27 13:41 ` Christian Biesinger via gdb-patches
2020-01-28 3:12 ` Tom Tromey
2020-01-23 0:57 ` [PATCH 06/38] Change some attribute functions to be methods Tom Tromey
2020-01-23 0:57 ` [PATCH 26/38] Change line_table methods to return unique_xmalloc_ptr Tom Tromey
2020-01-23 1:12 ` [PATCH 03/38] Change section functions to be methods of dwarf2_section_info Tom Tromey
2020-01-23 1:21 ` [PATCH 29/38] Add some methods to dwarf2_per_cu_data Tom Tromey
2020-01-23 2:34 ` [PATCH 37/38] Simplify "want_partial_unit" handling Tom Tromey
2020-02-08 17:38 ` [PATCH 00/38] Start reorganization of DWARF code Simon Marchi
2020-02-08 20:45 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200123005710.7978-39-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).