gdb/ax-gdb.h - gdb

Data types defined

Macros defined

Source code

  1. /* GDB-specific functions for operating on agent expressions
  2.    Copyright (C) 1998-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef AX_GDB_H
  15. #define AX_GDB_H

  16. struct expression;
  17. union exp_element;

  18. /* Types and enums */

  19. /* GDB stores expressions in the form of a flattened tree (struct
  20.    expression), so we just walk that tree and generate agent bytecodes
  21.    as we go along.

  22.    GDB's normal evaluation uses struct value, which contains the
  23.    expression's value as well as its address or the register it came
  24.    from.  The `+' operator uses the value, whereas the unary `&'
  25.    operator will use the address portion.  The `=' operator will use
  26.    the address or register number of its left hand side.

  27.    The issues are different when generating agent bytecode.  Given a
  28.    variable reference expression, we should not necessarily generate
  29.    code to fetch its value, because the next operator may be `=' or
  30.    unary `&'.  Instead, when we recurse on a subexpression, we
  31.    indicate whether we want that expression to produce an lvalue or an
  32.    rvalue.  If we requested an lvalue, then the recursive call tells
  33.    us whether it generated code to compute an address on the stack, or
  34.    whether the lvalue lives in a register.

  35.    The `axs' prefix here means `agent expression, static', because
  36.    this is all static analysis of the expression, i.e. analysis which
  37.    doesn't depend on the contents of memory and registers.  */


  38. /* Different kinds of agent expression static values.  */
  39. enum axs_lvalue_kind
  40.   {
  41.     /* We generated code to compute the subexpression's value.
  42.        Constants and arithmetic operators yield this.  */
  43.     axs_rvalue,

  44.     /* We generated code to yield the subexpression's value's address on
  45.        the top of the stack.  If the caller needs an rvalue, it should
  46.        call require_rvalue to produce the rvalue from this address.  */
  47.     axs_lvalue_memory,

  48.     /* We didn't generate any code, and the stack is undisturbed,
  49.        because the subexpression's value lives in a register; u.reg is
  50.        the register number.  If the caller needs an rvalue, it should
  51.        call require_rvalue to produce the rvalue from this register
  52.        number.  */
  53.     axs_lvalue_register
  54.   };

  55. /* Structure describing what we got from a subexpression.  Think of
  56.    this as parallel to value.h's enum lval_type, except that we're
  57.    describing a value which will exist when the expression is
  58.    evaluated in the future, not a value we have in our hand.  */
  59. struct axs_value
  60.   {
  61.     enum axs_lvalue_kind kind;        /* see above */

  62.     /* The type of the subexpression.  Even if lvalue == axs_lvalue_memory,
  63.        this is the type of the value itself; the value on the stack is a
  64.        "pointer to" an object of this type.  */
  65.     struct type *type;

  66.     /* If nonzero, this is a variable which does not actually exist in
  67.        the program.  */
  68.     char optimized_out;

  69.     union
  70.       {
  71.         /* if kind == axs_lvalue_register, this is the register number */
  72.         int reg;
  73.       }
  74.     u;
  75.   };


  76. /* Translating GDB expressions into agent expressions.  */

  77. /* Given a GDB expression EXPR, return bytecode to trace its value.
  78.    The result will use the `trace' and `trace_quick' bytecodes to
  79.    record the value of all memory touched by the expression, and leave
  80.    no values on the stack.  The caller can then use the ax_reqs
  81.    function to discover which registers the expression uses.  */
  82. extern struct agent_expr *gen_trace_for_expr (CORE_ADDR, struct expression *,
  83.                                               int);

  84. extern struct agent_expr *gen_trace_for_var (CORE_ADDR, struct gdbarch *,
  85.                                              struct symbol *, int);

  86. extern struct agent_expr *gen_trace_for_return_address (CORE_ADDR,
  87.                                                         struct gdbarch *,
  88.                                                         int);

  89. extern struct agent_expr *gen_eval_for_expr (CORE_ADDR, struct expression *);

  90. extern void gen_expr (struct expression *exp, union exp_element **pc,
  91.                       struct agent_expr *ax, struct axs_value *value);

  92. extern void require_rvalue (struct agent_expr *ax, struct axs_value *value);

  93. struct format_piece;
  94. extern struct agent_expr *gen_printf (CORE_ADDR, struct gdbarch *,
  95.                                       CORE_ADDR, LONGEST, const char *, int,
  96.                                       struct format_piece *,
  97.                                       int, struct expression **);

  98. #endif /* AX_GDB_H */