ValueObjectSP GoUserExpression::GoInterpreter::VisitIndexExpr(const lldb_private::GoASTIndexExpr *e) { ValueObjectSP target = EvaluateExpr(e->GetX()); if (!target) return nullptr; ValueObjectSP index = EvaluateExpr(e->GetIndex()); if (!index) return nullptr; bool is_signed; if (!index->GetCompilerType().IsIntegerType(is_signed)) { m_error.SetErrorString("Unsupported index"); return nullptr; } size_t idx; if (is_signed) idx = index->GetValueAsSigned(0); else idx = index->GetValueAsUnsigned(0); if (GoASTContext::IsGoSlice(target->GetCompilerType())) { target = target->GetStaticValue(); ValueObjectSP cap = target->GetChildMemberWithName(ConstString("cap"), true); if (cap) { uint64_t capval = cap->GetValueAsUnsigned(0); if (idx >= capval) { m_error.SetErrorStringWithFormat("Invalid index %" PRIu64 " , cap = %" PRIu64, uint64_t(idx), capval); return nullptr; } } target = target->GetChildMemberWithName(ConstString("array"), true); if (target && m_use_dynamic != eNoDynamicValues) { ValueObjectSP dynamic = target->GetDynamicValue(m_use_dynamic); if (dynamic) target = dynamic; } if (!target) return nullptr; return target->GetSyntheticArrayMember(idx, true); } return target->GetChildAtIndex(idx, true); }
ValueObjectSP GoUserExpression::GoInterpreter::VisitSelectorExpr(const lldb_private::GoASTSelectorExpr *e) { ValueObjectSP target = EvaluateExpr(e->GetX()); if (target) { if (target->GetCompilerType().IsPointerType()) { target = target->Dereference(m_error); if (m_error.Fail()) return nullptr; } ConstString field(e->GetSel()->GetName().m_value); ValueObjectSP result = target->GetChildMemberWithName(field, true); if (!result) m_error.SetErrorStringWithFormat("Unknown child %s", field.AsCString()); return result; } if (const GoASTIdent *package = llvm::dyn_cast<GoASTIdent>(e->GetX())) { if (VariableSP global = FindGlobalVariable(m_exe_ctx.GetTargetSP(), package->GetName().m_value + "." + e->GetSel()->GetName().m_value)) { if (m_frame) { m_error.Clear(); return m_frame->GetValueObjectForFrameVariable(global, m_use_dynamic); } } } if (const GoASTBasicLit *packageLit = llvm::dyn_cast<GoASTBasicLit>(e->GetX())) { if (packageLit->GetValue().m_type == GoLexer::LIT_STRING) { std::string value = packageLit->GetValue().m_value.str(); value = value.substr(1, value.size() - 2); if (VariableSP global = FindGlobalVariable(m_exe_ctx.GetTargetSP(), value + "." + e->GetSel()->GetName().m_value)) { if (m_frame) { m_error.Clear(); return m_frame->TrackGlobalVariable(global, m_use_dynamic); } } } } // EvaluateExpr should have already set m_error. return target; }
OperatingSystemGo::Goroutine OperatingSystemGo::CreateGoroutineAtIndex(uint64_t idx, Error &err) { err.Clear(); Goroutine result; ValueObjectSP g = m_allg_sp->GetSyntheticArrayMember(idx, true)->Dereference(err); if (err.Fail()) { return result; } ConstString name("goid"); ValueObjectSP val = g->GetChildMemberWithName(name, true); bool success = false; result.m_goid = val->GetValueAsUnsigned(0, &success); if (!success) { err.SetErrorToGenericError(); err.SetErrorString("unable to read goid"); return result; } name.SetCString("atomicstatus"); val = g->GetChildMemberWithName(name, true); result.m_status = (uint32_t)val->GetValueAsUnsigned(0, &success); if (!success) { err.SetErrorToGenericError(); err.SetErrorString("unable to read atomicstatus"); return result; } name.SetCString("sched"); val = g->GetChildMemberWithName(name, true); result.m_gobuf = val->GetAddressOf(false); name.SetCString("stack"); val = g->GetChildMemberWithName(name, true); name.SetCString("lo"); ValueObjectSP child = val->GetChildMemberWithName(name, true); result.m_lostack = child->GetValueAsUnsigned(0, &success); if (!success) { err.SetErrorToGenericError(); err.SetErrorString("unable to read stack.lo"); return result; } name.SetCString("hi"); child = val->GetChildMemberWithName(name, true); result.m_histack = child->GetValueAsUnsigned(0, &success); if (!success) { err.SetErrorToGenericError(); err.SetErrorString("unable to read stack.hi"); return result; } return result; }
bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() { if (m_element_type.GetOpaqueQualType() && m_element_type.GetTypeSystem()) return true; m_element_type.Clear(); ValueObjectSP deref; Error error; deref = m_root_node->Dereference(error); if (!deref || error.Fail()) return false; deref = deref->GetChildMemberWithName(ConstString("__value_"), true); if (!deref) return false; m_element_type = deref->GetCompilerType(); return true; }
bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() { static ConstString g___value_("__value_"); static ConstString g_tree_("__tree_"); static ConstString g_pair3("__pair3_"); if (m_element_type.GetOpaqueQualType() && m_element_type.GetTypeSystem()) return true; m_element_type.Clear(); ValueObjectSP deref; Status error; deref = m_root_node->Dereference(error); if (!deref || error.Fail()) return false; deref = deref->GetChildMemberWithName(g___value_, true); if (deref) { m_element_type = deref->GetCompilerType(); return true; } deref = m_backend.GetChildAtNamePath({g_tree_, g_pair3}); if (!deref) return false; m_element_type = deref->GetCompilerType() .GetTypeTemplateArgument(1) .GetTypeTemplateArgument(1); if (m_element_type) { std::string name; uint64_t bit_offset_ptr; uint32_t bitfield_bit_size_ptr; bool is_bitfield_ptr; m_element_type = m_element_type.GetFieldAtIndex( 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); m_element_type = m_element_type.GetTypedefedType(); return m_element_type.IsValid(); } else { m_element_type = m_backend.GetCompilerType().GetTypeTemplateArgument(0); return m_element_type.IsValid(); } }