1 /* Longjump free calls to gdb internal routines.
2 Copyright 1999 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. */
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 static int wrap_parse_exp_1 (char *);
47 static int wrap_evaluate_expression (char *);
49 static int wrap_value_fetch_lazy (char *);
51 static int wrap_value_equal (char *);
53 static int wrap_value_subscript (char *);
55 static int wrap_value_ind (char *opaque_arg);
57 static int wrap_parse_and_eval_type (char *);
60 gdb_parse_exp_1 (stringptr, block, comma, expression)
64 struct expression **expression;
66 struct gdb_wrapper_arguments args;
67 args.args[0].pointer = stringptr;
68 args.args[1].pointer = block;
69 args.args[2].integer = comma;
71 if (!catch_errors ((catch_errors_ftype *) wrap_parse_exp_1, &args,
72 "", RETURN_MASK_ERROR))
74 /* An error occurred */
78 *expression = (struct expression *) args.result.pointer;
84 wrap_parse_exp_1 (argptr)
87 struct gdb_wrapper_arguments *args
88 = (struct gdb_wrapper_arguments *) argptr;
89 args->result.pointer = parse_exp_1((char **) args->args[0].pointer,
90 (struct block *) args->args[1].pointer,
91 args->args[2].integer);
96 gdb_evaluate_expression (exp, value)
97 struct expression *exp;
100 struct gdb_wrapper_arguments args;
101 args.args[0].pointer = exp;
103 if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args,
104 "", RETURN_MASK_ERROR))
106 /* An error occurred */
110 *value = (value_ptr) args.result.pointer;
115 wrap_evaluate_expression (a)
118 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
120 (args)->result.pointer =
121 (char *) evaluate_expression ((struct expression *) args->args[0].pointer);
126 gdb_value_fetch_lazy (value)
129 struct gdb_wrapper_arguments args;
131 args.args[0].pointer = value;
132 return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args,
133 "", RETURN_MASK_ERROR);
137 wrap_value_fetch_lazy (a)
140 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
142 value_fetch_lazy ((value_ptr) (args)->args[0].pointer);
147 gdb_value_equal (val1, val2, result)
152 struct gdb_wrapper_arguments args;
154 args.args[0].pointer = val1;
155 args.args[1].pointer = val2;
157 if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args,
158 "", RETURN_MASK_ERROR))
160 /* An error occurred */
164 *result = args.result.integer;
172 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
173 value_ptr val1, val2;
175 val1 = (value_ptr) (args)->args[0].pointer;
176 val2 = (value_ptr) (args)->args[1].pointer;
178 (args)->result.integer = value_equal (val1, val2);
183 gdb_value_subscript (val1, val2, rval)
188 struct gdb_wrapper_arguments args;
190 args.args[0].pointer = val1;
191 args.args[1].pointer = val2;
193 if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
194 "", RETURN_MASK_ERROR))
196 /* An error occurred */
200 *rval = (value_ptr) args.result.pointer;
205 wrap_value_subscript (a)
208 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
209 value_ptr val1, val2;
211 val1 = (value_ptr) (args)->args[0].pointer;
212 val2 = (value_ptr) (args)->args[1].pointer;
214 (args)->result.pointer = value_subscript (val1, val2);
219 gdb_value_ind (val, rval)
223 struct gdb_wrapper_arguments args;
225 args.args[0].pointer = val;
227 if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args,
228 "", RETURN_MASK_ERROR))
230 /* An error occurred */
234 *rval = (value_ptr) args.result.pointer;
239 wrap_value_ind (opaque_arg)
242 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg;
245 val = (value_ptr) (args)->args[0].pointer;
246 (args)->result.pointer = value_ind (val);
251 gdb_parse_and_eval_type (char *p, int length, struct type **type)
253 struct gdb_wrapper_arguments args;
254 args.args[0].pointer = p;
255 args.args[1].integer = length;
257 if (!catch_errors ((catch_errors_ftype *) wrap_parse_and_eval_type, &args,
258 "", RETURN_MASK_ALL))
260 /* An error occurred */
264 *type = (struct type *) args.result.pointer;
269 wrap_parse_and_eval_type (char *a)
271 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
273 char *p = (char *) args->args[0].pointer;
274 int length = args->args[1].integer;
276 args->result.pointer = (char *) parse_and_eval_type (p, length);