]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/ax-gdb.h
import gdb-19990422 snapshot
[thirdparty/binutils-gdb.git] / gdb / ax-gdb.h
CommitLineData
c906108c
SS
1/* GDB-specific functions for operating on agent expressions
2 Copyright 1998 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
c906108c
SS
20#ifndef AX_GDB_H
21#define AX_GDB_H
22
23\f
24/* Types and enums */
25
26/* GDB stores expressions in the form of a flattened tree (struct
27 expression), so we just walk that tree and generate agent bytecodes
28 as we go along.
29
30 GDB's normal evaluation uses struct value, which contains the
31 expression's value as well as its address or the register it came
32 from. The `+' operator uses the value, whereas the unary `&'
33 operator will use the address portion. The `=' operator will use
34 the address or register number of its left hand side.
35
36 The issues are different when generating agent bytecode. Given a
37 variable reference expression, we should not necessarily generate
38 code to fetch its value, because the next operator may be `=' or
39 unary `&'. Instead, when we recurse on a subexpression, we
40 indicate whether we want that expression to produce an lvalue or an
41 rvalue. If we requested an lvalue, then the recursive call tells
42 us whether it generated code to compute an address on the stack, or
43 whether the lvalue lives in a register.
44
45 The `axs' prefix here means `agent expression, static', because
46 this is all static analysis of the expression, i.e. analysis which
47 doesn't depend on the contents of memory and registers. */
48
49
50/* Different kinds of agent expression static values. */
51enum axs_lvalue_kind {
52 /* We generated code to compute the subexpression's value.
53 Constants and arithmetic operators yield this. */
54 axs_rvalue,
55
56 /* We generated code to yield the subexpression's value's address on
57 the top of the stack. If the caller needs an rvalue, it should
58 call require_rvalue to produce the rvalue from this address. */
59 axs_lvalue_memory,
60
61 /* We didn't generate any code, and the stack is undisturbed,
62 because the subexpression's value lives in a register; u.reg is
63 the register number. If the caller needs an rvalue, it should
64 call require_rvalue to produce the rvalue from this register
65 number. */
66 axs_lvalue_register
67};
68
69/* Structure describing what we got from a subexpression. Think of
70 this as parallel to value.h's enum lval_type, except that we're
71 describing a value which will exist when the expression is
72 evaluated in the future, not a value we have in our hand. */
73struct axs_value {
74 enum axs_lvalue_kind kind; /* see above */
75
76 /* The type of the subexpression. Even if lvalue == axs_lvalue_memory,
77 this is the type of the value itself; the value on the stack is a
78 "pointer to" an object of this type. */
79 struct type *type;
80
81 union {
82 /* if kind == axs_lvalue_register, this is the register number */
83 int reg;
84 } u;
85};
86
87\f
88/* Translating GDB expressions into agent expressions. */
89
90/* Given a GDB expression EXPR, translate it into the agent bytecode,
91 and return it. FLAGS are from enum expr_to_agent_flags. */
92extern struct agent_expr *expr_to_agent PARAMS ((struct expression *EXPR,
93 struct axs_value *VALUE));
94
95/* Given a GDB expression EXPR denoting an lvalue in memory, produce a
96 string of agent bytecode which will leave its address and size on
97 the top of stack. Return the agent expression. */
98extern struct agent_expr *expr_to_address_and_size
99 PARAMS ((struct expression *EXPR));
100
101/* Given a GDB expression EXPR, return bytecode to trace its value.
102 The result will use the `trace' and `trace_quick' bytecodes to
103 record the value of all memory touched by the expression, and leave
104 no values on the stack. The caller can then use the ax_reqs
105 function to discover which registers the expression uses. */
106extern struct agent_expr *gen_trace_for_expr PARAMS ((CORE_ADDR,
107 struct expression *));
108
109#endif /* AX_GDB_H */