public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: add nullptr check to cooked_index_functions::dump Date: Tue, 31 Jan 2023 18:22:08 +0000 (GMT) [thread overview] Message-ID: <20230131182208.E675B3858CDA@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cd07187f238b4d0135f2e331810cc5995a8be8f3 commit cd07187f238b4d0135f2e331810cc5995a8be8f3 Author: Simon Marchi <simon.marchi@efficios.com> Date: Tue Jan 31 10:57:21 2023 -0500 gdb: add nullptr check to cooked_index_functions::dump Since commit 7d82b08e9e0a ("gdb/dwarf: dump cooked index contents in cooked_index_functions::dump"), we see: maint print objfiles /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-error/dw2-error^M ^M Object file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-error/dw2-error: Objfile at 0x614000005040, bfd at 0x6120000e08c0, 15 minsyms^M ^M Cooked index in use:^M ^M /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/gdb-checked-static-cast.h:58: internal-error: checked_static_cast: Assertion `result != nullptr' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M ----- Backtrace -----^M FAIL: gdb.dwarf2/dw2-error.exp: maint print objfiles /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-error/dw2-error (GDB internal error) The problem is that when cooked_index_functions fails to build an index, per_objfile->index_table is nullptr. Therefore, add a nullptr check, like other methods of cooked_index_functions already do. Print the "Cooked index in use" message after the nullptr check, such that if the cooked index failed to build, that message is not printed. Change-Id: Id67aef592e76c41b1e3bde9838a4e36cef873253 Diff: --- gdb/dwarf2/read.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e8a3e359ada..6cee22a3faa 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -18589,14 +18589,15 @@ struct cooked_index_functions : public dwarf2_base_index_functions void dump (struct objfile *objfile) override { - gdb_printf ("Cooked index in use:\n"); - gdb_printf ("\n"); - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); cooked_index_vector *index = (gdb::checked_static_cast<cooked_index_vector *> - (per_objfile->per_bfd->index_table.get ())); + (per_objfile->per_bfd->index_table.get ())); + if (index == nullptr) + return; + gdb_printf ("Cooked index in use:\n"); + gdb_printf ("\n"); index->dump (objfile->arch ()); }
reply other threads:[~2023-01-31 18:22 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230131182208.E675B3858CDA@sourceware.org \ --to=simark@sourceware.org \ --cc=gdb-cvs@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).