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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.hp/] [gdb.compat/] [xdb3.exp] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright (C) 1998, 2007, 2008, 2009, 2010 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 .  */
15
 
16
 
17
if $tracelevel then {
18
        strace $tracelevel
19
}
20
 
21
if { [skip_hp_tests] } then { continue }
22
 
23
set testfile1 "average"
24
set testfile2 "sum"
25
set testfile "xdb-test"
26
set binfile1 ${objdir}/${subdir}/${testfile1}
27
set binfile2 ${objdir}/${subdir}/${testfile2}
28
set binfile ${objdir}/${subdir}/${testfile}
29
 
30
if  { [gdb_compile "${srcdir}/${subdir}/average.c" "${binfile1}.o" object {debug}] != "" } {
31
     untested xdb3.exp
32
     return -1
33
}
34
 
35
if  { [gdb_compile "${srcdir}/${subdir}/sum.c" "${binfile2}.o" object {debug}] != "" } {
36
     untested xdb3.exp
37
     return -1
38
}
39
 
40
if  { [gdb_compile "${binfile1}.o ${binfile2}.o" ${binfile} executable {debug}] != "" } {
41
     untested xdb3.exp
42
     return -1
43
}
44
 
45
if [get_compiler_info ${binfile}] {
46
    return -1;
47
}
48
if { $gcc_compiled } then { continue }
49
 
50
 
51
proc xdb_reinitialize_dir { subdir } {
52
    global gdb_prompt
53
 
54
   send_gdb "D\n"
55
    gdb_expect {
56
        -re "Reinitialize source path to empty.*y or n. " {
57
            send_gdb "y\n"
58
            gdb_expect {
59
                -re "Source directories searched.*$gdb_prompt $" {
60
                    send_gdb "D $subdir\n"
61
                    gdb_expect {
62
                        -re "Source directories searched.*$gdb_prompt $" {
63
                            verbose "Dir set to $subdir"
64
                        }
65
                        -re ".*$gdb_prompt $" {
66
                            perror "Dir \"$subdir\" failed."
67
                        }
68
                    }
69
                }
70
                -re ".*$gdb_prompt $" {
71
                    perror "Dir \"$subdir\" failed."
72
                }
73
            }
74
        }
75
        -re ".*$gdb_prompt $" {
76
            perror "Dir \"$subdir\" failed."
77
        }
78
    }
79
}
80
 
81
#
82
#test_search
83
#
84
proc test_search { } {
85
    gdb_test "set listsize 4" ""
86
    gdb_test "list average.c:1" "1\[ \t\]+/. This is a sample .*"
87
    gdb_test "/ print_average" "17\[ \t\]+void print_average\\(int \\*list.*"
88
    gdb_test "/ print_average" "19\[ \t\]+void print_average\\(list, low, high\\)"
89
    gdb_test "/ print_average" "42\[ \t\]+print_average \\(my_list, first, last\\);"
90
    gdb_test "? print_average" "19\[ \t\]+void print_average\\(list, low, high\\)"
91
    gdb_test "? sum" "9\[ \t]+extern int sum\\(\\);"
92
}
93
 
94
#
95
#test_viewing_loc
96
#
97
proc test_viewing_loc { } {
98
    gdb_test "L" "No stack."
99
    gdb_test "break main" ""
100
    gdb_test "R" ""
101
    gdb_test "L" "#0\[ \t\]+main \\(\\) at.*average.c:38\r\n38\[ \t\]+int first = 0, last = 0;"
102
}
103
 
104
#
105
#test_dir_list
106
#
107
proc test_dir_list { } {
108
    gdb_test "ld" "Source directories searched: .*"
109
}
110
 
