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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [gcore.exp] - Blame information for rev 321

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

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 2002, 2003, 2004, 2007, 2008 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
# Please email any bugs, comments, and/or additions to this file to:
17
# bug-gdb@prep.ai.mit.edu
18
 
19
# This file was written by Michael Snyder (msnyder@redhat.com)
20
# This is a test for the gdb command "generate-core-file".
21
 
22
if $tracelevel then {
23
        strace $tracelevel
24
}
25
 
26
set prms_id 0
27
set bug_id 0
28
 
29
set testfile "gcore"
30
set srcfile  ${testfile}.c
31
set binfile  ${objdir}/${subdir}/${testfile}
32
 
33
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
34
     untested gcore.exp
35
     return -1
36
}
37
 
38
# Start with a fresh gdb.
39
 
40
gdb_exit
41
gdb_start
42
gdb_reinitialize_dir $srcdir/$subdir
43
gdb_load ${binfile}
44
 
45
# Does this gdb support gcore?
46
send_gdb "help gcore\n"
47
gdb_expect {
48
    -re "Undefined command: .gcore.*$gdb_prompt $" {
49
        # gcore command not supported -- nothing to test here.
50
        unsupported "gdb does not support gcore on this target"
51
        return -1;
52
    }
53
    -re "Save a core file .*$gdb_prompt $" {
54
        pass "help gcore"
55
    }
56
    -re ".*$gdb_prompt $" {
57
        fail "help gcore"
58
    }
59
    timeout {
60
        fail "help gcore (timeout)"
61
    }
62
}
63
 
64
if { ! [ runto_main ] } then {
65
    untested gcore.exp
66
    return -1
67
}
68
 
69
proc capture_command_output { command prefix } {
70
    global gdb_prompt
71
    global expect_out
72
 
73
    set output_string ""
74
    send_gdb "$command\n"
75
    gdb_expect {
76
        -re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
77
            set output_string $expect_out(1,string)
78
        }
79
        default {
80
            fail "capture_command_output failed on $command."
81
        }
82
    }
83
    return $output_string
84
}
85
 
86
gdb_test "break terminal_func" "Breakpoint .* at .*${srcfile}, line .*" \
87
        "set breakpoint at terminal_func"
88
 
89
gdb_test "continue" "Breakpoint .* terminal_func.*" \
90
        "continue to terminal_func"
91
 
92
set print_prefix ".\[0123456789\]* = "
93
 
94
set pre_corefile_backtrace [capture_command_output "backtrace" ""]
95
set pre_corefile_regs [capture_command_output "info registers" ""]
96
set pre_corefile_allregs [capture_command_output "info all-reg" ""]
97
set pre_corefile_static_array \
98
        [capture_command_output "print static_array" "$print_prefix"]
99
set pre_corefile_uninit_array \
100
        [capture_command_output "print un_initialized_array" "$print_prefix"]
101
set pre_corefile_heap_string \
102
        [capture_command_output "print heap_string" "$print_prefix"]
103
set pre_corefile_local_array \
104
        [capture_command_output "print array_func::local_array" "$print_prefix"]
105
set pre_corefile_extern_array \
106
        [capture_command_output "print extern_array" "$print_prefix"]
107
 
108
set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
109
 
110
set core_supported 0
111
gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
112
        "save a corefile" \
113
{
114
  -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
115
    pass "save a corefile"
116
    global core_supported
117
    set core_supported 1
118
  }
119
  -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
120
    unsupported "save a corefile"
121
    global core_supported
122
    set core_supported 0
123
  }
124
}
125
 
126
if {!$core_supported} {
127
  return -1
128
}
129
 
130
# Now restart gdb and load the corefile.
131
gdb_exit
132
gdb_start
133
gdb_reinitialize_dir $srcdir/$subdir
134
gdb_load ${binfile}
135
 
