From: Tom Tromey Date: Tue, 6 Nov 2012 15:21:24 +0000 (+0000) Subject: * gdb.threads/gcore-thread.exp: Use gdb_gcore_cmd. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2d338fa948bca672c696ce23da905bddbbc374b4;p=binutils-gdb.git * 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. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 80aac5bd379..be01765e44a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,18 @@ +2012-11-06 Tom Tromey + + * 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 * 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 e3223d98000..2ad3af680bc 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 ab97f6969e5..f631b458401 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 d015787763a..5f234444be0 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 16f12c7f93d..0c7bac4a505 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 7736bb8b578..13c3e75a33c 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 5b8d6c77eb6..b35126db1a9 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 faa8fa7f520..a6db867f922 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 c05bc4ab525..c6c8d8c768a 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 88d6cdf8134..ddc384f4a69 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 37eadd3864b..97189b9b055 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 a9720450909..16e8b54fc4b 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.