From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/5] gdb/dwarf: move DWP htab nullptr check to lookup_dwo_unit_in_dwp
Date: Sat, 17 Jan 2026 01:02:32 -0500 [thread overview]
Message-ID: <20260117060335.691691-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20260117060335.691691-1-simon.marchi@polymtl.ca>
From: Simon Marchi <simon.marchi@polymtl.ca>
cutu_reader::lookup_dwo_cutu gets hold of the right htab for the kind of
unit to look up (CU or TU), but then just uses the pointer to know if it
should call lookup_dwo_unit_in_dwp or not. lookup_dwo_unit_in_dwp then
uses the same condition to obtain the correct htab. I think it would
make more sense to return early from lookup_dwo_unit_in_dwp instead, if
the required htab does not exist.
Change-Id: I6f8f96aba2452f8261b3c60667e72fb21b97c89d
---
gdb/dwarf2/read.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 331f1b9c5261..1b728764f711 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -6967,8 +6967,12 @@ lookup_dwo_unit_in_dwp (dwarf2_per_bfd *per_bfd,
struct dwp_file *dwp_file, const char *comp_dir,
ULONGEST signature, int is_debug_types)
{
- const struct dwp_hash_table *dwp_htab =
- is_debug_types ? dwp_file->tus : dwp_file->cus;
+ const dwp_hash_table *dwp_htab
+ = is_debug_types ? dwp_file->tus : dwp_file->cus;
+
+ if (dwp_htab == nullptr)
+ return nullptr;
+
bfd *dbfd = dwp_file->dbfd.get ();
uint32_t mask = dwp_htab->nr_slots - 1;
uint32_t hash = signature & mask;
@@ -7522,25 +7526,19 @@ cutu_reader::lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name,
dwp_file *dwp_file = per_objfile->per_bfd->dwp_file.get ();
- if (dwp_file != NULL)
+ if (dwp_file != nullptr)
{
- const struct dwp_hash_table *dwp_htab =
- is_debug_types ? dwp_file->tus : dwp_file->cus;
+ dwo_unit *dwo_cutu
+ = lookup_dwo_unit_in_dwp (per_bfd, dwp_file, comp_dir, signature,
+ is_debug_types);
- if (dwp_htab != NULL)
+ if (dwo_cutu != nullptr)
{
- struct dwo_unit *dwo_cutu =
- lookup_dwo_unit_in_dwp (per_bfd, dwp_file, comp_dir, signature,
- is_debug_types);
+ dwarf_read_debug_printf ("Virtual DWO %s %s found: @%s",
+ kind, hex_string (signature),
+ host_address_to_string (dwo_cutu));
- if (dwo_cutu != NULL)
- {
- dwarf_read_debug_printf ("Virtual DWO %s %s found: @%s",
- kind, hex_string (signature),
- host_address_to_string (dwo_cutu));
-
- return dwo_cutu;
- }
+ return dwo_cutu;
}
}
else
--
2.52.0
next prev parent reply other threads:[~2026-01-17 6:05 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 ` [PATCH 1/5] gdb/dwarf: merge one CU/TU code path simon.marchi
2026-01-17 6:02 ` simon.marchi [this message]
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-3-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