LLDB mainline
BorrowedStackFrame.cpp
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
10
11using namespace lldb;
12using namespace lldb_private;
13
15
17 StackFrameSP borrowed_frame_sp, uint32_t new_frame_index,
18 std::optional<uint32_t> new_concrete_frame_index)
19 : StackFrame(
20 borrowed_frame_sp->GetThread(), new_frame_index,
21 borrowed_frame_sp->GetConcreteFrameIndex(),
22 borrowed_frame_sp->GetRegisterContextSP(),
23 borrowed_frame_sp->GetStackID().GetPC(),
24 borrowed_frame_sp->GetStackID().GetCallFrameAddressWithoutMetadata(),
25 borrowed_frame_sp->m_behaves_like_zeroth_frame,
26 &borrowed_frame_sp->GetSymbolContext(eSymbolContextEverything)),
27 m_borrowed_frame_sp(borrowed_frame_sp),
28 m_new_frame_index(new_frame_index) {
29 if (new_concrete_frame_index)
30 m_new_concrete_frame_index = *new_concrete_frame_index;
31 else
33 IsInlined() ? LLDB_INVALID_FRAME_ID : new_frame_index;
34}
35
37
39 m_new_frame_index = index;
40}
41
43 // FIXME: We need to find where the concrete frame into which this frame was
44 // inlined landed in the new stack frame list as that is the correct concrete
45 // frame index in this
46 // stack frame.
48}
49
53
55 return m_borrowed_frame_sp->GetFrameCodeAddress();
56}
57
59 return m_borrowed_frame_sp->GetFrameCodeAddressForSymbolication();
60}
61
65
66const SymbolContext &
67BorrowedStackFrame::GetSymbolContext(SymbolContextItem resolve_scope) {
68 return m_borrowed_frame_sp->GetSymbolContext(resolve_scope);
69}
70
72 return m_borrowed_frame_sp->GetFrameBaseValue(value);
73}
74
77 return m_borrowed_frame_sp->GetFrameBaseExpression(error_ptr);
78}
79
81 return m_borrowed_frame_sp->GetFrameBlock();
82}
83
87
89 Status *error_ptr) {
90 return m_borrowed_frame_sp->GetVariableList(get_file_globals, error_ptr);
91}
92
95 bool must_have_valid_location) {
96 return m_borrowed_frame_sp->GetInScopeVariableList(get_file_globals,
97 must_have_valid_location);
98}
99
101 llvm::StringRef var_expr, DynamicValueType use_dynamic, uint32_t options,
102 VariableSP &var_sp, Status &error) {
103 return m_borrowed_frame_sp->GetValueForVariableExpressionPath(
104 var_expr, use_dynamic, options, var_sp, error);
105}
106
108 return m_borrowed_frame_sp->HasDebugInformation();
109}
110
112 return m_borrowed_frame_sp->Disassemble();
113}
114
116 const VariableSP &variable_sp, DynamicValueType use_dynamic) {
117 return m_borrowed_frame_sp->GetValueObjectForFrameVariable(variable_sp,
118 use_dynamic);
119}
120
122 return m_borrowed_frame_sp->IsInlined();
123}
124
126 return m_borrowed_frame_sp->IsSynthetic();
127}
128
130 return m_borrowed_frame_sp->IsHistorical();
131}
132
134 return m_borrowed_frame_sp->IsArtificial();
135}
136
138
140 return m_borrowed_frame_sp->GetFunctionName();
141}
142
144 return m_borrowed_frame_sp->GetDisplayFunctionName();
145}
146
150
154
158
160 return m_borrowed_frame_sp->GuessValueForAddress(addr);
161}
162
165 int64_t offset) {
166 return m_borrowed_frame_sp->GuessValueForRegisterAndOffset(reg, offset);
167}
168
172
176
180
181bool BorrowedStackFrame::isA(const void *ClassID) const {
182 return ClassID == &ID || StackFrame::isA(ClassID);
183}
184
186 return obj->isA(&ID);
187}
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.
Block * GetFrameBlock() override
Get the current lexical scope block for this StackFrame, if possible.
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 ...
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 ...
lldb::ThreadSP GetThread() const
Definition StackFrame.h:135
bool m_behaves_like_zeroth_frame
Whether this frame behaves like the zeroth frame, in the sense that its pc value might not immediatel...
Definition StackFrame.h:600
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.
virtual bool isA(const void *ClassID) const
Definition StackFrame.h:49
const lldb::RegisterContextSP & GetRegisterContextSP() const
Definition StackFrame.h:248
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.
#define LLDB_INVALID_FRAME_ID
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.