This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCHv4 2/5] gdb: New API for tracking innermost block
- From: Simon Marchi <simark at simark dot ca>
- To: Andrew Burgess <andrew dot burgess at embecosm dot com>, gdb-patches at sourceware dot org
- Cc: donb at codesourcery dot com
- Date: Sun, 12 Nov 2017 11:26:26 -0500
- Subject: Re: [PATCHv4 2/5] gdb: New API for tracking innermost block
- Authentication-results: sourceware.org; auth=none
- References: <cover.1508418720.git.andrew.burgess@embecosm.com> <30e9656515ca65bd2ee5bf98f5d2e28def3b68e8.1508418720.git.andrew.burgess@embecosm.com>
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