public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Handle core without build-id in gdb.base/corefile-buildid.exp
@ 2024-03-19  7:38 Tom de Vries
  2024-03-20 17:17 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2024-03-19  7:38 UTC (permalink / raw)
  To: gdb-patches

On aarch64-linux (debian 12), when running test-case gdb.base/corefile-buildid.exp, I get:
...
expecting exec file "debugdir-exec/.build-id/ec/f10ec5d39648774f8c35d3cf757c8db52f5163"
info files^M
Local core dump file:^M
        `build-exec/corefile-buildid.core', file type elf64-littleaarch64.^M
        0x0000aaaac1d70000 - 0x0000aaaac1d71000 is load1^M
	...
        0x0000ffffffa8b000 - 0x0000ffffffaac000 is load16^M
(gdb) FAIL: gdb.base/corefile-buildid.exp: exec: info files
...

The problem is that the test-case expect the build-id to be available in the
core file, while it isn't.

Fix this by detecting that the build-id isn't available in the core file using eu-readelf, as in
gdb.base/coredump-filter-build-id.exp.

Tested on aarch64-linux.
---
 gdb/testsuite/gdb.base/corefile-buildid.exp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/corefile-buildid.exp b/gdb/testsuite/gdb.base/corefile-buildid.exp
index f9c85a8642d..130198611ec 100644
--- a/gdb/testsuite/gdb.base/corefile-buildid.exp
+++ b/gdb/testsuite/gdb.base/corefile-buildid.exp
@@ -217,7 +217,7 @@ proc locate_exec_from_core_build_id {corefile buildid suffix \
 # of shared and/or stripped/.debug executables.
 
 proc do_corefile_buildid_tests {args} {
-    global binfile testfile srcfile execdir sharedir
+    global binfile testfile srcfile execdir sharedir hex
 
     # Parse options.
     parse_args [list {sepdebug} {shared}]
@@ -266,6 +266,18 @@ proc do_corefile_buildid_tests {args} {
 	}
 	verbose -log "corefile is $corefile"
 
+	if { [catch "exec [gdb_find_eu-unstrip] -n --core $corefile" output] == 0 } {
+	    set line [lindex [split $output "\n"] 0]
+	    set binfile_re (?:[string_to_regexp $program_to_run]|\\\[(?:exe|pie)\\\])
+	    if { ![regexp "^${hex}\\+${hex} \[a-f0-9\]+@${hex}.*$binfile_re$" $line] } {
+		unsupported "build id for exec"
+		return
+	    }
+	} else {
+	    unsupported "eu-unstrip execution"
+	    return
+	}
+
 	# Grab the build-id from the binary, removing ".debug" from the end.
 	set buildid [build_id_debug_filename_get $program_to_run]
 	if {$buildid == ""} {

base-commit: bb1684fbea382f81c71dee4f7a32ecb51a1deab4
-- 
2.35.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [gdb/testsuite] Handle core without build-id in gdb.base/corefile-buildid.exp
  2024-03-19  7:38 [PATCH] [gdb/testsuite] Handle core without build-id in gdb.base/corefile-buildid.exp Tom de Vries
@ 2024-03-20 17:17 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2024-03-20 17:17 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> The problem is that the test-case expect the build-id to be available in the
Tom> core file, while it isn't.

Tom> Fix this by detecting that the build-id isn't available in the core file using eu-readelf, as in
Tom> gdb.base/coredump-filter-build-id.exp.

I was kind of surprised to find that gdb's test suite depends on a
non-binutils program like this, but whatever, the dependency is already
there.

Anyway this seems fine to me.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-20 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19  7:38 [PATCH] [gdb/testsuite] Handle core without build-id in gdb.base/corefile-buildid.exp Tom de Vries
2024-03-20 17:17 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).