1 /* Longjump free calls to gdb internal routines.
2 Copyright 1999, 2000 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
23 /* Use this struct to pass arguments to wrapper routines. We assume
24 (arbitrarily) that no gdb function takes more than ten arguments. */
25 struct gdb_wrapper_arguments
28 /* Pointer to some result from the gdb function call, if any */
36 /* The list of arguments. */
44 struct captured_value_struct_elt_args
51 struct value **result_ptr;
54 static int wrap_parse_exp_1 (char *);
56 static int wrap_evaluate_expression (char *);
58 static int wrap_value_fetch_lazy (char *);
60 static int wrap_value_equal (char *);
62 static int wrap_value_assign (char *);
64 static int wrap_value_subscript (char *);
66 static int wrap_value_ind (char *opaque_arg);
68 static int do_captured_value_struct_elt (struct ui_out *uiout, void *data);
70 static int wrap_parse_and_eval_type (char *);
73 gdb_parse_exp_1 (char **stringptr, struct block *block, int comma,
74 struct expression **expression)
76 struct gdb_wrapper_arguments args;
77 args.args[0].pointer = stringptr;
78 args.args[1].pointer = block;
79 args.args[2].integer = comma;
81 if (!catch_errors ((catch_errors_ftype *) wrap_parse_exp_1, &args,
82 "", RETURN_MASK_ERROR))
84 /* An error occurred */
88 *expression = (struct expression *) args.result.pointer;
94 wrap_parse_exp_1 (char *argptr)
96 struct gdb_wrapper_arguments *args
97 = (struct gdb_wrapper_arguments *) argptr;
98 args->result.pointer = parse_exp_1((char **) args->args[0].pointer,
99 (struct block *) args->args[1].pointer,
100 args->args[2].integer);
105 gdb_evaluate_expression (struct expression *exp, struct value **value)
107 struct gdb_wrapper_arguments args;
108 args.args[0].pointer = exp;
110 if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args,
111 "", RETURN_MASK_ERROR))
113 /* An error occurred */
117 *value = (struct value *) args.result.pointer;
122 wrap_evaluate_expression (char *a)
124 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
126 (args)->result.pointer =
127 (char *) evaluate_expression ((struct expression *) args->args[0].pointer);
132 gdb_value_fetch_lazy (struct value *value)
134 struct gdb_wrapper_arguments args;
136 args.args[0].pointer = value;
137 return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args,
138 "", RETURN_MASK_ERROR);
142 wrap_value_fetch_lazy (char *a)
144 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
146 value_fetch_lazy ((struct value *) (args)->args[0].pointer);
151 gdb_value_equal (struct value *val1, struct value *val2, int *result)
153 struct gdb_wrapper_arguments args;
155 args.args[0].pointer = val1;
156 args.args[1].pointer = val2;
158 if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args,
159 "", RETURN_MASK_ERROR))
161 /* An error occurred */
165 *result = args.result.integer;
170 wrap_value_equal (char *a)
172 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
176 val1 = (struct value *) (args)->args[0].pointer;
177 val2 = (struct value *) (args)->args[1].pointer;
179 (args)->result.integer = value_equal (val1, val2);
184 gdb_value_assign (struct value *val1, struct value *val2, struct value **result)
186 struct gdb_wrapper_arguments args;
188 args.args[0].pointer = val1;
189 args.args[1].pointer = val2;
191 if (!catch_errors ((catch_errors_ftype *) wrap_value_assign, &args,
192 "", RETURN_MASK_ERROR))
194 /* An error occurred */
198 *result = (struct value *) args.result.pointer;
203 wrap_value_assign (char *a)
205 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
209 val1 = (struct value *) (args)->args[0].pointer;
210 val2 = (struct value *) (args)->args[1].pointer;
212 (args)->result.pointer = value_assign (val1, val2);
217 gdb_value_subscript (struct value *val1, struct value *val2, struct value **rval)
219 struct gdb_wrapper_arguments args;
221 args.args[0].pointer = val1;
222 args.args[1].pointer = val2;
224 if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
225 "", RETURN_MASK_ERROR))
227 /* An error occurred */
231 *rval = (struct value *) args.result.pointer;
236 wrap_value_subscript (char *a)
238 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
242 val1 = (struct value *) (args)->args[0].pointer;
243 val2 = (struct value *) (args)->args[1].pointer;
245 (args)->result.pointer = value_subscript (val1, val2);
250 gdb_value_ind (struct value *val, struct value **rval)
252 struct gdb_wrapper_arguments args;
254 args.args[0].pointer = val;
256 if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args,
257 "", RETURN_MASK_ERROR))
259 /* An error occurred */
263 *rval = (struct value *) args.result.pointer;
268 wrap_value_ind (char *opaque_arg)
270 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg;
273 val = (struct value *) (args)->args[0].pointer;
274 (args)->result.pointer = value_ind (val);
279 gdb_parse_and_eval_type (char *p, int length, struct type **type)
281 struct gdb_wrapper_arguments args;
282 args.args[0].pointer = p;
283 args.args[1].integer = length;
285 if (!catch_errors ((catch_errors_ftype *) wrap_parse_and_eval_type, &args,
286 "", RETURN_MASK_ALL))
288 /* An error occurred */
292 *type = (struct type *) args.result.pointer;
297 wrap_parse_and_eval_type (char *a)
299 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
301 char *p = (char *) args->args[0].pointer;
302 int length = args->args[1].integer;
304 args->result.pointer = (char *) parse_and_eval_type (p, length);
310 gdb_value_struct_elt (struct ui_out *uiout, struct value **result, struct value **argp,
311 struct value **args, char *name, int *static_memfuncp,
314 struct captured_value_struct_elt_args cargs;
318 cargs.static_memfuncp = static_memfuncp;
320 cargs.result_ptr = result;
321 return catch_exceptions (uiout, do_captured_value_struct_elt, &cargs,
322 NULL, RETURN_MASK_ALL);
326 do_captured_value_struct_elt (struct ui_out *uiout, void *data)
328 struct captured_value_struct_elt_args *cargs = data;
329 *cargs->result_ptr = value_struct_elt (cargs->argp, cargs->args, cargs->name,
330 cargs->static_memfuncp, cargs->err);