Clarify texinfo/
[deliverable/binutils-gdb.git] / gdb / wrapper.c
CommitLineData
8b93c638
JM
1/* Longjump free calls to gdb internal routines.
2 Copyright 1999 Free Software Foundation, Inc.
3
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.
8
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.
13
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. */
18
19#include "defs.h"
20#include "value.h"
21#include "frame.h"
22#include "wrapper.h"
23
1d1358b6 24/* Use this struct to pass arguments to wrapper routines. We assume
8b93c638
JM
25 (arbitrarily) that no gdb function takes more than ten arguments. */
26struct gdb_wrapper_arguments
27 {
28
29 /* Pointer to some result from the gdb function call, if any */
1d1358b6
MS
30 union wrapper_results
31 {
32 int integer;
33 void *pointer;
34 } result;
35
8b93c638
JM
36
37 /* The list of arguments. */
1d1358b6
MS
38 union wrapper_args
39 {
40 int integer;
41 void *pointer;
42 } args[10];
8b93c638
JM
43 };
44
a14ed312 45static int wrap_parse_exp_1 (char *);
73a93a32 46
a14ed312 47static int wrap_evaluate_expression (char *);
8b93c638 48
a14ed312 49static int wrap_value_fetch_lazy (char *);
8b93c638 50
a14ed312 51static int wrap_value_equal (char *);
8b93c638 52
a14ed312 53static int wrap_value_subscript (char *);
8310b29b 54
a14ed312 55static int wrap_value_ind (char *opaque_arg);
8b93c638 56
287e3058 57static int wrap_parse_and_eval_type (char *);
c91ecb25 58
73a93a32
JI
59int
60gdb_parse_exp_1 (stringptr, block, comma, expression)
61 char **stringptr;
62 struct block *block;
63 int comma;
64 struct expression **expression;
65{
66 struct gdb_wrapper_arguments args;
1d1358b6
MS
67 args.args[0].pointer = stringptr;
68 args.args[1].pointer = block;
69 args.args[2].integer = comma;
73a93a32
JI
70
71 if (!catch_errors ((catch_errors_ftype *) wrap_parse_exp_1, &args,
72 "", RETURN_MASK_ERROR))
73 {
74 /* An error occurred */
75 return 0;
76 }
77
1d1358b6 78 *expression = (struct expression *) args.result.pointer;
73a93a32
JI
79 return 1;
80
81}
82
287e3058 83static int
73a93a32
JI
84wrap_parse_exp_1 (argptr)
85 char *argptr;
86{
87 struct gdb_wrapper_arguments *args
88 = (struct gdb_wrapper_arguments *) argptr;
1d1358b6
MS
89 args->result.pointer = parse_exp_1((char **) args->args[0].pointer,
90 (struct block *) args->args[1].pointer,
91 args->args[2].integer);
73a93a32
JI
92 return 1;
93}
94
8b93c638
JM
95int
96gdb_evaluate_expression (exp, value)
97 struct expression *exp;
98 value_ptr *value;
99{
100 struct gdb_wrapper_arguments args;
1d1358b6 101 args.args[0].pointer = exp;
8b93c638
JM
102
103 if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args,
104 "", RETURN_MASK_ERROR))
105 {
106 /* An error occurred */
107 return 0;
108 }
109
1d1358b6 110 *value = (value_ptr) args.result.pointer;
8b93c638
JM
111 return 1;
112}
113
287e3058 114static int
8b93c638
JM
115wrap_evaluate_expression (a)
116 char *a;
117{
118 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
119
1d1358b6
MS
120 (args)->result.pointer =
121 (char *) evaluate_expression ((struct expression *) args->args[0].pointer);
8b93c638
JM
122 return 1;
123}
124
125int
126gdb_value_fetch_lazy (value)
127 value_ptr value;
128{
129 struct gdb_wrapper_arguments args;
130
1d1358b6 131 args.args[0].pointer = value;
8b93c638
JM
132 return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args,
133 "", RETURN_MASK_ERROR);
134}
135
287e3058 136static int
8b93c638
JM
137wrap_value_fetch_lazy (a)
138 char *a;
139{
140 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
141
1d1358b6 142 value_fetch_lazy ((value_ptr) (args)->args[0].pointer);
8b93c638
JM
143 return 1;
144}
145
146int
147gdb_value_equal (val1, val2, result)
148 value_ptr val1;
149 value_ptr val2;
150 int *result;
151{
152 struct gdb_wrapper_arguments args;
153
1d1358b6
MS
154 args.args[0].pointer = val1;
155 args.args[1].pointer = val2;
8b93c638
JM
156
157 if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args,
158 "", RETURN_MASK_ERROR))
159 {
160 /* An error occurred */
161 return 0;
162 }
163
1d1358b6 164 *result = args.result.integer;
8b93c638
JM
165 return 1;
166}
167
287e3058 168static int
8b93c638
JM
169wrap_value_equal (a)
170 char *a;
171{
172 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
173 value_ptr val1, val2;
174
1d1358b6
MS
175 val1 = (value_ptr) (args)->args[0].pointer;
176 val2 = (value_ptr) (args)->args[1].pointer;
8b93c638 177
1d1358b6 178 (args)->result.integer = value_equal (val1, val2);
8b93c638
JM
179 return 1;
180}
181
8310b29b
FN
182int
183gdb_value_subscript (val1, val2, rval)
184 value_ptr val1;
185 value_ptr val2;
186 value_ptr * rval;
187{
188 struct gdb_wrapper_arguments args;
189
190 args.args[0].pointer = val1;
191 args.args[1].pointer = val2;
192
193 if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
194 "", RETURN_MASK_ERROR))
195 {
196 /* An error occurred */
197 return 0;
198 }
199
200 *rval = (value_ptr) args.result.pointer;
201 return 1;
202}
203
287e3058 204static int
8310b29b
FN
205wrap_value_subscript (a)
206 char *a;
207{
208 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
209 value_ptr val1, val2;
210
211 val1 = (value_ptr) (args)->args[0].pointer;
212 val2 = (value_ptr) (args)->args[1].pointer;
213
214 (args)->result.pointer = value_subscript (val1, val2);
215 return 1;
216}
217
8b93c638
JM
218int
219gdb_value_ind (val, rval)
220 value_ptr val;
221 value_ptr *rval;
222{
223 struct gdb_wrapper_arguments args;
224
1d1358b6 225 args.args[0].pointer = val;
8b93c638
JM
226
227 if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args,
228 "", RETURN_MASK_ERROR))
229 {
230 /* An error occurred */
231 return 0;
232 }
233
1d1358b6 234 *rval = (value_ptr) args.result.pointer;
8b93c638
JM
235 return 1;
236}
237
287e3058 238static int
8b93c638
JM
239wrap_value_ind (opaque_arg)
240 char *opaque_arg;
241{
242 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg;
243 value_ptr val;
244
1d1358b6
MS
245 val = (value_ptr) (args)->args[0].pointer;
246 (args)->result.pointer = value_ind (val);
8b93c638
JM
247 return 1;
248}
73a93a32 249
c91ecb25
ND
250int
251gdb_parse_and_eval_type (char *p, int length, struct type **type)
252{
253 struct gdb_wrapper_arguments args;
254 args.args[0].pointer = p;
255 args.args[1].integer = length;
256
257 if (!catch_errors ((catch_errors_ftype *) wrap_parse_and_eval_type, &args,
258 "", RETURN_MASK_ALL))
259 {
260 /* An error occurred */
261 return 0;
262 }
263
264 *type = (struct type *) args.result.pointer;
265 return 1;
266}
267
287e3058 268static int
c91ecb25
ND
269wrap_parse_and_eval_type (char *a)
270{
271 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
272
273 char *p = (char *) args->args[0].pointer;
274 int length = args->args[1].integer;
275
276 args->result.pointer = (char *) parse_and_eval_type (p, length);
277
278 return 1;
279}
This page took 0.068999 seconds and 4 git commands to generate.