]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: add a constructor for symtab
authorAndrew Burgess <aburgess@redhat.com>
Fri, 31 Oct 2025 10:19:41 +0000 (10:19 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Sun, 2 Nov 2025 16:09:04 +0000 (16:09 +0000)
commit1ddfd4f3eac858294793801fa52d63d36042b4b3
tree080f414e1946d9b3c5a92ee9c00987282e558adb
parent8e9bfa66d8be6d133ba4ff026b69c19a307cd7c9
gdb: add a constructor for symtab

Convert symtab to use obstack_new, and have a real constructor.  The
filename, filename_for_id and m_compunit, members should really not
change once the symtab has been created, so make these members private
(m_compunit was already private) and set them just once from the
constructor.  The set_compunit function has been deleted, and new
getter functions for filename and filename_for_id have been added.

The language is also set at construction time, but can be updated
later, so set the language in the constructor, but retain
symtab::set_language for when the language needs to be updated.

Prior to this patch the symtab was allocated with OBSTACK_ZALLOC which
would zero out the symtab object.  With the call to objstack_new
fields in the symtab would no longer be initialised, so I've added
default member initialisation for everything not set in the
constructor.

The interesting changes are in symtab.h, and symfile.c.  Everything
else is just updating to handle symfile::filename and
symfile::filename_for_id becoming methods.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
15 files changed:
gdb/ada-lang.c
gdb/cli/cli-cmds.c
gdb/compile/compile-c-symbols.c
gdb/compile/compile-cplus-symbols.c
gdb/compile/compile-cplus-types.c
gdb/infrun.c
gdb/linespec.c
gdb/macroscope.c
gdb/python/py-breakpoint.c
gdb/skip.c
gdb/source.c
gdb/symfile-debug.c
gdb/symfile.c
gdb/symtab.c
gdb/symtab.h