From patchwork Thu Mar 9 17:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66177 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 C30163858296 for ; Thu, 9 Mar 2023 17:52:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C30163858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678384328; bh=k/zRQ9/TlELDJqEsHGw98vn2cACKg63OppzuECBqUuM=; 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=xeItKSoxaiGsr7cBGVxaMymA3mrTpl3+3h5jv9eEnqFQYi9tpA9SYfJuMwVQRA3lU /2nGBjqQesN1B2dkHjiF8Apiu0oPcC2VF5fkVbOn6Y00Aa00gqtbkuq5RsZTQWG5Yl OqLI2rCgiGpfKHfMeLkk8SWHAruJsrVlqwpYpc4I= 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 D0DE23858C78 for ; Thu, 9 Mar 2023 17:51:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D0DE23858C78 Received: by mail-il1-x135.google.com with SMTP id i19so1438497ila.10 for ; Thu, 09 Mar 2023 09:51:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678384276; 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=k/zRQ9/TlELDJqEsHGw98vn2cACKg63OppzuECBqUuM=; b=A55kCLcgbx6fdQ6g1isev797+0wgcB9+5bZ+Oc+4mO3iqNeT0902g2lxjGfLaYv+BC xdw/JJX/BnYX3n7cJq/iq3w/aBcS+xYUoNRET47xMzXMVchCcEOzcktzsaCMWvaH4+Kc 1Bk0ugex4ejIx+5vNN/ZPn5IWZQ8O6H2Iwmsn+nCvqbWn5tXYMG5pp4Du/Agm9NI114F wM7xf9qBcj3gz6wHOM0CWqtUyt+EYqp3w+R7+AmaNR3NoBl+rkjsSfePWk5b9lIPorxw GMCdKLEjVjKNSv04iBG9/eCoUM//vQOS2DabqrYo94B8BgxkMo7MnRl4c/m3jq2dv2fc Fy9Q== X-Gm-Message-State: AO0yUKUO+UVKJ4jqzgapGdLMGVDg9KVCfS5KabAtpQIdY8cXOz3Gvrkh x95Lu6Pz6He0LJX9/0SDLCW78vlBk4QQawVAATE= X-Google-Smtp-Source: AK7set+ZR3rz/eLxo7r2QucWHLDUaQQLZJI7pW1bozJTSkd36aU+plzslLViRMc4awUUyWfUh/vzGg== X-Received: by 2002:a05:6e02:144f:b0:314:f7f:a35a with SMTP id p15-20020a056e02144f00b003140f7fa35amr18725995ilo.7.1678384276030; Thu, 09 Mar 2023 09:51:16 -0800 (PST) Received: from localhost.localdomain (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id j5-20020a056e020ee500b00315785bfabfsm5572276ilk.47.2023.03.09.09.51.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 09:51:15 -0800 (PST) Date: Thu, 09 Mar 2023 10:50:57 -0700 Subject: [PATCH 3/3] Use the correct frame when evaluating a dynamic property MIME-Version: 1.0 Message-Id: <20230309-submit-static-link-fix-v1-3-23af27781fd2@adacore.com> References: <20230309-submit-static-link-fix-v1-0-23af27781fd2@adacore.com> In-Reply-To: <20230309-submit-static-link-fix-v1-0-23af27781fd2@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-11.7 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 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" The test case in this patch shows an unusual situation: an Ada array has a dynamic bound, but the bound comes from a frame that's referred to by the static link. This frame is correctly found when evaluating the array variable itself, but is lost when evaluating the array's bounds. This patch fixes the problem by passing this frame through to value_at_lazy in the DWARF expression evaluator. --- gdb/dwarf2/expr.c | 4 ++-- gdb/testsuite/gdb.ada/static-link.exp | 33 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.ada/static-link/pck.ads | 18 +++++++++++++++ gdb/testsuite/gdb.ada/static-link/prog.adb | 35 ++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 2b41372be8a..fd83ba29a90 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1002,8 +1002,8 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, } address = value_as_address (value_from_pointer (ptr_type, address)); - retval = value_at_lazy (subobj_type, - address + subobj_offset); + retval = value_at_lazy (subobj_type, address + subobj_offset, + m_frame); if (in_stack_memory) retval->set_stack (true); } diff --git a/gdb/testsuite/gdb.ada/static-link.exp b/gdb/testsuite/gdb.ada/static-link.exp new file mode 100644 index 00000000000..86f2fb5076b --- /dev/null +++ b/gdb/testsuite/gdb.ada/static-link.exp @@ -0,0 +1,33 @@ +# 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 . + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile prog + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/prog.adb] +if {![runto "prog.adb:$bp_location"]} { + return -1 +} + +gdb_test "ptype value" [string_to_regexp "type = array (1 .. 3) of integer"] diff --git a/gdb/testsuite/gdb.ada/static-link/pck.ads b/gdb/testsuite/gdb.ada/static-link/pck.ads new file mode 100644 index 00000000000..a37f7bb0a10 --- /dev/null +++ b/gdb/testsuite/gdb.ada/static-link/pck.ads @@ -0,0 +1,18 @@ +-- 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 . + +package Pck is + Some_Value : Integer := 3; +end Pck; diff --git a/gdb/testsuite/gdb.ada/static-link/prog.adb b/gdb/testsuite/gdb.ada/static-link/prog.adb new file mode 100644 index 00000000000..a14817b7440 --- /dev/null +++ b/gdb/testsuite/gdb.ada/static-link/prog.adb @@ -0,0 +1,35 @@ +-- 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 . + +with Pck; use Pck; + +procedure Prog is + + Upper : Integer := Some_Value; + Value : array (1 .. Upper) of Integer := (23, 24, 25); + + procedure Inner_Most is + begin + null; -- STOP + end; + + procedure Intermediate is + begin + Inner_Most; + end; + +begin + Intermediate; +end Prog;