Fix "maint print" error messages
[binutils-gdb.git] / gdb / testsuite / gdb.cp / exception.cc
blob6f0e090bb4f4f58ed79c3d2d40199472bd69c649
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 1997-2024 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 // Test file for exception handling support.
20 int foo (int i)
22 if (i < 32)
23 throw (int) 13;
24 else
25 return i * 2;
28 extern "C" int bar (int k, unsigned long eharg, int flag);
30 int bar (int k, unsigned long eharg, int flag)
32 return 1;
35 int catcher (int x)
37 return x;
40 int main()
42 int j;
44 try {
45 j = foo (20);
47 catch (int x) {
48 catcher (x);
51 try {
52 try {
53 j = foo (20);
55 catch (int x) {
56 catcher (x);
57 throw;
60 catch (int y) {
61 catcher (y);
64 // Not caught
65 foo (20);