1# Copyright (C) 2004, 2007 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# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18
19# This file was written by Manoj Iyer. (manjo@austin.ibm.com)
20# Test break points and single step on thread functions.
21#
22# Test Purpose:
23# - Test that breakpoints, continue in a threaded  application works.
24#   On powerpc64-unknown-linux-gnu system, running kernel version
25#   2.6.5-7.71-pseries64 this test is known to fail due to kernel bug
26#   in ptrace system call.
27#
28# Test Strategy:
29# - thread_check.c creates 2 threads
30# - start gdb
31# - create 2 breakpoints #1 main() #2 tf() (the thread function)
32# - run gdb till #1 main() breakpoint is reached
33# - continue to breakpoint #2 tf()
34# - delete all breakpoints
35# - exit gdb.
36
37if $tracelevel then {
38        strace $tracelevel
39}
40
41set prms_id 0
42set bug_id 0
43
44set testfile "thread_check"
45set srcfile ${testfile}.c
46set binfile ${objdir}/${subdir}/${testfile}
47
48if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
49    return -1
50}
51
52
53gdb_start
54gdb_reinitialize_dir $srcdir/$subdir
55gdb_load ${binfile}
56
57if ![runto_main] then {
58   fail "Can't run to main"
59      return 1;
60}
61
62
63#
64# set breakpoint at thread fucntion tf
65#
66gdb_test "break tf" \
67    "Breakpoint.*at.* file .*$srcfile, line.*" \
68    "breakpoint at tf"
69
70
71#
72#
73# continue to tf() breakpoint #2
74#
75gdb_test "continue" \
76     ".*Breakpoint 2,.*tf.*at.*$srcfile:.*" \
77     "continue to tf"
78
79#
80# backtrace from thread function.
81#
82gdb_test "backtrace" \
83    "#0 .*tf .*at .*$srcfile:.*" \
84    "backtrace from thread function"
85
86
87#
88# delete all breakpoints
89#
90delete_breakpoints
91
92#
93# exit gdb
94#
95gdb_exit
96