diff options
-rw-r--r-- | gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c | 39 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c | 43 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp | 31 |
4 files changed, 130 insertions, 7 deletions
diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c new file mode 100644 index 0000000..7a95417 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008-2022 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Test gdb's "return" command in reverse. The code for this test is based + on the code in test finish-reverse.c. The code was modified to call the + function via a function pointer so the test will behave the same on all + platforms. See comments in finish-reverse-bkpt.exp. */ + +int void_test = 0; + +void +void_func () +{ + void_test = 1; /* VOID FUNC */ +} + +int +main (int argc, char **argv) +{ + int i; + void (*funp) (void) = void_func; + + funp (); + return 0; +} diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp index 5bfe147..3d98178 100644 --- a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp +++ b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp @@ -19,11 +19,32 @@ # the functions entry would be ignored. Make sure the bug doesn't # reappear. +# The test sets a breakpoint with the command break *void_func to set a +# breakpoint on the first instruction of the function. The issue is on +# PowerPC it uses Global Entry Points (GEP) and Local Entry Points (LEP). +# The GEP is the first instruction in the function. It sets up register +# r2 and then reaches the LEP. +# +# <void_func>: +# lis r2,4098 <- GEP +# addi r2,r2,32512 +# mflr r0 <- LEP +# std r0,16(r1) +# .... + +# +# The command break *void_func sets the breakpoint on the GEP. Calling +# the function with void_func() will enter the function via the LEP. So, +# this test needs to use a function pointer to call void_func() so the +# function will be entered via the GEP to work as designed on PowerPC in +# addition to non-PowerPC systems. On non-PowerPC systems, the GEP and LEP +# are the same. + if ![supports_reverse] { return } -standard_testfile finish-reverse.c +standard_testfile if { [prepare_for_testing "failed to prepare" "$testfile" $srcfile] } { return -1 @@ -38,6 +59,7 @@ if [supports_process_record] { gdb_test_no_output "record" "turn on process record" } +# Start the test. set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"] gdb_test "tbreak void_func" \ "Temporary breakpoint $decimal at .*$srcfile, line $breakloc\." \ diff --git a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c new file mode 100644 index 0000000..6d0ed52 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c @@ -0,0 +1,43 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008-2022 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <stdlib.h> +#include <string.h> + +/* Test reverse finish command. The code for this test is based on the code + in test step-reverse.c. The code was modified to call the function via + a function pointer so the test will behave the same on all platforms. + See comments in next-reverse-bkpt-over-sr.exp. */ + +int myglob = 0; + +int +callee() { + return myglob++; +} + +int +main () { + int (*funp) (void) = callee; + + /* Test next-reverse-bkpt-over-sr.exp needs to call function callee using + a function pointer to work correctly on PowerPC. See comments in + next-reverse-bkpt-over-sr.exp. */ + funp (); /* FUNCTION PTR CALL TO CALLEE */ + + exit (0); /* END OF MAIN */ +} diff --git a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp index 71d915d..b8364e2 100644 --- a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp +++ b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp @@ -14,20 +14,37 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ # This file is part of the GDB testsuite. It tests reverse stepping. -# Lots of code borrowed from "step-test.exp". - # # reverse-next over a function call sets a step-resume breakpoint at # callee's entry point, runs to it, and then does an extra single-step # to get at the callee's caller. Test that a user breakpoint set at # the same location as the step-resume breakpoint isn't ignored. # +# The test sets a breakpoint with the command break *callee to set a +# breakpoint on the first instruction of the function. The issue is on +# PowerPC it uses Global Entry Points (GEP) and Local Entry Points (LEP). +# The GEP is the first instruction in the function. It sets up register +# r2 and then reaches the LEP. +# +# <callee>: +# lis r2,4098 <- GEP +# addi r2,r2,32512 +# mflr r0 <- LEP +# std r0,16(r1) + +# +# The command break *callee sets the breakpoint on the GEP. Calling +# the function with callee() will enter the function via the LEP. So, +# this test needs to use a function pointer to call callee() so the +# function will be entered via the GEP to work as designed on PowerPC in +# addition to non-PowerPC systems. On non-PowerPC systems, the GEP and LEP +# are the same. if ![supports_reverse] { return } -standard_testfile step-reverse.c +standard_testfile if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 @@ -42,8 +59,10 @@ if [supports_process_record] { gdb_test_no_output "record" "turn on process record" } -set lineno [gdb_get_line_number "STEP INTO THIS CALL"] -gdb_test "advance $lineno" ".*STEP INTO THIS CALL.*" "get past callee call" +# Stop after the function pointer call to test the reverse-next command. +set lineno [gdb_get_line_number "END OF MAIN"] +gdb_test "advance $lineno" ".*END OF MAIN.*" \ + "get past callee call" gdb_test "b \*callee" "" "set breakpoint at callee's entry" @@ -53,5 +72,5 @@ gdb_test "reverse-next" \ "reverse-next over call trips user breakpoint at function entry" gdb_test "up" \ - ".*NEXT OVER THIS CALL.*" \ + ".*FUNCTION PTR CALL TO CALLEE.*" \ "stopped at the right callee call" |