1 //===-- StackFrame.cpp ----------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/StackFrame.h"
10 #include "lldb/Core/Debugger.h"
11 #include "lldb/Core/Disassembler.h"
12 #include "lldb/Core/FormatEntity.h"
13 #include "lldb/Core/Mangled.h"
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/Value.h"
16 #include "lldb/Core/ValueObjectConstResult.h"
17 #include "lldb/Core/ValueObjectMemory.h"
18 #include "lldb/Core/ValueObjectVariable.h"
19 #include "lldb/Symbol/CompileUnit.h"
20 #include "lldb/Symbol/Function.h"
21 #include "lldb/Symbol/Symbol.h"
22 #include "lldb/Symbol/SymbolContextScope.h"
23 #include "lldb/Symbol/SymbolFile.h"
24 #include "lldb/Symbol/Type.h"
25 #include "lldb/Symbol/VariableList.h"
26 #include "lldb/Target/ABI.h"
27 #include "lldb/Target/ExecutionContext.h"
28 #include "lldb/Target/Process.h"
29 #include "lldb/Target/RegisterContext.h"
30 #include "lldb/Target/StackFrameRecognizer.h"
31 #include "lldb/Target/Target.h"
32 #include "lldb/Target/Thread.h"
33 #include "lldb/Utility/LLDBLog.h"
34 #include "lldb/Utility/Log.h"
35 #include "lldb/Utility/RegisterValue.h"
37 #include "lldb/lldb-enumerations.h"
42 using namespace lldb_private
;
44 // The first bits in the flags are reserved for the SymbolContext::Scope bits
45 // so we know if we have tried to look up information in our internal symbol
46 // context (m_sc) already.
47 #define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextLastItem) << 1)
48 #define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1)
49 #define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1)
50 #define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
51 #define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1)
53 StackFrame::StackFrame(const ThreadSP
&thread_sp
, user_id_t frame_idx
,
54 user_id_t unwind_frame_index
, addr_t cfa
,
55 bool cfa_is_valid
, addr_t pc
, StackFrame::Kind kind
,
56 bool behaves_like_zeroth_frame
,
57 const SymbolContext
*sc_ptr
)
58 : m_thread_wp(thread_sp
), m_frame_index(frame_idx
),
59 m_concrete_frame_index(unwind_frame_index
), m_reg_context_sp(),
60 m_id(pc
, cfa
, nullptr), m_frame_code_addr(pc
), m_sc(), m_flags(),
61 m_frame_base(), m_frame_base_error(), m_cfa_is_valid(cfa_is_valid
),
62 m_stack_frame_kind(kind
),
63 m_behaves_like_zeroth_frame(behaves_like_zeroth_frame
),
64 m_variable_list_sp(), m_variable_list_value_objects(),
65 m_recognized_frame_sp(), m_disassembly(), m_mutex() {
66 // If we don't have a CFA value, use the frame index for our StackID so that
67 // recursive functions properly aren't confused with one another on a history
69 if (IsHistorical() && !m_cfa_is_valid
) {
70 m_id
.SetCFA(m_frame_index
);
73 if (sc_ptr
!= nullptr) {
75 m_flags
.Set(m_sc
.GetResolvedMask());
79 StackFrame::StackFrame(const ThreadSP
&thread_sp
, user_id_t frame_idx
,
80 user_id_t unwind_frame_index
,
81 const RegisterContextSP
®_context_sp
, addr_t cfa
,
82 addr_t pc
, bool behaves_like_zeroth_frame
,
83 const SymbolContext
*sc_ptr
)
84 : m_thread_wp(thread_sp
), m_frame_index(frame_idx
),
85 m_concrete_frame_index(unwind_frame_index
),
86 m_reg_context_sp(reg_context_sp
), m_id(pc
, cfa
, nullptr),
87 m_frame_code_addr(pc
), m_sc(), m_flags(), m_frame_base(),
88 m_frame_base_error(), m_cfa_is_valid(true),
89 m_stack_frame_kind(StackFrame::Kind::Regular
),
90 m_behaves_like_zeroth_frame(behaves_like_zeroth_frame
),
91 m_variable_list_sp(), m_variable_list_value_objects(),
92 m_recognized_frame_sp(), m_disassembly(), m_mutex() {
93 if (sc_ptr
!= nullptr) {
95 m_flags
.Set(m_sc
.GetResolvedMask());
98 if (reg_context_sp
&& !m_sc
.target_sp
) {
99 m_sc
.target_sp
= reg_context_sp
->CalculateTarget();
101 m_flags
.Set(eSymbolContextTarget
);
105 StackFrame::StackFrame(const ThreadSP
&thread_sp
, user_id_t frame_idx
,
106 user_id_t unwind_frame_index
,
107 const RegisterContextSP
®_context_sp
, addr_t cfa
,
108 const Address
&pc_addr
, bool behaves_like_zeroth_frame
,
109 const SymbolContext
*sc_ptr
)
110 : m_thread_wp(thread_sp
), m_frame_index(frame_idx
),
111 m_concrete_frame_index(unwind_frame_index
),
112 m_reg_context_sp(reg_context_sp
),
113 m_id(pc_addr
.GetLoadAddress(thread_sp
->CalculateTarget().get()), cfa
,
115 m_frame_code_addr(pc_addr
), m_sc(), m_flags(), m_frame_base(),
116 m_frame_base_error(), m_cfa_is_valid(true),
117 m_stack_frame_kind(StackFrame::Kind::Regular
),
118 m_behaves_like_zeroth_frame(behaves_like_zeroth_frame
),
119 m_variable_list_sp(), m_variable_list_value_objects(),
120 m_recognized_frame_sp(), m_disassembly(), m_mutex() {
121 if (sc_ptr
!= nullptr) {
123 m_flags
.Set(m_sc
.GetResolvedMask());
126 if (!m_sc
.target_sp
&& reg_context_sp
) {
127 m_sc
.target_sp
= reg_context_sp
->CalculateTarget();
129 m_flags
.Set(eSymbolContextTarget
);
132 ModuleSP
pc_module_sp(pc_addr
.GetModule());
133 if (!m_sc
.module_sp
|| m_sc
.module_sp
!= pc_module_sp
) {
135 m_sc
.module_sp
= pc_module_sp
;
136 m_flags
.Set(eSymbolContextModule
);
138 m_sc
.module_sp
.reset();
143 StackFrame::~StackFrame() = default;
145 StackID
&StackFrame::GetStackID() {
146 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
147 // Make sure we have resolved the StackID object's symbol context scope if we
148 // already haven't looked it up.
150 if (m_flags
.IsClear(RESOLVED_FRAME_ID_SYMBOL_SCOPE
)) {
151 if (m_id
.GetSymbolContextScope()) {
152 // We already have a symbol context scope, we just don't have our flag
154 m_flags
.Set(RESOLVED_FRAME_ID_SYMBOL_SCOPE
);
156 // Calculate the frame block and use this for the stack ID symbol context
157 // scope if we have one.
158 SymbolContextScope
*scope
= GetFrameBlock();
159 if (scope
== nullptr) {
160 // We don't have a block, so use the symbol
161 if (m_flags
.IsClear(eSymbolContextSymbol
))
162 GetSymbolContext(eSymbolContextSymbol
);
164 // It is ok if m_sc.symbol is nullptr here
167 // Set the symbol context scope (the accessor will set the
168 // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags).
169 SetSymbolContextScope(scope
);
175 uint32_t StackFrame::GetFrameIndex() const {
176 ThreadSP thread_sp
= GetThread();
178 return thread_sp
->GetStackFrameList()->GetVisibleStackFrameIndex(
181 return m_frame_index
;
184 void StackFrame::SetSymbolContextScope(SymbolContextScope
*symbol_scope
) {
185 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
186 m_flags
.Set(RESOLVED_FRAME_ID_SYMBOL_SCOPE
);
187 m_id
.SetSymbolContextScope(symbol_scope
);
190 const Address
&StackFrame::GetFrameCodeAddress() {
191 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
192 if (m_flags
.IsClear(RESOLVED_FRAME_CODE_ADDR
) &&
193 !m_frame_code_addr
.IsSectionOffset()) {
194 m_flags
.Set(RESOLVED_FRAME_CODE_ADDR
);
196 // Resolve the PC into a temporary address because if ResolveLoadAddress
197 // fails to resolve the address, it will clear the address object...
198 ThreadSP
thread_sp(GetThread());
200 TargetSP
target_sp(thread_sp
->CalculateTarget());
202 const bool allow_section_end
= true;
203 if (m_frame_code_addr
.SetOpcodeLoadAddress(
204 m_frame_code_addr
.GetOffset(), target_sp
.get(),
205 AddressClass::eCode
, allow_section_end
)) {
206 ModuleSP
module_sp(m_frame_code_addr
.GetModule());
208 m_sc
.module_sp
= module_sp
;
209 m_flags
.Set(eSymbolContextModule
);
215 return m_frame_code_addr
;
218 // This can't be rewritten into a call to
219 // RegisterContext::GetPCForSymbolication because this
220 // StackFrame may have been constructed with a special pc,
221 // e.g. tail-call artificial frames.
222 Address
StackFrame::GetFrameCodeAddressForSymbolication() {
223 Address
lookup_addr(GetFrameCodeAddress());
224 if (!lookup_addr
.IsValid())
226 if (m_behaves_like_zeroth_frame
)
229 addr_t offset
= lookup_addr
.GetOffset();
231 lookup_addr
.SetOffset(offset
- 1);
233 // lookup_addr is the start of a section. We need do the math on the
234 // actual load address and re-compute the section. We're working with
235 // a 'noreturn' function at the end of a section.
236 TargetSP target_sp
= CalculateTarget();
238 addr_t addr_minus_one
= lookup_addr
.GetOpcodeLoadAddress(
239 target_sp
.get(), AddressClass::eCode
) -
241 lookup_addr
.SetOpcodeLoadAddress(addr_minus_one
, target_sp
.get());
247 bool StackFrame::ChangePC(addr_t pc
) {
248 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
249 // We can't change the pc value of a history stack frame - it is immutable.
252 m_frame_code_addr
.SetRawAddress(pc
);
255 ThreadSP
thread_sp(GetThread());
257 thread_sp
->ClearStackFrames();
261 const char *StackFrame::Disassemble() {
262 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
263 if (!m_disassembly
.Empty())
264 return m_disassembly
.GetData();
266 ExecutionContext
exe_ctx(shared_from_this());
267 if (Target
*target
= exe_ctx
.GetTargetPtr()) {
268 Disassembler::Disassemble(target
->GetDebugger(), target
->GetArchitecture(),
269 *this, m_disassembly
);
272 return m_disassembly
.Empty() ? nullptr : m_disassembly
.GetData();
275 Block
*StackFrame::GetFrameBlock() {
276 if (m_sc
.block
== nullptr && m_flags
.IsClear(eSymbolContextBlock
))
277 GetSymbolContext(eSymbolContextBlock
);
280 Block
*inline_block
= m_sc
.block
->GetContainingInlinedBlock();
282 // Use the block with the inlined function info as the frame block we
283 // want this frame to have only the variables for the inlined function
284 // and its non-inlined block child blocks.
287 // This block is not contained within any inlined function blocks with so
288 // we want to use the top most function block.
289 return &m_sc
.function
->GetBlock(false);
295 // Get the symbol context if we already haven't done so by resolving the
296 // PC address as much as possible. This way when we pass around a
297 // StackFrame object, everyone will have as much information as possible and no
298 // one will ever have to look things up manually.
299 const SymbolContext
&
300 StackFrame::GetSymbolContext(SymbolContextItem resolve_scope
) {
301 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
302 // Copy our internal symbol context into "sc".
303 if ((m_flags
.Get() & resolve_scope
) != resolve_scope
) {
304 uint32_t resolved
= 0;
306 // If the target was requested add that:
307 if (!m_sc
.target_sp
) {
308 m_sc
.target_sp
= CalculateTarget();
310 resolved
|= eSymbolContextTarget
;
313 // Resolve our PC to section offset if we haven't already done so and if we
314 // don't have a module. The resolved address section will contain the
315 // module to which it belongs
316 if (!m_sc
.module_sp
&& m_flags
.IsClear(RESOLVED_FRAME_CODE_ADDR
))
317 GetFrameCodeAddress();
319 // If this is not frame zero, then we need to subtract 1 from the PC value
320 // when doing address lookups since the PC will be on the instruction
321 // following the function call instruction...
322 Address
lookup_addr(GetFrameCodeAddressForSymbolication());
324 if (m_sc
.module_sp
) {
325 // We have something in our stack frame symbol context, lets check if we
326 // haven't already tried to lookup one of those things. If we haven't
327 // then we will do the query.
329 SymbolContextItem actual_resolve_scope
= SymbolContextItem(0);
331 if (resolve_scope
& eSymbolContextCompUnit
) {
332 if (m_flags
.IsClear(eSymbolContextCompUnit
)) {
334 resolved
|= eSymbolContextCompUnit
;
336 actual_resolve_scope
|= eSymbolContextCompUnit
;
340 if (resolve_scope
& eSymbolContextFunction
) {
341 if (m_flags
.IsClear(eSymbolContextFunction
)) {
343 resolved
|= eSymbolContextFunction
;
345 actual_resolve_scope
|= eSymbolContextFunction
;
349 if (resolve_scope
& eSymbolContextBlock
) {
350 if (m_flags
.IsClear(eSymbolContextBlock
)) {
352 resolved
|= eSymbolContextBlock
;
354 actual_resolve_scope
|= eSymbolContextBlock
;
358 if (resolve_scope
& eSymbolContextSymbol
) {
359 if (m_flags
.IsClear(eSymbolContextSymbol
)) {
361 resolved
|= eSymbolContextSymbol
;
363 actual_resolve_scope
|= eSymbolContextSymbol
;
367 if (resolve_scope
& eSymbolContextLineEntry
) {
368 if (m_flags
.IsClear(eSymbolContextLineEntry
)) {
369 if (m_sc
.line_entry
.IsValid())
370 resolved
|= eSymbolContextLineEntry
;
372 actual_resolve_scope
|= eSymbolContextLineEntry
;
376 if (actual_resolve_scope
) {
377 // We might be resolving less information than what is already in our
378 // current symbol context so resolve into a temporary symbol context
379 // "sc" so we don't clear out data we have already found in "m_sc"
381 // Set flags that indicate what we have tried to resolve
382 resolved
|= m_sc
.module_sp
->ResolveSymbolContextForAddress(
383 lookup_addr
, actual_resolve_scope
, sc
);
384 // Only replace what we didn't already have as we may have information
385 // for an inlined function scope that won't match what a standard
386 // lookup by address would match
387 if ((resolved
& eSymbolContextCompUnit
) && m_sc
.comp_unit
== nullptr)
388 m_sc
.comp_unit
= sc
.comp_unit
;
389 if ((resolved
& eSymbolContextFunction
) && m_sc
.function
== nullptr)
390 m_sc
.function
= sc
.function
;
391 if ((resolved
& eSymbolContextBlock
) && m_sc
.block
== nullptr)
392 m_sc
.block
= sc
.block
;
393 if ((resolved
& eSymbolContextSymbol
) && m_sc
.symbol
== nullptr)
394 m_sc
.symbol
= sc
.symbol
;
395 if ((resolved
& eSymbolContextLineEntry
) &&
396 !m_sc
.line_entry
.IsValid()) {
397 m_sc
.line_entry
= sc
.line_entry
;
398 m_sc
.line_entry
.ApplyFileMappings(m_sc
.target_sp
);
402 // If we don't have a module, then we can't have the compile unit,
403 // function, block, line entry or symbol, so we can safely call
404 // ResolveSymbolContextForAddress with our symbol context member m_sc.
405 if (m_sc
.target_sp
) {
406 resolved
|= m_sc
.target_sp
->GetImages().ResolveSymbolContextForAddress(
407 lookup_addr
, resolve_scope
, m_sc
);
411 // Update our internal flags so we remember what we have tried to locate so
412 // we don't have to keep trying when more calls to this function are made.
413 // We might have dug up more information that was requested (for example if
414 // we were asked to only get the block, we will have gotten the compile
415 // unit, and function) so set any additional bits that we resolved
416 m_flags
.Set(resolve_scope
| resolved
);
419 // Return the symbol context with everything that was possible to resolve
424 VariableList
*StackFrame::GetVariableList(bool get_file_globals
,
426 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
427 if (m_flags
.IsClear(RESOLVED_VARIABLES
)) {
428 m_flags
.Set(RESOLVED_VARIABLES
);
429 m_variable_list_sp
= std::make_shared
<VariableList
>();
431 Block
*frame_block
= GetFrameBlock();
434 const bool get_child_variables
= true;
435 const bool can_create
= true;
436 const bool stop_if_child_block_is_inlined_function
= true;
437 frame_block
->AppendBlockVariables(can_create
, get_child_variables
,
438 stop_if_child_block_is_inlined_function
,
439 [](Variable
*v
) { return true; },
440 m_variable_list_sp
.get());
444 if (m_flags
.IsClear(RESOLVED_GLOBAL_VARIABLES
) && get_file_globals
) {
445 m_flags
.Set(RESOLVED_GLOBAL_VARIABLES
);
447 if (m_flags
.IsClear(eSymbolContextCompUnit
))
448 GetSymbolContext(eSymbolContextCompUnit
);
450 if (m_sc
.comp_unit
) {
451 VariableListSP
global_variable_list_sp(
452 m_sc
.comp_unit
->GetVariableList(true));
453 if (m_variable_list_sp
)
454 m_variable_list_sp
->AddVariables(global_variable_list_sp
.get());
456 m_variable_list_sp
= global_variable_list_sp
;
460 if (error_ptr
&& m_variable_list_sp
->GetSize() == 0) {
461 // Check with the symbol file to check if there is an error for why we
462 // don't have variables that the user might need to know about.
463 GetSymbolContext(eSymbolContextEverything
);
464 if (m_sc
.module_sp
) {
465 SymbolFile
*sym_file
= m_sc
.module_sp
->GetSymbolFile();
467 *error_ptr
= sym_file
->GetFrameVariableError(*this);
471 return m_variable_list_sp
.get();
475 StackFrame::GetInScopeVariableList(bool get_file_globals
,
476 bool must_have_valid_location
) {
477 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
478 // We can't fetch variable information for a history stack frame.
480 return VariableListSP();
482 VariableListSP
var_list_sp(new VariableList
);
483 GetSymbolContext(eSymbolContextCompUnit
| eSymbolContextBlock
);
486 const bool can_create
= true;
487 const bool get_parent_variables
= true;
488 const bool stop_if_block_is_inlined_function
= true;
489 m_sc
.block
->AppendVariables(
490 can_create
, get_parent_variables
, stop_if_block_is_inlined_function
,
491 [this, must_have_valid_location
](Variable
*v
) {
492 return v
->IsInScope(this) && (!must_have_valid_location
||
493 v
->LocationIsValidForFrame(this));
498 if (m_sc
.comp_unit
&& get_file_globals
) {
499 VariableListSP
global_variable_list_sp(
500 m_sc
.comp_unit
->GetVariableList(true));
501 if (global_variable_list_sp
)
502 var_list_sp
->AddVariables(global_variable_list_sp
.get());
508 ValueObjectSP
StackFrame::GetValueForVariableExpressionPath(
509 llvm::StringRef var_expr
, DynamicValueType use_dynamic
, uint32_t options
,
510 VariableSP
&var_sp
, Status
&error
) {
511 llvm::StringRef original_var_expr
= var_expr
;
512 // We can't fetch variable information for a history stack frame.
514 return ValueObjectSP();
516 if (var_expr
.empty()) {
517 error
.SetErrorStringWithFormat("invalid variable path '%s'",
518 var_expr
.str().c_str());
519 return ValueObjectSP();
522 const bool check_ptr_vs_member
=
523 (options
& eExpressionPathOptionCheckPtrVsMember
) != 0;
524 const bool no_fragile_ivar
=
525 (options
& eExpressionPathOptionsNoFragileObjcIvar
) != 0;
526 const bool no_synth_child
=
527 (options
& eExpressionPathOptionsNoSyntheticChildren
) != 0;
528 // const bool no_synth_array = (options &
529 // eExpressionPathOptionsNoSyntheticArrayRange) != 0;
532 bool address_of
= false;
533 ValueObjectSP valobj_sp
;
534 const bool get_file_globals
= true;
535 // When looking up a variable for an expression, we need only consider the
536 // variables that are in scope.
537 VariableListSP
var_list_sp(GetInScopeVariableList(get_file_globals
));
538 VariableList
*variable_list
= var_list_sp
.get();
541 return ValueObjectSP();
543 // If first character is a '*', then show pointer contents
544 std::string var_expr_storage
;
545 if (var_expr
[0] == '*') {
547 var_expr
= var_expr
.drop_front(); // Skip the '*'
548 } else if (var_expr
[0] == '&') {
550 var_expr
= var_expr
.drop_front(); // Skip the '&'
553 size_t separator_idx
= var_expr
.find_first_of(".-[=+~|&^%#@!/?,<>{}");
554 StreamString var_expr_path_strm
;
556 ConstString
name_const_string(var_expr
.substr(0, separator_idx
));
558 var_sp
= variable_list
->FindVariable(name_const_string
, false);
560 bool synthetically_added_instance_object
= false;
563 var_expr
= var_expr
.drop_front(name_const_string
.GetLength());
566 if (!var_sp
&& (options
& eExpressionPathOptionsAllowDirectIVarAccess
)) {
567 // Check for direct ivars access which helps us with implicit access to
568 // ivars using "this" or "self".
569 GetSymbolContext(eSymbolContextFunction
| eSymbolContextBlock
);
570 llvm::StringRef instance_var_name
= m_sc
.GetInstanceVariableName();
571 if (!instance_var_name
.empty()) {
572 var_sp
= variable_list
->FindVariable(ConstString(instance_var_name
));
575 if (Type
*var_type
= var_sp
->GetType())
576 if (auto compiler_type
= var_type
->GetForwardCompilerType())
577 if (!compiler_type
.IsPointerType())
578 var_expr_storage
= ".";
580 if (var_expr_storage
.empty())
581 var_expr_storage
= "->";
582 var_expr_storage
+= var_expr
;
583 var_expr
= var_expr_storage
;
584 synthetically_added_instance_object
= true;
589 if (!var_sp
&& (options
& eExpressionPathOptionsInspectAnonymousUnions
)) {
590 // Check if any anonymous unions are there which contain a variable with
592 for (const VariableSP
&variable_sp
: *variable_list
) {
595 if (!variable_sp
->GetName().IsEmpty())
598 Type
*var_type
= variable_sp
->GetType();
602 if (!var_type
->GetForwardCompilerType().IsAnonymousType())
604 valobj_sp
= GetValueObjectForFrameVariable(variable_sp
, use_dynamic
);
607 valobj_sp
= valobj_sp
->GetChildMemberWithName(name_const_string
);
613 if (var_sp
&& !valobj_sp
) {
614 valobj_sp
= GetValueObjectForFrameVariable(var_sp
, use_dynamic
);
619 error
.SetErrorStringWithFormat("no variable named '%s' found in this frame",
620 name_const_string
.GetCString());
621 return ValueObjectSP();
624 // We are dumping at least one child
625 while (!var_expr
.empty()) {
626 // Calculate the next separator index ahead of time
627 ValueObjectSP child_valobj_sp
;
628 const char separator_type
= var_expr
[0];
629 bool expr_is_ptr
= false;
630 switch (separator_type
) {
633 if (var_expr
.size() >= 2 && var_expr
[1] != '>')
634 return ValueObjectSP();
636 if (no_fragile_ivar
) {
637 // Make sure we aren't trying to deref an objective
638 // C ivar if this is not allowed
639 const uint32_t pointer_type_flags
=
640 valobj_sp
->GetCompilerType().GetTypeInfo(nullptr);
641 if ((pointer_type_flags
& eTypeIsObjC
) &&
642 (pointer_type_flags
& eTypeIsPointer
)) {
643 // This was an objective C object pointer and it was requested we
644 // skip any fragile ivars so return nothing here
645 return ValueObjectSP();
649 // If we have a non pointer type with a sythetic value then lets check if
650 // we have an sythetic dereference specified.
651 if (!valobj_sp
->IsPointerType() && valobj_sp
->HasSyntheticValue()) {
653 if (valobj_sp
->GetCompilerType().IsReferenceType()) {
654 valobj_sp
= valobj_sp
->GetSyntheticValue()->Dereference(deref_error
);
656 error
.SetErrorStringWithFormatv(
657 "Failed to dereference reference type: %s", deref_error
);
658 return ValueObjectSP();
662 valobj_sp
= valobj_sp
->Dereference(deref_error
);
664 error
.SetErrorStringWithFormatv(
665 "Failed to dereference sythetic value: {0}", deref_error
);
666 return ValueObjectSP();
668 // Some synthetic plug-ins fail to set the error in Dereference
670 error
.SetErrorString("Failed to dereference sythetic value");
671 return ValueObjectSP();
676 var_expr
= var_expr
.drop_front(); // Remove the '-'
679 var_expr
= var_expr
.drop_front(); // Remove the '.' or '>'
680 separator_idx
= var_expr
.find_first_of(".-[");
681 ConstString
child_name(var_expr
.substr(0, var_expr
.find_first_of(".-[")));
683 if (check_ptr_vs_member
) {
684 // We either have a pointer type and need to verify valobj_sp is a
685 // pointer, or we have a member of a class/union/struct being accessed
686 // with the . syntax and need to verify we don't have a pointer.
687 const bool actual_is_ptr
= valobj_sp
->IsPointerType();
689 if (actual_is_ptr
!= expr_is_ptr
) {
690 // Incorrect use of "." with a pointer, or "->" with a
691 // class/union/struct instance or reference.
692 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
694 error
.SetErrorStringWithFormat(
695 "\"%s\" is a pointer and . was used to attempt to access "
696 "\"%s\". Did you mean \"%s->%s\"?",
697 var_expr_path_strm
.GetData(), child_name
.GetCString(),
698 var_expr_path_strm
.GetData(), var_expr
.str().c_str());
700 error
.SetErrorStringWithFormat(
701 "\"%s\" is not a pointer and -> was used to attempt to "
702 "access \"%s\". Did you mean \"%s.%s\"?",
703 var_expr_path_strm
.GetData(), child_name
.GetCString(),
704 var_expr_path_strm
.GetData(), var_expr
.str().c_str());
705 return ValueObjectSP();
708 child_valobj_sp
= valobj_sp
->GetChildMemberWithName(child_name
);
709 if (!child_valobj_sp
) {
710 if (!no_synth_child
) {
711 child_valobj_sp
= valobj_sp
->GetSyntheticValue();
714 child_valobj_sp
->GetChildMemberWithName(child_name
);
717 if (no_synth_child
|| !child_valobj_sp
) {
718 // No child member with name "child_name"
719 if (synthetically_added_instance_object
) {
720 // We added a "this->" or "self->" to the beginning of the
721 // expression and this is the first pointer ivar access, so just
722 // return the normal error
723 error
.SetErrorStringWithFormat(
724 "no variable or instance variable named '%s' found in "
726 name_const_string
.GetCString());
728 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
730 error
.SetErrorStringWithFormat(
731 "\"%s\" is not a member of \"(%s) %s\"",
732 child_name
.GetCString(),
733 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
734 var_expr_path_strm
.GetData());
736 error
.SetErrorStringWithFormat(
737 "incomplete expression path after \"%s\" in \"%s\"",
738 var_expr_path_strm
.GetData(),
739 original_var_expr
.str().c_str());
742 return ValueObjectSP();
745 synthetically_added_instance_object
= false;
746 // Remove the child name from the path
747 var_expr
= var_expr
.drop_front(child_name
.GetLength());
748 if (use_dynamic
!= eNoDynamicValues
) {
749 ValueObjectSP
dynamic_value_sp(
750 child_valobj_sp
->GetDynamicValue(use_dynamic
));
751 if (dynamic_value_sp
)
752 child_valobj_sp
= dynamic_value_sp
;
757 // Array member access, or treating pointer as an array Need at least two
758 // brackets and a number
759 if (var_expr
.size() <= 2) {
760 error
.SetErrorStringWithFormat(
761 "invalid square bracket encountered after \"%s\" in \"%s\"",
762 var_expr_path_strm
.GetData(), var_expr
.str().c_str());
763 return ValueObjectSP();
766 // Drop the open brace.
767 var_expr
= var_expr
.drop_front();
768 long child_index
= 0;
770 // If there's no closing brace, this is an invalid expression.
771 size_t end_pos
= var_expr
.find_first_of(']');
772 if (end_pos
== llvm::StringRef::npos
) {
773 error
.SetErrorStringWithFormat(
774 "missing closing square bracket in expression \"%s\"",
775 var_expr_path_strm
.GetData());
776 return ValueObjectSP();
778 llvm::StringRef index_expr
= var_expr
.take_front(end_pos
);
779 llvm::StringRef original_index_expr
= index_expr
;
780 // Drop all of "[index_expr]"
781 var_expr
= var_expr
.drop_front(end_pos
+ 1);
783 if (index_expr
.consumeInteger(0, child_index
)) {
784 // If there was no integer anywhere in the index expression, this is
785 // erroneous expression.
786 error
.SetErrorStringWithFormat("invalid index expression \"%s\"",
787 index_expr
.str().c_str());
788 return ValueObjectSP();
791 if (index_expr
.empty()) {
792 // The entire index expression was a single integer.
794 if (valobj_sp
->GetCompilerType().IsPointerToScalarType() && deref
) {
795 // what we have is *ptr[low]. the most similar C++ syntax is to deref
796 // ptr and extract bit low out of it. reading array item low would be
797 // done by saying ptr[low], without a deref * sign
799 ValueObjectSP
temp(valobj_sp
->Dereference(error
));
801 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
802 error
.SetErrorStringWithFormat(
803 "could not dereference \"(%s) %s\"",
804 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
805 var_expr_path_strm
.GetData());
806 return ValueObjectSP();
810 } else if (valobj_sp
->GetCompilerType().IsArrayOfScalarType() &&
812 // what we have is *arr[low]. the most similar C++ syntax is to get
813 // arr[0] (an operation that is equivalent to deref-ing arr) and
814 // extract bit low out of it. reading array item low would be done by
815 // saying arr[low], without a deref * sign
817 ValueObjectSP
temp(valobj_sp
->GetChildAtIndex(0));
819 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
820 error
.SetErrorStringWithFormat(
821 "could not get item 0 for \"(%s) %s\"",
822 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
823 var_expr_path_strm
.GetData());
824 return ValueObjectSP();
830 bool is_incomplete_array
= false;
831 if (valobj_sp
->IsPointerType()) {
832 bool is_objc_pointer
= true;
834 if (valobj_sp
->GetCompilerType().GetMinimumLanguage() !=
836 is_objc_pointer
= false;
837 else if (!valobj_sp
->GetCompilerType().IsPointerType())
838 is_objc_pointer
= false;
840 if (no_synth_child
&& is_objc_pointer
) {
841 error
.SetErrorStringWithFormat(
842 "\"(%s) %s\" is an Objective-C pointer, and cannot be "
844 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
845 var_expr_path_strm
.GetData());
847 return ValueObjectSP();
848 } else if (is_objc_pointer
) {
849 // dereferencing ObjC variables is not valid.. so let's try and
850 // recur to synthetic children
851 ValueObjectSP synthetic
= valobj_sp
->GetSyntheticValue();
852 if (!synthetic
/* no synthetic */
853 || synthetic
== valobj_sp
) /* synthetic is the same as
854 the original object */
856 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
857 error
.SetErrorStringWithFormat(
858 "\"(%s) %s\" is not an array type",
859 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
860 var_expr_path_strm
.GetData());
862 static_cast<uint32_t>(child_index
) >=
864 ->GetNumChildren() /* synthetic does not have that many values */) {
865 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
866 error
.SetErrorStringWithFormat(
867 "array index %ld is not valid for \"(%s) %s\"", child_index
,
868 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
869 var_expr_path_strm
.GetData());
871 child_valobj_sp
= synthetic
->GetChildAtIndex(child_index
);
872 if (!child_valobj_sp
) {
873 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
874 error
.SetErrorStringWithFormat(
875 "array index %ld is not valid for \"(%s) %s\"", child_index
,
876 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
877 var_expr_path_strm
.GetData());
882 valobj_sp
->GetSyntheticArrayMember(child_index
, true);
883 if (!child_valobj_sp
) {
884 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
885 error
.SetErrorStringWithFormat(
886 "failed to use pointer as array for index %ld for "
889 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
890 var_expr_path_strm
.GetData());
893 } else if (valobj_sp
->GetCompilerType().IsArrayType(
894 nullptr, nullptr, &is_incomplete_array
)) {
895 // Pass false to dynamic_value here so we can tell the difference
896 // between no dynamic value and no member of this type...
897 child_valobj_sp
= valobj_sp
->GetChildAtIndex(child_index
);
898 if (!child_valobj_sp
&& (is_incomplete_array
|| !no_synth_child
))
900 valobj_sp
->GetSyntheticArrayMember(child_index
, true);
902 if (!child_valobj_sp
) {
903 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
904 error
.SetErrorStringWithFormat(
905 "array index %ld is not valid for \"(%s) %s\"", child_index
,
906 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
907 var_expr_path_strm
.GetData());
909 } else if (valobj_sp
->GetCompilerType().IsScalarType()) {
910 // this is a bitfield asking to display just one bit
911 child_valobj_sp
= valobj_sp
->GetSyntheticBitFieldChild(
912 child_index
, child_index
, true);
913 if (!child_valobj_sp
) {
914 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
915 error
.SetErrorStringWithFormat(
916 "bitfield range %ld-%ld is not valid for \"(%s) %s\"",
917 child_index
, child_index
,
918 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
919 var_expr_path_strm
.GetData());
922 ValueObjectSP synthetic
= valobj_sp
->GetSyntheticValue();
923 if (no_synth_child
/* synthetic is forbidden */ ||
924 !synthetic
/* no synthetic */
925 || synthetic
== valobj_sp
) /* synthetic is the same as the
928 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
929 error
.SetErrorStringWithFormat(
930 "\"(%s) %s\" is not an array type",
931 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
932 var_expr_path_strm
.GetData());
934 static_cast<uint32_t>(child_index
) >=
936 ->GetNumChildren() /* synthetic does not have that many values */) {
937 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
938 error
.SetErrorStringWithFormat(
939 "array index %ld is not valid for \"(%s) %s\"", child_index
,
940 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
941 var_expr_path_strm
.GetData());
943 child_valobj_sp
= synthetic
->GetChildAtIndex(child_index
);
944 if (!child_valobj_sp
) {
945 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
946 error
.SetErrorStringWithFormat(
947 "array index %ld is not valid for \"(%s) %s\"", child_index
,
948 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
949 var_expr_path_strm
.GetData());
954 if (!child_valobj_sp
) {
955 // Invalid array index...
956 return ValueObjectSP();
959 if (use_dynamic
!= eNoDynamicValues
) {
960 ValueObjectSP
dynamic_value_sp(
961 child_valobj_sp
->GetDynamicValue(use_dynamic
));
962 if (dynamic_value_sp
)
963 child_valobj_sp
= dynamic_value_sp
;
965 // Break out early from the switch since we were able to find the child
970 // this is most probably a BitField, let's take a look
971 if (index_expr
.front() != '-') {
972 error
.SetErrorStringWithFormat("invalid range expression \"'%s'\"",
973 original_index_expr
.str().c_str());
974 return ValueObjectSP();
977 index_expr
= index_expr
.drop_front();
978 long final_index
= 0;
979 if (index_expr
.getAsInteger(0, final_index
)) {
980 error
.SetErrorStringWithFormat("invalid range expression \"'%s'\"",
981 original_index_expr
.str().c_str());
982 return ValueObjectSP();
985 // if the format given is [high-low], swap range
986 if (child_index
> final_index
) {
987 long temp
= child_index
;
988 child_index
= final_index
;
992 if (valobj_sp
->GetCompilerType().IsPointerToScalarType() && deref
) {
993 // what we have is *ptr[low-high]. the most similar C++ syntax is to
994 // deref ptr and extract bits low thru high out of it. reading array
995 // items low thru high would be done by saying ptr[low-high], without a
998 ValueObjectSP
temp(valobj_sp
->Dereference(error
));
1000 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
1001 error
.SetErrorStringWithFormat(
1002 "could not dereference \"(%s) %s\"",
1003 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
1004 var_expr_path_strm
.GetData());
1005 return ValueObjectSP();
1009 } else if (valobj_sp
->GetCompilerType().IsArrayOfScalarType() && deref
) {
1010 // what we have is *arr[low-high]. the most similar C++ syntax is to
1011 // get arr[0] (an operation that is equivalent to deref-ing arr) and
1012 // extract bits low thru high out of it. reading array items low thru
1013 // high would be done by saying arr[low-high], without a deref * sign
1015 ValueObjectSP
temp(valobj_sp
->GetChildAtIndex(0));
1017 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
1018 error
.SetErrorStringWithFormat(
1019 "could not get item 0 for \"(%s) %s\"",
1020 valobj_sp
->GetTypeName().AsCString("<invalid type>"),
1021 var_expr_path_strm
.GetData());
1022 return ValueObjectSP();
1029 valobj_sp
->GetSyntheticBitFieldChild(child_index
, final_index
, true);
1030 if (!child_valobj_sp
) {
1031 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
1032 error
.SetErrorStringWithFormat(
1033 "bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index
,
1034 final_index
, valobj_sp
->GetTypeName().AsCString("<invalid type>"),
1035 var_expr_path_strm
.GetData());
1038 if (!child_valobj_sp
) {
1039 // Invalid bitfield range...
1040 return ValueObjectSP();
1043 if (use_dynamic
!= eNoDynamicValues
) {
1044 ValueObjectSP
dynamic_value_sp(
1045 child_valobj_sp
->GetDynamicValue(use_dynamic
));
1046 if (dynamic_value_sp
)
1047 child_valobj_sp
= dynamic_value_sp
;
1049 // Break out early from the switch since we were able to find the child
1056 valobj_sp
->GetExpressionPath(var_expr_path_strm
);
1057 error
.SetErrorStringWithFormat(
1058 "unexpected char '%c' encountered after \"%s\" in \"%s\"",
1059 separator_type
, var_expr_path_strm
.GetData(),
1060 var_expr
.str().c_str());
1062 return ValueObjectSP();
1066 if (child_valobj_sp
)
1067 valobj_sp
= child_valobj_sp
;
1071 ValueObjectSP
deref_valobj_sp(valobj_sp
->Dereference(error
));
1072 valobj_sp
= deref_valobj_sp
;
1073 } else if (address_of
) {
1074 ValueObjectSP
address_of_valobj_sp(valobj_sp
->AddressOf(error
));
1075 valobj_sp
= address_of_valobj_sp
;
1081 bool StackFrame::GetFrameBaseValue(Scalar
&frame_base
, Status
*error_ptr
) {
1082 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
1083 if (!m_cfa_is_valid
) {
1084 m_frame_base_error
.SetErrorString(
1085 "No frame base available for this historical stack frame.");
1089 if (m_flags
.IsClear(GOT_FRAME_BASE
)) {
1090 if (m_sc
.function
) {
1091 m_frame_base
.Clear();
1092 m_frame_base_error
.Clear();
1094 m_flags
.Set(GOT_FRAME_BASE
);
1095 ExecutionContext
exe_ctx(shared_from_this());
1097 addr_t loclist_base_addr
= LLDB_INVALID_ADDRESS
;
1098 if (!m_sc
.function
->GetFrameBaseExpression().IsAlwaysValidSingleExpr())
1100 m_sc
.function
->GetAddressRange().GetBaseAddress().GetLoadAddress(
1101 exe_ctx
.GetTargetPtr());
1103 if (!m_sc
.function
->GetFrameBaseExpression().Evaluate(
1104 &exe_ctx
, nullptr, loclist_base_addr
, nullptr, nullptr,
1105 expr_value
, &m_frame_base_error
)) {
1106 // We should really have an error if evaluate returns, but in case we
1107 // don't, lets set the error to something at least.
1108 if (m_frame_base_error
.Success())
1109 m_frame_base_error
.SetErrorString(
1110 "Evaluation of the frame base expression failed.");
1112 m_frame_base
= expr_value
.ResolveValue(&exe_ctx
);
1115 m_frame_base_error
.SetErrorString("No function in symbol context.");
1119 if (m_frame_base_error
.Success())
1120 frame_base
= m_frame_base
;
1123 *error_ptr
= m_frame_base_error
;
1124 return m_frame_base_error
.Success();
1127 DWARFExpressionList
*StackFrame::GetFrameBaseExpression(Status
*error_ptr
) {
1128 if (!m_sc
.function
) {
1130 error_ptr
->SetErrorString("No function in symbol context.");
1135 return &m_sc
.function
->GetFrameBaseExpression();
1138 RegisterContextSP
StackFrame::GetRegisterContext() {
1139 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
1140 if (!m_reg_context_sp
) {
1141 ThreadSP
thread_sp(GetThread());
1143 m_reg_context_sp
= thread_sp
->CreateRegisterContextForFrame(this);
1145 return m_reg_context_sp
;
1148 bool StackFrame::HasDebugInformation() {
1149 GetSymbolContext(eSymbolContextLineEntry
);
1150 return m_sc
.line_entry
.IsValid();
1154 StackFrame::GetValueObjectForFrameVariable(const VariableSP
&variable_sp
,
1155 DynamicValueType use_dynamic
) {
1156 ValueObjectSP valobj_sp
;
1157 { // Scope for stack frame mutex. We need to drop this mutex before we figure
1158 // out the dynamic value. That will require converting the StackID in the
1159 // VO back to a StackFrame, which will in turn require locking the
1160 // StackFrameList. If we still hold the StackFrame mutex, we could suffer
1161 // lock inversion against the pattern of getting the StackFrameList and
1162 // then the stack frame, which is fairly common.
1163 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
1164 if (IsHistorical()) {
1167 VariableList
*var_list
= GetVariableList(true, nullptr);
1169 // Make sure the variable is a frame variable
1170 const uint32_t var_idx
= var_list
->FindIndexForVariable(variable_sp
.get());
1171 const uint32_t num_variables
= var_list
->GetSize();
1172 if (var_idx
< num_variables
) {
1173 valobj_sp
= m_variable_list_value_objects
.GetValueObjectAtIndex(var_idx
);
1175 if (m_variable_list_value_objects
.GetSize() < num_variables
)
1176 m_variable_list_value_objects
.Resize(num_variables
);
1177 valobj_sp
= ValueObjectVariable::Create(this, variable_sp
);
1178 m_variable_list_value_objects
.SetValueObjectAtIndex(var_idx
,
1183 } // End of StackFrame mutex scope.
1184 if (use_dynamic
!= eNoDynamicValues
&& valobj_sp
) {
1185 ValueObjectSP dynamic_sp
= valobj_sp
->GetDynamicValue(use_dynamic
);
1192 bool StackFrame::IsInlined() {
1193 if (m_sc
.block
== nullptr)
1194 GetSymbolContext(eSymbolContextBlock
);
1196 return m_sc
.block
->GetContainingInlinedBlock() != nullptr;
1200 bool StackFrame::IsHistorical() const {
1201 return m_stack_frame_kind
== StackFrame::Kind::History
;
1204 bool StackFrame::IsArtificial() const {
1205 return m_stack_frame_kind
== StackFrame::Kind::Artificial
;
1208 lldb::LanguageType
StackFrame::GetLanguage() {
1209 CompileUnit
*cu
= GetSymbolContext(eSymbolContextCompUnit
).comp_unit
;
1211 return cu
->GetLanguage();
1212 return lldb::eLanguageTypeUnknown
;
1215 lldb::LanguageType
StackFrame::GuessLanguage() {
1216 LanguageType lang_type
= GetLanguage();
1218 if (lang_type
== eLanguageTypeUnknown
) {
1219 SymbolContext sc
= GetSymbolContext(eSymbolContextFunction
1220 | eSymbolContextSymbol
);
1222 lang_type
= sc
.function
->GetMangled().GuessLanguage();
1226 lang_type
= sc
.symbol
->GetMangled().GuessLanguage();
1234 std::pair
<const Instruction::Operand
*, int64_t>
1235 GetBaseExplainingValue(const Instruction::Operand
&operand
,
1236 RegisterContext
®ister_context
, lldb::addr_t value
) {
1237 switch (operand
.m_type
) {
1238 case Instruction::Operand::Type::Dereference
:
1239 case Instruction::Operand::Type::Immediate
:
1240 case Instruction::Operand::Type::Invalid
:
1241 case Instruction::Operand::Type::Product
:
1242 // These are not currently interesting
1243 return std::make_pair(nullptr, 0);
1244 case Instruction::Operand::Type::Sum
: {
1245 const Instruction::Operand
*immediate_child
= nullptr;
1246 const Instruction::Operand
*variable_child
= nullptr;
1247 if (operand
.m_children
[0].m_type
== Instruction::Operand::Type::Immediate
) {
1248 immediate_child
= &operand
.m_children
[0];
1249 variable_child
= &operand
.m_children
[1];
1250 } else if (operand
.m_children
[1].m_type
==
1251 Instruction::Operand::Type::Immediate
) {
1252 immediate_child
= &operand
.m_children
[1];
1253 variable_child
= &operand
.m_children
[0];
1255 if (!immediate_child
) {
1256 return std::make_pair(nullptr, 0);
1258 lldb::addr_t adjusted_value
= value
;
1259 if (immediate_child
->m_negative
) {
1260 adjusted_value
+= immediate_child
->m_immediate
;
1262 adjusted_value
-= immediate_child
->m_immediate
;
1264 std::pair
<const Instruction::Operand
*, int64_t> base_and_offset
=
1265 GetBaseExplainingValue(*variable_child
, register_context
,
1267 if (!base_and_offset
.first
) {
1268 return std::make_pair(nullptr, 0);
1270 if (immediate_child
->m_negative
) {
1271 base_and_offset
.second
-= immediate_child
->m_immediate
;
1273 base_and_offset
.second
+= immediate_child
->m_immediate
;
1275 return base_and_offset
;
1277 case Instruction::Operand::Type::Register
: {
1278 const RegisterInfo
*info
=
1279 register_context
.GetRegisterInfoByName(operand
.m_register
.AsCString());
1281 return std::make_pair(nullptr, 0);
1283 RegisterValue reg_value
;
1284 if (!register_context
.ReadRegister(info
, reg_value
)) {
1285 return std::make_pair(nullptr, 0);
1287 if (reg_value
.GetAsUInt64() == value
) {
1288 return std::make_pair(&operand
, 0);
1290 return std::make_pair(nullptr, 0);
1294 return std::make_pair(nullptr, 0);
1297 std::pair
<const Instruction::Operand
*, int64_t>
1298 GetBaseExplainingDereference(const Instruction::Operand
&operand
,
1299 RegisterContext
®ister_context
,
1300 lldb::addr_t addr
) {
1301 if (operand
.m_type
== Instruction::Operand::Type::Dereference
) {
1302 return GetBaseExplainingValue(operand
.m_children
[0], register_context
,
1305 return std::make_pair(nullptr, 0);
1309 lldb::ValueObjectSP
StackFrame::GuessValueForAddress(lldb::addr_t addr
) {
1310 TargetSP target_sp
= CalculateTarget();
1312 const ArchSpec
&target_arch
= target_sp
->GetArchitecture();
1314 AddressRange pc_range
;
1315 pc_range
.GetBaseAddress() = GetFrameCodeAddress();
1316 pc_range
.SetByteSize(target_arch
.GetMaximumOpcodeByteSize());
1318 const char *plugin_name
= nullptr;
1319 const char *flavor
= nullptr;
1320 const bool force_live_memory
= true;
1322 DisassemblerSP disassembler_sp
=
1323 Disassembler::DisassembleRange(target_arch
, plugin_name
, flavor
,
1324 *target_sp
, pc_range
, force_live_memory
);
1326 if (!disassembler_sp
|| !disassembler_sp
->GetInstructionList().GetSize()) {
1327 return ValueObjectSP();
1330 InstructionSP instruction_sp
=
1331 disassembler_sp
->GetInstructionList().GetInstructionAtIndex(0);
1333 llvm::SmallVector
<Instruction::Operand
, 3> operands
;
1335 if (!instruction_sp
->ParseOperands(operands
)) {
1336 return ValueObjectSP();
1339 RegisterContextSP register_context_sp
= GetRegisterContext();
1341 if (!register_context_sp
) {
1342 return ValueObjectSP();
1345 for (const Instruction::Operand
&operand
: operands
) {
1346 std::pair
<const Instruction::Operand
*, int64_t> base_and_offset
=
1347 GetBaseExplainingDereference(operand
, *register_context_sp
, addr
);
1349 if (!base_and_offset
.first
) {
1353 switch (base_and_offset
.first
->m_type
) {
1354 case Instruction::Operand::Type::Immediate
: {
1355 lldb_private::Address addr
;
1356 if (target_sp
->ResolveLoadAddress(base_and_offset
.first
->m_immediate
+
1357 base_and_offset
.second
,
1359 auto c_type_system_or_err
=
1360 target_sp
->GetScratchTypeSystemForLanguage(eLanguageTypeC
);
1361 if (auto err
= c_type_system_or_err
.takeError()) {
1362 LLDB_LOG_ERROR(GetLog(LLDBLog::Thread
), std::move(err
),
1363 "Unable to guess value for given address: {0}");
1364 return ValueObjectSP();
1366 auto ts
= *c_type_system_or_err
;
1369 CompilerType void_ptr_type
=
1370 ts
->GetBasicTypeFromAST(lldb::BasicType::eBasicTypeChar
)
1372 return ValueObjectMemory::Create(this, "", addr
, void_ptr_type
);
1375 return ValueObjectSP();
1379 case Instruction::Operand::Type::Register
: {
1380 return GuessValueForRegisterAndOffset(base_and_offset
.first
->m_register
,
1381 base_and_offset
.second
);
1384 return ValueObjectSP();
1388 return ValueObjectSP();
1392 ValueObjectSP
GetValueForOffset(StackFrame
&frame
, ValueObjectSP
&parent
,
1394 if (offset
< 0 || uint64_t(offset
) >= parent
->GetByteSize()) {
1395 return ValueObjectSP();
1398 if (parent
->IsPointerOrReferenceType()) {
1402 for (int ci
= 0, ce
= parent
->GetNumChildren(); ci
!= ce
; ++ci
) {
1403 ValueObjectSP child_sp
= parent
->GetChildAtIndex(ci
);
1406 return ValueObjectSP();
1409 int64_t child_offset
= child_sp
->GetByteOffset();
1410 int64_t child_size
= child_sp
->GetByteSize().value_or(0);
1412 if (offset
>= child_offset
&& offset
< (child_offset
+ child_size
)) {
1413 return GetValueForOffset(frame
, child_sp
, offset
- child_offset
);
1420 return ValueObjectSP();
1424 ValueObjectSP
GetValueForDereferincingOffset(StackFrame
&frame
,
1425 ValueObjectSP
&base
,
1427 // base is a pointer to something
1428 // offset is the thing to add to the pointer We return the most sensible
1429 // ValueObject for the result of *(base+offset)
1431 if (!base
->IsPointerOrReferenceType()) {
1432 return ValueObjectSP();
1436 ValueObjectSP pointee
= base
->Dereference(error
);
1439 return ValueObjectSP();
1442 if (offset
>= 0 && uint64_t(offset
) >= pointee
->GetByteSize()) {
1443 int64_t index
= offset
/ pointee
->GetByteSize().value_or(1);
1444 offset
= offset
% pointee
->GetByteSize().value_or(1);
1445 const bool can_create
= true;
1446 pointee
= base
->GetSyntheticArrayMember(index
, can_create
);
1449 if (!pointee
|| error
.Fail()) {
1450 return ValueObjectSP();
1453 return GetValueForOffset(frame
, pointee
, offset
);
1456 /// Attempt to reconstruct the ValueObject for the address contained in a
1457 /// given register plus an offset.
1459 /// \param [in] frame
1460 /// The current stack frame.
1465 /// \param [in] offset
1466 /// The offset from the register.
1468 /// \param [in] disassembler
1469 /// A disassembler containing instructions valid up to the current PC.
1471 /// \param [in] variables
1472 /// The variable list from the current frame,
1475 /// The program counter for the instruction considered the 'user'.
1478 /// A string describing the base for the ExpressionPath. This could be a
1479 /// variable, a register value, an argument, or a function return value.
1480 /// The ValueObject if found. If valid, it has a valid ExpressionPath.
1481 lldb::ValueObjectSP
DoGuessValueAt(StackFrame
&frame
, ConstString reg
,
1482 int64_t offset
, Disassembler
&disassembler
,
1483 VariableList
&variables
, const Address
&pc
) {
1484 // Example of operation for Intel:
1486 // +14: movq -0x8(%rbp), %rdi
1487 // +18: movq 0x8(%rdi), %rdi
1488 // +22: addl 0x4(%rdi), %eax
1490 // f, a pointer to a struct, is known to be at -0x8(%rbp).
1492 // DoGuessValueAt(frame, rdi, 4, dis, vars, 0x22) finds the instruction at
1493 // +18 that assigns to rdi, and calls itself recursively for that dereference
1494 // DoGuessValueAt(frame, rdi, 8, dis, vars, 0x18) finds the instruction at
1495 // +14 that assigns to rdi, and calls itself recursively for that
1497 // DoGuessValueAt(frame, rbp, -8, dis, vars, 0x14) finds "f" in the
1499 // Returns a ValueObject for f. (That's what was stored at rbp-8 at +14)
1500 // Returns a ValueObject for *(f+8) or f->b (That's what was stored at rdi+8
1502 // Returns a ValueObject for *(f->b+4) or f->b->a (That's what was stored at
1505 // First, check the variable list to see if anything is at the specified
1508 using namespace OperandMatchers
;
1510 const RegisterInfo
*reg_info
=
1511 frame
.GetRegisterContext()->GetRegisterInfoByName(reg
.AsCString());
1513 return ValueObjectSP();
1516 Instruction::Operand op
=
1517 offset
? Instruction::Operand::BuildDereference(
1518 Instruction::Operand::BuildSum(
1519 Instruction::Operand::BuildRegister(reg
),
1520 Instruction::Operand::BuildImmediate(offset
)))
1521 : Instruction::Operand::BuildDereference(
1522 Instruction::Operand::BuildRegister(reg
));
1524 for (VariableSP var_sp
: variables
) {
1525 if (var_sp
->LocationExpressionList().MatchesOperand(frame
, op
))
1526 return frame
.GetValueObjectForFrameVariable(var_sp
, eNoDynamicValues
);
1529 const uint32_t current_inst
=
1530 disassembler
.GetInstructionList().GetIndexOfInstructionAtAddress(pc
);
1531 if (current_inst
== UINT32_MAX
) {
1532 return ValueObjectSP();
1535 for (uint32_t ii
= current_inst
- 1; ii
!= (uint32_t)-1; --ii
) {
1536 // This is not an exact algorithm, and it sacrifices accuracy for
1537 // generality. Recognizing "mov" and "ld" instructions –– and which
1538 // are their source and destination operands -- is something the
1539 // disassembler should do for us.
1540 InstructionSP instruction_sp
=
1541 disassembler
.GetInstructionList().GetInstructionAtIndex(ii
);
1543 if (instruction_sp
->IsCall()) {
1544 ABISP abi_sp
= frame
.CalculateProcess()->GetABI();
1549 const char *return_register_name
;
1550 if (!abi_sp
->GetPointerReturnRegister(return_register_name
)) {
1554 const RegisterInfo
*return_register_info
=
1555 frame
.GetRegisterContext()->GetRegisterInfoByName(
1556 return_register_name
);
1557 if (!return_register_info
) {
1563 if (!MatchUnaryOp(MatchOpType(Instruction::Operand::Type::Dereference
),
1564 MatchRegOp(*return_register_info
))(op
) &&
1566 MatchOpType(Instruction::Operand::Type::Dereference
),
1567 MatchBinaryOp(MatchOpType(Instruction::Operand::Type::Sum
),
1568 MatchRegOp(*return_register_info
),
1569 FetchImmOp(offset
)))(op
)) {
1573 llvm::SmallVector
<Instruction::Operand
, 1> operands
;
1574 if (!instruction_sp
->ParseOperands(operands
) || operands
.size() != 1) {
1578 switch (operands
[0].m_type
) {
1581 case Instruction::Operand::Type::Immediate
: {
1583 Address load_address
;
1584 if (!frame
.CalculateTarget()->ResolveLoadAddress(
1585 operands
[0].m_immediate
, load_address
)) {
1588 frame
.CalculateTarget()->GetImages().ResolveSymbolContextForAddress(
1589 load_address
, eSymbolContextFunction
, sc
);
1593 CompilerType function_type
= sc
.function
->GetCompilerType();
1594 if (!function_type
.IsFunctionType()) {
1597 CompilerType return_type
= function_type
.GetFunctionReturnType();
1598 RegisterValue return_value
;
1599 if (!frame
.GetRegisterContext()->ReadRegister(return_register_info
,
1603 std::string
name_str(
1604 sc
.function
->GetName().AsCString("<unknown function>"));
1605 name_str
.append("()");
1606 Address
return_value_address(return_value
.GetAsUInt64());
1607 ValueObjectSP return_value_sp
= ValueObjectMemory::Create(
1608 &frame
, name_str
, return_value_address
, return_type
);
1609 return GetValueForDereferincingOffset(frame
, return_value_sp
, offset
);
1616 llvm::SmallVector
<Instruction::Operand
, 2> operands
;
1617 if (!instruction_sp
->ParseOperands(operands
) || operands
.size() != 2) {
1621 Instruction::Operand
*origin_operand
= nullptr;
1622 auto clobbered_reg_matcher
= [reg_info
](const Instruction::Operand
&op
) {
1623 return MatchRegOp(*reg_info
)(op
) && op
.m_clobbered
;
1626 if (clobbered_reg_matcher(operands
[0])) {
1627 origin_operand
= &operands
[1];
1629 else if (clobbered_reg_matcher(operands
[1])) {
1630 origin_operand
= &operands
[0];
1636 // We have an origin operand. Can we track its value down?
1637 ValueObjectSP source_path
;
1638 ConstString origin_register
;
1639 int64_t origin_offset
= 0;
1641 if (FetchRegOp(origin_register
)(*origin_operand
)) {
1642 source_path
= DoGuessValueAt(frame
, origin_register
, 0, disassembler
,
1643 variables
, instruction_sp
->GetAddress());
1644 } else if (MatchUnaryOp(
1645 MatchOpType(Instruction::Operand::Type::Dereference
),
1646 FetchRegOp(origin_register
))(*origin_operand
) ||
1648 MatchOpType(Instruction::Operand::Type::Dereference
),
1649 MatchBinaryOp(MatchOpType(Instruction::Operand::Type::Sum
),
1650 FetchRegOp(origin_register
),
1651 FetchImmOp(origin_offset
)))(*origin_operand
)) {
1653 DoGuessValueAt(frame
, origin_register
, origin_offset
, disassembler
,
1654 variables
, instruction_sp
->GetAddress());
1659 GetValueForDereferincingOffset(frame
, source_path
, offset
);
1667 return ValueObjectSP();
1671 lldb::ValueObjectSP
StackFrame::GuessValueForRegisterAndOffset(ConstString reg
,
1673 TargetSP target_sp
= CalculateTarget();
1675 const ArchSpec
&target_arch
= target_sp
->GetArchitecture();
1677 Block
*frame_block
= GetFrameBlock();
1680 return ValueObjectSP();
1683 Function
*function
= frame_block
->CalculateSymbolContextFunction();
1685 return ValueObjectSP();
1688 AddressRange pc_range
= function
->GetAddressRange();
1690 if (GetFrameCodeAddress().GetFileAddress() <
1691 pc_range
.GetBaseAddress().GetFileAddress() ||
1692 GetFrameCodeAddress().GetFileAddress() -
1693 pc_range
.GetBaseAddress().GetFileAddress() >=
1694 pc_range
.GetByteSize()) {
1695 return ValueObjectSP();
1698 const char *plugin_name
= nullptr;
1699 const char *flavor
= nullptr;
1700 const bool force_live_memory
= true;
1701 DisassemblerSP disassembler_sp
=
1702 Disassembler::DisassembleRange(target_arch
, plugin_name
, flavor
,
1703 *target_sp
, pc_range
, force_live_memory
);
1705 if (!disassembler_sp
|| !disassembler_sp
->GetInstructionList().GetSize()) {
1706 return ValueObjectSP();
1709 const bool get_file_globals
= false;
1710 VariableList
*variables
= GetVariableList(get_file_globals
, nullptr);
1713 return ValueObjectSP();
1716 return DoGuessValueAt(*this, reg
, offset
, *disassembler_sp
, *variables
,
1717 GetFrameCodeAddress());
1720 lldb::ValueObjectSP
StackFrame::FindVariable(ConstString name
) {
1721 ValueObjectSP value_sp
;
1726 TargetSP target_sp
= CalculateTarget();
1727 ProcessSP process_sp
= CalculateProcess();
1729 if (!target_sp
&& !process_sp
)
1732 VariableList variable_list
;
1734 SymbolContext
sc(GetSymbolContext(eSymbolContextBlock
));
1737 const bool can_create
= true;
1738 const bool get_parent_variables
= true;
1739 const bool stop_if_block_is_inlined_function
= true;
1741 if (sc
.block
->AppendVariables(
1742 can_create
, get_parent_variables
, stop_if_block_is_inlined_function
,
1743 [this](Variable
*v
) { return v
->IsInScope(this); },
1745 var_sp
= variable_list
.FindVariable(name
);
1749 value_sp
= GetValueObjectForFrameVariable(var_sp
, eNoDynamicValues
);
1755 TargetSP
StackFrame::CalculateTarget() {
1757 ThreadSP
thread_sp(GetThread());
1759 ProcessSP
process_sp(thread_sp
->CalculateProcess());
1761 target_sp
= process_sp
->CalculateTarget();
1766 ProcessSP
StackFrame::CalculateProcess() {
1767 ProcessSP process_sp
;
1768 ThreadSP
thread_sp(GetThread());
1770 process_sp
= thread_sp
->CalculateProcess();
1774 ThreadSP
StackFrame::CalculateThread() { return GetThread(); }
1776 StackFrameSP
StackFrame::CalculateStackFrame() { return shared_from_this(); }
1778 void StackFrame::CalculateExecutionContext(ExecutionContext
&exe_ctx
) {
1779 exe_ctx
.SetContext(shared_from_this());
1782 void StackFrame::DumpUsingSettingsFormat(Stream
*strm
, bool show_unique
,
1783 const char *frame_marker
) {
1784 if (strm
== nullptr)
1787 GetSymbolContext(eSymbolContextEverything
);
1788 ExecutionContext
exe_ctx(shared_from_this());
1792 s
.PutCString(frame_marker
);
1794 const FormatEntity::Entry
*frame_format
= nullptr;
1795 Target
*target
= exe_ctx
.GetTargetPtr();
1798 frame_format
= target
->GetDebugger().GetFrameFormatUnique();
1800 frame_format
= target
->GetDebugger().GetFrameFormat();
1803 if (frame_format
&& FormatEntity::Format(*frame_format
, s
, &m_sc
, &exe_ctx
,
1804 nullptr, nullptr, false, false)) {
1805 strm
->PutCString(s
.GetString());
1807 Dump(strm
, true, false);
1812 void StackFrame::Dump(Stream
*strm
, bool show_frame_index
,
1813 bool show_fullpaths
) {
1814 if (strm
== nullptr)
1817 if (show_frame_index
)
1818 strm
->Printf("frame #%u: ", m_frame_index
);
1819 ExecutionContext
exe_ctx(shared_from_this());
1820 Target
*target
= exe_ctx
.GetTargetPtr();
1821 strm
->Printf("0x%0*" PRIx64
" ",
1822 target
? (target
->GetArchitecture().GetAddressByteSize() * 2)
1824 GetFrameCodeAddress().GetLoadAddress(target
));
1825 GetSymbolContext(eSymbolContextEverything
);
1826 const bool show_module
= true;
1827 const bool show_inline
= true;
1828 const bool show_function_arguments
= true;
1829 const bool show_function_name
= true;
1830 m_sc
.DumpStopContext(strm
, exe_ctx
.GetBestExecutionContextScope(),
1831 GetFrameCodeAddress(), show_fullpaths
, show_module
,
1832 show_inline
, show_function_arguments
,
1833 show_function_name
);
1836 void StackFrame::UpdateCurrentFrameFromPreviousFrame(StackFrame
&prev_frame
) {
1837 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
1838 assert(GetStackID() ==
1839 prev_frame
.GetStackID()); // TODO: remove this after some testing
1840 m_variable_list_sp
= prev_frame
.m_variable_list_sp
;
1841 m_variable_list_value_objects
.Swap(prev_frame
.m_variable_list_value_objects
);
1842 if (!m_disassembly
.GetString().empty()) {
1843 m_disassembly
.Clear();
1844 m_disassembly
.PutCString(prev_frame
.m_disassembly
.GetString());
1848 void StackFrame::UpdatePreviousFrameFromCurrentFrame(StackFrame
&curr_frame
) {
1849 std::lock_guard
<std::recursive_mutex
> guard(m_mutex
);
1850 assert(GetStackID() ==
1851 curr_frame
.GetStackID()); // TODO: remove this after some testing
1852 m_id
.SetPC(curr_frame
.m_id
.GetPC()); // Update the Stack ID PC value
1853 assert(GetThread() == curr_frame
.GetThread());
1854 m_frame_index
= curr_frame
.m_frame_index
;
1855 m_concrete_frame_index
= curr_frame
.m_concrete_frame_index
;
1856 m_reg_context_sp
= curr_frame
.m_reg_context_sp
;
1857 m_frame_code_addr
= curr_frame
.m_frame_code_addr
;
1858 m_behaves_like_zeroth_frame
= curr_frame
.m_behaves_like_zeroth_frame
;
1859 assert(!m_sc
.target_sp
|| !curr_frame
.m_sc
.target_sp
||
1860 m_sc
.target_sp
.get() == curr_frame
.m_sc
.target_sp
.get());
1861 assert(!m_sc
.module_sp
|| !curr_frame
.m_sc
.module_sp
||
1862 m_sc
.module_sp
.get() == curr_frame
.m_sc
.module_sp
.get());
1863 assert(m_sc
.comp_unit
== nullptr || curr_frame
.m_sc
.comp_unit
== nullptr ||
1864 m_sc
.comp_unit
== curr_frame
.m_sc
.comp_unit
);
1865 assert(m_sc
.function
== nullptr || curr_frame
.m_sc
.function
== nullptr ||
1866 m_sc
.function
== curr_frame
.m_sc
.function
);
1867 m_sc
= curr_frame
.m_sc
;
1868 m_flags
.Clear(GOT_FRAME_BASE
| eSymbolContextEverything
);
1869 m_flags
.Set(m_sc
.GetResolvedMask());
1870 m_frame_base
.Clear();
1871 m_frame_base_error
.Clear();
1874 bool StackFrame::HasCachedData() const {
1875 if (m_variable_list_sp
)
1877 if (m_variable_list_value_objects
.GetSize() > 0)
1879 if (!m_disassembly
.GetString().empty())
1884 bool StackFrame::GetStatus(Stream
&strm
, bool show_frame_info
, bool show_source
,
1885 bool show_unique
, const char *frame_marker
) {
1886 if (show_frame_info
) {
1888 DumpUsingSettingsFormat(&strm
, show_unique
, frame_marker
);
1892 ExecutionContext
exe_ctx(shared_from_this());
1893 bool have_source
= false, have_debuginfo
= false;
1894 Debugger::StopDisassemblyType disasm_display
=
1895 Debugger::eStopDisassemblyTypeNever
;
1896 Target
*target
= exe_ctx
.GetTargetPtr();
1898 Debugger
&debugger
= target
->GetDebugger();
1899 const uint32_t source_lines_before
=
1900 debugger
.GetStopSourceLineCount(true);
1901 const uint32_t source_lines_after
=
1902 debugger
.GetStopSourceLineCount(false);
1903 disasm_display
= debugger
.GetStopDisassemblyDisplay();
1905 GetSymbolContext(eSymbolContextCompUnit
| eSymbolContextLineEntry
);
1906 if (m_sc
.comp_unit
&& m_sc
.line_entry
.IsValid()) {
1907 have_debuginfo
= true;
1908 if (source_lines_before
> 0 || source_lines_after
> 0) {
1909 uint32_t start_line
= m_sc
.line_entry
.line
;
1910 if (!start_line
&& m_sc
.function
) {
1911 FileSpec source_file
;
1912 m_sc
.function
->GetStartLineSourceInfo(source_file
, start_line
);
1916 target
->GetSourceManager().DisplaySourceLinesWithLineNumbers(
1917 m_sc
.line_entry
.file
, start_line
, m_sc
.line_entry
.column
,
1918 source_lines_before
, source_lines_after
, "->", &strm
);
1921 // TODO: Give here a one time warning if source file is missing.
1922 if (!m_sc
.line_entry
.line
) {
1923 ConstString fn_name
= m_sc
.GetFunctionName();
1925 if (!fn_name
.IsEmpty())
1927 "Note: this address is compiler-generated code in function "
1928 "%s that has no source code associated with it.",
1929 fn_name
.AsCString());
1931 strm
.Printf("Note: this address is compiler-generated code that "
1932 "has no source code associated with it.");
1937 switch (disasm_display
) {
1938 case Debugger::eStopDisassemblyTypeNever
:
1941 case Debugger::eStopDisassemblyTypeNoDebugInfo
:
1946 case Debugger::eStopDisassemblyTypeNoSource
:
1951 case Debugger::eStopDisassemblyTypeAlways
:
1953 const uint32_t disasm_lines
= debugger
.GetDisassemblyLineCount();
1954 if (disasm_lines
> 0) {
1955 const ArchSpec
&target_arch
= target
->GetArchitecture();
1956 const char *plugin_name
= nullptr;
1957 const char *flavor
= nullptr;
1958 const bool mixed_source_and_assembly
= false;
1959 Disassembler::Disassemble(
1960 target
->GetDebugger(), target_arch
, plugin_name
, flavor
,
1961 exe_ctx
, GetFrameCodeAddress(),
1962 {Disassembler::Limit::Instructions
, disasm_lines
},
1963 mixed_source_and_assembly
, 0,
1964 Disassembler::eOptionMarkPCAddress
, strm
);
1974 RecognizedStackFrameSP
StackFrame::GetRecognizedFrame() {
1975 if (!m_recognized_frame_sp
) {
1976 m_recognized_frame_sp
= GetThread()
1979 .GetFrameRecognizerManager()
1980 .RecognizeFrame(CalculateStackFrame());
1982 return m_recognized_frame_sp
;