|
| 1 | +//===----------------------------------------------------------------------===// |
| 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_TARGET_BORROWEDSTACKFRAME_H |
| 10 | +#define LLDB_TARGET_BORROWEDSTACKFRAME_H |
| 11 | + |
| 12 | +#include "lldb/Target/StackFrame.h" |
| 13 | + |
| 14 | +namespace lldb_private { |
| 15 | + |
| 16 | +/// \class BorrowedStackFrame BorrowedStackFrame.h |
| 17 | +/// "lldb/Target/BorrowedStackFrame.h" |
| 18 | +/// |
| 19 | +/// A wrapper around an existing StackFrame that supersedes its frame indices. |
| 20 | +/// |
| 21 | +/// This class is useful when you need to present an existing stack frame |
| 22 | +/// with a different index, such as when creating synthetic frame views or |
| 23 | +/// renumbering frames without copying all the underlying data. |
| 24 | +/// |
| 25 | +/// All methods delegate to the borrowed frame except for GetFrameIndex() |
| 26 | +/// & GetConcreteFrameIndex() which uses the overridden indices. |
| 27 | +class BorrowedStackFrame : public StackFrame { |
| 28 | +public: |
| 29 | + /// Construct a BorrowedStackFrame that wraps an existing frame. |
| 30 | + /// |
| 31 | + /// \param [in] borrowed_frame_sp |
| 32 | + /// The existing StackFrame to borrow from. This frame's data will be |
| 33 | + /// used for all operations except frame index queries. |
| 34 | + /// |
| 35 | + /// \param [in] new_frame_index |
| 36 | + /// The frame index to report instead of the borrowed frame's index. |
| 37 | + /// |
| 38 | + /// \param [in] new_concrete_frame_index |
| 39 | + /// Optional concrete frame index. If not provided, defaults to |
| 40 | + /// new_frame_index. |
| 41 | + BorrowedStackFrame( |
| 42 | + lldb::StackFrameSP borrowed_frame_sp, uint32_t new_frame_index, |
| 43 | + std::optional<uint32_t> new_concrete_frame_index = std::nullopt); |
| 44 | + |
| 45 | + ~BorrowedStackFrame() override = default; |
| 46 | + |
| 47 | + uint32_t GetFrameIndex() const override; |
| 48 | + void SetFrameIndex(uint32_t index); |
| 49 | + |
| 50 | + /// Get the concrete frame index for this borrowed frame. |
| 51 | + /// |
| 52 | + /// Returns the overridden concrete frame index provided at construction, |
| 53 | + /// or LLDB_INVALID_FRAME_ID if the borrowed frame represents an inlined |
| 54 | + /// function, since this would require some computation if we chain inlined |
| 55 | + /// borrowed stack frames. |
| 56 | + /// |
| 57 | + /// \return |
| 58 | + /// The concrete frame index, or LLDB_INVALID_FRAME_ID for inline frames. |
| 59 | + uint32_t GetConcreteFrameIndex() override; |
| 60 | + |
| 61 | + StackID &GetStackID() override; |
| 62 | + |
| 63 | + const Address &GetFrameCodeAddress() override; |
| 64 | + |
| 65 | + Address GetFrameCodeAddressForSymbolication() override; |
| 66 | + |
| 67 | + bool ChangePC(lldb::addr_t pc) override; |
| 68 | + |
| 69 | + const SymbolContext & |
| 70 | + GetSymbolContext(lldb::SymbolContextItem resolve_scope) override; |
| 71 | + |
| 72 | + llvm::Error GetFrameBaseValue(Scalar &value) override; |
| 73 | + |
| 74 | + DWARFExpressionList *GetFrameBaseExpression(Status *error_ptr) override; |
| 75 | + |
| 76 | + Block *GetFrameBlock() override; |
| 77 | + |
| 78 | + lldb::RegisterContextSP GetRegisterContext() override; |
| 79 | + |
| 80 | + VariableList *GetVariableList(bool get_file_globals, |
| 81 | + Status *error_ptr) override; |
| 82 | + |
| 83 | + lldb::VariableListSP |
| 84 | + GetInScopeVariableList(bool get_file_globals, |
| 85 | + bool must_have_valid_location = false) override; |
| 86 | + |
| 87 | + lldb::ValueObjectSP GetValueForVariableExpressionPath( |
| 88 | + llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, |
| 89 | + uint32_t options, lldb::VariableSP &var_sp, Status &error) override; |
| 90 | + |
| 91 | + bool HasDebugInformation() override; |
| 92 | + |
| 93 | + const char *Disassemble() override; |
| 94 | + |
| 95 | + lldb::ValueObjectSP |
| 96 | + GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, |
| 97 | + lldb::DynamicValueType use_dynamic) override; |
| 98 | + |
| 99 | + bool IsInlined() override; |
| 100 | + |
| 101 | + bool IsSynthetic() const override; |
| 102 | + |
| 103 | + bool IsHistorical() const override; |
| 104 | + |
| 105 | + bool IsArtificial() const override; |
| 106 | + |
| 107 | + bool IsHidden() override; |
| 108 | + |
| 109 | + const char *GetFunctionName() override; |
| 110 | + |
| 111 | + const char *GetDisplayFunctionName() override; |
| 112 | + |
| 113 | + lldb::ValueObjectSP FindVariable(ConstString name) override; |
| 114 | + |
| 115 | + SourceLanguage GetLanguage() override; |
| 116 | + |
| 117 | + SourceLanguage GuessLanguage() override; |
| 118 | + |
| 119 | + lldb::ValueObjectSP GuessValueForAddress(lldb::addr_t addr) override; |
| 120 | + |
| 121 | + lldb::ValueObjectSP GuessValueForRegisterAndOffset(ConstString reg, |
| 122 | + int64_t offset) override; |
| 123 | + |
| 124 | + StructuredData::ObjectSP GetLanguageSpecificData() override; |
| 125 | + |
| 126 | + lldb::RecognizedStackFrameSP GetRecognizedFrame() override; |
| 127 | + |
| 128 | + /// Get the underlying borrowed frame. |
| 129 | + lldb::StackFrameSP GetBorrowedFrame() const; |
| 130 | + |
| 131 | + bool isA(const void *ClassID) const override; |
| 132 | + static bool classof(const StackFrame *obj); |
| 133 | + |
| 134 | +private: |
| 135 | + lldb::StackFrameSP m_borrowed_frame_sp; |
| 136 | + uint32_t m_new_frame_index; |
| 137 | + uint32_t m_new_concrete_frame_index; |
| 138 | + static char ID; |
| 139 | + |
| 140 | + BorrowedStackFrame(const BorrowedStackFrame &) = delete; |
| 141 | + const BorrowedStackFrame &operator=(const BorrowedStackFrame &) = delete; |
| 142 | +}; |
| 143 | + |
| 144 | +} // namespace lldb_private |
| 145 | + |
| 146 | +#endif // LLDB_TARGET_BORROWEDSTACKFRAME_H |
0 commit comments