bool lldb_private::formatters::swift::ObjC_Selector_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { static ConstString g_ptr("ptr"); static ConstString g__rawValue("_rawValue"); ValueObjectSP ptr_sp(valobj.GetChildAtNamePath({ g_ptr, g__rawValue })); if (!ptr_sp) return false; auto ptr_value = ptr_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (0 == ptr_value || LLDB_INVALID_ADDRESS == ptr_value) return false; StringPrinter::ReadStringAndDumpToStreamOptions read_options; read_options.SetLocation(ptr_value) .SetProcessSP(valobj.GetProcessSP()) .SetStream(&stream) .SetQuote('"') .SetNeedsZeroTermination(true) .SetLanguage(lldb::eLanguageTypeSwift); return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII>(read_options); }
std::unique_ptr<SwiftHashedContainerBufferHandler> SwiftHashedContainerBufferHandler::CreateBufferHandlerForNativeStorageOwner (ValueObject &valobj, lldb::addr_t storage_ptr, bool fail_on_no_children, NativeCreatorFunction Native) { #if 0 static ConstString g_Native("native"); static ConstString g_nativeStorage("nativeStorage"); static ConstString g_buffer("buffer"); Error error; ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return nullptr; ValueObjectSP native_sp(valobj.GetChildAtNamePath( {g_Native, g_nativeStorage, g_buffer} )); if (!native_sp) { if (fail_on_no_children) return nullptr; else { lldb::addr_t native_storage_ptr = storage_ptr + (3 * process_sp->GetAddressByteSize()); native_storage_ptr = process_sp->ReadPointerFromMemory(native_storage_ptr, error); // (AnyObject,AnyObject)? SwiftASTContext *swift_ast_ctx = process_sp->GetTarget().GetScratchSwiftASTContext(error); if (swift_ast_ctx) { CompilerType element_type(swift_ast_ctx->GetTypeFromMangledTypename("_TtGSqTPs9AnyObject_PS____", error)); auto handler = std::unique_ptr<SwiftHashedContainerBufferHandler>(Native(valobj, native_storage_ptr, element_type)); if (handler && handler->IsValid()) return handler; } return nullptr; } } CompilerType child_type(native_sp->GetCompilerType()); lldb::TemplateArgumentKind kind; CompilerType element_type(child_type.GetTemplateArgument(1, kind)); if (element_type.IsValid() == false || kind != lldb::eTemplateArgumentKindType) return nullptr; lldb::addr_t native_storage_ptr = process_sp->ReadPointerFromMemory(storage_ptr + 2*process_sp->GetAddressByteSize(), error); if (error.Fail() || native_storage_ptr == LLDB_INVALID_ADDRESS) return nullptr; auto handler = std::unique_ptr<SwiftHashedContainerBufferHandler>(Native(valobj, native_storage_ptr, element_type)); if (handler && handler->IsValid()) return handler; #endif return nullptr; }
bool lldb_private::formatters::swift::StringCore_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options, StringPrinter::ReadStringAndDumpToStreamOptions read_options) { static ConstString g_some("some"); static ConstString g__baseAddress("_baseAddress"); static ConstString g__countAndFlags("_countAndFlags"); static ConstString g_value("_value"); static ConstString g__rawValue("_rawValue"); ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return false; ValueObjectSP baseAddress_sp(valobj.GetChildAtNamePath({ g__baseAddress, g_some, g__rawValue })); ValueObjectSP _countAndFlags_sp(valobj.GetChildAtNamePath({ g__countAndFlags, g_value })); if (!_countAndFlags_sp) return false; lldb::addr_t baseAddress = baseAddress_sp ? baseAddress_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS) : 0; InferiorSizedWord _countAndFlags = InferiorSizedWord(_countAndFlags_sp->GetValueAsUnsigned(0),*process_sp.get()); if (baseAddress == LLDB_INVALID_ADDRESS) return false; bool hasCocoaBuffer = (_countAndFlags << 1).IsNegative(); if (baseAddress == 0) { if (hasCocoaBuffer) { static ConstString g__owner("_owner"); static ConstString g_Some("some"); static ConstString g_instance_type("instance_type"); ValueObjectSP dyn_inst_type0(valobj.GetChildAtNamePath({g__owner,g_Some,g_instance_type})); if (!dyn_inst_type0) return false; lldb::addr_t dyn_inst_type0_ptr = dyn_inst_type0->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (dyn_inst_type0_ptr == 0 || dyn_inst_type0_ptr == LLDB_INVALID_ADDRESS) return false; InferiorSizedWord dataAddress_isw = InferiorSizedWord(dyn_inst_type0_ptr, *process_sp.get()); DataExtractor id_ptr = dataAddress_isw.GetAsData(process_sp->GetByteOrder()); CompilerType id_type = process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID); if (!id_type) return false; ValueObjectSP nsstringhere_sp = ValueObject::CreateValueObjectFromData("nsstringhere", id_ptr, valobj.GetExecutionContextRef(), id_type); if (nsstringhere_sp) return NSStringSummaryProvider(*nsstringhere_sp.get(), stream, summary_options); return false; } else { stream.Printf("\"\""); return true; } } const InferiorSizedWord _countMask = InferiorSizedWord::GetMaximum(*process_sp.get()) >> 2; uint64_t count = (_countAndFlags & _countMask).GetValue(); bool isASCII = ((_countAndFlags >> (_countMask.GetBitSize() - 1)).SignExtend() << 8).IsZero(); if (count == 0) { stream.Printf("\"\""); return true; } read_options.SetLocation(baseAddress); read_options.SetProcessSP(process_sp); read_options.SetStream(&stream); read_options.SetSourceSize(count); read_options.SetNeedsZeroTermination(false); read_options.SetIgnoreMaxLength(summary_options.GetCapping() == lldb::eTypeSummaryUncapped); read_options.SetBinaryZeroIsTerminator(false); read_options.SetLanguage(summary_options.GetLanguage()); if (summary_options.GetLanguage() == lldb::eLanguageTypeObjC) read_options.SetPrefixToken("@"); if (isASCII) return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(read_options); else return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(read_options); }