111
#
112
#test_list_sources
113
#
114
proc test_list_sources { } {
115
    if [istarget "hppa64-*-*"] {
116
        gdb_test "lf" "Source files for which symbols have been read in:\r\n\r\n.*average\\.c.*Source files for which symbols will be read in on demand:\r\n\r\nglobals,.*\[se\]\[un\]\[md\]\\.c.*\[se\]\[un\]\[md\]\\.c"
117
    } else {
118
        gdb_test "lf" "Source files for which symbols have been read in:\r\n\r\n.*average\\.c.*\r\n\r\nSource files for which symbols will be read in on demand:\r\n\r\nglobals, end\\.c,.*sum\\.c"
119
    }
120
}
121
#
122
#test_vlist
123
#
124
proc test_vlist { } {
125
    gdb_test "v main" "34\[ \t\]+main \\(\\)\r\n35\[ \t\]+#endif\r\n36\[ \t\]+.\r\n37\[ \t\]+char c;"
126
}
127
 
128
#
129
#test_va
130
#
131
proc test_va { } {
132
    if [istarget "hppa64-*-*"] {
133
        gdb_test "va main" "Dump of assembler code for function main:\r\n.*0x.* 
:\[ \t\]+std %rp,-0x10\\(%sp\\)\r\n0x.* :\[ \t\]+std,ma %r3,0xd0\\(%sp\\)\r\n.*0x.* :\[ \t\]+std %r4,-0xc8\\(%sp\\)\r\n.*0x.* :\[ \t\]+copy %ret1,%r3\r\n.*"
134
    } else {
135
        gdb_test "va main" "Dump of assembler code for function main:\r\n.*0x.* 
:\[ \t\]+stw %rp,-0x14\\(%sr0,%sp\\)\r\n0x.* :\[ \t\]+ldo 0x\[48\]0\\(%sp\\),%sp\r\n.*0x.* :\[ \t\]+stw %r0,-0x.*\\(%sr0,%sp\\)\r\n.*0x.* :\[ \t\]+stw %r0,-0x.*\\(%sr0,%sp\\)\r\n.*"
136
    }
137
}
138
 
139
#
140
#test_list_globals
141
#
142
proc test_list_globals { } {
143
    gdb_test "lg" "All defined variables:\r\n\r\nFile globals:.*"
144
#    gdb_test "lg" "All defined variables:\r\n\r\nFile globals:\r\nchar __buffer.512.;\r\nint __d_eh_catch_catch;\r\nint __d_eh_catch_throw;.*"
145
}
146
 
147
#
148
#test_list_registers
149
#
150
proc test_list_registers { } {
151
    if [istarget "hppa64-*-*"] {
152
        gdb_test "lr" "\[ \t\]+flags:.*r17:.*pcsqh:.*cr0:.*\r\n\[ \t\]+r1:.*r18:.*pcoqt:.*cr8:.*"
153
    } else {
154
        gdb_test "lr" "\[ \t\]+flags:.*r18:.*pcsqt:.*ccr:.*\r\n\[ \t\]+r1:.*r19:.*eiem:.*cr12:.*"
155
    }
156
    gdb_test "lr r1" "r1 .*"
157
}
158
 
159
#
160
#test_backtrace
161
#
162
proc test_backtrace { } {
163
    gdb_test "t" "#0  main \\(\\) at.*average.c:39"
164
    gdb_test "T" "#0  main \\(\\) at.*average.c:39\r\n\[ \t\]+c = *.*\r\n\[ \t\]+first = 0\r\n\[ \t\]+last = 0"
165
 
166
    gdb_test "break sum" ""
167
    gdb_test "cont" ""
168
    gdb_test "next"
169
 
170
    gdb_test "t" "#0  sum \\(list=0x.*, low=0, high=9\\) at.*sum\.c:12\r\n#1  0x.* in print_average \\(list=0x.*, low=0, high=9\\) at.*average\.c:24\r\n#2  0x.* in main \\(\\) at.*average\.c:42"
171
    gdb_test "t 1" "#0  sum \\(list=0x.*, low=0, high=9\\) at.*sum\.c:12\r\n\\(More stack frames follow\.\.\.\\)"
172
    gdb_test "T" "#0  sum \\(list=0x.*, low=0, high=9\\) at.*sum\.c:12\r\n\[ \t\]+i = 0\r\n\[ \t\]+s = 0\r\n#1  0x.* in print_average \\(list=0x.*, low=0, high=9\\) at.*average\.c:24\r\n\[ \t\]+total = 0\r\n\[ \t\]+num_elements = 0\r\n\[ \t\]+average = 0\r\n#2  0x.* in main \\(\\) at.*average\.c:42\r\n\[ \t\]+c = *.*\r\n\[ \t\]+first = 0\r\n\[ \t\]+last = 9"
173
    gdb_test "T 1" "#0  sum \\(list=0x.*, low=0, high=9\\) at.*sum\.c:12\r\n\[ \t\]+i = 0\r\n\[ \t\]+s = 0\r\n\\(More stack frames follow\.\.\.\\)"
174
 
175
    gdb_test "V" "#0  sum \\(list=0x.*, low=0, high=9\\) at.*sum\.c:12\r\n\\12\[ \t\]+for \\(i = low;.*\\)"
176
    gdb_test "V 1" "#1  0x.* in print_average \\(list=0x.*, low=0, high=9\\) at.*average\.c:24\r\n24\[ \t\]+total = sum\\(list, low, high\\);"
177
}
178
 
