This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb: Remove LANG_MAGIC
- From: Pedro Alves <palves at redhat dot com>
- To: Andrew Burgess <andrew dot burgess at embecosm dot com>, gdb-patches at sourceware dot org
- Date: Fri, 12 Apr 2019 10:50:00 +0100
- Subject: Re: [PATCH] gdb: Remove LANG_MAGIC
- References: <20190411232350.27832-1-andrew.burgess@embecosm.com>
On 4/12/19 12:23 AM, Andrew Burgess wrote:
> The language_defn structure has an la_magic field, this used to be
> used as a basic check that the language_defn structure had the
> expected layout - at least the end of the structure was where we
> expected it to be.
>
> This feature only really makes sense if we imagine GDB dynamically
> loading language support from dynamic libraries, where a version
> mismatch might cause problems.
We used to have more magic fields like these in other structures,
like target_ops, for example. IIRC, their intended purpose was to
catch miscompilation, before we had Makefile auto-dependencies. Before
that, it was common to change the structure's definition, rebuild, and
then find out that gdb hit a "failed internal consistency check" assertion,
because some of the .o files hadn't been rebuilt to reflect the new layout.
For example, the target_ops magic said:
/* Magic number for checking ops size. If a struct doesn't end with this
number, somebody changed the declaration but didn't change all the
places that initialize one. */
#define OPS_MAGIC 3840
With auto-dependencies, the problem this "solved" is largely a
thing of the past.
Thanks,
Pedro Alves