From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>,
Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 01/13] [gdb/symtab] Factor out m_die_range_map usage
Date: Thu, 30 Nov 2023 13:55:19 +0100 [thread overview]
Message-ID: <cf79e98b-7c0d-4050-9342-41d7db4c2cf7@suse.de> (raw)
In-Reply-To: <8734y5oyy7.fsf@tromey.com>
[-- Attachment #1: Type: text/plain, Size: 735 bytes --]
On 10/20/23 21:50, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> Factor out usage of cooked_indexer::m_die_range_map into new class parent_map
> Tom> with member functions find_parent and set_parent.
>
> Tom> + /* Find the parent of DIE LOOKUP. */
> Tom> + const cooked_index_entry *find_parent (CORE_ADDR lookup) const
> Tom> + {
>
> I sort of regret doing this stuff using CORE_ADDR. I think the API
> would be better if 'form_addr' was handled privately in the wrapper
> class.
This updated patch moves form_addr into the wrapper class, but doesn't
make it private because there's still one remaining reference from
outside the class.
WDYT?
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-symtab-Factor-out-m_die_range_map-usage.patch --]
[-- Type: text/x-patch, Size: 7329 bytes --]
From 946ead3f1f4d6a46c481a6dfe1578fa49afcf1a8 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Tue, 22 Aug 2023 13:17:47 +0200
Subject: [PATCH] [gdb/symtab] Factor out m_die_range_map usage
Factor out usage of cooked_indexer::m_die_range_map into new class parent_map
with member functions find_parent and set_parent.
Tested on x86_64-linux.
---
gdb/dwarf2/cooked-index.h | 51 +++++++++++++++++++++++++++++++++
gdb/dwarf2/read.c | 60 +++++++++++++++++++++------------------
2 files changed, 83 insertions(+), 28 deletions(-)
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 5675ea68bb8..47bc48ea459 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -239,6 +239,57 @@ struct cooked_index_entry : public allocate_on_obstack
bool for_name) const;
};
+class parent_map
+{
+public:
+
+ /* A DIE address as formed by form_addr, defining a tuple
+ <OFFSET, IS_DWZ>. */
+ typedef CORE_ADDR die_addr;
+
+ /* Find the parent of DIE LOOKUP. */
+ const cooked_index_entry *find_parent (die_addr lookup) const
+ {
+ const void *obj = m_parent_map.find (lookup);
+ return static_cast<const cooked_index_entry *> (obj);
+ }
+
+ /* Find the parent of DIE <OFFSET, IS_DWZ>. */
+ const cooked_index_entry *find_parent (sect_offset offset, bool is_dwz) const
+ {
+ return find_parent (form_addr (offset, is_dwz));
+ }
+
+ /* Set the parent of DIES in range [START, END] to PARENT_ENTRY. */
+ void set_parent (die_addr start, die_addr end,
+ const cooked_index_entry *parent_entry)
+ {
+ m_parent_map.set_empty (start, end, (void *)parent_entry);
+ }
+
+ /* Set the parent of DIES in range <[START, END], IS_DWZ> to PARENT_ENTRY. */
+ void set_parent (sect_offset start, sect_offset end, bool is_dwz,
+ const cooked_index_entry *parent_entry)
+ {
+ set_parent (form_addr (start, is_dwz), form_addr (end, is_dwz),
+ parent_entry);
+ }
+
+ /* A helper function to turn a tuple <OFFSET, IS_DWZ> into a die_addr. */
+ static die_addr form_addr (sect_offset offset, bool is_dwz)
+ {
+ CORE_ADDR value = to_underlying (offset);
+ if (is_dwz)
+ value |= ((CORE_ADDR) 1) << (8 * sizeof (CORE_ADDR) - 1);
+ return value;
+ }
+
+private:
+
+ /* An addrmap that maps from section offsets to cooked_index_entry *. */
+ addrmap_mutable m_parent_map;
+};
+
class cooked_index;
/* An index of interesting DIEs. This is "cooked", in contrast to a
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 9311666a832..926feab8a7a 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4552,16 +4552,6 @@ class cooked_indexer
private:
- /* A helper function to turn a section offset into an address that
- can be used in an addrmap. */
- CORE_ADDR form_addr (sect_offset offset, bool is_dwz)
- {
- CORE_ADDR value = to_underlying (offset);
- if (is_dwz)
- value |= ((CORE_ADDR) 1) << (8 * sizeof (CORE_ADDR) - 1);
- return value;
- }
-
/* A helper function to scan the PC bounds of READER and record them
in the storage's addrmap. */
void check_bounds (cutu_reader *reader);
@@ -4599,7 +4589,7 @@ class cooked_indexer
cooked_index_flag *flags,
sect_offset *sibling_offset,
const cooked_index_entry **parent_entry,
- CORE_ADDR *maybe_defer,
+ parent_map::die_addr *maybe_defer,
bool for_specification);
/* Handle DW_TAG_imported_unit, by scanning the DIE to find
@@ -4629,14 +4619,34 @@ class cooked_indexer
/* An addrmap that maps from section offsets (see the form_addr
method) to newly-created entries. See m_deferred_entries to
understand this. */
- addrmap_mutable m_die_range_map;
+ parent_map m_die_range_map;
+
+ /* Find the parent of DIE <OFFSET, IS_DWZ>. */
+ const cooked_index_entry *find_parent (sect_offset offset, bool is_dwz) const
+ {
+ return m_die_range_map.find_parent (offset, is_dwz);
+ }
+
+ /* Find the parent of DIE LOOKUP. */
+ const cooked_index_entry *find_parent (parent_map::die_addr lookup) const
+ {
+ return m_die_range_map.find_parent (lookup);
+ }
+
+ /* Set the parent of DIES in range <[START, END], IS_DWZ> to
+ PARENT_ENTRY. */
+ void set_parent (sect_offset start, sect_offset end, bool is_dwz,
+ const cooked_index_entry *parent_entry)
+ {
+ m_die_range_map.set_parent (start, end, is_dwz, parent_entry);
+ }
/* A single deferred entry. */
struct deferred_entry
{
sect_offset die_offset;
const char *name;
- CORE_ADDR spec_offset;
+ parent_map::die_addr spec_offset;
dwarf_tag tag;
cooked_index_flag flags;
};
@@ -16009,7 +16019,7 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
cooked_index_flag *flags,
sect_offset *sibling_offset,
const cooked_index_entry **parent_entry,
- CORE_ADDR *maybe_defer,
+ parent_map::die_addr *maybe_defer,
bool for_specification)
{
bool origin_is_dwz = false;
@@ -16182,13 +16192,9 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
if (new_reader->cu == reader->cu
&& new_info_ptr > watermark_ptr
&& *parent_entry == nullptr)
- *maybe_defer = form_addr (origin_offset, origin_is_dwz);
+ *maybe_defer = parent_map::form_addr (origin_offset, origin_is_dwz);
else if (*parent_entry == nullptr)
- {
- CORE_ADDR lookup = form_addr (origin_offset, origin_is_dwz);
- void *obj = m_die_range_map.find (lookup);
- *parent_entry = static_cast <cooked_index_entry *> (obj);
- }
+ *parent_entry = find_parent (origin_offset, origin_is_dwz);
unsigned int bytes_read;
const abbrev_info *new_abbrev = peek_die_abbrev (*new_reader,
@@ -16305,11 +16311,10 @@ cooked_indexer::recurse (cutu_reader *reader,
{
/* Both start and end are inclusive, so use both "+ 1" and "- 1" to
limit the range to the children of parent_entry. */
- CORE_ADDR start = form_addr (parent_entry->die_offset + 1,
- reader->cu->per_cu->is_dwz);
- CORE_ADDR end = form_addr (sect_offset (info_ptr - 1 - reader->buffer),
- reader->cu->per_cu->is_dwz);
- m_die_range_map.set_empty (start, end, (void *) parent_entry);
+ set_parent (parent_entry->die_offset + 1,
+ sect_offset (info_ptr - 1 - reader->buffer),
+ reader->cu->per_cu->is_dwz,
+ parent_entry);
}
return info_ptr;
@@ -16351,7 +16356,7 @@ cooked_indexer::index_dies (cutu_reader *reader,
const char *name = nullptr;
const char *linkage_name = nullptr;
- CORE_ADDR defer = 0;
+ parent_map::die_addr defer = 0;
cooked_index_flag flags = IS_STATIC;
sect_offset sibling {};
const cooked_index_entry *this_parent_entry = parent_entry;
@@ -16482,8 +16487,7 @@ cooked_indexer::make_index (cutu_reader *reader)
for (const auto &entry : m_deferred_entries)
{
- void *obj = m_die_range_map.find (entry.spec_offset);
- cooked_index_entry *parent = static_cast<cooked_index_entry *> (obj);
+ const cooked_index_entry *parent = find_parent (entry.spec_offset);
m_index_storage->add (entry.die_offset, entry.tag, entry.flags,
entry.name, parent, m_per_cu);
}
base-commit: 53302c2d33c26909cc8446819f6677076ba48ca9
--
2.35.3
next prev parent reply other threads:[~2023-11-30 12:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 12:50 [PATCH 00/13] [gdb/symtab, cc-with-dwz] Fix gdb.cp/breakpoint-locs.exp Tom de Vries
2023-10-02 12:50 ` [PATCH 01/13] [gdb/symtab] Factor out m_die_range_map usage Tom de Vries
2023-10-09 20:33 ` Alexandra Petlanova Hajkova
2023-10-09 21:43 ` Tom de Vries
2023-10-20 19:50 ` Tom Tromey
2023-11-30 12:55 ` Tom de Vries [this message]
2023-10-02 12:50 ` [PATCH 02/13] [gdb/symtab] Check effect in parent_map::set_parent Tom de Vries
2023-10-20 19:51 ` Tom Tromey
2023-11-30 14:05 ` Tom de Vries
2023-10-02 12:50 ` [PATCH 03/13] [gdb/symtab] Handle nullptr parent " Tom de Vries
2023-10-02 12:50 ` [PATCH 04/13] [gdb/symtab] Add parent_map::dump Tom de Vries
2023-10-10 9:05 ` Alexandra Petlanova Hajkova
2023-10-20 19:51 ` Tom Tromey
2023-10-02 12:50 ` [PATCH 05/13] [gdb/symtab] Factor out m_deferred_entries usage Tom de Vries
2023-10-02 12:50 ` [PATCH 06/13] [gdb/symtab] Add debug_handle_deferred_entries Tom de Vries
2023-10-02 12:50 ` [PATCH 07/13] [gdb/symtab] Resolve deferred entries, inter-shard case Tom de Vries
2023-10-20 20:11 ` Tom Tromey
2023-12-10 8:10 ` Tom de Vries
2023-10-02 12:50 ` [PATCH 08/13] [gdb/testsuite] Add gdb.dwarf2/forward-spec-inter-cu.exp Tom de Vries
2023-10-02 12:50 ` [PATCH 09/13] [gdb/symtab] Keep track of processed DIEs in shard Tom de Vries
2023-10-22 11:00 ` Alexandra Petlanova Hajkova
2023-12-08 12:09 ` Tom de Vries
2023-10-02 12:50 ` [PATCH 10/13] [gdb/symtab] Resolve deferred entries, intra-shard case Tom de Vries
2023-10-02 12:50 ` [PATCH 11/13] [gdb/symtab] Don't defer backward refs, inter-cu " Tom de Vries
2023-10-02 12:50 ` [PATCH 12/13] [gdb/testsuite] Add gdb.dwarf2/backward-spec-inter-cu.exp Tom de Vries
2023-10-02 12:50 ` [PATCH 13/13] [gdb/symtab] Add DW_TAG_inlined_subroutine entries in the cooked index for c++ Tom de Vries
2023-10-16 11:40 ` [PING][PATCH 00/13] [gdb/symtab, cc-with-dwz] Fix gdb.cp/breakpoint-locs.exp Tom de Vries
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=cf79e98b-7c0d-4050-9342-41d7db4c2cf7@suse.de \
--to=tdevries@suse.de \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).