From patchwork Thu May 4 14:21:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 68757 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD81D385773B for ; Thu, 4 May 2023 14:22:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD81D385773B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683210151; bh=V6A4st8Q8frJxRblwgkugDsYMnEpsVheuYZ0RNKTD9s=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kT/9kI7rYN74N8S9bGCIwGMnlGMDeGBaX7v6cQtRndvRtQaypEJmA0UrxV8UTyPPE 8NpyfHvSPw9IzByQ1Arc9NmfJCJV88Zs0sd6MfJfvQH2owVH9STZlsP+G43/RL0X0a gKNpTjFKpwCuESNljhhbWtI8oy3h+qRb19kS+yqA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id BE92A385734D for ; Thu, 4 May 2023 14:21:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE92A385734D Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-33119abae99so21104745ab.0 for ; Thu, 04 May 2023 07:21:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683210089; x=1685802089; 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=V6A4st8Q8frJxRblwgkugDsYMnEpsVheuYZ0RNKTD9s=; b=Mk4azK9zCKcJn3S/mUIQ06CRqnu7J7F9Gg3l9AWfcdTjy+a7drQZRndawUhuIdRUCx SCU/VgGivnulFZD8tCI6nLyBnH29LANaSv4ZQFubLov9sLJ+1X9fZ/iJ+saeVXLWTyMK JomwNJvS/iPcC9Y8mBBKnEclO14S2gtgwBjh+vlOQ2hSFbtxq+soCJXnMdRLEoNB34lp 4XgUeB3QfGBuw5PKI1m2ec6oeFqhtwU6bueSbXpMuD7e1CmQ/N/QL+sfa0zrHPILsMk0 WHWs8843oyczNBh1t1qzjF+EwQC52Kdyz34H/8lStfn7/xto2SCVnfyR4n0k4FMh+ZID yEOQ== X-Gm-Message-State: AC+VfDzrbDNO6Hf8KCPUsTec/srUO0fr/rTTB4AJS8xrr9Ae3XL2LHGC Az3msAcQYZAS/4IV2wFPEvcYIeGtvTKOAyjESApDmA== X-Google-Smtp-Source: ACHHUZ4bykuZ+ssRXb9C0sWEMYbx7WaX0bW708ln10hNhydf55FopUktv/95OTjvrxzRqXu41Epnrw== X-Received: by 2002:a6b:fd12:0:b0:769:b99d:f43e with SMTP id c18-20020a6bfd12000000b00769b99df43emr643299ioi.8.1683210088969; Thu, 04 May 2023 07:21:28 -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.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 07:21:28 -0700 (PDT) Date: Thu, 04 May 2023 08:21:29 -0600 Subject: [PATCH 08/11] Add PARSER_LEAVE_BLOCK_ALONE flag MIME-Version: 1.0 Message-Id: <20230504-frameless-v1-8-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.4 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This adds a PARSER_LEAVE_BLOCK_ALONE flag, and changes the parse API to respect it. This flag lets callers avoid any change to the passed-in block and expression PC, letting them specify the context exactly. In particular, now nullptr can be used to indicate that the parse should not examine any local variables. --- gdb/expression.h | 6 ++++++ gdb/parse.c | 37 +++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/gdb/expression.h b/gdb/expression.h index c485b159ef8..d1858776e8e 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -301,6 +301,12 @@ enum parser_flag it parses. For yacc-based parsers, this translates to setting yydebug. */ PARSER_DEBUG = (1 << 2), + + /* Normally the expression-parsing functions like parse_exp_1 will + attempt to find a context block if one is not passed in. If set, + this flag suppresses this search and uses a null context for the + parse. */ + PARSER_LEAVE_BLOCK_ALONE = (1 << 3), }; DEF_ENUM_FLAGS_TYPE (enum parser_flag, parser_flags); diff --git a/gdb/parse.c b/gdb/parse.c index bbe5cf12d37..221733a3f90 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -344,26 +344,31 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, if (tracker == nullptr) tracker = &local_tracker; - /* If no context specified, try using the current frame, if any. */ - if (!expression_context_block) - expression_context_block = get_selected_block (&expression_context_pc); - else if (pc == 0) - expression_context_pc = expression_context_block->entry_pc (); - else - expression_context_pc = pc; + if ((flags & PARSER_LEAVE_BLOCK_ALONE) == 0) + { + /* If no context specified, try using the current frame, if any. */ + if (!expression_context_block) + expression_context_block + = get_selected_block (&expression_context_pc); + else if (pc == 0) + expression_context_pc = expression_context_block->entry_pc (); + else + expression_context_pc = pc; - /* Fall back to using the current source static context, if any. */ + /* Fall back to using the current source static context, if any. */ - if (!expression_context_block) - { - struct symtab_and_line cursal = get_current_source_symtab_and_line (); + if (!expression_context_block) + { + struct symtab_and_line cursal + = get_current_source_symtab_and_line (); - if (cursal.symtab) - expression_context_block - = cursal.symtab->compunit ()->blockvector ()->static_block (); + if (cursal.symtab) + expression_context_block + = cursal.symtab->compunit ()->blockvector ()->static_block (); - if (expression_context_block) - expression_context_pc = expression_context_block->entry_pc (); + if (expression_context_block) + expression_context_pc = expression_context_block->entry_pc (); + } } if (language_mode == language_mode_auto && block != NULL)