[2/3] RFC: merge symbol "ops" and "aclass" fields
Jan Kratochvil
jan.kratochvil@redhat.com
Sun Feb 3 09:20:00 GMT 2013
Hi Tom,
such a minor sanity check, not sure if worth it:
On Wed, 16 Jan 2013 17:08:32 +0100, Tom Tromey wrote:
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -584,6 +587,30 @@ struct symbol_register_ops
> int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch);
> };
>
> +/* Objects of this type are used to find the address class and the
> + various computed ops vectors of a symbol. */
> +
> +struct symbol_impl
> +{
> + enum address_class aclass;
> +
> + /* Used with LOC_COMPUTED. */
> + const struct symbol_computed_ops *ops_computed;
> +
> + /* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */
> + const struct symbol_register_ops *ops_register;
> +
> + /* Used to store a per-symbol-reader datum. */
> + const void *reader_datum;
These three fields could be union.
> +};
[...]
> @@ -679,10 +692,22 @@ struct symbol
> #define SYMBOL_TYPE(symbol) (symbol)->type
> #define SYMBOL_LINE(symbol) (symbol)->line
> #define SYMBOL_SYMTAB(symbol) (symbol)->symtab
> -#define SYMBOL_COMPUTED_OPS(symbol) (symbol)->ops.ops_computed
> -#define SYMBOL_REGISTER_OPS(symbol) (symbol)->ops.ops_register
> +#define SYMBOL_COMPUTED_OPS(symbol) \
> + ((symbol_impls[(symbol)->aclass_index]).ops_computed)
> +#define SYMBOL_REGISTER_OPS(symbol) \
> + ((symbol_impls[(symbol)->aclass_index]).ops_register)
> +#define SYMBOL_READER_DATUM(symbol) \
> + ((symbol_impls[(symbol)->aclass_index]).reader_datum)
> #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value
And these accessors could gdb_assert impl->ACLASS. Currently if ACLASS does
not match it returns NULL, which would (correctly) crash on dereferencing
a method but such coding bug would not be noticed during accesses like:
if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs)
Thanks,
Jan
More information about the Gdb-patches
mailing list