aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2004-09-23 20:48:04 +0000
committerAndrew Cagney <cagney@redhat.com>2004-09-23 20:48:04 +0000
commit4bb3667f25d7be37190529c1952b96f12a3a8828 (patch)
tree2dd39705c4fa8a794a4f1cbcf1a93b92bb188144
parent60fe1a5107bbccef456d88b8e6985ccced32165a (diff)
downloadgdb-4bb3667f25d7be37190529c1952b96f12a3a8828.zip
gdb-4bb3667f25d7be37190529c1952b96f12a3a8828.tar.gz
gdb-4bb3667f25d7be37190529c1952b96f12a3a8828.tar.bz2
2004-09-23 Andrew Cagney <cagney@gnu.org>
* gdb.base/bigcore.exp: Replace the code that creates a corefile from a separate process with code that creates a corefile by making the inferior dump core.
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.base/bigcore.exp117
2 files changed, 71 insertions, 52 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 53b2b57..9765913 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-23 Andrew Cagney <cagney@gnu.org>
+
+ * gdb.base/bigcore.exp: Replace the code that creates a corefile
+ from a separate process with code that creates a corefile by
+ making the inferior dump core.
+
2004-09-23 Mark Kettenis <kettenis@gnu.org>
* gdb.base/sigstep.exp: Avoid comments withing gdb_test_multiple
diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp
index 0a55eae..c04f232 100644
--- a/gdb/testsuite/gdb.base/bigcore.exp
+++ b/gdb/testsuite/gdb.base/bigcore.exp
@@ -65,36 +65,6 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
-# Create a core file named "TESTFILE.corefile" rather than just
-# "core", to avoid problems with sys admin types that like to
-# regularly prune all files named "core" from the system.
-
-# Some systems append "core" to the name of the program; others append
-# the name of the program to "core"; still others (like Linux, as of
-# May 2003) create cores named "core.PID". In the latter case, we
-# could have many core files lying around, and it may be difficult to
-# tell which one is ours, so let's run the program in a subdirectory.
-
-set found 0
-set coredir "${objdir}/${subdir}/coredir.[getpid]"
-file mkdir $coredir
-catch "system \"(cd ${coredir}; ${binfile}; true) >/dev/null 2>&1\""
-set names [glob -nocomplain -directory $coredir *core*]
-if {[llength $names] == 1} {
- set file [file join $coredir [lindex $names 0]]
- remote_exec build "mv $file $corefile"
- set found 1
-}
-
-# Try to clean up after ourselves.
-remote_file build delete [file join $coredir coremmap.data]
-remote_exec build "rmdir $coredir"
-
-if { $found == 0 } {
- warning "can't generate a core file - core tests suppressed - check ulimit -c"
- return 0
-}
-
# Run GDB on the bigcore program up-to where it will dump core.
gdb_exit
@@ -113,28 +83,6 @@ gdb_test "tbreak $print_core_line"
gdb_test continue ".*print_string.*"
gdb_test next ".*0 = 0.*"
-# Check that the corefile is plausibly large enough. We're trying to
-# detect the case where the operating system has truncated the file
-# just before signed wraparound. TCL, unfortunately, has a similar
-# problem - so use catch. It can handle the "bad" size but not necessarily
-# the "good" one. And we must use GDB for the comparison, similarly.
-
-if {[catch {file size $corefile} core_size] == 0} {
- set core_ok 0
- gdb_test_multiple "print bytes_allocated < $core_size" "check core size" {
- -re " = 1\r\n$gdb_prompt $" {
- pass "check core size"
- set core_ok 1
- }
- -re " = 0\r\n$gdb_prompt $" {
- xfail "check core size (system does not support large corefiles)"
- }
- }
- if {$core_ok == 0} {
- return 0
- }
-}
-
# Traverse part of bigcore's linked list of memory chunks (forward or
# backward), saving each chunk's address.
@@ -170,6 +118,71 @@ proc extract_heap { dir } {
set next_heap [extract_heap next]
set prev_heap [extract_heap prev]
+# Now create a core dump
+
+# Rename the core file to "TESTFILE.corefile" rather than just "core",
+# to avoid problems with sys admin types that like to regularly prune
+# all files named "core" from the system.
+
+# Some systems append "core" to the name of the program; others append
+# the name of the program to "core"; still others (like Linux, as of
+# May 2003) create cores named "core.PID".
+
+# Save the process ID. Some systems dump the core into core.PID.
+set test "grab pid"
+gdb_test_multiple "info program" $test {
+ -re "child process (\[0-9\]+).*$gdb_prompt $" {
+ set inferior_pid $expect_out(1,string)
+ pass $test
+ }
+ -re "$gdb_prompt $" {
+ set inferior_pid unknown
+ pass $test
+ }
+}
+
+# Dump core using SIGABRT
+set oldtimeout $timeout
+set timeout 600
+gdb_test "signal SIGABRT" "Program terminated with signal SIGABRT, .*"
+
+# Find the corefile
+set file ""
+foreach pat [list core.${inferior_pid} ${testfile}.core core] {
+ set names [glob -nocomplain $pat]
+ if {[llength $names] == 1} {
+ set file [lindex $names 0]
+ remote_exec build "mv $file $corefile"
+ break
+ }
+}
+
+if { $file == "" } {
+ untested "Can't generate a core file"
+ return 0
+}
+
+# Check that the corefile is plausibly large enough. We're trying to
+# detect the case where the operating system has truncated the file
+# just before signed wraparound. TCL, unfortunately, has a similar
+# problem - so use catch. It can handle the "bad" size but not
+# necessarily the "good" one. And we must use GDB for the comparison,
+# similarly.
+
+set core_ok 0
+if {[catch {file size $corefile} core_size] == 0} {
+ gdb_test_multiple "print bytes_allocated < $core_size" "check core size" {
+ -re " = 1\r\n$gdb_prompt $" {
+ pass "check core size"
+ set core_ok 1
+ }
+ }
+}
+if {$core_ok == 0} {
+ untested "check core size (system does not support large corefiles)"
+ return 0
+}
+
# Now load up that core file
set test "load corefile"