From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by sourceware.org (Postfix) with ESMTPS id 1B0F63858C52 for ; Thu, 4 May 2023 14:21:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B0F63858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-766692684e1so11794639f.3 for ; Thu, 04 May 2023 07:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1683210085; x=1685802085; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=08U5cbyWniqMXaTrPE1g1DC2tDiuDELM9sAHA5BET80=; b=U/gTjZi8j04lylNIEUPJh6GKr/6JwlF9BXgEfVfEGsd4Hd44Jh4YCtphnEvBgbjKXj vIiMvBt7Atsypzscf/2RYRfrbzym3QQyrJy5XwxDcBN0NYWHQCqUbJ1o4DX9/Mvdw4ap 5AkK83tg9CK+0mtvlmHgV3AfQNUfnoxl5GLwJg6VTAAOUTbzxZrMJA+Bnmdu3cgzqi0x CW/fHaV9WJt9al+OH36bMmSzU6S8BCRc7W78ck3KoOR94tElx4XrbPkXPUAfySsM63G9 LLX4rDStk/EVV+x97sc/33q11ElkByjKJH0Qih2CnCoptzVa3An1oy1euxvmApJ2JkkA qJdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683210085; x=1685802085; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=08U5cbyWniqMXaTrPE1g1DC2tDiuDELM9sAHA5BET80=; b=IiEwFa5RlsMClyDHt8ogT2A0eOBKpwqmJLpU7PNddpiY/FjU1jRsrJMbWTHqcvBVsd ZpSkJ27JCi4+VGBWr4n0CcQQVYPOhfVKuns1vcDHI94mu6SBuCx7WDgyYbo9EBDUu6t5 L0F8gjxEDHviutXTGr4pkhWyN/vl7raA0niYKvOtqmn33b44m2n0VIdGamSse5a06nmo 2SMtjPwz17V/kwWhUDHtwprB2qbSXUobYis0rzXbMN3Y7iJRf3hhYBv//4r2Uqv4BuQk P07fB6M5DhT3OUl6bDw7E+jpzrLmjayD8uYBKpYdB5HPCTeSwX6CgyH2Vvv1COkv7DMv 0yng== X-Gm-Message-State: AC+VfDwIehJfJ0sBmMTaYsgjEf6HdURf46JfFRbOdr4f9JyhGqCi+Q8C AwvLMbdK6y6hN04zUNo3syswp/2wMUf1h7GADpYXAg== X-Google-Smtp-Source: ACHHUZ6NC/KlyseQDSKdBODNNaFziHNYhKaxbby/tw+ok84BMNwru25vTXOHyFnJM2LV/7RIQUD7Tg== X-Received: by 2002:a5d:81d9:0:b0:768:dd79:c013 with SMTP id t25-20020a5d81d9000000b00768dd79c013mr12304084iol.17.1683210085279; Thu, 04 May 2023 07:21:25 -0700 (PDT) Received: from localhost.localdomain (71-211-191-82.hlrn.qwest.net. [71.211.191.82]) by smtp.gmail.com with ESMTPSA id r16-20020a6b4410000000b00760a07e4e09sm9983384ioa.5.2023.05.04.07.21.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 07:21:24 -0700 (PDT) From: Tom Tromey Date: Thu, 04 May 2023 08:21:23 -0600 Subject: [PATCH 02/11] Move innermost_block_tracker to expression.h MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230504-frameless-v1-2-4191201740b0@adacore.com> References: <20230504-frameless-v1-0-4191201740b0@adacore.com> In-Reply-To: <20230504-frameless-v1-0-4191201740b0@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: I think parser-defs.h should hold declarations that can be used by parser implementations, whereas expression.h should hold declarations that are used by code that wants to call a parser. Following this logic, this patch moves innermost_block_tracker to expression.h. --- gdb/expression.h | 46 ++++++++++++++++++++++++++++++++++++++++++++-- gdb/parser-defs.h | 43 ------------------------------------------- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/gdb/expression.h b/gdb/expression.h index e6e4bec2e80..8d351b30a3a 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -21,6 +21,7 @@ #define EXPRESSION_H 1 #include "gdbtypes.h" +#include "symtab.h" /* While parsing expressions we need to track the innermost lexical block that we encounter. In some situations we need to track the innermost @@ -239,9 +240,51 @@ struct expression typedef std::unique_ptr expression_up; +/* When parsing expressions we track the innermost block that was + referenced. */ + +class innermost_block_tracker +{ +public: + innermost_block_tracker (innermost_block_tracker_types types + = INNERMOST_BLOCK_FOR_SYMBOLS) + : m_types (types), + m_innermost_block (NULL) + { /* Nothing. */ } + + /* Update the stored innermost block if the new block B is more inner + than the currently stored block, or if no block is stored yet. The + type T tells us whether the block B was for a symbol or for a + register. The stored innermost block is only updated if the type T is + a type we are interested in, the types we are interested in are held + in M_TYPES and set during RESET. */ + void update (const struct block *b, innermost_block_tracker_types t); + + /* Overload of main UPDATE method which extracts the block from BS. */ + void update (const struct block_symbol &bs) + { + update (bs.block, INNERMOST_BLOCK_FOR_SYMBOLS); + } + + /* Return the stored innermost block. Can be nullptr if no symbols or + registers were found during an expression parse, and so no innermost + block was defined. */ + const struct block *block () const + { + return m_innermost_block; + } + +private: + /* The type of innermost block being looked for. */ + innermost_block_tracker_types m_types; + + /* The currently stored innermost block found while parsing an + expression. */ + const struct block *m_innermost_block; +}; + /* From parse.c */ -class innermost_block_tracker; extern expression_up parse_expression (const char *, innermost_block_tracker * = nullptr, bool void_context_p = false); @@ -270,7 +313,6 @@ struct expr_completion_base extern expression_up parse_expression_for_completion (const char *, std::unique_ptr *completer); -class innermost_block_tracker; extern expression_up parse_exp_1 (const char **, CORE_ADDR pc, const struct block *, int, innermost_block_tracker * = nullptr); diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 62829a86f9a..5c6bc222b6b 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -316,49 +316,6 @@ struct parser_state : public expr_builder std::vector m_operations; }; -/* When parsing expressions we track the innermost block that was - referenced. */ - -class innermost_block_tracker -{ -public: - innermost_block_tracker (innermost_block_tracker_types types - = INNERMOST_BLOCK_FOR_SYMBOLS) - : m_types (types), - m_innermost_block (NULL) - { /* Nothing. */ } - - /* Update the stored innermost block if the new block B is more inner - than the currently stored block, or if no block is stored yet. The - type T tells us whether the block B was for a symbol or for a - register. The stored innermost block is only updated if the type T is - a type we are interested in, the types we are interested in are held - in M_TYPES and set during RESET. */ - void update (const struct block *b, innermost_block_tracker_types t); - - /* Overload of main UPDATE method which extracts the block from BS. */ - void update (const struct block_symbol &bs) - { - update (bs.block, INNERMOST_BLOCK_FOR_SYMBOLS); - } - - /* Return the stored innermost block. Can be nullptr if no symbols or - registers were found during an expression parse, and so no innermost - block was defined. */ - const struct block *block () const - { - return m_innermost_block; - } - -private: - /* The type of innermost block being looked for. */ - innermost_block_tracker_types m_types; - - /* The currently stored innermost block found while parsing an - expression. */ - const struct block *m_innermost_block; -}; - /* A string token, either a char-string or bit-string. Char-strings are used, for example, for the names of symbols. */ -- 2.39.1