}
set any "\[^\r\n\]*"
gdb_test_multiple "info threads" "collect thread id" {
- -re ". ($decimal).$decimal (Thread ${any}) \"threadname_\[0-9\]+\" $any" {
+ -re ". ($decimal).$decimal (${tdlabel_re} ${any}) \"threadname_\[0-9\]+\" $any" {
set thr_num $expect_out(1,string)
set target_id($thr_num) $expect_out(2,string)
exp_continue
# reported in the "Id" column.
gdb_test "info threads" \
- {.*[\r\n]+\* +([0-9]+) +Thread[^\r\n]* do_something \(n=\1\) at.*}
+ [format {.*[\r\n]+\* +([0-9]+) +%s[^\r\n]* do_something \(n=\1\) at.*} $tdlabel_re]
# Check for expected results when passing a valid thread handle to
# thread_from_handle().
# There should be only one thread listed at this point.
gdb_test_multiple "info threads" "" {
- -re "2 Thread.*$gdb_prompt $" {
+ -re "2 ${tdlabel_re}.*$gdb_prompt $" {
fail $gdb_test_name
}
-re "has terminated.*$gdb_prompt $" {
fail $gdb_test_name
}
- -re "\\\* 1\[\t \]*Thread\[^\r\n\]*\r\n$gdb_prompt $" {
+ -re "\\\* 1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n$gdb_prompt $" {
pass $gdb_test_name
}
}
# There should be two threads at this point with thread 1 selected.
gdb_test "info threads" \
- "\\\* 1\[\t \]*Thread\[^\r\n\]*\r\n 2\[\t \]*Thread\[^\r\n\]*" \
+ "\\\* 1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n 2\[\t \]*${tdlabel_re}\[^\r\n\]*" \
"second thread should now exist"
# Switch threads.
# Check that thread 2 is still selected.
gdb_test "info threads" \
- " 1\[\t \]*Thread\[^\r\n\]*\r\n\\\* 2\[\t \]*Thread\[^\r\n\]*" \
+ " 1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n\\\* 2\[\t \]*${tdlabel_re}\[^\r\n\]*" \
"second thread should still be selected after stepi"
# Turn scheduler locking off again so that when we continue all
gdb_test "continue" ".*breakpoint here.*" "continue to exec"
-gdb_test "info threads" "1 *Thread.*2 *Thread.*3 *Thread.*" "info threads before exec"
+gdb_test "info threads" "1 *${tdlabel_re}.*2 *${tdlabel_re}.*3 *${tdlabel_re}.*" "info threads before exec"
# Work around PR25656, where the breakpoint above sets 2 breakpoint locations:
# - one on gdb.threads/execl.c:$linenumber, and
"continue across exec"
gdb_test_multiple "info threads" "info threads after exec" {
- -re "2 *Thread .*$gdb_prompt $" {
+ -re "2 *${tdlabel_re} .*$gdb_prompt $" {
# Old threads left behind.
fail "$gdb_test_name"
}
- -re "4 *Thread .*$gdb_prompt $" {
+ -re "4 *${tdlabel_re} .*$gdb_prompt $" {
# New threads registered.
fail "$gdb_test_name"
}
# * 3 Thread 0x40a00950 (LWP 5553) start (arg=0x0) at ../.././gdb/testsuite/gdb.threads/fork-child-threads.c:28
# 2 Thread 0x2aaaaaac3000 (LWP 5552) 0x00000031674076dd in pthread_join (threadid=<optimized out>, thread_return=<optimized out>) at pthread_join.c:89
-gdb_test "info threads" " Thread .* Thread .*" "two threads found"
+gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .*" "two threads found"
gdb_test "continue" "Catchpoint.*" "1, get to the fork event"
-gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "1, multiple threads found"
+gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "1, multiple threads found"
gdb_test "thread 1" ".*" "1, switched away from event thread"
set test "1, followed to the child, found one thread"
gdb_test_multiple "info threads" "metest" {
- -re " Thread .* Thread .*$gdb_prompt $" {
+ -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
fail "$test"
}
- -re " Thread .*$gdb_prompt $" {
+ -re " ${tdlabel_re} .*$gdb_prompt $" {
pass "$test"
}
-re "$gdb_prompt $" {
set test "1, followed to the child, found two threads"
gdb_test_multiple "info threads" "$test" {
- -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
+ -re " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
fail "$test"
}
- -re " Thread .* Thread .*$gdb_prompt $" {
+ -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
pass "$test"
}
-re "$gdb_prompt $" {
gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
-gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "2, multiple threads found"
+gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "2, multiple threads found"
gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
set test "2, followed to the child, found two threads"
gdb_test_multiple "info threads" "$test" {
- -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
+ -re " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
fail "$test"
}
- -re " Thread .* Thread .*$gdb_prompt $" {
+ -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
pass "$test"
}
-re "$gdb_prompt $" {
gdb_test "info threads" \
[multi_line \
"\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*" \
- " 1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
- "\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*"] \
+ " 1 *${tdlabel_re} \[^\r\n\]* .* \[^\r\n\]*" \
+ "\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*"] \
"info threads before break"
# Check that "break" is still operating on the same file by default.
gdb_test "info threads" \
[multi_line \
"\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*" \
- " 1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
- "\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*"] \
+ " 1 *${tdlabel_re} \[^\r\n\]* .* \[^\r\n\]*" \
+ "\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*"] \
"info threads before list"
# And that so is "list".
global gdb_prompt
global NUM_THREADS
global decimal
+ global tdlabel_re
set saw_continuing 0
set test "continue -a &"
set running_count 0
set test "all threads are stopped"
return_if_nonzero [gdb_test_multiple "info threads" $test {
- -re "Thread \[^\r\n\]* \\(running\\)" {
+ -re "${tdlabel_re} \[^\r\n\]* \\(running\\)" {
incr running_count
exp_continue
}
gdb_continue_to_breakpoint "break-here" ".* break-here .*"
gdb_test "info threads" \
- "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
+ "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*" \
"single thread has been left"
# Test that ctrl-c works even if the leader has exited.
set cmd "info threads"
set ok 0
gdb_test_multiple $cmd $cmd {
- -re " 1 *Thread " {
+ -re " 1 *${tdlabel_re} " {
set ok 1
exp_continue
}
"continue stops when thread 2 exits"
gdb_test "info threads" \
- "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *Thread \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 2> has terminated.*" \
+ "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *${tdlabel_re} \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 2> has terminated.*" \
"only main thread left, thread 2 terminated"
# Select the main thread, let the third thread start, and stop at the
"continue stops when the main thread exits"
gdb_test "info threads" \
- "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *Thread \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 1> has terminated.*" \
+ "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *${tdlabel_re} \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 1> has terminated.*" \
"only thread 3 left, main thread terminated"
# Make sure thread apply all works when we have exited threads in the
proc do_test { lock_sched nonstop } {
global executable
+ global tdlabel_re
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop $nonstop\""
}
gdb_test "info threads" \
- "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
+ "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*" \
"single thread left"
# Also test with sched-lock to make sure we can follow the
global srcdir srcfile gdb_prompt expect_out
global horiz
global main_id thread1_id thread2_id
+ global tdlabel_re
# We should be able to do an info threads before starting any others.
set return_me 1
gdb_test_multiple "info threads" "info threads" {
- -re ".*Thread.*main.*$gdb_prompt $" {
+ -re ".*${tdlabel_re}.*main.*$gdb_prompt $" {
pass "info threads"
set return_me 0
}
# Extract the thread id number of main thread from "info threads" output.
gdb_test_multiple "info threads" "get main thread id" {
- -re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)" {
+ -re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}main.*)($gdb_prompt $)" {
}
}
# Extract the thread id number of thread 1 from "info threads" output.
gdb_test_multiple "info threads" "get thread 1 id" {
- -re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)" {
+ -re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}thread1.*)($gdb_prompt $)" {
}
}
# Extract the thread id number of thread 2 from "info threads" output.
gdb_test_multiple "info threads" "get thread 2 id" {
- -re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)" {
+ -re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}thread2.*)($gdb_prompt $)" {
}
}
# request a signal be delivered with the "signal" command.
proc test { step_over } {
- global srcfile binfile
+ global srcfile binfile tdlabel_re
with_test_prefix "step-over $step_over" {
clean_restart ${binfile}
gdb_test "thread 1" "Switching to thread 1.*"
- set pattern "\\\* 1\[ \t\]+Thread.*"
+ set pattern "\\\* 1\[ \t\]+${tdlabel_re}.*"
gdb_test "info threads" $pattern "thread 1 selected"
# scheduler-locking) of the test to perform.
proc test { schedlock } {
- global srcfile binfile
+ global srcfile binfile tdlabel_re
with_test_prefix "schedlock $schedlock" {
clean_restart ${binfile}
gdb_test "continue" "all_threads_signalled.*" \
"continue to all_threads signalled"
- gdb_test "info threads" "\\\* 1\[ \t\]+Thread.*" "thread 1 selected"
+ gdb_test "info threads" "\\\* 1\[ \t\]+${tdlabel_re}.*" "thread 1 selected"
# With schedlock still enabled, let each thread report its
# signal.
# with "signal 0" or "continue".
proc test { command } {
- global srcfile binfile
+ global srcfile binfile tdlabel_re
with_test_prefix "$command" {
clean_restart ${binfile}
gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1"
- set pattern "\\\* 2\[ \t\]+Thread.*"
+ set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
gdb_test "info threads" $pattern "thread 2 intercepted signal"
# SIGTRAP.
proc test { sigtrap_thread } {
- global srcfile binfile
+ global srcfile binfile tdlabel_re
with_test_prefix "sigtrap thread $sigtrap_thread" {
clean_restart ${binfile}
return 0
}
- set pattern "\\\* 2\[ \t\]+Thread.*"
+ set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
gdb_test "info threads" $pattern "thread 2 hit breakpoint"
gdb_test "break sigtrap_handler" "Breakpoint .* at .*$srcfile.*"
"Continuing with signal SIGTRAP.*Breakpoint .* sigtrap_handler .*" \
"signal SIGTRAP reaches handler"
- set pattern "\\\* $sigtrap_thread\[ \t\]+Thread.*"
+ set pattern "\\\* $sigtrap_thread\[ \t\]+${tdlabel_re}.*"
gdb_test "info threads" $pattern "right thread got the signal"
}
}
set test "info threads"
gdb_test_multiple "info threads" "$test" {
- -re " Thread .*$gdb_prompt " {
+ -re " ${tdlabel_re} .*$gdb_prompt " {
pass "$test"
}
-re "$gdb_prompt " {
proc get_thread_id {func} {
global gdb_prompt
+ global tdlabel_re
set thre -1
set test "get $func thread id"
gdb_test_multiple "info threads" $test {
- -re "(\[0-9\]+)\[^\n\r\]*Thread\[^\n\r\]*$func.*$gdb_prompt $" {
+ -re "(\[0-9\]+)\[^\n\r\]*${tdlabel_re}\[^\n\r\]*$func.*$gdb_prompt $" {
# Get the thread's id.
set thre $expect_out(1,string)
pass $test
proc get_thread_list { } {
global gdb_prompt
global expect_out
+ global tdlabel_re
set thr_list ""
-re "^ *Id *Target Id\[^\n\]*\n" {
exp_continue
}
- -re "^\\* *(\[0-9\]*) *Thread \[^\n\]*main\[^\n\]*\n" {
+ -re "^\\* *(\[0-9\]*) *${tdlabel_re} \[^\n\]*main\[^\n\]*\n" {
set thr_list "$expect_out(1,string) $thr_list"
exp_continue
}
- -re "^ *(\[0-9\]*) *Thread \[^\n\]*\n" {
+ -re "^ *(\[0-9\]*) *${tdlabel_re} \[^\n\]*\n" {
lappend thr_list $expect_out(1,string)
exp_continue
}
timeout { fail "continue to first thread (timeout)" }
}
-gdb_test "info thread" ".*Thread.*spin.*" \
+gdb_test "info thread" ".*${tdlabel_re}.*spin.*" \
"at least one th in spin while stopped at first th"
check_thread_local "first"
gdb_test "continue" ".*Breakpoint 2.*tls value.*" "continue to second thread"
-gdb_test "info thread" "Thread.*spin.*" \
+gdb_test "info thread" "${tdlabel_re}.*spin.*" \
"at least one th in spin while stopped at second th"
check_thread_local "second"
gdb_test "continue" ".*Breakpoint 2.*tls value.*" "continue to third thread"
-gdb_test "info thread" ".*Thread.*spin.*" \
+gdb_test "info thread" ".*${tdlabel_re}.*spin.*" \
"at least one th in spin while stopped at third th"
check_thread_local "third"
set no_of_threads 0
send_gdb "info thread\n"
gdb_expect {
- -re "^info thread\[ \t\r\n\]+ *Id .*Frame\[ \t\r\n\]+.*(\[0-9\]+) *Thread\[^\r\n\]+\r\n$gdb_prompt $" {
+ -re "^info thread\[ \t\r\n\]+ *Id .*Frame\[ \t\r\n\]+.*(\[0-9\]+) *${tdlabel_re}\[^\r\n\]+\r\n$gdb_prompt $" {
set no_of_threads $expect_out(1,string)
pass "get number of threads"
}
send_gdb "info thread\n"
gdb_expect {
- -re ".* 1 *Thread.*2 *Thread.*$gdb_prompt $" {
+ -re ".* 1 *${tdlabel_re}.*2 *${tdlabel_re}.*$gdb_prompt $" {
fail "too many threads left at end"
}
- -re ".*\\\* 1 *Thread.*main.*$gdb_prompt $" {
+ -re ".*\\\* 1 *${tdlabel_re}.*main.*$gdb_prompt $" {
pass "expect only base thread at end"
}
-re ".*No stack.*$gdb_prompt $" {
# There is always a thread of an inferior, either a live one or
# a faked one.
- gdb_test "info threads" "\\* ${decimal} (process|Thread) \[0-9\.\]+\[ \t\].*"
+ gdb_test "info threads" "\\* ${decimal} ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
gdb_test "info inferiors" "\\* 1 process ${decimal} \[ \t\]+\[^\r\n\]*\[ \t\]+${binfile}.*"
}
}
# List all the thread. It is expected to get three threads without
# any errors.
gdb_test_multiple "info threads 3 2 1" "info threads" {
- -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" {
+ -re "3\[ \t\]+${tdlabel_re} .*2\[ \t\]+${tdlabel_re} .*1\[ \t\]+${tdlabel_re} .*${gdb_prompt} $" {
pass "info threads"
}
}
set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
+# A regular expression that matches the first word of a thread
+# description after the thread number info 'info threads'
+set tdlabel_re "(process|Thread|LWP)"
+
# A regular expression that matches a value history number.
# E.g., $1, $2, etc.
set valnum_re "\\\$$decimal"