]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: get real executable in gdb.gdb/index-file.exp
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 6 Aug 2025 19:28:19 +0000 (15:28 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 27 Aug 2025 19:57:29 +0000 (15:57 -0400)
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>
gdb/testsuite/gdb.gdb/index-file.exp
gdb/testsuite/lib/selftest-support.exp

index 2252b79d162c729f2f293320d5506f6ab7852f4a..a9af21181436fef26969705a0f950976e8e01057 100644 (file)
@@ -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
index 0ab10f2e180a5e02f23859077c4e3659ac81f8de..af8ec6fb9820e5cf99d78533c4ebe9f021292401 100644 (file)
@@ -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