Update
[gdb.git] / gdb / wrapper.c
blob7d8d6b353860c69ec74686b17e058c4ed131a509
1 /* Longjump free calls to GDB internal routines.
3 Copyright (C) 1999, 2000, 2005, 2007, 2008 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 #include "defs.h"
19 #include "value.h"
20 #include "exceptions.h"
21 #include "wrapper.h"
22 #include "ui-out.h"
24 int
25 gdb_parse_exp_1 (char **stringptr, struct block *block, int comma,
26 struct expression **expression)
28 volatile struct gdb_exception except;
30 TRY_CATCH (except, RETURN_MASK_ERROR)
32 *expression = parse_exp_1 (stringptr, block, comma);
35 if (except.reason < 0)
36 return 0;
37 return 1;
40 int
41 gdb_evaluate_expression (struct expression *exp, struct value **value)
43 volatile struct gdb_exception except;
45 TRY_CATCH (except, RETURN_MASK_ERROR)
47 *value = evaluate_expression(exp);
50 if (except.reason < 0)
51 return 0;
52 return 1;
55 int
56 gdb_value_fetch_lazy (struct value *val)
58 volatile struct gdb_exception except;
60 TRY_CATCH (except, RETURN_MASK_ERROR)
62 value_fetch_lazy (val);
65 if (except.reason < 0)
66 return 0;
67 return 1;
70 int
71 gdb_value_equal (struct value *val1, struct value *val2, int *result)
73 volatile struct gdb_exception except;
75 TRY_CATCH (except, RETURN_MASK_ERROR)
77 *result = value_equal (val1, val2);
80 if (except.reason < 0)
81 return 0;
82 return 1;
85 int
86 gdb_value_assign (struct value *val1, struct value *val2,
87 struct value **result)
89 volatile struct gdb_exception except;
91 TRY_CATCH (except, RETURN_MASK_ERROR)
93 *result = value_assign (val1, val2);
96 if (except.reason < 0)
97 return 0;
98 return 1;
102 gdb_value_subscript (struct value *val1, struct value *val2,
103 struct value **result)
105 volatile struct gdb_exception except;
107 TRY_CATCH (except, RETURN_MASK_ERROR)
109 *result = value_subscript (val1, val2);
112 if (except.reason < 0)
113 return 0;
114 return 1;
118 gdb_value_ind (struct value *val, struct value **result)
120 volatile struct gdb_exception except;
122 TRY_CATCH (except, RETURN_MASK_ERROR)
124 *result = value_ind (val);
127 if (except.reason < 0)
128 return 0;
129 return 1;
133 gdb_parse_and_eval_type (char *p, int length, struct type **type)
135 volatile struct gdb_exception except;
137 TRY_CATCH (except, RETURN_MASK_ERROR)
139 *type = parse_and_eval_type (p, length);
142 if (except.reason < 0)
143 return 0;
144 return 1;
147 enum gdb_rc
148 gdb_value_struct_elt (struct ui_out *uiout, struct value **result,
149 struct value **argp, struct value **args, char *name,
150 int *static_memfuncp, char *err)
152 volatile struct gdb_exception except;
154 TRY_CATCH (except, RETURN_MASK_ALL)
156 *result = value_struct_elt (argp, args, name, static_memfuncp, err);
159 if (except.reason < 0)
160 return GDB_RC_FAIL;
161 return GDB_RC_OK;