From: Tom de Vries Date: Thu, 4 Dec 2025 09:29:52 +0000 (+0100) Subject: [gdb/testsuite] Fix build-id check in gdb.python/py-missing-objfile.exp X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b52c9bb8929a0f7010e2cec5cc16562d01a84de3;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Fix build-id check in gdb.python/py-missing-objfile.exp 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. --- diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.exp b/gdb/testsuite/gdb.python/py-missing-objfile.exp index 9f1f9eb377c..2f54f618cf0 100644 --- a/gdb/testsuite/gdb.python/py-missing-objfile.exp +++ b/gdb/testsuite/gdb.python/py-missing-objfile.exp @@ -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 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index b502e0c7de3..8dc03231a10 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -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.