GDB (API)
|
00001 /* GDB-specific functions for operating on agent expressions 00002 Copyright (C) 1998-2013 Free Software Foundation, Inc. 00003 00004 This file is part of GDB. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00018 00019 #ifndef AX_GDB_H 00020 #define AX_GDB_H 00021 00022 struct expression; 00023 union exp_element; 00024 00025 /* Types and enums */ 00026 00027 /* GDB stores expressions in the form of a flattened tree (struct 00028 expression), so we just walk that tree and generate agent bytecodes 00029 as we go along. 00030 00031 GDB's normal evaluation uses struct value, which contains the 00032 expression's value as well as its address or the register it came 00033 from. The `+' operator uses the value, whereas the unary `&' 00034 operator will use the address portion. The `=' operator will use 00035 the address or register number of its left hand side. 00036 00037 The issues are different when generating agent bytecode. Given a 00038 variable reference expression, we should not necessarily generate 00039 code to fetch its value, because the next operator may be `=' or 00040 unary `&'. Instead, when we recurse on a subexpression, we 00041 indicate whether we want that expression to produce an lvalue or an 00042 rvalue. If we requested an lvalue, then the recursive call tells 00043 us whether it generated code to compute an address on the stack, or 00044 whether the lvalue lives in a register. 00045 00046 The `axs' prefix here means `agent expression, static', because 00047 this is all static analysis of the expression, i.e. analysis which 00048 doesn't depend on the contents of memory and registers. */ 00049 00050 00051 /* Different kinds of agent expression static values. */ 00052 enum axs_lvalue_kind 00053 { 00054 /* We generated code to compute the subexpression's value. 00055 Constants and arithmetic operators yield this. */ 00056 axs_rvalue, 00057 00058 /* We generated code to yield the subexpression's value's address on 00059 the top of the stack. If the caller needs an rvalue, it should 00060 call require_rvalue to produce the rvalue from this address. */ 00061 axs_lvalue_memory, 00062 00063 /* We didn't generate any code, and the stack is undisturbed, 00064 because the subexpression's value lives in a register; u.reg is 00065 the register number. If the caller needs an rvalue, it should 00066 call require_rvalue to produce the rvalue from this register 00067 number. */ 00068 axs_lvalue_register 00069 }; 00070 00071 /* Structure describing what we got from a subexpression. Think of 00072 this as parallel to value.h's enum lval_type, except that we're 00073 describing a value which will exist when the expression is 00074 evaluated in the future, not a value we have in our hand. */ 00075 struct axs_value 00076 { 00077 enum axs_lvalue_kind kind; /* see above */ 00078 00079 /* The type of the subexpression. Even if lvalue == axs_lvalue_memory, 00080 this is the type of the value itself; the value on the stack is a 00081 "pointer to" an object of this type. */ 00082 struct type *type; 00083 00084 /* If nonzero, this is a variable which does not actually exist in 00085 the program. */ 00086 char optimized_out; 00087 00088 union 00089 { 00090 /* if kind == axs_lvalue_register, this is the register number */ 00091 int reg; 00092 } 00093 u; 00094 }; 00095 00096 00097 /* Translating GDB expressions into agent expressions. */ 00098 00099 /* Given a GDB expression EXPR, return bytecode to trace its value. 00100 The result will use the `trace' and `trace_quick' bytecodes to 00101 record the value of all memory touched by the expression, and leave 00102 no values on the stack. The caller can then use the ax_reqs 00103 function to discover which registers the expression uses. */ 00104 extern struct agent_expr *gen_trace_for_expr (CORE_ADDR, struct expression *, 00105 int); 00106 00107 extern struct agent_expr *gen_trace_for_var (CORE_ADDR, struct gdbarch *, 00108 struct symbol *, int); 00109 00110 extern struct agent_expr *gen_trace_for_return_address (CORE_ADDR, 00111 struct gdbarch *, 00112 int); 00113 00114 extern struct agent_expr *gen_eval_for_expr (CORE_ADDR, struct expression *); 00115 00116 extern void gen_expr (struct expression *exp, union exp_element **pc, 00117 struct agent_expr *ax, struct axs_value *value); 00118 00119 extern void require_rvalue (struct agent_expr *ax, struct axs_value *value); 00120 00121 struct format_piece; 00122 extern struct agent_expr *gen_printf (CORE_ADDR, struct gdbarch *, 00123 CORE_ADDR, LONGEST, const char *, int, 00124 struct format_piece *, 00125 int, struct expression **); 00126 00127 #endif /* AX_GDB_H */