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; From patchwork Wed Nov 1 17:09:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78886 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 E07E5385701C for ; Wed, 1 Nov 2023 17:10:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 25EE13858D35 for ; Wed, 1 Nov 2023 17:09:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 25EE13858D35 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 25EE13858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858588; cv=none; b=Vl3T/xDytFItTyPFMDMt7WZWRqE5uMx2wYvMksn/6IP90UuUOs1p23Q0yygrkZmuWcw9W1VH2a3cZok0MjsE2tayjD2KSUD4fcygIIDUE9mpLk5CssjE0zdgT6wKXfP9CdxdTg9G3SJpVUgPRdqZyEn6dp0Ct8ce4ZYEXpUXUU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858588; c=relaxed/simple; bh=kRJ8Dc+kjyVpgMlD0VxsDcnmu08tvpqa3bR7k8M9uX4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=KCp2PIrZ5eIl2WpBsi/vO3onLyFphKSVcoWyV2z8NUeFHOmSkP1x8L6bn25PGhD3jIxmUn214UISubcdJl5Nt58VdAEbg9bNfAqV3D//SQLTZmXX62UvYifnfF7Md4+BPxFmmwezgrvBPawRWC8UywtZ93Lw7KtEoQATCcYeNlk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-358ff34cd9eso18156275ab.1 for ; Wed, 01 Nov 2023 10:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1698858579; x=1699463379; 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=ix0xkc9JuWp6J6yE3M2VPjcvQLxc+8OobdlhSJOoBJg=; b=Yd08IcYNdDxaVduDE9gl2MBLeB+ArLB8sgYwXNPv+fSBrwc8WS0zT1wyP69uWiqxts cRlNRoC3+1u2H4vuFbtMshJn3kVBMenlpxq73wY/DUuuoJpWsdqa9wiMouKd6q2HAfS2 5mNhA7W5ceqD6KH2+lPVhBIMo/tg/L92pSkBGsj8d9PbyEK+rFXCUA6+ZdiG2ZAjDUAl zs2XNe1ijXF5L74mYxC4PuDmj/Old7iXklwMhIBU24kSX/e8Ksrn8+oEh0Hx1AjitNLx nhwViA+0n/Pc5Xr3dzrL56bnHV7S0OxfGewGT0PUHGcprYYheGsLq2nCjN860hI0nwGW QtBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858579; x=1699463379; 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=ix0xkc9JuWp6J6yE3M2VPjcvQLxc+8OobdlhSJOoBJg=; b=djMFBtdO7N/qjEk/9G/KpmQwPe4xSGR426rjRFbGf3eUbdSLT5qL1A7Oeeo08wdrO8 Z1T29VwK2EQqUOU6nGdG+QER7+oL3J26Bp++/uEC0cfsKgpsqV7YcnAmBVGgh59Hj1TB E3StA9UU7rUXXEVtrEN30IP+CNW7wUJoqQue97mTQVNLNtcUhJvSjDyjGMt3xgC9zoBf 4Ie/NXK9HimnYx6WR89girEwnypRvPGqnO0JEDtK9ya1OpYpXjs9iBldwqKcPyCBjvt+ jUV1iHMHNOQO5q171QVQ1nRUKu+se3/5oMfnaUcgg8BHiAd+y8rf29dFGaPUBZhca4Pv RR/A== X-Gm-Message-State: AOJu0YzJdbLID1BfuCQBKD++45p+DHvOi+5Wpg8Ooj8NpWkx/hAU/kjK akcjMAYxYcMGJR8RoAakFBBt2KdvWYJJVgHJ4GO6DQ== X-Google-Smtp-Source: AGHT+IHnl+AsMWWmKiVO9opIYpM/2ZHpKvjj9L3zddp7fMdE/7lUeI1+HPVwDm2IWqTgXGYJbTMopg== X-Received: by 2002:a92:7613:0:b0:359:42b0:cb01 with SMTP id r19-20020a927613000000b0035942b0cb01mr2304621ilc.19.1698858579308; Wed, 01 Nov 2023 10:09:39 -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.38 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:34 -0600 Subject: [PATCH 2/7] Add block::function_block MIME-Version: 1.0 Message-Id: <20231101-dap-nested-function-v1-2-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 the method block::function_block, to easily access a block's enclosing function block. --- gdb/block.c | 13 +++++++++++++ gdb/block.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/gdb/block.c b/gdb/block.c index 6ada69c388f..e588a68aa2f 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -378,6 +378,19 @@ block::global_block () const /* See block.h. */ +const struct block * +block::function_block () const +{ + const block *block = this; + + while (block != nullptr && block->function () == nullptr) + block = block->superblock (); + + return block; +} + +/* See block.h. */ + void block::set_compunit_symtab (struct compunit_symtab *cu) { diff --git a/gdb/block.h b/gdb/block.h index 9fccbe02b99..a29298517b0 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -273,6 +273,12 @@ struct block : public allocate_on_obstack bool is_global_block () const { return superblock () == nullptr; } + /* Return the function block for this block. Returns nullptr if + there is no enclosing function, i.e., if this block is a static + or global block. */ + + const struct block *function_block () const; + /* Set the compunit of this block, which must be a global block. */ void set_compunit_symtab (struct compunit_symtab *); From patchwork Wed Nov 1 17:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78881 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 0C0FB3858C3A for ; Wed, 1 Nov 2023 17:10:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id C726D3858D37 for ; Wed, 1 Nov 2023 17:09:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C726D3858D37 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 C726D3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::132 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858588; cv=none; b=lqSTupO1es95u5bkameMDNwIeAmuqHwk0evt0Hj5naMwJsAw2ZI2lm0U9DAvoKZpe3ceeijD3eJ1rCbRHWJWQCNNr25SxIYyGnUEY9Jo+FQK8GiTjl9xnYFq70BQbPaNGIVPDUdypOtBkyj1mrFwlsDLw9dujn6hsK7CfUrcpDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858588; c=relaxed/simple; bh=Em0z4xUSnmcwZL6N/YobM9L8uttUzwMAI90By16ZkZI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ZXU/Ei3o9eYfmc3/YQUoiFqg1JJSi0BlYNas7MDzDki0ob+iPyUbi7S/7ijE7TH/4kHx9VEgeGoVOdniYY93iHSzTCF/86OurCQ3dnim4HL4OvkZE8JIqFZ74115qfPxEy2jVQKwkSMVljvSroXjWxkevgCF8ClGWM3+fPRN3Jc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-357c9dc1068so161205ab.0 for ; Wed, 01 Nov 2023 10:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1698858580; x=1699463380; 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=8xOfG0EK0PwCA1U6OBfWaClCBJneM8uaw8vTfDSYYSU=; b=UrCv2+pQ5PIRrRSgUDfMWh1bKxa6wiV3xGlchZ/DYoZ3EE34PknnZO2GLZLVmiEKgd QvVqrSWpIZ+Et8S2niyTFXS1BkjX8iGLcjrpHgNzwjRl0+VHaJCkj4eDhpwhTVwtdgaQ YCbvvnazMU7K7T2mjM5sgz6NRVwVJdRw24nMYXtzsZuq2rOBi8z5wQlSUTnkK1DUYnZV HN7nATHSB+fih8kDs8UWinx5fyyhLrAT0tIuc0q21G6dxzH71NBAW/ynTw70ouah2ifD j1C6CdGSEIeLg9sAuLutdSHjfnhhRM+kd9yXp+sC8rKv2JsD+UzR//w53NaiVkuOADas c1uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858580; x=1699463380; 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=8xOfG0EK0PwCA1U6OBfWaClCBJneM8uaw8vTfDSYYSU=; b=EFYMG5axpiK9g+EHFU66ZDMRaCCW2vVef4e1eryyQhQY4NXhEV6S0J35lb3SRz1BTG RCmq/mFpr3x2JRH+fd6QyFmp6jsvLaPv3Y9HmulJZ4GIOrxRnrB9rA66rG0XWf6P7/0I ht8yshMQF5nN223Zv6BhH07rMaeb4sCwx+bwfa0BST53P04eUm1Ly8N5rxGgqF5F788w lr0QwgfgtPR1Sy076AuRa2MOI5agzlBsPP4ySLR+5LdgvUW6zMlOwoelFvIAFoXuwvQN uk2mcnKNr5ywQwgbtfBBE+0tIbgUDz0jjnnsBQv2okEwMdOpJrUYl4mz4GTxTr2ju834 Sh/w== X-Gm-Message-State: AOJu0Yy4RFYi7/fdTsVRb/Zqr0ZF/hbplBuehMFepxMRewOhutX4+M1W hjzHSb+DbBP+OYt9WBH7HFZvI3CbSKggV8nG+qr38A== X-Google-Smtp-Source: AGHT+IEcBQnDhysimCQ1OrD0ScIJ0kL19CG/YutoNqGQXt/7ZZvdkKeoz7XnavRFDX42fcy/CcLkkQ== X-Received: by 2002:a05:6e02:1aa5:b0:34a:95f9:650c with SMTP id l5-20020a056e021aa500b0034a95f9650cmr3610835ilv.10.1698858579928; Wed, 01 Nov 2023 10:09:39 -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.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:09:39 -0700 (PDT) From: Tom Tromey Date: Wed, 01 Nov 2023 11:09:35 -0600 Subject: [PATCH 3/7] Move follow_static_link to frame.c MIME-Version: 1.0 Message-Id: <20231101-dap-nested-function-v1-3-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.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, 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 moves the follow_static_link function to frame.c and exports it for use elsewhere. The API is changed slightly to make it more generically useful. --- gdb/findvar.c | 59 ++++++----------------------------------------------------- gdb/frame.c | 40 ++++++++++++++++++++++++++++++++++++++++ gdb/frame.h | 7 +++++++ 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/gdb/findvar.c b/gdb/findvar.c index 1079b85df82..952ec20c0b7 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -31,7 +31,6 @@ #include "block.h" #include "objfiles.h" #include "language.h" -#include "dwarf2/loc.h" #include "gdbsupport/selftest.h" /* Basic byte-swapping routines. All 'extract' functions return a @@ -391,41 +390,6 @@ symbol_read_needs_frame (struct symbol *sym) return symbol_read_needs (sym) == SYMBOL_NEEDS_FRAME; } -/* Given static link expression and the frame it lives in, look for the frame - the static links points to and return it. Return NULL if we could not find - such a frame. */ - -static frame_info_ptr -follow_static_link (frame_info_ptr frame, - const struct dynamic_prop *static_link) -{ - CORE_ADDR upper_frame_base; - - if (!dwarf2_evaluate_property (static_link, frame, NULL, &upper_frame_base)) - return NULL; - - /* Now climb up the stack frame until we reach the frame we are interested - in. */ - for (; frame != NULL; frame = get_prev_frame (frame)) - { - struct symbol *framefunc = get_frame_function (frame); - - /* Stacks can be quite deep: give the user a chance to stop this. */ - QUIT; - - /* If we don't know how to compute FRAME's base address, don't give up: - maybe the frame we are looking for is upper in the stack frame. */ - if (framefunc != NULL - && SYMBOL_BLOCK_OPS (framefunc) != NULL - && SYMBOL_BLOCK_OPS (framefunc)->get_frame_base != NULL - && (SYMBOL_BLOCK_OPS (framefunc)->get_frame_base (framefunc, frame) - == upper_frame_base)) - break; - } - - return frame; -} - /* Assuming VAR is a symbol that can be reached from FRAME thanks to lexical rules, look for the frame that is actually hosting VAR and return it. If, for some reason, we found no such frame, return NULL. @@ -494,25 +458,14 @@ get_hosting_frame (struct symbol *var, const struct block *var_block, /* Assuming we have a block for this frame: if we are at the function level, the immediate upper lexical block is in an outer function: follow the static link. */ - else if (frame_block->function ()) + else if (frame_block->function () != nullptr) { - const struct dynamic_prop *static_link - = frame_block->static_link (); - int could_climb_up = 0; - - if (static_link != NULL) - { - frame = follow_static_link (frame, static_link); - if (frame != NULL) - { - frame_block = get_frame_block (frame, NULL); - could_climb_up = frame_block != NULL; - } - } - if (!could_climb_up) + frame = frame_follow_static_link (frame); + if (frame != nullptr) { - frame = NULL; - break; + frame_block = get_frame_block (frame, nullptr); + if (frame_block == nullptr) + frame = nullptr; } } diff --git a/gdb/frame.c b/gdb/frame.c index 7077016ccba..4a46ccb9abc 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -43,6 +43,7 @@ #include "hashtab.h" #include "valprint.h" #include "cli/cli-option.h" +#include "dwarf2/loc.h" /* The sentinel frame terminates the innermost end of the frame chain. If unwound, it returns the information needed to construct an @@ -3120,6 +3121,45 @@ get_frame_sp (frame_info_ptr this_frame) return gdbarch_unwind_sp (gdbarch, frame_info_ptr (this_frame->next)); } +/* See frame.h. */ + +frame_info_ptr +frame_follow_static_link (frame_info_ptr frame) +{ + const block *frame_block = get_frame_block (frame, nullptr); + frame_block = frame_block->function_block (); + + const struct dynamic_prop *static_link = frame_block->static_link (); + if (static_link == nullptr) + return {}; + + CORE_ADDR upper_frame_base; + + if (!dwarf2_evaluate_property (static_link, frame, NULL, &upper_frame_base)) + return {}; + + /* Now climb up the stack frame until we reach the frame we are interested + in. */ + for (; frame != nullptr; frame = get_prev_frame (frame)) + { + struct symbol *framefunc = get_frame_function (frame); + + /* Stacks can be quite deep: give the user a chance to stop this. */ + QUIT; + + /* If we don't know how to compute FRAME's base address, don't give up: + maybe the frame we are looking for is upper in the stack frame. */ + if (framefunc != NULL + && SYMBOL_BLOCK_OPS (framefunc) != NULL + && SYMBOL_BLOCK_OPS (framefunc)->get_frame_base != NULL + && (SYMBOL_BLOCK_OPS (framefunc)->get_frame_base (framefunc, frame) + == upper_frame_base)) + break; + } + + return frame; +} + /* Return the reason why we can't unwind past FRAME. */ enum unwind_stop_reason diff --git a/gdb/frame.h b/gdb/frame.h index 1d7422cac32..19bf8176682 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -640,6 +640,13 @@ class address_space; /* Return the frame's address space. */ extern const address_space *get_frame_address_space (frame_info_ptr); +/* A frame may have a "static link". That is, in some languages, a + nested function may have access to variables from the enclosing + block and frame. This function looks for a frame's static link. + If found, returns the corresponding frame; otherwise, returns a + null frame_info_ptr. */ +extern frame_info_ptr frame_follow_static_link (frame_info_ptr frame); + /* For frames where we can not unwind further, describe why. */ enum unwind_stop_reason From patchwork Wed Nov 1 17:09:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78887 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 821E73858C01 for ; Wed, 1 Nov 2023 17:10:51 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id 60AB23858D38 for ; Wed, 1 Nov 2023 17:09:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60AB23858D38 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 60AB23858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858590; cv=none; b=ujvjvPj/812l/r+HI2IG1zG5OVdun49Q7Blffzjznfa3/bpQeXjLlN1aaorCikOq8iR4cM80L4lQZ0bxV9NMce59ERCokZCOZ7rSblKo4Pa9nWiJYXS+cUv0cm5wUVb4izgJgoplDfaP7pH+nb7ZRhdZK+ZWs793PvPWyHuqRkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858590; c=relaxed/simple; bh=2YfJMavKTaay5zIO2IVyxWmtfWdG+P+ljMYwZP48Q5Y=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=KBlOeJVjLJWbHSUKd37NZOfFJFGYhGL2wnXGR4CdWiHDxrfg1PH9jUc/diOG1xD/ENdMXewIUmh4pIi9V/lUh3ofWY6Wp5dlgGkEBG+p7XgtECKnfZcJt7McqjySHP8Rlw55maKacpwkhTHu0N5a2FAItIO8Z/mn3V99fT5EgtI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7a996357550so245162639f.2 for ; Wed, 01 Nov 2023 10:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1698858580; x=1699463380; 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=ffxN3Y7nnrv7dTHjFHVXVZDthCSrPPTkaZoadIUNOTM=; b=jdxh8EChYq4CACg4+aro5KCUqSV8bO2hHdXKqODc2FLTeqkbP5Bq/i8PL4kIlX9vuL 7747cCCCpfTLY5XPvDv/Elv1vqqxFCB0xkvDjdMNOvZRm9cMQjqS04xfTe+qGQd4uVDi DamRdWId0o9kMW3ewx/qHAN0e7ywAU4ZSKO+IC9/tBih73y7ZgC4wvz1PS7ZSWjuP5lp r0pCzZY0/FkTy6cwzxXWMG9GtaiafUCg7PAZ8QHb4Sn6kxgXhC4AxfEb5jtRcdjyGGIo NDUqVKoiU8/Mhx5vRfzMPdomYXN+n3exmmF3YdJMBXQWoGQe43GmLoY+BITiAGohjNJn uAXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858580; x=1699463380; 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=ffxN3Y7nnrv7dTHjFHVXVZDthCSrPPTkaZoadIUNOTM=; b=EedM5K6kTmghsUfV0wL0ChQBYQGxrzWEZ68W8jThV+RKNc+K+jeoczSF3vo/AXe6Zz b74usP4Jx7qpu2kS1vEQaEsiA+BgmcmzPeD7LIXRkekF/2bhv8RVwOrT0BodgQSxvpdX /nGdOSsDukUzToVrHHh+8lDyD4RMf+lbRJbbVDEDuVQxRr3irhJire5mzHGzYqKCgrON +ZZOujPUPcraRA8PSHJEFtLUH+dJrl0SeqEet35dfc3dZUY4F+F+4mBeUkSQFXqzkVf6 bBY0Q05pGwNdwLLOb6XX7KNoe36OJ3uLAZbug4qF+8b+YzYedUCN7zfTtp+7gKIS5739 6Yrg== X-Gm-Message-State: AOJu0Yy2LocKZ7v2coZC6YTyKvuYJ5cq6j8SgwGSE67eSon8M2rEWer6 koYY12Jth6FrHws27KFO4ZDOZVqy1UiC6GKYGoQ2WQ== X-Google-Smtp-Source: AGHT+IGShJscVvbw5i1ky1ZHIPzcAQKAYOH0iYvAtSypCP/C8nqSorQupS30T4RcLrrBHp97L54Psw== X-Received: by 2002:a6b:ea0a:0:b0:79f:99b6:63 with SMTP id m10-20020a6bea0a000000b0079f99b60063mr15875694ioc.9.1698858580548; Wed, 01 Nov 2023 10:09:40 -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.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:09:40 -0700 (PDT) From: Tom Tromey Date: Wed, 01 Nov 2023 11:09:36 -0600 Subject: [PATCH 4/7] Add gdb.Frame.static_link method MIME-Version: 1.0 Message-Id: <20231101-dap-nested-function-v1-4-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 new gdb.Frame.static_link method to the gdb Python layer. This can be used to find the static link frame for a given frame. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 3 +++ gdb/doc/python.texi | 10 ++++++++++ gdb/python/py-frame.c | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 95663433f1c..503f53a2ea1 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -17,6 +17,9 @@ ** New read/write attribute gdb.Value.bytes that contains a bytes object holding the contents of this value. + ** New method gdb.Frame.static_link that returns the outer frame + of a nested function frame. + *** Changes in GDB 14 * GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 8cc3f92cbfe..afe447644c5 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -5732,6 +5732,16 @@ Set this frame to be the selected frame. @xref{Stack, ,Examining the Stack}. @end defun +@defun Frame.static_link () +In some languages (e.g., Ada, but also a GNU C extension), a nested +function can access the variables in the outer scope. This is done +via a ``static link'', which is a reference from the nested frame to +the appropriate outer frame. + +This method returns this frame's static link frame, if one exists. If +there is no static link, this method returns @code{None}. +@end defun + @defun Frame.level () Return an integer, the stack frame level for this frame. @xref{Frames, ,Stack Frames}. @end defun diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 1a55e514e39..0a7e10f09ff 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -622,6 +622,30 @@ frapy_language (PyObject *self, PyObject *args) Py_RETURN_NONE; } +/* The static link for this frame. */ + +static PyObject * +frapy_static_link (PyObject *self, PyObject *args) +{ + frame_info_ptr link; + + try + { + FRAPY_REQUIRE_VALID (self, link); + + link = frame_follow_static_link (link); + } + catch (const gdb_exception &except) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + + if (link == nullptr) + Py_RETURN_NONE; + + return frame_info_to_frame_object (link); +} + /* Implementation of gdb.newest_frame () -> gdb.Frame. Returns the newest frame object. */ @@ -800,6 +824,8 @@ Return the value of the variable in this frame." }, "The stack level of this frame." }, { "language", frapy_language, METH_NOARGS, "The language of this frame." }, + { "static_link", frapy_static_link, METH_NOARGS, + "The static link of this frame, or None." }, {NULL} /* Sentinel */ }; From patchwork Wed Nov 1 17:09:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78882 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 BAB4C3857703 for ; Wed, 1 Nov 2023 17:10:14 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id ED2703858D39 for ; Wed, 1 Nov 2023 17:09:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED2703858D39 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 ED2703858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858589; cv=none; b=eKC6u9idpHs/RmFwMD0dOSZfnY5Q/fn0LZbgcCxdeDgjUlNwa8hh6LAb4dt2icrf1zKE83FfrFZAX7ksWUhTL91Q7wMVDQf2PzLniGYbZr4xgdFUzvVTvUFOQSC8S5dDZUnSK1uKfCgSKlPSqh4Ushb2Y99bxLB7JMq3Idlm9gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858589; c=relaxed/simple; bh=MLgpfTbDlrxoFVrCYATyqzjs++ZtczlZTpXtNjFEvd4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=xzGRJNDZkV4mkCrheMABUuM0QIaW5ZfyaQMC73zGCxs+qPNOrnx9JzFCPDJFeBV1rbfRXMTPmuLOHnqM/hhZPXMkQnX02z5WUxvNQLivVC/skoxNREAyrylut8JsI+8ygrI/q9T+xsv8C0lsU9ioyBsRCOKRoW/LcJOC+S1ehgk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-358ff34cd9eso18156595ab.1 for ; Wed, 01 Nov 2023 10:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1698858581; x=1699463381; 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=2lfMRuqgS2kiKRn890LlKHqgZ4WOL6XshBCVFjX4jvU=; b=EzIjcXLzM8n7zXyvCe0d2pZBvTqImvT+ZQr9WqI1T8NVnoN+jHd8eJBG/nxoRQE7CM 13IGp18MmQdR+RTDFnxiR0yO7GaJ+h5ZSCoxzlJuWJoNjsBAKpFTpnEFKr3ZGTbrz2KX u4TdXKBwuyVDtKqw259fMFavVfzUDeoOoVAwgyDx8GNXitw1Z/GNfOi5R1uQlIqbnIHm Cdo3pa3qOfLJBHO0mLiGw76XC4kjp4qDB0RrwyIZdpZRIAqmpTdHjmnp3CB5/2THFkAH RWT/lhYyrjHc3HPS0Ndb5Y3zAuvZ/C+f6Pm2AUUAf0/fpjdl3TVNouNSDne+TOWqw3do hzPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858581; x=1699463381; 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=2lfMRuqgS2kiKRn890LlKHqgZ4WOL6XshBCVFjX4jvU=; b=N9/kN0uvCwx6eivAcOr99QwqPjxBafvkq+p3tEtn2e1I+XBkaTejZrFWoFK0REdBO5 piSWNvkc4S4ZnIjAQWEe0nUhT7YRqqQr4t+kZSitm4swcB7wPLPpcxXlrMozowStGCnP C1ZJCQmK3w8TpsQpyhkdpZErZ0XjfQgCsHVnsURktOwpD/XgWZWSS1jV3Qv52wJrpnk2 SJRWnnCk1DZFWwEYucZ3rpE7JweJqy1uzgx5hWBVaEE6t/9Gy3O8q3yfzA8JJPB4bvqh puBArN0Cwsi6l+uPUVS0PJN4FQ+bkh/tEban3aVkJLAVfNlY+57gmOXfm+mrE+aWBGFj G5ZQ== X-Gm-Message-State: AOJu0YxzSnNhmXHKoY/r04YS+dzfecPBru56nfI018BN7NA9UpBF3CeM dOxYzeP29vTbVX9KseoTgpRqgMuUXQafD9tMr7ivhA== X-Google-Smtp-Source: AGHT+IGTTEfZgYEJLKjszWSODmJRJv/6n5z7ckKtW+MvxMPuCt7coPEd2R3OybCCRQLKS8cMfBKitg== X-Received: by 2002:a92:d847:0:b0:359:4ae3:cd8d with SMTP id h7-20020a92d847000000b003594ae3cd8dmr1205011ilq.6.1698858581129; Wed, 01 Nov 2023 10:09:41 -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.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:09:40 -0700 (PDT) From: Tom Tromey Date: Wed, 01 Nov 2023 11:09:37 -0600 Subject: [PATCH 5/7] Fix a bug in DAP scopes code MIME-Version: 1.0 Message-Id: <20231101-dap-nested-function-v1-5-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 While working on static links, I noticed that the DAP scopes code does not handle the scenario where a frame decorator returns None. This situation should be handled identically to a frame decorator returning an empty iterator. --- gdb/python/lib/gdb/dap/scopes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py index 87f2ed7547f..13c35817fb6 100644 --- a/gdb/python/lib/gdb/dap/scopes.py +++ b/gdb/python/lib/gdb/dap/scopes.py @@ -107,10 +107,14 @@ def _get_scope(id): else: frame = frame_for_id(id) scopes = [] - args = frame.frame_args() + # Make sure to handle the None case as well as the empty + # iterator case. + args = tuple(frame.frame_args() or ()) if args: scopes.append(_ScopeReference("Arguments", "arguments", frame, args)) - locs = frame.frame_locals() + # Make sure to handle the None case as well as the empty + # iterator case. + locs = tuple(frame.frame_locals() or ()) if locs: scopes.append(_ScopeReference("Locals", "locals", frame, locs)) scopes.append(_RegisterReference("Registers", frame)) From patchwork Wed Nov 1 17:09:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78885 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 8D5B53857B9B for ; Wed, 1 Nov 2023 17:10:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 9EB763858CD1 for ; Wed, 1 Nov 2023 17:09:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9EB763858CD1 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 9EB763858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858599; cv=none; b=idb6bC/ck+nyWKCCqhLFzbbIaFtbuykozEws2sxKtSfG0lmernlseJOs31ttRS3IhBNwPbswmoNpJgC9d55l3ce6lrDBxNhN/GvppfZ2YiN9mvDQeSMOQITpeVUScJXewV1z+Yfmy/0Z5/7tGgAZg+LaKTR02VW/vuw77KgL/os= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858599; c=relaxed/simple; bh=MsFabVKnTzCyNz1CNTqTM7G6hBAvLERlzmnzjKhVRm0=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=tu/ewhA6OcWWQgu5MjIectW7R61UVOo8g9FBM6e83+EPQ9yv5fZCfMXlpwPWQdQlTcWQqM3t3oKqZbFfgZoHE4qk3izw3w7v/2flObuhNZU2JGF2JXyipMLj3WE2llfj3kqHlEjZ7FiDgUqXMZs4/vLeQs+PlxhbChNJZ+CY6/g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-7a683bd610dso236893039f.1 for ; Wed, 01 Nov 2023 10:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1698858582; x=1699463382; 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=LzVlJ17BxTlM3jAfKuPriFYd/vaw81jBaafXziB3cBw=; b=IX5O9v9/mkzfXGoBEp9wyNdJviZekZfKa2fJF4NbLlcfcjxtwb/Rv5AsW98/KV9BGG +gxk9EkjeTV2dKKYsMRZ5BjoZbeIvZ0prQuZ/+FFI+HaV4fq/j2gCAOyM2lHvWPk4SNo +iYCRdOL+M/CTZIGDelZiDH5TF+WdUFCqUCJFOwUIDVgHacdLBqOxn12Sl3SUtqoJnXq A52qhMhnyUyPBaADamKZLfseZ8zjUMkRpIiTA30ilS0JLQ9bxdShwVu7Myj/15qInWOv FdmTuGYWRiO4PVAg2/1LcT4R8KVkLKqR19xjf1nodtSr4CiIAnZroDTQaD9mGu4Xao+U 9t5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858582; x=1699463382; 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=LzVlJ17BxTlM3jAfKuPriFYd/vaw81jBaafXziB3cBw=; b=QB+Gw/iA6/FkR+4B/NxmE1j9aOTYyTO92jkKc+Ys0Fok4uKBUuWl8aaoG1prMpEauQ 7IYhCi8SG1mo8KnQb3wd+D69a0a8JqgCP2hgHsARjX+2Tql7poj6n/d4MGkSe8mU5wmU iueFG2pZ/naeQORGMO50+eQ6N/J8+eLiCFJ2cMvNptX/x5EppUVa0mpWJPDikgYl6lJl J8gu6cJ0W60CwZxdPHQx4kT0m7UbU8/FiHBDPHbyb/k8bvgBE7ROBLOY90atAsOmVH6A 65rLhxQLVHVvImYDiD7dVrBEyFlff6y6yeT7tZL+e0jBnMZRSmgXLpRdCRUJVXA0nLi5 y4Dg== X-Gm-Message-State: AOJu0Yy0OAefW0cPLGTY5/e1i/+1E3cNVS77lbGq30zTPn3CZNJRXmF3 JfE9s1mfEPZe6lU/mFUgqcbama5/cA6zIuKah81j8Q== X-Google-Smtp-Source: AGHT+IE0xdgaFGKPQsizsXKqMBb4rRmqRvcPCs+wSjgcHiG/hnqXzhTujMeAegunbApnsyhkGmWdqw== X-Received: by 2002:a05:6602:1492:b0:786:ef34:1a6 with SMTP id a18-20020a056602149200b00786ef3401a6mr20568460iow.7.1698858581729; Wed, 01 Nov 2023 10:09:41 -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.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:09:41 -0700 (PDT) From: Tom Tromey Date: Wed, 01 Nov 2023 11:09:38 -0600 Subject: [PATCH 6/7] Handle the static link in FrameDecorator MIME-Version: 1.0 Message-Id: <20231101-dap-nested-function-v1-6-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, KAM_SHORT, 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 A co-worker requested that the DAP scope for a nested function's frame also show the variables from outer frames. DAP doesn't directly support this notion, so this patch arranges to put these variables into the inner frames "Locals" scope. I chose to do this only for DAP. For CLI and MI, gdb currently does not do this, so this preserves the behavior. Note that an earlier patch (see commit 4a1311ba) removed some code that seemed to do something similar. However, that code did not actually work. --- gdb/python/lib/gdb/FrameDecorator.py | 64 +++++++++++++++++----- gdb/testsuite/gdb.dap/ada-nested.exp | 91 +++++++++++++++++++++++++++++++ gdb/testsuite/gdb.dap/ada-nested/prog.adb | 32 +++++++++++ 3 files changed, 174 insertions(+), 13 deletions(-) diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py index 39ee2e2547c..b6eb1ab1de0 100644 --- a/gdb/python/lib/gdb/FrameDecorator.py +++ b/gdb/python/lib/gdb/FrameDecorator.py @@ -213,18 +213,36 @@ class DAPFrameDecorator(_FrameDecoratorBase): return sal.symtab.fullname() return None + def frame_locals(self): + """Return an iterable of local variables for this frame, if + any. The iterable object contains objects conforming with the + Symbol/Value interface. If there are no frame locals, or if + this frame is deemed to be a special case, return None.""" + + if hasattr(self._base, "frame_locals"): + return self._base.frame_locals() + + frame = self.inferior_frame() + args = FrameVars(frame) + return args.fetch_frame_locals(True) + class SymValueWrapper(object): """A container class conforming to the Symbol/Value interface which holds frame locals or frame arguments.""" - def __init__(self, symbol, value): + # The FRAME argument is needed here because gdb.Symbol doesn't + # carry the block with it, and so read_var can't find symbols from + # outer (static link) frames. + def __init__(self, frame, symbol): + self.frame = frame self.sym = symbol - self.val = value def value(self): """Return the value associated with this symbol, or None""" - return self.val + if self.frame is None: + return None + return self.frame.read_var(self.sym) def symbol(self): """Return the symbol, or Python text, associated with this @@ -240,32 +258,50 @@ class FrameVars(object): def __init__(self, frame): self.frame = frame - def fetch_frame_locals(self): + def fetch_frame_locals(self, follow_link=False): """Public utility method to fetch frame local variables for the stored frame. Frame arguments are not fetched. If there are no frame local variables, return an empty list.""" lvars = [] + frame = self.frame try: - block = self.frame.block() + block = frame.block() except RuntimeError: block = None + traversed_link = False while block is not None: if block.is_global or block.is_static: break for sym in block: + # Exclude arguments from the innermost function, but + # if we found and traversed a static link, just treat + # all such variables as "local". if sym.is_argument: + if not traversed_link: + continue + elif not sym.is_variable: + # We use an 'elif' here because is_variable + # returns False for arguments as well. Anyway, + # don't include non-variables here. continue - if sym.is_variable: - lvars.append(SymValueWrapper(sym, None)) + lvars.append(SymValueWrapper(frame, sym)) - # Stop when the function itself is seen, to avoid showing - # variables from outer functions in a nested function. if block.function is not None: - break - - block = block.superblock + if not follow_link: + break + # If the frame has a static link, follow it here. + traversed_link = True + frame = frame.static_link() + if frame is None: + break + try: + block = frame.block() + except RuntimeError: + block = None + else: + block = block.superblock return lvars @@ -287,10 +323,12 @@ class FrameVars(object): for sym in block: if not sym.is_argument: continue - args.append(SymValueWrapper(sym, None)) + args.append(SymValueWrapper(None, sym)) # Stop when the function itself is seen, to avoid showing # variables from outer functions in a nested function. + # Note that we don't traverse the static link for + # arguments, only for locals. if block.function is not None: break diff --git a/gdb/testsuite/gdb.dap/ada-nested.exp b/gdb/testsuite/gdb.dap/ada-nested.exp new file mode 100644 index 00000000000..1a02f4f352e --- /dev/null +++ b/gdb/testsuite/gdb.dap/ada-nested.exp @@ -0,0 +1,91 @@ +# Copyright 2023 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check the scope of a nested function. + +load_lib ada.exp +load_lib dap-support.exp + +require allow_ada_tests allow_dap_tests + +standard_ada_testfile prog + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \ + {debug additional_flags=-gnata}] != ""} { + return -1 +} + +if {[dap_launch $binfile] == ""} { + return +} + +set line [gdb_get_line_number "STOP"] +set obj [dap_check_request_and_response "set breakpoint" \ + setBreakpoints \ + [format {o source [o path [%s]] \ + breakpoints [a [o line [i %d]]]} \ + [list s $srcfile] $line]] +set fn_bpno [dap_get_breakpoint_number $obj] + +dap_check_request_and_response "start inferior" configurationDone + +dap_wait_for_event_and_check "stopped at breakpoint" stopped \ + "body reason" breakpoint \ + "body hitBreakpointIds" $fn_bpno + +set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \ + {o threadId [i 1]}] \ + 0] +set frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id] + +set scopes [dap_check_request_and_response "get scopes" scopes \ + [format {o frameId [i %d]} $frame_id]] +set scopes [dict get [lindex $scopes 0] body scopes] + +# This is what the implementation does, so we can assume it, but check +# just in case something changes. +lassign $scopes args locals _ignore +gdb_assert {[dict get $args name] == "Arguments"} "argument scope" +gdb_assert {[dict get $locals name] == "Locals"} "local scope" + +gdb_assert {[dict get $locals namedVariables] == 3} "two locals" + +set num [dict get $locals variablesReference] +set refs [lindex [dap_check_request_and_response "fetch variables" \ + "variables" \ + [format {o variablesReference [i %d] count [i 3]} \ + $num]] \ + 0] + +foreach var [dict get $refs body variables] { + set name [dict get $var name] + + switch $name { + "i" { + gdb_assert {[dict get $var value] == "1"} "check value of i" + } + "x" { + gdb_assert {[dict get $var value] == "12"} "check value of x" + } + "outer_arg" { + gdb_assert {[dict get $var value] == "1"} "check value of outer_arg" + } + default { + fail "unknown variable $name" + } + } +} + +dap_shutdown diff --git a/gdb/testsuite/gdb.dap/ada-nested/prog.adb b/gdb/testsuite/gdb.dap/ada-nested/prog.adb new file mode 100644 index 00000000000..6b38835a94c --- /dev/null +++ b/gdb/testsuite/gdb.dap/ada-nested/prog.adb @@ -0,0 +1,32 @@ +-- Copyright 2023 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +procedure Foo is + X : Integer := 12; + + procedure Outer (Outer_Arg : Integer) is + procedure Bump (Stride : Integer) is + begin + X := X + Stride; -- STOP + end; + begin + Bump (Outer_Arg); + end; + +begin + for I in 1 .. 20 loop + Outer (1); + end loop; +end Foo; From patchwork Wed Nov 1 17:09:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78883 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 5FB62385773F for ; Wed, 1 Nov 2023 17:10:16 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 367783858CDA for ; Wed, 1 Nov 2023 17:09:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 367783858CDA 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 367783858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858589; cv=none; b=aTZ72mEruuorWZwfaBbEahvxVUQ0MSKkiZw7Epq262zJAwrONWMNQKo3IK2BlDQzBsPZOCg9beUUTIjpEuYiBu2mij+eoJQt4BMi5i0RPrd0vmfsrs93YzfsEuty/upPfWV76N3sbKTgk6ujq0E1aa4ipzLJdC72SugOaiDO734= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698858589; c=relaxed/simple; bh=ZJpsbR+SqEwJoaeUXcGC0M7lNS9uUBECSUbdtQ1r/gg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=f1+0LwA6xIy1c5H5Ycd/1e+1V8V8dg2eOO8zoPAa09faq8qhbNn+3gaZUbEpzTw6IdmwEuqVh9Rr0eow4E6pb7N3sAfYuU6ZWDmfhqqO9FXc3wW3zBUUeso56GGMyHHPwYpgBcVyqgG0EuP1rXMddvczAwzHeCy3nZMY51qCV10= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3594cb642beso1302675ab.3 for ; Wed, 01 Nov 2023 10:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1698858582; x=1699463382; 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=BolMrql4ZRlnAFZUDStuqSpmWv6r4RyeX4Pc5/7Pzm4=; b=TRI86sF9LmRGIP84zsrtASVMx1SYY7w9BaAUIhBC1xfRKZau2BdKxqwETuNMOe8Mlk nLqig7Z1wu7r1mzC5NswcAT0F6aWAQlBcCEz55hdmBcHjfJjh7cKA7EAXsoKyWTHyVmi pFxrK7EdiHeyM/+z/QaMjlUXWO7BBhx5DlDy/e7l1GBAWtfR7EgvRuV5XPCEGrHcYl3Q cj5op+AvOhD4QFq09WaXhHBZMmvdNCS9zFZTkMTS2IXmBzX0yERBmkvQHQBxzKlCkdiK CZYy0yC7QQs1fr6GYEy23IWNalrteBkaJ4j/IZuniWAW6Mr5NOT3krj+1CkJj21lgbUs xHMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858582; x=1699463382; 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=BolMrql4ZRlnAFZUDStuqSpmWv6r4RyeX4Pc5/7Pzm4=; b=taT3QQfyQgVP7KYhHowcZb0Ud1d1ZRLHEs0FoT6Uimh4B9Bo7kL8f7hKyrhI5EIimt qoESwZXDShwF8Bj61T31s/LJeb7d7HunAITWh0TwMLpxvdHVSVxKahFJugUKBm5ZgpIy kg8bh4i5JZHi48dVYY3WD1nAyaHTnSkeclWf+u0NzZ05e6Nx44OgAODeos+7kL5sey1c GDudMcNyxm2e70MI0N8IHafXDO/PLD2xf2yV/fipwWEcnuRIT3Tz4lRg5G3Fhqt5oYXA JznxUYhlxE8taTvze64rSBMNWt7RR/WWedYI0C6liE4OdLbtugJN5SsUnjBTjRddXGup rlYw== X-Gm-Message-State: AOJu0Yw4my4/a1dllDJJxRs56BPmxeJO7922odSw4ht2EpLfl1j9jIOZ E3QKT8MVyHbWkitOSSBVl9Kl8uYIDzhj5uEYDC/NTw== X-Google-Smtp-Source: AGHT+IEZkPZVrYfPbfaUbD0RgJcZihtYnDmgb91HYX9j5egvXrDd1M9G5Rx9FXnTPyepMVmaYLYqVg== X-Received: by 2002:a05:6e02:cd3:b0:359:38ab:5a55 with SMTP id c19-20020a056e020cd300b0035938ab5a55mr4399785ilj.22.1698858582400; Wed, 01 Nov 2023 10:09:42 -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.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:09:41 -0700 (PDT) From: Tom Tromey Date: Wed, 01 Nov 2023 11:09:39 -0600 Subject: [PATCH 7/7] Update gdb.Symbol.is_variable documentation MIME-Version: 1.0 Message-Id: <20231101-dap-nested-function-v1-7-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 Kévin found a bug in an earlier version of this series that was based on a misconception I had about Symbol.is_variable. This patch fixes the documentation to explain the method a bit better. --- gdb/doc/python.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index afe447644c5..3a7d61af5a5 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -6045,7 +6045,9 @@ local variables will require a frame, but other symbols will not. @end defvar @defvar Symbol.is_variable -@code{True} if the symbol is a variable. +@code{True} if the symbol is a variable, as opposed to something like +a function or type. Note that this also returns @code{False} for +arguments. @end defvar A @code{gdb.Symbol} object has the following methods: