]> Git Repo - binutils.git/blob - gdb/testsuite/gdb.threads/pthread_cond_wait.exp
fc2942e07a06a3b698c2d482a86e46be2953f36e
[binutils.git] / gdb / testsuite / gdb.threads / pthread_cond_wait.exp
1 # Copyright (C) 2004, 2007-2012 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[email protected]
18
19 # This file verifies that GDB is able to compute a backtrace for a thread
20 # being blocked on a call to pthread_cond_wait(). 
21
22 set testfile "pthread_cond_wait"
23 set srcfile ${testfile}.c
24 set binfile ${objdir}/${subdir}/${testfile}
25
26 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
27     return -1
28 }
29
30 gdb_exit
31 gdb_start
32 gdb_reinitialize_dir $srcdir/$subdir
33 gdb_load ${binfile}
34 runto_main
35
36 gdb_test "break break_me" \
37     "Breakpoint 2 at .*: file .*${srcfile}, line .*" \
38          "breakpoint on break_me"
39
40 gdb_test "continue" \
41          ".*Breakpoint 2, break_me ().*" \
42          "run to break_me"
43
44
45 # Backtrace all threads, find the one running noreturn, and
46 # verify that we are able to get a sensible backtrace, including
47 # the frame for the pthread_cond_wait() call.
48 #
49 # The string below will only match if the functions named
50 # occur in a single thread's backtrace, in the given order.
51 #
52
53 global hex
54 global decimal
55
56 #
57 # This is a "backtrace break" ("btb"):
58 #
59 set btb "\[^\r\n\]+\[\r\n\]+\#${decimal}\[ \t\]+${hex} in "
60
61 # One of the threads is blocked on a call to pthread_cond_wait, and
62 # we want to verify that we are able to get a sensible backtrace for
63 # that thread.  Because we don't know its thread ID, we can't switch
64 # to it before doing the backtrace. So we get a backtrace for all
65 # threads, and verify that one them returns the expected backtrace.
66 gdb_test "thread apply all backtrace" \
67     "pthread_cond_wait${btb}cond_wait${btb}noreturn${btb}forever_pthread.*" \
68     "backtrace in blocked thread"
69
This page took 0.019188 seconds and 2 git commands to generate.