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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.mi/] [mi-watch.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
#   Copyright (C) 1999 2000 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 2 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, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
 
17
# Please email any bugs, comments, and/or additions to this file to:
18
# bug-gdb@prep.ai.mit.edu
19
 
20
#
21
# Test essential Machine interface (MI) operations
22
#
23
# Verify that, using the MI, we can run a simple program and perform basic
24
# debugging activities like: insert breakpoints, run the program,
25
# step, next, continue until it ends and, last but not least, quit.
26
#
27
# The goal is not to test gdb functionality, which is done by other tests,
28
# but to verify the correct output response to MI operations.
29
#
30
 
31
load_lib mi-support.exp
32
 
33
gdb_exit
34
if [mi_gdb_start] {
35
    continue
36
}
37
 
38
set testfile "basics"
39
set srcfile ${testfile}.c
40
set binfile ${objdir}/${subdir}/${testfile}
41
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
42
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
43
}
44
 
45
mi_delete_breakpoints
46
mi_gdb_reinitialize_dir $srcdir/$subdir
47
mi_gdb_load ${binfile}
48
 
49
proc test_watchpoint_creation_and_listing {} {
50
    global mi_gdb_prompt
51
    global srcfile
52
    global hex
53
 
54
    # Insert a watchpoint and list
55
    # Tests:
56
    # -break-watch C
57
    # -break-list
58
 
59
    mi_gdb_test "111-break-watch C" \
60
             "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \
61
             "break-watch operation"
62
 
63
    mi_gdb_test "222-break-list" \
64
                "222\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"1\"\},bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\}" \
65
                "list of watchpoints"
66
 
67
}
68
 
69
# UNUSED at the time
70
proc test_awatch_creation_and_listing {} {
71
    global mi_gdb_prompt
72
    global srcfile
73
    global hex
74
 
75
    # Insert an access watchpoint and list it
76
    # Tests:
77
    # -break-watch -a A
78
    # -break-list
79
 
80
    mi_gdb_test "333-break-watch -a A" \
81
             "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"32\"\}" \
82
             "break-watch -a operation"
83
 
84
    mi_gdb_test "444-break-list" \
85
                "444\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\}" \
86
                "list of watchpoints awatch"
87
 
88
    mi_gdb_test "777-break-delete 3" \
89
            "777\\^done" \
90
            "delete access watchpoint"
91
}
92
 
93
# UNUSED at the time
94
proc test_rwatch_creation_and_listing {} {
95
    global mi_gdb_prompt
96
    global srcfile
97
    global hex
98
 
99
    # Insert a read watchpoint and list it.
100
    # Tests:
101
    # -break-insert -r B
102
    # -break-list
103
 
104
    mi_gdb_test "200-break-watch -r C" \
105
             "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \
106
             "break-insert -r operation"
107
 
108
    mi_gdb_test "300-break-list" \
109
                "300\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\}" \
110
                "list of breakpoints"
111
 
112
    mi_gdb_test "177-break-delete 4" \
113
            "177\\^done" \
114
            "delete read watchpoint"
115
}
116
 
117
proc test_running_the_program {} {
118
    global mi_gdb_prompt
119
    global hex
120
 
121
    # Run the program without args, then specify srgs and rerun the program
122
    # Tests:
123
    # -exec-run
124
 
125
    mi_gdb_test "300-break-insert callee4" \
126
             "300\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"0\"\}" \
127
             "insert breakpoint at callee4"
128
 
129
    # mi_gdb_test cannot be used for asynchronous commands because there are
130
    # two prompts involved and this can lead to a race condition.
131
    # The following is equivalent to a send_gdb "000-exec-run\n"
132
    mi_run_cmd
133
    # The running part has been checked already by mi_run_cmd
134
        gdb_expect {
135
            -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" \
136
                    { pass "run to callee4" }
137
          -re ".*$mi_gdb_prompt$" {fail "run to callee4 (2)"}
138
          timeout {fail "run to callee4 (timeout 2)"}
139
        }
140
}
141
 
142
proc test_watchpoint_triggering {} {
143
    global mi_gdb_prompt
144
    global hex
145
 
146
    # Continue execution until the watchpoint is reached,  continue again,
147
    # to see the watchpoint go out of scope.
148
    # Does:
149
    # -exec-continue (Here wp triggers)
150
    # -exec-continue (Here wp goes out of scope)
151
 
152
    send_gdb "222-exec-continue\n"
153
    gdb_expect {
154
      -re "222\\^running\r\n$mi_gdb_prompt" {
155
        gdb_expect {
156
            -re "222\\*stopped,reason=\"watchpoint-trigger\",wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\},thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"13\"\}\r\n$mi_gdb_prompt$" {
157
            pass "watchpoint trigger"
158
          }
159
          -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"}
160
          timeout {fail "watchpoint trigger (timeout 2)"}
161
        }
162
      }
163
      -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"}
164
      timeout {fail "watchpoint trigger (timeout 1)"}
165
    }
166
 
167
    send_gdb "223-exec-continue\n"
168
    gdb_expect {
169
      -re "223\\^running\r\n$mi_gdb_prompt" {
170
        gdb_expect {
171
            -re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee3\",args=\{.*\},file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" {
172
            pass "wp out of scope"
173
          }
174
          -re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"}
175
          timeout {fail "wp out of scope (timeout 2)"}
176
        }
177
      }
178
      -re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"}
179
      timeout {fail "wp out of scope (timeout 1)"}
180
    }
181
}
182
 
183
test_running_the_program
184
test_watchpoint_creation_and_listing
185
#test_rwatch_creation_and_listing
186
#test_awatch_creation_and_listing
187
test_watchpoint_triggering
188
 
189
mi_gdb_exit
190
return 0
191
 
192
# Local variables:
193
# change-log-default-name: "ChangeLog-mi"
194
# End:
195
 

powered by: WebSVN 2.1.0

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