diff options
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/eh_return.c | 98 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/eh_return.exp | 47 |
3 files changed, 151 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d855615..f0b7949 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-08-16 Tom de Vries <tdevries@suse.de> + + PR gdb/25350 + * gdb.base/eh_return.c: New test. + * gdb.base/eh_return.exp: New file. + 2020-08-15 Tom de Vries <tdevries@suse.de> * gdb.fortran/mixed-lang-stack.c (fortran_charlen_t): New type. diff --git a/gdb/testsuite/gdb.base/eh_return.c b/gdb/testsuite/gdb.base/eh_return.c new file mode 100644 index 0000000..80eea9c --- /dev/null +++ b/gdb/testsuite/gdb.base/eh_return.c @@ -0,0 +1,98 @@ +/* This testcase is part of GDB, the GNU debugger. + + It was copied from gcc repo, gcc/testsuite/gcc.target/aarch64/eh_return.c. + + Copyright 2020 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 <stdio.h> + +int val, test, failed; + +int main (void); + +void +eh0 (void *p) +{ + val = (int)(long)p & 7; + if (val) + abort (); +} + +void +eh1 (void *p, int x) +{ + void *q = __builtin_alloca (x); + eh0 (q); + __builtin_eh_return (0, p); +} + +void +eh2a (int a,int b,int c,int d,int e,int f,int g,int h, void *p) +{ + val = a + b + c + d + e + f + g + h + (int)(long)p & 7; +} + +void +eh2 (void *p) +{ + eh2a (val, val, val, val, val, val, val, val, p); + __builtin_eh_return (0, p); +} + + +void +continuation (void) +{ + test++; + main (); +} + +void +fail (void) +{ + failed = 1; + printf ("failed\n"); + continuation (); +} + +void +do_test1 (void) +{ + if (!val) + eh1 (continuation, 100); + fail (); +} + +void +do_test2 (void) +{ + if (!val) + eh2 (continuation); + fail (); +} + +int +main (void) +{ + if (test == 0) + do_test1 (); + if (test == 1) + do_test2 (); + if (failed || test != 2) + exit (1); + exit (0); +} diff --git a/gdb/testsuite/gdb.base/eh_return.exp b/gdb/testsuite/gdb.base/eh_return.exp new file mode 100644 index 0000000..e38398e --- /dev/null +++ b/gdb/testsuite/gdb.base/eh_return.exp @@ -0,0 +1,47 @@ +# Copyright 2020 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/>. */ + +# Check if executable generated from eh_return.c assert when setting a +# breakpoint at the last insn of eh, and running to it. + +standard_testfile + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { + return -1 +} + +set address -1 + +# Get the address of the last insn in function eh2. +gdb_test_multiple "disassemble eh2" "" { + -re -wrap "($hex)\[^\r\n\]*\r\nEnd of assembler dump." { + set address $expect_out(1,string) + pass $gdb_test_name + } +} + +if { $address == -1 } { + return 0 +} + +clean_restart ${binfile} + +gdb_breakpoint "*$address" message + +# The assert did not reproduce when running to main, and continuing to the +# breakpoint, so instead, run to the breakpoint. +gdb_run_cmd + +gdb_test "" "Breakpoint .*" "hit breakpoint" |