]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/eh_return.exp
gdb/testsuite: remove use of then keyword from gdb.base/*.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / eh_return.exp
CommitLineData
4a94e368 1# Copyright 2020-2022 Free Software Foundation, Inc.
f569c1c5
TV
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# Check if executable generated from eh_return.c assert when setting a
17# breakpoint at the last insn of eh, and running to it.
18
19standard_testfile
20
aa63b0a7 21# Set compiler flags.
65a33d75 22if {[istarget "powerpc*"]} {
aa63b0a7
CL
23 # PowerPC generates a Traceback Table, as defined in the PPC64 ABI,
24 # following each function by default. The Traceback Table information is
25 # typically interpreted by the disassembler as data represented with
26 # .long xxxx following the last instruction in the function. For example:
27 #
28 # Dump of assembler code for function eh2:
29 # 0x00000000100009e0 <+0>: lis r2,4098
30 # ...
31 # 0x0000000010000b04 <+292>: add r1,r1,r10
32 # 0x0000000010000b08 <+296>: blr
33 # 0x0000000010000b0c <+300>: .long 0x0
34 # 0x0000000010000b10 <+304>: .long 0x1000000
35 # 0x0000000010000b14 <+308>: .long 0x1000180
36 # End of assembler dump.
37 #
38 # Disable the Traceback Table generation, using the PowerPC specific
39 # compiler option, so the test gdb_test_multiple "disassemble eh2" will
40 # locate the address of the blr instruction not the last .long statement.
41 if { [test_compiler_info "gcc-*"] } {
42 set compile_flags {debug nopie additional_flags=-mtraceback=no}
43 } elseif { [test_compiler_info "xlc-*"] } {
44 set compile_flags {debug nopie additional_flags=-qtbtable=none}
45 } elseif { [test_compiler_info "clang-*"] } {
46 set compile_flags [list debug nopie additional_flags=-mllvm \
47 additional_flags=-xcoff-traceback-table=false]
48 } else {
49 set compile_flags {debug nopie }
50 }
51} else {
52 set compile_flags {debug nopie}
53}
54
e840f2e3 55if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
aa63b0a7 56 $compile_flags]} {
f569c1c5
TV
57 return -1
58}
59
60set address -1
61
62# Get the address of the last insn in function eh2.
63gdb_test_multiple "disassemble eh2" "" {
64 -re -wrap "($hex)\[^\r\n\]*\r\nEnd of assembler dump." {
65 set address $expect_out(1,string)
66 pass $gdb_test_name
67 }
68}
69
70if { $address == -1 } {
71 return 0
72}
73
74clean_restart ${binfile}
75
48ca5676 76gdb_assert [gdb_breakpoint "*$address" no-message] "set breakpoint on address"
f569c1c5
TV
77
78# The assert did not reproduce when running to main, and continuing to the
79# breakpoint, so instead, run to the breakpoint.
80gdb_run_cmd
81
82gdb_test "" "Breakpoint .*" "hit breakpoint"