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_assign (char *);
55 static int wrap_value_subscript (char *);
57 static int wrap_value_ind (char *opaque_arg
);
59 static int wrap_parse_and_eval_type (char *);
62 gdb_parse_exp_1 (char **stringptr
, struct block
*block
, int comma
,
63 struct expression
**expression
)
65 struct gdb_wrapper_arguments args
;
66 args
.args
[0].pointer
= stringptr
;
67 args
.args
[1].pointer
= block
;
68 args
.args
[2].integer
= comma
;
70 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_exp_1
, &args
,
71 "", RETURN_MASK_ERROR
))
73 /* An error occurred */
77 *expression
= (struct expression
*) args
.result
.pointer
;
83 wrap_parse_exp_1 (char *argptr
)
85 struct gdb_wrapper_arguments
*args
86 = (struct gdb_wrapper_arguments
*) argptr
;
87 args
->result
.pointer
= parse_exp_1((char **) args
->args
[0].pointer
,
88 (struct block
*) args
->args
[1].pointer
,
89 args
->args
[2].integer
);
94 gdb_evaluate_expression (struct expression
*exp
, value_ptr
*value
)
96 struct gdb_wrapper_arguments args
;
97 args
.args
[0].pointer
= exp
;
99 if (!catch_errors ((catch_errors_ftype
*) wrap_evaluate_expression
, &args
,
100 "", RETURN_MASK_ERROR
))
102 /* An error occurred */
106 *value
= (value_ptr
) args
.result
.pointer
;
111 wrap_evaluate_expression (char *a
)
113 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
115 (args
)->result
.pointer
=
116 (char *) evaluate_expression ((struct expression
*) args
->args
[0].pointer
);
121 gdb_value_fetch_lazy (value_ptr value
)
123 struct gdb_wrapper_arguments args
;
125 args
.args
[0].pointer
= value
;
126 return catch_errors ((catch_errors_ftype
*) wrap_value_fetch_lazy
, &args
,
127 "", RETURN_MASK_ERROR
);
131 wrap_value_fetch_lazy (char *a
)
133 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
135 value_fetch_lazy ((value_ptr
) (args
)->args
[0].pointer
);
140 gdb_value_equal (value_ptr val1
, value_ptr val2
, int *result
)
142 struct gdb_wrapper_arguments args
;
144 args
.args
[0].pointer
= val1
;
145 args
.args
[1].pointer
= val2
;
147 if (!catch_errors ((catch_errors_ftype
*) wrap_value_equal
, &args
,
148 "", RETURN_MASK_ERROR
))
150 /* An error occurred */
154 *result
= args
.result
.integer
;
159 wrap_value_equal (char *a
)
161 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
162 value_ptr val1
, val2
;
164 val1
= (value_ptr
) (args
)->args
[0].pointer
;
165 val2
= (value_ptr
) (args
)->args
[1].pointer
;
167 (args
)->result
.integer
= value_equal (val1
, val2
);
172 gdb_value_assign (value_ptr val1
, value_ptr val2
, value_ptr
*result
)
174 struct gdb_wrapper_arguments args
;
176 args
.args
[0].pointer
= val1
;
177 args
.args
[1].pointer
= val2
;
179 if (!catch_errors ((catch_errors_ftype
*) wrap_value_assign
, &args
,
180 "", RETURN_MASK_ERROR
))
182 /* An error occurred */
186 *result
= (value_ptr
) args
.result
.pointer
;
191 wrap_value_assign (char *a
)
193 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
194 value_ptr val1
, val2
;
196 val1
= (value_ptr
) (args
)->args
[0].pointer
;
197 val2
= (value_ptr
) (args
)->args
[1].pointer
;
199 (args
)->result
.pointer
= value_assign (val1
, val2
);
204 gdb_value_subscript (value_ptr val1
, value_ptr val2
, value_ptr
*rval
)
206 struct gdb_wrapper_arguments args
;
208 args
.args
[0].pointer
= val1
;
209 args
.args
[1].pointer
= val2
;
211 if (!catch_errors ((catch_errors_ftype
*) wrap_value_subscript
, &args
,
212 "", RETURN_MASK_ERROR
))
214 /* An error occurred */
218 *rval
= (value_ptr
) args
.result
.pointer
;
223 wrap_value_subscript (char *a
)
225 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
226 value_ptr val1
, val2
;
228 val1
= (value_ptr
) (args
)->args
[0].pointer
;
229 val2
= (value_ptr
) (args
)->args
[1].pointer
;
231 (args
)->result
.pointer
= value_subscript (val1
, val2
);
236 gdb_value_ind (value_ptr val
, value_ptr
*rval
)
238 struct gdb_wrapper_arguments args
;
240 args
.args
[0].pointer
= val
;
242 if (!catch_errors ((catch_errors_ftype
*) wrap_value_ind
, &args
,
243 "", RETURN_MASK_ERROR
))
245 /* An error occurred */
249 *rval
= (value_ptr
) args
.result
.pointer
;
254 wrap_value_ind (char *opaque_arg
)
256 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) opaque_arg
;
259 val
= (value_ptr
) (args
)->args
[0].pointer
;
260 (args
)->result
.pointer
= value_ind (val
);
265 gdb_parse_and_eval_type (char *p
, int length
, struct type
**type
)
267 struct gdb_wrapper_arguments args
;
268 args
.args
[0].pointer
= p
;
269 args
.args
[1].integer
= length
;
271 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_and_eval_type
, &args
,
272 "", RETURN_MASK_ALL
))
274 /* An error occurred */
278 *type
= (struct type
*) args
.result
.pointer
;
283 wrap_parse_and_eval_type (char *a
)
285 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
287 char *p
= (char *) args
->args
[0].pointer
;
288 int length
= args
->args
[1].integer
;
290 args
->result
.pointer
= (char *) parse_and_eval_type (p
, length
);