bool lldb_private::formatters::swift::Range_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { static ConstString g_startIndex("startIndex"); static ConstString g_endIndex("endIndex"); ValueObjectSP startIndex_sp(valobj.GetChildMemberWithName(g_startIndex, true)); ValueObjectSP endIndex_sp(valobj.GetChildMemberWithName(g_endIndex, true)); if (!startIndex_sp || !endIndex_sp) return false; startIndex_sp = startIndex_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true); endIndex_sp = endIndex_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true); auto start_summary = startIndex_sp->GetValueAsCString(); auto end_summary = endIndex_sp->GetValueAsCString(); // the Range should not have a summary unless both start and end indices have one - or it will look awkward if (!start_summary || !start_summary[0] || !end_summary || !end_summary[0]) return false; stream.Printf("%s..<%s",start_summary, end_summary); return true; }
bool lldb_private::formatters::GoStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &opts) { ProcessSP process_sp = valobj.GetProcessSP(); if (!process_sp) return false; if (valobj.IsPointerType()) { Error err; ValueObjectSP deref = valobj.Dereference(err); if (!err.Success()) return false; return GoStringSummaryProvider(*deref, stream, opts); } ConstString str_name("str"); ConstString len_name("len"); ValueObjectSP data_sp = valobj.GetChildMemberWithName(str_name, true); ValueObjectSP len_sp = valobj.GetChildMemberWithName(len_name, true); if (!data_sp || !len_sp) return false; bool success; lldb::addr_t valobj_addr = data_sp->GetValueAsUnsigned(0, &success); if (!success) return false; uint64_t length = len_sp->GetValueAsUnsigned(0); if (length == 0) { stream.Printf("\"\""); return true; } StringPrinter::ReadStringAndDumpToStreamOptions options(valobj); options.SetLocation(valobj_addr); options.SetProcessSP(process_sp); options.SetStream(&stream); options.SetSourceSize(length); options.SetNeedsZeroTermination(false); options.SetLanguage(eLanguageTypeGo); if (!StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF8>(options)) { stream.Printf("Summary Unavailable"); return true; } return true; }
bool lldb_private::formatters::swift::StaticString_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options, StringPrinter::ReadStringAndDumpToStreamOptions read_options) { static ConstString g__startPtrOrData("_startPtrOrData"); static ConstString g__byteSize("_utf8CodeUnitCount"); static ConstString g__flags("_flags"); ValueObjectSP flags_sp(valobj.GetChildMemberWithName(g__flags, true)); if (!flags_sp) return false; ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return false; // 0 == pointer representation InferiorSizedWord flags(flags_sp->GetValueAsUnsigned(0), *process_sp); if (0 != (flags & 0x1).GetValue()) return false; ValueObjectSP startptr_sp(valobj.GetChildMemberWithName(g__startPtrOrData, true)); ValueObjectSP bytesize_sp(valobj.GetChildMemberWithName(g__byteSize, true)); if (!startptr_sp || !bytesize_sp) return false; lldb::addr_t start_ptr = startptr_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); uint64_t size = bytesize_sp->GetValueAsUnsigned(0); if (start_ptr == LLDB_INVALID_ADDRESS || start_ptr == 0) return false; if (size == 0) { stream.Printf("\"\""); return true; } read_options.SetProcessSP(process_sp); read_options.SetLocation(start_ptr); read_options.SetSourceSize(size); read_options.SetBinaryZeroIsTerminator(false); read_options.SetNeedsZeroTermination(false); read_options.SetStream(&stream); read_options.SetIgnoreMaxLength(summary_options.GetCapping() == lldb::eTypeSummaryUncapped); read_options.SetLanguage(lldb::eLanguageTypeSwift); return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(read_options); }
bool lldb_private::formatters::JavaStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &opts) { if (valobj.IsPointerOrReferenceType()) { Error error; ValueObjectSP deref = valobj.Dereference(error); if (error.Fail()) return false; return JavaStringSummaryProvider(*deref, stream, opts); } ProcessSP process_sp = valobj.GetProcessSP(); if (!process_sp) return false; ConstString data_name("value"); ConstString length_name("count"); ValueObjectSP length_sp = valobj.GetChildMemberWithName(length_name, true); ValueObjectSP data_sp = valobj.GetChildMemberWithName(data_name, true); if (!data_sp || !length_sp) return false; bool success = false; uint64_t length = length_sp->GetValueAsUnsigned(0, &success); if (!success) return false; if (length == 0) { stream.Printf("\"\""); return true; } lldb::addr_t valobj_addr = data_sp->GetAddressOf(); StringPrinter::ReadStringAndDumpToStreamOptions options(valobj); options.SetLocation(valobj_addr); options.SetProcessSP(process_sp); options.SetStream(&stream); options.SetSourceSize(length); options.SetNeedsZeroTermination(false); options.SetLanguage(eLanguageTypeJava); if (StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF16>(options)) return true; stream.Printf("Summary Unavailable"); return true; }
static bool RangeFamily_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options, bool isHalfOpen) { static ConstString g_lowerBound("lowerBound"); static ConstString g_upperBound("upperBound"); ValueObjectSP lowerBound_sp(valobj.GetChildMemberWithName(g_lowerBound, true)); ValueObjectSP upperBound_sp(valobj.GetChildMemberWithName(g_upperBound, true)); if (!lowerBound_sp || !upperBound_sp) return false; lowerBound_sp = lowerBound_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true); upperBound_sp = upperBound_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true); auto start_summary = lowerBound_sp->GetValueAsCString(); auto end_summary = upperBound_sp->GetValueAsCString(); // the Range should not have a summary unless both start and end indices have one - or it will look awkward if (!start_summary || !start_summary[0] || !end_summary || !end_summary[0]) return false; stream.Printf("%s%s%s", start_summary, isHalfOpen ? "..<" : "...", end_summary); return true; }
bool lldb_private::formatters::swift::String_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options, StringPrinter::ReadStringAndDumpToStreamOptions read_options) { static ConstString g_core("_core"); ValueObjectSP core_sp = valobj.GetChildMemberWithName(g_core, true); if (core_sp) return StringCore_SummaryProvider(*core_sp, stream, summary_options, read_options); return false; }
bool lldb_private::formatters::swift::UnicodeScalar_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { static ConstString g_value("_value"); ValueObjectSP value_sp(valobj.GetChildMemberWithName(g_value,true)); if (!value_sp) return false; return Char32SummaryProvider(*value_sp.get(), stream, options); }
bool lldb_private::formatters::LibCxxAtomicSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { static ConstString g___a_("__a_"); if (ValueObjectSP child = valobj.GetChildMemberWithName(g___a_, true)) { std::string summary; if (child->GetSummaryAsCString(summary, options) && summary.size() > 0) { stream.Printf("%s", summary.c_str()); return true; } } return false; }
bool lldb_private::formatters::swift::DarwinBoolean_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { static ConstString g__value("_value"); ValueObjectSP value_child(valobj.GetChildMemberWithName(g__value, true)); if (!value_child) return false; auto value = value_child->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); switch (value) { case 0: stream.Printf("false"); return true; default: stream.Printf("true"); return true; } }
bool lldb_private::formatters::swift::StridedRangeGenerator_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { static ConstString g__bounds("_bounds"); static ConstString g__stride("_stride"); ValueObjectSP bounds_sp(valobj.GetChildMemberWithName(g__bounds,true)); ValueObjectSP stride_sp(valobj.GetChildMemberWithName(g__stride,true)); if (!bounds_sp || !stride_sp) return false; auto bounds_summary = bounds_sp->GetSummaryAsCString(); auto stride_summary = stride_sp->GetValueAsCString(); if (!bounds_summary || !bounds_summary[0] || !stride_summary || !stride_summary[0]) return false; stream.Printf("(%s).by(%s)", bounds_summary, stride_summary); return true; }
bool lldb_private::formatters::swift::Character_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { static ConstString g_Small("Small"); static ConstString g_Large("Large"); static ConstString g__representation("_representation"); static ConstString g__storage("_storage"); static ConstString g_storage("storage"); static ConstString g_Some("Some"); ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return false; ValueObjectSP representation_sp = valobj.GetChildMemberWithName(g__representation, true); if (!representation_sp) return false; ConstString value(representation_sp->GetValueAsCString()); if (value == g_Large) { ValueObjectSP largeBuffer_sp(representation_sp->GetChildAtNamePath( {g_Large,g__storage,g_storage,g_Some} )); if (!largeBuffer_sp) return false; lldb::addr_t buffer_ptr = largeBuffer_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (LLDB_INVALID_ADDRESS == buffer_ptr || 0 == buffer_ptr) return false; buffer_ptr += 2*process_sp->GetAddressByteSize(); Error error; buffer_ptr = process_sp->ReadPointerFromMemory(buffer_ptr, error); if (LLDB_INVALID_ADDRESS == buffer_ptr || 0 == buffer_ptr) return false; StringPrinter::ReadStringAndDumpToStreamOptions options; options.SetLocation(buffer_ptr) .SetEscapeNonPrintables(true) .SetNeedsZeroTermination(true) .SetPrefixToken(0) .SetProcessSP(valobj.GetProcessSP()) .SetQuote('"') .SetStream(&stream) .SetLanguage(lldb::eLanguageTypeSwift); return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options); } else if (value == g_Small) { const uint64_t invalidRepr = 0xFFFFFFFFFFFFFFFF; ValueObjectSP smallBuffer_sp(representation_sp->GetChildAtNamePath( {g_Small} )); if (!smallBuffer_sp) return false; uint64_t buffer_data = smallBuffer_sp->GetValueAsUnsigned(invalidRepr); if (invalidRepr == buffer_data) return false; uint8_t bytes[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00}; uint64_t mask = 0x00000000000000FF; uint8_t shift = 0; uint8_t pos = 0; for(; pos < 7; pos++, mask<<=8, shift+=8) { auto val = (uint8_t)((mask & buffer_data) >> shift); if (0xFF == val) break; bytes[pos] = val; } DataExtractor data(bytes, 7, process_sp->GetByteOrder(), process_sp->GetAddressByteSize()); StringPrinter::ReadBufferAndDumpToStreamOptions options; options.SetData(data) .SetEscapeNonPrintables(true) .SetPrefixToken(0) .SetQuote('"') .SetStream(&stream) .SetSourceSize(pos) .SetLanguage(lldb::eLanguageTypeSwift); return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF8>(options); } return false; }