From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32297 invoked by alias); 25 Jun 2009 03:33:05 -0000 Received: (qmail 32231 invoked by uid 22791); 25 Jun 2009 03:32:57 -0000 X-SWARE-Spam-Status: No, hits=0.7 required=5.0 tests=AWL,BAYES_50,HK_OBFDOM,J_CHICKENPOX_37,J_CHICKENPOX_43,J_CHICKENPOX_92,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f202.google.com (HELO mail-px0-f202.google.com) (209.85.216.202) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 25 Jun 2009 03:32:44 +0000 Received: by pxi40 with SMTP id 40so982143pxi.12 for ; Wed, 24 Jun 2009 20:32:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.143.35.15 with SMTP id n15mr765350wfj.35.1245900762719; Wed, 24 Jun 2009 20:32:42 -0700 (PDT) In-Reply-To: <4A429163.6080109@vmware.com> References: <4A429163.6080109@vmware.com> Date: Thu, 25 Jun 2009 03:33:00 -0000 Message-ID: Subject: Re: [PATCH] New testsuite directory gdb.reverse, and tests From: Hui Zhu To: Michael Snyder Cc: gdb-patches@sourceware.org, jakob@virtutech.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-06/txt/msg00667.txt.bz2 Hi Michael, Thanks for your work. :) And I got a error when configure: config.status: creating gdb.server/Makefile config.status: creating gdb.java/Makefile config.status: creating gdb.mi/Makefile config.status: creating gdb.modula2/Makefile config.status: creating gdb.objc/Makefile config.status: creating gdb.opt/Makefile config.status: creating gdb.pascal/Makefile config.status: creating gdb.python/Makefile config.status: creating gdb.reverse/Makefile config.status: error: cannot find input file: gdb.reverse/Makefile.in I think because your patch doesn't include it. Thanks, Hui On Thu, Jun 25, 2009 at 04:49, Michael Snyder wrote: > Here are some new tests to test reverse debugging. > I've moved the test solib-reverse (submitted earlier) into this directory. > > Since most targets don't (yet) implement reverse debugging, > these tests all return with no results unless you add the > following to your board description file: > > =A0 =A0set_board_info gdb,can_reverse 1 > > In addition, since Process Record requires some special > commands that will not be used by remote debug targets > such as SID and Simics (eg. to start and stop recording), > you'll also want to define the following for process record: > > =A0 =A0set_board_info gdb,use_precord 1 > > I hope that the Virtutech folk will try out these tests > using Simics and let me know if any changes are required. > > OK, to commit? > > > 2009-06-24 =A0Michael Snyder =A0 > > =A0 =A0 =A0 =A0* gdb.reverse: New directory. > =A0 =A0 =A0 =A0* gdb.reverse/break-reverse.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/break-reverse.exp: New test. > =A0 =A0 =A0 =A0* gdb.reverse/consecutive-reverse.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/consecutive-reverse.exp: New test. > =A0 =A0 =A0 =A0* gdb.reverse/finish-reverse.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/finish-reverse.exp: New test. > =A0 =A0 =A0 =A0* gdb.reverse/machinestate.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/machinestate1.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/machinestate.exp: New test. > =A0 =A0 =A0 =A0* gdb.reverse/Makefile.in: New file. > =A0 =A0 =A0 =A0* gdb.reverse/shr2.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/solib-reverse.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/solib-reverse.exp: New test. > =A0 =A0 =A0 =A0* gdb.reverse/step-reverse.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/step-reverse.exp: New test. > =A0 =A0 =A0 =A0* gdb.reverse/until-reverse.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/until-reverse1.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/until-reverse.exp: New test. > =A0 =A0 =A0 =A0* gdb.reverse/watch-reverse.c: New test. > =A0 =A0 =A0 =A0* gdb.reverse/watch-reverse.exp: New test. > =A0 =A0 =A0 =A0* configure.ac (AC_OUTPUT): Add gdb.reverse/Makefile. > =A0 =A0 =A0 =A0* configure: Regenerate. > > Index: configure > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/testsuite/configure,v > retrieving revision 1.29 > diff -u -p -r1.29 configure > --- configure =A0 19 Oct 2008 19:59:31 -0000 =A0 =A0 =A01.29 > +++ configure =A0 24 Jun 2009 20:38:54 -0000 > @@ -3131,7 +3131,7 @@ done > > > > - > > > =A0ac_config_files=3D"$ac_config_files Makefile gdb.ada/Makefile > gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile > gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile > gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile > gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile > gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile" > + > > > =A0ac_config_files=3D"$ac_config_files Makefile gdb.ada/Makefile > gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile > gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile > gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile > gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile > gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile > gdb.xml/Makefile" > =A0cat >confcache <<\_ACEOF > =A0# This file is a shell script that caches the results of configure > =A0# tests run on this system so they can be shared between configure > @@ -3699,6 +3699,7 @@ do > =A0 "gdb.opt/Makefile" ) CONFIG_FILES=3D"$CONFIG_FILES gdb.opt/Makefile" = ;; > =A0 "gdb.pascal/Makefile" ) CONFIG_FILES=3D"$CONFIG_FILES gdb.pascal/Make= file" > ;; > =A0 "gdb.python/Makefile" ) CONFIG_FILES=3D"$CONFIG_FILES gdb.python/Make= file" > ;; > + =A0"gdb.reverse/Makefile" ) CONFIG_FILES=3D"$CONFIG_FILES > gdb.reverse/Makefile" ;; > =A0 "gdb.threads/Makefile" ) CONFIG_FILES=3D"$CONFIG_FILES gdb.threads/Ma= kefile" > ;; > =A0 "gdb.trace/Makefile" ) CONFIG_FILES=3D"$CONFIG_FILES gdb.trace/Makefi= le" ;; > =A0 "gdb.xml/Makefile" ) CONFIG_FILES=3D"$CONFIG_FILES gdb.xml/Makefile" = ;; > Index: configure.ac > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/testsuite/configure.ac,v > retrieving revision 1.12 > diff -u -p -r1.12 configure.ac > --- configure.ac =A0 =A0 =A0 =A019 Oct 2008 19:59:31 -0000 =A0 =A0 =A01.12 > +++ configure.ac =A0 =A0 =A0 =A024 Jun 2009 20:38:54 -0000 > @@ -117,5 +117,5 @@ AC_OUTPUT([Makefile \ > =A0 gdb.fortran/Makefile gdb.server/Makefile \ > =A0 gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile \ > =A0 gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \ > - =A0gdb.python/Makefile \ > + =A0gdb.python/Makefile gdb.reverse/Makefile \ > =A0 gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile]) > Index: gdb.reverse/break-reverse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/break-reverse.c > diff -N gdb.reverse/break-reverse.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/break-reverse.c 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,37 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008, 2009 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +int xyz; > + > +int bar () > +{ > + =A0xyz =3D 2; /* break in bar */ > + =A0return 1; > +} > + > +int foo () > +{ > + =A0xyz =3D 1; /* break in foo */ > + =A0return bar (); > +} > + > +int main () > +{ > + =A0xyz =3D 0; =A0 =A0 /* break in main */ > + =A0foo (); > + =A0return (xyz =3D=3D 2 ? 0 : 1); > +} =A0 =A0 =A0 =A0 =A0 =A0 =A0/* end of main */ > Index: gdb.reverse/break-reverse.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/break-reverse.exp > diff -N gdb.reverse/break-reverse.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/break-reverse.exp =A0 =A0 =A0 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,89 @@ > +# =A0 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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see . > + > +# This file was written by Michael Snyder (msnyder@vmware.com). > + > +# > +# Test reverse debugging with breakpoints. > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "break-reverse" > +set srcfile =A0${testfile}.c > + > +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { > + =A0 =A0return -1 > +} > + > +set foo_location =A0[gdb_get_line_number "break in foo" ] > +set bar_location =A0[gdb_get_line_number "break in bar" ] > +set main_location [gdb_get_line_number "break in main"] > +set end_location =A0[gdb_get_line_number "end of main" =A0] > + > +runto main > + > +if [target_info exists gdb,use_precord] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +gdb_test "break foo" \ > + =A0 =A0"Breakpoint $decimal at .* line $foo_location\." \ > + =A0 =A0"set breakpoint on foo" > + > +gdb_test "break bar" \ > + =A0 =A0"Breakpoint $decimal at .* line $bar_location\." \ > + =A0 =A0"set breakpoint on bar" > + > +gdb_test "break $end_location" \ > + =A0 =A0"Breakpoint $decimal at .* line $end_location\." \ > + =A0 =A0set breakpoint at end of main" > + > +gdb_continue_to_breakpoint "foo" ".*/$srcfile:$foo_location.*" > +gdb_continue_to_breakpoint "bar" ".*/$srcfile:$bar_location.*" > +gdb_continue_to_breakpoint "end" ".*/$srcfile:$end_location.*" > + > +# 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" =A0".*/$srcfile:$bar_location.= *" > +gdb_continue_to_breakpoint "foo backward" =A0".*/$srcfile:$foo_location.= *" > + > +gdb_test_multiple "continue" "main backward" { > + =A0 =A0-re ".*Breakpoint $decimal,.*/$srcfile:$main_location.*$gdb_prom= pt $" { > + =A0 =A0 =A0 pass "main backward" > + =A0 =A0} > + =A0 =A0-re "No more reverse-execution history.* break in main .*$gdb_pr= ompt $" > { > + =A0 =A0 =A0 pass "main backward" > + =A0 =A0} > +} > + > +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" { > + =A0 =A0-re ".*Breakpoint $decimal,.*/$srcfile:$end_location.*$gdb_promp= t $" { > + =A0 =A0 =A0 pass "end of record log" > + =A0 =A0} > + =A0 =A0-re "No more reverse-execution history.* end of main .*$gdb_prom= pt $" { > + =A0 =A0 =A0 pass "end of record log" > + =A0 =A0} > +} > Index: gdb.reverse/consecutive-reverse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/consecutive-reverse.c > diff -N gdb.reverse/consecutive-reverse.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/consecutive-reverse.c =A0 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,37 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008, 2009 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +/* > + =A0 Purpose of this test: =A0to test breakpoints on consecutive instruc= tions. > +*/ > + > +int a[7] =3D {1, 2, 3, 4, 5, 6, 7}; > + > +/* assert: first line of foo has more than one instruction. */ > +int foo () > +{ > + =A0return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]; > +} > + > +main() > +{ > +#ifdef usestubs > + =A0 =A0set_debug_traps (); > + =A0 =A0breakpoint (); > +#endif > + =A0foo (); > +} > Index: gdb.reverse/consecutive-reverse.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/consecutive-reverse.exp > diff -N gdb.reverse/consecutive-reverse.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/consecutive-reverse.exp 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,131 @@ > +# =A0 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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see . > + > +# Please email any bugs, comments, and/or additions to this file to: > +# bug-gdb@prep.ai.mit.edu > + > +# Based on a file written by Michael Snyder. (msnyder@redhat.com) > + > +# > +# Test reverse debugging breakpoints at consecutive instruction addresse= s. > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "consecutive-reverse" > +set srcfile ${testfile}.c > + > +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { > + =A0 =A0return -1 > +} > + > +runto main > + > +if [target_info exists gdb,use_precord] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +gdb_breakpoint foo > +gdb_test "continue" "Breakpoint $decimal, foo .*" \ > + =A0 =A0 =A0 "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 { > + =A0 =A0global hex > + =A0 =A0global foo1_addr > + =A0 =A0global foo2_addr > + =A0 =A0global gdb_prompt > + > + =A0 =A0-re "($hex).*\[\r\n\]+($hex).*$gdb_prompt $" { > + =A0 =A0 =A0 set foo1_addr $expect_out(1,string) > + =A0 =A0 =A0 set foo2_addr $expect_out(2,string) > + =A0 =A0 =A0 pass "get breakpoint address for foo" > + =A0 =A0} > + =A0 =A0-re ".*$gdb_prompt $" { > + =A0 =A0 =A0 fail "get breakpoint address for foo" > + =A0 =A0 =A0 return 0; > + =A0 =A0} > + =A0 =A0timeout { > + =A0 =A0 =A0 fail "get breakpoint address for foo (timeout)" > + =A0 =A0 =A0 return 0; > + =A0 =A0} > +} > + > +gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .= *" > \ > + =A0 =A0 =A0 "set bp, 2nd instr" > + > +send_gdb "step\n" > +gdb_expect { > + =A0 =A0-re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { > + =A0 =A0 =A0 set stop_addr $expect_out(1,string) > + =A0 =A0 =A0 if [eval expr "$foo2_addr =3D=3D $stop_addr"] then { > + =A0 =A0 =A0 =A0 =A0 pass "stopped at bp, 2nd instr" > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 fail "stopped at bp, 2nd instr (wrong address)" > + =A0 =A0 =A0 } > + =A0 =A0} > + =A0 =A0-re ".*$gdb_prompt $" { > + =A0 =A0 =A0 fail "stopped at bp, 2nd instr" > + =A0 =A0} > + =A0 =A0timeout { > + =A0 =A0 =A0 fail "stopped at bp, 2nd instr (timeout)" > + > + =A0 =A0} > +} > + > +### > +### > +### > + > +# 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" { > + =A0 =A0-re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { > + =A0 =A0 =A0 set stop_addr $expect_out(1,string) > + =A0 =A0 =A0 if [eval expr "$foo1_addr =3D=3D $stop_addr"] then { > + =A0 =A0 =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 fail "$test_msg (wrong address)" > + =A0 =A0 =A0 } > + =A0 =A0} > + =A0 =A0-re "Breakpoint $decimal, foo.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "print \$pc =3D=3D $foo1_addr\n" > + =A0 =A0 =A0 gdb_expect { > + =A0 =A0 =A0 =A0 =A0 -re "$decimal =3D 1\[\r\n\]+$gdb_prompt $" { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 -re "$decimal =3D 0\[\r\n\]+$gdb_prompt $" { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fail "$test_msg (wrong address)" > + =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } > + =A0 =A0} > + =A0 =A0-re ".*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_msg" > + =A0 =A0} > +} > Index: gdb.reverse/finish-reverse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/finish-reverse.c > diff -N gdb.reverse/finish-reverse.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/finish-reverse.c =A0 =A0 =A0 =A024 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,127 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008, 2009 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +/* Test gdb's "return" command in reverse. =A0*/ > + > +int void_test =3D 0; > +int main_test =3D 0; > + > +char =A0 =A0 =A0char_returnval =A0 =A0 =A0=3D '1'; > +short =A0 =A0 short_returnval =A0 =A0 =3D 1; > +int =A0 =A0 =A0 int_returnval =A0 =A0 =A0 =3D 1; > +long =A0 =A0 =A0long_returnval =A0 =A0 =A0=3D 1; > +long long long_long_returnval =3D 1; > +float =A0 =A0 float_returnval =A0 =A0 =3D 1; > +double =A0 =A0double_returnval =A0 =A0=3D 1; > + > +union { > + =A0char =A0 =A0 =A0char_testval; > + =A0short =A0 =A0 short_testval; > + =A0int =A0 =A0 =A0 int_testval; > + =A0long =A0 =A0 =A0long_testval; > + =A0long long long_long_testval; > + =A0float =A0 =A0 float_testval; > + =A0double =A0 =A0double_testval; > + =A0char =A0 =A0 =A0ffff[80]; > +} testval; > + > +void void_func () > +{ > + =A0void_test =3D 1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* VOID FUNC */ > +} > + > +char char_func () > +{ > + =A0return char_returnval; =A0 =A0 =A0 /* CHAR FUNC */ > +} > + > +short short_func () > +{ > + =A0return short_returnval; =A0 =A0 =A0/* SHORT FUNC */ > +} > + > +int int_func () > +{ > + =A0return int_returnval; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* INT FUNC */ > +} > + > +long long_func () > +{ > + =A0return long_returnval; =A0 =A0 =A0 /* LONG FUNC */ > +} > + > +long long long_long_func () > +{ > + =A0return long_long_returnval; =A0/* LONG LONG FUNC */ > +} > + > +float float_func () > +{ > + =A0return float_returnval; =A0 =A0 =A0/* FLOAT FUNC */ > +} > + > +double double_func () > +{ > + =A0return double_returnval; =A0 =A0 /* DOUBLE FUNC */ > +} > + > +int main (int argc, char **argv) > +{ > + =A0char char_resultval; > + =A0short short_resultval; > + =A0int int_resultval; > + =A0long long_resultval; > + =A0long long long_long_resultval; > + =A0float float_resultval; > + =A0double double_resultval; > + =A0int i; > + > + =A0/* A "test load" that will insure that the function really returns > + =A0 =A0 a ${type} (as opposed to just a truncated or part of a ${type})= . =A0*/ > + =A0for (i =3D 0; i < sizeof (testval.ffff); i++) > + =A0 =A0testval.ffff[i] =3D 0xff; > + > + =A0void_func (); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0/* call to void_func */ > + =A0char_resultval =A0 =A0 =A0=3D char_func (); =A0 =A0 =A0 =A0 =A0/* vo= id_checkpoint */ > + =A0short_resultval =A0 =A0 =3D short_func (); =A0 =A0 =A0 =A0 /* char_c= heckpoint */ > + =A0int_resultval =A0 =A0 =A0 =3D int_func (); =A0 =A0 =A0 =A0 =A0 /* sh= ort_checkpoint */ > + =A0long_resultval =A0 =A0 =A0=3D long_func (); =A0 =A0 =A0 =A0 =A0/* in= t_checkpoint */ > + =A0long_long_resultval =3D long_long_func (); =A0 =A0 /* long_checkpoin= t */ > + > + =A0/* On machines using IEEE floating point, the test pattern of all > + =A0 =A0 1-bits established above turns out to be a floating-point NaN > + =A0 =A0 ("Not a Number"). =A0According to the IEEE rules, NaN's aren't = even > + =A0 =A0 equal to themselves. =A0This can lead to stupid conversations w= ith > + =A0 =A0 GDB like: > + > + =A0 =A0 =A0 (gdb) p testval.float_testval =3D=3D testval.float_testval > + =A0 =A0 =A0 $7 =3D 0 > + =A0 =A0 =A0 (gdb) > + > + =A0 =A0 This is the correct answer, but it's not the sort of thing > + =A0 =A0 return2.exp wants to see. =A0So to make things work the way they > + =A0 =A0 ought, we'll set aside the `union' cleverness and initialize the > + =A0 =A0 test values explicitly here. =A0These values have interesting b= its > + =A0 =A0 throughout the value, so we'll still detect truncated values. = =A0*/ > + > + =A0testval.float_testval =3D 2.7182818284590452354;/* long_long_checkpo= int */ > + =A0float_resultval =A0 =A0 =3D float_func (); > + =A0testval.double_testval =3D 3.14159265358979323846; /* float_checkpoi= nt */ > + =A0double_resultval =A0 =A0=3D double_func (); > + =A0main_test =3D 1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 /* double_checkpoint */ > + =A0return 0; > +} > Index: gdb.reverse/finish-reverse.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/finish-reverse.exp > diff -N gdb.reverse/finish-reverse.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/finish-reverse.exp =A0 =A0 =A024 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,264 @@ > +# 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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see . > + > +# Please email any bugs, comments, and/or additions to this file to: > +# bug-gdb@prep.ai.mit.edu > + > +# > +# Test "reverse-finish" command > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "finish-reverse" > +set srcfile ${testfile}.c > + > +if { [prepare_for_testing $testfile.exp "$testfile" $srcfile] } { > + =A0 =A0return -1 > +} > + > +proc test_start_of_line { line_text test_msg } { > + =A0 =A0global gdb_prompt > + =A0 =A0global decimal > + =A0 =A0global hex > + > + =A0 =A0send_gdb "info line\n" > + =A0 =A0gdb_expect { > + =A0 =A0 =A0 -re "Line $decimal of .* starts at address ($hex) .*$gdb_pr= ompt $" { > + =A0 =A0 =A0 =A0 =A0 set line_begin $expect_out(1,string) > + =A0 =A0 =A0 } > + =A0 =A0 =A0 default { > + =A0 =A0 =A0 =A0 =A0 fail "Get line address in test_start_of_line" > + =A0 =A0 =A0 } > + =A0 =A0} > + =A0 =A0send_gdb "info reg pc\n" > + =A0 =A0gdb_expect { > + =A0 =A0 =A0 -re ".*: ($hex)\r\n*$gdb_prompt $" { > + =A0 =A0 =A0 =A0 =A0 set stop_pc $expect_out(1,string) > + =A0 =A0 =A0 } > + =A0 =A0 =A0 default { > + =A0 =A0 =A0 =A0 =A0 fail"Get stop pc in test_start_of_line" > + =A0 =A0 =A0 } > + =A0 =A0} > + =A0 =A0gdb_test "print $line_begin =3D=3D $stop_pc" \ > + =A0 =A0 =A0 " =3D 1\[\r\n\]*" \ > + =A0 =A0 =A0 "test_start_of_line, $test_msg" > +} > + > +runto main > + > +if [target_info exists gdb,use_precord] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +# Test finish from void func > + > +set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"] > +gdb_test "break void_func" \ > + =A0 =A0"Breakpoint $decimal at .*/$srcfile, line $breakloc\." \ > + =A0 =A0"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" { > + =A0 =A0-re " call to void_func .*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re " void_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > +} > + > +# Test finish from char func > + > +set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"] > +gdb_test "break char_func" \ > + =A0 =A0"Breakpoint $decimal at .*/$srcfile, line $breakloc\." \ > + =A0 =A0"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" { > + =A0 =A0-re " void_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re " char_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > +} > + > +# Test finish from short func > + > +set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"] > +gdb_test "break short_func" \ > + =A0 =A0"Breakpoint $decimal at .* line $breakloc\." \ > + =A0 =A0"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" { > + =A0 =A0-re " char_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re " short_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > +} > + > +# Test finish from int func > + > +set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"] > +gdb_test "break int_func" \ > + =A0 =A0"Breakpoint $decimal at .* line $breakloc\." \ > + =A0 =A0"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" { > + =A0 =A0-re " short_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re " int_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > +} > + > +# Test finish from long func > + > +set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"] > +gdb_test "break long_func" \ > + =A0 =A0"Breakpoint $decimal at .* line $breakloc\." \ > + =A0 =A0"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" { > + =A0 =A0-re " int_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re " long_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > +} > + > +# Test finish from long long func > + > +set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"] > +gdb_test "break long_long_func" \ > + =A0 =A0"Breakpoint $decimal at .* line $breakloc\." \ > + =A0 =A0"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" { > + =A0 =A0-re " long_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re " long_long_checkpoint .*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > +} > + > + > +### > +### > +### > + > +# 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" { > + =A0 =A0-re ".* long_checkpoint.*$gdb_prompt $" { > + =A0 =A0 =A0 test_start_of_line "long_checkpoint" "$test_msg" > + =A0 =A0} > +} > + > +# 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" { > + =A0 =A0-re ".* int_checkpoint.*$gdb_prompt $" { > + =A0 =A0 =A0 test_start_of_line "int_checkpoint" "$test_msg" > + =A0 =A0} > +} > + > +# 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" { > + =A0 =A0-re ".* short_checkpoint.*$gdb_prompt $" { > + =A0 =A0 =A0 test_start_of_line "short_checkpoint" "$test_msg" > + =A0 =A0} > +} > + > +# 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" { > + =A0 =A0-re ".* char_checkpoint.*$gdb_prompt $" { > + =A0 =A0 =A0 test_start_of_line "char_checkpoint" "$test_msg" > + =A0 =A0} > +} > + > +# 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" { > + =A0 =A0-re ".* void_checkpoint.*$gdb_prompt $" { > + =A0 =A0 =A0 test_start_of_line "void_checkpoint" "$test_msg" > + =A0 =A0} > +} > + > +# 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" { > + =A0 =A0-re ".* call to void_func.*$gdb_prompt $" { > + =A0 =A0 =A0 test_start_of_line "call to void_func" "$test_msg" > + =A0 =A0} > +} > + > +return 0 > Index: gdb.reverse/machinestate.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/machinestate.c > diff -N gdb.reverse/machinestate.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/machinestate.c =A024 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,101 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008, 2009 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +/* > + * Test restoration of machine state > + */ > + > +extern void hide (int); > + > +/* Test register variable > + =A0 Requires -- compiler honors 'register'. =A0*/ > + > +void > +register_state (void) > +{ > + =A0register int a =3D 0; > + > + =A0hide (a); =A0 =A0/* External function to defeat optimization. =A0*/ > + =A0a++; =A0 =A0 =A0 =A0 /* register_state: set breakpoint here */ > + =A0hide (a); =A0 =A0/* register post-change */ > +} > + > +/* Test auto variable (whatever that means). =A0*/ > + > +void > +auto_state (void) > +{ > + =A0auto int a =3D 0; > + > + =A0hide (a); =A0 =A0/* External function to defeat optimization. =A0*/ > + =A0a++; =A0 =A0 =A0 =A0 /* auto_state: set breakpoint here */ > + =A0hide (a); =A0 =A0/* auto post-change */ > +} > + > +/* Test function-static variable. =A0*/ > + > +void > +function_static_state (void) > +{ > + =A0static int a =3D 0; > + > + =A0hide (a); =A0 =A0/* External function to defeat optimization. =A0*/ > + =A0a++; =A0 =A0 =A0 =A0 /* function_static_state: set breakpoint here */ > + =A0hide (a); =A0 =A0/* function static post-change */ > +} > + > +/* Test module-static variable. =A0*/ > + > +static int astatic; > + > +void > +module_static_state (void) > +{ > + =A0astatic =3D 0; > + > + =A0hide (astatic); =A0 =A0 =A0/* External function to defeat optimizati= on. =A0*/ > + =A0astatic++; =A0 =A0 =A0 =A0 =A0 /* module_static_state: set breakpoin= t here */ > + =A0hide (astatic); =A0 =A0 =A0/* module static post-change */ > +} > + > +/* Test module-global variable. =A0*/ > + > +int aglobal; > + > +void > +module_global_state (void) > +{ > + =A0aglobal =3D 0; > + > + =A0hide (aglobal); =A0 =A0 =A0/* External function to defeat optimizati= on. =A0*/ > + =A0aglobal++; =A0 =A0 =A0 =A0 =A0 /* module_global_state: set breakpoin= t here */ > + =A0hide (aglobal); =A0 =A0 =A0/* module global post-change */ > +} > + > +/* main test driver */ > + > +int > +main (int argc, char **argv) > +{ > + =A0register_state (); =A0 /* begin main */ > + =A0auto_state (); > + =A0function_static_state (); > + =A0module_static_state (); > + =A0module_global_state (); > + > + =A0return 0; =A0 =A0 =A0 =A0 =A0 =A0/* end main */ > +} > Index: gdb.reverse/machinestate.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/machinestate.exp > diff -N gdb.reverse/machinestate.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/machinestate.exp =A0 =A0 =A0 =A024 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,233 @@ > +# 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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see . > + > +# Please email any bugs, comments, and/or additions to this file to: > +# bug-gdb@prep.ai.mit.edu > + > +# > +# This test tests the restoration of various kinds of machine state > +# to their original values by reverse execution. =A0We 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: > +# =A0 register variable > +# =A0 auto variable > +# =A0 function static variable > +# =A0 module static variable > +# =A0 module global variable > +# > +# TODO: > +# various, possibly including... > +# =A0 .bss variable, .data variable, ... > +# =A0 shared library variable > +# =A0 heap variable (pointer)... > +# =A0 overlay variables... > +# =A0 Test forward replay > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "machinestate" > +set srcfile =A0${testfile}.c > +set srcfile1 ${testfile}1.c > + > +if { [prepare_for_testing $testfile.exp $testfile {machinestate.c > machinestate1.c} ] } { > + =A0 =A0return -1 > +} > + > +set newline "\[\r\n\]+" > + > +set beginmain [gdb_get_line_number " begin main " $srcfile] > +set endmain =A0 [gdb_get_line_number " end main " =A0 $srcfile] > + > +# Test begins > + > +runto main > + > +if [target_info exists gdb,use_precord] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +# Proceed to end of main > + > +gdb_test "break $endmain" \ > + =A0 =A0"Breakpoint.* file .*/$srcfile, line $endmain.*" "" > +gdb_continue_to_breakpoint "end of main" ".*/$srcfile:$endmain.*" > + > +### > +### > +### > + > +# Now run backward to each of several points where data is changed. > +# > + > +# Module global variable, reverse > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "module_global_state: set breakpoint he= re" $srcfile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to > $breakloc" > + > +gdb_test "print aglobal" ".* =3D 0$newline" =A0"module global > reverse-breakpoint" > +gdb_test "step" =A0 =A0 =A0 =A0 =A0".* module global post-change .*" "" > +gdb_test "print aglobal" ".* =3D 1$newline" =A0"module global forward pa= st bp" > +gdb_test "reverse-step" =A0".*$newline$breakloc.*" "" > +gdb_test "print aglobal" ".* =3D 0$newline" =A0"module global reverse-st= ep to > bp" > + > + > +# Module static variable, reverse > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "module_static_state: set breakpoint he= re" $srcfile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to > $breakloc" > + > +gdb_test "print astatic" ".* =3D 0$newline" =A0"module static > reverse-breakpoint" > +gdb_test "step" =A0 =A0 =A0 =A0 =A0".* module static post-change .*" "" > +gdb_test "print astatic" ".* =3D 1$newline" =A0"module static forward" > +gdb_test "reverse-step" =A0".*$newline$breakloc.*" "" > +gdb_test "print astatic" ".* =3D 0$newline" =A0"module static reverse-st= ep" > + > +# Function static variable, reverse > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "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" =A0 =A0 =A0".* =3D 0$newline" =A0"function static > reverse-breakpoint" > +gdb_test "step" =A0 =A0 =A0 =A0 ".* function static post-change .*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 1$newline" =A0"function static for= ward" > +gdb_test "reverse-step" ".*$newline$breakloc.*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"function static rev= erse-step" > + > +# Auto variable, reverse > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "auto_state: set breakpoint here" $srcf= ile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to > $breakloc" > + > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"auto var reverse-br= eakpoint" > +gdb_test "step" =A0 =A0 =A0 =A0 ".* auto post-change .*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 1$newline" =A0"auto var forward" > +gdb_test "reverse-step" ".*$newline$breakloc.*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"auto var reverse-st= ep" > + > +# Register variable, reverse > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "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" =A0 =A0 =A0".* =3D 0$newline" =A0"register var revers= e-breakpoint" > +gdb_test "step" =A0 =A0 =A0 =A0 ".* register post-change .*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 1$newline" =A0"register var step p= ost-change" > +gdb_test "reverse-step" ".*$newline$breakloc.*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"register var revers= e step-to" > + > +# Proceed to beginning of main > + > +gdb_test "tbreak $beginmain" ".*/$srcfile, line $beginmain.*" "" > +gdb_test "reverse-continue" =A0".*/$srcfile:$beginmain.*" "reverse to ma= in" > + > +# Now repeat tests while replaying forward. > + > +# Register variable, forward > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "register_state: set breakpoint here" $= srcfile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "continue" =A0 =A0 =A0 =A0 ".*/$srcfile:$breakloc.*" "forward to > $breakloc" > + > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"register var forwar= d-breakpoint" > +gdb_test "reverse-step" ".*hide.*" "" > +gdb_test "step" =A0 =A0 =A0 =A0 ".*$newline$breakloc.*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"register var forwar= d step-to" > +gdb_test "step" =A0 =A0 =A0 =A0 ".* register post-change .*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 1$newline" =A0"register var step p= ost-change" > + > +# Auto variable, forward > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "auto_state: set breakpoint here" $srcf= ile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "continue" =A0 =A0 =A0 =A0 ".*/$srcfile:$breakloc.*" "forward to > $breakloc" > + > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"auto var forward-br= eakpoint" > +gdb_test "reverse-step" ".*hide.*" "" > +gdb_test "step" =A0 =A0 =A0 =A0 ".*$newline$breakloc.*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"auto var forward st= ep-to" > +gdb_test "step" =A0 =A0 =A0 =A0 ".* auto post-change .*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 1$newline" =A0"auto var step post-= change" > + > +# Function static variable, forward > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "function_static_state: set breakpoint = here" $srcfile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "continue" =A0 =A0 =A0 =A0 ".*/$srcfile:$breakloc.*" "forward to > $breakloc" > + > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"function static > forward-breakpoint" > +gdb_test "reverse-step" ".*hide.*" "" > +gdb_test "step" =A0 =A0 =A0 =A0 ".*$newline$breakloc.*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 0$newline" =A0"function static for= ward step-to" > +gdb_test "step" =A0 =A0 =A0 =A0 ".* function static post-change .*" "" > +gdb_test "print a" =A0 =A0 =A0".* =3D 1$newline" =A0"function static step > post-change" > + > +# Module static variable, forward > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "module_static_state: set breakpoint he= re" $srcfile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "continue" =A0 =A0 =A0 =A0 ".*/$srcfile:$breakloc.*" "forward to > $breakloc" > + > +gdb_test "print astatic" ".* =3D 0$newline" =A0"module static > forward-breakpoint" > +gdb_test "reverse-step" =A0".*hide.*" "" > +gdb_test "step" =A0 =A0 =A0 =A0 =A0".*$newline$breakloc.*" "" > +gdb_test "print astatic" ".* =3D 0$newline" =A0"module static forward st= ep-to" > +gdb_test "step" =A0 =A0 =A0 =A0 =A0".* module static post-change .*" "" > +gdb_test "print astatic" ".* =3D 1$newline" =A0"module static step post-= change" > + > +# Module global variable, forward > + > +set breakloc [gdb_get_line_number \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "module_global_state: set breakpoint he= re" $srcfile] > + > +gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" > +gdb_test "continue" =A0 =A0 =A0 =A0 ".*/$srcfile:$breakloc.*" "forward to > $breakloc" > + > +gdb_test "print aglobal" ".* =3D 0$newline" =A0"module global > forward-breakpoint" > +gdb_test "reverse-step" =A0".*hide.*" "" > +gdb_test "step" =A0 =A0 =A0 =A0 =A0".*$newline$breakloc.*" "" > +gdb_test "print aglobal" ".* =3D 0$newline" =A0"module global forward st= ep-to" > +gdb_test "step" =A0 =A0 =A0 =A0 =A0".* module global post-change .*" "" > +gdb_test "print aglobal" ".* =3D 1$newline" =A0"module global step post-= change" > + > Index: gdb.reverse/machinestate1.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/machinestate1.c > diff -N gdb.reverse/machinestate1.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/machinestate1.c 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,25 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +/* > + * Aux function for machine state test. > + */ > + > +void > +hide (int x) > +{ > +} > Index: gdb.reverse/shr2.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/shr2.c > diff -N gdb.reverse/shr2.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/shr2.c =A024 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,34 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2009 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +#ifdef PROTOTYPES > +int shr2(int x) > +#else > +int shr2(x) int x; > +#endif > +{ > + =A0return 2*x; > +} > + > +#ifdef PROTOTYPES > +int shr2_local(int x) > +#else > +int shr2_local(x) int x; > +#endif > +{ > + =A0return 2*x; > +} > Index: gdb.reverse/solib-reverse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/solib-reverse.c > diff -N gdb.reverse/solib-reverse.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/solib-reverse.c 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,43 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2009 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +/* Test reverse debugging of shared libraries. =A0*/ > + > +#include > + > +/* Shared library function */ > +extern int shr2(int); > + > +int main () > +{ > + =A0char* cptr =3D "String 1"; > + =A0int b[2] =3D {5,8}; > + > + =A0b[0] =3D shr2(12); =A0 =A0 =A0 =A0 =A0 =A0 /* begin part two */ > + =A0b[1] =3D shr2(17); =A0 =A0 =A0 =A0 =A0 =A0 /* middle part two */ > + > + =A0b[0] =3D 6; =A0 b[1] =3D 9; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* generi= c statement, end part two > */ > + =A0printf ("message 1\n"); =A0 =A0 =A0/* printf one */ > + =A0printf ("message 2\n"); =A0 =A0 =A0/* printf two */ > + =A0printf ("message 3\n"); =A0 =A0 =A0/* printf three */ > + =A0sleep (0); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* sleep one */ > + =A0sleep (0); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* sleep two */ > + =A0sleep (0); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* sleep three */ > + > + =A0return 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* end part one */ > +} > + > Index: gdb.reverse/solib-reverse.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/solib-reverse.exp > diff -N gdb.reverse/solib-reverse.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/solib-reverse.exp =A0 =A0 =A0 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,127 @@ > +# 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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see . > + > +# This file was written by Michael Snyder (msnyder@vmware.com). > + > +# > +# Test reverse debugging with shared libraries. > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "solib-reverse" > +set srcfile =A0${testfile}.c > +set libfile =A0"shr2" > +set libsrc =A0 ${libfile}.c > +set library =A0${objdir}/${subdir}/${libfile}.sl > +set binfile =A0${objdir}/${subdir}/${testfile} > + > +if [get_compiler_info ${binfile}] { > + =A0 =A0return -1 > +} > + > +if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] > !=3D "" } { > + =A0 =A0untested "Could not compile shared library." > + =A0 =A0return -1 > +} > + > +set exec_opts [list debug shlib=3D${library}] > + > +if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable > $exec_opts] !=3D "" } { > + =A0 =A0untested "Could not compile $binfile." > + =A0 =A0return -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] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +# > +# 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 .*" =A0 "reverse-step second sleep" > +gdb_test "reverse-step" " sleep one .*" =A0 \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "reverse-step first sleep, dynsym r= esolve" > + > +gdb_test "reverse-step" " printf three .*" "reverse-step third printf" > +gdb_test "reverse-step" " printf two .*" =A0 "reverse-step second printf" > +gdb_test "reverse-step" " printf one .*" =A0 \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "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 on= e" > + > +gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep" > +gdb_test "reverse-next" " sleep two .*" =A0 "reverse-next second sleep" > +gdb_test "reverse-next" " sleep one .*" =A0 \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "reverse-next first sleep, dynsym r= esolve" > + > +gdb_test "reverse-next" " printf three .*" "reverse-next third printf" > +gdb_test "reverse-next" " printf two .*" =A0 "reverse-next second printf" > +gdb_test "reverse-next" " printf one .*" =A0 \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "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 functi= on > 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 functi= on > two" > +gdb_test "reverse-step" " begin part two.*" "reverse-step back to main t= wo" > + > +# > +# 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" > Index: gdb.reverse/step-reverse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/step-reverse.c > diff -N gdb.reverse/step-reverse.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/step-reverse.c =A024 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,78 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008, 2009 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > =A0*/ > + > +#include > +#include > + > +/* Test various kinds of stepping. > +*/ > +int myglob =3D 0; > + > +int callee() { =A0 =A0 =A0 =A0 /* ENTER CALLEE */ > + =A0myglob++; return 0; =A0/* ARRIVED IN CALLEE */ > +} =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* RETURN FROM CALLEE */ > + > +/* A structure which, we hope, will need to be passed using memcpy. =A0*/ > +struct rhomboidal { > + =A0int rather_large[100]; > +}; > + > +void > +large_struct_by_value (struct rhomboidal r) > +{ > + =A0myglob +=3D r.rather_large[42]; /* step-test.exp: arrive here 1 */ > +} > + > +int main () { > + =A0 int w,x,y,z; > + =A0 int a[10], b[10]; > + > + =A0 /* Test "next" and "step" */ > + =A0 w =3D 0; =A0 =A0 =A0/* BREAK AT MAIN */ > + =A0 x =3D 1; =A0 =A0 =A0/* NEXT TEST 1 */ > + =A0 y =3D 2; =A0 =A0 =A0/* STEP TEST 1 */ > + =A0 z =3D 3; =A0 =A0 =A0/* REVERSE NEXT TEST 1 */ > + =A0 w =3D w + 2; =A0/* NEXT TEST 2 */ > + =A0 x =3D x + 3; =A0/* REVERSE STEP TEST 1 */ > + =A0 y =3D y + 4; > + =A0 z =3D z + 5; =A0/* STEP TEST 2 */ > + > + =A0 /* Test that "next" goes over a call */ > + =A0 callee(); =A0 /* NEXT OVER THIS CALL */ > + > + =A0 /* Test that "step" doesn't */ > + =A0 callee(); =A0 /* STEP INTO THIS CALL */ > + > + =A0 /* Test "stepi" */ > + =A0 a[5] =3D a[3] - a[4]; /* FINISH TEST */ > + =A0 callee(); =A0 /* STEPI TEST */ > + > + =A0 /* Test "nexti" */ > + =A0 callee(); =A0 /* NEXTI TEST */ > + > + =A0 y =3D w + z; > + > + =A0 { > + =A0 =A0 struct rhomboidal r; > + =A0 =A0 memset (r.rather_large, 0, sizeof (r.rather_large)); > + =A0 =A0 r.rather_large[42] =3D 10; > + =A0 =A0 large_struct_by_value (r); =A0/* step-test.exp: large struct by= value */ > + =A0 } > + > + =A0 exit (0); > +} > + > Index: gdb.reverse/step-reverse.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/step-reverse.exp > diff -N gdb.reverse/step-reverse.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/step-reverse.exp =A0 =A0 =A0 =A024 Jun 2009 20:38:54 -0000 > @@ -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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see = . =A0*/ > +# step-reverse.exp -- Expect script to test reverse stepping in gdb. > +# Lots of code borrowed from "step-test.exp". > + > +# > +# Test step and next in reverse > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "step-reverse" > +set srcfile =A0${testfile}.c > + > +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { > + =A0 =A0return -1 > +} > + > +runto main > + > +if [target_info exists gdb,use_precord] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +# 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" { > + =A0 =A0-re "FINISH TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > + =A0 =A0-re "STEP INTO THIS CALL.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > +} > + > +# stepi over flat code (no calls) > + > +set test_message "simple stepi" > +gdb_test_multiple "stepi" "$test_message" { > + =A0 =A0-re "STEPI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > + =A0 =A0-re "FINISH TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "NEXTI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > +} > + > +# stepi into a function call > + > +set test_message "stepi into function call" > +gdb_test_multiple "stepi" "$test_message" { > + =A0 =A0-re "ARRIVED IN CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > + =A0 =A0-re "NEXTI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > + =A0 =A0-re "RETURN FROM CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > + =A0 =A0-re "ENTER CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > +} > + > +# stepi thru return of a function call > + > +set test_message "stepi back from function call" > +gdb_test_multiple "stepi" "$test_message" { > + =A0 =A0-re "NEXTI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > + =A0 =A0-re "ARRIVED IN CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "RETURN FROM CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "STEPI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "ENTER CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > +} > + > +### > +### > +### > + > +# 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 =A0[gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile= "] > +set test_message "reverse stepi thru function return" > +gdb_test_multiple "stepi" "$test_message" { > + =A0 =A0-re "NEXTI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (start statement)" > + =A0 =A0} > + =A0 =A0-re "RETURN FROM CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "$hex\[ \t\]*$stepi_location.*ARRIVED IN CALLEE.*$gdb_prompt= $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "ARRIVED IN CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > + =A0 =A0-re "ENTER CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > + =A0 =A0-re "STEPI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > +} > + > +# stepi backward out of a function call > + > +set stepi_location =A0[gdb_get_line_number "FINISH TEST" "$srcfile"] > +set test_message "reverse stepi from a function call" > +gdb_test_multiple "stepi" "$test_message" { > + =A0 =A0-re "ARRIVED IN CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (start statement)" > + =A0 =A0} > + =A0 =A0-re "ENTER CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "${hex}\[ \t\]*$stepi_location.*STEPI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "STEPI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > + =A0 =A0-re "STEP INTO THIS CALL.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > +} > + > +# stepi backward over flat code (no calls) > + > +set stepi_location =A0[gdb_get_line_number "FINISH TEST" "$srcfile"] > +set test_message "simple reverse stepi" > +gdb_test_multiple "stepi" "$test_message" { > + =A0 =A0-re "STEPI TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (start statement)" > + =A0 =A0} > + =A0 =A0-re "$hex\[ \t\]*$stepi_location.* FINISH TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "stepi\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "$stepi_location.* FINISH TEST.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > + =A0 =A0-re "STEP INTO THIS CALL.*$gdb_prompt $" { > + =A0 =A0 =A0 fail "$test_message (too far)" > + =A0 =A0} > +} > + > +# step backward into function (thru return) > + > +set test_message "reverse step into fn call" > +gdb_test_multiple "step" "$test_message" { > + =A0 =A0-re "RETURN FROM CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 send_gdb "step\n" > + =A0 =A0 =A0 exp_continue > + =A0 =A0} > + =A0 =A0-re "ARRIVED IN CALLEE.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_message" > + =A0 =A0} > +} > + > +# 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" > + > +return 0 > Index: gdb.reverse/until-reverse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/until-reverse.c > diff -N gdb.reverse/until-reverse.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/until-reverse.c 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,149 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008, 2009 > + =A0 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > + > + =A0 Please email any bugs, comments, and/or additions to this file to: > + =A0 bug-gdb@prep.ai.mit.edu =A0*/ > + > +#ifdef vxworks > + > +# =A0include > + > +/* VxWorks does not supply atoi. =A0*/ > +static int > +atoi (z) > + =A0 =A0 char *z; > +{ > + =A0int i =3D 0; > + > + =A0while (*z >=3D '0' && *z <=3D '9') > + =A0 =A0i =3D i * 10 + (*z++ - '0'); > + =A0return i; > +} > + > +/* I don't know of any way to pass an array to VxWorks. =A0This function > + =A0 can be called directly from gdb. =A0*/ > + > +vxmain (arg) > +char *arg; > +{ > + =A0char *argv[2]; > + > + =A0argv[0] =3D ""; > + =A0argv[1] =3D arg; > + =A0main (2, argv, (char **) 0); > +} > + > +#else /* ! vxworks */ > +# =A0include > +# =A0include > +#endif /* ! vxworks */ > + > +#ifdef PROTOTYPES > +extern int marker1 (void); > +extern int marker2 (int a); > +extern void marker3 (char *a, char *b); > +extern void marker4 (long d); > +#else > +extern int marker1 (); > +extern int marker2 (); > +extern void marker3 (); > +extern void marker4 (); > +#endif > + > +/* > + * =A0 =A0 This simple classical example of recursion is useful for > + * =A0 =A0 testing stack backtraces and such. > + */ > + > +#ifdef PROTOTYPES > +int factorial(int); > + > +int > +main (int argc, char **argv, char **envp) > +#else > +int > +main (argc, argv, envp) > +int argc; > +char *argv[], **envp; > +#endif > +{ > +#ifdef usestubs > + =A0 =A0set_debug_traps(); =A0/* set breakpoint 5 here */ > + =A0 =A0breakpoint(); > +#endif > + =A0 =A0if (argc =3D=3D 12345) { =A0/* an unlikely value < 2^16, in case= uninited */ > /* set breakpoint 6 here */ > + =A0 =A0 =A0 fprintf (stderr, "usage: =A0factorial \n"); > + =A0 =A0 =A0 return 1; > + =A0 =A0} > + =A0 =A0printf ("%d\n", factorial (atoi ("6"))); =A0/* set breakpoint 1 = here */ > + =A0 =A0/* set breakpoint 12 here */ > + =A0 =A0marker1 (); =A0/* set breakpoint 11 here */ > + =A0 =A0marker2 (43); /* set breakpoint 20 here */ > + =A0 =A0marker3 ("stack", "trace"); /* set breakpoint 21 here */ > + =A0 =A0marker4 (177601976L); > + =A0 =A0/* We're used by a test that requires malloc, so make sure it is > + =A0 =A0 =A0 in the executable. =A0*/ > + =A0 =A0(void)malloc (1); > + > + =A0 =A0argc =3D (argc =3D=3D 12345); /* This is silly, but we can step = off of it */ > /* set breakpoint 2 here */ > + =A0 =A0return argc; =A0/* set breakpoint 10 here */ > +} /* set breakpoint 10a here */ > + > +#ifdef PROTOTYPES > +int factorial (int value) > +#else > +int factorial (value) > +int value; > +#endif > +{ > + =A0if (value > 1) { =A0/* set breakpoint 7 here */ > + =A0 =A0 =A0 value *=3D factorial (value - 1); > + =A0 =A0} > + =A0 =A0return (value); /* set breakpoint 19 here */ > +} > + > +#ifdef PROTOTYPES > +int multi_line_if_conditional (int a, int b, int c) > +#else > +int multi_line_if_conditional (a, b, c) > + =A0int a, b, c; > +#endif > +{ > + =A0if (a =A0 =A0/* set breakpoint 3 here */ > + =A0 =A0 =A0&& b > + =A0 =A0 =A0&& c) > + =A0 =A0return 0; > + =A0else > + =A0 =A0return 1; > +} > + > +#ifdef PROTOTYPES > +int multi_line_while_conditional (int a, int b, int c) > +#else > +int multi_line_while_conditional (a, b, c) > + =A0int a, b, c; > +#endif > +{ > + =A0while (a /* set breakpoint 4 here */ > + =A0 =A0 =A0&& b > + =A0 =A0 =A0&& c) > + =A0 =A0{ > + =A0 =A0 =A0a--, b--, c--; > + =A0 =A0} > + =A0return 0; > +} > Index: gdb.reverse/until-reverse.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/until-reverse.exp > diff -N gdb.reverse/until-reverse.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/until-reverse.exp =A0 =A0 =A0 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,133 @@ > +# 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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see = . =A0*/ > + > +# Please email any bugs, comments, and/or additions to this file to: > +# bug-gdb@prep.ai.mit.edu > + > +# > +# Test 'until' and 'advance' in reverse. > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "until-reverse" > +set srcfile ${testfile}.c > +set srcfile1 ${testfile}1.c > + > +if { [prepare_for_testing $testfile.exp $testfile {until-reverse.c > until-reverse1.c} ] } { > + =A0 =A0return -1 > +} > + > +set bp_location1 =A0[gdb_get_line_number "set breakpoint 1 here"] > +set bp_location7 =A0[gdb_get_line_number "set breakpoint 7 here"] > +set bp_location9 =A0[gdb_get_line_number "set breakpoint 9 here" "$srcfi= le1"] > +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] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +# Verify that plain vanilla "until " works. > +# > +gdb_test "until $bp_location1" \ > + =A0 =A0"main .* at .*:$bp_location1.*" \ > + =A0 =A0"until line number" > + > +# Advance up to factorial, outer invocation > +# > +gdb_test "advance factorial" \ > + =A0 =A0"factorial .value=3D6..*$srcfile:$bp_location7.*" \ > + =A0 =A0"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" \ > + =A0 =A0"factorial .value=3D720.*${srcfile}:$bp_location19.*" \ > + =A0 =A0"until factorial, recursive function" > + > +# Finish out to main scope > +# > +gdb_test "finish" \ > + =A0 =A0" in main .*$srcfile:$bp_location1.*" \ > + =A0 =A0"finish to main" > + > +# Advance to a function called by main (marker2) > +# > +gdb_test "advance marker2" \ > + =A0 =A0"marker2 .a=3D43.*$srcfile1:$bp_location9.*" \ > + =A0 =A0"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" { > + =A0 =A0-re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > + =A0 =A0-re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" { > + =A0 =A0 =A0 pass "$test_msg" > + =A0 =A0} > +} > + > +### > +### > +### > + > +# 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" \ > + =A0 =A0"marker2 .a=3D43.*$srcfile1:$bp_location9.*" \ > + =A0 =A0"reverse-advance to marker2" > + > +# Finish out to main scope (backward) > + > +gdb_test "finish" \ > + =A0 =A0" in main .*$srcfile:$bp_location20.*" \ > + =A0 =A0"reverse-finish from marker2" > + > +# Advance backward to last line of factorial (outer invocation) > + > +gdb_test "advance $bp_location19" \ > + =A0 =A0"factorial .value=3D720.*${srcfile}:$bp_location19.*" \ > + =A0 =A0"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" \ > + =A0 =A0"factorial .value=3D6..*$srcfile:$bp_location7.*" \ > + =A0 =A0"reverse-until to entry of factorial" > + > + > Index: gdb.reverse/until-reverse1.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/until-reverse1.c > diff -N gdb.reverse/until-reverse1.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/until-reverse1.c =A0 =A0 =A0 =A024 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,52 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008 > + =A0 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > + > + =A0 Please email any bugs, comments, and/or additions to this file to: > + =A0 bug-gdb@prep.ai.mit.edu =A0*/ > + > +/* The code for this file was extracted from the gdb testsuite > + =A0 testcase "break.c". */ > + > +/* The following functions do nothing useful. =A0They are included > + =A0 simply as places to try setting breakpoints at. =A0They are > + =A0 explicitly "one-line functions" to verify that this case works > + =A0 (some versions of gcc have or have had problems with this). > + > + =A0 These functions are in a separate source file to prevent an > + =A0 optimizing compiler from inlining them and optimizing them away. */ > + > +#ifdef PROTOTYPES > +int marker1 (void) { return (0); } =A0 =A0 /* set breakpoint 15 here */ > +int marker2 (int a) { return (1); } =A0 =A0/* set breakpoint 8 here */ > +void marker3 (char *a, char *b) {} =A0 =A0 /* set breakpoint 17 here */ > +void marker4 (long d) {} =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* set breakpoint 1= 4 here */ > +#else > +int marker1 () { return (0); } =A0 =A0 =A0 =A0 /* set breakpoint 16 here= */ > +int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */ > +void marker3 (a, b) char *a, *b; {} =A0 =A0/* set breakpoint 18 here */ > +void marker4 (d) long d; {} =A0 =A0 =A0 =A0 =A0 =A0/* set breakpoint 13 = here */ > +#endif > + > +/* A structure we use for field name completion tests. =A0*/ > +struct some_struct > +{ > + =A0int a_field; > + =A0int b_field; > +}; > + > +struct some_struct values[50]; > Index: gdb.reverse/watch-reverse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/watch-reverse.c > diff -N gdb.reverse/watch-reverse.c > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/watch-reverse.c 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,222 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + =A0 Copyright 2008, 2009 > + =A0 Free Software Foundation, Inc. > + > + =A0 This program is free software; you can redistribute it and/or modify > + =A0 it under the terms of the GNU General Public License as published by > + =A0 the Free Software Foundation; either version 3 of the License, or > + =A0 (at your option) any later version. > + > + =A0 This program is distributed in the hope that it will be useful, > + =A0 but WITHOUT ANY WARRANTY; without even the implied warranty of > + =A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =A0See the > + =A0 GNU General Public License for more details. > + > + =A0 You should have received a copy of the GNU General Public License > + =A0 along with this program. =A0If not, see . > + > + =A0 Please email any bugs, comments, and/or additions to this file to: > + =A0 bug-gdb@prep.ai.mit.edu =A0*/ > + > +#include > +#include > +/* > + * =A0 =A0 Since using watchpoints can be very slow, we have to take som= e pains > to > + * =A0 =A0 ensure that we don't run too long with them enabled or we run= the > risk > + * =A0 =A0 of having the test timeout. =A0To help avoid this, we insert = some > marker > + * =A0 =A0 functions in the execution stream so we can set breakpoints a= t known > + * =A0 =A0 locations, without worrying about invalidating line numbers by > changing > + * =A0 =A0 this file. =A0We use null bodied functions are markers since = gdb does > + * =A0 =A0 not support breakpoints at labeled text points at this time. > + * > + * =A0 =A0 One place we need is a marker for when we start executing our= tests > + * =A0 =A0 instructions rather than any process startup code, so we inse= rt one > + * =A0 =A0 right after entering main(). =A0Another is right before we fi= nish, > before > + * =A0 =A0 we start executing any process termination code. > + * > + * =A0 =A0 Another problem we have to guard against, at least for the te= st > + * =A0 =A0 suite, is that we need to ensure that the line that causes the > + * =A0 =A0 watchpoint to be hit is still the current line when gdb notic= es > + * =A0 =A0 the hit. =A0Depending upon the specific code generated by the > compiler, > + * =A0 =A0 the instruction after the one that triggers the hit may be pa= rt of > + * =A0 =A0 the same line or part of the next line. =A0Thus we ensure tha= t there > + * =A0 =A0 are always some instructions to execute on the same line afte= r the > + * =A0 =A0 code that should trigger the hit. > + */ > + > +int count =3D -1; > +int ival1 =3D -1; > +int ival2 =3D -1; > +int ival3 =3D -1; > +int ival4 =3D -1; > +int ival5 =3D -1; > +char buf[10]; > +struct foo > +{ > + =A0int val; > +}; > +struct foo struct1, struct2, *ptr1, *ptr2; > + > +int doread =3D 0; > + > +char *global_ptr; > + > +void marker1 () > +{ > +} > + > +void marker2 () > +{ > +} > + > +void marker4 () > +{ > +} > + > +void marker5 () > +{ > +} > + > +void marker6 () > +{ > +} > + > +#ifdef PROTOTYPES > +void recurser (int =A0x) > +#else > +void recurser (x) int =A0x; > +#endif > +{ > + =A0int =A0local_x; > + > + =A0if (x > 0) > + =A0 =A0recurser (x-1); > + =A0local_x =3D x; > +} > + > +void > +func2 () > +{ > + =A0int =A0local_a; > + =A0static int =A0static_b; > + > + =A0ival5++; > + =A0local_a =3D ival5; > + =A0static_b =3D local_a; > +} > + > +void > +func3 () > +{ > + =A0int x; > + =A0int y; > + > + =A0x =3D 0; > + =A0x =3D 1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= /* second x assignment */ > + =A0y =3D 1; > + =A0y =3D 2; > +} > + > +int > +func1 () > +{ > + =A0/* The point of this is that we will set a breakpoint at this call. > + > + =A0 =A0 Then, if DECR_PC_AFTER_BREAK equals the size of a function call > + =A0 =A0 instruction (true on a sun3 if this is gcc-compiled--FIXME we > + =A0 =A0 should use asm() to make it work for any compiler, present or > + =A0 =A0 future), then we will end up branching to the location just aft= er > + =A0 =A0 the breakpoint. =A0And we better not confuse that with hitting = the > + =A0 =A0 breakpoint. =A0*/ > + =A0func2 (); > + =A0return 73; > +} > + > +void > +func4 () > +{ > + =A0buf[0] =3D 3; > + =A0global_ptr =3D buf; > + =A0buf[0] =3D 7; > +} > + > +int main () > +{ > +#ifdef usestubs > + =A0set_debug_traps(); > + =A0breakpoint(); > +#endif > + =A0struct1.val =3D 1; > + =A0struct2.val =3D 2; > + =A0ptr1 =3D &struct1; > + =A0ptr2 =3D &struct2; > + =A0marker1 (); > + =A0func1 (); > + =A0for (count =3D 0; count < 4; count++) { > + =A0 =A0ival1 =3D count; > + =A0 =A0ival3 =3D count; ival4 =3D count; > + =A0} > + =A0ival1 =3D count; /* Outside loop */ > + =A0ival2 =3D count; > + =A0ival3 =3D count; ival4 =3D count; > + =A0marker2 (); > + =A0if (doread) > + =A0 =A0{ > + =A0 =A0 =A0static char msg[] =3D "type stuff for buf now:"; > + =A0 =A0 =A0write (1, msg, sizeof (msg) - 1); > + =A0 =A0 =A0read (0, &buf[0], 5); > + =A0 =A0} > + =A0marker4 (); > + > + =A0/* We have a watchpoint on ptr1->val. =A0It should be triggered if > + =A0 =A0 ptr1's value changes. =A0*/ > + =A0ptr1 =3D ptr2; > + > + =A0/* This should not trigger the watchpoint. =A0If it does, then we > + =A0 =A0 used the wrong value chain to re-insert the watchpoints or we > + =A0 =A0 are not evaluating the watchpoint expression correctly. =A0*/ > + =A0struct1.val =3D 5; > + =A0marker5 (); > + > + =A0/* We have a watchpoint on ptr1->val. =A0It should be triggered if > + =A0 =A0 ptr1's value changes. =A0*/ > + =A0ptr1 =3D ptr2; > + > + =A0/* This should not trigger the watchpoint. =A0If it does, then we > + =A0 =A0 used the wrong value chain to re-insert the watchpoints or we > + =A0 =A0 are not evaluating the watchpoint expression correctly. =A0*/ > + =A0struct1.val =3D 5; > + =A0marker5 (); > + > + =A0/* We're going to watch locals of func2, to see that out-of-scope > + =A0 =A0 watchpoints are detected and properly deleted. > + =A0 =A0 */ > + =A0marker6 (); > + > + =A0/* This invocation is used for watches of a single > + =A0 =A0 local variable. */ > + =A0func2 (); > + > + =A0/* This invocation is used for watches of an expression > + =A0 =A0 involving a local variable. */ > + =A0func2 (); > + > + =A0/* This invocation is used for watches of a static > + =A0 =A0 (non-stack-based) local variable. */ > + =A0func2 (); > + > + =A0/* This invocation is used for watches of a local variable > + =A0 =A0 when recursion happens. > + =A0 =A0 */ > + =A0marker6 (); > + =A0recurser (2); > + > + =A0marker6 (); > + > + =A0func3 (); > + > + =A0func4 (); > + > + =A0return 0; > +} > Index: gdb.reverse/watch-reverse.exp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: gdb.reverse/watch-reverse.exp > diff -N gdb.reverse/watch-reverse.exp > --- /dev/null =A0 1 Jan 1970 00:00:00 -0000 > +++ gdb.reverse/watch-reverse.exp =A0 =A0 =A0 24 Jun 2009 20:38:54 -0000 > @@ -0,0 +1,131 @@ > +# 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. =A0See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. =A0If not, see . > + > +# Please email any bugs, comments, and/or additions to this file to: > +# bug-gdb@prep.ai.mit.edu > + > +# Based on a file written by Fred Fish. (fnf@cygnus.com) > + > +# > +# Test reverse debugging with watchpoints > +# > + > +if ![target_info exists gdb,can_reverse] { > + =A0 =A0return > +} > + > +set testfile "watch-reverse" > +set srcfile ${testfile}.c > +set binfile ${objdir}/${subdir}/${testfile} > + > +if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { > + =A0 =A0return -1 > +} > + > +runto main > + > +if [target_info exists gdb,use_precord] { > + =A0 =A0# Activate process record/replay > + =A0 =A0gdb_test "record" "" "Turn on process record" > + =A0 =A0# FIXME: command ought to acknowledge, so we can test if it succ= eeded. > +} > + > +# Only software watchpoints can be used in reverse > +gdb_test "set can-use-hw-watchpoints 0" "" "" > + > +gdb_test "break marker1" \ > + =A0 =A0"Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ > + =A0 =A0"set breakpoint at marker1" > + > +gdb_test "break marker2" \ > + =A0 =A0"Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ > + =A0 =A0"set breakpoint at marker2" > + > +gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*" > + > +gdb_test "watch ival3" \ > + =A0 =A0".*\[Ww\]atchpoint $decimal: ival3.*" \ > + =A0 =A0"set watchpoint on ival3" > + > +# Continue until first change, from -1 to 0 > + > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D -1.*New value =3D 0.*iv= al3 =3D > count; ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit, first time" > + > +# Continue until the next change, from 0 to 1. > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 0.*New value =3D 1.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit, second time" > + > +# Continue until the next change, from 1 to 2. > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 1.*New value =3D 2.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit, third time" > + > +# Continue until the next change, from 2 to 3. > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 2.*New value =3D 3.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit, fourth time" > + > +# Continue until the next change, from 3 to 4. > +# Note that this one is outside the loop. > + > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 3.*New value =3D 4.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"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" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 4.*New value =3D 3.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit in reverse, first time" > + > +# Reverse until the previous change, from 3 to 2. > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 3.*New value =3D 2.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit in reverse, second time" > + > +# Reverse until the previous change, from 2 to 1. > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 2.*New value =3D 1.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit in reverse, third time" > + > +# Reverse until the previous change, from 1 to 0. > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 1.*New value =3D 0.*iva= l3 =3D count; > ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit in reverse, fourth time" > + > +# Reverse until first change, from 0 to -1 > + > +gdb_test "continue" \ > + =A0 =A0".*\[Ww\]atchpoint.*ival3.*Old value =3D 0.*New value =3D -1.*iv= al3 =3D > count; ival4 =3D count;.*" \ > + =A0 =A0"watchpoint hit in reverse, fifth time" > + > + > +return 0 > >