]>
Commit | Line | Data |
---|---|---|
1c7b1e5a MK |
1 | /* Longjump free calls to GDB internal routines. |
2 | ||
7b6bb8da | 3 | Copyright (C) 1999, 2000, 2005, 2007, 2008, 2009, 2010, 2011 |
0fb0cc75 | 4 | Free Software Foundation, Inc. |
8b93c638 JM |
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 | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
8b93c638 JM |
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 | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8b93c638 JM |
18 | |
19 | #include "defs.h" | |
20 | #include "value.h" | |
60250e8b | 21 | #include "exceptions.h" |
8b93c638 | 22 | #include "wrapper.h" |
1c7b1e5a | 23 | #include "ui-out.h" |
9a845ea2 | 24 | #include "target.h" |
c91ecb25 | 25 | |
73a93a32 | 26 | int |
fba45db2 KB |
27 | gdb_parse_exp_1 (char **stringptr, struct block *block, int comma, |
28 | struct expression **expression) | |
73a93a32 | 29 | { |
71fff37b | 30 | volatile struct gdb_exception except; |
73a93a32 | 31 | |
1c7b1e5a | 32 | TRY_CATCH (except, RETURN_MASK_ERROR) |
73a93a32 | 33 | { |
1c7b1e5a | 34 | *expression = parse_exp_1 (stringptr, block, comma); |
73a93a32 JI |
35 | } |
36 | ||
1c7b1e5a MK |
37 | if (except.reason < 0) |
38 | return 0; | |
73a93a32 JI |
39 | return 1; |
40 | } | |
41 | ||
8b93c638 | 42 | int |
c9847381 | 43 | gdb_evaluate_expression (struct expression *exp, struct value **value) |
8b93c638 | 44 | { |
71fff37b | 45 | volatile struct gdb_exception except; |
8b93c638 | 46 | |
1c7b1e5a | 47 | TRY_CATCH (except, RETURN_MASK_ERROR) |
8b93c638 | 48 | { |
1c7b1e5a | 49 | *value = evaluate_expression(exp); |
8b93c638 JM |
50 | } |
51 | ||
1c7b1e5a MK |
52 | if (except.reason < 0) |
53 | return 0; | |
8b93c638 JM |
54 | return 1; |
55 | } | |
56 | ||
57 | int | |
1c7b1e5a | 58 | gdb_value_fetch_lazy (struct value *val) |
8b93c638 | 59 | { |
71fff37b | 60 | volatile struct gdb_exception except; |
8b93c638 | 61 | |
1c7b1e5a MK |
62 | TRY_CATCH (except, RETURN_MASK_ERROR) |
63 | { | |
64 | value_fetch_lazy (val); | |
65 | } | |
8b93c638 | 66 | |
1c7b1e5a MK |
67 | if (except.reason < 0) |
68 | return 0; | |
8b93c638 JM |
69 | return 1; |
70 | } | |
71 | ||
72 | int | |
c9847381 | 73 | gdb_value_equal (struct value *val1, struct value *val2, int *result) |
8b93c638 | 74 | { |
71fff37b | 75 | volatile struct gdb_exception except; |
8b93c638 | 76 | |
1c7b1e5a | 77 | TRY_CATCH (except, RETURN_MASK_ERROR) |
8b93c638 | 78 | { |
1c7b1e5a | 79 | *result = value_equal (val1, val2); |
8b93c638 JM |
80 | } |
81 | ||
1c7b1e5a MK |
82 | if (except.reason < 0) |
83 | return 0; | |
8b93c638 JM |
84 | return 1; |
85 | } | |
86 | ||
8a1a0112 | 87 | int |
1c7b1e5a MK |
88 | gdb_value_assign (struct value *val1, struct value *val2, |
89 | struct value **result) | |
8a1a0112 | 90 | { |
71fff37b | 91 | volatile struct gdb_exception except; |
8a1a0112 | 92 | |
1c7b1e5a | 93 | TRY_CATCH (except, RETURN_MASK_ERROR) |
8a1a0112 | 94 | { |
1c7b1e5a | 95 | *result = value_assign (val1, val2); |
8a1a0112 FN |
96 | } |
97 | ||
1c7b1e5a MK |
98 | if (except.reason < 0) |
99 | return 0; | |
8a1a0112 FN |
100 | return 1; |
101 | } | |
102 | ||
8310b29b | 103 | int |
2497b498 | 104 | gdb_value_subscript (struct value *val, LONGEST index, |
1c7b1e5a | 105 | struct value **result) |
8310b29b | 106 | { |
71fff37b | 107 | volatile struct gdb_exception except; |
8310b29b | 108 | |
1c7b1e5a | 109 | TRY_CATCH (except, RETURN_MASK_ERROR) |
8310b29b | 110 | { |
2497b498 | 111 | *result = value_subscript (val, index); |
8310b29b FN |
112 | } |
113 | ||
1c7b1e5a MK |
114 | if (except.reason < 0) |
115 | return 0; | |
8310b29b FN |
116 | return 1; |
117 | } | |
118 | ||
8b93c638 | 119 | int |
1c7b1e5a | 120 | gdb_value_ind (struct value *val, struct value **result) |
8b93c638 | 121 | { |
71fff37b | 122 | volatile struct gdb_exception except; |
8b93c638 | 123 | |
1c7b1e5a | 124 | TRY_CATCH (except, RETURN_MASK_ERROR) |
8b93c638 | 125 | { |
1c7b1e5a | 126 | *result = value_ind (val); |
8b93c638 JM |
127 | } |
128 | ||
1c7b1e5a MK |
129 | if (except.reason < 0) |
130 | return 0; | |
8b93c638 JM |
131 | return 1; |
132 | } | |
73a93a32 | 133 | |
c91ecb25 ND |
134 | int |
135 | gdb_parse_and_eval_type (char *p, int length, struct type **type) | |
136 | { | |
71fff37b | 137 | volatile struct gdb_exception except; |
c91ecb25 | 138 | |
1c7b1e5a | 139 | TRY_CATCH (except, RETURN_MASK_ERROR) |
c91ecb25 | 140 | { |
1c7b1e5a | 141 | *type = parse_and_eval_type (p, length); |
c91ecb25 ND |
142 | } |
143 | ||
1c7b1e5a MK |
144 | if (except.reason < 0) |
145 | return 0; | |
c91ecb25 ND |
146 | return 1; |
147 | } | |
ddc54292 KS |
148 | |
149 | enum gdb_rc | |
1c7b1e5a MK |
150 | gdb_value_struct_elt (struct ui_out *uiout, struct value **result, |
151 | struct value **argp, struct value **args, char *name, | |
152 | int *static_memfuncp, char *err) | |
ddc54292 | 153 | { |
71fff37b | 154 | volatile struct gdb_exception except; |
ddc54292 | 155 | |
5c3ce3f7 | 156 | TRY_CATCH (except, RETURN_MASK_ERROR) |
1c7b1e5a MK |
157 | { |
158 | *result = value_struct_elt (argp, args, name, static_memfuncp, err); | |
159 | } | |
160 | ||
161 | if (except.reason < 0) | |
162 | return GDB_RC_FAIL; | |
ddc54292 KS |
163 | return GDB_RC_OK; |
164 | } | |
9a845ea2 JK |
165 | |
166 | /* Call target_find_new_threads without throwing exception. Exception is | |
167 | printed if it got thrown. */ | |
168 | ||
169 | int | |
170 | gdb_target_find_new_threads (void) | |
171 | { | |
172 | volatile struct gdb_exception except; | |
173 | ||
174 | TRY_CATCH (except, RETURN_MASK_ERROR) | |
175 | { | |
176 | target_find_new_threads (); | |
177 | } | |
178 | ||
179 | if (except.reason < 0) | |
180 | { | |
181 | exception_print (gdb_stderr, except); | |
182 | return 0; | |
183 | } | |
184 | return 1; | |
185 | } |