1 # Copyright
2002, 2003, 2004 Free Software Foundation
, Inc.
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.
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.
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.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-gdb@prep.ai.mit.edu
20 # This file was written by Michael Snyder
(msnyder@redhat.com
)
21 # This is a test
for the gdb command
"generate-core-file".
30 # Single
-threaded test case
31 set testfile
"pthreads"
32 set srcfile $
{testfile
}.c
33 set binfile $
{objdir
}/$
{subdir
}/gcore
-$
{testfile
}
35 if [istarget
"*-*-linux"] then {
36 set target_cflags
"-D_MIT_POSIX_THREADS"
41 if {[gdb_compile_pthreads
"${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
45 # Now we can proceed with the real testing.
47 # Start with a fresh gdb.
51 gdb_reinitialize_dir $srcdir
/$subdir
54 # regexp
for "horizontal" text (i.e. doesn't include newline or
56 set horiz
"\[^\n\r\]*"
63 send_gdb
"help gcore\n"
65 -re
"Undefined command: .gcore.*$gdb_prompt $" {
66 # gcore command not supported
-- nothing to test here.
67 unsupported
"gdb does not support gcore on this target"
70 -re
"Save a core file .*$gdb_prompt $" {
73 -re
".*$gdb_prompt $" {
77 fail
"help gcore (timeout)"
81 if { ! [ runto_main
] } then {
82 gdb_suppress_entire_file
"Run to main failed, so all tests in this file will automatically fail."
85 send_gdb
"info threads\n"
87 -re
".* main .*$gdb_prompt $" {
88 # OK
, threads are supported.
90 -re
"${nl}$gdb_prompt $" {
91 unsupported
"gdb does not support threads on this target"
96 # Make sure thread
1 is running
98 gdb_breakpoint
"thread1"
99 gdb_test
"continue" "Continuing.*Breakpoint.* thread1 .*" "thread 1 is running"
101 # Make sure thread
2 is running
103 gdb_breakpoint
"thread2"
104 gdb_test
"continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
106 set escapedfilename
[string_to_regexp $
{objdir
}/$
{subdir
}/gcore.test
]
108 gdb_test_multiple
"gcore ${objdir}/${subdir}/gcore.test" \
111 -re
"Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
112 pass
"save a corefile"
113 global core_supported
116 -re
"Can't create a corefile\[\r\n\]+$gdb_prompt $" {
117 unsupported
"save a corefile"
118 global core_supported
123 global core_supported
124 if {!$core_supported
} {
128 # Now restart gdb and
load the corefile.
131 gdb_reinitialize_dir $srcdir
/$subdir
134 send_gdb
"core ${objdir}/${subdir}/gcore.test\n"
136 -re
".* is not a core dump:.*$gdb_prompt $" {
137 fail
"re-load generated corefile (bad file format)"
138 # No use proceeding from here.
141 -re
".*: No such file or directory.*$gdb_prompt $" {
142 fail
"re-load generated corefile (file not found)"
143 # No use proceeding from here.
146 -re
".*Couldn't find .* registers in core file.*$gdb_prompt $" {
147 fail
"re-load generated corefile (incomplete note section)"
149 -re
"Core was generated by .*$gdb_prompt $" {
150 pass
"re-load generated corefile"
152 -re
".*$gdb_prompt $" {
153 fail
"re-load generated corefile"
156 fail
"re-load generated corefile (timeout)"
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
:
166 gdb_test
"info threads" ".*${nl} 2 ${horiz}${nl}\\* 1 .*" \
167 "corefile contains at least two threads"
169 # One thread in the corefile should be in the
"thread2" function.
171 gdb_test
"info threads" ".* thread2 .*" \
172 "a corefile thread is executing thread2"
174 # The thread2 thread should be marked as the current thread.
176 gdb_test
"info threads" ".*${nl}\\* ${horiz} thread2 .*" \
177 "thread2 is current thread in corefile"