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