]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/testsuite: use libtool to launch selftests
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 27 Aug 2025 19:55:45 +0000 (15:55 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 27 Aug 2025 19:57:29 +0000 (15:57 -0400)
commitd6340aa42e2573297c93fe86d27b28ae0de0ecb0
tree83713dc390b976e1182e54e11adede59c1ec5014
parent15b3c1756339dfc00c61a8ad1390222ce4bbca4f
gdb/testsuite: use libtool to launch selftests

When building GDB on Cygwin, gdb/gdb.exe is a libtool wrapper (which
happens to be a PE executable).  The real executable is at
gdb/.libs/gdb.exe.  The "does gdb have debug info test" that
_selftest_setup does is bogus, because it loads the libtool wrapper
(which doesn't have debug info), doesn't see any debug info, and thus
the test is skipped.

The "correct" way to deal with libtool wrappers is to run the shell
command you want to run under `libtool --mode=execute`.  That will
replace any path resembling to a libtool wrapper with the real
executable path.  But it will also add to the environment the library
paths necessary for this executable to find the libraries it needs.

Therefore, modify the `do_self_tests` proc to:

  - run the top-level GDB commands under `libtool --mode=execute`
  - pass the path to the inferior GDB on the command-line of the
    top-level, so that it gets replaced with the real executable's path

However, the "file" command was previously used to detect the presence
of debug info in the GDB executable.  It's not easy to implement this
check when loading the executable directly on the command line. So, add
a separate proc, _selftest_check_executable_debug_info, that spawns a
temporary GDB and does the debug info check through the file command.
This proc uses libtool to obtain the path to the real executable.

When building, we use the bundled libtool.m4 at the top of the tree.
This means that the libtool system package, and therefore the libtool
binary, might not be available.  Check for the presence of the libtool
binary first, and only do the conversion if it is found.  If it is not
found, the test should still work on platforms that don't require the
conversion.

With this commit, the test runs on Cygwin, even though there are
failures later.

Change-Id: Ie7b712cdc84671a5a017655a7e41687ff23f906c
Reviewed-By: Keith Seitz <keiths@redhat.com>
gdb/testsuite/lib/selftest-support.exp