From: Luis Machado <luis.machado@linaro.org>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 05/14] Introduce dwarf2_unshareable and move die_type_hash
Date: Tue, 18 Feb 2020 11:23:00 -0000 [thread overview]
Message-ID: <8b5bda21-39f2-a7ca-d3e9-b5fb938e7099@linaro.org> (raw)
In-Reply-To: <20200215165444.32653-6-tom@tromey.com>
Just one nit...
On 2/15/20 1:54 PM, Tom Tromey wrote:
> The goal of this series is to share dwarf2_per_objfile across
> objfiles. However, this is difficult to do, because it has some
> members that are inherently per-objfile.
>
> This patch introduces a new "unshareable" object. The idea here is
> that we'll have one such object per objfile, and we'll temporarily
> update the pointer when needed. This is a bit ugly, but it's
> convenient, because it doesn't require a huge rewriting of the DWARF
> code. (I would be in favor of such a rewriting, but ... it's huge.)
>
> This patch further moves one such member, the DIE type hash, to the
> new structure.
>
> In this patch, the new object is managed by the dwarf2_per_objfile.
> However, by the end of the series, this will change.
>
> gdb/ChangeLog
> 2020-02-15 Tom Tromey <tom@tromey.com>
>
> * dwarf2/read.h (struct dwarf2_unshareable): New type.
> (struct dwarf2_per_objfile) <die_type_hash>: Move to
> dwarf2_unshareable.
> <unshareable>: New member.
> * dwarf2/read.c (dwarf2_per_objfile::dwarf2_per_objfile):
> Initialize "unshareable".
> (dwarf2_per_objfile::~dwarf2_per_objfile): Delete unshareable.
> (set_die_type, get_die_type_at_offset): Update.
> ---
> gdb/ChangeLog | 11 +++++++++++
> gdb/dwarf2/read.c | 19 +++++++++++++------
> gdb/dwarf2/read.h | 28 +++++++++++++++++++++++-----
> 3 files changed, 47 insertions(+), 11 deletions(-)
>
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index a897b11693a..cb04eb19beb 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -1774,7 +1774,10 @@ dwarf2_per_objfile::dwarf2_per_objfile (struct objfile *objfile_,
> const dwarf2_debug_sections *names,
> bool can_copy_)
> : objfile (objfile_),
> - can_copy (can_copy_)
> + can_copy (can_copy_),
> + /* Temporarily just allocate one per objfile -- we don't have
> + sharing yet. */
> + unshareable (new dwarf2_unshareable)
> {
> if (names == NULL)
> names = &dwarf2_elf_names;
> @@ -1796,6 +1799,8 @@ dwarf2_per_objfile::~dwarf2_per_objfile ()
> for (signatured_type *sig_type : all_type_units)
> sig_type->per_cu.imported_symtabs_free ();
>
> + delete unshareable;
> +
> /* Everything else should be on the objfile obstack. */
> }
>
> @@ -24434,8 +24439,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
> cu->per_cu->addr_type ()))
> add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type);
>
> - if (dwarf2_per_objfile->die_type_hash == NULL)
> - dwarf2_per_objfile->die_type_hash
> + if (dwarf2_per_objfile->unshareable->die_type_hash == NULL)
> + dwarf2_per_objfile->unshareable->die_type_hash
> = htab_up (htab_create_alloc (127,
> per_cu_offset_and_type_hash,
> per_cu_offset_and_type_eq,
> @@ -24445,7 +24450,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
> ofs.sect_off = die->sect_off;
> ofs.type = type;
> slot = (struct dwarf2_per_cu_offset_and_type **)
> - htab_find_slot (dwarf2_per_objfile->die_type_hash.get (), &ofs, INSERT);
> + htab_find_slot (dwarf2_per_objfile->unshareable->die_type_hash.get (),
> + &ofs, INSERT);
> if (*slot)
> complaint (_("A problem internal to GDB: DIE %s has type already set"),
> sect_offset_str (die->sect_off));
> @@ -24465,13 +24471,14 @@ get_die_type_at_offset (sect_offset sect_off,
> struct dwarf2_per_cu_offset_and_type *slot, ofs;
> struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
>
> - if (dwarf2_per_objfile->die_type_hash == NULL)
> + if (dwarf2_per_objfile->unshareable->die_type_hash == NULL)
> return NULL;
>
> ofs.per_cu = per_cu;
> ofs.sect_off = sect_off;
> slot = ((struct dwarf2_per_cu_offset_and_type *)
> - htab_find (dwarf2_per_objfile->die_type_hash.get (), &ofs));
> + htab_find (dwarf2_per_objfile->unshareable->die_type_hash.get (),
> + &ofs));
> if (slot)
> return slot->type;
> else
> diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
> index 5fa8dec9bfb..06a0fa3a19a 100644
> --- a/gdb/dwarf2/read.h
> +++ b/gdb/dwarf2/read.h
> @@ -66,6 +66,24 @@ struct dwarf2_queue_item
> enum language pretend_language;
> };
>
> +/* Some DWARF data cannot (currently) be shared across objfiles. Such
> + data is stored in this object.
> +
> + dwarf2_per_objfile holds a pointer to an instance of this object.
> + This pointer is temporarily set when expanding CUs. This hackish
> + approach is due to the history of the DWARF reader. In the past,
> + all objects were stored per-objfile, and this object was introduced
> + in the process of separating out the shareable and per-objfile
> + state. */
> +
> +struct dwarf2_unshareable
> +{
> + /* Table mapping type DIEs to their struct type *.
> + This is NULL if not allocated yet.
"This is nullptr"
> + The mapping is done via (CU/TU + DIE offset) -> type. */
> + htab_up die_type_hash;
> +};
> +
> /* Collection of data recorded per objfile.
> This hangs off of dwarf2_objfile_data_key. */
>
> @@ -214,11 +232,6 @@ public:
> symbols. */
> bool reading_partial_symbols = false;
>
> - /* Table mapping type DIEs to their struct type *.
> - This is NULL if not allocated yet.
> - The mapping is done via (CU/TU + DIE offset) -> type. */
> - htab_up die_type_hash;
> -
> /* The CUs we recently read. */
> std::vector<dwarf2_per_cu_data *> just_read_cus;
>
> @@ -241,6 +254,11 @@ public:
>
> /* CUs that are queued to be read. */
> std::queue<dwarf2_queue_item> queue;
> +
> + /* State that cannot be shared across objfiles. This is normally
> + nullptr and is temporarily set to the correct value at the entry
> + points of the reader. */
> + dwarf2_unshareable *unshareable = nullptr;
> };
>
> /* Get the dwarf2_per_objfile associated to OBJFILE. */
>
next prev parent reply other threads:[~2020-02-18 11:23 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-15 16:54 [PATCH 00/14] Share DWARF partial symtabs between objfiles Tom Tromey
2020-02-15 16:55 ` [PATCH 14/14] Share DWARF partial symtabs Tom Tromey
2020-02-18 12:26 ` Luis Machado
2020-02-21 23:03 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 05/14] Introduce dwarf2_unshareable and move die_type_hash Tom Tromey
2020-02-18 11:23 ` Luis Machado [this message]
2020-02-19 4:20 ` Simon Marchi
2020-02-21 22:43 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 11/14] Split type_unit_group Tom Tromey
2020-02-18 12:08 ` Luis Machado
2020-02-22 0:40 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 03/14] Introduce dwarf2_per_objfile::obstack Tom Tromey
2020-02-19 4:13 ` Simon Marchi
2020-02-22 0:44 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 12/14] Fix a memory leak and remove an unused member Tom Tromey
2020-02-15 16:55 ` [PATCH 02/14] Simplify setting of reading_partial_symbols Tom Tromey
2020-02-15 16:55 ` [PATCH 07/14] Add dwarf2_per_cu_data::index Tom Tromey
2020-02-18 11:39 ` Luis Machado
2020-02-21 23:36 ` Tom Tromey
2020-02-19 4:36 ` Simon Marchi
2020-02-19 5:31 ` Simon Marchi
2020-02-21 23:41 ` Tom Tromey
2020-02-21 23:41 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 06/14] Add "objfile" parameter to two partial_symtab methods Tom Tromey
2020-02-18 11:26 ` Luis Machado
2020-02-15 16:55 ` [PATCH 10/14] Introduce dwarf2_enter_objfile and use it Tom Tromey
2020-02-18 11:58 ` Luis Machado
2020-02-21 22:54 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 09/14] Add objfile member to DWARF batons Tom Tromey
2020-02-15 16:55 ` [PATCH 01/14] Fix latent bug in dwarf2_find_containing_comp_unit Tom Tromey
2020-02-19 3:42 ` Simon Marchi
2020-02-19 14:08 ` Tom Tromey
2020-02-20 0:11 ` Tom Tromey
2020-02-20 0:12 ` Tom Tromey
[not found] ` <3a3f1f39-c715-58ba-06a8-2980afb82c53@simark.ca>
2020-02-20 16:50 ` Tom Tromey
2020-03-07 19:12 ` Christian Biesinger
2020-02-15 16:55 ` [PATCH 13/14] Move signatured_type::type to unshareable object Tom Tromey
2020-02-15 16:55 ` [PATCH 04/14] Convert IS_TYPE_UNIT_GROUP to method Tom Tromey
2020-02-15 16:55 ` [PATCH 08/14] Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data Tom Tromey
2020-02-18 11:50 ` Luis Machado
2020-02-19 4:47 ` Simon Marchi
2020-02-22 0:38 ` Tom Tromey
2020-02-22 0:36 ` Tom Tromey
2020-02-17 12:31 ` [PATCH 00/14] Share DWARF partial symtabs between objfiles Luis Machado
2020-02-17 16:59 ` Tom Tromey
2020-02-22 21:50 ` Tom de Vries
2020-02-22 22:01 ` Tom Tromey
2020-02-23 2:37 ` Simon Marchi
2020-02-23 23:58 ` Tom Tromey
2020-02-24 2:52 ` Simon Marchi
2020-02-24 3:07 ` Tom Tromey
2020-02-24 3:22 ` Tom Tromey
2020-02-24 13:42 ` Tom de Vries
2020-02-24 16:00 ` Tom de Vries
2020-02-24 17:29 ` Tom Tromey
2020-02-24 23:15 ` Tom Tromey
2020-02-24 19:18 ` Simon Marchi
2020-02-24 23:20 ` Tom Tromey
2020-02-24 22:48 ` 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=8b5bda21-39f2-a7ca-d3e9-b5fb938e7099@linaro.org \
--to=luis.machado@linaro.org \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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