From patchwork Wed Oct 19 11:53:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 5276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp277796wrs; Wed, 19 Oct 2022 04:53:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6OGUKw2SEa6p2mXSsHrJ3aIE9Cy75HCcUvfXabphDj1yP7IEqVQkT+LKYQ2HD8B6s0VEKr X-Received: by 2002:aa7:d392:0:b0:458:800a:c47 with SMTP id x18-20020aa7d392000000b00458800a0c47mr6954329edq.5.1666180414152; Wed, 19 Oct 2022 04:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666180414; cv=none; d=google.com; s=arc-20160816; b=IKC6aQv+XqSoYIqlofYhYTikwFqe/n5K+76TsnUyV+Y0AFMKMOmobCpJQBuQEqnq+s iis2yuuavEfhv+WkHDba8Nu+SAPuDxv7XkaMwkHLI58FBxNmIUdl00Ea3z6+MH3HgQ6o 4a0Gcn/pfOyeiiG1fOU1oyabL53DzjUa07EsZ3j9wuTz0WXcohlG3m/vCMEdRYJ2NqCw mwLyfZlcnD/a4fyMpznnMa6HHBfEt6VvKWFAZYbKSyU2V3/9LDmRXaZSBc3OTrv7smIb 2CJB5WrxaK3gfuqP1VKV0xQQ5VBl1T9RAsgMjcoezdsZcXeDwsxe7id6uuRpvBN485YY BNIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :in-reply-to:content-disposition:mime-version:references:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=SksabJ+Tfi20GNMydzOaeAfybuQT3a+2XFkLKyOutJY=; b=ulnKC6yo2X+Ul8e2VdVQYc1W0m5C4SfIU/ia6TnYEhdlj+fVyeg5tSKe9axi8OcyL8 hBVqB+eCKjcum3CT0LuqorB1LmPu3jf5G/ZBYsj9CiMlO2gjzm4e/fpbC8WnjKblOXpf xff5jJ+HiRgdYgKhggVVxMywUZCYT+d6dvNqpCfZeoC97HD0lMYfihmjKpZNKOm0/bzT R9ZUoM9pOAvRPrS79Q7p/ExbA3H/Lyj3NBV4efIN8jJYMcs1bD3Fn7XQQPkBKQEZPn8e 7MeGKCOOgm3iVVt0NseqVyYO2BeOmGToGnbrTeeb5ZPiee4Zp1BYAumrV81hYbPgWpUk V7DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=SNg+w2Za; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id cs13-20020a170906dc8d00b0077b4248b138si13917037ejc.127.2022.10.19.04.53.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 04:53:34 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=SNg+w2Za; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A25B33858C2F for ; Wed, 19 Oct 2022 11:53:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A25B33858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666180412; bh=SksabJ+Tfi20GNMydzOaeAfybuQT3a+2XFkLKyOutJY=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=SNg+w2ZaZx7SlvsUMlV/A5sDFldoHiCHYAYKmEyGwWi3mI+wHqYjKlmuv08a1Ul1K J2iMg7GaT+oaD5Ic8Uloea9wZnNu6EaQrDZGwuE1wG1AT0QJkCdsye9gOLHRtpYfHx c03IvqUNl3Dyj4NqToW2lJprJLel+FGsmyQS+TL0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 9EF4A3858D39 for ; Wed, 19 Oct 2022 11:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9EF4A3858D39 Received: by mail-pf1-x42b.google.com with SMTP id y191so17014005pfb.2 for ; Wed, 19 Oct 2022 04:53:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SksabJ+Tfi20GNMydzOaeAfybuQT3a+2XFkLKyOutJY=; b=wQoO/jWK3igO+kVLlh8ZEkJVYODKAxHHd+OlZPyvTNmdj+rF1wfVjzE+E6WhYNJW1i KtxjuK0UsTUyF4cW9f6HR5QVBp9HRQQCPEXStvPXbVRLSW8Co9We1U++YzKiYPdJ0y5p P55s7CKu5wNdxHqbyzwep+r7OMUvihdOVYzXVpLiKGtybJcaV9cFU0wLkTqphZ+jzyyF cOPXh10Vk2oiZENKk+ufTu4MM7W1v6xrpqkCRL1/jMHBXHQxoKvlUHcm1NEyINcFI1+5 Zlp8r0chIyRyUNrmsVpKYUgDpXcCvpdrAiWzNB1IeYDcFJYxBNbobcyJFiBxm9KOvNuG GqeQ== X-Gm-Message-State: ACrzQf0zaIfss/zYFjwWYtK7rUGk9US9ibRtucAwp6HnnEcFKJAYWyP4 /KraLIkuNFCIlibbZYE5oMhELEYwF6s= X-Received: by 2002:a05:6a00:124a:b0:563:55ba:a6f8 with SMTP id u10-20020a056a00124a00b0056355baa6f8mr8356358pfi.2.1666180402551; Wed, 19 Oct 2022 04:53:22 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:1cc1:f0c0:dfa1:b903]) by smtp.gmail.com with ESMTPSA id b26-20020aa7951a000000b005604c1a0fbcsm11196501pfp.74.2022.10.19.04.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 04:53:21 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 00D821140F51; Wed, 19 Oct 2022 22:23:18 +1030 (ACDT) Date: Wed, 19 Oct 2022 22:23:18 +1030 To: Tom de Vries Subject: Fix addr2line test for ppc64 elfv1 and mingw Message-ID: References: <20221019073533.3F8543858D3C@sourceware.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3035.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Cc: Binutils Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747116793928112340?= X-GMAIL-MSGID: =?utf-8?q?1747116793928112340?= On Wed, Oct 19, 2022 at 07:32:40PM +1030, Alan Modra wrote: > On Wed, Oct 19, 2022 at 09:55:59AM +0200, Tom de Vries via Binutils wrote: > > looks like this: > > ... > > regexp -line {^([0-9a-fA-F]+)?[ ]+T main} $output contents > > set list [regexp -inline -all -- {\S+} $contents] > > ... > > is causing: > > ... > > ERROR: tcl error sourcing /var/lib/buildbot/workers/wildebeest/binutils-debian-ppc64/binutils-gdb/binutils/testsuite/binutils-all/addr2line.exp. > > ERROR: tcl error code TCL LOOKUP VARNAME contents > > ERROR: can't read "contents": no such variable > > while executing > > "regexp -inline -all -- {\S+} $contents" > > (file "/var/lib/buildbot/workers/wildebeest/binutils-debian-ppc64/binutils-gdb/binutils/testsuite/binutils-all/addr2line.exp" > > line 31) > > invoked from within > > ... > > > > If the regexp doesn't match, contents is not set. > > Right. It doesn't match for PowerPC64 ELFv1 because function symbols > are defined on a descriptor and are flagged as "D" not "T". The test > also fails on cygwin/mingw where the compiler output is testprog.exe. > > I think the following will do the trick, I'll commit after a full > test run. It needed a bit more work to make the test pass on powerpc64 * testsuite/binutils-all/addr2line.exp: Tidy. For powerpc64 arrange to pass --synthetic to nm, and extract .main and .fn symbol address for addr2line test. Handle default executable extension on cygwin/mingw compilers. diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/binutils-all/addr2line.exp index 15e60366ac2..66a2d5d32a0 100644 --- a/binutils/testsuite/binutils-all/addr2line.exp +++ b/binutils/testsuite/binutils-all/addr2line.exp @@ -14,48 +14,60 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -global $NM -global $ADDR2LINE - set testname "addr2line" +set opts "" +set dot "" +set exe [exeext] + +# powerpc64 function symbols are on descriptors rather than code. +if [istarget powerpc64-*-*] { + set opts --synthetic + set dot {\.} +} + if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } { verbose "Unable to compile test file." - untested "addr2line" + untested "$testname" return } #testcase for default option. #Run nm command and input the main symbol address to addr2line. -set output [binutils_run $NM "tmpdir/testprog"] -regexp -line {^([0-9a-fA-F]+)?[ ]+T main} $output contents -set list [regexp -inline -all -- {\S+} $contents] -set got [binutils_run $ADDR2LINE "-e tmpdir/testprog [lindex $list 0]"] -set want "$srcdir/$subdir/testprog.c:\[0-9\]+" -if ![regexp $want $got] then { - fail "$testname $got\n" +set output [binutils_run $NM "$opts tmpdir/testprog$exe"] +if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then { + fail "$testname" } else { - pass "$testname" + set list [regexp -inline -all -- {\S+} $contents] + set got [binutils_run $ADDR2LINE "-e tmpdir/testprog$exe [lindex $list 0]"] + set want "$srcdir/$subdir/testprog.c:\[0-9\]+" + if ![regexp $want $got] then { + fail "$testname $got\n" + } else { + pass "$testname" + } } #testcase for -f option. #Run nm command and input the fn function symbol address to addr2line. -regexp -line {^([0-9a-fA-F]+)?[ ]+T fn} $output contents -pass "output is $output \n contents is $contents\n" -set list [regexp -inline -all -- {\S+} $contents] -set got [binutils_run $ADDR2LINE "-f -e tmpdir/testprog [lindex $list 0]"] -set want "fn\n$srcdir/$subdir/testprog.c:\[0-9\]+" -if ![regexp $want $got] then { - fail "$testname -f option $got\n" +if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}fn" $output contents] then { + fail "$testname -f option" } else { - pass "$testname -f option" -} + set list [regexp -inline -all -- {\S+} $contents] + set got [binutils_run $ADDR2LINE "-f -e tmpdir/testprog$exe [lindex $list 0]"] + set want "fn\n$srcdir/$subdir/testprog.c:\[0-9\]+" + if ![regexp $want $got] then { + fail "$testname -f option $got\n" + } else { + pass "$testname -f option" + } #testcase for -s option. #Using the same fn function address used in -f option. -set got [binutils_run $ADDR2LINE "-s -e tmpdir/testprog [lindex $list 0]"] -set want "testprog.c:\[0-9\]+" -if ![regexp $want $got] then { - fail "$testname -s option $got\n" -} else { - pass "$testname -s option" + set got [binutils_run $ADDR2LINE "-s -e tmpdir/testprog$exe [lindex $list 0]"] + set want "testprog.c:\[0-9\]+" + if ![regexp $want $got] then { + fail "$testname -s option $got\n" + } else { + pass "$testname -s option" + } }