]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix build-id check in gdb.python/py-missing-objfile.exp
authorTom de Vries <tdevries@suse.de>
Thu, 4 Dec 2025 09:29:52 +0000 (10:29 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 4 Dec 2025 09:29:52 +0000 (10:29 +0100)
I recently added two requires in test-case gdb.python/py-missing-objfile.exp:
...
# The following tests assume that the build-ids of binfile and libfile can be
# found in the core file.
require {expect_build_id_in_core_file $binfile}
require {expect_build_id_in_core_file $libfile}
...

However, at the point where the check is done, the files are no longer
available at that location, which makes the require fail.

First, make the problem visible, by making proc expect_build_id_in_core_file
throw an error if the filename argument specifies a non-existing file.

Then, fix test-case gdb.python/py-missing-objfile.exp by moving the calls to
expect_build_id_in_core_file to a point where the files exist.

Tested on x86_64-linux.

gdb/testsuite/gdb.python/py-missing-objfile.exp
gdb/testsuite/lib/gdb.exp

index 9f1f9eb377ce661e1a31bca9a4d5f4e692adbfd4..2f54f618cf0b5580e18f8cd5881e12d77a93cfd5 100644 (file)
@@ -34,6 +34,11 @@ if { [build_executable "build exec" $binfile $srcfile $opts] == -1} {
     return
 }
 
+set expect_build_id_in_core_file_binfile \
+    [expect_build_id_in_core_file $binfile]
+set expect_build_id_in_core_file_libfile \
+    [expect_build_id_in_core_file $libfile]
+
 # The cc-with-gnu-debuglink board will split the debug out into the
 # .debug directory.  This test script relies on having GDB lookup the
 # objfile and debug via the build-id, which this test sets up.  Trying
@@ -185,8 +190,8 @@ with_test_prefix "no objfiles available" {
 
 # The following tests assume that the build-ids of binfile and libfile can be
 # found in the core file.
-require {expect_build_id_in_core_file $binfile}
-require {expect_build_id_in_core_file $libfile}
+require {expr $expect_build_id_in_core_file_binfile}
+require {expr $expect_build_id_in_core_file_libfile}
 
 with_test_prefix "all objfiles available" {
     # Another sanity check that GDB can find the files via the
index b502e0c7de3c7211378741da477bc68e1eebabf6..8dc03231a104bef105f1a786fd6a465189d7195e 100644 (file)
@@ -11677,6 +11677,10 @@ proc section_get {exec section} {
 # Otherwise, return false.
 
 proc expect_build_id_in_core_file { filename } {
+    if {![file exists $filename]} {
+       error "File not found: $filename"
+    }
+
     # I'm not sure if other kernels take care to add the first page of
     # each ELF into the core file.  If they do then this test can be
     # relaxed.