bool lldb_private::formatters::BlockPointerSummaryProvider( ValueObject &valobj, Stream &s, const TypeSummaryOptions &) { lldb_private::SyntheticChildrenFrontEnd *synthetic_children = BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP()); if (!synthetic_children) { return false; } synthetic_children->Update(); static const ConstString s_FuncPtr_name("__FuncPtr"); lldb::ValueObjectSP child_sp = synthetic_children->GetChildAtIndex( synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name)); if (!child_sp) { return false; } lldb::ValueObjectSP qualified_child_representation_sp = child_sp->GetQualifiedRepresentationIfAvailable( lldb::eDynamicDontRunTarget, true); const char *child_value = qualified_child_representation_sp->GetValueAsCString(); s.Printf("%s", child_value); return true; }
bool lldb_private::formatters::ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { const uint32_t type_info = valobj.GetCompilerType().GetTypeInfo(); ValueObjectSP real_guy_sp = valobj.GetSP(); if (type_info & eTypeIsPointer) { Error err; real_guy_sp = valobj.Dereference(err); if (err.Fail() || !real_guy_sp) return false; } else if (type_info & eTypeIsReference) { real_guy_sp = valobj.GetChildAtIndex(0, true); if (!real_guy_sp) return false; } uint64_t value = real_guy_sp->GetValueAsUnsigned(0); if (value == 0) { stream.Printf("NO"); return true; } stream.Printf("YES"); return true; }
lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx, bool can_create) { Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS); if (log) log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, retrieving " "child at index %zu", GetName().AsCString(), idx); UpdateValueIfNeeded(); ValueObject *valobj; if (m_children_byindex.GetValueForKey(idx, valobj) == false) { if (can_create && m_synth_filter_ap.get() != nullptr) { if (log) log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at " "index %zu not cached and will be created", GetName().AsCString(), idx); lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex(idx); if (log) log->Printf( "[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index " "%zu created as %p (is " "synthetic: %s)", GetName().AsCString(), idx, static_cast<void *>(synth_guy.get()), synth_guy.get() ? (synth_guy->IsSyntheticChildrenGenerated() ? "yes" : "no") : "no"); if (!synth_guy) return synth_guy; if (synth_guy->IsSyntheticChildrenGenerated()) m_synthetic_children_cache.AppendObject(synth_guy); m_children_byindex.SetValueForKey(idx, synth_guy.get()); synth_guy->SetPreferredDisplayLanguageIfNeeded( GetPreferredDisplayLanguage()); return synth_guy; } else { if (log) log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at " "index %zu not cached and cannot " "be created (can_create = %s, synth_filter = %p)", GetName().AsCString(), idx, can_create ? "yes" : "no", static_cast<void *>(m_synth_filter_ap.get())); return lldb::ValueObjectSP(); } } else { if (log) log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at " "index %zu cached as %p", GetName().AsCString(), idx, static_cast<void *>(valobj)); return valobj->GetSP(); } }
ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter) : ValueObject(parent), m_address (), m_type_sp(), m_use_synthetic (lldb::eUseSyntheticFilter), m_synth_sp(filter), m_synth_filter(filter->GetFrontEnd(parent.GetSP())), m_children_byindex(), m_name_toindex() { SetName (parent.GetName()); }
lldb::ValueObjectSP ValueObjectRegisterSet::GetChildMemberWithName (const ConstString &name, bool can_create) { ValueObject *valobj = NULL; if (m_reg_ctx_sp && m_reg_set) { const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName (name.AsCString()); if (reg_info != NULL) valobj = new ValueObjectRegister(*this, m_reg_ctx_sp, reg_info->kinds[eRegisterKindLLDB]); } if (valobj) return valobj->GetSP(); else return ValueObjectSP(); }
bool lldb_private::formatters::VectorTypeSummaryProvider (ValueObject& valobj, Stream& s, const TypeSummaryOptions&) { auto synthetic_children = VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()); if (!synthetic_children) return false; synthetic_children->Update(); s.PutChar('('); bool first = true; size_t idx = 0, len = synthetic_children->CalculateNumChildren(); for (; idx < len; idx++) { auto child_sp = synthetic_children->GetChildAtIndex(idx); if (!child_sp) continue; child_sp = child_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true); const char* child_value = child_sp->GetValueAsCString(); if (child_value && *child_value) { if (first) { s.Printf("%s", child_value); first = false; } else { s.Printf(", %s", child_value); } } } s.PutChar(')'); return true; }
ScriptedSyntheticChildren::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) : SyntheticChildrenFrontEnd(backend), m_python_class(pclass), m_wrapper_sp(), m_interpreter(NULL) { if (backend == LLDB_INVALID_UID) return; TargetSP target_sp = backend.GetTargetSP(); if (!target_sp) return; m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); if (m_interpreter != NULL) m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider( m_python_class.c_str(), backend.GetSP()); }
lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create) { UpdateValueIfNeeded(); ValueObject *valobj; if (m_children_byindex.GetValueForKey(idx, valobj) == false) { if (can_create && m_synth_filter_ap.get() != NULL) { lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx); if (!synth_guy) return synth_guy; m_children_byindex.SetValueForKey(idx, synth_guy.get()); return synth_guy; } else return lldb::ValueObjectSP(); } else return valobj->GetSP(); }
std::unique_ptr<SwiftHashedContainerBufferHandler> SwiftHashedContainerBufferHandler::CreateBufferHandler (ValueObject& valobj, NativeCreatorFunction Native, SyntheticCreatorFunction Synthetic, ConstString mangled, ConstString demangled) { static ConstString g__variantStorage("_variantStorage"); static ConstString g_Native("native"); static ConstString g_Cocoa("cocoa"); static ConstString g_nativeStorage("nativeStorage"); static ConstString g_buffer("buffer"); static ConstString g_storage("storage"); static ConstString g__storage("_storage"); static ConstString g_Some("some"); Error error; ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return nullptr; ConstString type_name_cs(valobj.GetTypeName()); if (type_name_cs) { llvm::StringRef type_name_strref(type_name_cs.GetStringRef()); if (type_name_strref.startswith(mangled.GetCString()) || type_name_strref.startswith(demangled.GetCString())) { return CreateBufferHandlerForNativeStorageOwner(valobj, valobj.GetPointerValue(), false, Native); } } ValueObjectSP valobj_sp = valobj.GetSP()->GetQualifiedRepresentationIfAvailable(lldb::eDynamicCanRunTarget, false); ValueObjectSP _variantStorageSP(valobj_sp->GetChildMemberWithName(g__variantStorage, true)); if (!_variantStorageSP) return nullptr; ConstString storage_kind(_variantStorageSP->GetValueAsCString()); if (!storage_kind) return nullptr; if (g_Cocoa == storage_kind) { ValueObjectSP child_sp(_variantStorageSP->GetChildMemberWithName(g_Native, true)); if (!child_sp) return nullptr; // it's an NSDictionary in disguise uint64_t cocoa_storage_ptr = child_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (cocoa_storage_ptr == LLDB_INVALID_ADDRESS || error.Fail()) return nullptr; cocoa_storage_ptr &= 0x00FFFFFFFFFFFFFF; // for some reason I need to zero out the MSB; figure out why later CompilerType id = process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID); InferiorSizedWord isw(cocoa_storage_ptr, *process_sp); ValueObjectSP cocoarr_sp = ValueObject::CreateValueObjectFromData("cocoarr", isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), id); if (!cocoarr_sp) return nullptr; auto objc_runtime = process_sp->GetObjCLanguageRuntime(); auto descriptor_sp = objc_runtime->GetClassDescriptor(*cocoarr_sp); if (!descriptor_sp) return nullptr; ConstString classname(descriptor_sp->GetClassName()); if (classname && classname.GetStringRef().startswith(mangled.GetCString())) { return CreateBufferHandlerForNativeStorageOwner(*_variantStorageSP, cocoa_storage_ptr, true, Native); } else { auto handler = std::unique_ptr<SwiftHashedContainerBufferHandler>(Synthetic(cocoarr_sp)); if (handler && handler->IsValid()) return handler; return nullptr; } } if (g_Native == storage_kind) { ValueObjectSP native_sp(_variantStorageSP->GetChildAtNamePath({ g_Native })); ValueObjectSP nativeStorage_sp(_variantStorageSP->GetChildAtNamePath( { g_Native, g_nativeStorage } )); if (!native_sp || !nativeStorage_sp) return nullptr; CompilerType child_type(valobj.GetCompilerType()); lldb::TemplateArgumentKind kind; CompilerType key_type(child_type.GetTemplateArgument(0, kind)); CompilerType value_type(child_type.GetTemplateArgument(1, kind)); auto handler = std::unique_ptr<SwiftHashedContainerBufferHandler>(Native(nativeStorage_sp, key_type, value_type)); if (handler && handler->IsValid()) return handler; return nullptr; } return nullptr; }