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 int gdb_parse_exp_1
PARAMS ((char **, struct block
*,
46 int, struct expression
**));
47 int wrap_parse_exp_1
PARAMS ((char *));
49 int gdb_evaluate_expression
PARAMS ((struct expression
*, value_ptr
*));
50 int wrap_evaluate_expression
PARAMS ((char *));
52 int gdb_value_fetch_lazy
PARAMS ((value_ptr
));
53 int wrap_value_fetch_lazy
PARAMS ((char *));
55 int gdb_value_equal
PARAMS ((value_ptr
, value_ptr
, int *));
56 int wrap_value_equal
PARAMS ((char *));
58 int gdb_value_subscript
PARAMS ((value_ptr
, value_ptr
, value_ptr
* rval
));
59 int wrap_value_subscript
PARAMS ((char *));
61 int gdb_value_ind
PARAMS ((value_ptr val
, value_ptr
* rval
));
62 int wrap_value_ind
PARAMS ((char *opaque_arg
));
64 int gdb_parse_and_eval_type (char *, int, struct type
**);
65 int wrap_parse_and_eval_type (char *);
68 gdb_parse_exp_1 (stringptr
, block
, comma
, expression
)
72 struct expression
**expression
;
74 struct gdb_wrapper_arguments args
;
75 args
.args
[0].pointer
= stringptr
;
76 args
.args
[1].pointer
= block
;
77 args
.args
[2].integer
= comma
;
79 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_exp_1
, &args
,
80 "", RETURN_MASK_ERROR
))
82 /* An error occurred */
86 *expression
= (struct expression
*) args
.result
.pointer
;
92 wrap_parse_exp_1 (argptr
)
95 struct gdb_wrapper_arguments
*args
96 = (struct gdb_wrapper_arguments
*) argptr
;
97 args
->result
.pointer
= parse_exp_1((char **) args
->args
[0].pointer
,
98 (struct block
*) args
->args
[1].pointer
,
99 args
->args
[2].integer
);
104 gdb_evaluate_expression (exp
, value
)
105 struct expression
*exp
;
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
= (value_ptr
) args
.result
.pointer
;
123 wrap_evaluate_expression (a
)
126 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
128 (args
)->result
.pointer
=
129 (char *) evaluate_expression ((struct expression
*) args
->args
[0].pointer
);
134 gdb_value_fetch_lazy (value
)
137 struct gdb_wrapper_arguments args
;
139 args
.args
[0].pointer
= value
;
140 return catch_errors ((catch_errors_ftype
*) wrap_value_fetch_lazy
, &args
,
141 "", RETURN_MASK_ERROR
);
145 wrap_value_fetch_lazy (a
)
148 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
150 value_fetch_lazy ((value_ptr
) (args
)->args
[0].pointer
);
155 gdb_value_equal (val1
, val2
, result
)
160 struct gdb_wrapper_arguments args
;
162 args
.args
[0].pointer
= val1
;
163 args
.args
[1].pointer
= val2
;
165 if (!catch_errors ((catch_errors_ftype
*) wrap_value_equal
, &args
,
166 "", RETURN_MASK_ERROR
))
168 /* An error occurred */
172 *result
= args
.result
.integer
;
180 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
181 value_ptr val1
, val2
;
183 val1
= (value_ptr
) (args
)->args
[0].pointer
;
184 val2
= (value_ptr
) (args
)->args
[1].pointer
;
186 (args
)->result
.integer
= value_equal (val1
, val2
);
191 gdb_value_subscript (val1
, val2
, rval
)
196 struct gdb_wrapper_arguments args
;
198 args
.args
[0].pointer
= val1
;
199 args
.args
[1].pointer
= val2
;
201 if (!catch_errors ((catch_errors_ftype
*) wrap_value_subscript
, &args
,
202 "", RETURN_MASK_ERROR
))
204 /* An error occurred */
208 *rval
= (value_ptr
) args
.result
.pointer
;
213 wrap_value_subscript (a
)
216 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
217 value_ptr val1
, val2
;
219 val1
= (value_ptr
) (args
)->args
[0].pointer
;
220 val2
= (value_ptr
) (args
)->args
[1].pointer
;
222 (args
)->result
.pointer
= value_subscript (val1
, val2
);
227 gdb_value_ind (val
, rval
)
231 struct gdb_wrapper_arguments args
;
233 args
.args
[0].pointer
= val
;
235 if (!catch_errors ((catch_errors_ftype
*) wrap_value_ind
, &args
,
236 "", RETURN_MASK_ERROR
))
238 /* An error occurred */
242 *rval
= (value_ptr
) args
.result
.pointer
;
247 wrap_value_ind (opaque_arg
)
250 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) opaque_arg
;
253 val
= (value_ptr
) (args
)->args
[0].pointer
;
254 (args
)->result
.pointer
= value_ind (val
);
259 gdb_parse_and_eval_type (char *p
, int length
, struct type
**type
)
261 struct gdb_wrapper_arguments args
;
262 args
.args
[0].pointer
= p
;
263 args
.args
[1].integer
= length
;
265 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_and_eval_type
, &args
,
266 "", RETURN_MASK_ALL
))
268 /* An error occurred */
272 *type
= (struct type
*) args
.result
.pointer
;
277 wrap_parse_and_eval_type (char *a
)
279 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
281 char *p
= (char *) args
->args
[0].pointer
;
282 int length
= args
->args
[1].integer
;
284 args
->result
.pointer
= (char *) parse_and_eval_type (p
, length
);