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. */
21 #include "exceptions.h"
24 /* Use this struct to pass arguments to wrapper routines. We assume
25 (arbitrarily) that no gdb function takes more than ten arguments. */
26 struct gdb_wrapper_arguments
29 /* Pointer to some result from the gdb function call, if any */
37 /* The list of arguments. */
45 struct captured_value_struct_elt_args
52 struct value **result_ptr;
55 static int wrap_parse_exp_1 (char *);
57 static int wrap_evaluate_expression (char *);
59 static int wrap_value_fetch_lazy (char *);
61 static int wrap_value_equal (char *);
63 static int wrap_value_assign (char *);
65 static int wrap_value_subscript (char *);
67 static int wrap_value_ind (char *opaque_arg);
69 static int do_captured_value_struct_elt (struct ui_out *uiout, void *data);
71 static int wrap_parse_and_eval_type (char *);
74 gdb_parse_exp_1 (char **stringptr, struct block *block, int comma,
75 struct expression **expression)
77 struct gdb_wrapper_arguments args;
78 args.args[0].pointer = stringptr;
79 args.args[1].pointer = block;
80 args.args[2].integer = comma;
82 if (!catch_errors ((catch_errors_ftype *) wrap_parse_exp_1, &args,
83 "", RETURN_MASK_ERROR))
85 /* An error occurred */
89 *expression = (struct expression *) args.result.pointer;
95 wrap_parse_exp_1 (char *argptr)
97 struct gdb_wrapper_arguments *args
98 = (struct gdb_wrapper_arguments *) argptr;
99 args->result.pointer = parse_exp_1((char **) args->args[0].pointer,
100 (struct block *) args->args[1].pointer,
101 args->args[2].integer);
106 gdb_evaluate_expression (struct expression *exp, struct value **value)
108 struct gdb_wrapper_arguments args;
109 args.args[0].pointer = exp;
111 if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args,
112 "", RETURN_MASK_ERROR))
114 /* An error occurred */
118 *value = (struct value *) args.result.pointer;
123 wrap_evaluate_expression (char *a)
125 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
127 (args)->result.pointer =
128 (char *) evaluate_expression ((struct expression *) args->args[0].pointer);
133 gdb_value_fetch_lazy (struct value *value)
135 struct gdb_wrapper_arguments args;
137 args.args[0].pointer = value;
138 return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args,
139 "", RETURN_MASK_ERROR);
143 wrap_value_fetch_lazy (char *a)
145 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
147 value_fetch_lazy ((struct value *) (args)->args[0].pointer);
152 gdb_value_equal (struct value *val1, struct value *val2, int *result)
154 struct gdb_wrapper_arguments args;
156 args.args[0].pointer = val1;
157 args.args[1].pointer = val2;
159 if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args,
160 "", RETURN_MASK_ERROR))
162 /* An error occurred */
166 *result = args.result.integer;
171 wrap_value_equal (char *a)
173 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
177 val1 = (struct value *) (args)->args[0].pointer;
178 val2 = (struct value *) (args)->args[1].pointer;
180 (args)->result.integer = value_equal (val1, val2);
185 gdb_value_assign (struct value *val1, struct value *val2, struct value **result)
187 struct gdb_wrapper_arguments args;
189 args.args[0].pointer = val1;
190 args.args[1].pointer = val2;
192 if (!catch_errors ((catch_errors_ftype *) wrap_value_assign, &args,
193 "", RETURN_MASK_ERROR))
195 /* An error occurred */
199 *result = (struct value *) args.result.pointer;
204 wrap_value_assign (char *a)
206 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
210 val1 = (struct value *) (args)->args[0].pointer;
211 val2 = (struct value *) (args)->args[1].pointer;
213 (args)->result.pointer = value_assign (val1, val2);
218 gdb_value_subscript (struct value *val1, struct value *val2, struct value **rval)
220 struct gdb_wrapper_arguments args;
222 args.args[0].pointer = val1;
223 args.args[1].pointer = val2;
225 if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
226 "", RETURN_MASK_ERROR))
228 /* An error occurred */
232 *rval = (struct value *) args.result.pointer;
237 wrap_value_subscript (char *a)
239 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
243 val1 = (struct value *) (args)->args[0].pointer;
244 val2 = (struct value *) (args)->args[1].pointer;
246 (args)->result.pointer = value_subscript (val1, val2);
251 gdb_value_ind (struct value *val, struct value **rval)
253 struct gdb_wrapper_arguments args;
255 args.args[0].pointer = val;
257 if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args,
258 "", RETURN_MASK_ERROR))
260 /* An error occurred */
264 *rval = (struct value *) args.result.pointer;
269 wrap_value_ind (char *opaque_arg)
271 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg;
274 val = (struct value *) (args)->args[0].pointer;
275 (args)->result.pointer = value_ind (val);
280 gdb_parse_and_eval_type (char *p, int length, struct type **type)
282 struct gdb_wrapper_arguments args;
283 args.args[0].pointer = p;
284 args.args[1].integer = length;
286 if (!catch_errors ((catch_errors_ftype *) wrap_parse_and_eval_type, &args,
287 "", RETURN_MASK_ALL))
289 /* An error occurred */
293 *type = (struct type *) args.result.pointer;
298 wrap_parse_and_eval_type (char *a)
300 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
302 char *p = (char *) args->args[0].pointer;
303 int length = args->args[1].integer;
305 args->result.pointer = (char *) parse_and_eval_type (p, length);
311 gdb_value_struct_elt (struct ui_out *uiout, struct value **result, struct value **argp,
312 struct value **args, char *name, int *static_memfuncp,
315 struct captured_value_struct_elt_args cargs;
319 cargs.static_memfuncp = static_memfuncp;
321 cargs.result_ptr = result;
322 return catch_exceptions (uiout, do_captured_value_struct_elt, &cargs,
323 NULL, RETURN_MASK_ALL);
327 do_captured_value_struct_elt (struct ui_out *uiout, void *data)
329 struct captured_value_struct_elt_args *cargs = data;
330 *cargs->result_ptr = value_struct_elt (cargs->argp, cargs->args, cargs->name,
331 cargs->static_memfuncp, cargs->err);