This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCHv4 2/5] gdb: New API for tracking innermost block


On 2017-10-19 09:27 AM, Andrew Burgess wrote:
> This commit is preparation for a later change, at this point there
> should be no user visible change.
> 
> We currently maintain a global innermost_block which tracks the most
> inner block encountered when parsing an expression.
> 
> This commit wraps the innermost_block into a new class, and switches all
> direct accesses to the variable to use the class API.

Hi Andrew,

I think this is a nice cleanup on its own right, removing a lot of duplicated
code.  LGTM with a nit:

> diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
> index f7ba7f088c..d9de10dda8 100644
> --- a/gdb/parser-defs.h
> +++ b/gdb/parser-defs.h
> @@ -63,9 +63,41 @@ extern const struct block *expression_context_block;
>     then look up the macro definitions active at that point.  */
>  extern CORE_ADDR expression_context_pc;
>  
> +/* When parsing expressions we track the innermost block that was
> +   referenced.  These functions are described in more detail at their
> +   definition site.  */
> +class innermost_block_tracker
> +{
> +public:
> +  innermost_block_tracker ()
> +    : innermost_block (NULL)
> +  { /* Nothing.  */ }
> +
> +  void reset ()
> +  {
> +    innermost_block = NULL;
> +  }
> +
> +  void update (const struct block *b);
> +
> +  void update (const struct block_symbol &bs)
> +  {
> +    update (bs.block);
> +  }
> +
> +  const struct block *block () const
> +  {
> +    return innermost_block;
> +  }
> +
> +private:
> +  const struct block *innermost_block;

Private members should be prefixed with m_ (m_innermost_block).

Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]