Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 1/5] gdb/dwarf: merge one CU/TU code path
Date: Sat, 17 Jan 2026 01:02:31 -0500	[thread overview]
Message-ID: <20260117060335.691691-2-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20260117060335.691691-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@polymtl.ca>

Simplify the code by merging the paths for CUs and TUs.  It is also not
necessary to check if the maps are empty.

Change-Id: I43e2cf4bb1217a72dda8a03957ed733f87bf57b2
---
 gdb/dwarf2/read.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 98cc1aa5b941..331f1b9c5261 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -7560,30 +7560,19 @@ cutu_reader::lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name,
 	    dwo_file = add_dwo_file (per_bfd, std::move (new_dwo_file));
 	}
 
-      if (dwo_file != NULL)
+      if (dwo_file != nullptr)
 	{
-	  struct dwo_unit *dwo_cutu = NULL;
+	  dwo_unit_set &dwo_units
+	    = is_debug_types ? dwo_file->tus : dwo_file->cus;
 
-	  if (is_debug_types && !dwo_file->tus.empty ())
+	  if (auto dwo_unit_it = dwo_units.find (signature);
+	      dwo_unit_it != dwo_units.end ())
 	    {
-	      if (auto it = dwo_file->tus.find (signature);
-		  it != dwo_file->tus.end ())
-		dwo_cutu = it->get ();
-	    }
-	  else if (!is_debug_types && !dwo_file->cus.empty ())
-	    {
-	      if (auto it = dwo_file->cus.find (signature);
-		  it != dwo_file->cus.end ())
-		dwo_cutu = it->get ();
-	    }
-
-	  if (dwo_cutu != NULL)
-	    {
-	      dwarf_read_debug_printf ("DWO %s %s(%s) found: @%s",
-				       kind, dwo_name, hex_string (signature),
-				       host_address_to_string (dwo_cutu));
-
-	      return dwo_cutu;
+	      dwarf_read_debug_printf
+		("DWO %s %s(%s) found: @%s", kind, dwo_name,
+		 hex_string (signature),
+		 host_address_to_string (dwo_unit_it->get ()));
+	      return dwo_unit_it->get ();
 	    }
 	}
     }
-- 
2.52.0


  reply	other threads:[~2026-01-17  6:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17  6:02 [PATCH 0/5] Some semi-random DWARF cleanups simon.marchi
2026-01-17  6:02 ` simon.marchi [this message]
2026-01-17  6:02 ` [PATCH 2/5] gdb/dwarf: move DWP htab nullptr check to lookup_dwo_unit_in_dwp simon.marchi
2026-01-17  6:02 ` [PATCH 3/5] gdb/dwarf: add comments to debug_names::build simon.marchi
2026-01-17  6:02 ` [PATCH 4/5] gdb/dwarf: rename some abbrev-related things in debug_names writer simon.marchi
2026-01-17  6:02 ` [PATCH 5/5] gdb/dwarf: add unit_lists structure to index writer simon.marchi
2026-01-20 17:00   ` Tom Tromey
2026-01-20 17:33     ` Simon Marchi
2026-01-20 20:42       ` Tom Tromey
2026-01-20 21:12         ` Simon Marchi
2026-01-20 17:00 ` [PATCH 0/5] Some semi-random DWARF cleanups 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=20260117060335.691691-2-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --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