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

Subversion Repositories or1k

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

Go to most recent revision | 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 Machine interface (MI) operations for disassembly.
22
#
23
# The goal is not to test gdb functionality, which is done by other tests,
24
# but to verify the correct output response to MI operations.
25
#
26
 
27
load_lib mi-support.exp
28
 
29
gdb_exit
30
if [mi_gdb_start] {
31
    continue
32
}
33
 
34
set testfile "basics"
35
set srcfile ${testfile}.c
36
set binfile ${objdir}/${subdir}/${testfile}
37
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
38
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
39
}
40
 
41
mi_delete_breakpoints
42
mi_gdb_reinitialize_dir $srcdir/$subdir
43
mi_gdb_load ${binfile}
44
 
45
proc test_breakpoints_creation_and_listing {} {
46
    global mi_gdb_prompt
47
    global srcfile
48
    global hex
49
 
50
    # Insert some breakpoints and list them
51
    # Also, disable some so they do not interfere with other tests
52
    # Tests:
53
    # -break-insert
54
    # -break-list
55
    # -break-disable
56
    # -break-info
57
 
58
    mi_gdb_test "200-break-insert main" \
59
             "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \
60
             "break-insert operation"
61
 
62
    mi_gdb_test "204-break-list" \
63
                "204\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}\}" \
64
                "list of breakpoints"
65
}
66
 
67
proc test_running_the_program {} {
68
    global mi_gdb_prompt
69
    global hex
70
 
71
    # Run the program without args
72
    # Tests:
73
    # -exec-run
74
 
75
    # mi_gdb_test cannot be used for asynchronous commands because there are
76
    # two prompts involved and this can lead to a race condition.
77
    # FIXME: We are accepting a duplicate file and line info temporarely.
78
    # The following is equivalent to a send_gdb "000-exec-run\n"
79
    mi_run_cmd
80
    # The running part has been checked already by mi_run_cmd
81
        gdb_expect {
82
            -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" {
83
            pass "run to main"
84
          }
85
          -re ".*$mi_gdb_prompt$" {fail "run to main (2)"}
86
          timeout {fail "run to main (timeout 2)"}
87
        }
88
}
89
 
90
proc test_disassembly_only {} {
91
    global mi_gdb_prompt
92
    global hex
93
    global decimal
94
 
95
    # Test disassembly more only for the current function.
96
    # Tests:
97
    # -data-disassemble -s $pc -e "$pc+8" -- 0
98
    # -data-disassembly -f basics.c -l 32 -- 0
99
 
100
    mi_gdb_test "print/x \$pc" "" ""
101
    mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \
102
            "111\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\}" \
103
             "data-disassemble from pc to pc+12 assembly only"
104
 
105
    mi_gdb_test "222-data-disassemble  -f basics.c -l 32 -- 0" \
106
            "222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \
107
              "data-disassemble file & line, assembly only"
108
}
109
 
110
proc test_disassembly_lines_limit {} {
111
    global mi_gdb_prompt
112
    global hex
113
    global decimal
114
 
115
    # Test disassembly more only for the current function.
116
    # Tests:
117
    # -data-disassembly -f basics.c -l 32 -n 20 -- 0
118
    # -data-disassembly -f basics.c -l 32 -n 0 -- 0
119
    # -data-disassembly -f basics.c -l 32 -n 50 -- 0
120
 
121
    mi_gdb_test "print/x \$pc" "" ""
122
    mi_gdb_test "222-data-disassemble  -f basics.c -l 32 -n 20 -- 0" \
123
            "222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \
124
              "data-disassemble file, line, number assembly only"
125
 
126
    mi_gdb_test "222-data-disassemble  -f basics.c -l 32 -n 0 -- 0" \
127
            "222\\^done,asm_insns=\{\}" \
128
              "data-disassemble file, line, number (zero lines) assembly only"
129
 
130
    mi_gdb_test "222-data-disassemble  -f basics.c -l 32 -n 50 -- 0" \
131
            "222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \
132
              "data-disassemble file, line, number (more than main lines) assembly only"
133
}
134
 
