public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom de Vries <tdevries@suse.de>
Subject: [PATCH gdb/symtab v2 1/7] Refactor condition in scan_attributes
Date: Mon, 08 Apr 2024 15:11:37 -0600	[thread overview]
Message-ID: <20240408-die-map-madness-v2-1-6741626d544d@tromey.com> (raw)
In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com>

From: Tom de Vries <tdevries@suse.de>

In scan_attributes there's code:
...
	  if (new_reader->cu == reader->cu
	      && new_info_ptr > watermark_ptr
	      && *parent_entry == nullptr)
	    ...
	  else if (*parent_entry == nullptr)
	    ...
...
that uses the "*parent_entry == nullptr" condition twice.

Make this somewhat more readable by factoring out the condition:
...
	  if (*parent_entry == nullptr)
	    {
	      if (new_reader->cu == reader->cu
		  && new_info_ptr > watermark_ptr)
		...
	      else
		...
	    }
...

This also allows us to factor out "form_addr (origin_offset, origin_is_dwz)".

Tested on x86_64-linux.
---
 gdb/dwarf2/read.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 9e37011ddf0..7b306d8594c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16267,15 +16267,17 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
 	  const gdb_byte *new_info_ptr = (new_reader->buffer
 					  + to_underlying (origin_offset));
 
-	  if (new_reader->cu == reader->cu
-	      && new_info_ptr > watermark_ptr
-	      && *parent_entry == nullptr)
-	    *maybe_defer = form_addr (origin_offset, origin_is_dwz);
-	  else if (*parent_entry == nullptr)
+	  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);
+	      CORE_ADDR addr = form_addr (origin_offset, origin_is_dwz);
+	      if (new_reader->cu == reader->cu
+		  && new_info_ptr > watermark_ptr)
+		*maybe_defer = addr;
+	      else
+		{
+		  void *obj = m_die_range_map.find (addr);
+		  *parent_entry = static_cast <cooked_index_entry *> (obj);
+		}
 	    }
 
 	  unsigned int bytes_read;

-- 
2.43.0


  reply	other threads:[~2024-04-08 21:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 21:11 [PATCH gdb/symtab v2 0/7] Compute DWARF entry parents across CUs Tom Tromey
2024-04-08 21:11 ` Tom Tromey [this message]
2024-04-08 21:11 ` [PATCH v2 2/7] Change handling of DW_TAG_enumeration_type in DWARF scanner Tom Tromey
2024-04-08 21:11 ` [PATCH v2 3/7] Add move operators for addrmap Tom Tromey
2024-04-08 21:11 ` [PATCH v2 4/7] Introduce class parent_map for DIE range map Tom Tromey
2024-04-08 21:11 ` [PATCH v2 5/7] Correctly handle DIE parent computations Tom Tromey
2024-04-08 21:11 ` [PATCH gdb/testsuite v2 6/7] Add gdb.dwarf2/forward-spec-inter-cu.exp Tom Tromey
2024-04-08 21:11 ` [PATCH gdb/testsuite v2 7/7] Add gdb.dwarf2/backward-spec-inter-cu.exp Tom Tromey
2024-04-16 17:54 ` [PATCH gdb/symtab v2 0/7] Compute DWARF entry parents across CUs 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=20240408-die-map-madness-v2-1-6741626d544d@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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).