GDB (API)
/home/stan/gdb/src/gdb/expression.h
Go to the documentation of this file.
00001 /* Definitions for expressions stored in reversed prefix form, for GDB.
00002 
00003    Copyright (C) 1986-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #if !defined (EXPRESSION_H)
00021 #define EXPRESSION_H 1
00022 
00023 
00024 #include "symtab.h"             /* Needed for "struct block" type.  */
00025 #include "doublest.h"           /* Needed for DOUBLEST.  */
00026 
00027 
00028 /* Definitions for saved C expressions.  */
00029 
00030 /* An expression is represented as a vector of union exp_element's.
00031    Each exp_element is an opcode, except that some opcodes cause
00032    the following exp_element to be treated as a long or double constant
00033    or as a variable.  The opcodes are obeyed, using a stack for temporaries.
00034    The value is left on the temporary stack at the end.  */
00035 
00036 /* When it is necessary to include a string,
00037    it can occupy as many exp_elements as it needs.
00038    We find the length of the string using strlen,
00039    divide to find out how many exp_elements are used up,
00040    and skip that many.  Strings, like numbers, are indicated
00041    by the preceding opcode.  */
00042 
00043 enum exp_opcode
00044   {
00045 #define OP(name) name ,
00046 
00047 #include "std-operator.def"
00048 
00049     /* First extension operator.  Individual language modules define extra
00050        operators in *.def include files below with numbers higher than
00051        OP_EXTENDED0.  */
00052     OP (OP_EXTENDED0)
00053 
00054 /* Language specific operators.  */
00055 #include "ada-operator.def"
00056 
00057 #undef OP
00058 
00059     /* Existing only to swallow the last comma (',') from last .inc file.  */
00060     OP_UNUSED_LAST
00061   };
00062 
00063 union exp_element
00064   {
00065     enum exp_opcode opcode;
00066     struct symbol *symbol;
00067     LONGEST longconst;
00068     DOUBLEST doubleconst;
00069     gdb_byte decfloatconst[16];
00070     /* Really sizeof (union exp_element) characters (or less for the last
00071        element of a string).  */
00072     char string;
00073     struct type *type;
00074     struct internalvar *internalvar;
00075     const struct block *block;
00076     struct objfile *objfile;
00077   };
00078 
00079 struct expression
00080   {
00081     const struct language_defn *language_defn;  /* language it was
00082                                                    entered in.  */
00083     struct gdbarch *gdbarch;  /* architecture it was parsed in.  */
00084     int nelts;
00085     union exp_element elts[1];
00086   };
00087 
00088 /* Macros for converting between number of expression elements and bytes
00089    to store that many expression elements.  */
00090 
00091 #define EXP_ELEM_TO_BYTES(elements) \
00092     ((elements) * sizeof (union exp_element))
00093 #define BYTES_TO_EXP_ELEM(bytes) \
00094     (((bytes) + sizeof (union exp_element) - 1) / sizeof (union exp_element))
00095 
00096 /* From parse.c */
00097 
00098 extern struct expression *parse_expression (const char *);
00099 
00100 extern struct type *parse_expression_for_completion (const char *, char **,
00101                                                      enum type_code *);
00102 
00103 extern struct expression *parse_exp_1 (const char **, CORE_ADDR pc,
00104                                        const struct block *, int);
00105 
00106 /* For use by parsers; set if we want to parse an expression and
00107    attempt completion.  */
00108 extern int parse_completion;
00109 
00110 /* The innermost context required by the stack and register variables
00111    we've encountered so far.  To use this, set it to NULL, then call
00112    parse_<whatever>, then look at it.  */
00113 extern const struct block *innermost_block;
00114 
00115 /* From eval.c */
00116 
00117 /* Values of NOSIDE argument to eval_subexp.  */
00118 
00119 enum noside
00120   {
00121     EVAL_NORMAL,
00122     EVAL_SKIP,                  /* Only effect is to increment pos.  */
00123     EVAL_AVOID_SIDE_EFFECTS     /* Don't modify any variables or
00124                                    call any functions.  The value
00125                                    returned will have the correct
00126                                    type, and will have an
00127                                    approximately correct lvalue
00128                                    type (inaccuracy: anything that is
00129                                    listed as being in a register in
00130                                    the function in which it was
00131                                    declared will be lval_register).
00132                                    Ideally this would not even read
00133                                    target memory, but currently it
00134                                    does in many situations.  */
00135   };
00136 
00137 extern struct value *evaluate_subexp_standard
00138   (struct type *, struct expression *, int *, enum noside);
00139 
00140 /* From expprint.c */
00141 
00142 extern void print_expression (struct expression *, struct ui_file *);
00143 
00144 extern char *op_name (struct expression *exp, enum exp_opcode opcode);
00145 
00146 extern char *op_string (enum exp_opcode);
00147 
00148 extern void dump_raw_expression (struct expression *,
00149                                  struct ui_file *, char *);
00150 extern void dump_prefix_expression (struct expression *, struct ui_file *);
00151 
00152 #endif /* !defined (EXPRESSION_H) */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines