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,
56 bool behaves_like_zeroth_frame,
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() {
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,
81 const RegisterContextSP ®_context_sp,
addr_t cfa,
82 addr_t pc,
bool behaves_like_zeroth_frame,
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),
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,
107 const RegisterContextSP ®_context_sp,
addr_t cfa,
108 const Address &pc_addr,
bool behaves_like_zeroth_frame,
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;
146 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
159 if (scope ==
nullptr) {
178 return thread_sp->GetStackFrameList()->GetVisibleStackFrameIndex(
185 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
191 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
200 TargetSP target_sp(thread_sp->CalculateTarget());
202 const bool allow_section_end =
true;
248 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
257 thread_sp->ClearStackFrames();
262 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
301 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
303 if ((
m_flags.
Get() & resolve_scope) != resolve_scope) {
310 resolved |= eSymbolContextTarget;
329 SymbolContextItem actual_resolve_scope = SymbolContextItem(0);
331 if (resolve_scope & eSymbolContextCompUnit) {
334 resolved |= eSymbolContextCompUnit;
336 actual_resolve_scope |= eSymbolContextCompUnit;
340 if (resolve_scope & eSymbolContextFunction) {
343 resolved |= eSymbolContextFunction;
345 actual_resolve_scope |= eSymbolContextFunction;
349 if (resolve_scope & eSymbolContextBlock) {
352 resolved |= eSymbolContextBlock;
354 actual_resolve_scope |= eSymbolContextBlock;
358 if (resolve_scope & eSymbolContextSymbol) {
361 resolved |= eSymbolContextSymbol;
363 actual_resolve_scope |= eSymbolContextSymbol;
367 if (resolve_scope & eSymbolContextLineEntry) {
370 resolved |= eSymbolContextLineEntry;
372 actual_resolve_scope |= eSymbolContextLineEntry;
376 if (actual_resolve_scope) {
383 lookup_addr, actual_resolve_scope, sc);
387 if ((resolved & eSymbolContextCompUnit) &&
m_sc.
comp_unit ==
nullptr)
389 if ((resolved & eSymbolContextFunction) &&
m_sc.
function ==
nullptr)
391 if ((resolved & eSymbolContextBlock) &&
m_sc.
block ==
nullptr)
393 if ((resolved & eSymbolContextSymbol) &&
m_sc.
symbol ==
nullptr)
395 if ((resolved & eSymbolContextLineEntry) &&
406 resolved |=
m_sc.
target_sp->GetImages().ResolveSymbolContextForAddress(
407 lookup_addr, resolve_scope,
m_sc);
426 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
434 const bool get_child_variables =
true;
435 const bool can_create =
true;
436 const bool stop_if_child_block_is_inlined_function =
true;
438 stop_if_child_block_is_inlined_function,
451 VariableListSP global_variable_list_sp(
476 bool must_have_valid_location) {
477 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
480 return VariableListSP();
486 const bool can_create =
true;
487 const bool get_parent_variables =
true;
488 const bool stop_if_block_is_inlined_function =
true;
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 ||
499 VariableListSP global_variable_list_sp(
501 if (global_variable_list_sp)
502 var_list_sp->AddVariables(global_variable_list_sp.get());
511 llvm::StringRef original_var_expr = var_expr;
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 =
524 const bool no_fragile_ivar =
526 const bool no_synth_child =
532 bool address_of =
false;
533 ValueObjectSP valobj_sp;
534 const bool get_file_globals =
true;
541 return ValueObjectSP();
545 if (var_expr[0] ==
'*') {
547 var_expr = var_expr.drop_front();
548 }
else if (var_expr[0] ==
'&') {
550 var_expr = var_expr.drop_front();
553 size_t separator_idx = var_expr.find_first_of(
".-[=+~|&^%#@!/?,<>{}");
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());
571 bool is_instance_method =
false;
574 method_object_name)) {
575 if (is_instance_method && method_object_name) {
576 var_sp = variable_list->
FindVariable(method_object_name);
579 if (
Type *var_type = var_sp->GetType())
580 if (
auto compiler_type = var_type->GetForwardCompilerType())
581 if (!compiler_type.IsPointerType())
582 var_expr_storage =
".";
584 if (var_expr_storage.empty())
585 var_expr_storage =
"->";
586 var_expr_storage += var_expr;
587 var_expr = var_expr_storage;
588 synthetically_added_instance_object =
true;
597 for (
const VariableSP &variable_sp : *variable_list) {
600 if (!variable_sp->GetName().IsEmpty())
603 Type *var_type = variable_sp->GetType();
612 valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string,
true);
618 if (var_sp && !valobj_sp) {
624 error.SetErrorStringWithFormat(
"no variable named '%s' found in this frame",
626 return ValueObjectSP();
630 while (!var_expr.empty()) {
632 ValueObjectSP child_valobj_sp;
633 const char separator_type = var_expr[0];
634 bool expr_is_ptr =
false;
635 switch (separator_type) {
638 if (var_expr.size() >= 2 && var_expr[1] !=
'>')
639 return ValueObjectSP();
641 if (no_fragile_ivar) {
645 valobj_sp->GetCompilerType().GetTypeInfo(
nullptr);
646 if ((pointer_type_flags & eTypeIsObjC) &&
647 (pointer_type_flags & eTypeIsPointer)) {
650 return ValueObjectSP();
656 if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) {
658 if (valobj_sp->GetCompilerType().IsReferenceType()) {
659 valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
661 error.SetErrorStringWithFormatv(
662 "Failed to dereference reference type: %s", deref_error);
663 return ValueObjectSP();
667 valobj_sp = valobj_sp->Dereference(deref_error);
669 error.SetErrorStringWithFormatv(
670 "Failed to dereference sythetic value: {0}", deref_error);
671 return ValueObjectSP();
675 error.SetErrorString(
"Failed to dereference sythetic value");
676 return ValueObjectSP();
681 var_expr = var_expr.drop_front();
684 var_expr = var_expr.drop_front();
685 separator_idx = var_expr.find_first_of(
".-[");
686 ConstString child_name(var_expr.substr(0, var_expr.find_first_of(
".-[")));
688 if (check_ptr_vs_member) {
692 const bool actual_is_ptr = valobj_sp->IsPointerType();
694 if (actual_is_ptr != expr_is_ptr) {
697 valobj_sp->GetExpressionPath(var_expr_path_strm);
699 error.SetErrorStringWithFormat(
700 "\"%s\" is a pointer and . was used to attempt to access "
701 "\"%s\". Did you mean \"%s->%s\"?",
703 var_expr_path_strm.
GetData(), var_expr.str().c_str());
705 error.SetErrorStringWithFormat(
706 "\"%s\" is not a pointer and -> was used to attempt to "
707 "access \"%s\". Did you mean \"%s.%s\"?",
709 var_expr_path_strm.
GetData(), var_expr.str().c_str());
710 return ValueObjectSP();
713 child_valobj_sp = valobj_sp->GetChildMemberWithName(child_name,
true);
714 if (!child_valobj_sp) {
715 if (!no_synth_child) {
716 child_valobj_sp = valobj_sp->GetSyntheticValue();
719 child_valobj_sp->GetChildMemberWithName(child_name,
true);
722 if (no_synth_child || !child_valobj_sp) {
724 if (synthetically_added_instance_object) {
728 error.SetErrorStringWithFormat(
729 "no variable or instance variable named '%s' found in "
733 valobj_sp->GetExpressionPath(var_expr_path_strm);
735 error.SetErrorStringWithFormat(
736 "\"%s\" is not a member of \"(%s) %s\"",
738 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
741 error.SetErrorStringWithFormat(
742 "incomplete expression path after \"%s\" in \"%s\"",
744 original_var_expr.str().c_str());
747 return ValueObjectSP();
750 synthetically_added_instance_object =
false;
752 var_expr = var_expr.drop_front(child_name.
GetLength());
754 ValueObjectSP dynamic_value_sp(
755 child_valobj_sp->GetDynamicValue(use_dynamic));
756 if (dynamic_value_sp)
757 child_valobj_sp = dynamic_value_sp;
764 if (var_expr.size() <= 2) {
765 error.SetErrorStringWithFormat(
766 "invalid square bracket encountered after \"%s\" in \"%s\"",
767 var_expr_path_strm.
GetData(), var_expr.str().c_str());
768 return ValueObjectSP();
772 var_expr = var_expr.drop_front();
773 long child_index = 0;
776 size_t end_pos = var_expr.find_first_of(
']');
777 if (end_pos == llvm::StringRef::npos) {
778 error.SetErrorStringWithFormat(
779 "missing closing square bracket in expression \"%s\"",
781 return ValueObjectSP();
783 llvm::StringRef index_expr = var_expr.take_front(end_pos);
784 llvm::StringRef original_index_expr = index_expr;
786 var_expr = var_expr.drop_front(end_pos + 1);
788 if (index_expr.consumeInteger(0, child_index)) {
791 error.SetErrorStringWithFormat(
"invalid index expression \"%s\"",
792 index_expr.str().c_str());
793 return ValueObjectSP();
796 if (index_expr.empty()) {
799 if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref) {
804 ValueObjectSP temp(valobj_sp->Dereference(
error));
806 valobj_sp->GetExpressionPath(var_expr_path_strm);
807 error.SetErrorStringWithFormat(
808 "could not dereference \"(%s) %s\"",
809 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
811 return ValueObjectSP();
815 }
else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() &&
822 ValueObjectSP temp(valobj_sp->GetChildAtIndex(0,
true));
824 valobj_sp->GetExpressionPath(var_expr_path_strm);
825 error.SetErrorStringWithFormat(
826 "could not get item 0 for \"(%s) %s\"",
827 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
829 return ValueObjectSP();
835 bool is_incomplete_array =
false;
836 if (valobj_sp->IsPointerType()) {
837 bool is_objc_pointer =
true;
839 if (valobj_sp->GetCompilerType().GetMinimumLanguage() !=
841 is_objc_pointer =
false;
842 else if (!valobj_sp->GetCompilerType().IsPointerType())
843 is_objc_pointer =
false;
845 if (no_synth_child && is_objc_pointer) {
846 error.SetErrorStringWithFormat(
847 "\"(%s) %s\" is an Objective-C pointer, and cannot be "
849 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
852 return ValueObjectSP();
853 }
else if (is_objc_pointer) {
856 ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
858 || synthetic == valobj_sp)
861 valobj_sp->GetExpressionPath(var_expr_path_strm);
862 error.SetErrorStringWithFormat(
863 "\"(%s) %s\" is not an array type",
864 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
867 static_cast<uint32_t>(child_index) >=
869 ->GetNumChildren() ) {
870 valobj_sp->GetExpressionPath(var_expr_path_strm);
871 error.SetErrorStringWithFormat(
872 "array index %ld is not valid for \"(%s) %s\"", child_index,
873 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
876 child_valobj_sp = synthetic->GetChildAtIndex(child_index,
true);
877 if (!child_valobj_sp) {
878 valobj_sp->GetExpressionPath(var_expr_path_strm);
879 error.SetErrorStringWithFormat(
880 "array index %ld is not valid for \"(%s) %s\"", child_index,
881 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
887 valobj_sp->GetSyntheticArrayMember(child_index,
true);
888 if (!child_valobj_sp) {
889 valobj_sp->GetExpressionPath(var_expr_path_strm);
890 error.SetErrorStringWithFormat(
891 "failed to use pointer as array for index %ld for "
894 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
898 }
else if (valobj_sp->GetCompilerType().IsArrayType(
899 nullptr,
nullptr, &is_incomplete_array)) {
902 child_valobj_sp = valobj_sp->GetChildAtIndex(child_index,
true);
903 if (!child_valobj_sp && (is_incomplete_array || !no_synth_child))
905 valobj_sp->GetSyntheticArrayMember(child_index,
true);
907 if (!child_valobj_sp) {
908 valobj_sp->GetExpressionPath(var_expr_path_strm);
909 error.SetErrorStringWithFormat(
910 "array index %ld is not valid for \"(%s) %s\"", child_index,
911 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
914 }
else if (valobj_sp->GetCompilerType().IsScalarType()) {
916 child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(
917 child_index, child_index,
true);
918 if (!child_valobj_sp) {
919 valobj_sp->GetExpressionPath(var_expr_path_strm);
920 error.SetErrorStringWithFormat(
921 "bitfield range %ld-%ld is not valid for \"(%s) %s\"",
922 child_index, child_index,
923 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
927 ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
928 if (no_synth_child ||
930 || synthetic == valobj_sp)
933 valobj_sp->GetExpressionPath(var_expr_path_strm);
934 error.SetErrorStringWithFormat(
935 "\"(%s) %s\" is not an array type",
936 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
939 static_cast<uint32_t>(child_index) >=
941 ->GetNumChildren() ) {
942 valobj_sp->GetExpressionPath(var_expr_path_strm);
943 error.SetErrorStringWithFormat(
944 "array index %ld is not valid for \"(%s) %s\"", child_index,
945 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
948 child_valobj_sp = synthetic->GetChildAtIndex(child_index,
true);
949 if (!child_valobj_sp) {
950 valobj_sp->GetExpressionPath(var_expr_path_strm);
951 error.SetErrorStringWithFormat(
952 "array index %ld is not valid for \"(%s) %s\"", child_index,
953 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
959 if (!child_valobj_sp) {
961 return ValueObjectSP();
965 ValueObjectSP dynamic_value_sp(
966 child_valobj_sp->GetDynamicValue(use_dynamic));
967 if (dynamic_value_sp)
968 child_valobj_sp = dynamic_value_sp;
976 if (index_expr.front() !=
'-') {
977 error.SetErrorStringWithFormat(
"invalid range expression \"'%s'\"",
978 original_index_expr.str().c_str());
979 return ValueObjectSP();
982 index_expr = index_expr.drop_front();
983 long final_index = 0;
984 if (index_expr.getAsInteger(0, final_index)) {
985 error.SetErrorStringWithFormat(
"invalid range expression \"'%s'\"",
986 original_index_expr.str().c_str());
987 return ValueObjectSP();
991 if (child_index > final_index) {
992 long temp = child_index;
993 child_index = final_index;
997 if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref) {
1003 ValueObjectSP temp(valobj_sp->Dereference(
error));
1005 valobj_sp->GetExpressionPath(var_expr_path_strm);
1006 error.SetErrorStringWithFormat(
1007 "could not dereference \"(%s) %s\"",
1008 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
1009 var_expr_path_strm.
GetData());
1010 return ValueObjectSP();
1014 }
else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref) {
1020 ValueObjectSP temp(valobj_sp->GetChildAtIndex(0,
true));
1022 valobj_sp->GetExpressionPath(var_expr_path_strm);
1023 error.SetErrorStringWithFormat(
1024 "could not get item 0 for \"(%s) %s\"",
1025 valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
1026 var_expr_path_strm.
GetData());
1027 return ValueObjectSP();
1034 valobj_sp->GetSyntheticBitFieldChild(child_index, final_index,
true);
1035 if (!child_valobj_sp) {
1036 valobj_sp->GetExpressionPath(var_expr_path_strm);
1037 error.SetErrorStringWithFormat(
1038 "bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index,
1039 final_index, valobj_sp->GetTypeName().AsCString(
"<invalid type>"),
1040 var_expr_path_strm.
GetData());
1043 if (!child_valobj_sp) {
1045 return ValueObjectSP();
1049 ValueObjectSP dynamic_value_sp(
1050 child_valobj_sp->GetDynamicValue(use_dynamic));
1051 if (dynamic_value_sp)
1052 child_valobj_sp = dynamic_value_sp;
1061 valobj_sp->GetExpressionPath(var_expr_path_strm);
1062 error.SetErrorStringWithFormat(
1063 "unexpected char '%c' encountered after \"%s\" in \"%s\"",
1064 separator_type, var_expr_path_strm.
GetData(),
1065 var_expr.str().c_str());
1067 return ValueObjectSP();
1071 if (child_valobj_sp)
1072 valobj_sp = child_valobj_sp;
1076 ValueObjectSP deref_valobj_sp(valobj_sp->Dereference(
error));
1077 valobj_sp = deref_valobj_sp;
1078 }
else if (address_of) {
1079 ValueObjectSP address_of_valobj_sp(valobj_sp->AddressOf(
error));
1080 valobj_sp = address_of_valobj_sp;
1087 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1090 "No frame base available for this historical stack frame.");
1109 &exe_ctx,
nullptr, loclist_base_addr,
nullptr,
nullptr,
1115 "Evaluation of the frame base expression failed.");
1144 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1161 ValueObjectSP valobj_sp;
1168 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1177 if (var_idx < num_variables) {
1190 ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue(use_dynamic);
1225 | eSymbolContextSymbol);
1239 std::pair<const Instruction::Operand *, int64_t>
1242 switch (operand.
m_type) {
1248 return std::make_pair(
nullptr, 0);
1260 if (!immediate_child) {
1261 return std::make_pair(
nullptr, 0);
1269 std::pair<const Instruction::Operand *, int64_t> base_and_offset =
1270 GetBaseExplainingValue(*variable_child, register_context,
1272 if (!base_and_offset.first) {
1273 return std::make_pair(
nullptr, 0);
1276 base_and_offset.second -= immediate_child->
m_immediate;
1278 base_and_offset.second += immediate_child->
m_immediate;
1280 return base_and_offset;
1283 const RegisterInfo *info =
1286 return std::make_pair(
nullptr, 0);
1290 return std::make_pair(
nullptr, 0);
1293 return std::make_pair(&operand, 0);
1295 return std::make_pair(
nullptr, 0);
1299 return std::make_pair(
nullptr, 0);
1302 std::pair<const Instruction::Operand *, int64_t>
1307 return GetBaseExplainingValue(operand.
m_children[0], register_context,
1310 return std::make_pair(
nullptr, 0);
1317 const ArchSpec &target_arch = target_sp->GetArchitecture();
1323 const char *plugin_name =
nullptr;
1324 const char *flavor =
nullptr;
1325 const bool force_live_memory =
true;
1327 DisassemblerSP disassembler_sp =
1329 *target_sp, pc_range, force_live_memory);
1331 if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) {
1332 return ValueObjectSP();
1335 InstructionSP instruction_sp =
1336 disassembler_sp->GetInstructionList().GetInstructionAtIndex(0);
1338 llvm::SmallVector<Instruction::Operand, 3> operands;
1340 if (!instruction_sp->ParseOperands(operands)) {
1341 return ValueObjectSP();
1346 if (!register_context_sp) {
1347 return ValueObjectSP();
1351 std::pair<const Instruction::Operand *, int64_t> base_and_offset =
1352 GetBaseExplainingDereference(operand, *register_context_sp, addr);
1354 if (!base_and_offset.first) {
1358 switch (base_and_offset.first->m_type) {
1361 if (target_sp->ResolveLoadAddress(base_and_offset.first->m_immediate +
1362 base_and_offset.second,
1364 auto c_type_system_or_err =
1366 if (
auto err = c_type_system_or_err.takeError()) {
1368 "Unable to guess value for given address");
1369 return ValueObjectSP();
1371 auto ts = *c_type_system_or_err;
1380 return ValueObjectSP();
1386 base_and_offset.second);
1389 return ValueObjectSP();
1393 return ValueObjectSP();
1397 ValueObjectSP GetValueForOffset(
StackFrame &frame, ValueObjectSP &parent,
1399 if (offset < 0 || uint64_t(offset) >= parent->GetByteSize()) {
1400 return ValueObjectSP();
1403 if (parent->IsPointerOrReferenceType()) {
1407 for (
int ci = 0, ce = parent->GetNumChildren(); ci != ce; ++ci) {
1408 const bool can_create =
true;
1409 ValueObjectSP child_sp = parent->GetChildAtIndex(ci, can_create);
1412 return ValueObjectSP();
1415 int64_t child_offset = child_sp->GetByteOffset();
1416 int64_t child_size = child_sp->GetByteSize().value_or(0);
1418 if (offset >= child_offset && offset < (child_offset + child_size)) {
1419 return GetValueForOffset(frame, child_sp, offset - child_offset);
1426 return ValueObjectSP();
1430 ValueObjectSP GetValueForDereferincingOffset(
StackFrame &frame,
1431 ValueObjectSP &base,
1437 if (!base->IsPointerOrReferenceType()) {
1438 return ValueObjectSP();
1442 ValueObjectSP pointee = base->Dereference(
error);
1445 return ValueObjectSP();
1448 if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) {
1449 int64_t index = offset / pointee->GetByteSize().value_or(1);
1450 offset = offset % pointee->GetByteSize().value_or(1);
1451 const bool can_create =
true;
1452 pointee = base->GetSyntheticArrayMember(index, can_create);
1455 if (!pointee ||
error.Fail()) {
1456 return ValueObjectSP();
1459 return GetValueForOffset(frame, pointee, offset);
1514 using namespace OperandMatchers;
1516 const RegisterInfo *reg_info =
1519 return ValueObjectSP();
1530 for (VariableSP var_sp : variables) {
1531 if (var_sp->LocationExpressionList().MatchesOperand(frame, op))
1538 return ValueObjectSP();
1546 InstructionSP instruction_sp =
1549 if (instruction_sp->IsCall()) {
1555 const char *return_register_name;
1556 if (!abi_sp->GetPointerReturnRegister(return_register_name)) {
1560 const RegisterInfo *return_register_info =
1562 return_register_name);
1563 if (!return_register_info) {
1579 llvm::SmallVector<Instruction::Operand, 1> operands;
1580 if (!instruction_sp->ParseOperands(operands) || operands.size() != 1) {
1584 switch (operands[0].m_type) {
1591 operands[0].m_immediate, load_address)) {
1595 load_address, eSymbolContextFunction, sc);
1611 name_str.append(
"()");
1614 &frame, name_str, return_value_address, return_type);
1615 return GetValueForDereferincingOffset(frame, return_value_sp, offset);
1622 llvm::SmallVector<Instruction::Operand, 2> operands;
1623 if (!instruction_sp->ParseOperands(operands) || operands.size() != 2) {
1632 if (clobbered_reg_matcher(operands[0])) {
1633 origin_operand = &operands[1];
1635 else if (clobbered_reg_matcher(operands[1])) {
1636 origin_operand = &operands[0];
1643 ValueObjectSP source_path;
1645 int64_t origin_offset = 0;
1647 if (
FetchRegOp(origin_register)(*origin_operand)) {
1648 source_path = DoGuessValueAt(frame, origin_register, 0, disassembler,
1649 variables, instruction_sp->GetAddress());
1652 FetchRegOp(origin_register))(*origin_operand) ||
1657 FetchImmOp(origin_offset)))(*origin_operand)) {
1659 DoGuessValueAt(frame, origin_register, origin_offset, disassembler,
1660 variables, instruction_sp->GetAddress());
1665 GetValueForDereferincingOffset(frame, source_path, offset);
1673 return ValueObjectSP();
1681 const ArchSpec &target_arch = target_sp->GetArchitecture();
1686 return ValueObjectSP();
1691 return ValueObjectSP();
1701 return ValueObjectSP();
1704 const char *plugin_name =
nullptr;
1705 const char *flavor =
nullptr;
1706 const bool force_live_memory =
true;
1707 DisassemblerSP disassembler_sp =
1709 *target_sp, pc_range, force_live_memory);
1711 if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) {
1712 return ValueObjectSP();
1715 const bool get_file_globals =
false;
1719 return ValueObjectSP();
1722 return DoGuessValueAt(*
this, reg, offset, *disassembler_sp, *variables,
1727 ValueObjectSP value_sp;
1735 if (!target_sp && !process_sp)
1743 const bool can_create =
true;
1744 const bool get_parent_variables =
true;
1745 const bool stop_if_block_is_inlined_function =
true;
1748 can_create, get_parent_variables, stop_if_block_is_inlined_function,
1749 [
this](
Variable *v) { return v->IsInScope(this); },
1765 ProcessSP process_sp(thread_sp->CalculateProcess());
1767 target_sp = process_sp->CalculateTarget();
1773 ProcessSP process_sp;
1776 process_sp = thread_sp->CalculateProcess();
1789 const char *frame_marker) {
1790 if (strm ==
nullptr)
1810 nullptr,
nullptr,
false,
false)) {
1813 Dump(strm,
true,
false);
1819 bool show_fullpaths) {
1820 if (strm ==
nullptr)
1823 if (show_frame_index)
1827 strm->
Printf(
"0x%0*" PRIx64
" ",
1832 const bool show_module =
true;
1833 const bool show_inline =
true;
1834 const bool show_function_arguments =
true;
1835 const bool show_function_name =
true;
1838 show_inline, show_function_arguments,
1839 show_function_name);
1843 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1855 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1891 bool show_unique,
const char *frame_marker) {
1892 if (show_frame_info) {
1899 bool have_source =
false, have_debuginfo =
false;
1905 const uint32_t source_lines_before =
1907 const uint32_t source_lines_after =
1913 have_debuginfo =
true;
1914 if (source_lines_before > 0 || source_lines_after > 0) {
1924 source_lines_before, source_lines_after,
"->", &strm);
1933 "Note: this address is compiler-generated code in function "
1934 "%s that has no source code associated with it.",
1937 strm.
Printf(
"Note: this address is compiler-generated code that "
1938 "has no source code associated with it.");
1943 switch (disasm_display) {
1960 if (disasm_lines > 0) {
1962 const char *plugin_name =
nullptr;
1963 const char *flavor =
nullptr;
1964 const bool mixed_source_and_assembly =
false;
1966 target->
GetDebugger(), target_arch, plugin_name, flavor,
1969 mixed_source_and_assembly, 0,
1985 .GetFrameRecognizerManager()