From: Simon Marchi Date: Fri, 6 Feb 2026 02:52:31 +0000 (-0500) Subject: gdb/block: add assert in block_iterator::compunit_symtab X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f0eb8d61e7b1f2a17f3f09deb411b75eb531f5c;p=thirdparty%2Fbinutils-gdb.git gdb/block: add assert in block_iterator::compunit_symtab Verify that the compunit is only accessed when the iterator is in the mode where that field makes sense. We could also set compunit_symtab_ even in "single block" mode, it wouldn't hurt, but it would not be useful either. Change-Id: I237db16bb485148f9e906b2e7238159e9f0a8585 Approved-By: Tom Tromey Approved-By: Andrew Burgess Tested-By: Guinevere Larsen --- diff --git a/gdb/block.c b/gdb/block.c index 5aa58545393..730e4580a5b 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -442,6 +442,10 @@ initialize_block_iterator (const struct block *block, compunit_symtab * block_iterator::compunit_symtab () const { + /* The compunit field is only used when iterating over global or static + blocks. */ + gdb_assert (this->which != FIRST_LOCAL_BLOCK); + if (this->idx == -1) return this->compunit_symtab_;