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 (char **stringptr
, struct block
*block
, int comma
,
61 struct expression
**expression
)
63 struct gdb_wrapper_arguments args
;
64 args
.args
[0].pointer
= stringptr
;
65 args
.args
[1].pointer
= block
;
66 args
.args
[2].integer
= comma
;
68 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_exp_1
, &args
,
69 "", RETURN_MASK_ERROR
))
71 /* An error occurred */
75 *expression
= (struct expression
*) args
.result
.pointer
;
81 wrap_parse_exp_1 (char *argptr
)
83 struct gdb_wrapper_arguments
*args
84 = (struct gdb_wrapper_arguments
*) argptr
;
85 args
->result
.pointer
= parse_exp_1((char **) args
->args
[0].pointer
,
86 (struct block
*) args
->args
[1].pointer
,
87 args
->args
[2].integer
);
92 gdb_evaluate_expression (struct expression
*exp
, value_ptr
*value
)
94 struct gdb_wrapper_arguments args
;
95 args
.args
[0].pointer
= exp
;
97 if (!catch_errors ((catch_errors_ftype
*) wrap_evaluate_expression
, &args
,
98 "", RETURN_MASK_ERROR
))
100 /* An error occurred */
104 *value
= (value_ptr
) args
.result
.pointer
;
109 wrap_evaluate_expression (char *a
)
111 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
113 (args
)->result
.pointer
=
114 (char *) evaluate_expression ((struct expression
*) args
->args
[0].pointer
);
119 gdb_value_fetch_lazy (value_ptr value
)
121 struct gdb_wrapper_arguments args
;
123 args
.args
[0].pointer
= value
;
124 return catch_errors ((catch_errors_ftype
*) wrap_value_fetch_lazy
, &args
,
125 "", RETURN_MASK_ERROR
);
129 wrap_value_fetch_lazy (char *a
)
131 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
133 value_fetch_lazy ((value_ptr
) (args
)->args
[0].pointer
);
138 gdb_value_equal (value_ptr val1
, value_ptr val2
, int *result
)
140 struct gdb_wrapper_arguments args
;
142 args
.args
[0].pointer
= val1
;
143 args
.args
[1].pointer
= val2
;
145 if (!catch_errors ((catch_errors_ftype
*) wrap_value_equal
, &args
,
146 "", RETURN_MASK_ERROR
))
148 /* An error occurred */
152 *result
= args
.result
.integer
;
157 wrap_value_equal (char *a
)
159 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
160 value_ptr val1
, val2
;
162 val1
= (value_ptr
) (args
)->args
[0].pointer
;
163 val2
= (value_ptr
) (args
)->args
[1].pointer
;
165 (args
)->result
.integer
= value_equal (val1
, val2
);
170 gdb_value_subscript (value_ptr val1
, value_ptr val2
, value_ptr
*rval
)
172 struct gdb_wrapper_arguments args
;
174 args
.args
[0].pointer
= val1
;
175 args
.args
[1].pointer
= val2
;
177 if (!catch_errors ((catch_errors_ftype
*) wrap_value_subscript
, &args
,
178 "", RETURN_MASK_ERROR
))
180 /* An error occurred */
184 *rval
= (value_ptr
) args
.result
.pointer
;
189 wrap_value_subscript (char *a
)
191 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
192 value_ptr val1
, val2
;
194 val1
= (value_ptr
) (args
)->args
[0].pointer
;
195 val2
= (value_ptr
) (args
)->args
[1].pointer
;
197 (args
)->result
.pointer
= value_subscript (val1
, val2
);
202 gdb_value_ind (value_ptr val
, value_ptr
*rval
)
204 struct gdb_wrapper_arguments args
;
206 args
.args
[0].pointer
= val
;
208 if (!catch_errors ((catch_errors_ftype
*) wrap_value_ind
, &args
,
209 "", RETURN_MASK_ERROR
))
211 /* An error occurred */
215 *rval
= (value_ptr
) args
.result
.pointer
;
220 wrap_value_ind (char *opaque_arg
)
222 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) opaque_arg
;
225 val
= (value_ptr
) (args
)->args
[0].pointer
;
226 (args
)->result
.pointer
= value_ind (val
);
231 gdb_parse_and_eval_type (char *p
, int length
, struct type
**type
)
233 struct gdb_wrapper_arguments args
;
234 args
.args
[0].pointer
= p
;
235 args
.args
[1].integer
= length
;
237 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_and_eval_type
, &args
,
238 "", RETURN_MASK_ALL
))
240 /* An error occurred */
244 *type
= (struct type
*) args
.result
.pointer
;
249 wrap_parse_and_eval_type (char *a
)
251 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
253 char *p
= (char *) args
->args
[0].pointer
;
254 int length
= args
->args
[1].integer
;
256 args
->result
.pointer
= (char *) parse_and_eval_type (p
, length
);