public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Fix addr2line test for ppc64 elfv1 and mingw
@ 2022-10-19 11:55 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-10-19 11:55 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2b06e59de0675c2cb526af2de6803dae29703d15

commit 2b06e59de0675c2cb526af2de6803dae29703d15
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Oct 19 18:52:43 2022 +1030

    Fix addr2line test for ppc64 elfv1 and mingw
    
            * 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:
---
 binutils/testsuite/binutils-all/addr2line.exp | 66 ++++++++++++++++-----------
 1 file changed, 39 insertions(+), 27 deletions(-)

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"
+    }
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-19 11:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 11:55 [binutils-gdb] Fix addr2line test for ppc64 elfv1 and mingw Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).