gdb/testsuite: Use _inferior_thread_count in gdb.threads/threadcrash.exp

A linaro PR [1] reports that the gdb.threads/threadcrash.exp test-case fails
to cout the number of threads in the inferior:
...
FAIL: gdb.threads/threadcrash.exp: test_gcore: $thread_count == 7
FAIL: gdb.threads/threadcrash.exp: test_gcore: $thread_count == [llength $test_list]
...

Fix this by getting the convenience variable _inferior_thread_count as opposed
to calculating it based on the output of "info threads".

Tested on arm-linux and x86_64-linux.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Approved-By: Tom de Vries <tdevries@suse.de>

[1] https://linaro.atlassian.net/browse/GNU-1120
This commit is contained in:
Guinevere Larsen
2024-03-11 10:57:31 +01:00
committed by Tom de Vries
parent 72ab7ac8be
commit b95b92ec09

View File

@@ -20,26 +20,6 @@
# a gcore.
# Check that the inferior has 7 threads, and return the number of threads (7).
# We return the thread count so that, even if there is some error in the test,
# the final log doesn't get flooded with failures.
proc test_thread_count {} {
set thread_count 0
gdb_test_multiple "info threads" "getting thread count" -lbl {
-re "Thread" {
incr thread_count
exp_continue
}
-re "$::gdb_prompt " {
gdb_assert {$thread_count == 7}
}
}
return $thread_count
}
# 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
@@ -132,7 +112,8 @@ proc thread_apply_all {} {
proc do_full_test {} {
global test_list
set thread_count [test_thread_count]
set thread_count [get_valueof "" "\$_inferior_thread_count" 0]
gdb_assert {$thread_count == 7}
thread_apply_all