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.threads/] [gcore-thread.exp] - Blame information for rev 178

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
# Single-threaded test case
30
set testfile "pthreads"
31
set srcfile  ${testfile}.c
32
set binfile  ${objdir}/${subdir}/gcore-${testfile}
33
 
34
if [istarget "*-*-linux"] then {
35
    set target_cflags "-D_MIT_POSIX_THREADS"
36
} else {
37
    set target_cflags ""
38
}
39
 
40
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
41
    return -1
42
}
43
 
44
# Now we can proceed with the real testing.
45
 
46
# Start with a fresh gdb.
47
 
48
gdb_exit
49
gdb_start
50
gdb_reinitialize_dir $srcdir/$subdir
51
gdb_load ${binfile}
52
 
53
# regexp for "horizontal" text (i.e. doesn't include newline or
54
# carriage return)
55
set horiz "\[^\n\r\]*"
56
 
57
# regexp for newline
58
set nl "\[\r\n\]+"
59
 
60
set timeout 30
61
 
62
send_gdb "help gcore\n"
63
gdb_expect {
64
    -re "Undefined command: .gcore.*$gdb_prompt $" {
65
        # gcore command not supported -- nothing to test here.
66
        unsupported "gdb does not support gcore on this target"
67
        return -1;
68
    }
69
    -re "Save a core file .*$gdb_prompt $" {
70
        pass "help gcore"
71
    }
72
    -re ".*$gdb_prompt $" {
73
        fail "help gcore"
74
    }
75
    timeout {
76
        fail "help gcore (timeout)"
77
    }
78
}
79
 
80
if { ! [ runto_main ] } then {
81
    untested gcore-thread.exp
82
    return -1
83
}
84
 
85
send_gdb "info threads\n"
86
gdb_expect {
87
    -re ".* main .*$gdb_prompt $" {
88
        # OK, threads are supported.
89
    }
90
    -re "${nl}$gdb_prompt $" {
91
        unsupported "gdb does not support threads on this target"
92
        return -1;
93
    }
94
}
95
 
96
# Make sure thread 1 is running
97
delete_breakpoints
98
gdb_breakpoint "thread1"
99
gdb_test "continue" "Continuing.*Breakpoint.* thread1 .*" "thread 1 is running"
100
 
101
# Make sure thread 2 is running
102
delete_breakpoints
103
gdb_breakpoint "thread2"
104
gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
105
 
106
set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
107
# Drop corefile
108
gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
109
        "save a corefile" \
110
{
111
  -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
112
    pass "save a corefile"
113
    global core_supported
114
    set core_supported 1
115
  }
116
  -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
117
    unsupported "save a corefile"
118
    global core_supported
119
    set core_supported 0
120
  }
121
}
122
 
123
global core_supported
124
if {!$core_supported} {
125
  return -1
126
}
127
 
128
# Now restart gdb and load the corefile.
129
gdb_exit
130
gdb_start
131
gdb_reinitialize_dir $srcdir/$subdir
132
gdb_load ${binfile}
133
 
134
send_gdb "core ${objdir}/${subdir}/gcore.test\n"
135
gdb_expect {
136
    -re ".* is not a core dump:.*$gdb_prompt $" {
137
        fail "re-load generated corefile (bad file format)"
138
        # No use proceeding from here.
139
        return;
140
    }
141
    -re ".*: No such file or directory.*$gdb_prompt $" {
142
        fail "re-load generated corefile (file not found)"
143
        # No use proceeding from here.
144
        return;
145
    }
146
    -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
147
        fail "re-load generated corefile (incomplete note section)"
148
    }
149
    -re "Core was generated by .*$gdb_prompt $" {
150
        pass "re-load generated corefile"
151
    }
152
    -re ".*$gdb_prompt $" {
153
        fail "re-load generated corefile"
154
    }
155
    timeout {
156
        fail "re-load generated corefile (timeout)"
157
    }
158
}
159
 
160
# FIXME: now what can we test about the thread state?
161
# We do not know for certain that there should be at least
162
# three threads, because who knows what kind of many-to-one
163
# mapping various OS's may do?  Let's assume that there must
164
# be at least two threads:
165
 
166
gdb_test "info threads" ".*${nl}  2 ${horiz}${nl}\\* 1 .*" \
167
        "corefile contains at least two threads"
168
 
169
# One thread in the corefile should be in the "thread2" function.
170
 
171
gdb_test "info threads" ".* thread2 .*" \
172
        "a corefile thread is executing thread2"
173
 
174
# The thread2 thread should be marked as the current thread.
175
 
176
gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
177
        "thread2 is current thread in corefile"
178
 

powered by: WebSVN 2.1.0

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