[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.
This commit is contained in:
Tom de Vries
2025-12-04 10:29:52 +01:00
parent bfaa4d5816
commit b52c9bb892
2 changed files with 11 additions and 2 deletions

View 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

View 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.