Commit | Line | Data |
---|---|---|
c906108c | 1 | /* GDB-specific functions for operating on agent expressions |
4c38e0a4 | 2 | Copyright (C) 1998, 1999, 2000, 2007, 2008, 2009, 2010 |
0fb0cc75 | 3 | Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
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 | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 10 | (at your option) any later version. |
c906108c | 11 | |
c5aa993b JM |
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. | |
c906108c | 16 | |
c5aa993b | 17 | You should have received a copy of the GNU General Public License |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 19 | |
c906108c SS |
20 | #ifndef AX_GDB_H |
21 | #define AX_GDB_H | |
da3331ec AC |
22 | |
23 | struct expression; | |
c5aa993b | 24 | |
c906108c SS |
25 | /* Types and enums */ |
26 | ||
27 | /* GDB stores expressions in the form of a flattened tree (struct | |
28 | expression), so we just walk that tree and generate agent bytecodes | |
29 | as we go along. | |
30 | ||
31 | GDB's normal evaluation uses struct value, which contains the | |
32 | expression's value as well as its address or the register it came | |
33 | from. The `+' operator uses the value, whereas the unary `&' | |
34 | operator will use the address portion. The `=' operator will use | |
35 | the address or register number of its left hand side. | |
36 | ||
37 | The issues are different when generating agent bytecode. Given a | |
38 | variable reference expression, we should not necessarily generate | |
39 | code to fetch its value, because the next operator may be `=' or | |
40 | unary `&'. Instead, when we recurse on a subexpression, we | |
41 | indicate whether we want that expression to produce an lvalue or an | |
42 | rvalue. If we requested an lvalue, then the recursive call tells | |
43 | us whether it generated code to compute an address on the stack, or | |
44 | whether the lvalue lives in a register. | |
45 | ||
46 | The `axs' prefix here means `agent expression, static', because | |
47 | this is all static analysis of the expression, i.e. analysis which | |
48 | doesn't depend on the contents of memory and registers. */ | |
49 | ||
50 | ||
51 | /* Different kinds of agent expression static values. */ | |
c5aa993b JM |
52 | enum axs_lvalue_kind |
53 | { | |
54 | /* We generated code to compute the subexpression's value. | |
55 | Constants and arithmetic operators yield this. */ | |
56 | axs_rvalue, | |
57 | ||
58 | /* We generated code to yield the subexpression's value's address on | |
59 | the top of the stack. If the caller needs an rvalue, it should | |
60 | call require_rvalue to produce the rvalue from this address. */ | |
61 | axs_lvalue_memory, | |
62 | ||
63 | /* We didn't generate any code, and the stack is undisturbed, | |
64 | because the subexpression's value lives in a register; u.reg is | |
65 | the register number. If the caller needs an rvalue, it should | |
66 | call require_rvalue to produce the rvalue from this register | |
67 | number. */ | |
68 | axs_lvalue_register | |
69 | }; | |
c906108c SS |
70 | |
71 | /* Structure describing what we got from a subexpression. Think of | |
72 | this as parallel to value.h's enum lval_type, except that we're | |
73 | describing a value which will exist when the expression is | |
74 | evaluated in the future, not a value we have in our hand. */ | |
c5aa993b JM |
75 | struct axs_value |
76 | { | |
77 | enum axs_lvalue_kind kind; /* see above */ | |
78 | ||
79 | /* The type of the subexpression. Even if lvalue == axs_lvalue_memory, | |
80 | this is the type of the value itself; the value on the stack is a | |
81 | "pointer to" an object of this type. */ | |
82 | struct type *type; | |
83 | ||
400c6af0 SS |
84 | /* If nonzero, this is a variable which does not actually exist in |
85 | the program. */ | |
86 | char optimized_out; | |
87 | ||
c5aa993b JM |
88 | union |
89 | { | |
90 | /* if kind == axs_lvalue_register, this is the register number */ | |
91 | int reg; | |
92 | } | |
93 | u; | |
94 | }; | |
c906108c | 95 | \f |
c5aa993b | 96 | |
c906108c SS |
97 | /* Translating GDB expressions into agent expressions. */ |
98 | ||
c906108c SS |
99 | /* Given a GDB expression EXPR, return bytecode to trace its value. |
100 | The result will use the `trace' and `trace_quick' bytecodes to | |
101 | record the value of all memory touched by the expression, and leave | |
102 | no values on the stack. The caller can then use the ax_reqs | |
103 | function to discover which registers the expression uses. */ | |
a14ed312 | 104 | extern struct agent_expr *gen_trace_for_expr (CORE_ADDR, struct expression *); |
c906108c | 105 | |
400c6af0 SS |
106 | extern struct agent_expr *gen_trace_for_var (CORE_ADDR, struct gdbarch *, |
107 | struct symbol *); | |
0936ad1d | 108 | |
782b2b07 SS |
109 | extern struct agent_expr *gen_eval_for_expr (CORE_ADDR, struct expression *); |
110 | ||
3cf03773 TT |
111 | extern int trace_kludge; |
112 | ||
c906108c | 113 | #endif /* AX_GDB_H */ |