OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.threads/] [watchthreads2.exp] - Blame information for rev 330

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# This testcase is part of GDB, the GNU debugger.
2
 
3
# Copyright 2009, 2010 Free Software Foundation, Inc.
4
 
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program.  If not, see .
17
 
18
# Check that watchpoints get propagated to all existing threads when the
19
# watchpoint is created.
20
 
21
set NR_THREADS 4
22
set X_INCR_COUNT 10
23
 
24
if $tracelevel {
25
    strace $tracelevel
26
}
27
 
28
 
29
# This test verifies that a watchpoint is detected in the proper thread
30
# so the test is only meaningful on a system with hardware watchpoints.
31
if [target_info exists gdb,no_hardware_watchpoints] {
32
    return 0;
33
}
34
 
35
set testfile "watchthreads2"
36
set srcfile ${testfile}.c
37
set binfile ${objdir}/${subdir}/${testfile}
38
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}" "additional_flags=-DNR_THREADS=$NR_THREADS -DX_INCR_COUNT=$X_INCR_COUNT"]] != "" } {
39
    return -1
40
}
41
 
42
gdb_exit
43
gdb_start
44
gdb_reinitialize_dir $srcdir/$subdir
45
gdb_load ${binfile}
46
 
47
gdb_test_no_output "set can-use-hw-watchpoints 1" ""
48
 
49
#
50
# Run to `main' where we begin our tests.
51
#
52
 
53
if ![runto_main] then {
54
    gdb_suppress_tests
55
}
56
 
57
gdb_test "break thread_started" \
58
         "Breakpoint 2 at .*: file .*${srcfile}, line .*" \
59
         "breakpoint on thread_started"
60
 
61
# Run the program until all threads have hit thread_started.
62
# We use this as the vehicle to determine when gdb is aware
63
# of all threads (i.e. "info threads" would show all threads).
64
 
65
set nr_started 0
66
set message "run to thread_started"
67
for { set i 0 } { $i < $NR_THREADS } { incr i } {
68
    gdb_test_multiple "continue" $message {
69
        -re ".*Breakpoint 2, thread_started ().*$gdb_prompt $" {
70
            incr nr_started
71
        }
72
        timeout {
73
            set i $NR_THREADS
74
        }
75
    }
76
}
77
if { $nr_started == $NR_THREADS } {
78
    pass "all threads started"
79
} else {
80
    fail "all threads started"
81
    # No point in continuing.
82
    return -1
83
}
84
 
85
# Watch X, it will be modified by all threads.
86
# We want this watchpoint to be set *after* all threads are running.
87
gdb_test "watch x" "Hardware watchpoint 3: x"
88
 
89
# Now that the watchpoint is set, we can let the threads increment X.
90
gdb_test_no_output "set var test_ready = 1"
91
 
92
# While debugging.
93
#gdb_test_no_output "set debug infrun 1"
94
 
95
set x_inc_line [gdb_get_line_number "X increment"]
96
set x_thread_loc "thread_function \\\(arg=.*\\\) at .*watchthreads.c:$x_inc_line"
97
 
98
# X is incremented under a mutex, so we should get NR_THREADS * X_INCR_COUNT
99
# hits.
100
set limit [expr $NR_THREADS*$X_INCR_COUNT]
101
set x_count 0
102
set done 0
103
 
104
set message "x watch loop"
105
 
106
for {set i 0} {!$done && $i < $limit} {incr i} {
107
    set test_flag 0
108
 
109
    gdb_test_multiple "continue" $message {
110
        -re "(.*Hardware watchpoint.*)$gdb_prompt $" {
111
            set string $expect_out(1,string)
112
 
113
            if [regexp "Hardware watchpoint 3: x\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $x_count\[^\r\]*\r\[^\r\]*New value = [expr $x_count+1]\r" $string] {
114
                incr x_count
115
                set test_flag 1
116
            } else {
117
                # We test for new value = old value + 1 each iteration.
118
                # This can fail due to gdb/10116.
119
                # This is caught after the loop exits.
120
            }
121
        }
122
        -re "The program is not being run.*$gdb_prompt $" {
123
            fail "$message (program terminated)"
124
        }
125
    }
126
 
127
    # If we fail above, don't bother continuing loop.
128
    if { $test_flag == 0 } {
129
        set done 1
130
    }
131
}
132
 
133
if { $i == $limit } {
134
    pass "all threads incremented x"
135
} else {
136
    kfail "gdb/10116" "gdb can drop watchpoints in multithreaded app"
137
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.