xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp (revision 8e33eff89e26cf71871ead62f0d5063e1313c33a)
1# Copyright 2008-2023 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15
16# This file is part of the GDB testsuite.  It tests reverse stepping.
17#
18# reverse-next over a function call sets a step-resume breakpoint at
19# callee's entry point, runs to it, and then does an extra single-step
20# to get at the callee's caller.  Test that a user breakpoint set at
21# the same location as the step-resume breakpoint isn't ignored.
22#
23# The test sets a breakpoint with the command break *callee to set a
24# breakpoint on the first instruction of the function.  The issue is on
25# PowerPC it uses Global Entry Points (GEP) and Local Entry Points (LEP).
26# The GEP is the first instruction in the function.  It sets up register
27# r2 and then reaches the LEP.
28#
29#  <callee>:
30#   lis     r2,4098        <- GEP
31#   addi    r2,r2,32512
32#   mflr    r0             <- LEP
33#   std     r0,16(r1)
34
35#
36# The command break *callee sets the breakpoint on the GEP.  Calling
37# the function with callee() will enter the function via the LEP.  So,
38# this test needs to use a function pointer to call callee() so the
39# function will be entered via the GEP to work as designed on PowerPC in
40# addition to non-PowerPC systems.  On non-PowerPC systems, the GEP and LEP
41# are the same.
42
43if ![supports_reverse] {
44    return
45}
46
47standard_testfile
48
49if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
50    return -1
51}
52
53if {![runto_main]} {
54    return 0
55}
56
57if [supports_process_record] {
58    # Activate process record/replay
59    gdb_test_no_output "record" "turn on process record"
60}
61
62# Stop after the function pointer call to test the reverse-next command.
63set lineno [gdb_get_line_number "END OF MAIN"]
64gdb_test "advance $lineno" ".*END OF MAIN.*" \
65    "get past callee call"
66
67gdb_test "b \*callee" "" "set breakpoint at callee's entry"
68
69set bpnum [get_integer_valueof "\$bpnum" 0]
70gdb_test "reverse-next" \
71    "Breakpoint $bpnum, callee.*" \
72    "reverse-next over call trips user breakpoint at function entry"
73
74gdb_test "up" \
75    ".*FUNCTION PTR CALL TO CALLEE.*" \
76    "stopped at the right callee call"
77