gdb/expression.h - gdb

Data types defined

Macros defined

Source code

  1. /* Definitions for expressions stored in reversed prefix form, for GDB.

  2.    Copyright (C) 1986-2015 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. #if !defined (EXPRESSION_H)
  15. #define EXPRESSION_H 1


  16. #include "symtab.h"                /* Needed for "struct block" type.  */
  17. #include "doublest.h"                /* Needed for DOUBLEST.  */


  18. /* Definitions for saved C expressions.  */

  19. /* An expression is represented as a vector of union exp_element's.
  20.    Each exp_element is an opcode, except that some opcodes cause
  21.    the following exp_element to be treated as a long or double constant
  22.    or as a variable.  The opcodes are obeyed, using a stack for temporaries.
  23.    The value is left on the temporary stack at the end.  */

  24. /* When it is necessary to include a string,
  25.    it can occupy as many exp_elements as it needs.
  26.    We find the length of the string using strlen,
  27.    divide to find out how many exp_elements are used up,
  28.    and skip that many.  Strings, like numbers, are indicated
  29.    by the preceding opcode.  */

  30. enum exp_opcode
  31.   {
  32. #define OP(name) name ,

  33. #include "std-operator.def"

  34.     /* First extension operator.  Individual language modules define extra
  35.        operators in *.def include files below with numbers higher than
  36.        OP_EXTENDED0.  */
  37.     OP (OP_EXTENDED0)

  38. /* Language specific operators.  */
  39. #include "ada-operator.def"

  40. #undef OP

  41.     /* Existing only to swallow the last comma (',') from last .inc file.  */
  42.     OP_UNUSED_LAST
  43.   };

  44. union exp_element
  45.   {
  46.     enum exp_opcode opcode;
  47.     struct symbol *symbol;
  48.     LONGEST longconst;
  49.     DOUBLEST doubleconst;
  50.     gdb_byte decfloatconst[16];
  51.     /* Really sizeof (union exp_element) characters (or less for the last
  52.        element of a string).  */
  53.     char string;
  54.     struct type *type;
  55.     struct internalvar *internalvar;
  56.     const struct block *block;
  57.     struct objfile *objfile;
  58.   };

  59. struct expression
  60.   {
  61.     const struct language_defn *language_defn;        /* language it was
  62.                                                    entered in.  */
  63.     struct gdbarch *gdbarch/* architecture it was parsed in.  */
  64.     int nelts;
  65.     union exp_element elts[1];
  66.   };

  67. /* Macros for converting between number of expression elements and bytes
  68.    to store that many expression elements.  */

  69. #define EXP_ELEM_TO_BYTES(elements) \
  70.     ((elements) * sizeof (union exp_element))
  71. #define BYTES_TO_EXP_ELEM(bytes) \
  72.     (((bytes) + sizeof (union exp_element) - 1) / sizeof (union exp_element))

  73. /* From parse.c */

  74. extern struct expression *parse_expression (const char *);

  75. extern struct type *parse_expression_for_completion (const char *, char **,
  76.                                                      enum type_code *);

  77. extern struct expression *parse_exp_1 (const char **, CORE_ADDR pc,
  78.                                        const struct block *, int);

  79. /* For use by parsers; set if we want to parse an expression and
  80.    attempt completion.  */
  81. extern int parse_completion;

  82. /* The innermost context required by the stack and register variables
  83.    we've encountered so far.  To use this, set it to NULL, then call
  84.    parse_<whatever>, then look at it.  */
  85. extern const struct block *innermost_block;

  86. /* From eval.c */

  87. /* Values of NOSIDE argument to eval_subexp.  */

  88. enum noside
  89.   {
  90.     EVAL_NORMAL,
  91.     EVAL_SKIP,                        /* Only effect is to increment pos.  */
  92.     EVAL_AVOID_SIDE_EFFECTS        /* Don't modify any variables or
  93.                                    call any functions.  The value
  94.                                    returned will have the correct
  95.                                    type, and will have an
  96.                                    approximately correct lvalue
  97.                                    type (inaccuracy: anything that is
  98.                                    listed as being in a register in
  99.                                    the function in which it was
  100.                                    declared will be lval_register).
  101.                                    Ideally this would not even read
  102.                                    target memory, but currently it
  103.                                    does in many situations.  */
  104.   };

  105. extern struct value *evaluate_subexp_standard
  106.   (struct type *, struct expression *, int *, enum noside);

  107. /* From expprint.c */

  108. extern void print_expression (struct expression *, struct ui_file *);

  109. extern char *op_name (struct expression *exp, enum exp_opcode opcode);

  110. extern char *op_string (enum exp_opcode);

  111. extern void dump_raw_expression (struct expression *,
  112.                                  struct ui_file *, char *);
  113. extern void dump_prefix_expression (struct expression *, struct ui_file *);

  114. #endif /* !defined (EXPRESSION_H) */