xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/corethreads.exp (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1# Copyright 2011-2023 Free Software Foundation, Inc.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16# Are we on a target board?  And non-Linux targets seem to identify the thread
17# differently.
18if {![isnative] || ![istarget "*-*-linux*"]} {
19    return
20}
21
22standard_testfile
23set executable ${testfile}
24if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
25     untested "failed to compile"
26     return -1
27}
28
29set corefile [core_find $binfile]
30if {$corefile == ""} {
31    return 0
32}
33
34clean_restart $executable
35
36gdb_test "core-file $corefile" "Core was generated by .*" "load core"
37gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "sanity check we see the core file"
38
39set test "print pthread_t of thread0"
40gdb_test_multiple "p/x thread0" $test {
41    -re " = (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
42	pass $test
43	set thread0 $expect_out(1,string)
44    }
45}
46set test "print pthread_t of thread1"
47gdb_test_multiple "p/x thread1" $test {
48    -re " = (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
49	pass $test
50	set thread1 $expect_out(1,string)
51    }
52}
53
54gdb_test "info threads" "\r\n *\[12\] +Thread $thread0 .*" "thread0 found"
55gdb_test "info threads" "\r\n *\\*? +\[12\] +Thread $thread1 .*" "thread1 found"
56gdb_test "info threads" "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\[^\r\n\]+\r\n\[^\r\n\]+" "no other thread found"
57