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. */
23 /* Use this struct to pass arguments to wrapper routines. We assume
24 (arbitrarily) that no gdb function takes more than ten arguments. */
25 struct gdb_wrapper_arguments
28 /* Pointer to some result from the gdb function call, if any */
36 /* The list of arguments. */
44 static int wrap_parse_exp_1 (char *);
46 static int wrap_evaluate_expression (char *);
48 static int wrap_value_fetch_lazy (char *);
50 static int wrap_value_equal (char *);
52 static int wrap_value_assign (char *);
54 static int wrap_value_subscript (char *);
56 static int wrap_value_ind (char *opaque_arg
);
58 static int wrap_parse_and_eval_type (char *);
61 gdb_parse_exp_1 (char **stringptr
, struct block
*block
, int comma
,
62 struct expression
**expression
)
64 struct gdb_wrapper_arguments args
;
65 args
.args
[0].pointer
= stringptr
;
66 args
.args
[1].pointer
= block
;
67 args
.args
[2].integer
= comma
;
69 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_exp_1
, &args
,
70 "", RETURN_MASK_ERROR
))
72 /* An error occurred */
76 *expression
= (struct expression
*) args
.result
.pointer
;
82 wrap_parse_exp_1 (char *argptr
)
84 struct gdb_wrapper_arguments
*args
85 = (struct gdb_wrapper_arguments
*) argptr
;
86 args
->result
.pointer
= parse_exp_1((char **) args
->args
[0].pointer
,
87 (struct block
*) args
->args
[1].pointer
,
88 args
->args
[2].integer
);
93 gdb_evaluate_expression (struct expression
*exp
, struct value
**value
)
95 struct gdb_wrapper_arguments args
;
96 args
.args
[0].pointer
= exp
;
98 if (!catch_errors ((catch_errors_ftype
*) wrap_evaluate_expression
, &args
,
99 "", RETURN_MASK_ERROR
))
101 /* An error occurred */
105 *value
= (struct value
*) args
.result
.pointer
;
110 wrap_evaluate_expression (char *a
)
112 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
114 (args
)->result
.pointer
=
115 (char *) evaluate_expression ((struct expression
*) args
->args
[0].pointer
);
120 gdb_value_fetch_lazy (struct value
*value
)
122 struct gdb_wrapper_arguments args
;
124 args
.args
[0].pointer
= value
;
125 return catch_errors ((catch_errors_ftype
*) wrap_value_fetch_lazy
, &args
,
126 "", RETURN_MASK_ERROR
);
130 wrap_value_fetch_lazy (char *a
)
132 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
134 value_fetch_lazy ((struct value
*) (args
)->args
[0].pointer
);
139 gdb_value_equal (struct value
*val1
, struct value
*val2
, int *result
)
141 struct gdb_wrapper_arguments args
;
143 args
.args
[0].pointer
= val1
;
144 args
.args
[1].pointer
= val2
;
146 if (!catch_errors ((catch_errors_ftype
*) wrap_value_equal
, &args
,
147 "", RETURN_MASK_ERROR
))
149 /* An error occurred */
153 *result
= args
.result
.integer
;
158 wrap_value_equal (char *a
)
160 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
164 val1
= (struct value
*) (args
)->args
[0].pointer
;
165 val2
= (struct value
*) (args
)->args
[1].pointer
;
167 (args
)->result
.integer
= value_equal (val1
, val2
);
172 gdb_value_assign (struct value
*val1
, struct value
*val2
, struct value
**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
= (struct value
*) args
.result
.pointer
;
191 wrap_value_assign (char *a
)
193 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
197 val1
= (struct value
*) (args
)->args
[0].pointer
;
198 val2
= (struct value
*) (args
)->args
[1].pointer
;
200 (args
)->result
.pointer
= value_assign (val1
, val2
);
205 gdb_value_subscript (struct value
*val1
, struct value
*val2
, struct value
**rval
)
207 struct gdb_wrapper_arguments args
;
209 args
.args
[0].pointer
= val1
;
210 args
.args
[1].pointer
= val2
;
212 if (!catch_errors ((catch_errors_ftype
*) wrap_value_subscript
, &args
,
213 "", RETURN_MASK_ERROR
))
215 /* An error occurred */
219 *rval
= (struct value
*) args
.result
.pointer
;
224 wrap_value_subscript (char *a
)
226 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
230 val1
= (struct value
*) (args
)->args
[0].pointer
;
231 val2
= (struct value
*) (args
)->args
[1].pointer
;
233 (args
)->result
.pointer
= value_subscript (val1
, val2
);
238 gdb_value_ind (struct value
*val
, struct value
**rval
)
240 struct gdb_wrapper_arguments args
;
242 args
.args
[0].pointer
= val
;
244 if (!catch_errors ((catch_errors_ftype
*) wrap_value_ind
, &args
,
245 "", RETURN_MASK_ERROR
))
247 /* An error occurred */
251 *rval
= (struct value
*) args
.result
.pointer
;
256 wrap_value_ind (char *opaque_arg
)
258 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) opaque_arg
;
261 val
= (struct value
*) (args
)->args
[0].pointer
;
262 (args
)->result
.pointer
= value_ind (val
);
267 gdb_parse_and_eval_type (char *p
, int length
, struct type
**type
)
269 struct gdb_wrapper_arguments args
;
270 args
.args
[0].pointer
= p
;
271 args
.args
[1].integer
= length
;
273 if (!catch_errors ((catch_errors_ftype
*) wrap_parse_and_eval_type
, &args
,
274 "", RETURN_MASK_ALL
))
276 /* An error occurred */
280 *type
= (struct type
*) args
.result
.pointer
;
285 wrap_parse_and_eval_type (char *a
)
287 struct gdb_wrapper_arguments
*args
= (struct gdb_wrapper_arguments
*) a
;
289 char *p
= (char *) args
->args
[0].pointer
;
290 int length
= args
->args
[1].integer
;
292 args
->result
.pointer
= (char *) parse_and_eval_type (p
, length
);