179
#
180
# test_go
181
#
182
proc test_go { }  {
183
    gdb_test "break main" ""
184
    gdb_test "R" ""
185
 
186
    gdb_test "g +1" "Breakpoint.*at 0x.*: file.*average\.c, line 39\.\r\nContinuing at 0x.*\.\r\nmain \\(\\) at.*average\.c:39\r\n39\[ \t\]+last = num-1;"
187
    gdb_test "g 42" "Breakpoint.*at 0x.*: file.*average\.c, line 42\.\r\nContinuing at 0x.*\.\r\nmain \\(\\) at.*average\.c:42\r\n42\[ \t\]+print_average \\(my_list, first, last\\);"
188
 
189
}
190
 
191
#
192
#test_breakpoints
193
#
194
proc test_breakpoints { } {
195
    global gdb_prompt
196
 
197
    gdb_test "sb" ""
198
    gdb_test "lb" "Num.*Type.*Disp.*Enb.*Address.*What\r\n1\[ \r\]+breakpoint\[ \r\]+keep n.*in main at.*average\.c:38.*"
199
    gdb_test "ab" ""
200
    gdb_test "lb" "Num.*Type.*Disp.*Enb.*Address.*What\r\n1\[ \r\]+breakpoint\[ \r\]+keep y.*in main at.*average\.c:38.*"
201
    gdb_test "ba sum" "Breakpoint.*at.*: file.*sum\.c, line 11\."
202
    gdb_test "cont" ""
203
    gdb_test "bx" "Breakpoint.*at.*: file.*sum.c, line 15\."
204
    #gdb_test "bx if (1)" "Breakpoint.*at.*: file.*sum.c, line 15\."
205
    gdb_test "bx 1" "Breakpoint.*at.*: file.*average.c, line 29\."
206
    gdb_test "bx 1 if (1)" "Breakpoint.*at.*: file.*average.c, line 29\."
207
    gdb_test "bc 1 2" "Will ignore next 2 crossings of breakpoint 1\."
208
    gdb_test "lb 1" "Num.*Type.*Disp.*Enb.*Address.*What\r\n1\[ \r\]+breakpoint\[ \r\]+keep y.*in main at.*average\.c:38\r\n.*breakpoint already hit 1 time\r\n.*ignore next 2 hits.*"
209
 
210
    send_gdb "db\n"
211
    gdb_expect {
212
        -re "Delete all breakpoints.*y or n. $" {
213
            send_gdb "y\n"
214
            exp_continue
215
        }
216
        -re "y\r\n$gdb_prompt $" {}
217
        -re ".*$gdb_prompt $" { # This happens if there were no breakpoints
218
            }
219
        timeout { perror "Delete all breakpoints (timeout)" ; return }
220
    }
221
    send_gdb "lb\n"
222
    gdb_expect {
223
        -re "No breakpoints or watchpoints..*$gdb_prompt $" {}
224
        -re ".*$gdb_prompt $" { perror "breakpoints not deleted" ; return }
225
        timeout { perror "info breakpoints (timeout)" ; return }
226
    }
227
gdb_test "xbreak" "Breakpoint.*at.*file.*sum.c, line 15."
228
gdb_test "xbreak print_average" "Breakpoint.*at.*file.*average.c, line 29."
229
gdb_test "xbreak if (1)" "Note: breakpoint.*also set at pc.*Breakpoint.*at.*file.*sum.c, line 15."
230
gdb_test "xbreak print_average if (1)" "Note: breakpoint.*also set at pc.*Breakpoint.*at.*file.*average.c, line 29."
231
 
232
    send_gdb "lb\n"
233
    gdb_expect {
234
        -re "Num Type           Disp Enb Address    What.*breakpoint     keep y.*sum.c:15.*breakpoint     keep y.*average.c:29.*breakpoint     keep y.*sum.c:15.*stop only if 1.*breakpoint     keep y.*average.c:29.*stop only if 1.*$gdb_prompt $" {pass "lb on xbreaks"}
235
        -re ".*$gdb_prompt $" { fail "breakpoints not deleted"}
236
        timeout { fail "info breakpoints (timeout)" }
237
    }
238
 
239
}
240
 