135
 
136
proc test_disassembly_mixed {} {
137
    global mi_gdb_prompt
138
    global hex
139
    global decimal
140
 
141
    # Test disassembly more only for the current function.
142
    # Tests:
143
    # -data-disassembly -f basics.c -l 21 -- 1
144
    # -data-disassembly -s $pc -e "$pc+8" -- 1
145
 
146
    mi_gdb_test "002-data-disassemble -f basics.c -l 21 -- 1" \
147
            "002\\^done,asm_insns=\{src_and_asm_line=\{line=\"21\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",inst=\".*\"\}.*\}\},.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",inst=\".*\"\}\}\}\}" \
148
             "data-disassemble file, line assembly mixed"
149
 
150
    #
151
    # In mixed mode, the lowest level of granularity is the source line.
152
    # So we are going to get the disassembly for the source line at
153
    # which we are now, even if we have specified that the range is only 2 insns.
154
    #
155
    mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \
156
            "003\\^done,asm_insns=\{src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}\}\}" \
157
             "data-disassemble range assembly mixed"
158
}
159
 
160
proc test_disassembly_mixed_lines_limit {} {
161
    global mi_gdb_prompt
162
    global hex
163
    global decimal
164
 
165
    # Test disassembly more only for the current function.
166
    # Tests:
167
    # -data-disassembly -f basics.c -l 32 -n 20 -- 1
168
    # -data-disassembly -f basics.c -l 32 -n 0 -- 1
169
    # -data-disassembly -f basics.c -l 32 -n 50 -- 1
170
 
171
    mi_gdb_test "print/x \$pc" "" ""
172
    mi_gdb_test "222-data-disassemble  -f basics.c -l 32 -n 20 -- 1" \
173
            "222\\^done,asm_insns=\{src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\}" \
174
              "data-disassemble file, line, number assembly mixed"
175
 
176
    mi_gdb_test "222-data-disassemble  -f basics.c -l 32 -n 0 -- 1" \
177
            "222\\^done,asm_insns=\{src_and_asm_line=\{line=\"31\",file=\".*basics.c\",line_asm_insn=\{\}\}\}" \
178
              "data-disassemble file, line, number (zero lines) assembly mixed"
179
 
180
    mi_gdb_test "222-data-disassemble  -f basics.c -l 32 -n 50 -- 1" \
181
            "222\\^done,asm_insns=\{src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\}" \
182
              "data-disassemble file, line, number (more than main lines) assembly mixed"
183
}
184
 
185
proc test_disassembly_bogus_args {} {
186
    global mi_gdb_prompt
187
    global hex
188
 
189
    # Test that bogus input to disassembly command is rejected.
190
    # Tests:
191
    # -data-disassembly -f foo -l abc -n 0 -- 0
192
    # -data-disassembly -s foo -e bar -- 0
193
    # -data-disassembly -s $pc -f basics.c -- 0
194
    # -data-disassembly -f basics.c -l 32 -- 9
195
 
196
    mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
197
             ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
198
             "data-disassemble bogus filename"
199
 
200
    mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
201
             "321\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \
202
             "data-disassemble bogus address"
203
 
204
    mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
205
             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
206
             "data-disassemble mix different args"
207
 
208
    mi_gdb_test "789-data-disassemble -f basics.c -l 32 -- 9" \
209
             "789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \
210
             "data-disassemble wrong mode arg"
211
 
212
}
213
 
214
test_breakpoints_creation_and_listing
215
test_running_the_program
216
test_disassembly_only
217
test_disassembly_mixed
218
test_disassembly_bogus_args
219
test_disassembly_lines_limit
220
test_disassembly_mixed_lines_limit
221
 
222
mi_gdb_exit
223
return 0
224
 
225
# Local variables:
226
# change-log-default-name: "ChangeLog-mi"
227
# End:

powered by: WebSVN 2.1.0

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