public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/symtab] Refactor condition in scan_attributes
@ 2024-04-16 17:55 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-04-16 17:55 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=08b91f595d7e2f181e3ac18838ff5a9421aa4d33
commit 08b91f595d7e2f181e3ac18838ff5a9421aa4d33
Author: Tom de Vries <tdevries@suse.de>
Date: Mon Dec 11 15:41:26 2023 +0100
[gdb/symtab] Refactor condition in scan_attributes
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.
Diff:
---
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 b029c49a339..4c97fe12307 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16266,15 +16266,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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-16 17:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 17:55 [binutils-gdb] [gdb/symtab] Refactor condition in scan_attributes Tom Tromey
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).