241
#
242
# test_signals
243
#
244
proc test_signals { } {
245
    gdb_test "handle SIGTERM nostop noprint" ""
246
    gdb_test "z 15 s" "Signal.*Stop.*Print.*Pass to program.*Description\r\nSIGTERM.*Yes.*Yes.*Yes.*Terminated"
247
    gdb_test "z 15 r" "Signal.*Stop.*Print.*Pass to program.*Description\r\nSIGTERM.*No.*No.*Yes.*Terminated"
248
    gdb_test "z 15 i" "Signal.*Stop.*Print.*Pass to program.*Description\r\nSIGTERM.*No.*No.*No.*Terminated"
249
    gdb_test "z 15 r" "Signal.*Stop.*Print.*Pass to program.*Description\r\nSIGTERM.*No.*Yes.*No.*Terminated"
250
    gdb_test "z 15 Q" "Signal.*Stop.*Print.*Pass to program.*Description\r\nSIGTERM.*No.*No.*No.*Terminated"
251
    gdb_test "lz" "Signal.*Stop.*Print.*Pass to program.*Description\r\n\r\nSIGHUP.*Yes.*"
252
}
253
 
254
 
255
 
256
# Start with a fresh gdb.
257
global GDBFLAGS
258
set saved_gdbflags $GDBFLAGS
259
 
260
set GDBFLAGS "$GDBFLAGS --xdb"
261
 
262
gdb_exit
263
gdb_start
264
 
265
xdb_reinitialize_dir $srcdir/$subdir
266
 
267
gdb_load ${binfile}
268
send_gdb "set width 0\n"
269
gdb_expect -re "$gdb_prompt $"
270
test_search
271
test_viewing_loc
272
test_dir_list
273
test_list_sources
274
test_vlist
275
test_va
276
gdb_test "next"
277
gdb_test "l" "No arguments.\r\nc = *.*\r\nfirst = 0\r\nlast = 0"
278
#test_list_globals
279
test_list_registers
280
test_backtrace
281
 
282
# Start with a fresh gdb.
283
 
284
gdb_exit
285
gdb_start
286
xdb_reinitialize_dir $srcdir/$subdir
287
 
288
gdb_load ${binfile}
289
send_gdb "set width 0\n"
290
gdb_expect -re "$gdb_prompt $"
291
test_go
292
 
293
 
294
gdb_exit
295
gdb_start
296
xdb_reinitialize_dir $srcdir/$subdir
297
 
298
gdb_load ${binfile}
299
send_gdb "set width 0\n"
300
gdb_expect -re "$gdb_prompt $"
301
gdb_test "break main" ""
302
gdb_test "R" ""
303
gdb_test "S" "39\[ \t\]+last = num-1;"
304
test_breakpoints
305
test_signals
306
gdb_test "sm" ""
307
gdb_test "info set" ".*pagination:  State of pagination is off.*"
308
gdb_test "am" ""
309
gdb_test "info set" ".*pagination:  State of pagination is on.*"
310
gdb_exit
311
 
312
set GDBFLAGS $saved_gdbflags
313
 
314
return 0
315
 
316
 
317
 
318
 
319
 
320
 

powered by: WebSVN 2.1.0

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