From 02506ff1ad948dc6cd941c91ea3c3aa28831f03d Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Thu, 22 Oct 2009 19:58:26 +0000 Subject: [PATCH] 2009-10-19 Michael Snyder * gdb.reverse/break-precsave.exp: New test. * gdb.reverse/consecutive-precsave.exp: Ditto. * gdb.reverse/finish-precsave.exp: Ditto. * gdb.reverse/i386-precsave.exp: Ditto. * gdb.reverse/machinestate-precsave.exp: Ditto. * gdb.reverse/sigall-precsave.exp: Ditto. * gdb.reverse/solilb-precsave.exp: Ditto. * gdb.reverse/step-precsave.exp: Ditto. * gdb.reverse/until-precsave.exp: Ditto. * gdb.reverse/watch-precsave.exp: Ditto. --- gdb/testsuite/ChangeLog | 13 + gdb/testsuite/gdb.reverse/break-precsave.exp | 107 +++++ .../gdb.reverse/consecutive-precsave.exp | 137 ++++++ gdb/testsuite/gdb.reverse/finish-precsave.exp | 250 ++++++++++ gdb/testsuite/gdb.reverse/i386-precsave.exp | 306 ++++++++++++ .../gdb.reverse/machinestate-precsave.exp | 256 ++++++++++ gdb/testsuite/gdb.reverse/sigall-precsave.exp | 439 ++++++++++++++++++ gdb/testsuite/gdb.reverse/solib-precsave.exp | 143 ++++++ gdb/testsuite/gdb.reverse/step-precsave.exp | 273 +++++++++++ gdb/testsuite/gdb.reverse/until-precsave.exp | 146 ++++++ gdb/testsuite/gdb.reverse/watch-precsave.exp | 142 ++++++ 11 files changed, 2212 insertions(+) create mode 100644 gdb/testsuite/gdb.reverse/break-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/consecutive-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/finish-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/i386-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/machinestate-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/sigall-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/solib-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/step-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/until-precsave.exp create mode 100644 gdb/testsuite/gdb.reverse/watch-precsave.exp diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9d6113c570d..6f4099fdc1a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2009-10-22 Michael Snyder + + * gdb.reverse/break-precsave.exp: New test. + * gdb.reverse/consecutive-precsave.exp: Ditto. + * gdb.reverse/finish-precsave.exp: Ditto. + * gdb.reverse/i386-precsave.exp: Ditto. + * gdb.reverse/machinestate-precsave.exp: Ditto. + * gdb.reverse/sigall-precsave.exp: Ditto. + * gdb.reverse/solilb-precsave.exp: Ditto. + * gdb.reverse/step-precsave.exp: Ditto. + * gdb.reverse/until-precsave.exp: Ditto. + * gdb.reverse/watch-precsave.exp: Ditto. + 2009-10-22 Michael Snyder * gdb.reverse/consecutive-reverse.exp: Substitute gdb_test_multiple diff --git a/gdb/testsuite/gdb.reverse/break-precsave.exp b/gdb/testsuite/gdb.reverse/break-precsave.exp new file mode 100644 index 00000000000..e4aa00bd5b3 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/break-precsave.exp @@ -0,0 +1,107 @@ +# Copyright 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the GDB testsuite. It tests reverse debugging +# with breakpoints in a process record logfile. + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +set testfile "break-reverse" +set srcfile ${testfile}.c + +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { + return -1 +} + +set foo_location [gdb_get_line_number "break in foo" ] +set bar_location [gdb_get_line_number "break in bar" ] +set main_location [gdb_get_line_number "break in main"] +set end_location [gdb_get_line_number "end of main" ] + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +gdb_test "break $end_location" \ + "Breakpoint $decimal at .*/$srcfile, line $end_location\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save break.precsave" \ + "Saved core file break.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore break.precsave" \ + "Program terminated with signal .*" \ + "reload precord save file" + +gdb_test "break foo" \ + "Breakpoint $decimal at .* line $foo_location\." \ + "set breakpoint on foo" + +gdb_test "break bar" \ + "Breakpoint $decimal at .* line $bar_location\." \ + "set breakpoint on bar" + +gdb_continue_to_breakpoint "foo" ".*/$srcfile:$foo_location.*" +gdb_continue_to_breakpoint "bar" ".*/$srcfile:$bar_location.*" +gdb_test_multiple "continue" "go to end of main forward" { + -re ".*Breakpoint $decimal,.*/$srcfile:$end_location.*$gdb_prompt $" { + pass "go to end of main forward" + } + -re "No more reverse-execution history.* end of main .*$gdb_prompt $" { + pass "go to end of main forward" + } +} + +# FIXME 'set exec-dir' command should give some output so we can test. +gdb_test "set exec-direction reverse" "" "set reverse" + +gdb_continue_to_breakpoint "bar backward" ".*/$srcfile:$bar_location.*" +gdb_continue_to_breakpoint "foo backward" ".*/$srcfile:$foo_location.*" + +gdb_test_multiple "continue" "main backward" { + -re ".*Breakpoint $decimal,.*/$srcfile:$main_location.*$gdb_prompt $" { + pass "main backward" + } + -re "No more reverse-execution history.* break in main .*$gdb_prompt $" { + pass "main backward" + } +} + +gdb_test "set exec-direction forward" "" "set forward" + +gdb_continue_to_breakpoint "foo" ".*/$srcfile:$foo_location.*" +gdb_continue_to_breakpoint "bar" ".*/$srcfile:$bar_location.*" + +gdb_test_multiple "continue" "end of record log" { + -re ".*Breakpoint $decimal,.*/$srcfile:$end_location.*$gdb_prompt $" { + pass "end of record log" + } + -re "No more reverse-execution history.* end of main .*$gdb_prompt $" { + pass "end of record log" + } +} diff --git a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp new file mode 100644 index 00000000000..01c0ec29e59 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp @@ -0,0 +1,137 @@ +# Copyright 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the GDB testsuite. It tests stepping over +# consecutive instructions in a process record logfile. + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +set testfile "consecutive-reverse" +set srcfile ${testfile}.c + +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { + return -1 +} + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +set end_location [gdb_get_line_number "end of main" ] +gdb_test "break $end_location" \ + "Breakpoint $decimal at .*/$srcfile, line $end_location\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save consecutive.precsave" \ + "Saved core file consecutive.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore consecutive.precsave" \ + "Program terminated with signal .*" \ + "reload precord save file" + +gdb_breakpoint foo +gdb_test "continue" "Breakpoint $decimal, foo .*" \ + "continue to breakpoint in foo" + +set foo1_addr 0 +set foo2_addr 0 +set stop_addr 0 + +send_gdb "x /2i \$pc\n" +gdb_expect { + global hex + global foo1_addr + global foo2_addr + global gdb_prompt + + -re "($hex).*\[\r\n\]+($hex).*$gdb_prompt $" { + set foo1_addr $expect_out(1,string) + set foo2_addr $expect_out(2,string) + pass "get breakpoint address for foo" + } + -re ".*$gdb_prompt $" { + fail "get breakpoint address for foo" + return 0; + } + timeout { + fail "get breakpoint address for foo (timeout)" + return 0; + } +} + +gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \ + "set bp, 2nd instr" + +set testmsg "stopped at bp, 2nd instr" +gdb_test_multiple "step" $testmsg { + -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { + set stop_addr $expect_out(1,string) + if [eval expr "$foo2_addr == $stop_addr"] then { + pass "stopped at bp, 2nd instr" + } else { + fail "stopped at bp, 2nd instr (wrong address)" + } + } +} + +### +### +### + +# Set reverse execution direction +# FIXME: command needs to acknowledge, so we can test if it succeeded. + +gdb_test "set exec-dir reverse" "" "set reverse execution" + +# Now step backward and hope to hit the first breakpoint. + +set test_msg "stopped at bp in reverse, 1st instr" +gdb_test_multiple "step" "$test_msg" { + -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { + set stop_addr $expect_out(1,string) + if [eval expr "$foo1_addr == $stop_addr"] then { + pass "$test_msg" + } else { + fail "$test_msg (wrong address)" + } + } + -re "Breakpoint $decimal, foo.*$gdb_prompt $" { + send_gdb "print \$pc == $foo1_addr\n" + gdb_expect { + -re "$decimal = 1\[\r\n\]+$gdb_prompt $" { + pass "$test_msg" + } + -re "$decimal = 0\[\r\n\]+$gdb_prompt $" { + fail "$test_msg (wrong address)" + } + } + } + -re ".*$gdb_prompt $" { + fail "$test_msg" + } +} diff --git a/gdb/testsuite/gdb.reverse/finish-precsave.exp b/gdb/testsuite/gdb.reverse/finish-precsave.exp new file mode 100644 index 00000000000..14bc2231078 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/finish-precsave.exp @@ -0,0 +1,250 @@ +# Copyright 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the GDB testsuite. It tests 'finish' with +# reverse debugging. + +if ![target_info exists gdb,can_reverse] { + return +} + +set testfile "finish-reverse" +set srcfile ${testfile}.c + +if { [prepare_for_testing $testfile.exp "$testfile" $srcfile] } { + return -1 +} + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +# Run until end, then save execution log. + +set breakloc [gdb_get_line_number "end of main" "$srcfile"] +gdb_test "break $breakloc" \ + "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save finish.precsave" \ + "Saved core file finish.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore finish.precsave" \ + "Program terminated with signal .*" \ + "reload precord save file" + +# Test finish from void func + +set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"] +gdb_test "break void_func" \ + "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \ + "set breakpoint on void_func" +gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*" + +set test_msg "finish from void_func" +gdb_test_multiple "finish" "$test_msg" { + -re " call to void_func .*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } + -re " void_checkpoint .*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test finish from char func + +set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"] +gdb_test "break char_func" \ + "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \ + "set breakpoint on char_func" +gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*" + +set test_msg "finish from char_func" +gdb_test_multiple "finish" "$test_msg" { + -re " void_checkpoint .*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } + -re " char_checkpoint .*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test finish from short func + +set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"] +gdb_test "break short_func" \ + "Breakpoint $decimal at .* line $breakloc\." \ + "set breakpoint on short_func" +gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*" + +set test_msg "finish from short_func" +gdb_test_multiple "finish" "$test_msg" { + -re " char_checkpoint .*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } + -re " short_checkpoint .*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test finish from int func + +set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"] +gdb_test "break int_func" \ + "Breakpoint $decimal at .* line $breakloc\." \ + "set breakpoint on int_func" +gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*" + +set test_msg "finish from int_func" +gdb_test_multiple "finish" "$test_msg" { + -re " short_checkpoint .*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } + -re " int_checkpoint .*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test finish from long func + +set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"] +gdb_test "break long_func" \ + "Breakpoint $decimal at .* line $breakloc\." \ + "set breakpoint on long_func" +gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*" + +set test_msg "finish from long_func" +gdb_test_multiple "finish" "$test_msg" { + -re " int_checkpoint .*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } + -re " long_checkpoint .*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test finish from long long func + +set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"] +gdb_test "break long_long_func" \ + "Breakpoint $decimal at .* line $breakloc\." \ + "set breakpoint on long_long_func" +gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*" + +set test_msg "finish from long_long_func" +gdb_test_multiple "finish" "$test_msg" { + -re " long_checkpoint .*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } + -re " long_long_checkpoint .*$gdb_prompt $" { + pass "$test_msg" + } +} + + +### +### +### + +# Now switch to reverse +gdb_test "set exec-dir reverse" "" "set reverse execution" + +# Test reverse finish from long long func + +set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"] +gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*" + +set test_msg "reverse finish from long_long_func" +gdb_test_multiple "finish" "$test_msg" { + -re ".* long_checkpoint.*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test reverse finish from long func + +set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"] +gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*" + +set test_msg "reverse finish from long_func" +gdb_test_multiple "finish" "$test_msg" { + -re ".* int_checkpoint.*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test reverse finish from int func + +set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"] +gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*" + +set test_msg "reverse finish from int_func" +gdb_test_multiple "finish" "$test_msg" { + -re ".* short_checkpoint.*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test reverse finish from short func + +set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"] +gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*" + +set test_msg "reverse finish from short_func" +gdb_test_multiple "finish" "$test_msg" { + -re ".* char_checkpoint.*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test reverse finish from char func + +set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"] +gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*" + +set test_msg "reverse finish from char_func" +gdb_test_multiple "finish" "$test_msg" { + -re ".* void_checkpoint.*$gdb_prompt $" { + pass "$test_msg" + } +} + +# Test reverse finish from void func + +set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"] +gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*" + +set test_msg "reverse finish from void_func" +gdb_test_multiple "finish" "$test_msg" { + -re ".* call to void_func.*$gdb_prompt $" { + pass "$test_msg" + } +} diff --git a/gdb/testsuite/gdb.reverse/i386-precsave.exp b/gdb/testsuite/gdb.reverse/i386-precsave.exp new file mode 100644 index 00000000000..cf8295f803b --- /dev/null +++ b/gdb/testsuite/gdb.reverse/i386-precsave.exp @@ -0,0 +1,306 @@ +# Copyright 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +# +# This test tests some i386 general instructions with a precord dumpfile. +# + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if ![istarget "i?86-*linux*"] then { + verbose "Skipping i386 reverse tests." + return +} + +set testfile "i386-reverse" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +# some targets have leading underscores on assembly symbols. +# TODO: detect this automatically +set additional_flags "" +if [istarget "i?86-*-cygwin*"] then { + set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\"" +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } { + untested i386-reverse + return -1 +} + +set end_of_main [gdb_get_line_number " end of main "] +set end_of_inc_dec_tests [gdb_get_line_number " end inc_dec_tests "] + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +global hex +global decimal + +gdb_test "break $end_of_main" \ + "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save i386.precsave" \ + "Saved core file i386.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore i386.precsave" \ + "Program terminated with signal .*" \ + "reload precord save file" + +gdb_test "step" "inc .eax.*" "step to inc eax 1st time" +send_gdb "info reg eax\n" +gdb_expect { + -re "eax *($hex)\t.*$gdb_prompt " { + set preinc_eax $expect_out(1,string) + } +} + +gdb_test "step" "inc .ecx.*" "step to inc ecx 1st time" +send_gdb "info reg ecx\n" +gdb_expect { + -re "ecx *($hex)\t.*$gdb_prompt " { + set preinc_ecx $expect_out(1,string) + } +} + +gdb_test "step" "inc .edx.*" "step to inc edx 1st time" +send_gdb "info reg edx\n" +gdb_expect { + -re "edx *($hex)\t.*$gdb_prompt " { + set preinc_edx $expect_out(1,string) + } +} + +gdb_test "step" "inc .ebx.*" "step to inc ebx 1st time" +send_gdb "info reg ebx\n" +gdb_expect { + -re "ebx *($hex)\t.*$gdb_prompt " { + set preinc_ebx $expect_out(1,string) + } +} + +gdb_test "step" "inc .esp.*" "step to inc esp 1st time" +send_gdb "info reg esp\n" +gdb_expect { + -re "esp *($hex)\t.*$gdb_prompt " { + set preinc_esp $expect_out(1,string) + } +} + +gdb_test "step" "inc .ebp.*" "step to inc ebp 1st time" +send_gdb "info reg ebp\n" +gdb_expect { + -re "ebp *($hex)\t.*$gdb_prompt " { + set preinc_ebp $expect_out(1,string) + } +} + +gdb_test "step" "inc .esi.*" "step to inc esi 1st time" +send_gdb "info reg esi\n" +gdb_expect { + -re "esi *($hex)\t.*$gdb_prompt " { + set preinc_esi $expect_out(1,string) + } +} + +gdb_test "step" "inc .edi.*" "step to inc edi 1st time" +send_gdb "info reg edi\n" +gdb_expect { + -re "edi *($hex)\t.*$gdb_prompt " { + set preinc_edi $expect_out(1,string) + } +} + +gdb_test "step" "dec .eax.*" "step to dec eax 1st time" +send_gdb "info reg eax\n" +gdb_expect { + -re "eax *($hex)\t.*$gdb_prompt " { + set predec_eax $expect_out(1,string) + } +} + +gdb_test "step" "dec .ecx.*" "step to dec ecx 1st time" +send_gdb "info reg ecx\n" +gdb_expect { + -re "ecx *($hex)\t.*$gdb_prompt " { + set predec_ecx $expect_out(1,string) + } +} + +gdb_test "step" "dec .edx.*" "step to dec edx 1st time" +send_gdb "info reg edx\n" +gdb_expect { + -re "edx *($hex)\t.*$gdb_prompt " { + set predec_edx $expect_out(1,string) + } +} + +gdb_test "step" "dec .ebx.*" "step to dec ebx 1st time" +send_gdb "info reg ebx\n" +gdb_expect { + -re "ebx *($hex)\t.*$gdb_prompt " { + set predec_ebx $expect_out(1,string) + } +} + +gdb_test "step" "dec .esp.*" "step to dec esp 1st time" +send_gdb "info reg esp\n" +gdb_expect { + -re "esp *($hex)\t.*$gdb_prompt " { + set predec_esp $expect_out(1,string) + } +} + +gdb_test "step" "dec .ebp.*" "step to dec ebp 1st time" +send_gdb "info reg ebp\n" +gdb_expect { + -re "ebp *($hex)\t.*$gdb_prompt " { + set predec_ebp $expect_out(1,string) + } +} + +gdb_test "step" "dec .esi.*" "step to dec esi 1st time" +send_gdb "info reg esi\n" +gdb_expect { + -re "esi *($hex)\t.*$gdb_prompt " { + set predec_esi $expect_out(1,string) + } +} + +gdb_test "step" "dec .edi.*" "step to dec edi 1st time" +send_gdb "info reg edi\n" +gdb_expect { + -re "edi *($hex)\t.*$gdb_prompt " { + set predec_edi $expect_out(1,string) + } +} + +# gdb_test "step" "end inc_dec_tests .*" "step to end inc_dec_tests 1st time" + +gdb_test "break $end_of_main" \ + "Breakpoint $decimal at .* line $end_of_main\." \ + "set breakpoint at end of main" + +gdb_test "continue" \ + " end of main .*" \ + "continue to end of main" + +gdb_test "break $end_of_inc_dec_tests" \ + "Breakpoint $decimal at .* line $end_of_inc_dec_tests\." \ + "set breakpoint at end of inc_dec_tests" + +gdb_test "reverse-continue" \ + " end inc_dec_tests .*" \ + "reverse to inc_dec_tests" + +# +# Now reverse step, and check register values. +# + +gdb_test "info reg edi" "edi *$preinc_edi\t.*" "edi before reverse-dec" +gdb_test "reverse-step" "dec .edi.*" "reverse-step to dec edi" +gdb_test "info reg edi" "edi *$predec_edi\t.*" "edi after reverse-dec" + +gdb_test "info reg esi" "esi *$preinc_esi\t.*" "esi before reverse-dec" +gdb_test "reverse-step" "dec .esi.*" "reverse-step to dec esi" +gdb_test "info reg esi" "esi *$predec_esi\t.*" "esi after reverse-dec" + +gdb_test "info reg ebp" "ebp *$preinc_ebp\t.*" "ebp before reverse-dec" +gdb_test "reverse-step" "dec .ebp.*" "reverse-step to dec ebp" +gdb_test "info reg ebp" "ebp *$predec_ebp\t.*" "ebp after reverse-dec" + +gdb_test "info reg esp" "esp *$preinc_esp\t.*" "esp before reverse-dec" +gdb_test "reverse-step" "dec .esp.*" "reverse-step to dec esp" +gdb_test "info reg esp" "esp *$predec_esp\t.*" "esp after reverse-dec" + +gdb_test "info reg ebx" "ebx *$preinc_ebx\t.*" "ebx before reverse-dec" +gdb_test "reverse-step" "dec .ebx.*" "reverse-step to dec ebx" +gdb_test "info reg ebx" "ebx *$predec_ebx\t.*" "ebx after reverse-dec" + +gdb_test "info reg edx" "edx *$preinc_edx\t.*" "edx before reverse-dec" +gdb_test "reverse-step" "dec .edx.*" "reverse-step to dec edx" +gdb_test "info reg edx" "edx *$predec_edx\t.*" "edx after reverse-dec" + +gdb_test "info reg ecx" "ecx *$preinc_ecx\t.*" "ecx before reverse-dec" +gdb_test "reverse-step" "dec .ecx.*" "reverse-step to dec ecx" +gdb_test "info reg ecx" "ecx *$predec_ecx\t.*" "ecx after reverse-dec" + +gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax before reverse-dec" +gdb_test "reverse-step" "dec .eax.*" "reverse-step to dec eax" +gdb_test "info reg eax" "eax *$predec_eax\t.*" "eax after reverse-dec" + +gdb_test "info reg edi" "edi *$predec_edi\t.*" "edi before reverse-inc" +gdb_test "reverse-step" "inc .edi.*" "reverse-step to inc edi" +gdb_test "info reg edi" "edi *$preinc_edi\t.*" "edi after reverse-inc" + +gdb_test "info reg esi" "esi *$predec_esi\t.*" "esi before reverse-inc" +gdb_test "reverse-step" "inc .esi.*" "reverse-step to inc esi" +gdb_test "info reg esi" "esi *$preinc_esi\t.*" "esi after reverse-inc" + +gdb_test "info reg ebp" "ebp *$predec_ebp\t.*" "ebp before reverse-inc" +gdb_test "reverse-step" "inc .ebp.*" "reverse-step to inc ebp" +gdb_test "info reg ebp" "ebp *$preinc_ebp\t.*" "ebp after reverse-inc" + +gdb_test "info reg esp" "esp *$predec_esp\t.*" "esp before reverse-inc" +gdb_test "reverse-step" "inc .esp.*" "reverse-step to inc esp" +gdb_test "info reg esp" "esp *$preinc_esp\t.*" "esp after reverse-inc" + +gdb_test "info reg ebx" "ebx *$predec_ebx\t.*" "ebx before reverse-inc" +gdb_test "reverse-step" "inc .ebx.*" "reverse-step to inc ebx" +gdb_test "info reg ebx" "ebx *$preinc_ebx\t.*" "ebx after reverse-inc" + +gdb_test "info reg edx" "edx *$predec_edx\t.*" "edx before reverse-inc" +gdb_test "reverse-step" "inc .edx.*" "reverse-step to inc edx" +gdb_test "info reg edx" "edx *$preinc_edx\t.*" "edx after reverse-inc" + +gdb_test "info reg ecx" "ecx *$predec_ecx\t.*" "ecx before reverse-inc" +gdb_test "reverse-step" "inc .ecx.*" "reverse-step to inc ecx" +gdb_test "info reg ecx" "ecx *$preinc_ecx\t.*" "ecx after reverse-inc" + +gdb_test "info reg eax" "eax *$predec_eax\t.*" "eax before reverse-inc" +gdb_test "reverse-step" "inc .eax.*" "reverse-step to inc eax" +gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax after reverse-inc" + + diff --git a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp new file mode 100644 index 00000000000..55f29370e80 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp @@ -0,0 +1,256 @@ +# Copyright 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the GDB testsuite. +# This test tests the restoration of various kinds of machine state +# to their original values with a process record log. We will execute +# the program forward while it changes various types of data, and +# then execute it backward to see if their values get restored. +# +# The types of machine state (data) that are tested are: +# register variable +# auto variable +# function static variable +# module static variable +# module global variable +# +# TODO: +# various, possibly including... +# .bss variable, .data variable, ... +# shared library variable +# heap variable (pointer)... +# overlay variables... +# Test forward replay +# + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +set testfile "machinestate" +set srcfile ${testfile}.c +set srcfile1 ms1.c + +if { [prepare_for_testing $testfile.exp $testfile {machinestate.c ms1.c} ] } { + return -1 +} + +set newline "\[\r\n\]+" + +set beginmain [gdb_get_line_number " begin main " $srcfile] +set endmain [gdb_get_line_number " end main " $srcfile] + +# Test begins + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +gdb_test "break $endmain" \ + "Breakpoint $decimal at .*/$srcfile, line $endmain\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end main .*" "run to end of main" + +gdb_test "record save machinestate.precsave" \ + "Saved core file machinestate.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore machinestate.precsave" \ + "Program terminated with signal .*" \ + "reload prec save file" + +# Proceed to end of main + +gdb_test "break $endmain" \ + "Breakpoint.* file .*/$srcfile, line $endmain.*" "" + +gdb_test_multiple "continue" "go to end of main forward" { + -re ".*Breakpoint $decimal,.*/$srcfile:$endmain.*$gdb_prompt $" { + pass "go to end of main forward" + } + -re "No more reverse-execution history.* end main .*$gdb_prompt $" { + pass "go to end of main forward" + } +} + +### +### +### + +# Now run backward to each of several points where data is changed. +# + +# Module global variable, reverse + +set breakloc [gdb_get_line_number \ + "module_global_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" + +gdb_test "print aglobal" ".* = 0$newline" "module global reverse-breakpoint" +gdb_test "step" ".* module global post-change .*" "" +gdb_test "print aglobal" ".* = 1$newline" "module global forward past bp" +gdb_test "reverse-step" ".*$newline$breakloc.*" "" +gdb_test "print aglobal" ".* = 0$newline" "module global reverse-step to bp" + + +# Module static variable, reverse + +set breakloc [gdb_get_line_number \ + "module_static_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" + +gdb_test "print astatic" ".* = 0$newline" "module static reverse-breakpoint" +gdb_test "step" ".* module static post-change .*" "" +gdb_test "print astatic" ".* = 1$newline" "module static forward" +gdb_test "reverse-step" ".*$newline$breakloc.*" "" +gdb_test "print astatic" ".* = 0$newline" "module static reverse-step" + +# Function static variable, reverse + +set breakloc [gdb_get_line_number \ + "function_static_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" + +gdb_test "print a" ".* = 0$newline" "function static reverse-breakpoint" +gdb_test "step" ".* function static post-change .*" "" +gdb_test "print a" ".* = 1$newline" "function static forward" +gdb_test "reverse-step" ".*$newline$breakloc.*" "" +gdb_test "print a" ".* = 0$newline" "function static reverse-step" + +# Auto variable, reverse + +set breakloc [gdb_get_line_number \ + "auto_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" + +gdb_test "print a" ".* = 0$newline" "auto var reverse-breakpoint" +gdb_test "step" ".* auto post-change .*" "" +gdb_test "print a" ".* = 1$newline" "auto var forward" +gdb_test "reverse-step" ".*$newline$breakloc.*" "" +gdb_test "print a" ".* = 0$newline" "auto var reverse-step" + +# Register variable, reverse + +set breakloc [gdb_get_line_number \ + "register_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" + +gdb_test "print a" ".* = 0$newline" "register var reverse-breakpoint" +gdb_test "step" ".* register post-change .*" "" +gdb_test "print a" ".* = 1$newline" "register var step post-change" +gdb_test "reverse-step" ".*$newline$breakloc.*" "" +gdb_test "print a" ".* = 0$newline" "register var reverse step-to" + +# Proceed to beginning of main + +gdb_test "tbreak $beginmain" ".*/$srcfile, line $beginmain.*" "" +gdb_test "reverse-continue" ".*/$srcfile:$beginmain.*" "reverse to main" + +# Now repeat tests while replaying forward. + +# Register variable, forward + +set breakloc [gdb_get_line_number \ + "register_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" + +gdb_test "print a" ".* = 0$newline" "register var forward-breakpoint" +gdb_test "reverse-step" ".*hide.*" "" +gdb_test "step" ".*$newline$breakloc.*" "" +gdb_test "print a" ".* = 0$newline" "register var forward step-to" +gdb_test "step" ".* register post-change .*" "" +gdb_test "print a" ".* = 1$newline" "register var step post-change" + +# Auto variable, forward + +set breakloc [gdb_get_line_number \ + "auto_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" + +gdb_test "print a" ".* = 0$newline" "auto var forward-breakpoint" +gdb_test "reverse-step" ".*hide.*" "" +gdb_test "step" ".*$newline$breakloc.*" "" +gdb_test "print a" ".* = 0$newline" "auto var forward step-to" +gdb_test "step" ".* auto post-change .*" "" +gdb_test "print a" ".* = 1$newline" "auto var step post-change" + +# Function static variable, forward + +set breakloc [gdb_get_line_number \ + "function_static_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" + +gdb_test "print a" ".* = 0$newline" "function static forward-breakpoint" +gdb_test "reverse-step" ".*hide.*" "" +gdb_test "step" ".*$newline$breakloc.*" "" +gdb_test "print a" ".* = 0$newline" "function static forward step-to" +gdb_test "step" ".* function static post-change .*" "" +gdb_test "print a" ".* = 1$newline" "function static step post-change" + +# Module static variable, forward + +set breakloc [gdb_get_line_number \ + "module_static_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" + +gdb_test "print astatic" ".* = 0$newline" "module static forward-breakpoint" +gdb_test "reverse-step" ".*hide.*" "" +gdb_test "step" ".*$newline$breakloc.*" "" +gdb_test "print astatic" ".* = 0$newline" "module static forward step-to" +gdb_test "step" ".* module static post-change .*" "" +gdb_test "print astatic" ".* = 1$newline" "module static step post-change" + +# Module global variable, forward + +set breakloc [gdb_get_line_number \ + "module_global_state: set breakpoint here" $srcfile] + +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" +gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" + +gdb_test "print aglobal" ".* = 0$newline" "module global forward-breakpoint" +gdb_test "reverse-step" ".*hide.*" "" +gdb_test "step" ".*$newline$breakloc.*" "" +gdb_test "print aglobal" ".* = 0$newline" "module global forward step-to" +gdb_test "step" ".* module global post-change .*" "" +gdb_test "print aglobal" ".* = 1$newline" "module global step post-change" + diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp new file mode 100644 index 00000000000..21134cafb9b --- /dev/null +++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp @@ -0,0 +1,439 @@ +# Copyright 2009 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if [target_info exists gdb,nosignals] { + verbose "Skipping sigall-reverse.exp because of nosignals." + return +} + +if ![target_info exists gdb,can_reverse] { + return +} + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +set testfile sigall-reverse +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested sigall.exp + return -1 +} + +# Make the first signal SIGABRT because it is always supported. +set sig_supported 1 +set thissig "ABRT" + +proc test_one_sig {nextsig} { + global sig_supported + global gdb_prompt + global thissig + + set this_sig_supported $sig_supported + gdb_test "handle SIG$thissig stop print" \ + "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*" + gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*" + gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*" + + set need_another_continue 1 + set missed_handler 0 + if $this_sig_supported then { + if { $thissig == "IO" } { + setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu" + } + set testmsg "get signal $thissig" + gdb_test_multiple "continue" $testmsg { + -re "Program received signal SIG$thissig.*handle_$thissig.*$gdb_prompt $" { + fail "$testmsg (wrong location)" + } + -re "Program received signal SIG$thissig.*$gdb_prompt $" { + pass $testmsg + } + -re "Breakpoint.* handle_$thissig.*$gdb_prompt $" { + xfail $testmsg + set need_another_continue 0 + } + } + } + if [ istarget "alpha-dec-osf3*" ] then { + # OSF/1-3.x is unable to continue with a job control stop signal. + # The inferior remains stopped without an event of interest + # and GDB waits forever for the inferior to stop on an event + # of interest. Work around the kernel bug. + if { $thissig == "TSTP" || $thissig == "TTIN" || $thissig == "TTOU" } { + setup_xfail "alpha-dec-osf3*" + fail "cannot continue from signal $thissig" + set need_another_continue 0 + } + } + + if $need_another_continue then { + if { $thissig == "URG" } { + setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu" + } + # Either Lynx or GDB screws up on SIGPRIO + if { $thissig == "PRIO" } { + setup_xfail "*-*-*lynx*" + } + set testmsg "send signal $thissig" + gdb_test_multiple "continue" $testmsg { + -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" { + pass $testmsg + } + -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" { + fail "missed breakpoint at handle_$thissig" + set missed_handler 1 + } + } + } + + if { $missed_handler == "0" } then { + set testmsg "advance to $nextsig" + gdb_test_multiple "signal 0" $testmsg { + -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" { + pass $testmsg + set sig_supported 1 + } + -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" { + pass $testmsg + set sig_supported 0 + } + } + } + set thissig $nextsig +} + +proc test_one_sig_reverse {prevsig} { + global gdb_prompt + + gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \ + "reverse to handler of $prevsig" + + set saw_signal 0 + set testmsg "reverse to gen_$prevsig" + gdb_test_multiple "reverse-continue" $testmsg { + -re "Breakpoint.*handle_.*$gdb_prompt " { + pass "$testmsg (un-handled)" + } + -re "Program received signal SIG$prevsig.*$gdb_prompt " { + pass "reverse to signal event, $prevsig" + + set nested_testmsg "reverse signal delivered" + gdb_test_multiple "frame" $nested_testmsg { + -re ".*handle_$prevsig.*$gdb_prompt " { + fail "$nested_testmsg (wrong location)" + } + -re ".*$gdb_prompt " { + pass $nested_testmsg + } + } + + set saw_signal 1 + send_gdb "reverse-continue\n" + exp_continue + } + -re "Breakpoint.*kill.*$gdb_prompt " { + if { $saw_signal } then { + pass "$testmsg (handled)" + } else { + xfail "$testmsg (handled)" + } + } + -re "No more reverse-execution history.*kill.*$gdb_prompt " { + if { $saw_signal } then { + pass "$testmsg (handled)" + } else { + xfail "$testmsg (handled)" + } + } + } +} + +gdb_load $binfile + +runto gen_ABRT + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +# Run until end, then save execution log. + +set breakloc [gdb_get_line_number "end of main" "$srcfile"] +gdb_test "break $breakloc" \ + "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \ + "BP at end of main" + +# Signal handlers must be disabled +gdb_test "handle all nostop noprint" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save sigall.precsave" \ + "Saved core file sigall.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore sigall.precsave" \ + "Program terminated with signal .*" \ + "reload precord save file" + +# Signal handlers must be re-enabled +gdb_test "handle all stop print" + +# test signal handling +test_one_sig HUP +test_one_sig QUIT +test_one_sig ILL +test_one_sig EMT +test_one_sig FPE +test_one_sig BUS +test_one_sig SEGV +test_one_sig SYS +test_one_sig PIPE +test_one_sig ALRM +test_one_sig URG +test_one_sig TSTP +test_one_sig CONT +test_one_sig CHLD +test_one_sig TTIN +test_one_sig TTOU +test_one_sig IO +test_one_sig XCPU +test_one_sig XFSZ +test_one_sig VTALRM +test_one_sig PROF +test_one_sig WINCH +test_one_sig LOST +test_one_sig USR1 +test_one_sig USR2 +test_one_sig PWR +test_one_sig POLL +test_one_sig WIND +test_one_sig PHONE +test_one_sig WAITING +test_one_sig LWP +test_one_sig DANGER +test_one_sig GRANT +test_one_sig RETRACT +test_one_sig MSG +test_one_sig SOUND +test_one_sig SAK +test_one_sig PRIO +test_one_sig 33 +test_one_sig 34 +test_one_sig 35 +test_one_sig 36 +test_one_sig 37 +test_one_sig 38 +test_one_sig 39 +test_one_sig 40 +test_one_sig 41 +test_one_sig 42 +test_one_sig 43 +test_one_sig 44 +test_one_sig 45 +test_one_sig 46 +test_one_sig 47 +test_one_sig 48 +test_one_sig 49 +test_one_sig 50 +test_one_sig 51 +test_one_sig 52 +test_one_sig 53 +test_one_sig 54 +test_one_sig 55 +test_one_sig 56 +test_one_sig 57 +test_one_sig 58 +test_one_sig 59 +test_one_sig 60 +test_one_sig 61 +test_one_sig 62 +test_one_sig 63 +test_one_sig TERM + +# The last signal (SIGTERM) gets handled slightly differently because +# we are not setting up for another test. +gdb_test "handle SIGTERM stop print" \ + "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*" +gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*" +gdb_test "continue" \ + "Continuing.*Program received signal SIGTERM.*" \ + "get signal TERM" +gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM" + +gdb_test "continue" " end of main .*" "continue to sigall exit" + +test_one_sig_reverse TERM +test_one_sig_reverse 63 +test_one_sig_reverse 62 +test_one_sig_reverse 61 +test_one_sig_reverse 60 +test_one_sig_reverse 59 +test_one_sig_reverse 58 +test_one_sig_reverse 57 +test_one_sig_reverse 56 +test_one_sig_reverse 55 +test_one_sig_reverse 54 +test_one_sig_reverse 53 +test_one_sig_reverse 52 +test_one_sig_reverse 51 +test_one_sig_reverse 50 +test_one_sig_reverse 49 +test_one_sig_reverse 48 +test_one_sig_reverse 47 +test_one_sig_reverse 46 +test_one_sig_reverse 45 +test_one_sig_reverse 44 +test_one_sig_reverse 43 +test_one_sig_reverse 42 +test_one_sig_reverse 41 +test_one_sig_reverse 40 +test_one_sig_reverse 39 +test_one_sig_reverse 38 +test_one_sig_reverse 37 +test_one_sig_reverse 36 +test_one_sig_reverse 35 +test_one_sig_reverse 34 +test_one_sig_reverse 33 +test_one_sig_reverse PRIO +test_one_sig_reverse SAK +test_one_sig_reverse SOUND +test_one_sig_reverse MSG +test_one_sig_reverse RETRACT +test_one_sig_reverse GRANT +test_one_sig_reverse DANGER +test_one_sig_reverse LWP +test_one_sig_reverse WAITING +test_one_sig_reverse PHONE +test_one_sig_reverse WIND +test_one_sig_reverse POLL +test_one_sig_reverse PWR +test_one_sig_reverse USR2 +test_one_sig_reverse USR1 +test_one_sig_reverse LOST +test_one_sig_reverse WINCH +test_one_sig_reverse PROF +test_one_sig_reverse VTALRM +test_one_sig_reverse XFSZ +test_one_sig_reverse XCPU +test_one_sig_reverse IO +test_one_sig_reverse TTOU +test_one_sig_reverse TTIN +test_one_sig_reverse CHLD +test_one_sig_reverse CONT +test_one_sig_reverse TSTP +test_one_sig_reverse URG +test_one_sig_reverse ALRM +test_one_sig_reverse PIPE +test_one_sig_reverse SYS +test_one_sig_reverse SEGV +test_one_sig_reverse BUS +test_one_sig_reverse FPE +test_one_sig_reverse EMT +test_one_sig_reverse ILL +test_one_sig_reverse QUIT +test_one_sig_reverse HUP +test_one_sig_reverse ABRT + +# Make the first signal SIGABRT because it is always supported. +set sig_supported 1 +set thissig "ABRT" + +test_one_sig HUP +test_one_sig QUIT +test_one_sig ILL +test_one_sig EMT +test_one_sig FPE +test_one_sig BUS +test_one_sig SEGV +test_one_sig SYS +test_one_sig PIPE +test_one_sig ALRM +test_one_sig URG +test_one_sig TSTP +test_one_sig CONT +test_one_sig CHLD +test_one_sig TTIN +test_one_sig TTOU +test_one_sig IO +test_one_sig XCPU +test_one_sig XFSZ +test_one_sig VTALRM +test_one_sig PROF +test_one_sig WINCH +test_one_sig LOST +test_one_sig USR1 +test_one_sig USR2 +test_one_sig PWR +test_one_sig POLL +test_one_sig WIND +test_one_sig PHONE +test_one_sig WAITING +test_one_sig LWP +test_one_sig DANGER +test_one_sig GRANT +test_one_sig RETRACT +test_one_sig MSG +test_one_sig SOUND +test_one_sig SAK +test_one_sig PRIO +test_one_sig 33 +test_one_sig 34 +test_one_sig 35 +test_one_sig 36 +test_one_sig 37 +test_one_sig 38 +test_one_sig 39 +test_one_sig 40 +test_one_sig 41 +test_one_sig 42 +test_one_sig 43 +test_one_sig 44 +test_one_sig 45 +test_one_sig 46 +test_one_sig 47 +test_one_sig 48 +test_one_sig 49 +test_one_sig 50 +test_one_sig 51 +test_one_sig 52 +test_one_sig 53 +test_one_sig 54 +test_one_sig 55 +test_one_sig 56 +test_one_sig 57 +test_one_sig 58 +test_one_sig 59 +test_one_sig 60 +test_one_sig 61 +test_one_sig 62 +test_one_sig 63 +test_one_sig TERM diff --git a/gdb/testsuite/gdb.reverse/solib-precsave.exp b/gdb/testsuite/gdb.reverse/solib-precsave.exp new file mode 100644 index 00000000000..4de19fe3eeb --- /dev/null +++ b/gdb/testsuite/gdb.reverse/solib-precsave.exp @@ -0,0 +1,143 @@ +# Copyright 2009 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the GDB testsuite. It tests precord debugging +# with shared libraries and a logfile. + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +set testfile "solib-reverse" +set srcfile ${testfile}.c +set libfile "shr2" +set libsrc ${libfile}.c +set library ${objdir}/${subdir}/${libfile}.sl +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } { + untested "Could not compile shared library." + return -1 +} + +set exec_opts [list debug shlib=${library}] + +if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } { + untested "Could not compile $binfile." + return -1 +} + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +set end_of_main [gdb_get_line_number "end of main" ] +gdb_test "break $end_of_main" \ + "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save solib.precsave" \ + "Saved core file solib.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore solib.precsave" \ + "Program terminated with signal .*" \ + "reload core file" + +# +# Test reverse-step over undebuggable solib functions. +# + +# Run forward past some solib function calls. + +set end_part_one [gdb_get_line_number " end part one" "$srcfile"] +set end_part_two [gdb_get_line_number " end part two" "$srcfile"] +gdb_test "until $end_part_one" " end part one.*" "run until end part one" + +gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep" +gdb_test "reverse-step" " sleep two .*" "reverse-step second sleep" +gdb_test "reverse-step" " sleep one .*" \ + "reverse-step first sleep, dynsym resolve" + +gdb_test "reverse-step" " printf three .*" "reverse-step third printf" +gdb_test "reverse-step" " printf two .*" "reverse-step second printf" +gdb_test "reverse-step" " printf one .*" \ + "reverse-step first printf, dynsym resolve" +gdb_test "reverse-step" " generic statement.*" "reverse-step generic" + + +# +# Test reverse-next over undebuggable solib functions. +# + +# Run forward again... + +gdb_test "until $end_part_one" " end part one.*" "forward to end part one" + +gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep" +gdb_test "reverse-next" " sleep two .*" "reverse-next second sleep" +gdb_test "reverse-next" " sleep one .*" \ + "reverse-next first sleep, dynsym resolve" + +gdb_test "reverse-next" " printf three .*" "reverse-next third printf" +gdb_test "reverse-next" " printf two .*" "reverse-next second printf" +gdb_test "reverse-next" " printf one .*" \ + "reverse-next first printf, dynsym resolve" +gdb_test "reverse-next" " generic statement.*" "reverse-next generic" + + +# +# Test reverse-step into debuggable solib function +# + +gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one" +gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one" +gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one" + +gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two" +gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two" +gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two" + +# +# Test reverse-next over debuggable solib function +# + +gdb_test "until $end_part_two" " end part two.*" "run until end part two" + +gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one" +gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two" diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp new file mode 100644 index 00000000000..545d8b2a6f0 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/step-precsave.exp @@ -0,0 +1,273 @@ +# Copyright 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +# This file is part of the GDB testsuite. It tests reverse stepping. +# Lots of code borrowed from "step-test.exp". + +# +# Test step and next with a reloaded process record file. +# + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +set testfile "step-reverse" +set srcfile ${testfile}.c + +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { + return -1 +} + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +set end_of_main [gdb_get_line_number "end of main" ] +gdb_test "break $end_of_main" \ + "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save step.precsave" \ + "Saved core file step.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore step.precsave" \ + "Program terminated with signal .*" \ + "reload core file" + +# plain vanilla step/next (no count) + +gdb_test "next" ".*NEXT TEST 1.*" "next test 1" +gdb_test "step" ".*STEP TEST 1.*" "step test 1" + +# step/next with count + +gdb_test "next 2" ".*NEXT TEST 2.*" "next test 2" +gdb_test "step 3" ".*STEP TEST 2.*" "step test 2" + +# step over call + +gdb_test "step" ".*NEXT OVER THIS CALL.*" "step up to call" +gdb_test "next" ".*STEP INTO THIS CALL.*" "next over call" + +# step into call + +gdb_test "step" ".*ARRIVED IN CALLEE.*" "step into call" + +# finish out of call + +set test_message "finish out of fn call" +gdb_test_multiple "finish" "$test_message" { + -re "FINISH TEST.*$gdb_prompt $" { + pass "$test_message" + } + -re "STEP INTO THIS CALL.*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } +} + +# stepi over flat code (no calls) + +set test_message "simple stepi" +gdb_test_multiple "stepi" "$test_message" { + -re "STEPI TEST.*$gdb_prompt $" { + pass "$test_message" + } + -re "FINISH TEST.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "NEXTI TEST.*$gdb_prompt $" { + fail "$test_message (too far)" + } +} + +# stepi into a function call + +set test_message "stepi into function call" +gdb_test_multiple "stepi" "$test_message" { + -re "ARRIVED IN CALLEE.*$gdb_prompt $" { + pass "$test_message" + } + -re "NEXTI TEST.*$gdb_prompt $" { + fail "$test_message (too far)" + } + -re "RETURN FROM CALLEE.*$gdb_prompt $" { + fail "$test_message (too far)" + } + -re "ENTER CALLEE.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "STEPI TEST.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } +} + +# stepi thru return of a function call + +set test_message "stepi back from function call" +gdb_test_multiple "stepi" "$test_message" { + -re "NEXTI TEST.*$gdb_prompt $" { + pass "$test_message" + } + -re "ARRIVED IN CALLEE.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "RETURN FROM CALLEE.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "STEPI TEST.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "ENTER CALLEE.*$gdb_prompt $" { + fail "$test_message (too far)" + } +} + +### +### +### + +# Set reverse execution direction +# FIXME: command needs to acknowledge, so we can test if it succeeded. + +gdb_test "set exec-dir reverse" "" "set reverse execution" + +# stepi backward thru return and into a function + +set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"] +set test_message "reverse stepi thru function return" +gdb_test_multiple "stepi" "$test_message" { + -re "NEXTI TEST.*$gdb_prompt $" { + fail "$test_message (start statement)" + } + -re "RETURN FROM CALLEE.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "$hex\[ \t\]*$stepi_location.*ARRIVED IN CALLEE.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "ARRIVED IN CALLEE.*$gdb_prompt $" { + pass "$test_message" + } + -re "ENTER CALLEE.*$gdb_prompt $" { + fail "$test_message (too far)" + } + -re "STEPI TEST.*$gdb_prompt $" { + fail "$test_message (too far)" + } +} + +# stepi backward out of a function call + +set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"] +set test_message "reverse stepi from a function call" +gdb_test_multiple "stepi" "$test_message" { + -re "ARRIVED IN CALLEE.*$gdb_prompt $" { + fail "$test_message (start statement)" + } + -re "ENTER CALLEE.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "${hex} in main .*:$stepi_location.*STEPI TEST.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "STEPI TEST.*$gdb_prompt $" { + pass "$test_message" + } + -re "STEP INTO THIS CALL.*$gdb_prompt $" { + fail "$test_message (too far)" + } +} + +# stepi backward over flat code (no calls) + +set stepi_location [gdb_get_line_number "FINISH TEST" "$srcfile"] +set test_message "simple reverse stepi" +gdb_test_multiple "stepi" "$test_message" { + -re "STEPI TEST.*$gdb_prompt $" { + fail "$test_message (start statement)" + } + -re "$hex\[ \t\]*$stepi_location.* FINISH TEST.*$gdb_prompt $" { + send_gdb "stepi\n" + exp_continue + } + -re "$stepi_location.* FINISH TEST.*$gdb_prompt $" { + pass "$test_message" + } + -re "STEP INTO THIS CALL.*$gdb_prompt $" { + fail "$test_message (too far)" + } +} + +# step backward into function (thru return) + +set test_message "reverse step into fn call" +gdb_test_multiple "step" "$test_message" { + -re "RETURN FROM CALLEE.*$gdb_prompt $" { + send_gdb "step\n" + exp_continue + } + -re "ARRIVED IN CALLEE.*$gdb_prompt $" { + pass "$test_message" + } +} + +# step backward out of called function (thru call) + +gdb_test "step" ".*STEP INTO THIS CALL.*" "reverse step out of called fn" + +# next backward over call + +gdb_test "next" ".*NEXT OVER THIS CALL.*" "reverse next over call" + +# step/next backward with count + +gdb_test "step 3" ".*REVERSE STEP TEST 1.*" "reverse step test 1" +gdb_test "next 2" ".*REVERSE NEXT TEST 1.*" "reverse next test 1" + +# step/next backward without count + +gdb_test "step" ".*STEP TEST 1.*" "reverse step test 2" +gdb_test "next" ".*NEXT TEST 1.*" "reverse next test 2" + + + +# Finish test by running forward to the end. +# FIXME return to this later... +# gdb_test "set exec-dir forward" "" "set forward execution" +# gdb_continue_to_end "step-reverse.exp" + diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp new file mode 100644 index 00000000000..212198a5fa3 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/until-precsave.exp @@ -0,0 +1,146 @@ +# Copyright 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +# This file is part of the GDB testsuite. It tests 'until' and +# 'advance' in precord logfile. + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +set testfile "until-reverse" +set srcfile ${testfile}.c +set srcfile1 ur1.c + +if { [prepare_for_testing $testfile.exp $testfile {until-reverse.c ur1.c} ] } { + return -1 +} + +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] +set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] +set bp_location9 [gdb_get_line_number "set breakpoint 9 here" "$srcfile1"] +set bp_location19 [gdb_get_line_number "set breakpoint 19 here"] +set bp_location20 [gdb_get_line_number "set breakpoint 20 here"] +set bp_location21 [gdb_get_line_number "set breakpoint 21 here"] + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +set end_of_main [gdb_get_line_number "set breakpoint 10a here" ] +gdb_test "break $end_of_main" \ + "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* set breakpoint 10a here .*" "run to end of main" + +gdb_test "record save until.precsave" \ + "Saved core file until.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore until.precsave" \ + "Program terminated with signal .*" \ + "reload core file" + +# Verify that plain vanilla "until " works. +# +gdb_test "until $bp_location1" \ + "main .* at .*:$bp_location1.*" \ + "until line number" + +# Advance up to factorial, outer invocation +# +gdb_test "advance factorial" \ + "factorial .value=6..*$srcfile:$bp_location7.*" \ + "advance to factorial" + +# At this point, 'until' should continue the inferior up to when all the +# inner invocations of factorial() are completed and we are back at this +# frame. +# +gdb_test "until $bp_location19" \ + "factorial .value=720.*${srcfile}:$bp_location19.*" \ + "until factorial, recursive function" + +# Finish out to main scope +# +gdb_test "finish" \ + " in main .*$srcfile:$bp_location1.*" \ + "finish to main" + +# Advance to a function called by main (marker2) +# +gdb_test "advance marker2" \ + "marker2 .a=43.*$srcfile1:$bp_location9.*" \ + "advance to marker2" + +# Now issue an until with another function, not called by the current +# frame, as argument. This should not work, i.e. the program should +# stop at main, the caller, where we put the 'guard' breakpoint. +# +set test_msg "until func, not called by current frame" +gdb_test_multiple "until marker3" "$test_msg" { + -re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" { + pass "$test_msg" + } + -re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" { + pass "$test_msg" + } +} + +### +### +### + +# Set reverse execution direction +# FIXME: command needs to acknowledge, so we can test if it succeeded. + +gdb_test "set exec-dir reverse" "" "set reverse execution" + +# +# We should now be at main, after the return from marker2. +# "Advance" backward into marker2. +# + +gdb_test "advance marker2" \ + "marker2 .a=43.*$srcfile1:$bp_location9.*" \ + "reverse-advance to marker2" + +# Finish out to main scope (backward) + +gdb_test "finish" \ + " in main .*$srcfile:$bp_location20.*" \ + "reverse-finish from marker2" + +# Advance backward to last line of factorial (outer invocation) + +gdb_test "advance $bp_location19" \ + "factorial .value=720.*${srcfile}:$bp_location19.*" \ + "reverse-advance to final return of factorial" + +# Now do "until" across the recursive calls, +# ending up in the same frame where we are now. + +gdb_test "until $bp_location7" \ + "factorial .value=6..*$srcfile:$bp_location7.*" \ + "reverse-until to entry of factorial" diff --git a/gdb/testsuite/gdb.reverse/watch-precsave.exp b/gdb/testsuite/gdb.reverse/watch-precsave.exp new file mode 100644 index 00000000000..f102a7c116e --- /dev/null +++ b/gdb/testsuite/gdb.reverse/watch-precsave.exp @@ -0,0 +1,142 @@ +# Copyright 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Based on a file written by Fred Fish. (fnf@cygnus.com) +# This file is part of the GDB testsuite. It tests precord dumpfile +# debugging with watchpoints. + +# This test suitable only for process record-replay +if ![target_info exists gdb,use_precord] { + return +} + +set testfile "watch-reverse" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { + return -1 +} + +runto main + +if [target_info exists gdb,use_precord] { + # Activate process record/replay + gdb_test "record" "" "Turn on process record" + # FIXME: command ought to acknowledge, so we can test if it succeeded. +} + +set end_location [gdb_get_line_number "end of main" ] +gdb_test "break $end_location" \ + "Breakpoint $decimal at .*/$srcfile, line $end_location\." \ + "BP at end of main" + +gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" + +gdb_test "record save watch.precsave" \ + "Saved core file watch.precsave with execution log\." \ + "save process recfile" + +gdb_test "kill" "" "Kill process, prepare to debug log file" \ + "Kill the program being debugged\\? \\(y or n\\) " "y" + +gdb_test "record restore watch.precsave" \ + "Program terminated with signal .*" \ + "reload core file" + +# Only software watchpoints can be used in reverse +gdb_test "set can-use-hw-watchpoints 0" "" "" + +gdb_test "break marker1" \ + "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "set breakpoint at marker1" + +gdb_test "break marker2" \ + "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "set breakpoint at marker2" + +gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*" + +gdb_test "watch ival3" \ + ".*\[Ww\]atchpoint $decimal: ival3.*" \ + "set watchpoint on ival3" + +# Continue until first change, from -1 to 0 + +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit, first time" + +# Continue until the next change, from 0 to 1. +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit, second time" + +# Continue until the next change, from 1 to 2. +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit, third time" + +# Continue until the next change, from 2 to 3. +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit, fourth time" + +# Continue until the next change, from 3 to 4. +# Note that this one is outside the loop. + +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit, fifth time" + +# Continue until we hit the finishing marker function. +# Make sure we hit no more watchpoints. + +gdb_continue_to_breakpoint "marker2" ".*/$srcfile:.*" + +### +### +### + +# FIXME 'set exec-dir' command should give some output so we can test. +gdb_test "set exec-direction reverse" "" "set reverse" + +# Reverse until the previous change, from 4 to 3 +# Note that this one is outside the loop + +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit in reverse, first time" + +# Reverse until the previous change, from 3 to 2. +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit in reverse, second time" + +# Reverse until the previous change, from 2 to 1. +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit in reverse, third time" + +# Reverse until the previous change, from 1 to 0. +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit in reverse, fourth time" + +# Reverse until first change, from 0 to -1 + +gdb_test "continue" \ + ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \ + "watchpoint hit in reverse, fifth time" -- 2.39.2