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 CEC163858CDB for ; Mon, 6 Nov 2023 10:58:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CEC163858CDB 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 CEC163858CDB 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=1699268291; cv=none; b=IbQeyCFli9MFgocoAch1gIY4R0LI6kLLrO9PzmZpbANX8twYcvTnIuQEdLO//zpTZtSh1DlTHsUdznNuS3nF7qEin3qODw0oHyzsMy/FDkowmgUo871TQb6ZtXSYu+QqFc40XqJSW2U174z6JaoMk0VQU3E0Aq/mxU0xn0EFp0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699268291; c=relaxed/simple; bh=hEqMQKtwQ+sO3G9iZZjban2fI5XAbArO0uAEVlu2fqI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=BbFVr4P/r4LM7j9+rF6GZF15SHIgFjvJGS6QnxqvvL/VP7lJH9v7yBHUPnv5Vp40ihjoGb/2vTAraeaoHM67qzdhh2jSiUaRUJOh41B3Jm+OtmAFAUGuWWQOEgHT3h81V3aSKdCl6a9IiJZH3dbh2yCUydM23gvy3GPcgxroQUg= 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 7C7771FB; Mon, 6 Nov 2023 02:58:50 -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 C112D3F64C; Mon, 6 Nov 2023 02:58:05 -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. In-Reply-To: <0CA83A3A-E7DC-4ACC-A7FC-76E5677703CF@sandoe.co.uk> (Iain Sandoe's message of "Sun, 5 Nov 2023 21:59:24 -1000") References: <20231026192301.58329-1-iain@sandoe.co.uk> <887CFAF9-D8A9-4121-99A0-A8A2869D75A6@sandoe.co.uk> <4EA34295-8D2A-4856-8F54-3ADACC915E68@sandoe.co.uk> <0CA83A3A-E7DC-4ACC-A7FC-76E5677703CF@sandoe.co.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Date: Mon, 06 Nov 2023 10:57:45 +0000 Message-ID: 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 5 Nov 2023, at 12:11, Richard Sandiford w= rote: >>=20 >> Iain Sandoe writes: > >>>> On 26 Oct 2023, at 21:00, Iain Sandoe wrote: >>>=20 >>>>> On 26 Oct 2023, at 20:49, Richard Sandiford >>> wrote: >>>>>=20 >>>>> Iain Sandoe writes: >>>>>> This was written before Thomas' modification to the ELF-handling to = allow >>>>>> a config-based change for target details. I did consider updating t= his >>>>>> 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= for >>>>>> Mach-O. I would say that in all probability we could improve things= but >>>>>> I'd like to put this forward as a well-tested initial implementation. >>>>>=20 >>>>> 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. >>>>=20 >>>> Fair enough, will explore what can be done (as I recall last I looked = the >>>> primary difference was in the initial start-up scan). >>>=20 >>> I=E2=80=99ve done this as attached. >>>=20 >>> For the record, when doing it, it gave rise to the same misgivings that= led >>> to the separate implementation before. >>>=20 >>> * as we add formats and uncover asm oddities, they all need to be handl= ed >>> in one set of code, IMO it could be come quite convoluted. >>>=20 >>> * now making a change to the MACH-O code, means I have to check I did n= ot >>> inadvertently break ELF (and likewise, in theory, an ELF change shoul= d check >>> MACH-O, but many folks do/can not do that). >>>=20 >>> Maybe there=E2=80=99s some half-way-house where code can usefully be sh= ared without >>> those down-sides. >>>=20 >>> Anyway, to make progress, is the revised version OK for trunk? (tested = on >>> aarch64-linux and aarch64-darwin). >>=20 >> 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. >>=20 >> (The patch tries to avoid capturing the user label prefix, hopefully >> avoiding the needsULP thing.) > > Yes, this works for me too for Arm64 Darwin (and probably is fine for oth= er > Darwin archs in case we implement body tests there). If we decide to emit > some comment-based markers to delineat functions without unwind data, > we can just amend the start and end. > > thanks, > Iain > (doing some wider testing, but for now the only mach-o cases are in the > arm64 code, so the fact that those passed so far is pretty good indicati= on). OK, great. It passed testing for me too, so please go ahead and commit if it does for you. > ----- > > As an aside what=E2=80=99s the intention for cases like this? > > .data > foo: > .xxxx =E2=80=A6. > .size foo, .-foo ATM there's no way for the test to say that specific pseudo-ops are interesting to it. Same for labels. It might be useful to add support for that though. Thanks, Richard > > > >>=20 >> Thanks, >> Richard >>=20 >>=20 >> diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.e= xp >> 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