aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-01-11 11:44:00 +0100
committerTom de Vries <tdevries@suse.de>2023-01-11 11:44:00 +0100
commitf1e19328594fb0cc35dc7d6573a7a36f5ab9ecc4 (patch)
tree2ea75544a9ad053bb36c3f9e574b7fc618078614 /gdb/testsuite
parentf56532cc17868e2c7e765bfd78322157048ff6ec (diff)
downloadfsf-binutils-gdb-f1e19328594fb0cc35dc7d6573a7a36f5ab9ecc4.zip
fsf-binutils-gdb-f1e19328594fb0cc35dc7d6573a7a36f5ab9ecc4.tar.gz
fsf-binutils-gdb-f1e19328594fb0cc35dc7d6573a7a36f5ab9ecc4.tar.bz2
[gdb/testsuite] Fix gdb.threads/dlopen-libpthread.exp for upstream glibc, again
On an x86_64 laptop running ubuntu 22.04.1 with unity desktop: ... $ echo $XDG_CURRENT_DESKTOP Unity:Unity7:ubuntu ... I have: ... $ echo $LD_PRELOAD libgtk3-nocsd.so.0 ... due to package gtk3-nocsd, a package recommended by unity-session. Consequently, for each exec these dependencies are pulled in, including libpthread.so.0: ... $ lddtree /lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 libgtk3-nocsd.so.0 => /lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (interpreter => none) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 ld-linux-x86-64.so.2 => /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ... So, while test-case gdb.threads/dlopen-libpthread.exp appears to run ok: ... # of expected passes 12 # of unsupported tests 1 ... with LD_PRELOAD="" we have instead: ... (gdb) PASS: gdb.threads/dlopen-libpthread.exp: continue to breakpoint: notify info sharedlibrary^M From To Syms Read Shared Object Library^M $hex $hex Yes /lib64/ld-linux-x86-64.so.2^M $hex $hex Yes /lib/x86_64-linux-gnu/libc.so.6^M $hex $hex Yes dlopen-libpthread.so^M (gdb) FAIL: gdb.threads/dlopen-libpthread.exp: libpthread.so found ... The problem is that libpthread is expected as dependency of dlopen-libpthread.so, but it's missing: ... $ lddtree dlopen-libpthread.so dlopen-libpthread.so => ./dlopen-libpthread.so (interpreter => none) libc.so.6 => $outputs/gdb.threads/dlopen-libpthread/dlopen-libpthread.so.d/libc.so.6 ld-linux-x86-64.so.2 => /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ... due to having glibc 2.35, which has libpthread integrated into libc. Fix this by: - adding a proc has_dependency - using [has_dependency $exec libpthread.so] as hint that libpthread may be preloaded - using ![has_dependency $shlib libpthread.so] to detect that the libpthread.so dependency is missing. Also add a missing return after untested "no matching probes". Tested on x86_64-linux, with and without LD_PRELOAD="".
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.threads/dlopen-libpthread.exp30
-rw-r--r--gdb/testsuite/lib/gdb.exp17
2 files changed, 41 insertions, 6 deletions
diff --git a/gdb/testsuite/gdb.threads/dlopen-libpthread.exp b/gdb/testsuite/gdb.threads/dlopen-libpthread.exp
index 0b325ce..134265f 100644
--- a/gdb/testsuite/gdb.threads/dlopen-libpthread.exp
+++ b/gdb/testsuite/gdb.threads/dlopen-libpthread.exp
@@ -61,16 +61,32 @@ foreach probe_name $probe_names {
if { !$have_probe } {
untested "no matching probes"
+ return -1
+}
+
+# We link the exec without -lpthread, but libpthread.so may already be loaded at main
+# due to LD_PRELOAD.
+set libpthread_maybe_preloaded 0
+set binfile [standard_output_file $executable]
+if { [has_dependency $binfile libpthread\\.so] == 1 } {
+ set libpthread_maybe_preloaded 1
+}
+
+# We link the shlib with -lpthread, but since glibc 2.34 libpthread has been
+# merged with libc, so libpthread.so may not be a dependency.
+set libpthread_missing 0
+if { [has_dependency $binfile_lib libpthread\\.so] == 0 } {
+ set libpthread_missing 1
}
set test "libpthread.so not found"
gdb_test_multiple "info sharedlibrary" $test {
-re "/libpthread\\.so.*\r\n$gdb_prompt $" {
- # With newer glibc, libpthread has been integrated into glibc so we
- # can expect it to be already loaded at main. This means we no longer
- # excercise the scenario we're trying to trigger, but continue
- # nevertheless.
- unsupported $test
+ if { $libpthread_maybe_preloaded } {
+ unsupported $test
+ } else {
+ fail $test
+ }
}
-re "/libc\\.so.*\r\n$gdb_prompt $" {
pass $test
@@ -85,4 +101,6 @@ gdb_breakpoint "notify"
# Cannot find new threads: generic error
gdb_continue_to_breakpoint "notify" ".* notify-here .*"
-gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found"
+if { !$libpthread_missing } {
+ gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found"
+}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index c41d469..39dfa67 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9355,5 +9355,22 @@ proc decompress_bz2 { bz2 } {
return $copy
}
+# Return 1 if the output of "ldd FILE" contains regexp DEP, 0 if it doesn't,
+# and -1 if there was a problem running the command.
+
+proc has_dependency { file dep } {
+ set ldd [gdb_find_ldd]
+ set command "$ldd $file"
+ set result [remote_exec host $command]
+ set status [lindex $result 0]
+ set output [lindex $result 1]
+ verbose -log "status of $command is $status"
+ verbose -log "output of $command is $output"
+ if { $status != 0 || $output == "" } {
+ return -1
+ }
+ return [regexp $dep $output]
+}
+
# Always load compatibility stuff.
load_lib future.exp