From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 32AAB3858C42; Wed, 22 Nov 2023 14:50:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32AAB3858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700664641; bh=lQ4V4pMV7Fp51QahSZlTKdIL9lo4g9GefizoK60jdgg=; h=From:To:Subject:Date:From; b=x+UXTi/0F7VuxzIJcFe6sfOtRbVAk53XnZx5Lh/gR6/IfJKsWWl2I8bZV/qeZjn+u WEgZ2F5aC5BQBoCX+9LjN+Ko+Coxlpk7lLIU76c5uCNaACz5WoxVPnCMXSXBkM8Prp U6F7ZYDpdZfiBys+ujcn8w5jAo/gcaj/g8qVXPsk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-5760] testsuite, Darwin: Add support for Mach-O function body scans. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: 6bf66276e3e41d5d92f7b7260e98b6a111653805 X-Git-Newrev: 2a46e0e7e20e6e9095708704ac0180859e258b7d Message-Id: <20231122145041.32AAB3858C42@sourceware.org> Date: Wed, 22 Nov 2023 14:50:41 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2a46e0e7e20e6e9095708704ac0180859e258b7d commit r14-5760-g2a46e0e7e20e6e9095708704ac0180859e258b7d Author: Iain Sandoe Date: Thu Oct 26 09:52:04 2023 +0100 testsuite, Darwin: Add support for Mach-O function body scans. We need to process the source slightly differently from ELF, especially in that we have __USER_LABEL_PREFIX__ and there are no function start and end assembler directives. This means we cannot delineate functions when frame output is switched off. TODO: consider adding -mtest-markers or something similar to inject assembler comments that can be scanned for. gcc/testsuite/ChangeLog: * lib/scanasm.exp: Initial handling for Mach-O function body scans. Signed-off-by: Iain Sandoe Co-authored-by: Richard Sandiford Diff: --- gcc/testsuite/lib/scanasm.exp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 16b5198d38b..85ee54ff9a8 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -804,23 +804,34 @@ proc configure_check-function-bodies { config } { # 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+):$}} } # 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} } - + # 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 @@ -852,9 +863,19 @@ proc parse_function_bodies { config filename result } { set fd [open $filename r] set in_function 0 while { [gets $fd line] >= 0 } { - if { [regexp $up_config(start) $line dummy function_name] } { - set in_function 1 - set function_body "" + if { $in_function == 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" @@ -957,7 +978,6 @@ proc check-function-bodies { args } { set start_expected {^(\S+):$} configure_check-function-bodies config - set have_bodies 0 if { [is_remote host] } { remote_upload host "$filename"