bool lldb_private::formatters::NSError_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return false; lldb::addr_t ptr_value = LLDB_INVALID_ADDRESS; CompilerType valobj_type(valobj.GetCompilerType()); Flags type_flags(valobj_type.GetTypeInfo()); if (type_flags.AllClear(eTypeHasValue)) { if (valobj.IsBaseClass() && valobj.GetParent()) ptr_value = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); } else ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (ptr_value == LLDB_INVALID_ADDRESS) return false; size_t ptr_size = process_sp->GetAddressByteSize(); lldb::addr_t code_location = ptr_value + 2 * ptr_size; lldb::addr_t domain_location = ptr_value + 3 * ptr_size; Error error; uint64_t code = process_sp->ReadUnsignedIntegerFromMemory(code_location, ptr_size, 0, error); if (error.Fail()) return false; lldb::addr_t domain_str_value = process_sp->ReadPointerFromMemory(domain_location, error); if (error.Fail() || domain_str_value == LLDB_INVALID_ADDRESS) return false; if (!domain_str_value) { stream.Printf("domain: nil - code: %" PRIu64, code); return true; } InferiorSizedWord isw(domain_str_value, *process_sp); ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData("domain_str", isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()); if (!domain_str_sp) return false; StreamString domain_str_summary; if (NSStringSummaryProvider(*domain_str_sp, domain_str_summary, options) && !domain_str_summary.Empty()) { stream.Printf("domain: %s - code: %" PRIu64, domain_str_summary.GetData(), code); return true; } else { stream.Printf("domain: nil - code: %" PRIu64, code); return true; } }
static lldb::addr_t DerefToNSErrorPointer(ValueObject &valobj) { CompilerType valobj_type(valobj.GetCompilerType()); Flags type_flags(valobj_type.GetTypeInfo()); if (type_flags.AllClear(eTypeHasValue)) { if (valobj.IsBaseClass() && valobj.GetParent()) return valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); } else { lldb::addr_t ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (type_flags.AllSet(eTypeIsPointer)) { CompilerType pointee_type(valobj_type.GetPointeeType()); Flags pointee_flags(pointee_type.GetTypeInfo()); if (pointee_flags.AllSet(eTypeIsPointer)) { if (ProcessSP process_sp = valobj.GetProcessSP()) { Status error; ptr_value = process_sp->ReadPointerFromMemory(ptr_value, error); } } } return ptr_value; } return LLDB_INVALID_ADDRESS; }
static bool ExtractFields(ValueObject &valobj, ValueObjectSP *name_sp, ValueObjectSP *reason_sp, ValueObjectSP *userinfo_sp, ValueObjectSP *reserved_sp) { ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return false; lldb::addr_t ptr = LLDB_INVALID_ADDRESS; CompilerType valobj_type(valobj.GetCompilerType()); Flags type_flags(valobj_type.GetTypeInfo()); if (type_flags.AllClear(eTypeHasValue)) { if (valobj.IsBaseClass() && valobj.GetParent()) ptr = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); } else { ptr = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); } if (ptr == LLDB_INVALID_ADDRESS) return false; size_t ptr_size = process_sp->GetAddressByteSize(); Status error; auto name = process_sp->ReadPointerFromMemory(ptr + 1 * ptr_size, error); if (error.Fail() || name == LLDB_INVALID_ADDRESS) return false; auto reason = process_sp->ReadPointerFromMemory(ptr + 2 * ptr_size, error); if (error.Fail() || reason == LLDB_INVALID_ADDRESS) return false; auto userinfo = process_sp->ReadPointerFromMemory(ptr + 3 * ptr_size, error); if (error.Fail() || userinfo == LLDB_INVALID_ADDRESS) return false; auto reserved = process_sp->ReadPointerFromMemory(ptr + 4 * ptr_size, error); if (error.Fail() || reserved == LLDB_INVALID_ADDRESS) return false; InferiorSizedWord name_isw(name, *process_sp); InferiorSizedWord reason_isw(reason, *process_sp); InferiorSizedWord userinfo_isw(userinfo, *process_sp); InferiorSizedWord reserved_isw(reserved, *process_sp); CompilerType voidstar = process_sp->GetTarget() .GetScratchClangASTContext() ->GetBasicType(lldb::eBasicTypeVoid) .GetPointerType(); if (name_sp) *name_sp = ValueObject::CreateValueObjectFromData( "name", name_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar); if (reason_sp) *reason_sp = ValueObject::CreateValueObjectFromData( "reason", reason_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar); if (userinfo_sp) *userinfo_sp = ValueObject::CreateValueObjectFromData( "userInfo", userinfo_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar); if (reserved_sp) *reserved_sp = ValueObject::CreateValueObjectFromData( "reserved", reserved_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar); return true; }
bool lldb_private::formatters::NSException_SummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return false; lldb::addr_t ptr_value = LLDB_INVALID_ADDRESS; CompilerType valobj_type(valobj.GetCompilerType()); Flags type_flags(valobj_type.GetTypeInfo()); if (type_flags.AllClear(eTypeHasValue)) { if (valobj.IsBaseClass() && valobj.GetParent()) ptr_value = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); } else ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (ptr_value == LLDB_INVALID_ADDRESS) return false; size_t ptr_size = process_sp->GetAddressByteSize(); lldb::addr_t name_location = ptr_value + 1 * ptr_size; lldb::addr_t reason_location = ptr_value + 2 * ptr_size; Error error; lldb::addr_t name = process_sp->ReadPointerFromMemory(name_location, error); if (error.Fail() || name == LLDB_INVALID_ADDRESS) return false; lldb::addr_t reason = process_sp->ReadPointerFromMemory(reason_location, error); if (error.Fail() || reason == LLDB_INVALID_ADDRESS) return false; InferiorSizedWord name_isw(name, *process_sp); InferiorSizedWord reason_isw(reason, *process_sp); CompilerType voidstar = process_sp->GetTarget() .GetScratchClangASTContext() ->GetBasicType(lldb::eBasicTypeVoid) .GetPointerType(); ValueObjectSP name_sp = ValueObject::CreateValueObjectFromData( "name_str", name_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar); ValueObjectSP reason_sp = ValueObject::CreateValueObjectFromData( "reason_str", reason_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar); if (!name_sp || !reason_sp) return false; StreamString name_str_summary; StreamString reason_str_summary; if (NSStringSummaryProvider(*name_sp, name_str_summary, options) && NSStringSummaryProvider(*reason_sp, reason_str_summary, options) && !name_str_summary.Empty() && !reason_str_summary.Empty()) { stream.Printf("name: %s - reason: %s", name_str_summary.GetData(), reason_str_summary.GetData()); return true; } else return false; }