LLDB mainline
BorrowedStackFrame.h
Go to the documentation of this file.
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
13
14namespace 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.
28public:
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.
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
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
75
76 Block *GetFrameBlock() override;
77
79
80 VariableList *GetVariableList(bool get_file_globals,
81 Status *error_ptr) override;
82
84 GetInScopeVariableList(bool get_file_globals,
85 bool must_have_valid_location = false) override;
86
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
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
114
115 SourceLanguage GetLanguage() override;
116
117 SourceLanguage GuessLanguage() override;
118
120
122 int64_t offset) override;
123
125
127
128 /// Get the underlying borrowed frame.
130
131 bool isA(const void *ClassID) const override;
132 static bool classof(const StackFrame *obj);
133
134private:
138 static char ID;
139
142};
143
144} // namespace lldb_private
145
146#endif // LLDB_TARGET_BORROWEDSTACKFRAME_H
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
Definition Address.h:62
A class that describes a single lexical block.
Definition Block.h:41
const Address & GetFrameCodeAddress() override
Get an Address for the current pc value in this StackFrame.
static bool classof(const StackFrame *obj)
const char * GetDisplayFunctionName() override
Get the frame's demangled display name.
SourceLanguage GuessLanguage() override
Similar to GetLanguage(), but is allowed to take a potentially incorrect guess if exact information i...
lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool must_have_valid_location=false) override
Retrieve the list of variables that are in scope at this StackFrame's pc.
bool isA(const void *ClassID) const override
bool IsInlined() override
Query whether this frame is a concrete frame on the call stack, or if it is an inlined frame derived ...
bool IsHidden() override
Query whether this frame should be hidden from backtraces.
lldb::ValueObjectSP FindVariable(ConstString name) override
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
lldb::ValueObjectSP GuessValueForRegisterAndOffset(ConstString reg, int64_t offset) override
Attempt to reconstruct the ValueObject for the address contained in a given register plus an offset.
BorrowedStackFrame(const BorrowedStackFrame &)=delete
Block * GetFrameBlock() override
Get the current lexical scope block for this StackFrame, if possible.
const BorrowedStackFrame & operator=(const BorrowedStackFrame &)=delete
bool ChangePC(lldb::addr_t pc) override
Change the pc value for a given thread.
lldb::ValueObjectSP GuessValueForAddress(lldb::addr_t addr) override
Attempt to econstruct the ValueObject for a given raw address touched by the current instruction.
const char * GetFunctionName() override
Get the frame's demangled name.
DWARFExpressionList * GetFrameBaseExpression(Status *error_ptr) override
Get the DWARFExpressionList corresponding to the Canonical Frame Address.
llvm::Error GetFrameBaseValue(Scalar &value) override
Return the Canonical Frame Address (DWARF term) for this frame.
lldb::RegisterContextSP GetRegisterContext() override
Get the RegisterContext for this frame, if possible.
lldb::StackFrameSP GetBorrowedFrame() const
Get the underlying borrowed frame.
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope) override
Provide a SymbolContext for this StackFrame's current pc value.
bool IsHistorical() const override
Query whether this frame is part of a historical backtrace.
BorrowedStackFrame(lldb::StackFrameSP borrowed_frame_sp, uint32_t new_frame_index, std::optional< uint32_t > new_concrete_frame_index=std::nullopt)
Construct a BorrowedStackFrame that wraps an existing frame.
bool IsSynthetic() const override
Query whether this frame is synthetic.
uint32_t GetFrameIndex() const override
Query this frame to find what frame it is in this Thread's StackFrameList.
const char * Disassemble() override
Return the disassembly for the instructions of this StackFrame's function as a single C string.
VariableList * GetVariableList(bool get_file_globals, Status *error_ptr) override
Retrieve the list of variables whose scope either:
bool HasDebugInformation() override
Determine whether this StackFrame has debug information available or not.
uint32_t GetConcreteFrameIndex() override
Get the concrete frame index for this borrowed frame.
bool IsArtificial() const override
Query whether this frame is artificial (e.g a synthesized result of inferring missing tail call frame...
Address GetFrameCodeAddressForSymbolication() override
Get the current code Address suitable for symbolication, may not be the same as GetFrameCodeAddress()...
StructuredData::ObjectSP GetLanguageSpecificData() override
Language plugins can use this API to report language-specific runtime information about this compile ...
SourceLanguage GetLanguage() override
Query this frame to determine what the default language should be when parsing expressions given the ...
~BorrowedStackFrame() override=default
lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic) override
Create a ValueObject for a given Variable in this StackFrame.
lldb::ValueObjectSP GetValueForVariableExpressionPath(llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error) override
Create a ValueObject for a variable name / pathname, possibly including simple dereference/child sele...
lldb::RecognizedStackFrameSP GetRecognizedFrame() override
A uniqued constant string class.
Definition ConstString.h:40
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
friend class BorrowedStackFrame
Definition StackFrame.h:559
StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx, lldb::user_id_t concrete_frame_idx, lldb::addr_t cfa, bool cfa_is_valid, lldb::addr_t pc, Kind frame_kind, bool artificial, bool behaves_like_zeroth_frame, const SymbolContext *sc_ptr)
Construct a StackFrame object without supplying a RegisterContextSP.
An error handling class.
Definition Status.h:118
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::RecognizedStackFrame > RecognizedStackFrameSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Variable > VariableSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
A type-erased pair of llvm::dwarf::SourceLanguageName and version.