aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2025-08-06 15:28:19 -0400
committerSimon Marchi <simon.marchi@efficios.com>2025-08-27 15:57:29 -0400
commit99c85f05b6e92ffd5d53e72b63d84d2c2b40df5c (patch)
tree803b028ecfca0b3157ab9167041573a3f8bc5512
parentbce590b465775329c817297ed670654e6e7cc476 (diff)
downloadbinutils-99c85f05b6e92ffd5d53e72b63d84d2c2b40df5c.zip
binutils-99c85f05b6e92ffd5d53e72b63d84d2c2b40df5c.tar.gz
binutils-99c85f05b6e92ffd5d53e72b63d84d2c2b40df5c.tar.bz2
gdb/testsuite: get real executable in gdb.gdb/index-file.exp
Similar to a previous patch, if the gdb executable is in fact a libtool wrapper, we need to get the path to the real executable to load it in the top-level gdb. With this change, the test runs on Cygwin, although I do see two failures: FAIL: gdb.gdb/index-file.exp: debug_names files are identical FAIL: gdb.gdb/index-file.exp: debug_str files are identical Change-Id: Ie06d1ece67e61530e5b664e65b5ef0edccaf6afa Reviewed-By: Keith Seitz <keiths@redhat.com>
-rw-r--r--gdb/testsuite/gdb.gdb/index-file.exp7
-rw-r--r--gdb/testsuite/lib/selftest-support.exp46
2 files changed, 44 insertions, 9 deletions
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
index 2252b79..a9af211 100644
--- a/gdb/testsuite/gdb.gdb/index-file.exp
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
@@ -30,6 +30,13 @@ if { $filename eq "" } {
return -1
}
+# If FILENAME is a libtool wrapper, then we need to get the path of the real
+# executable.
+set filename [selftest_libtool_get_real_gdb_executable $filename]
+if { $filename eq "" } {
+ return -1
+}
+
with_timeout_factor $timeout_factor {
# Start GDB, load FILENAME.
clean_restart $filename
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index 0ab10f2..af8ec6f 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -52,6 +52,37 @@ proc _selftest_has_libtool {} {
return [expr {$status == 0}]
}
+# If GDB is executed from a build tree, run libtool to obtain the real
+# executable path for EXECUTABLE, which may be a libtool wrapper. Return
+# the path on success. On failure, issue an UNTESTED test result and return
+# an empty string.
+#
+# If GDB is executed from an installed location, return EXECUTABLE unchanged.
+#
+# If libtool is not present on the host system, return EXECUTABLE unchanged.
+# The test might still work, because the GDB binary is not always a libtool
+# wrapper.
+
+proc selftest_libtool_get_real_gdb_executable { executable } {
+ if [_selftest_gdb_is_installed] {
+ return $executable
+ }
+
+ if ![_selftest_has_libtool] {
+ return $executable
+ }
+
+ lassign [remote_exec host libtool "--mode=execute echo -n $executable"] \
+ status executable
+
+ if { $status != 0 } {
+ untested "failed to run libtool"
+ return ""
+ }
+
+ return $executable
+}
+
# Return true if EXECUTABLE has debug info.
#
# If it doesn't, or if it's not possible to determine, issue an UNTESTED test
@@ -73,15 +104,12 @@ proc _selftest_check_executable_debug_info { executable } {
#
# If testing against an installed GDB, then there won't be a libtool
# wrapper, no need to convert.
- if { ![_selftest_gdb_is_installed] && [_selftest_has_libtool] } {
- lassign [remote_exec host libtool \
- "--mode=execute echo -n $executable"] \
- status executable
-
- if { $status != 0 } {
- untested "failed to run libtool"
- return false
- }
+ set executable [selftest_libtool_get_real_gdb_executable $executable]
+
+ if { $executable == "" } {
+ # selftest_libtool_get_real_gdb_executable already records an UNTESTED
+ # on failure.
+ return false
}
gdb_start