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 2AE883858C83 for ; Tue, 14 Mar 2023 13:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AE883858C83 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 o12so419524iow.6 for ; Tue, 14 Mar 2023 06:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1678801039; 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=QBM+o2EvLv6KBSRD0EKRF4PjRtEugUI/Fe6D8/HNe18=; b=BwExNtEnNuncgjjadopv5oUOsPKQifJ0f0BUyHl3JYhI6dmswBS7r+9uvrzxZbnvXy PyIdp4BIJu5L0kGDXSTAh64LfaTzWONvPqG6B793fVHvczu3Qy5Wp7pGNhUD3bIwY2M8 E8maO40bCeYylCgvcpdOphcHBFnKWDh5BV2GQe4i9aXnYsYCs+vpTxxpLZP4FU7fd9fR HefgGodT6FNJfwKnTMZyd+C2AO1hXvtm2sR289Rug3szXACvOV34xNe1YL8YP3sTOp6l ZnJF5T1Qrb6cB5DqBmQ3zHY4UGdJAUMaFPpu/Vfiv8X9MfH41wPNbcpHqM0Ew4xIlcDy BzDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678801039; 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=QBM+o2EvLv6KBSRD0EKRF4PjRtEugUI/Fe6D8/HNe18=; b=6aLSfgnpcGaQ43+33afS8z+JyVmmS1U8k3y/GnbvBiR7pBlf57GU1jj33Pw/twJTUl 7IM6isNybk6uRDQAekBWkafoV4H049tOq27L6/gU/szO35L3yyIJjF7N1qn/n/1E4KkR DJrK8HZ1UvC7eQC19/14XgiupiYmQOHo+iEZX7LS41uPx/SctVuAX2OVaVRuovilwidx AyHAn2FYkBIvIoqaAczxNghezxUZyBdFNXriWgu2o0DTTtZnjXvTawn2cf0qKPEPEfHl QCHxlNKfvrqfLDDIO5uqaVAXj6zJdAn+InPITs8KLjxUa9XmFMX4EKOLtLHFzb/G/9cD RBzw== X-Gm-Message-State: AO0yUKVjAkUt2H1VSFid2ittUEZk6kbwuPxpJ0XUc182ZxwiPyT4ytI2 sRDvap77JXewH7eGRcJEIH907ikNjt8O6E5fzg0= X-Google-Smtp-Source: AK7set9JAOQa0Ttl0GT1pA6m+HqoB5wPInwNM9puwwQh3gW2NnfSvT3OKpfitYSJ54rQ943ss2hX/g== X-Received: by 2002:a05:6602:2159:b0:74d:46eb:6a57 with SMTP id y25-20020a056602215900b0074d46eb6a57mr27871797ioy.20.1678801039357; Tue, 14 Mar 2023 06:37:19 -0700 (PDT) Received: from localhost.localdomain (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id d7-20020a6b7d47000000b0071664d0a4d7sm809045ioq.49.2023.03.14.06.37.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 06:37:19 -0700 (PDT) From: Tom Tromey Date: Tue, 14 Mar 2023 07:37:16 -0600 Subject: [PATCH 1/3] Handle function descriptors in call_site_target MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230314-submit-ppc-finish-fixes-v1-1-5f2f461b52f8@adacore.com> References: <20230314-submit-ppc-finish-fixes-v1-0-5f2f461b52f8@adacore.com> In-Reply-To: <20230314-submit-ppc-finish-fixes-v1-0-5f2f461b52f8@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-11.5 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 List-Id: call_site_target::iterate_over_addresses may look up a minimal symbol. On platforms like PPC64 that use function descriptors, this may find an unexpected address. The fix is to use gdbarch_convert_from_func_ptr_addr to convert from a function descriptor to the address recorded at the call site. I've added a new test case that is based on the internal AdaCore test that provoked this bug. However, I'm unable to test it as-is on PPC64. --- gdb/dwarf2/loc.c | 6 ++++- gdb/testsuite/gdb.ada/finish-large.exp | 30 ++++++++++++++++++++++++ gdb/testsuite/gdb.ada/finish-large/p.adb | 24 +++++++++++++++++++ gdb/testsuite/gdb.ada/finish-large/pck.adb | 28 ++++++++++++++++++++++ gdb/testsuite/gdb.ada/finish-large/pck.ads | 37 ++++++++++++++++++++++++++++++ 5 files changed, 124 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 914e016f085..d9615870aeb 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -711,7 +711,11 @@ call_site_target::iterate_over_addresses : msym.minsym->print_name ())); } - callback (msym.value_address ()); + + CORE_ADDR addr = (gdbarch_convert_from_func_ptr_addr + (call_site_gdbarch, msym.value_address (), + current_inferior ()->top_target ())); + callback (addr); } break; diff --git a/gdb/testsuite/gdb.ada/finish-large.exp b/gdb/testsuite/gdb.ada/finish-large.exp new file mode 100644 index 00000000000..5661d132a18 --- /dev/null +++ b/gdb/testsuite/gdb.ada/finish-large.exp @@ -0,0 +1,30 @@ +# 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 p + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} { + return -1 +} + +clean_restart ${testfile} +runto "pck.create_large" + +set value "= (i => 1, j => 2, k => 3, l => 4, m => 5, n => 6, o => 7, p => 8, q => 9, r => 10, s => 11, t => 12)" +gdb_test "finish" [string_to_regexp $value] diff --git a/gdb/testsuite/gdb.ada/finish-large/p.adb b/gdb/testsuite/gdb.ada/finish-large/p.adb new file mode 100644 index 00000000000..ce7631e5cbd --- /dev/null +++ b/gdb/testsuite/gdb.ada/finish-large/p.adb @@ -0,0 +1,24 @@ +-- 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 P is + Large : Data_Large; +begin + Large := Create_Large; + Large.P := 42; + Break_Me; +end P; diff --git a/gdb/testsuite/gdb.ada/finish-large/pck.adb b/gdb/testsuite/gdb.ada/finish-large/pck.adb new file mode 100644 index 00000000000..18ed031db12 --- /dev/null +++ b/gdb/testsuite/gdb.ada/finish-large/pck.adb @@ -0,0 +1,28 @@ +-- 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 body Pck is + + function Create_Large return Data_Large is + begin + return (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); + end Create_Large; + + procedure Break_Me is + begin + null; + end Break_Me; + +end Pck; diff --git a/gdb/testsuite/gdb.ada/finish-large/pck.ads b/gdb/testsuite/gdb.ada/finish-large/pck.ads new file mode 100644 index 00000000000..0ed49a71241 --- /dev/null +++ b/gdb/testsuite/gdb.ada/finish-large/pck.ads @@ -0,0 +1,37 @@ +-- 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 + + type Data_Large is record + I : Integer; + J : Integer; + K : Integer; + L : Integer; + M : Integer; + N : Integer; + O : Integer; + P : Integer; + Q : Integer; + R : Integer; + S : Integer; + T : Integer; + end record; + + function Create_Large return Data_Large; + + procedure Break_Me; + +end Pck; -- 2.39.1