Eliminate catch_errors
[deliverable/binutils-gdb.git] / gdb / exceptions.h
1 /* Exception (throw catch) mechanism, for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2017 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef EXCEPTIONS_H
21 #define EXCEPTIONS_H
22
23 #include "ui-out.h"
24
25 /* If E is an exception, print it's error message on the specified
26 stream. For _fprintf, prefix the message with PREFIX... */
27 extern void exception_print (struct ui_file *file, struct gdb_exception e);
28 extern void exception_fprintf (struct ui_file *file, struct gdb_exception e,
29 const char *prefix,
30 ...) ATTRIBUTE_PRINTF (3, 4);
31
32 /* Call FUNC(UIOUT, FUNC_ARGS) but wrapped within an exception
33 handler. If an exception (enum return_reason) is thrown using
34 throw_exception() than all cleanups installed since
35 catch_exceptions() was entered are invoked, the (-ve) exception
36 value is then returned by catch_exceptions. If FUNC() returns
37 normally (with a positive or zero return value) then that value is
38 returned by catch_exceptions(). It is an internal_error() for
39 FUNC() to return a negative value.
40
41 For the period of the FUNC() call: UIOUT is installed as the output
42 builder; ERRSTRING is installed as the error/quit message; and a
43 new cleanup_chain is established. The old values are restored
44 before catch_exceptions() returns.
45
46 The variant catch_exceptions_with_msg() is the same as
47 catch_exceptions() but adds the ability to return an allocated
48 copy of the gdb error message. This is used when a silent error is
49 issued and the caller wants to manually issue the error message.
50
51 MASK specifies what to catch; it is normally set to RETURN_MASK_ALL
52 if the code which calls catch_exceptions is not set up to deal with
53 a quit which isn't caught. But if the code can deal with it, it
54 generally should be RETURN_MASK_ERROR, unless for some reason it is
55 more useful to abort only the portion of the operation inside the
56 catch_exceptions. Note that quit should return to the command line
57 fairly quickly, even if some further processing is being done.
58
59 FIXME; cagney/2001-08-13: The need to override the global UIOUT
60 builder variable should just go away. */
61
62 struct ui_out;
63 typedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args);
64 extern int catch_exceptions (struct ui_out *uiout,
65 catch_exceptions_ftype *func, void *func_args,
66 return_mask mask);
67 typedef void (catch_exception_ftype) (struct ui_out *ui_out, void *args);
68 extern int catch_exceptions_with_msg (struct ui_out *uiout,
69 catch_exceptions_ftype *func,
70 void *func_args,
71 char **gdberrmsg,
72 return_mask mask);
73
74 /* Compare two exception objects for print equality. */
75 extern int exception_print_same (struct gdb_exception e1,
76 struct gdb_exception e2);
77 #endif
This page took 0.033374 seconds and 5 git commands to generate.