[binutils-gdb] gdb/dwarf: add dwo_file::find_tus
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6f2d5f677a947ca9c77e8818d943124db4609c03 commit 6f2d5f677a947ca9c77e8818d943124db4609c03 Author: Simon Marchi <[email protected]> Date: Mon May 11 11:40:29 2026 -0400 gdb/dwarf: add dwo_file::find_tus Add this little helper to make finding a TU a bit simpler. I always find the STL way of doing things cryptic, so I think that hiding it in small helper methods makes the code clearer. A subsequent patch will add more uses of it Change-Id: Ibfb20d0e44c65d2ff729f3e0980ec4435f223aef Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/dwarf2/dwo.h | 11 +++++++++++ gdb/dwarf2/read.c | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/dwo.h b/gdb/dwarf2/dwo.h index 025932b1e96..47d7bdde792 100644 --- a/gdb/dwarf2/dwo.h +++ b/gdb/dwarf2/dwo.h @@ -121,6 +121,17 @@ struct dwo_file dwo_file () = default; DISABLE_COPY_AND_ASSIGN (dwo_file); + /* Look for a type unit with signature SIGNATURE in this dwo_file. + + Return nullptr if not found. */ + dwo_unit *find_tu (ULONGEST signature) const + { + if (auto it = this->tus.find (signature); it != this->tus.end ()) + return it->get (); + + return nullptr; + } + /* The DW_AT_GNU_dwo_name or DW_AT_dwo_name attribute. For virtual DWO files the name is constructed from the section offsets of abbrev,line,loc,str_offsets so that we combine virtual DWO files diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4d797b0e29b..9cb7b83cc33 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2311,12 +2311,10 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig) /* Note: cu->dwo_unit is the dwo_unit that references this TU, not the dwo_unit of the TU itself. */ dwo_file *dwo_file = cu->dwo_unit->dwo_file; - auto it = dwo_file->tus.find (sig); - if (it == dwo_file->tus.end ()) + dwo_unit *dwo_entry = dwo_file->find_tu (sig); + if (dwo_entry == nullptr) return nullptr; - dwo_unit *dwo_entry = it->get (); - /* If the global table doesn't have an entry for this TU, add one. */ if (sig_type_it == per_bfd->signatured_types.end ()) {