From patchwork Wed Nov 1 17:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78884 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 7D6D3385772F for ; Wed, 1 Nov 2023 17:10:21 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 58A993858D32 for ; Wed, 1 Nov 2023 17:09:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 58A993858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 58A993858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858588; cv=none; b=wTebRspkfNQmXCcDisngIEMoVpwZ2AJjnF+kUKR18PYgvBlhJVr0lxUkru7l6REerCBdHq0FdcbZJxQO/1ezntc6FLihNbgqRC66yXaGiExv/G1dBSEwxRzY9PB02EfraNxkOnbN74M0pVDpvmWa3IhgK4EA5H/l7pBK1sBOPQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858588; c=relaxed/simple; bh=GLSagAaATjs95YkU+mTkBMVYuGWMK+a3QM3L0rwvzqQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=PLA/7SG9HA7JpPmB4nYzsFJUhWh0Jqj7m43qAT8m1jhoWmiWlTuvhYAQaNpKIkq9A0JF11Z4OWJrvNTpGwwXlcJfUyUIKmQ9cxquEMeCWv4qLsRlyga+igOllJMrUGXxla+CyKW1oQavP5IJuR1xXAx+/+stvl2VrrBxMH9A5Q4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3592fadbd7eso26105ab.0 for ; Wed, 01 Nov 2023 10:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1698858578; x=1699463378; darn=sourceware.org; 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=QseMYIa/cWERa7mW8pDN0axBwQKRiL1PDTyB0Xe90dc=; b=iPSzT16dRKVREEioc5nZqw4PXD3JXVecD0THj53PvIxIlHcwZ208ewU8LzRLCMUAHV 571GZKU6YsGrYLOnrI18V4NLCZz6OJiN0ebq1mxu2eKTomKpUChyh0dAprYfSj0A05ox a3un22clIuNUY+ecGa+LvqseMUaSnaDXs6nycH1sgTcfpiYzNZi6F7I1dBTfajxFpMCY Vz37YxnDaWK1LB5orKZ4GWgeiPlT281VJ6qqwtKXhk9N2H2sw28rsbqk6TIfHRafTpAr SjFhAUB4My89oOhxKAbtaxjVPWPgumV0GBDDRtczVVJv78mmBJCyRQPcwhwaOcdbq9kF bAVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858578; x=1699463378; 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=QseMYIa/cWERa7mW8pDN0axBwQKRiL1PDTyB0Xe90dc=; b=sVLzVUFh7JW9CiBSTum7lzBPA16xJ8wo6tOZf7uBuNJp5LThHsnjUOLMBtR8znkVC4 rI7dhFBVf3oddxSikuPcTBBwNwlZNFWXrW0j8M6MXS09N/OX19bg4Ng3uuIU7H93+8T+ ZXOU8lAMlhjGJVq62aYsBGHgbCDKq2BXsZbxwVWPF22BZeVMiiWOAIEtTTYcGzKQUhSV eD2KhYoHZMoudl6pkOI2TWSIbcNkMOaxs0ZdqiiYttDrNqkg5f+glnDXJLnNSXRHE2i3 hoE/EiV9VI/u5H8Pk+0022Eg+0jJj288XvO8z3nCW72oIi4uhoxoVLvjuNXE9xctRnAw SG4A== X-Gm-Message-State: AOJu0Ywcbh7OgtVkbokdUfCAn022iVtN2p31dxKQeGXe/+fQvADj+/TD /dqC9cAwYL8n6Oqcce9f4WYkEeeJIxd1OA7kFz2dnQ== X-Google-Smtp-Source: AGHT+IFE46+XAcMT1zDP8Wndot9rHwuWnXlG1F4XzaLdtR9PAKkKxyOVFaMmHt3NoYxLEmloTBj9ig== X-Received: by 2002:a92:a805:0:b0:359:41f7:3d32 with SMTP id o5-20020a92a805000000b0035941f73d32mr2552779ilh.26.1698858578506; Wed, 01 Nov 2023 10:09:38 -0700 (PDT) Received: from localhost.localdomain (97-122-77-73.hlrn.qwest.net. [97.122.77.73]) by smtp.gmail.com with ESMTPSA id gm2-20020a0566382b8200b0042b3a328ee0sm1017019jab.166.2023.11.01.10.09.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:09:38 -0700 (PDT) From: Tom Tromey Date: Wed, 01 Nov 2023 11:09:33 -0600 Subject: [PATCH 1/7] Add two convenience methods to block MIME-Version: 1.0 Message-Id: <20231101-dap-nested-function-v1-1-0b0c3b228ac7@adacore.com> References: <20231101-dap-nested-function-v1-0-0b0c3b228ac7@adacore.com> In-Reply-To: <20231101-dap-nested-function-v1-0-0b0c3b228ac7@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.8 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This adds a couple of convenience methods, block::is_static_block and block::is_global_block. --- gdb/block.h | 15 +++++++++++++++ gdb/findvar.c | 5 ++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gdb/block.h b/gdb/block.h index 3a197e63754..9fccbe02b99 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -254,10 +254,25 @@ struct block : public allocate_on_obstack const struct block *static_block () const; + /* Return true if this block is a static block. */ + + bool is_static_block () const + { + const block *sup = superblock (); + if (sup == nullptr) + return false; + return sup->is_global_block (); + } + /* Return the static block associated with block. */ const struct block *global_block () const; + /* Return true if this block is a global block. */ + + bool is_global_block () const + { return superblock () == nullptr; } + /* Set the compunit of this block, which must be a global block. */ void set_compunit_symtab (struct compunit_symtab *); diff --git a/gdb/findvar.c b/gdb/findvar.c index 4e992ecdcc7..1079b85df82 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -460,8 +460,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block, tests that embed global/static symbols with null location lists. We want to get instead of when evaluating them so return a frame instead of raising an error. */ - else if (var_block == var_block->global_block () - || var_block == var_block->static_block ()) + else if (var_block->is_global_block () || var_block->is_static_block ()) return frame; /* We have to handle the "my_func::my_local_var" notation. This requires us @@ -486,7 +485,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block, /* If we failed to find the proper frame, fallback to the heuristic method below. */ - else if (frame_block == frame_block->global_block ()) + else if (frame_block->is_global_block ()) { frame = NULL; break;