Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [2/3] RFC: merge symbol "ops" and "aclass" fields
Date: Sun, 03 Feb 2013 09:20:00 -0000	[thread overview]
Message-ID: <20130203092001.GD16948@host2.jankratochvil.net> (raw)
In-Reply-To: <8738y1hzzz.fsf@fleche.redhat.com>

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


  parent reply	other threads:[~2013-02-03  9:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 16:09 Tom Tromey
2013-02-03  9:06 ` Jan Kratochvil
2013-02-06 15:40   ` Tom Tromey
2013-02-06 15:52     ` Jan Kratochvil
2013-02-07 18:24       ` Jan Kratochvil
2013-02-03  9:20 ` Jan Kratochvil [this message]
2013-02-04 16:44   ` Tom Tromey
2013-03-14 20:29 ` Tom Tromey
2013-03-20 18:33   ` Tom Tromey

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=20130203092001.GD16948@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /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: link
Be 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