Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.base / eh_return.exp
blobbced409547b8bcae703d8b1b54fc01e1482fcf64
1 # Copyright 2020-2023 Free Software Foundation, Inc.
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.
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.
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/>.  */
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.
19 standard_testfile
21 # Set compiler flags.
22 if {[istarget "powerpc*"]} {
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}
55 if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
56          $compile_flags]} {
57     return -1
60 set address -1
62 # Get the address of the last insn in function eh2.
63 gdb_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     }
70 if { $address == -1 } {
71     return 0
74 clean_restart ${binfile}
76 gdb_assert [gdb_breakpoint "*$address" no-message] "set breakpoint on address"
78 # The assert did not reproduce when running to main, and continuing to the
79 # breakpoint, so instead, run to the breakpoint.
80 gdb_run_cmd
82 gdb_test "" "Breakpoint .*" "hit breakpoint"