aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Love <cel@us.ibm.com>2022-12-01 14:39:45 -0500
committerCarl Love <cel@us.ibm.com>2022-12-01 14:39:45 -0500
commitc367d9e0cbfda0e32b7074c2719dfaee42c4cfb6 (patch)
tree0a9961fcf1385a2e76ecbd901fba519e89cef254
parent4cb80f0e5bddc29cf50b08f0a4d2cca8ea330a23 (diff)
downloadgdb-c367d9e0cbfda0e32b7074c2719dfaee42c4cfb6.zip
gdb-c367d9e0cbfda0e32b7074c2719dfaee42c4cfb6.tar.gz
gdb-c367d9e0cbfda0e32b7074c2719dfaee42c4cfb6.tar.bz2
PowerPC, fix gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp
The tests set a break point with the command break *func. This sets a breakpoint on the first instruction of the function. PowerPC uses Global Entry Points (GEP) and Local Entry Points (LEP). The first instruction in the function is the GEP. The GEP sets up register r2 before reaching the LEP. When the function is called with func() the function is entered via the LEP and the test fails because GDB does not see the breakpoint on the GEP. However, if the function is called via a function pointer, execution begins at the GEP as the test expects. Currently finish-reverse-bkpt.exp uses source file finish-reverse.c and next-reverse-bpkt-over-sr.exp uses source file step-reverse.c A new source file was created for tests finish-reverse-bkpt.exp and next-reverse-bkpt-over-sr.exp. The new files use the new function pointer method to call the functions so the tests will work correctly on both PowerPC with a GEP and LEP as well as on other systems. The GEP is the same as the LEP on non PowerPC systems. The expect files were changed to use the new source files and to set the initial break point for the rest of the test on the function pointer call for the function. This patch fixes two PowerPC test failures in each of the tests gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp. Patch tested on PowerPC and Intel X86-64 with no regressions. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
-rw-r--r--gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c39
-rw-r--r--gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp24
-rw-r--r--gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c43
-rw-r--r--gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp31
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"