|
| 1 | +//===-- DWARFEvaluator.h ----------------------------------------*- C++ -*-===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +#ifndef LLDB_EXPRESSION_DWARFEVALUATOR_H |
| 10 | +#define LLDB_EXPRESSION_DWARFEVALUATOR_H |
| 11 | + |
| 12 | +#include "lldb/lldb-private.h" |
| 13 | +#include <vector> |
| 14 | + |
| 15 | +namespace lldb_private { |
| 16 | + |
| 17 | +class DWARFExpression; |
| 18 | + |
| 19 | +/// \class DWARFEvaluator DWARFEvaluator.h |
| 20 | +/// "lldb/Expression/DWARFEvaluator.h" Evaluates DWARF opcodes. |
| 21 | +/// |
| 22 | +class DWARFEvaluator { |
| 23 | +public: |
| 24 | + /// Crates a DWARF location expression evaluator |
| 25 | + /// |
| 26 | + /// \param[in] dwarf_expression |
| 27 | + /// The DWARF expression to evaluate. |
| 28 | + /// |
| 29 | + /// \param[in] exe_ctx |
| 30 | + /// The execution context in which to evaluate the location |
| 31 | + /// expression. The location expression may access the target's |
| 32 | + /// memory, especially if it comes from the expression parser. |
| 33 | + /// |
| 34 | + /// \param[in] reg_ctx |
| 35 | + /// An optional parameter which provides a RegisterContext for use |
| 36 | + /// when evaluating the expression (i.e. for fetching register values). |
| 37 | + /// Normally this will come from the ExecutionContext's StackFrame but |
| 38 | + /// in the case where an expression needs to be evaluated while building |
| 39 | + /// the stack frame list, this short-cut is available. |
| 40 | + /// |
| 41 | + /// \param[in] initial_value_ptr |
| 42 | + /// A value to put on top of the interpreter stack before evaluating |
| 43 | + /// the expression, if the expression is parametrized. Can be NULL. |
| 44 | + /// |
| 45 | + /// \param[in] object_address_ptr |
| 46 | + /// |
| 47 | + DWARFEvaluator(const DWARFExpression &dwarf_expression, |
| 48 | + ExecutionContext *exe_ctx, RegisterContext *reg_ctx, |
| 49 | + const Value *initial_value_ptr, |
| 50 | + const Value *object_address_ptr); |
| 51 | + |
| 52 | + /// DWARFEvaluator protocol. |
| 53 | + /// \{ |
| 54 | + |
| 55 | + /// Evaluate the DWARF location expression |
| 56 | + /// |
| 57 | + /// \param[in] result |
| 58 | + /// A value into which the result of evaluating the expression is |
| 59 | + /// to be placed. |
| 60 | + /// |
| 61 | + /// \param[in] error_ptr |
| 62 | + /// If non-NULL, used to report errors in expression evaluation. |
| 63 | + /// |
| 64 | + /// \return |
| 65 | + /// True on success; false otherwise. If error_ptr is non-NULL, |
| 66 | + /// details of the failure are provided through it. |
| 67 | + virtual bool Evaluate(Value &result, Status *error_ptr); |
| 68 | + |
| 69 | + /// Evaluate the DWARF location expression with the opcodes specified. |
| 70 | + /// |
| 71 | + /// \param[in] opcodes |
| 72 | + /// The DWARF opcodes to evaluate. |
| 73 | + /// |
| 74 | + /// \param[in] result |
| 75 | + /// A value into which the result of evaluating the expression is |
| 76 | + /// to be placed. |
| 77 | + /// |
| 78 | + /// \param[in] error_ptr |
| 79 | + /// If non-NULL, used to report errors in expression evaluation. |
| 80 | + /// |
| 81 | + /// \return |
| 82 | + /// True on success; false otherwise. If error_ptr is non-NULL, |
| 83 | + /// details of the failure are provided through it. |
| 84 | + virtual bool Evaluate(const DataExtractor &opcodes, Value &result, |
| 85 | + Status *error_ptr); |
| 86 | + |
| 87 | + /// Evaluates a specific DWARF opcode in the context of a DWARF expression |
| 88 | + virtual bool Evaluate(const uint8_t op, Process *process, StackFrame *frame, |
| 89 | + std::vector<Value> &stack, const DataExtractor &opcodes, |
| 90 | + lldb::offset_t &offset, Value &pieces, |
| 91 | + uint64_t &op_piece_offset, Log *log, Status *error_ptr); |
| 92 | + |
| 93 | + /// \} |
| 94 | + |
| 95 | +protected: |
| 96 | + const DWARFExpression &m_dwarf_expression; |
| 97 | + ExecutionContext *m_exe_ctx; |
| 98 | + RegisterContext *m_reg_ctx; |
| 99 | + const Value *m_initial_value_ptr; |
| 100 | + const Value *m_object_address_ptr; |
| 101 | + |
| 102 | +private: |
| 103 | + DWARFEvaluator(const DWARFEvaluator &); |
| 104 | + const DWARFEvaluator &operator=(const DWARFEvaluator &) = delete; |
| 105 | + |
| 106 | +}; |
| 107 | + |
| 108 | +} // namespace lldb_private |
| 109 | + |
| 110 | +#endif // LLDB_EXPRESSION_DWARFEVALUATOR_H |
0 commit comments