[PATCH] binutils: testsuite: Fix add2line test cases on Windows.
Jan Dubiec
jdx@o2.pl
Sun Sep 13 16:36:47 GMT 2026
The following two test cases fail on Windows:
[...]
Running /d/Works/binutils/binutils/testsuite/binutils-all/addr2line.exp ...
FAIL: addr2line
FAIL: addr2line -f option
[...]
There are two problems:
1. All targets: On Windows, nm uses DOS/Windows-style paths (i.e. paths
beginning with a drive letter and a colon), whereas the test suite uses
UNIX-style paths. This causes the test cases to fail.
2. H8/300 and probably a few other targets (e.g. CIRS?): gcc prepends
an underscore to symbol names, so this needs to be taken into account.
This patch fixes both issues.
Signed-off-by: Jan Dubiec <jdx@o2.pl>
---
binutils/testsuite/binutils-all/addr2line.exp | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/binutils-all/addr2line.exp
index cc3c851a15b..09722dd406b 100644
--- a/binutils/testsuite/binutils-all/addr2line.exp
+++ b/binutils/testsuite/binutils-all/addr2line.exp
@@ -19,6 +19,14 @@ set opts ""
set dot ""
set exe [exeext]
+# If the host is Windows/MSYS, replace the leading /X with a regular expression
+# that matches a DOS/Windows drive letter, e.g change /x/y/foo/bar to
+# [a-zA-Z]:/y/foo/bar.
+set tmp_srcdir $srcdir
+if { [ishost *-*-mingw*] } {
+ set tmp_srcdir [regsub {^/[a-zA-Z]} $tmp_srcdir {[a-zA-Z]:}]
+}
+
# powerpc64 function symbols are on descriptors rather than code.
# MUSL uses the ELFv2 ABI for PowerPC, so the problem does not apply there.
if { [istarget powerpc64-*-*] && ![istarget powerpc64-*-musl] } {
@@ -26,6 +34,12 @@ if { [istarget powerpc64-*-*] && ![istarget powerpc64-*-musl] } {
set dot {\.}
}
+# Bare metal gcc for H8/300 prepends an underscore to symbol names.
+# Note that h8300-linux-gnu-gcc does not do this.
+if { [istarget h8300-*-elf] } {
+ set dot {_}
+}
+
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
verbose "Unable to compile test file."
untested "$testname"
@@ -40,7 +54,7 @@ if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}main" $output contents] then
} else {
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\]+"
+ set want "$tmp_srcdir/$subdir/testprog.c:\[0-9\]+"
if ![regexp $want $got] then {
fail "$testname $got\n"
} else {
@@ -55,7 +69,7 @@ if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}fn" $output contents] then {
} else {
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\]+"
+ set want "fn\n$tmp_srcdir/$subdir/testprog.c:\[0-9\]+"
if ![regexp $want $got] then {
fail "$testname -f option $got\n"
} else {
--
2.55.0
More information about the Binutils
mailing list