From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 9E9473858D3C for ; Sun, 5 Nov 2023 22:11:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E9473858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9E9473858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699222314; cv=none; b=SZaxxNPHN6ysH68vjNe5kbTRHOr59M4EEmZ6vP/UTKAWZGU9XKo4rdZdxjBFWEDNNtv05WEV/yPhztsrPX1K/nvO+H4f3kc9Jo/ARSe/TcGRspS+SOSF/OTy0P2ik2fTF9QePISUQeK9oDPNM67X7NFzOdQG2gQy3MXxPzdmvC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699222314; c=relaxed/simple; bh=eKpwAva2InNqwZ22a4mtc05sOhWyNH6LWIQXAFZZjCs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=fbSxzUCMqeekAzkN3x9T9voqrGElETUiExRulxKs9nL7i1s17G9e88RhjHTFSWZCYms6DUldudp1PKbXXUFIZ80cfnH9YmBJMcACZtho0lC9HhC2/FGyW89GLNxgmAAFs5YUcxqiL+xfeWfeP7nmobtq5QAzPWTKpUew8MDoh3w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14F96C15; Sun, 5 Nov 2023 14:12:36 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 943063F6C4; Sun, 5 Nov 2023 14:11:51 -0800 (PST) From: Richard Sandiford To: Iain Sandoe Mail-Followup-To: Iain Sandoe ,GCC Patches , Thomas Schwinge , richard.sandiford@arm.com Cc: GCC Patches , Thomas Schwinge Subject: Re: [PATCH] testsuite, Darwin: Add support for Mach-O function body scans. References: <20231026192301.58329-1-iain@sandoe.co.uk> <887CFAF9-D8A9-4121-99A0-A8A2869D75A6@sandoe.co.uk> <4EA34295-8D2A-4856-8F54-3ADACC915E68@sandoe.co.uk> Date: Sun, 05 Nov 2023 22:11:50 +0000 In-Reply-To: <4EA34295-8D2A-4856-8F54-3ADACC915E68@sandoe.co.uk> (Iain Sandoe's message of "Fri, 27 Oct 2023 12:00:15 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-23.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,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 List-Id: Iain Sandoe writes: > Hi Richard, > >> On 26 Oct 2023, at 21:00, Iain Sandoe wrote: > >>> On 26 Oct 2023, at 20:49, Richard Sandiford > wrote: >>> >>> Iain Sandoe writes: >>>> This was written before Thomas' modification to the ELF-handling to al= low >>>> a config-based change for target details. I did consider updating this >>>> to try and use that scheme, but I think that it would sit a little >>>> awkwardly, since there are some differences in the start-up scanning f= or >>>> Mach-O. I would say that in all probability we could improve things b= ut >>>> I'd like to put this forward as a well-tested initial implementation. >>> >>> Sorry, I would prefer to extend the existing function instead. >>> E.g. there's already some divergence between the Mach-O version >>> and the default version, in that the Mach-O version doesn't print >>> verbose messages. I also don't think that the current default code >>> is so watertight that it'll never need to be updated in future. >> >> Fair enough, will explore what can be done (as I recall last I looked the >> primary difference was in the initial start-up scan). > > I=E2=80=99ve done this as attached. > > For the record, when doing it, it gave rise to the same misgivings that l= ed > to the separate implementation before. > > * as we add formats and uncover asm oddities, they all need to be handled > in one set of code, IMO it could be come quite convoluted. > > * now making a change to the MACH-O code, means I have to check I did not > inadvertently break ELF (and likewise, in theory, an ELF change should= check > MACH-O, but many folks do/can not do that). > > Maybe there=E2=80=99s some half-way-house where code can usefully be shar= ed without > those down-sides. > > Anyway, to make progress, is the revised version OK for trunk? (tested on > aarch64-linux and aarch64-darwin). Sorry for the slow reply. I was hoping we'd be able to share a bit more code than that, and avoid an isMACHO toggle. Does something like the attached adaption of your patch work? Only spot-checked on aarch64-linux-gnu so far. (The patch tries to avoid capturing the user label prefix, hopefully avoiding the needsULP thing.) Thanks, Richard diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 5df80325dff..2434550f0c3 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -785,23 +785,34 @@ proc configure_check-function-bodies { config } { =20 # Regexp for the start of a function definition (name in \1). if { [istarget nvptx*-*-*] } { - set up_config(start) {^// BEGIN(?: GLOBAL|) FUNCTION DEF: ([a-zA-Z_]\S+)$} + set up_config(start) { + {^// BEGIN(?: GLOBAL|) FUNCTION DEF: ([a-zA-Z_]\S+)$} + } + } elseif { [istarget *-*-darwin*] } { + set up_config(start) { + {^_([a-zA-Z_]\S+):$} + {^LFB[0-9]+:} + } } else { - set up_config(start) {^([a-zA-Z_]\S+):$} + set up_config(start) {{^([a-zA-Z_]\S+):$}} } =20 # Regexp for the end of a function definition. if { [istarget nvptx*-*-*] } { set up_config(end) {^\}$} + } elseif { [istarget *-*-darwin*] } { + set up_config(end) {^LFE[0-9]+} } else { set up_config(end) {^\s*\.size} } -=20 + # Regexp for lines that aren't interesting. if { [istarget nvptx*-*-*] } { # Skip lines beginning with '//' comments ('-fverbose-asm', for # example). set up_config(fluff) {^\s*(?://)} + } elseif { [istarget *-*-darwin*] } { + set up_config(fluff) {^\s*(?:\.|//|@)|^L[0-9ACESV]} } else { # Skip lines beginning with labels ('.L[...]:') or other directives # ('.align', '.cfi_startproc', '.quad [...]', '.text', etc.), '//' or @@ -833,9 +844,19 @@ proc parse_function_bodies { config filename result } { set fd [open $filename r] set in_function 0 while { [gets $fd line] >=3D 0 } { - if { [regexp $up_config(start) $line dummy function_name] } { - set in_function 1 - set function_body "" + if { $in_function =3D=3D 0 } { + if { [regexp [lindex $up_config(start) 0] \ + $line dummy function_name] } { + set in_function 1 + set function_body "" + } + } elseif { $in_function < [llength $up_config(start)] } { + if { [regexp [lindex $up_config(start) $in_function] $line] } { + incr in_function + } else { + verbose "parse_function_bodies: skipped $function_name" + set in_function 0 + } } elseif { $in_function } { if { [regexp $up_config(end) $line] } { verbose "parse_function_bodies: $function_name:\n$function_body" --=20 2.25.1