]>
Commit | Line | Data |
---|---|---|
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. */ |
26 | struct 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 |
45 | int gdb_parse_exp_1 PARAMS ((char **, struct block *, |
46 | int, struct expression **)); | |
47 | int wrap_parse_exp_1 PARAMS ((char *)); | |
48 | ||
8b93c638 JM |
49 | int gdb_evaluate_expression PARAMS ((struct expression *, value_ptr *)); |
50 | int wrap_evaluate_expression PARAMS ((char *)); | |
51 | ||
52 | int gdb_value_fetch_lazy PARAMS ((value_ptr)); | |
53 | int wrap_value_fetch_lazy PARAMS ((char *)); | |
54 | ||
55 | int gdb_value_equal PARAMS ((value_ptr, value_ptr, int *)); | |
56 | int wrap_value_equal PARAMS ((char *)); | |
57 | ||
58 | int gdb_value_ind PARAMS ((value_ptr val, value_ptr * rval)); | |
59 | int wrap_value_ind PARAMS ((char *opaque_arg)); | |
60 | ||
73a93a32 JI |
61 | int |
62 | gdb_parse_exp_1 (stringptr, block, comma, expression) | |
63 | char **stringptr; | |
64 | struct block *block; | |
65 | int comma; | |
66 | struct expression **expression; | |
67 | { | |
68 | struct gdb_wrapper_arguments args; | |
1d1358b6 MS |
69 | args.args[0].pointer = stringptr; |
70 | args.args[1].pointer = block; | |
71 | args.args[2].integer = comma; | |
73a93a32 JI |
72 | |
73 | if (!catch_errors ((catch_errors_ftype *) wrap_parse_exp_1, &args, | |
74 | "", RETURN_MASK_ERROR)) | |
75 | { | |
76 | /* An error occurred */ | |
77 | return 0; | |
78 | } | |
79 | ||
1d1358b6 | 80 | *expression = (struct expression *) args.result.pointer; |
73a93a32 JI |
81 | return 1; |
82 | ||
83 | } | |
84 | ||
85 | int | |
86 | wrap_parse_exp_1 (argptr) | |
87 | char *argptr; | |
88 | { | |
89 | struct gdb_wrapper_arguments *args | |
90 | = (struct gdb_wrapper_arguments *) argptr; | |
1d1358b6 MS |
91 | args->result.pointer = parse_exp_1((char **) args->args[0].pointer, |
92 | (struct block *) args->args[1].pointer, | |
93 | args->args[2].integer); | |
73a93a32 JI |
94 | return 1; |
95 | } | |
96 | ||
8b93c638 JM |
97 | int |
98 | gdb_evaluate_expression (exp, value) | |
99 | struct expression *exp; | |
100 | value_ptr *value; | |
101 | { | |
102 | struct gdb_wrapper_arguments args; | |
1d1358b6 | 103 | args.args[0].pointer = exp; |
8b93c638 JM |
104 | |
105 | if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args, | |
106 | "", RETURN_MASK_ERROR)) | |
107 | { | |
108 | /* An error occurred */ | |
109 | return 0; | |
110 | } | |
111 | ||
1d1358b6 | 112 | *value = (value_ptr) args.result.pointer; |
8b93c638 JM |
113 | return 1; |
114 | } | |
115 | ||
116 | int | |
117 | wrap_evaluate_expression (a) | |
118 | char *a; | |
119 | { | |
120 | struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a; | |
121 | ||
1d1358b6 MS |
122 | (args)->result.pointer = |
123 | (char *) evaluate_expression ((struct expression *) args->args[0].pointer); | |
8b93c638 JM |
124 | return 1; |
125 | } | |
126 | ||
127 | int | |
128 | gdb_value_fetch_lazy (value) | |
129 | value_ptr value; | |
130 | { | |
131 | struct gdb_wrapper_arguments args; | |
132 | ||
1d1358b6 | 133 | args.args[0].pointer = value; |
8b93c638 JM |
134 | return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args, |
135 | "", RETURN_MASK_ERROR); | |
136 | } | |
137 | ||
138 | int | |
139 | wrap_value_fetch_lazy (a) | |
140 | char *a; | |
141 | { | |
142 | struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a; | |
143 | ||
1d1358b6 | 144 | value_fetch_lazy ((value_ptr) (args)->args[0].pointer); |
8b93c638 JM |
145 | return 1; |
146 | } | |
147 | ||
148 | int | |
149 | gdb_value_equal (val1, val2, result) | |
150 | value_ptr val1; | |
151 | value_ptr val2; | |
152 | int *result; | |
153 | { | |
154 | struct gdb_wrapper_arguments args; | |
155 | ||
1d1358b6 MS |
156 | args.args[0].pointer = val1; |
157 | args.args[1].pointer = val2; | |
8b93c638 JM |
158 | |
159 | if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args, | |
160 | "", RETURN_MASK_ERROR)) | |
161 | { | |
162 | /* An error occurred */ | |
163 | return 0; | |
164 | } | |
165 | ||
1d1358b6 | 166 | *result = args.result.integer; |
8b93c638 JM |
167 | return 1; |
168 | } | |
169 | ||
170 | int | |
171 | wrap_value_equal (a) | |
172 | char *a; | |
173 | { | |
174 | struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a; | |
175 | value_ptr val1, val2; | |
176 | ||
1d1358b6 MS |
177 | val1 = (value_ptr) (args)->args[0].pointer; |
178 | val2 = (value_ptr) (args)->args[1].pointer; | |
8b93c638 | 179 | |
1d1358b6 | 180 | (args)->result.integer = value_equal (val1, val2); |
8b93c638 JM |
181 | return 1; |
182 | } | |
183 | ||
184 | int | |
185 | gdb_value_ind (val, rval) | |
186 | value_ptr val; | |
187 | value_ptr *rval; | |
188 | { | |
189 | struct gdb_wrapper_arguments args; | |
190 | ||
1d1358b6 | 191 | args.args[0].pointer = val; |
8b93c638 JM |
192 | |
193 | if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args, | |
194 | "", RETURN_MASK_ERROR)) | |
195 | { | |
196 | /* An error occurred */ | |
197 | return 0; | |
198 | } | |
199 | ||
1d1358b6 | 200 | *rval = (value_ptr) args.result.pointer; |
8b93c638 JM |
201 | return 1; |
202 | } | |
203 | ||
204 | int | |
205 | wrap_value_ind (opaque_arg) | |
206 | char *opaque_arg; | |
207 | { | |
208 | struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg; | |
209 | value_ptr val; | |
210 | ||
1d1358b6 MS |
211 | val = (value_ptr) (args)->args[0].pointer; |
212 | (args)->result.pointer = value_ind (val); | |
8b93c638 JM |
213 | return 1; |
214 | } | |
73a93a32 | 215 |