aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.arch/system-gcore.exp32
-rw-r--r--gdb/testsuite/gdb.arch/vsx-regs.exp33
-rw-r--r--gdb/testsuite/gdb.base/gcore.exp26
-rw-r--r--gdb/testsuite/gdb.threads/gcore-thread.exp33
-rw-r--r--gdb/testsuite/lib/gdb.exp43
6 files changed, 70 insertions, 103 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4965164..b41b135 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2013-05-06 Doug Evans <dje@google.com>
+ * lib/gdb.exp (gdb_core_cmd): New function.
+ * gdb.arch/system-gcore.exp: Use it.
+ * gdb.arch/vsx-regs.exp: Ditto.
+ * gdb.base/gcore.exp: Ditto.
+ * gdb.threads/gcore-thread.exp: Ditto.
+
* gdb.reverse/shr.h: New file.
* gdb.reverse/shr1.c: New file.
* gdb.reverse/shr2.c: #include "shr.h".
diff --git a/gdb/testsuite/gdb.arch/system-gcore.exp b/gdb/testsuite/gdb.arch/system-gcore.exp
index 08551e0..e7586da 100644
--- a/gdb/testsuite/gdb.arch/system-gcore.exp
+++ b/gdb/testsuite/gdb.arch/system-gcore.exp
@@ -95,8 +95,8 @@ set pre_corefile_local_array \
set pre_corefile_extern_array \
[capture_command_output "print extern_array" "$print_prefix"]
-set core_supported [gdb_gcore_cmd "${objdir}/${subdir}/gcore.test" \
- "save a corefile"]
+set corefile "${objdir}/${subdir}/gcore.test"
+set core_supported [gdb_gcore_cmd $corefile "save a corefile"]
if {!$core_supported} {
return -1
@@ -108,30 +108,10 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-send_gdb "core ${objdir}/${subdir}/gcore.test\n"
-gdb_expect {
- -re ".* is not a core dump:.*$gdb_prompt $" {
- fail "re-load generated corefile (bad file format)"
- # No use proceeding from here.
- return;
- }
- -re ".*: No such file or directory.*$gdb_prompt $" {
- fail "re-load generated corefile (file not found)"
- # No use proceeding from here.
- return;
- }
- -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
- fail "re-load generated corefile (incomplete note section)"
- }
- -re "Core was generated by .*$gdb_prompt $" {
- pass "re-load generated corefile"
- }
- -re ".*$gdb_prompt $" {
- fail "re-load generated corefile"
- }
- timeout {
- fail "re-load generated corefile (timeout)"
- }
+set core_reloaded [gdb_core_cmd $corefile "re-load generated corefile"]
+if { $core_reloaded == -1 } {
+ # No use proceeding from here.
+ return
}
gdb_test_sequence "where" "where in corefile" {
diff --git a/gdb/testsuite/gdb.arch/vsx-regs.exp b/gdb/testsuite/gdb.arch/vsx-regs.exp
index 7b27ac7..0ab111c 100644
--- a/gdb/testsuite/gdb.arch/vsx-regs.exp
+++ b/gdb/testsuite/gdb.arch/vsx-regs.exp
@@ -128,8 +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 core_supported [gdb_gcore_cmd "${objdir}/${subdir}/vsx-core.test" \
- "Save a VSX-enabled corefile"]
+set corefile "${objdir}/${subdir}/vsx-core.test"
+set core_supported [gdb_gcore_cmd "$corefile" "Save a VSX-enabled corefile"]
# Now run the F32~F63/VR0~VR31 tests.
@@ -168,31 +168,10 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-gdb_test_multiple "core ${objdir}/${subdir}/vsx-core.test" \
- "re-load generated corefile" \
-{
- -re ".* is not a core dump:.*$gdb_prompt $" {
- fail "re-load generated corefile (bad file format)"
- # No use proceeding from here.
- return;
- }
- -re ".*: No such file or directory.*$gdb_prompt $" {
- fail "re-load generated corefile (file not found)"
- # No use proceeding from here.
- return;
- }
- -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
- fail "re-load generated corefile (incomplete note section)"
- }
- -re "Core was generated by .*$gdb_prompt $" {
- pass "re-load generated corefile"
- }
- -re ".*$gdb_prompt $" {
- fail "re-load generated corefile"
- }
- timeout {
- fail "re-load generated corefile (timeout)"
- }
+set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
+if { $core_loaded == -1 } {
+ # No use proceeding from here.
+ return
}
for {set i 0} {$i < 32} {incr i 1} {
diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index 33528fb..6e3a5de 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -85,8 +85,8 @@ set pre_corefile_local_array \
set pre_corefile_extern_array \
[capture_command_output "print extern_array" "$print_prefix"]
-set core_supported [gdb_gcore_cmd "${objdir}/${subdir}/gcore.test" \
- "save a corefile"]
+set corefile "${objdir}/${subdir}/gcore.test"
+set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"]
if {!$core_supported} {
return -1
}
@@ -97,24 +97,10 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \
- "re-load generated corefile" {
- -re ".* is not a core dump:.*$gdb_prompt $" {
- fail "re-load generated corefile (bad file format)"
- # No use proceeding from here.
- return;
- }
- -re ".*: No such file or directory.*$gdb_prompt $" {
- fail "re-load generated corefile (file not found)"
- # No use proceeding from here.
- return;
- }
- -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
- fail "re-load generated corefile (incomplete note section)"
- }
- -re "Core was generated by .*$gdb_prompt $" {
- pass "re-load generated corefile"
- }
+set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
+if { $core_loaded == -1 } {
+ # No use proceeding from here.
+ return
}
gdb_test_sequence "where" "where in corefile" {
diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp
index 31714c8..b01ecb7 100644
--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -125,37 +125,10 @@ if {"$core0file" != ""} {
# Now restart gdb and load the corefile.
clean_restart ${testfile}
-proc load_core { corefile } {
- global gdb_prompt
- global libthread_db_seen
-
- gdb_test_multiple "core $corefile" \
- "re-load generated corefile" {
- -re "\\\[Thread debugging using \[^ \r\n\]* enabled\\\]\r\n" {
- exp_continue
- }
- -re " is not a core dump:.*\r\n$gdb_prompt $" {
- fail "re-load generated corefile (bad file format)"
- # No use proceeding from here.
- return 0
- }
- -re ": No such file or directory.*\r\n$gdb_prompt $" {
- fail "re-load generated corefile (file not found)"
- # No use proceeding from here.
- return 0
- }
- -re "Couldn't find .* registers in core file.*\r\n$gdb_prompt $" {
- fail "re-load generated corefile (incomplete note section)"
- }
- -re "Core was generated by .*\r\n$gdb_prompt $" {
- pass "re-load generated corefile"
- }
- }
- return 1
-}
-
foreach name { corefile core0file } { with_test_prefix $name {
- if ![load_core [subst $$name]] {
+ set core_loaded [gdb_core_cmd [subst $$name] "re-load generated corefile"]
+ if { $core_loaded == -1 } {
+ # No use proceeding from here.
continue
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 06e1226..b8a7cf8 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3176,6 +3176,49 @@ proc gdb_gcore_cmd {core test} {
return $result
}
+# Load core file CORE. TEST is the name of the test case.
+# This will record a pass/fail for loading the core file.
+# Returns:
+# 1 - core file is successfully loaded
+# 0 - core file loaded but has a non fatal error
+# -1 - core file failed to load
+
+proc gdb_core_cmd { core test } {
+ global gdb_prompt
+
+ gdb_test_multiple "core $core" "re-load generated corefile" {
+ -re "\\\[Thread debugging using \[^ \r\n\]* enabled\\\]\r\n" {
+ exp_continue
+ }
+ -re " is not a core dump:.*\r\n$gdb_prompt $" {
+ fail "re-load generated corefile (bad file format)"
+ return -1
+ }
+ -re ": No such file or directory.*\r\n$gdb_prompt $" {
+ fail "re-load generated corefile (file not found)"
+ return -1
+ }
+ -re "Couldn't find .* registers in core file.*\r\n$gdb_prompt $" {
+ fail "re-load generated corefile (incomplete note section)"
+ return 0
+ }
+ -re "Core was generated by .*\r\n$gdb_prompt $" {
+ pass "re-load generated corefile"
+ return 1
+ }
+ -re ".*$gdb_prompt $" {
+ fail "re-load generated corefile"
+ return -1
+ }
+ timeout {
+ fail "re-load generated corefile (timeout)"
+ return -1
+ }
+ }
+ fail "unsupported output from 'core' command"
+ return -1
+}
+
# 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.