* gdb.arch/system-gcore.exp: Use it.
* gdb.arch/vsx-regs.exp: Ditto.
* gdb.base/gcore.exp: Ditto.
* gdb.threads/gcore-thread.exp: Ditto.
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".
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
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" {
# 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.
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} {
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
}
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" {
# 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
}
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.