From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id DC8E63858D35 for ; Fri, 27 Oct 2023 11:00:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC8E63858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sandoe.co.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC8E63858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=85.119.248.222 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698404418; cv=none; b=I+z51V0GJckBqO8q3gnbe4TryFU2xSElJ7CNP7yOEhueknVf4XADB+2c46qV/ma3+xeOW5Gu+rAwZC4SQzyjnMEmLYqRYLFVMVkkdZpfo07wTAOkVhOjnyluc9lDs2xLqVYULj/YdpEMZPciE/lRlSy4lA1PGQkeOf+HiW+25JA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698404418; c=relaxed/simple; bh=IAbTQqg3vyhRAH7gDhgrXBW685O/AV7gn/tlxzhpBMQ=; h=From:Message-Id:Mime-Version:Subject:Date:To; b=T3LDiZi858xp2UjM//CRBc7wBnGj16VH0ZmbThovCVkoyJDecKEHjd8LSXZu5OPBa7oDNJAP3qKP/en6D2DcRhMNNh4wSKdtb7P6rG+vkR17eMGCG8Aqy8G6sXoeyTv3osDd7pORctKmhftB6QcKCfDVYGsf6bHhQYjXfT2iKf8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: (qmail 5193 invoked from network); 27 Oct 2023 11:00:15 -0000 X-APM-Out-ID: 16984044150518 X-APM-Authkey: 257869/1(257869/1) 8 Received: from unknown (HELO smtpclient.apple) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 27 Oct 2023 11:00:15 -0000 From: Iain Sandoe Message-Id: <4EA34295-8D2A-4856-8F54-3ADACC915E68@sandoe.co.uk> Content-Type: multipart/mixed; boundary="Apple-Mail=_EE23F47A-6863-4A79-923E-130531DF0C40" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: [PATCH] testsuite, Darwin: Add support for Mach-O function body scans. Date: Fri, 27 Oct 2023 12:00:15 +0100 In-Reply-To: <887CFAF9-D8A9-4121-99A0-A8A2869D75A6@sandoe.co.uk> Cc: GCC Patches , Thomas Schwinge To: Richard Sandiford References: <20231026192301.58329-1-iain@sandoe.co.uk> <887CFAF9-D8A9-4121-99A0-A8A2869D75A6@sandoe.co.uk> X-Mailer: Apple Mail (2.3696.120.41.1.4) X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,KAM_COUK,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --Apple-Mail=_EE23F47A-6863-4A79-923E-130531DF0C40 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Richard, > On 26 Oct 2023, at 21:00, Iain Sandoe wrote: >> 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 = 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 = 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). I=E2=80=99ve done this as attached. For the record, when doing it, it gave rise to the same misgivings that = led 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 = shared without those down-sides. Anyway, to make progress, is the revised version OK for trunk? (tested = on aarch64-linux and aarch64-darwin). thanks Iain --Apple-Mail=_EE23F47A-6863-4A79-923E-130531DF0C40 Content-Disposition: attachment; filename=0001-testsuite-Darwin-Add-support-for-Mach-O-function-bod.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-testsuite-Darwin-Add-support-for-Mach-O-function-bod.patch" Content-Transfer-Encoding: quoted-printable =46rom=201b403975b88ec0b327fff5191273f1774ae6652b=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Iain=20Sandoe=20=0ADate:=20= Thu,=2026=20Oct=202023=2009:52:04=20+0100=0ASubject:=20[PATCH=20v2]=20= testsuite,=20Darwin:=20Add=20support=20for=20Mach-O=20function=20body=0A=20= scans.=0A=0AWe=20need=20to=20process=20the=20source=20slightly=20= differently=20from=20ELF,=20especially=0Ain=20that=20we=20have=20= __USER_LABEL_PREFIX__=20and=20there=20are=20no=20function=20start=0Aand=20= end=20assembler=20directives.=20=20This=20means=20we=20cannot=20= delineate=20functions=0Awhen=20frame=20output=20is=20switched=20off.=0A=0A= TODO:=20consider=20adding=20-mtest-markers=20or=20something=20similar=20= to=20inject=0Aassembler=20comments=20that=20can=20be=20scanned=20for.=0A=0A= gcc/testsuite/ChangeLog:=0A=0A=09*=20lib/scanasm.exp:=20Initial=20= handling=20for=20Mach-O=20function=20body=20scans.=0A=0ASigned-off-by:=20= Iain=20Sandoe=20=0A---=0A=20= gcc/testsuite/lib/scanasm.exp=20|=2045=20= ++++++++++++++++++++++++++++++++---=0A=201=20file=20changed,=2042=20= insertions(+),=203=20deletions(-)=0A=0Adiff=20--git=20= a/gcc/testsuite/lib/scanasm.exp=20b/gcc/testsuite/lib/scanasm.exp=0A= index=205df80325dff..5b31aee954a=20100644=0A---=20= a/gcc/testsuite/lib/scanasm.exp=0A+++=20b/gcc/testsuite/lib/scanasm.exp=0A= @@=20-783,9=20+783,17=20@@=20proc=20scan-lto-assembler=20{=20args=20}=20= {=0A=20proc=20configure_check-function-bodies=20{=20config=20}=20{=0A=20=20= =20=20=20upvar=20$config=20up_config=0A=20=0A+=20=20=20=20if=20{=20= [istarget=20*-*-darwin*]=20}=20{=0A+=09set=20up_config(isMACHO)=201=0A+=20= =20=20=20}=20else=20{=0A+=09set=20up_config(isMACHO)=200=0A+=20=20=20=20= }=0A+=0A=20=20=20=20=20#=20Regexp=20for=20the=20start=20of=20a=20= function=20definition=20(name=20in=20\1).=0A=20=20=20=20=20if=20{=20= [istarget=20nvptx*-*-*]=20}=20{=0A=20=09set=20up_config(start)=20{^//=20= BEGIN(?:=20GLOBAL|)=20FUNCTION=20DEF:=20([a-zA-Z_]\S+)$}=0A+=20=20=20=20= }=20elseif=20{=20[istarget=20*-*-darwin*]=20}=20{=0A+=09set=20= up_config(start)=20{^LFB[0-9]+:}=0A=20=20=20=20=20}=20else=20{=0A=20=09= set=20up_config(start)=20{^([a-zA-Z_]\S+):$}=0A=20=20=20=20=20}=0A@@=20= -793,6=20+801,8=20@@=20proc=20configure_check-function-bodies=20{=20= config=20}=20{=0A=20=20=20=20=20#=20Regexp=20for=20the=20end=20of=20a=20= function=20definition.=0A=20=20=20=20=20if=20{=20[istarget=20nvptx*-*-*]=20= }=20{=0A=20=09set=20up_config(end)=20{^\}$}=0A+=20=20=20=20}=20elseif=20= {=20[istarget=20*-*-darwin*]=20}=20{=0A+=09set=20up_config(end)=20= {^LFE[0-9]+}=0A=20=20=20=20=20}=20else=20{=0A=20=09set=20up_config(end)=20= {^\s*\.size}=0A=20=20=20=20=20}=0A@@=20-802,6=20+812,8=20@@=20proc=20= configure_check-function-bodies=20{=20config=20}=20{=0A=20=09#=20Skip=20= lines=20beginning=20with=20'//'=20comments=20('-fverbose-asm',=20for=0A=20= =09#=20example).=0A=20=09set=20up_config(fluff)=20{^\s*(?://)}=0A+=20=20=20= =20}=20elseif=20{=20[istarget=20*-*-darwin*]=20}=20{=0A+=09set=20= up_config(fluff)=20{^\s*(?:\.|//|@)|^L[0-9ACESV]}=0A=20=20=20=20=20}=20= else=20{=0A=20=09#=20Skip=20lines=20beginning=20with=20labels=20= ('.L[...]:')=20or=20other=20directives=0A=20=09#=20('.align',=20= '.cfi_startproc',=20'.quad=20[...]',=20'.text',=20etc.),=20'//'=20or=0A= @@=20-820,6=20+832,13=20@@=20proc=20configure_check-function-bodies=20{=20= config=20}=20{=0A=20=20=20=20=20}=20else=20{=0A=20=09set=20= up_config(line_prefix)=20{\t}=0A=20=20=20=20=20}=0A+=0A+=20=20=20=20#=20= Regex=20for=20a=20label,=20account=20for=20USER_LABEL_PREFIX=0A+=20=20=20= =20if=20{=20[istarget=20*-*-darwin*]=20}=20{=0A+=09set=20= up_config(label)=20{^(_[a-zA-Z_]\S+):$}=0A+=20=20=20=20}=20else=20{=0A+=09= set=20up_config(label)=20{^([a-zA-Z_]\S+):$}=0A+=20=20=20=20}=0A=20}=0A=20= =0A=20#=20Per=20CONFIG,=20read=20assembly=20file=20FILENAME=20and=20= store=20a=20mapping=20from=20function=0A@@=20-833,8=20+852,20=20@@=20= proc=20parse_function_bodies=20{=20config=20filename=20result=20}=20{=0A=20= =20=20=20=20set=20fd=20[open=20$filename=20r]=0A=20=20=20=20=20set=20= in_function=200=0A=20=20=20=20=20while=20{=20[gets=20$fd=20line]=20>=3D=20= 0=20}=20{=0A-=09if=20{=20[regexp=20$up_config(start)=20$line=20dummy=20= function_name]=20}=20{=0A-=09=20=20=20=20set=20in_function=201=0A+=09if=20= {=20$up_config(isMACHO)=20&&=20$in_function=20<=202=20}=20{=0A+=09=20=20=20= =20if=20{=20!$in_function=20&&=20[regexp=20$up_config(label)=20$line=20= dummy=20function_name]=20}=20{=0A+=09=09set=20in_function=201=0A+=09=09= set=20function_body=20""=0A+=09=20=20=20=20}=20elseif=20{=20$in_function=20= =3D=3D=201=20}=20{=0A+=09=09if=20{=20[regexp=20$up_config(start)=20= $line]=20}=20{=0A+=09=09=20=20set=20in_function=202=0A+=09=09}=20else=20= {=0A+=09=09=20=20=20verbose=20"parse_function_bodies:=20skipped=20= $function_name"=0A+=09=09=20=20=20set=20in_function=200=0A+=09=09}=0A+=09= =20=20=20=20}=0A+=09}=20elseif=20{=20!$up_config(isMACHO)=20&&=20[regexp=20= $up_config(start)=20$line=20dummy=20function_name]=20}=20{=0A+=09=20=20=20= =20set=20in_function=202=0A=20=09=20=20=20=20set=20function_body=20""=0A=20= =09}=20elseif=20{=20$in_function=20}=20{=0A=20=09=20=20=20=20if=20{=20= [regexp=20$up_config(end)=20$line]=20}=20{=0A@@=20-883,6=20+914,12=20@@=20= proc=20check-function-bodies=20{=20args=20}=20{=0A=20=09error=20"too=20= many=20arguments=20to=20check-function-bodies"=0A=20=20=20=20=20}=0A=20=0A= +=20=20=20=20#=20some=20targets=20have=20a=20__USER_LABEL_PREFIX__=0A+=20= =20=20=20set=20needsULP=200=0A+=20=20=20=20if=20{=20[istarget=20= *-*-darwin*]=20}=20{=0A+=20=20=20=20=20=20set=20needsULP=201=0A+=20=20=20= =20}=0A+=0A=20=20=20=20=20if=20{=20[llength=20$args]=20>=3D=203=20}=20{=0A= =20=09set=20required_flags=20[lindex=20$args=202]=0A=20=0A@@=20-938,7=20= +975,6=20@@=20proc=20check-function-bodies=20{=20args=20}=20{=0A=20=20=20= =20=20set=20start_expected=20{^(\S+):$}=0A=20=0A=20=20=20=20=20= configure_check-function-bodies=20config=0A-=0A=20=20=20=20=20set=20= have_bodies=200=0A=20=20=20=20=20if=20{=20[is_remote=20host]=20}=20{=0A=20= =09remote_upload=20host=20"$filename"=0A@@=20-988,6=20+1024,9=20@@=20= proc=20check-function-bodies=20{=20args=20}=20{=0A=20=09=09if=20{=20= $xfail_all=20||=20[string=20equal=20$selector=20"F"]=20}=20{=0A=20=09=09=20= =20=20=20setup_xfail=20"*-*-*"=0A=20=09=09}=0A+=09=09if=20{=20$needsULP=20= }=20{=0A+=09=09=20=20=20=20set=20function_name=20"_$function_name"=0A+=09= =09}=0A=20=09=09set=20testname=20"$testcase=20check-function-bodies=20= $function_name"=0A=20=09=09if=20{=20!$have_bodies=20}=20{=0A=20=09=09=20=20= =20=20unresolved=20$testname=0A--=20=0A2.39.2=20(Apple=20Git-143)=0A=0A= --Apple-Mail=_EE23F47A-6863-4A79-923E-130531DF0C40 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_EE23F47A-6863-4A79-923E-130531DF0C40--