136
send_gdb "core ${objdir}/${subdir}/gcore.test\n"
137
gdb_expect {
138
    -re ".* is not a core dump:.*$gdb_prompt $" {
139
        fail "re-load generated corefile (bad file format)"
140
        # No use proceeding from here.
141
        return;
142
    }
143
    -re ".*: No such file or directory.*$gdb_prompt $" {
144
        fail "re-load generated corefile (file not found)"
145
        # No use proceeding from here.
146
        return;
147
    }
148
    -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
149
        fail "re-load generated corefile (incomplete note section)"
150
    }
151
    -re "Core was generated by .*$gdb_prompt $" {
152
        pass "re-load generated corefile"
153
    }
154
    -re ".*$gdb_prompt $" {
155
        fail "re-load generated corefile"
156
    }
157
    timeout {
158
        fail "re-load generated corefile (timeout)"
159
    }
160
}
161
 
162
send_gdb "where\n"
163
gdb_expect_list "where in corefile" ".*$gdb_prompt $" {
164
    ".*\[\r\n\]+#0 .* terminal_func \\(\\) at "
165
    ".*\[\r\n\]+#1 .* array_func \\(\\) at "
166
    ".*\[\r\n\]+#2 .* factorial_func \\(value=1\\) at "
167
    ".*\[\r\n\]+#3 .* factorial_func \\(value=2\\) at "
168
    ".*\[\r\n\]+#4 .* factorial_func \\(value=3\\) at "
169
    ".*\[\r\n\]+#5 .* factorial_func \\(value=4\\) at "
170
    ".*\[\r\n\]+#6 .* factorial_func \\(value=5\\) at "
171
    ".*\[\r\n\]+#7 .* factorial_func \\(value=6\\) at "
172
    ".*\[\r\n\]+#8 .* main \\(.*\\) at "
173
}
174
 
175
set post_corefile_regs [capture_command_output "info registers" ""]
176
if ![string compare $pre_corefile_regs $post_corefile_regs] then {
177
    pass "corefile restored general registers"
178
} else {
179
    fail "corefile restored general registers"
180
}
181
 
182
set post_corefile_allregs [capture_command_output "info all-reg" ""]
183
if ![string compare $pre_corefile_allregs $post_corefile_allregs] then {
184
    pass "corefile restored all registers"
185
} else {
186
    fail "corefile restored all registers"
187
}
188
 
189
set post_corefile_extern_array \
190
        [capture_command_output "print extern_array" "$print_prefix"]
191
if ![string compare $pre_corefile_extern_array $post_corefile_extern_array]  {
192
    pass "corefile restored extern array"
193
} else {
194
    fail "corefile restored extern array"
195
}
196
 
197
set post_corefile_static_array \
198
        [capture_command_output "print static_array" "$print_prefix"]
199
if ![string compare $pre_corefile_static_array $post_corefile_static_array]  {
200
    pass "corefile restored static array"
201
} else {
202
    fail "corefile restored static array"
203
}
204
 
205
set post_corefile_uninit_array \
206
        [capture_command_output "print un_initialized_array" "$print_prefix"]
207
if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array]  {
208
    pass "corefile restored un-initialized array"
209
} else {
210
    fail "corefile restored un-initialized array"
211
}
212
 
213
set post_corefile_heap_string \
214
        [capture_command_output "print heap_string" "$print_prefix"]
215
if ![string compare $pre_corefile_heap_string $post_corefile_heap_string]  {
216
    pass "corefile restored heap array"
217
} else {
218
    fail "corefile restored heap array"
219
}
220
 
221
set post_corefile_local_array \
222
        [capture_command_output "print array_func::local_array" "$print_prefix"]
223
if ![string compare $pre_corefile_local_array $post_corefile_local_array]  {
224
    pass "corefile restored stack array"
225
} else {
226
    fail "corefile restored stack array"
227
}
228
 
229
set post_corefile_backtrace [capture_command_output "backtrace" ""]
230
if ![string compare $pre_corefile_backtrace $post_corefile_backtrace]  {
231
    pass "corefile restored backtrace"
232
} else {
233
    fail "corefile restored backtrace"
234
}

powered by: WebSVN 2.1.0

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