std-operator.def 14 KB

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