This commit was generated by cvs2svn to track changes on a CVS vendor
[platform/upstream/binutils.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 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
36 int gdb_evaluate_expression PARAMS ((struct expression *, value_ptr *));
37 int wrap_evaluate_expression PARAMS ((char *));
38
39 int gdb_value_fetch_lazy PARAMS ((value_ptr));
40 int wrap_value_fetch_lazy PARAMS ((char *));
41
42 int gdb_value_equal PARAMS ((value_ptr, value_ptr, int *));
43 int wrap_value_equal PARAMS ((char *));
44
45 int gdb_value_ind PARAMS ((value_ptr val, value_ptr * rval));
46 int wrap_value_ind PARAMS ((char *opaque_arg));
47
48 int
49 gdb_evaluate_expression (exp, value)
50      struct expression *exp;
51      value_ptr *value;
52 {
53   struct gdb_wrapper_arguments args;
54   args.args[0] = (char *) exp;
55
56   if (!catch_errors ((catch_errors_ftype *) wrap_evaluate_expression, &args,
57                      "", RETURN_MASK_ERROR))
58     {
59       /* An error occurred */
60       return 0;
61     }
62
63   *value = (value_ptr) args.result;
64   return 1;
65 }
66
67 int
68 wrap_evaluate_expression (a)
69      char *a;
70 {
71   struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
72
73   (args)->result =
74     (char *) evaluate_expression ((struct expression *) (args)->args[0]);
75   return 1;
76 }
77
78 int
79 gdb_value_fetch_lazy (value)
80      value_ptr value;
81 {
82   struct gdb_wrapper_arguments args;
83
84   args.args[0] = (char *) value;
85   return catch_errors ((catch_errors_ftype *) wrap_value_fetch_lazy, &args,
86                        "", RETURN_MASK_ERROR);
87 }
88
89 int
90 wrap_value_fetch_lazy (a)
91      char *a;
92 {
93   struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
94
95   value_fetch_lazy ((value_ptr) (args)->args[0]);
96   return 1;
97 }
98
99 int
100 gdb_value_equal (val1, val2, result)
101      value_ptr val1;
102      value_ptr val2;
103      int *result;
104 {
105   struct gdb_wrapper_arguments args;
106
107   args.args[0] = (char *) val1;
108   args.args[1] = (char *) val2;
109
110   if (!catch_errors ((catch_errors_ftype *) wrap_value_equal, &args,
111                      "", RETURN_MASK_ERROR))
112     {
113       /* An error occurred */
114       return 0;
115     }
116
117   *result = (int) args.result;
118   return 1;
119 }
120
121 int
122 wrap_value_equal (a)
123      char *a;
124 {
125   struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
126   value_ptr val1, val2;
127
128   val1 = (value_ptr) (args)->args[0];
129   val2 = (value_ptr) (args)->args[1];
130
131   (args)->result = (char *) value_equal (val1, val2);
132   return 1;
133 }
134
135 int
136 gdb_value_ind (val, rval)
137      value_ptr val;
138      value_ptr *rval;
139 {
140   struct gdb_wrapper_arguments args;
141
142   args.args[0] = (char *) val;
143
144   if (!catch_errors ((catch_errors_ftype *) wrap_value_ind, &args,
145                      "", RETURN_MASK_ERROR))
146     {
147       /* An error occurred */
148       return 0;
149     }
150
151   *rval = (value_ptr) args.result;
152   return 1;
153 }
154
155 int
156 wrap_value_ind (opaque_arg)
157      char *opaque_arg;
158 {
159   struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) opaque_arg;
160   value_ptr val;
161
162   val = (value_ptr) (args)->args[0];
163   (args)->result = (char *) value_ind (val);
164   return 1;
165 }