public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug symtab/29367] [gdb, debug-types, gdb-index] Bad CU index complaint not triggered Date: Thu, 21 Jul 2022 09:00:10 +0000 [thread overview] Message-ID: <bug-29367-4717-1nuJXTUNMT@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-29367-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=29367 Tom de Vries <vries at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement --- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> --- (In reply to Tom de Vries from comment #0) > Now the question: is this change correct? > > I can't figure out how a type in a .debug_types section would be addressed > from the index. > > Maybe 56 is the correct way to address TU 0 ? At https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html I find: ... Note that if there are type CUs, then conceptually CUs and type CUs form a single list for the purposes of CU indices. ... I guess that answers my question. So this: ... /* Don't crash on bad data. */ - if (cu_index >= per_objfile->per_bfd->all_comp_units.size (CUTU)) + if (cu_index >= per_objfile->per_bfd->all_comp_units.size (CU)) ... is incorrect, the current code is in fact correct. But we might be able to be more strict though: ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index bcd01107377..8d216318c13 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2975,7 +2975,13 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter, && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); /* Don't crash on bad data. */ - if (cu_index >= per_objfile->per_bfd->all_comp_units.size ()) + size_t nr_tus = per_objfile->per_bfd->tu_stats.nr_tus; + size_t nr_cus = (per_objfile->per_bfd->all_comp_units.size () - nr_tus); + /* Only allow type symbols in type units. */ + size_t size_for_kind = (symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE + ? nr_cus + nr_tus + : nr_cus); + if (cu_index >= size_for_kind) { complaint (_(".gdb_index entry has bad CU index" " [in module %s]"), objfile_name (per_objfile->objfile)); ... by assuming there are only type symbols in the type units, which means for other symbols we can be more strict about the allowed indices. -- You are receiving this mail because: You are on the CC list for the bug.
prev parent reply other threads:[~2022-07-21 9:00 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-14 13:35 [Bug symtab/29367] New: " vries at gcc dot gnu.org 2022-07-21 9:00 ` vries at gcc dot gnu.org [this message]
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=bug-29367-4717-1nuJXTUNMT@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@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: linkBe 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).