From: Simon Marchi Date: Wed, 6 Aug 2025 19:28:19 +0000 (-0400) Subject: gdb/testsuite: get real executable in gdb.gdb/index-file.exp X-Git-Tag: gdb-17-branchpoint~151 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99c85f05b6e92ffd5d53e72b63d84d2c2b40df5c;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp index 2252b79d162..a9af2118143 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 0ab10f2e180..af8ec6fb982 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