Commit | Line | Data |
---|---|---|
56c12414 JK |
1 | /* Standard language operator definitions for GDB, the GNU debugger. |
2 | ||
42a4f53d | 3 | Copyright (C) 1986-2019 Free Software Foundation, Inc. |
56c12414 JK |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | /* Used when it's necessary to pass an opcode which will be ignored, | |
21 | or to catch uninitialized values. */ | |
22 | OP (OP_NULL) | |
23 | ||
24 | /* BINOP_... operate on two values computed by following subexpressions, | |
25 | replacing them by one result value. They take no immediate arguments. */ | |
26 | ||
27 | OP (BINOP_ADD) /* + */ | |
28 | OP (BINOP_SUB) /* - */ | |
29 | OP (BINOP_MUL) /* * */ | |
30 | OP (BINOP_DIV) /* / */ | |
31 | OP (BINOP_REM) /* % */ | |
32 | OP (BINOP_MOD) /* mod (Knuth 1.2.4) */ | |
33 | OP (BINOP_LSH) /* << */ | |
34 | OP (BINOP_RSH) /* >> */ | |
35 | OP (BINOP_LOGICAL_AND) /* && */ | |
36 | OP (BINOP_LOGICAL_OR) /* || */ | |
37 | OP (BINOP_BITWISE_AND) /* & */ | |
38 | OP (BINOP_BITWISE_IOR) /* | */ | |
39 | OP (BINOP_BITWISE_XOR) /* ^ */ | |
40 | OP (BINOP_EQUAL) /* == */ | |
41 | OP (BINOP_NOTEQUAL) /* != */ | |
42 | OP (BINOP_LESS) /* < */ | |
43 | OP (BINOP_GTR) /* > */ | |
44 | OP (BINOP_LEQ) /* <= */ | |
45 | OP (BINOP_GEQ) /* >= */ | |
46 | OP (BINOP_REPEAT) /* @ */ | |
47 | OP (BINOP_ASSIGN) /* = */ | |
48 | OP (BINOP_COMMA) /* , */ | |
49 | OP (BINOP_SUBSCRIPT) /* x[y] */ | |
50 | OP (BINOP_EXP) /* Exponentiation */ | |
51 | ||
52 | /* C++. */ | |
53 | ||
54 | OP (BINOP_MIN) /* <? */ | |
55 | OP (BINOP_MAX) /* >? */ | |
56 | ||
57 | /* STRUCTOP_MEMBER is used for pointer-to-member constructs. | |
58 | X . * Y translates into X STRUCTOP_MEMBER Y. */ | |
59 | OP (STRUCTOP_MEMBER) | |
60 | ||
61 | /* STRUCTOP_MPTR is used for pointer-to-member constructs | |
62 | when X is a pointer instead of an aggregate. */ | |
63 | OP (STRUCTOP_MPTR) | |
64 | ||
65 | /* TYPE_INSTANCE is used when the user specifies a specific | |
66 | type instantiation for overloaded methods/functions. | |
67 | ||
68 | The format is: | |
69 | TYPE_INSTANCE num_types type0 ... typeN num_types TYPE_INSTANCE. */ | |
70 | OP (TYPE_INSTANCE) | |
71 | ||
72 | /* end of C++. */ | |
73 | ||
74 | /* For Modula-2 integer division DIV. */ | |
75 | OP (BINOP_INTDIV) | |
76 | ||
77 | /* +=, -=, *=, and so on. The following exp_element is another opcode, | |
78 | a BINOP_, saying how to modify. Then comes another BINOP_ASSIGN_MODIFY, | |
79 | making three exp_elements in total. */ | |
80 | OP (BINOP_ASSIGN_MODIFY) | |
81 | ||
82 | /* Modula-2 standard (binary) procedures. */ | |
83 | OP (BINOP_VAL) | |
84 | ||
85 | /* Concatenate two operands, such as character strings or bitstrings. | |
86 | If the first operand is a integer expression, then it means concatenate | |
87 | the second operand with itself that many times. */ | |
88 | OP (BINOP_CONCAT) | |
89 | ||
56c12414 JK |
90 | /* This must be the highest BINOP_ value, for expprint.c. */ |
91 | OP (BINOP_END) | |
92 | ||
93 | /* Operates on three values computed by following subexpressions. */ | |
94 | OP (TERNOP_COND) /* ?: */ | |
95 | ||
c9402c95 YQ |
96 | /* A sub-string/sub-array. Ada syntax: OP1(OP2..OP3). Return |
97 | elements OP2 through OP3 of OP1. */ | |
56c12414 JK |
98 | OP (TERNOP_SLICE) |
99 | ||
56c12414 JK |
100 | /* Multidimensional subscript operator, such as Modula-2 x[a,b,...]. |
101 | The dimensionality is encoded in the operator, like the number of | |
102 | function arguments in OP_FUNCALL, I.E. <OP><dimension><OP>. | |
103 | The value of the first following subexpression is subscripted | |
104 | by each of the next following subexpressions, one per dimension. */ | |
105 | OP (MULTI_SUBSCRIPT) | |
106 | ||
107 | /* The OP_... series take immediate following arguments. | |
108 | After the arguments come another OP_... (the same one) | |
109 | so that the grouping can be recognized from the end. */ | |
110 | ||
111 | /* OP_LONG is followed by a type pointer in the next exp_element | |
112 | and the long constant value in the following exp_element. | |
113 | Then comes another OP_LONG. | |
114 | Thus, the operation occupies four exp_elements. */ | |
115 | OP (OP_LONG) | |
116 | ||
edd079d9 UW |
117 | /* OP_FLOAT is similar but takes a floating-point constant encoded in |
118 | the target format for the given type instead of a long. */ | |
119 | OP (OP_FLOAT) | |
56c12414 JK |
120 | |
121 | /* OP_VAR_VALUE takes one struct block * in the following element, | |
122 | and one struct symbol * in the following exp_element, followed | |
123 | by another OP_VAR_VALUE, making four exp_elements. If the | |
124 | block is non-NULL, evaluate the symbol relative to the | |
125 | innermost frame executing in that block; if the block is NULL | |
126 | use the selected frame. */ | |
127 | OP (OP_VAR_VALUE) | |
128 | ||
36b11add JK |
129 | /* OP_VAR_ENTRY_VALUE takes one struct symbol * in the following element, |
130 | followed by another OP_VAR_ENTRY_VALUE, making three exp_elements. | |
131 | somename@entry may mean parameter value as present at the entry of the | |
216f72a1 | 132 | current function. Implemented via DW_OP_entry_value. */ |
36b11add JK |
133 | OP (OP_VAR_ENTRY_VALUE) |
134 | ||
74ea4be4 PA |
135 | /* OP_VAR_MSYM_VALUE takes one struct objfile * in the following |
136 | element, and one struct minimal_symbol * in the following | |
137 | exp_element, followed by another OP_VAR_MSYM_VALUE, making four | |
138 | exp_elements. */ | |
139 | OP (OP_VAR_MSYM_VALUE) | |
140 | ||
56c12414 JK |
141 | /* OP_LAST is followed by an integer in the next exp_element. |
142 | The integer is zero for the last value printed, | |
143 | or it is the absolute number of a history element. | |
144 | With another OP_LAST at the end, this makes three exp_elements. */ | |
145 | OP (OP_LAST) | |
146 | ||
147 | /* OP_REGISTER is followed by a string in the next exp_element. | |
148 | This is the name of a register to fetch. */ | |
149 | OP (OP_REGISTER) | |
150 | ||
151 | /* OP_INTERNALVAR is followed by an internalvar ptr in the next | |
152 | exp_element. With another OP_INTERNALVAR at the end, this | |
153 | makes three exp_elements. */ | |
154 | OP (OP_INTERNALVAR) | |
155 | ||
156 | /* OP_FUNCALL is followed by an integer in the next exp_element. | |
157 | The integer is the number of args to the function call. | |
158 | That many plus one values from following subexpressions | |
159 | are used, the first one being the function. | |
160 | The integer is followed by a repeat of OP_FUNCALL, | |
161 | making three exp_elements. */ | |
162 | OP (OP_FUNCALL) | |
163 | ||
164 | /* OP_OBJC_MSGCALL is followed by a string in the next exp_element | |
165 | and then an integer. The string is the selector string. The | |
166 | integer is the number of arguments to the message call. That | |
167 | many plus one values are used, the first one being the object | |
168 | pointer. This is an Objective C message. */ | |
169 | OP (OP_OBJC_MSGCALL) | |
170 | ||
171 | /* This is EXACTLY like OP_FUNCALL but is semantically different. | |
172 | In F77, array subscript expressions, substring expressions and | |
173 | function calls are all exactly the same syntactically. They | |
174 | may only be disambiguated at runtime. Thus this operator, | |
175 | which indicates that we have found something of the form | |
176 | <name> ( <stuff> ). */ | |
177 | OP (OP_F77_UNDETERMINED_ARGLIST) | |
178 | ||
179 | /* OP_COMPLEX takes a type in the following element, followed by another | |
180 | OP_COMPLEX, making three exp_elements. It is followed by two double | |
181 | args, and converts them into a complex number of the given type. */ | |
182 | OP (OP_COMPLEX) | |
183 | ||
184 | /* OP_STRING represents a string constant. | |
185 | Its format is the same as that of a STRUCTOP, but the string | |
186 | data is just made into a string constant when the operation | |
187 | is executed. */ | |
188 | OP (OP_STRING) | |
189 | ||
56c12414 JK |
190 | /* OP_ARRAY creates an array constant out of the following subexpressions. |
191 | It is followed by two exp_elements, the first containing an integer | |
192 | that is the lower bound of the array and the second containing another | |
193 | integer that is the upper bound of the array. The second integer is | |
194 | followed by a repeat of OP_ARRAY, making four exp_elements total. | |
195 | The bounds are used to compute the number of following subexpressions | |
196 | to consume, as well as setting the bounds in the created array constant. | |
197 | The type of the elements is taken from the type of the first subexp, | |
198 | and they must all match. */ | |
199 | OP (OP_ARRAY) | |
200 | ||
201 | /* UNOP_CAST is followed by a type pointer in the next exp_element. | |
202 | With another UNOP_CAST at the end, this makes three exp_elements. | |
203 | It casts the value of the following subexpression. */ | |
204 | OP (UNOP_CAST) | |
205 | ||
9eaf6705 TT |
206 | /* Like UNOP_CAST, but the type is a subexpression. */ |
207 | OP (UNOP_CAST_TYPE) | |
208 | ||
56c12414 JK |
209 | /* The C++ dynamic_cast operator. */ |
210 | OP (UNOP_DYNAMIC_CAST) | |
211 | ||
212 | /* The C++ reinterpret_cast operator. */ | |
213 | OP (UNOP_REINTERPRET_CAST) | |
214 | ||
215 | /* UNOP_MEMVAL is followed by a type pointer in the next exp_element | |
216 | With another UNOP_MEMVAL at the end, this makes three exp_elements. | |
217 | It casts the contents of the word addressed by the value of the | |
218 | following subexpression. */ | |
219 | OP (UNOP_MEMVAL) | |
220 | ||
9eaf6705 TT |
221 | /* Like UNOP_MEMVAL, but the type is supplied as a subexpression. */ |
222 | OP (UNOP_MEMVAL_TYPE) | |
223 | ||
56c12414 JK |
224 | /* UNOP_... operate on one value from a following subexpression |
225 | and replace it with a result. They take no immediate arguments. */ | |
226 | ||
227 | OP (UNOP_NEG) /* Unary - */ | |
228 | OP (UNOP_LOGICAL_NOT) /* Unary ! */ | |
229 | OP (UNOP_COMPLEMENT) /* Unary ~ */ | |
230 | OP (UNOP_IND) /* Unary * */ | |
231 | OP (UNOP_ADDR) /* Unary & */ | |
232 | OP (UNOP_PREINCREMENT) /* ++ before an expression */ | |
233 | OP (UNOP_POSTINCREMENT) /* ++ after an expression */ | |
234 | OP (UNOP_PREDECREMENT) /* -- before an expression */ | |
235 | OP (UNOP_POSTDECREMENT) /* -- after an expression */ | |
236 | OP (UNOP_SIZEOF) /* Unary sizeof (followed by expression) */ | |
007e1530 | 237 | OP (UNOP_ALIGNOF) /* Unary alignof (followed by expression) */ |
56c12414 JK |
238 | |
239 | OP (UNOP_PLUS) /* Unary plus */ | |
240 | ||
241 | OP (UNOP_CAP) /* Modula-2 standard (unary) procedures */ | |
242 | OP (UNOP_CHR) | |
243 | OP (UNOP_ORD) | |
244 | OP (UNOP_ABS) | |
245 | OP (UNOP_FLOAT) | |
246 | OP (UNOP_HIGH) | |
247 | OP (UNOP_MAX) | |
248 | OP (UNOP_MIN) | |
249 | OP (UNOP_ODD) | |
250 | OP (UNOP_TRUNC) | |
251 | ||
252 | OP (OP_BOOL) /* Modula-2 builtin BOOLEAN type */ | |
253 | OP (OP_M2_STRING) /* Modula-2 string constants */ | |
254 | ||
255 | /* STRUCTOP_... operate on a value from a following subexpression | |
256 | by extracting a structure component specified by a string | |
257 | that appears in the following exp_elements (as many as needed). | |
258 | STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->". | |
259 | They differ only in the error message given in case the value is | |
260 | not suitable or the structure component specified is not found. | |
261 | ||
262 | The length of the string follows the opcode, followed by | |
263 | BYTES_TO_EXP_ELEM(length) elements containing the data of the | |
264 | string, followed by the length again and the opcode again. */ | |
265 | ||
266 | OP (STRUCTOP_STRUCT) | |
267 | OP (STRUCTOP_PTR) | |
268 | ||
c44af4eb TT |
269 | /* Anonymous field access, e.g. "foo.3". Used in Rust. */ |
270 | OP (STRUCTOP_ANONYMOUS) | |
271 | ||
56c12414 JK |
272 | /* C++: OP_THIS is just a placeholder for the class instance variable. |
273 | It just comes in a tight (OP_THIS, OP_THIS) pair. */ | |
274 | OP (OP_THIS) | |
275 | ||
56c12414 JK |
276 | /* Objective C: "@selector" pseudo-operator. */ |
277 | OP (OP_OBJC_SELECTOR) | |
278 | ||
279 | /* OP_SCOPE surrounds a type name and a field name. The type | |
280 | name is encoded as one element, but the field name stays as | |
281 | a string, which, of course, is variable length. */ | |
282 | OP (OP_SCOPE) | |
283 | ||
858be34c PA |
284 | /* OP_FUNC_STATIC_VAR refers to a function local static variable. The |
285 | function is taken from the following subexpression. The length of | |
286 | the variable name as a string follows the opcode, followed by | |
287 | BYTES_TO_EXP_ELEM(length) elements containing the data of the | |
288 | string, followed by the length again and the opcode again. | |
289 | ||
290 | Note this is used by C++, but not C. The C parser handles local | |
291 | static variables in the parser directly. Also, this is only used | |
292 | in C++ if the function/method name is not quoted, like e.g.: | |
293 | ||
294 | p S:method()::var | |
295 | p S:method() const::var | |
296 | ||
297 | If the function/method is quoted like instead: | |
298 | ||
299 | p 'S:method() const'::var | |
300 | ||
301 | then the C-specific handling directly in the parser takes over (see | |
6fdcd7cc | 302 | block/variable productions). |
e68cb8e0 PA |
303 | |
304 | Also, if the whole function+var is quoted like this: | |
305 | ||
306 | p 'S:method() const::var' | |
307 | ||
308 | then the whole quoted expression is interpreted as a single symbol | |
309 | name and we don't use OP_FUNC_STATIC_VAR either. In that case, the | |
310 | C++-specific symbol lookup routines take care of the | |
311 | function-local-static search. */ | |
858be34c PA |
312 | OP (OP_FUNC_STATIC_VAR) |
313 | ||
56c12414 JK |
314 | /* OP_TYPE is for parsing types, and used with the "ptype" command |
315 | so we can look up types that are qualified by scope, either with | |
316 | the GDB "::" operator, or the Modula-2 '.' operator. */ | |
317 | OP (OP_TYPE) | |
318 | ||
319 | /* An un-looked-up identifier. */ | |
320 | OP (OP_NAME) | |
321 | ||
322 | /* An Objective C Foundation Class NSString constant. */ | |
323 | OP (OP_OBJC_NSSTRING) | |
324 | ||
01739a3b TT |
325 | /* An array range operator (in Fortran 90, for "exp:exp", "exp:", |
326 | ":exp" and ":"). */ | |
327 | OP (OP_RANGE) | |
56c12414 | 328 | |
56c12414 JK |
329 | /* OP_ADL_FUNC specifies that the function is to be looked up in an |
330 | Argument Dependent manner (Koenig lookup). */ | |
331 | OP (OP_ADL_FUNC) | |
608b4967 TT |
332 | |
333 | /* The typeof operator. This has one expression argument, which is | |
334 | evaluated solely for its type. */ | |
335 | OP (OP_TYPEOF) | |
336 | ||
337 | /* The decltype operator. This has one expression argument, which is | |
338 | evaluated solely for its type. This is similar to typeof, but has | |
339 | slight different semantics. */ | |
340 | OP (OP_DECLTYPE) | |
6e72ca20 TT |
341 | |
342 | /* The typeid operator. This has one expression argument. */ | |
343 | OP (OP_TYPEID) | |
c44af4eb TT |
344 | |
345 | /* This is used for the Rust [expr; N] form of array construction. It | |
346 | takes two expression arguments. */ | |
347 | OP (OP_RUST_ARRAY) |