aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuinevere Larsen <blarsen@redhat.com>2024-03-11 10:57:32 +0100
committerTom de Vries <tdevries@suse.de>2024-03-11 10:57:32 +0100
commitf215d2d8ad7bc1f80e68a962196f0e6dc02951c9 (patch)
tree1078492d15b188b1a67fc436d9b3be0b36956a28
parent623840fc07dd8f3b21276d018d442cdf60292e73 (diff)
downloadgdb-f215d2d8ad7bc1f80e68a962196f0e6dc02951c9.zip
gdb-f215d2d8ad7bc1f80e68a962196f0e6dc02951c9.tar.gz
gdb-f215d2d8ad7bc1f80e68a962196f0e6dc02951c9.tar.bz2
gdb/testsuite: Reduce gdb.threads/threadcrash.exp reliance on libc symbols
The test gdb.threads/threadcrash.exp demanded GDB to fully unwind and print the names of all functions. However, some of the functions are from the libc library, and so the test implicitly demanded libc symbols to be available, and would fail otherwise, as was raised in PR gdb/31293. This commit changes it so we only explicitly check for functions that are not provided by threadcrash.c if they are indeed available. Tested on arm-linux and x86_64-linux. Approved-By: Tom de Vries <tdevries@suse.de> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31293
-rw-r--r--gdb/testsuite/gdb.threads/threadcrash.exp48
1 files changed, 41 insertions, 7 deletions
diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp
index 16fd7eb..c72ce73 100644
--- a/gdb/testsuite/gdb.threads/threadcrash.exp
+++ b/gdb/testsuite/gdb.threads/threadcrash.exp
@@ -20,6 +20,9 @@
# a gcore.
+set have_sleep -1
+set have_pthread_kill -1
+
# Use 'thread apply all backtrace' to check if all expected threads
# are present, and stopped in the expected locations. Set the global
# TEST_LIST to be the a list of regexps expected to match all the
@@ -27,6 +30,8 @@
# GDB sees the threads.
proc thread_apply_all {} {
+ global have_sleep
+ global have_pthread_kill
global test_list
set test_list { }
@@ -73,6 +78,14 @@ proc thread_apply_all {} {
lappend test_list 7
exp_continue
}
+ -re "^\r\n${hs} in sleep $hs$eol" {
+ set have_sleep 1
+ exp_continue
+ }
+ -re "^\r\n${hs} in pthread_kill $hs$eol" {
+ set have_pthread_kill 1
+ exp_continue
+ }
-re "^\r\n$hs$eol" {
exp_continue
}
@@ -82,6 +95,13 @@ proc thread_apply_all {} {
}
gdb_assert {$unwind_fail == false}
+
+ if { $have_sleep == -1 } {
+ set have_sleep 0
+ }
+ if { $have_pthread_kill == -1 } {
+ set have_pthread_kill 0
+ }
}
# Perform all the tests we're interested in. They are:
@@ -90,6 +110,8 @@ proc thread_apply_all {} {
# * testing if GDB recreated the full backtrace we expect for all threads
proc do_full_test {} {
+ global have_sleep
+ global have_pthread_kill
global test_list
set thread_count [get_valueof "" "\$_inferior_thread_count" 0]
gdb_assert {$thread_count == 7}
@@ -98,6 +120,18 @@ proc do_full_test {} {
gdb_assert {$thread_count == [llength $test_list]}
+ if { $have_sleep } {
+ set sleep ".*sleep.*"
+ } else {
+ set sleep ".*"
+ }
+
+ if { $have_pthread_kill } {
+ set pthread_kill ".*pthread_kill.*"
+ } else {
+ set pthread_kill ".*"
+ }
+
for {set i 0} {$i < $thread_count } {incr i} {
set thread_num [expr [llength $test_list] - $i]
@@ -105,25 +139,25 @@ proc do_full_test {} {
if { $type == 1 } {
set re \
[multi_line \
- ".sleep.*" \
+ $sleep \
".*do_syscall_task .location=SIGNAL_ALT_STACK.*" \
".*signal_handler.*" \
".*signal handler called.*" \
- ".*pthread_kill.*" \
+ $pthread_kill \
".*thread_function.*"]
} elseif { $type == 2 } {
set re \
[multi_line \
- ".*sleep.*" \
+ $sleep \
".*do_syscall_task .location=SIGNAL_HANDLER.*" \
".*signal_handler.*" \
".*signal handler called.*" \
- ".*pthread_kill.*" \
+ $pthread_kill \
".*thread_function.*"]
} elseif { $type == 3 } {
set re \
[multi_line \
- ".*sleep.*" \
+ $sleep \
".*do_syscall_task .location=NORMAL.*" \
".*thread_function.*"]
} elseif { $type == 4 } {
@@ -132,7 +166,7 @@ proc do_full_test {} {
".*do_spin_task .location=SIGNAL_ALT_STACK.*" \
".*signal_handler.*" \
".*signal handler called.*" \
- ".*pthread_kill.*" \
+ $pthread_kill \
".*thread_function.*"]
} elseif { $type == 5 } {
set re \
@@ -140,7 +174,7 @@ proc do_full_test {} {
".*do_spin_task .location=SIGNAL_HANDLER.*" \
".*signal_handler.*" \
".*signal handler called.*" \
- ".*pthread_kill.*" \
+ $pthread_kill \
".*thread_function.*"]
} elseif { $type == 6 } {
set re \