Fix my last change to actually compile.
[deliverable/binutils-gdb.git] / gdb / wrapper.c
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
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
27 {
28
29 /* Pointer to some result from the gdb function call, if any */
30 union wrapper_results
31 {
32 int integer;
33 void *pointer;
34 } result;
35
36
37 /* The list of arguments. */
38 union wrapper_args
39 {
40 int integer;
41 void *pointer;
42 } args[10];
43 };
44
45 static int wrap_parse_exp_1 (char *);
46
47 static int wrap_evaluate_expression (char *);
48
49 static int wrap_value_fetch_lazy (char *);
50
51 static int wrap_value_equal (char *);
52
53 static int wrap_value_subscript (char *);
54
55 static int wrap_value_ind (char *opaque_arg);
56
57 static int wrap_parse_and_eval_type (char *);
58
59 int
60 gdb_parse_exp_1 (char **stringptr, struct block *block, int comma,
61 struct expression **expression)
62 {
63 struct gdb_wrapper_arguments args;
64 args.args[0].pointer = stringptr;
65 args.args[1].pointer = block;
66 args.args[2].integer = comma;
67
68 if (!catch_errors ((catch_errors_ftype *) wrap_parse_exp_1, &args,
69 "", RETURN_MASK_ERROR))
70 {
71 /* An error occurred */
72 return 0;
73 }
74
75 *expression = (struct expression *) args.result.pointer;
76 return 1;
77
78 }
79
80 static int
81 wrap_parse_exp_1 (char *argptr)
82 {
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);
88 return 1;
89 }
90
91 int
92 gdb_evaluate_expression (struct expression *exp, value_ptr *value)
93 {
94 struct gdb_wrapper_arguments args;
95 args.args[0].pointer = exp;
96
97 if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args,
98 "", RETURN_MASK_ERROR))
99 {
100 /* An error occurred */
101 return 0;
102 }
103
104 *value = (value_ptr) args.result.pointer;
105 return 1;
106 }
107
108 static int
109 wrap_evaluate_expression (char *a)
110 {
111 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
112
113 (args)->result.pointer =
114 (char *) evaluate_expression ((struct expression *) args->args[0].pointer);
115 return 1;
116 }
117
118 int
119 gdb_value_fetch_lazy (value_ptr value)
120 {
121 struct gdb_wrapper_arguments args;
122
123 args.args[0].pointer = value;
124 return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args,
125 "", RETURN_MASK_ERROR);
126 }
127
128 static int
129 wrap_value_fetch_lazy (char *a)
130 {
131 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
132
133 value_fetch_lazy ((value_ptr) (args)->args[0].pointer);
134 return 1;
135 }
136
137 int
138 gdb_value_equal (value_ptr val1, value_ptr val2, int *result)
139 {
140 struct gdb_wrapper_arguments args;
141
142 args.args[0].pointer = val1;
143 args.args[1].pointer = val2;
144
145 if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args,
146 "", RETURN_MASK_ERROR))
147 {
148 /* An error occurred */
149 return 0;
150 }
151
152 *result = args.result.integer;
153 return 1;
154 }
155
156 static int
157 wrap_value_equal (char *a)
158 {
159 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
160 value_ptr val1, val2;
161
162 val1 = (value_ptr) (args)->args[0].pointer;
163 val2 = (value_ptr) (args)->args[1].pointer;
164
165 (args)->result.integer = value_equal (val1, val2);
166 return 1;
167 }
168
169 int
170 gdb_value_subscript (value_ptr val1, value_ptr val2, value_ptr *rval)
171 {
172 struct gdb_wrapper_arguments args;
173
174 args.args[0].pointer = val1;
175 args.args[1].pointer = val2;
176
177 if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
178 "", RETURN_MASK_ERROR))
179 {
180 /* An error occurred */
181 return 0;
182 }
183
184 *rval = (value_ptr) args.result.pointer;
185 return 1;
186 }
187
188 static int
189 wrap_value_subscript (char *a)
190 {
191 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
192 value_ptr val1, val2;
193
194 val1 = (value_ptr) (args)->args[0].pointer;
195 val2 = (value_ptr) (args)->args[1].pointer;
196
197 (args)->result.pointer = value_subscript (val1, val2);
198 return 1;
199 }
200
201 int
202 gdb_value_ind (value_ptr val, value_ptr *rval)
203 {
204 struct gdb_wrapper_arguments args;
205
206 args.args[0].pointer = val;
207
208 if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args,
209 "", RETURN_MASK_ERROR))
210 {
211 /* An error occurred */
212 return 0;
213 }
214
215 *rval = (value_ptr) args.result.pointer;
216 return 1;
217 }
218
219 static int
220 wrap_value_ind (char *opaque_arg)
221 {
222 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg;
223 value_ptr val;
224
225 val = (value_ptr) (args)->args[0].pointer;
226 (args)->result.pointer = value_ind (val);
227 return 1;
228 }
229
230 int
231 gdb_parse_and_eval_type (char *p, int length, struct type **type)
232 {
233 struct gdb_wrapper_arguments args;
234 args.args[0].pointer = p;
235 args.args[1].integer = length;
236
237 if (!catch_errors ((catch_errors_ftype *) wrap_parse_and_eval_type, &args,
238 "", RETURN_MASK_ALL))
239 {
240 /* An error occurred */
241 return 0;
242 }
243
244 *type = (struct type *) args.result.pointer;
245 return 1;
246 }
247
248 static int
249 wrap_parse_and_eval_type (char *a)
250 {
251 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
252
253 char *p = (char *) args->args[0].pointer;
254 int length = args->args[1].integer;
255
256 args->result.pointer = (char *) parse_and_eval_type (p, length);
257
258 return 1;
259 }
This page took 0.050264 seconds and 4 git commands to generate.