* read.c (cons_worker): Detect and reject unexpected string argument.
[deliverable/binutils-gdb.git] / gdb / wrapper.c
1 /* Longjump free calls to GDB internal routines.
2
3 Copyright (C) 1999, 2000, 2005, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #include "defs.h"
20 #include "value.h"
21 #include "exceptions.h"
22 #include "wrapper.h"
23 #include "ui-out.h"
24
25 int
26 gdb_parse_exp_1 (char **stringptr, struct block *block, int comma,
27 struct expression **expression)
28 {
29 volatile struct gdb_exception except;
30
31 TRY_CATCH (except, RETURN_MASK_ERROR)
32 {
33 *expression = parse_exp_1 (stringptr, block, comma);
34 }
35
36 if (except.reason < 0)
37 return 0;
38 return 1;
39 }
40
41 int
42 gdb_evaluate_expression (struct expression *exp, struct value **value)
43 {
44 volatile struct gdb_exception except;
45
46 TRY_CATCH (except, RETURN_MASK_ERROR)
47 {
48 *value = evaluate_expression(exp);
49 }
50
51 if (except.reason < 0)
52 return 0;
53 return 1;
54 }
55
56 int
57 gdb_value_fetch_lazy (struct value *val)
58 {
59 volatile struct gdb_exception except;
60
61 TRY_CATCH (except, RETURN_MASK_ERROR)
62 {
63 value_fetch_lazy (val);
64 }
65
66 if (except.reason < 0)
67 return 0;
68 return 1;
69 }
70
71 int
72 gdb_value_equal (struct value *val1, struct value *val2, int *result)
73 {
74 volatile struct gdb_exception except;
75
76 TRY_CATCH (except, RETURN_MASK_ERROR)
77 {
78 *result = value_equal (val1, val2);
79 }
80
81 if (except.reason < 0)
82 return 0;
83 return 1;
84 }
85
86 int
87 gdb_value_assign (struct value *val1, struct value *val2,
88 struct value **result)
89 {
90 volatile struct gdb_exception except;
91
92 TRY_CATCH (except, RETURN_MASK_ERROR)
93 {
94 *result = value_assign (val1, val2);
95 }
96
97 if (except.reason < 0)
98 return 0;
99 return 1;
100 }
101
102 int
103 gdb_value_subscript (struct value *val, LONGEST index,
104 struct value **result)
105 {
106 volatile struct gdb_exception except;
107
108 TRY_CATCH (except, RETURN_MASK_ERROR)
109 {
110 *result = value_subscript (val, index);
111 }
112
113 if (except.reason < 0)
114 return 0;
115 return 1;
116 }
117
118 int
119 gdb_value_ind (struct value *val, struct value **result)
120 {
121 volatile struct gdb_exception except;
122
123 TRY_CATCH (except, RETURN_MASK_ERROR)
124 {
125 *result = value_ind (val);
126 }
127
128 if (except.reason < 0)
129 return 0;
130 return 1;
131 }
132
133 int
134 gdb_parse_and_eval_type (char *p, int length, struct type **type)
135 {
136 volatile struct gdb_exception except;
137
138 TRY_CATCH (except, RETURN_MASK_ERROR)
139 {
140 *type = parse_and_eval_type (p, length);
141 }
142
143 if (except.reason < 0)
144 return 0;
145 return 1;
146 }
147
148 enum gdb_rc
149 gdb_value_struct_elt (struct ui_out *uiout, struct value **result,
150 struct value **argp, struct value **args, char *name,
151 int *static_memfuncp, char *err)
152 {
153 volatile struct gdb_exception except;
154
155 TRY_CATCH (except, RETURN_MASK_ERROR)
156 {
157 *result = value_struct_elt (argp, args, name, static_memfuncp, err);
158 }
159
160 if (except.reason < 0)
161 return GDB_RC_FAIL;
162 return GDB_RC_OK;
163 }
This page took 0.03506 seconds and 4 git commands to generate.