GDB (xrefs)
/tmp/gdb-8.1/gdb/ax-gdb.h
Go to the documentation of this file.
1 /* GDB-specific functions for operating on agent expressions
2  Copyright (C) 1998-2018 Free Software Foundation, Inc.
3 
4  This file is part of GDB.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 
19 #ifndef AX_GDB_H
20 #define AX_GDB_H
21 
22 #include "ax.h" /* For agent_expr_up. */
23 
24 struct expression;
25 union exp_element;
26 
27 /* Types and enums */
28 
29 /* GDB stores expressions in the form of a flattened tree (struct
30  expression), so we just walk that tree and generate agent bytecodes
31  as we go along.
32 
33  GDB's normal evaluation uses struct value, which contains the
34  expression's value as well as its address or the register it came
35  from. The `+' operator uses the value, whereas the unary `&'
36  operator will use the address portion. The `=' operator will use
37  the address or register number of its left hand side.
38 
39  The issues are different when generating agent bytecode. Given a
40  variable reference expression, we should not necessarily generate
41  code to fetch its value, because the next operator may be `=' or
42  unary `&'. Instead, when we recurse on a subexpression, we
43  indicate whether we want that expression to produce an lvalue or an
44  rvalue. If we requested an lvalue, then the recursive call tells
45  us whether it generated code to compute an address on the stack, or
46  whether the lvalue lives in a register.
47 
48  The `axs' prefix here means `agent expression, static', because
49  this is all static analysis of the expression, i.e. analysis which
50  doesn't depend on the contents of memory and registers. */
51 
52 
53 /* Different kinds of agent expression static values. */
55  {
56  /* We generated code to compute the subexpression's value.
57  Constants and arithmetic operators yield this. */
59 
60  /* We generated code to yield the subexpression's value's address on
61  the top of the stack. If the caller needs an rvalue, it should
62  call require_rvalue to produce the rvalue from this address. */
64 
65  /* We didn't generate any code, and the stack is undisturbed,
66  because the subexpression's value lives in a register; u.reg is
67  the register number. If the caller needs an rvalue, it should
68  call require_rvalue to produce the rvalue from this register
69  number. */
71  };
72 
73 /* Structure describing what we got from a subexpression. Think of
74  this as parallel to value.h's enum lval_type, except that we're
75  describing a value which will exist when the expression is
76  evaluated in the future, not a value we have in our hand. */
77 struct axs_value
78  {
79  enum axs_lvalue_kind kind; /* see above */
80 
81  /* The type of the subexpression. Even if lvalue == axs_lvalue_memory,
82  this is the type of the value itself; the value on the stack is a
83  "pointer to" an object of this type. */
84  struct type *type;
85 
86  /* If nonzero, this is a variable which does not actually exist in
87  the program. */
89 
90  union
91  {
92  /* if kind == axs_lvalue_register, this is the register number */
93  int reg;
94  }
95  u;
96  };
97 
98 
99 /* Translating GDB expressions into agent expressions. */
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. */
107  int);
108 
110  struct symbol *, int);
111 
113  struct gdbarch *,
114  int);
115 
117 
118 extern void gen_expr (struct expression *exp, union exp_element **pc,
119  struct agent_expr *ax, struct axs_value *value);
120 
121 extern void require_rvalue (struct agent_expr *ax, struct axs_value *value);
122 
123 extern agent_expr_up gen_printf (CORE_ADDR, struct gdbarch *,
124  CORE_ADDR, LONGEST, const char *, int,
125  int, struct expression **);
126 
127 #endif /* AX_GDB_H */
std::unique_ptr< agent_expr > agent_expr_up
Definition: ax.h:159
bfd_vma CORE_ADDR
Definition: common-types.h:41
void gen_expr(struct expression *exp, union exp_element **pc, struct agent_expr *ax, struct axs_value *value)
Definition: ax-gdb.c:1806
Definition: ax.h:83
axs_lvalue_kind
Definition: ax-gdb.h:54
struct type * type
Definition: ax-gdb.h:84
agent_expr_up gen_trace_for_var(CORE_ADDR, struct gdbarch *, struct symbol *, int)
Definition: ax-gdb.c:2433
char optimized_out
Definition: ax-gdb.h:88
agent_expr_up gen_trace_for_return_address(CORE_ADDR, struct gdbarch *, int)
Definition: ax-gdb.c:2516
int reg
Definition: ax-gdb.h:93
Definition: gdbtypes.h:749
agent_expr_up gen_printf(CORE_ADDR, struct gdbarch *, CORE_ADDR, LONGEST, const char *, int, int, struct expression **)
Definition: ax-gdb.c:2541
void require_rvalue(struct agent_expr *ax, struct axs_value *value)
Definition: ax-gdb.c:773
Definition: value.c:169
union axs_value::@13 u
agent_expr_up gen_eval_for_expr(CORE_ADDR, struct expression *)
Definition: ax-gdb.c:2496
enum axs_lvalue_kind kind
Definition: ax-gdb.h:79
long long LONGEST
Definition: common-types.h:52
agent_expr_up gen_trace_for_expr(CORE_ADDR, struct expression *, int)
Definition: ax-gdb.c:2466