Update winsup stuff.
[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
73a93a32
JI
45int gdb_parse_exp_1 PARAMS ((char **, struct block *,
46 int, struct expression **));
47int wrap_parse_exp_1 PARAMS ((char *));
48
8b93c638
JM
49int gdb_evaluate_expression PARAMS ((struct expression *, value_ptr *));
50int wrap_evaluate_expression PARAMS ((char *));
51
52int gdb_value_fetch_lazy PARAMS ((value_ptr));
53int wrap_value_fetch_lazy PARAMS ((char *));
54
55int gdb_value_equal PARAMS ((value_ptr, value_ptr, int *));
56int wrap_value_equal PARAMS ((char *));
57
8310b29b
FN
58int gdb_value_subscript PARAMS ((value_ptr, value_ptr, value_ptr * rval));
59int wrap_value_subscript PARAMS ((char *));
60
8b93c638
JM
61int gdb_value_ind PARAMS ((value_ptr val, value_ptr * rval));
62int wrap_value_ind PARAMS ((char *opaque_arg));
63
73a93a32
JI
64int
65gdb_parse_exp_1 (stringptr, block, comma, expression)
66 char **stringptr;
67 struct block *block;
68 int comma;
69 struct expression **expression;
70{
71 struct gdb_wrapper_arguments args;
1d1358b6
MS
72 args.args[0].pointer = stringptr;
73 args.args[1].pointer = block;
74 args.args[2].integer = comma;
73a93a32
JI
75
76 if (!catch_errors ((catch_errors_ftype *) wrap_parse_exp_1, &args,
77 "", RETURN_MASK_ERROR))
78 {
79 /* An error occurred */
80 return 0;
81 }
82
1d1358b6 83 *expression = (struct expression *) args.result.pointer;
73a93a32
JI
84 return 1;
85
86}
87
88int
89wrap_parse_exp_1 (argptr)
90 char *argptr;
91{
92 struct gdb_wrapper_arguments *args
93 = (struct gdb_wrapper_arguments *) argptr;
1d1358b6
MS
94 args->result.pointer = parse_exp_1((char **) args->args[0].pointer,
95 (struct block *) args->args[1].pointer,
96 args->args[2].integer);
73a93a32
JI
97 return 1;
98}
99
8b93c638
JM
100int
101gdb_evaluate_expression (exp, value)
102 struct expression *exp;
103 value_ptr *value;
104{
105 struct gdb_wrapper_arguments args;
1d1358b6 106 args.args[0].pointer = exp;
8b93c638
JM
107
108 if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args,
109 "", RETURN_MASK_ERROR))
110 {
111 /* An error occurred */
112 return 0;
113 }
114
1d1358b6 115 *value = (value_ptr) args.result.pointer;
8b93c638
JM
116 return 1;
117}
118
119int
120wrap_evaluate_expression (a)
121 char *a;
122{
123 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
124
1d1358b6
MS
125 (args)->result.pointer =
126 (char *) evaluate_expression ((struct expression *) args->args[0].pointer);
8b93c638
JM
127 return 1;
128}
129
130int
131gdb_value_fetch_lazy (value)
132 value_ptr value;
133{
134 struct gdb_wrapper_arguments args;
135
1d1358b6 136 args.args[0].pointer = value;
8b93c638
JM
137 return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args,
138 "", RETURN_MASK_ERROR);
139}
140
141int
142wrap_value_fetch_lazy (a)
143 char *a;
144{
145 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
146
1d1358b6 147 value_fetch_lazy ((value_ptr) (args)->args[0].pointer);
8b93c638
JM
148 return 1;
149}
150
151int
152gdb_value_equal (val1, val2, result)
153 value_ptr val1;
154 value_ptr val2;
155 int *result;
156{
157 struct gdb_wrapper_arguments args;
158
1d1358b6
MS
159 args.args[0].pointer = val1;
160 args.args[1].pointer = val2;
8b93c638
JM
161
162 if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args,
163 "", RETURN_MASK_ERROR))
164 {
165 /* An error occurred */
166 return 0;
167 }
168
1d1358b6 169 *result = args.result.integer;
8b93c638
JM
170 return 1;
171}
172
173int
174wrap_value_equal (a)
175 char *a;
176{
177 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
178 value_ptr val1, val2;
179
1d1358b6
MS
180 val1 = (value_ptr) (args)->args[0].pointer;
181 val2 = (value_ptr) (args)->args[1].pointer;
8b93c638 182
1d1358b6 183 (args)->result.integer = value_equal (val1, val2);
8b93c638
JM
184 return 1;
185}
186
8310b29b
FN
187int
188gdb_value_subscript (val1, val2, rval)
189 value_ptr val1;
190 value_ptr val2;
191 value_ptr * rval;
192{
193 struct gdb_wrapper_arguments args;
194
195 args.args[0].pointer = val1;
196 args.args[1].pointer = val2;
197
198 if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
199 "", RETURN_MASK_ERROR))
200 {
201 /* An error occurred */
202 return 0;
203 }
204
205 *rval = (value_ptr) args.result.pointer;
206 return 1;
207}
208
209int
210wrap_value_subscript (a)
211 char *a;
212{
213 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
214 value_ptr val1, val2;
215
216 val1 = (value_ptr) (args)->args[0].pointer;
217 val2 = (value_ptr) (args)->args[1].pointer;
218
219 (args)->result.pointer = value_subscript (val1, val2);
220 return 1;
221}
222
8b93c638
JM
223int
224gdb_value_ind (val, rval)
225 value_ptr val;
226 value_ptr *rval;
227{
228 struct gdb_wrapper_arguments args;
229
1d1358b6 230 args.args[0].pointer = val;
8b93c638
JM
231
232 if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args,
233 "", RETURN_MASK_ERROR))
234 {
235 /* An error occurred */
236 return 0;
237 }
238
1d1358b6 239 *rval = (value_ptr) args.result.pointer;
8b93c638
JM
240 return 1;
241}
242
243int
244wrap_value_ind (opaque_arg)
245 char *opaque_arg;
246{
247 struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg;
248 value_ptr val;
249
1d1358b6
MS
250 val = (value_ptr) (args)->args[0].pointer;
251 (args)->result.pointer = value_ind (val);
8b93c638
JM
252 return 1;
253}
73a93a32 254
This page took 0.048757 seconds and 4 git commands to generate.