Upload Tizen:Base source
[external/gdb.git] / gdb / testsuite / gdb.base / gdb11531.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 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 <http://www.gnu.org/licenses/>.
17
18 # Test GDB bug report 11531.
19 # This is a problem related to CANNOT_STEP_HW_WATCHPOINTS macro.
20 # It affects Solaris native targets.
21
22 if $tracelevel then {
23         strace $tracelevel
24 }
25
26
27 set testfile "gdb11531"
28
29 if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug}] } {
30     return -1;
31 }
32
33 # Disable hardware watchpoints if necessary.
34 if [target_info exists gdb,no_hardware_watchpoints] {
35    gdb_test_no_output "set can-use-hw-watchpoints 0" ""
36 }
37
38 if { ![runto main] } then {
39     fail "run to main"
40     return
41 }
42
43 # The breakpoint is probably at the instruction where the value being
44 # watched (myrec.x) gets updated.  This is the instruction where we
45 # expect to receive a watchpoint notification when we do the "stepi"
46 # below.  However, having the breakpoint at the same location as this
47 # intruction can possibly interfere with our testcase, as stepping
48 # over the breakpoint in order to get past it may incorrectly lead
49 # to the debugger missing the watchpoint hit.  This would be a bug
50 # in GDB, but this is not the bug that we are trying to test here.
51 # So, we remove all breakpoints first.
52
53 delete_breakpoints
54
55 set nl "\[\r\n\]+"
56
57 gdb_test "watch myrec.x" ".*atchpoint \[0-9\]+: myrec\.x" "Set watchpoint"
58
59 gdb_test "next" \
60     ".*${nl}.*atchpoint \[0-9\]+: myrec\.x${nl}Old value = 0${nl}New value = 5${nl}.*" \
61     "watchpoint variable triggers at next"
62
63 gdb_test "continue" \
64     ".*${nl}.*atchpoint \[0-9\]+: myrec\.x${nl}Old value = 5${nl}New value = 78${nl}.*" \
65     "watchpoint variable triggers at continue"
66