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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.threads/] [gcore-thread.exp] - Blame information for rev 816

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

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Michael Snyder (msnyder@redhat.com)
18
# This is a test for the gdb command "generate-core-file".
19
 
20
if $tracelevel then {
21
        strace $tracelevel
22
}
23
 
24
set prms_id 0
25
set bug_id 0
26
 
27
# Single-threaded test case
28
set testfile "pthreads"
29
set srcfile  ${testfile}.c
30
set binfile  ${objdir}/${subdir}/gcore-${testfile}
31
 
32
if [istarget "*-*-linux"] then {
33
    set target_cflags "-D_MIT_POSIX_THREADS"
34
} else {
35
    set target_cflags ""
36
}
37
 
38
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
39
    return -1
40
}
41
 
42
# Now we can proceed with the real testing.
43
 
44
# Start with a fresh gdb.
45
 
46
gdb_exit
47
gdb_start
48
gdb_reinitialize_dir $srcdir/$subdir
49
gdb_load ${binfile}
50
 
51
# regexp for "horizontal" text (i.e. doesn't include newline or
52
# carriage return)
53
set horiz "\[^\n\r\]*"
54
 
55
# regexp for newline
56
set nl "\[\r\n\]+"
57
 
58
set prev_timeout $timeout
59
set timeout 30
60
 
61
send_gdb "help gcore\n"
62
gdb_expect {
63
    -re "Undefined command: .gcore.*$gdb_prompt $" {
64
        # gcore command not supported -- nothing to test here.
65
        unsupported "gdb does not support gcore on this target"
66
        return -1;
67
    }
68
    -re "Save a core file .*$gdb_prompt $" {
69
        pass "help gcore"
70
    }
71
    -re ".*$gdb_prompt $" {
72
        fail "help gcore"
73
    }
74
    timeout {
75
        fail "help gcore (timeout)"
76
    }
77
}
78
 
79
if { ! [ runto_main ] } then {
80
    untested gcore-thread.exp
81
    return -1
82
}
83
 
84
send_gdb "info threads\n"
85
gdb_expect {
86
    -re ".* main .*$gdb_prompt $" {
87
        # OK, threads are supported.
88
    }
89
    -re "${nl}$gdb_prompt $" {
90
        unsupported "gdb does not support threads on this target"
91
        return -1;
92
    }
93
}
94
 
95
# Make sure thread 1 is running
96
delete_breakpoints
97
gdb_breakpoint "thread1"
98
gdb_test "continue" "Continuing.*Breakpoint.* thread1 .*" "thread 1 is running"
99
 
100
# Make sure thread 2 is running
101
delete_breakpoints
102
gdb_breakpoint "thread2"
103
gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
104
 
105
set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
106
# Drop corefile
107
gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
108
        "save a corefile" \
109
{
110
  -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
111
    pass "save a corefile"
112
    global core_supported
113
    set core_supported 1
114
  }
115
  -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
116
    unsupported "save a corefile"
117
    global core_supported
118
    set core_supported 0
119
  }
120
}
121
 
122
global core_supported
123
if {!$core_supported} {
124
  return -1
125
}
126
 
127
# Now restart gdb and load the corefile.
128
gdb_exit
129
gdb_start
130
gdb_reinitialize_dir $srcdir/$subdir
131
gdb_load ${binfile}
132
 
133
send_gdb "core ${objdir}/${subdir}/gcore.test\n"
134
gdb_expect {
135
    -re ".* is not a core dump:.*$gdb_prompt $" {
136
        fail "re-load generated corefile (bad file format)"
137
        # No use proceeding from here.
138
        return;
139
    }
140
    -re ".*: No such file or directory.*$gdb_prompt $" {
141
        fail "re-load generated corefile (file not found)"
142
        # No use proceeding from here.
143
        return;
144
    }
145
    -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
146
        fail "re-load generated corefile (incomplete note section)"
147
    }
148
    -re "Core was generated by .*$gdb_prompt $" {
149
        pass "re-load generated corefile"
150
    }
151
    -re ".*$gdb_prompt $" {
152
        fail "re-load generated corefile"
153
    }
154
    timeout {
155
        fail "re-load generated corefile (timeout)"
156
    }
157
}
158
 
159
# FIXME: now what can we test about the thread state?
160
# We do not know for certain that there should be at least
161
# three threads, because who knows what kind of many-to-one
162
# mapping various OS's may do?  Let's assume that there must
163
# be at least two threads:
164
 
165
gdb_test "info threads" ".*${nl}  2 ${horiz}${nl}\\* 1 .*" \
166
        "corefile contains at least two threads"
167
 
168
# One thread in the corefile should be in the "thread2" function.
169
 
170
gdb_test "info threads" ".* thread2 .*" \
171
        "a corefile thread is executing thread2"
172
 
173
# The thread2 thread should be marked as the current thread.
174
 
175
gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
176
        "thread2 is current thread in corefile"
177
 
178
set timeout $prev_timeout

powered by: WebSVN 2.1.0

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