aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-11-06 15:21:24 +0000
committerTom Tromey <tromey@redhat.com>2012-11-06 15:21:24 +0000
commit2d338fa948bca672c696ce23da905bddbbc374b4 (patch)
tree4c68d87ba638c046c890a6557c436f051f995edc
parent234fa27ce099ad5ef763209f8818fc2bf499f26c (diff)
downloadgdb-2d338fa948bca672c696ce23da905bddbbc374b4.zip
gdb-2d338fa948bca672c696ce23da905bddbbc374b4.tar.gz
gdb-2d338fa948bca672c696ce23da905bddbbc374b4.tar.bz2
* gdb.threads/gcore-thread.exp: Use gdb_gcore_cmd.
* gdb.python/py-strfns.exp (test_strfns_core_file): Use gdb_gcore_cmd. * gdb.cell/gcore.exp: Use gdb_gcore_cmd. * gdb.base/gcore.exp: Use gdb_gcore_cmd. * gdb.base/gcore-relro.exp: Use gdb_gcore_cmd. * gdb.base/gcore-buffer-overflow.exp: Use gdb_gcore_cmd. * gdb.base/auxv.exp: Use gdb_gcore_cmd. * gdb.arch/vsx-regs.exp: Use gdb_gcore_cmd. * gdb.arch/system-gcore.exp: Use gdb_gcore_cmd. * gdb.arch/pa-nullify.exp (test_core_bt): Use gdb_gcore_cmd. * lib/gdb.exp (gdb_gcore_cmd): New proc.
-rw-r--r--gdb/testsuite/ChangeLog15
-rw-r--r--gdb/testsuite/gdb.arch/pa-nullify.exp20
-rw-r--r--gdb/testsuite/gdb.arch/system-gcore.exp19
-rw-r--r--gdb/testsuite/gdb.arch/vsx-regs.exp20
-rw-r--r--gdb/testsuite/gdb.base/auxv.exp15
-rw-r--r--gdb/testsuite/gdb.base/gcore-buffer-overflow.exp15
-rw-r--r--gdb/testsuite/gdb.base/gcore-relro.exp13
-rw-r--r--gdb/testsuite/gdb.base/gcore.exp20
-rw-r--r--gdb/testsuite/gdb.cell/gcore.exp14
-rw-r--r--gdb/testsuite/gdb.python/py-strfns.exp17
-rw-r--r--gdb/testsuite/gdb.threads/gcore-thread.exp14
-rw-r--r--gdb/testsuite/lib/gdb.exp30
12 files changed, 63 insertions, 149 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 80aac5b..be01765 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,18 @@
+2012-11-06 Tom Tromey <tromey@redhat.com>
+
+ * gdb.threads/gcore-thread.exp: Use gdb_gcore_cmd.
+ * gdb.python/py-strfns.exp (test_strfns_core_file): Use
+ gdb_gcore_cmd.
+ * gdb.cell/gcore.exp: Use gdb_gcore_cmd.
+ * gdb.base/gcore.exp: Use gdb_gcore_cmd.
+ * gdb.base/gcore-relro.exp: Use gdb_gcore_cmd.
+ * gdb.base/gcore-buffer-overflow.exp: Use gdb_gcore_cmd.
+ * gdb.base/auxv.exp: Use gdb_gcore_cmd.
+ * gdb.arch/vsx-regs.exp: Use gdb_gcore_cmd.
+ * gdb.arch/system-gcore.exp: Use gdb_gcore_cmd.
+ * gdb.arch/pa-nullify.exp (test_core_bt): Use gdb_gcore_cmd.
+ * lib/gdb.exp (gdb_gcore_cmd): New proc.
+
2012-11-05 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork.exp (vfork_relations_in_info_inferiors): New
diff --git a/gdb/testsuite/gdb.arch/pa-nullify.exp b/gdb/testsuite/gdb.arch/pa-nullify.exp
index e3223d9..2ad3af6 100644
--- a/gdb/testsuite/gdb.arch/pa-nullify.exp
+++ b/gdb/testsuite/gdb.arch/pa-nullify.exp
@@ -107,26 +107,8 @@ gdb_test "stepi" "in main.*" "stepi to main"
proc gen_core { test } {
global gcorefile
- global gdb_prompt
- set gcore_works 0
- set escapedfilename [string_to_regexp $gcorefile]
-
- # gcore is not yet implemented for HPUX
- setup_xfail hppa*-*-hpux*
-
- gdb_test_multiple "gcore $gcorefile" "$test: gcore" {
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "$test: gcore"
- set gcore_works 1
- }
- -re "Undefined command.*$gdb_prompt $" {
- fail "$test: gcore (undefined command)"
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- fail "$test: gcore (can't create corefile)"
- }
- }
+ set gcore_works [gdb_gcore_cmd $gcorefile "$test: gcore"]
return $gcore_works
}
diff --git a/gdb/testsuite/gdb.arch/system-gcore.exp b/gdb/testsuite/gdb.arch/system-gcore.exp
index ab97f69..f631b45 100644
--- a/gdb/testsuite/gdb.arch/system-gcore.exp
+++ b/gdb/testsuite/gdb.arch/system-gcore.exp
@@ -95,23 +95,8 @@ set pre_corefile_local_array \
set pre_corefile_extern_array \
[capture_command_output "print extern_array" "$print_prefix"]
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
-
-set core_supported 0
-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
- "save a corefile" \
-{
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "save a corefile"
- global core_supported
- set core_supported 1
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported "save a corefile"
- global core_supported
- set core_supported 0
- }
-}
+set core_supported [gdb_gcore_cmd "${objdir}/${subdir}/gcore.test" \
+ "save a corefile"]
if {!$core_supported} {
return -1
diff --git a/gdb/testsuite/gdb.arch/vsx-regs.exp b/gdb/testsuite/gdb.arch/vsx-regs.exp
index d015787..5f23444 100644
--- a/gdb/testsuite/gdb.arch/vsx-regs.exp
+++ b/gdb/testsuite/gdb.arch/vsx-regs.exp
@@ -128,24 +128,8 @@ for {set i 0} {$i < 32} {incr i 1} {
# later when loading the core file (i.e., different register values for different
# vector register banks).
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/vsx-core.test]
-
-set core_supported 0
-
-gdb_test_multiple "gcore ${objdir}/${subdir}/vsx-core.test" \
- "Save a VSX-enabled corefile" \
-{
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "Save a VSX-enabled corefile"
- global core_supported
- set core_supported 1
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported "Save a VSX-enabled corefile"
- global core_supported
- set core_supported 0
- }
-}
+set core_supported [gdb_gcore_cmd "${objdir}/${subdir}/vsx-core.test" \
+ "Save a VSX-enabled corefile"]
# Now run the F32~F63/VR0~VR31 tests.
diff --git a/gdb/testsuite/gdb.base/auxv.exp b/gdb/testsuite/gdb.base/auxv.exp
index 16f12c7..0c7bac4 100644
--- a/gdb/testsuite/gdb.base/auxv.exp
+++ b/gdb/testsuite/gdb.base/auxv.exp
@@ -127,20 +127,7 @@ proc fetch_auxv {test} {
set live_data [fetch_auxv "info auxv on live process"]
# Now try gcore.
-set gcore_works 0
-set escapedfilename [string_to_regexp $gcorefile]
-gdb_test_multiple "gcore $gcorefile" "gcore" {
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "gcore"
- set gcore_works 1
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported "gcore"
- }
- -re "Undefined command: .*\[\r\n\]+$gdb_prompt $" {
- unsupported "gcore"
- }
-}
+set gcore_works [gdb_gcore_cmd "$gcorefile" "gcore"]
# Let the program continue and die.
gdb_test continue ".*Program received signal.*"
diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
index 7736bb8..13c3e75 100644
--- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
+++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
@@ -55,17 +55,4 @@ if { ! [ runto_main ] } then {
return -1
}
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore-buffer-overflow.test]
-
-set test "save a corefile"
-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore-buffer-overflow.test" $test {
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass $test
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported $test
- }
- eof {
- fail $test
- }
-}
+gdb_gcore_cmd "${objdir}/${subdir}/gcore-buffer-overflow.test" "save a corefile"
diff --git a/gdb/testsuite/gdb.base/gcore-relro.exp b/gdb/testsuite/gdb.base/gcore-relro.exp
index 5b8d6c7..b35126d 100644
--- a/gdb/testsuite/gdb.base/gcore-relro.exp
+++ b/gdb/testsuite/gdb.base/gcore-relro.exp
@@ -55,17 +55,8 @@ if ![runto lib] {
return -1
}
-set escapedfilename [string_to_regexp ${gcorefile}]
-
-set test "save a corefile"
-gdb_test_multiple "gcore ${gcorefile}" $test {
- -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" {
- pass $test
- }
- -re "Can't create a corefile\r\n$gdb_prompt $" {
- unsupported $test
- return -1
- }
+if {![gdb_gcore_cmd $gcorefile "save a corefile"]} {
+ return -1
}
# Now restart gdb and load the corefile.
diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index faa8fa7..a6db867 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -85,24 +85,8 @@ set pre_corefile_local_array \
set pre_corefile_extern_array \
[capture_command_output "print extern_array" "$print_prefix"]
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
-
-set core_supported 0
-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
- "save a corefile" \
-{
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "save a corefile"
- global core_supported
- set core_supported 1
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported "save a corefile"
- global core_supported
- set core_supported 0
- }
-}
-
+set core_supported [gdb_gcore_cmd "${objdir}/${subdir}/gcore.test" \
+ "save a corefile"]
if {!$core_supported} {
return -1
}
diff --git a/gdb/testsuite/gdb.cell/gcore.exp b/gdb/testsuite/gdb.cell/gcore.exp
index c05bc4a..c6c8d8c 100644
--- a/gdb/testsuite/gdb.cell/gcore.exp
+++ b/gdb/testsuite/gdb.cell/gcore.exp
@@ -69,21 +69,11 @@ delete_breakpoints
gdb_test "continue" ".*Aborted.*"
-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
-
-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
- "save a corefile" \
-{
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "save a corefile"
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported "save a corefile"
+if {![gdb_gcore_cmd "${objdir}/${subdir}/gcore.test" \
+ "save a corefile"]} {
return -1
- }
}
-
# Now restart gdb and load the corefile.
gdb_exit
gdb_start
diff --git a/gdb/testsuite/gdb.python/py-strfns.exp b/gdb/testsuite/gdb.python/py-strfns.exp
index 88d6cdf..ddc384f 100644
--- a/gdb/testsuite/gdb.python/py-strfns.exp
+++ b/gdb/testsuite/gdb.python/py-strfns.exp
@@ -67,20 +67,11 @@ proc test_strfns_core_file { } {
global objdir subdir gdb_prompt testfile
set filename "${objdir}/${subdir}/py-strfns.core"
- set escapedfilename [string_to_regexp $filename]
- gdb_test_multiple "gcore $filename" \
- "save a corefile" \
- {
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "save a corefile"
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported "save a corefile"
- # No use proceeding from here.
- return
- }
- }
+ if {![gdb_gcore_cmd "$filename" "save a corefile"]} {
+ # No use proceeding from here.
+ return
+ }
clean_restart $testfile
diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp
index 37eadd3..97189b9 100644
--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -91,20 +91,8 @@ delete_breakpoints
gdb_breakpoint "thread2"
gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
-set escapedfilename [string_to_regexp $corefile]
# Drop corefile
-set core_supported 0
-gdb_test_multiple "gcore $corefile" "save a corefile" \
-{
- -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
- pass "save a corefile"
- global core_supported
- set core_supported 1
- }
- -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
- unsupported "save a corefile"
- }
-}
+set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"]
if {!$core_supported} {
return -1
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a972045..16e8b54 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3026,6 +3026,36 @@ proc gdb_load_cmd { args } {
return -1
}
+# Invoke "gcore". CORE is the name of the core file to write. TEST
+# is the name of the test case. This will return 1 if the core file
+# was created, 0 otherwise. If this fails to make a core file because
+# this configuration of gdb does not support making core files, it
+# will call "unsupported", not "fail". However, if this fails to make
+# a core file for some other reason, then it will call "fail".
+
+proc gdb_gcore_cmd {core test} {
+ global gdb_prompt
+
+ set result 0
+ gdb_test_multiple "gcore $core" $test {
+ -re "Saved corefile .*\[\r\n\]+$gdb_prompt $" {
+ pass $test
+ set result 1
+ }
+
+ -re "Undefined command.*$gdb_prompt $" {
+ unsupported $test
+ verbose -log "'gcore' command undefined in gdb_gcore_cmd"
+ }
+
+ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
+ unsupported $test
+ }
+ }
+
+ return $result
+}
+
# Return the filename to download to the target and load on the target
# for this shared library. Normally just LIBNAME, unless shared libraries
# for this target have separate link and load images.