]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/powerpc-trap.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / powerpc-trap.exp
1 # Copyright 2021-2024 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.
17
18 # Test if GDB stops at various trap instructions inserted into
19 # the code.
20
21 if { [istarget powerpc-*] } {
22 standard_testfile powerpc-trap.s
23 # Number of expected SIGTRAPs to get. This needs to be kept in sync
24 # with the source file powerpc-trap.s.
25 set expected_traps 3
26 } elseif {[istarget powerpc64*] } {
27 standard_testfile powerpc64-trap.s
28 # Number of expected SIGTRAPs to get. This needs to be kept in sync
29 # with the source file powerpc64-trap.s.
30 set expected_traps 5
31 } else {
32 unsupported "Skipping powerpc-specific tests"
33 return
34 }
35
36 if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
37 return -1
38 }
39
40 if {![runto_main]} {
41 untested "could not run to main"
42 return -1
43 }
44
45 set keep_going 1
46 set count 0
47
48 while {$keep_going} {
49 set keep_going 0
50
51 # Continue to next program breakpoint instruction.
52 gdb_test_multiple "continue" "trap instruction $count causes SIGTRAP" {
53 -re "Program received signal SIGTRAP, Trace/breakpoint trap.*$gdb_prompt $" {
54 pass $gdb_test_name
55
56 # Advance PC to next instruction
57 gdb_test "set \$pc = \$pc + 4" "" "advance past trap instruction $count"
58
59 incr count
60 if {$count < $expected_traps} {
61 set keep_going 1
62 }
63 }
64 }
65 }
66
67 # Verify we stopped at the expected number of SIGTRAP's.
68 gdb_assert {$count == $expected_traps} "all trap instructions triggered"
69
70 # One last continue to reach the end of the test, to make sure we don't get
71 # another SIGTRAP.
72 gdb_test "continue" "exited normally.*" "continue to end"