Add data formatters for NSError and NSException

llvm-svn: 252269
This commit is contained in:
Enrico Granata 2015-11-06 02:43:32 +00:00
parent 5010868328
commit 16709ef9dd
7 changed files with 626 additions and 0 deletions

View File

@ -112,6 +112,167 @@ namespace lldb_private {
time_t
GetOSXEpoch ();
struct InferiorSizedWord {
InferiorSizedWord(const InferiorSizedWord& word) : ptr_size(word.ptr_size)
{
if (ptr_size == 4)
thirty_two = word.thirty_two;
else
sixty_four = word.sixty_four;
}
InferiorSizedWord
operator = (const InferiorSizedWord& word)
{
ptr_size = word.ptr_size;
if (ptr_size == 4)
thirty_two = word.thirty_two;
else
sixty_four = word.sixty_four;
return *this;
}
InferiorSizedWord(uint64_t val, Process& process) : ptr_size(process.GetAddressByteSize())
{
if (ptr_size == 4)
thirty_two = (uint32_t)val;
else if (ptr_size == 8)
sixty_four = val;
else
assert (false && "new pointer size is unknown");
}
bool
IsNegative () const
{
if (ptr_size == 4)
return ((int32_t)thirty_two) < 0;
else
return ((int64_t)sixty_four) < 0;
}
bool
IsZero () const
{
if (ptr_size == 4)
return thirty_two == 0;
else
return sixty_four == 0;
}
static InferiorSizedWord
GetMaximum (Process& process)
{
if (process.GetAddressByteSize() == 4)
return InferiorSizedWord(UINT32_MAX,4);
else
return InferiorSizedWord(UINT64_MAX,8);
}
InferiorSizedWord
operator >> (int rhs) const
{
if (ptr_size == 4)
return InferiorSizedWord(thirty_two >> rhs,4);
return InferiorSizedWord(sixty_four>>rhs,8);
}
InferiorSizedWord
operator << (int rhs) const
{
if (ptr_size == 4)
return InferiorSizedWord(thirty_two << rhs,4);
return InferiorSizedWord(sixty_four << rhs,8);
}
InferiorSizedWord
operator & (const InferiorSizedWord& word) const
{
if (ptr_size != word.ptr_size)
return InferiorSizedWord(0,ptr_size);
if (ptr_size == 4)
return InferiorSizedWord(thirty_two & word.thirty_two,4);
return InferiorSizedWord(sixty_four & word.sixty_four,8);
}
InferiorSizedWord
operator & (int x) const
{
if (ptr_size == 4)
return InferiorSizedWord(thirty_two & x,4);
return InferiorSizedWord(sixty_four & x,8);
}
size_t
GetBitSize () const
{
return ptr_size << 3;
}
size_t
GetByteSize () const
{
return ptr_size;
}
uint64_t
GetValue () const
{
if (ptr_size == 4)
return (uint64_t)thirty_two;
return sixty_four;
}
InferiorSizedWord
SignExtend () const
{
if (ptr_size == 4)
return InferiorSizedWord ((int32_t)thirty_two,4);
return InferiorSizedWord((int64_t)sixty_four,8);
}
uint8_t*
CopyToBuffer (uint8_t* buffer) const
{
if (ptr_size == 4)
{
memcpy(buffer, &thirty_two, 4);
return buffer + 4;
}
else
{
memcpy(buffer, &sixty_four, 8);
return buffer + 8;
}
}
DataExtractor
GetAsData (lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const
{
if (ptr_size == 4)
return DataExtractor(&thirty_two, 4, byte_order, 4);
else
return DataExtractor(&sixty_four, 8, byte_order, 8);
}
private:
InferiorSizedWord(uint64_t val, size_t psz) : ptr_size(psz)
{
if (ptr_size == 4)
thirty_two = (uint32_t)val;
else
sixty_four = val;
}
size_t ptr_size;
union {
uint32_t thirty_two;
uint64_t sixty_four;
};
};
} // namespace formatters
} // namespace lldb_private

View File

@ -739,6 +739,8 @@
8CF02AE919DCC01900B14BE0 /* InstrumentationRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CF02ADF19DCBF3B00B14BE0 /* InstrumentationRuntime.cpp */; };
8CF02AEA19DCC02100B14BE0 /* AddressSanitizerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CF02AE519DCBF8400B14BE0 /* AddressSanitizerRuntime.cpp */; };
8CF02AEF19DD16B100B14BE0 /* InstrumentationRuntimeStopInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CF02AED19DD15CF00B14BE0 /* InstrumentationRuntimeStopInfo.cpp */; };
9404957A1BEC497E00926025 /* NSError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940495781BEC497E00926025 /* NSError.cpp */; };
9404957B1BEC497E00926025 /* NSException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940495791BEC497E00926025 /* NSException.cpp */; };
94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */; };
940B02F619DC96E700AD0F52 /* SBExecutionContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940B02F519DC96E700AD0F52 /* SBExecutionContext.cpp */; };
940B04D91A8984FF0045D5F7 /* argdumper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940B04D81A8984FF0045D5F7 /* argdumper.cpp */; };
@ -2485,6 +2487,8 @@
94005E0313F438DF001EF42D /* python-wrapper.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-wrapper.swig"; sourceTree = "<group>"; };
94005E0513F45A1B001EF42D /* embedded_interpreter.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = embedded_interpreter.py; path = source/Interpreter/embedded_interpreter.py; sourceTree = "<group>"; };
94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = "<group>"; };
940495781BEC497E00926025 /* NSError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSError.cpp; path = Language/ObjC/NSError.cpp; sourceTree = "<group>"; };
940495791BEC497E00926025 /* NSException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSException.cpp; path = Language/ObjC/NSException.cpp; sourceTree = "<group>"; };
94094C68163B6CCC0083A547 /* ValueObjectCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectCast.h; path = include/lldb/Core/ValueObjectCast.h; sourceTree = "<group>"; };
94094C69163B6CD90083A547 /* ValueObjectCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectCast.cpp; path = source/Core/ValueObjectCast.cpp; sourceTree = "<group>"; };
940B02F419DC96CB00AD0F52 /* SBExecutionContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBExecutionContext.h; path = include/lldb/API/SBExecutionContext.h; sourceTree = "<group>"; };
@ -5530,6 +5534,8 @@
949EEDA41BA765B5008C63CF /* NSArray.cpp */,
94B9E50E1BBEFDFE000A48DC /* NSDictionary.h */,
949EEDA51BA765B5008C63CF /* NSDictionary.cpp */,
940495781BEC497E00926025 /* NSError.cpp */,
940495791BEC497E00926025 /* NSException.cpp */,
949EEDA61BA765B5008C63CF /* NSIndexPath.cpp */,
94B9E50F1BBF0069000A48DC /* NSSet.h */,
949EEDA71BA765B5008C63CF /* NSSet.cpp */,
@ -6434,6 +6440,7 @@
26474CAC18D0CB070073DEBA /* RegisterContextFreeBSD_x86_64.cpp in Sources */,
2689001713353DDE00698AC0 /* CommandObjectDisassemble.cpp in Sources */,
2689001813353DDE00698AC0 /* CommandObjectExpression.cpp in Sources */,
9404957B1BEC497E00926025 /* NSException.cpp in Sources */,
2689001A13353DDE00698AC0 /* CommandObjectFrame.cpp in Sources */,
2689001B13353DDE00698AC0 /* CommandObjectHelp.cpp in Sources */,
23F4034D1926E0F60046DC9B /* NativeRegisterContextRegisterInfo.cpp in Sources */,
@ -6478,6 +6485,7 @@
2689003213353E0400698AC0 /* Communication.cpp in Sources */,
2689003313353E0400698AC0 /* Connection.cpp in Sources */,
2689003513353E0400698AC0 /* ConstString.cpp in Sources */,
9404957A1BEC497E00926025 /* NSError.cpp in Sources */,
2689003613353E0400698AC0 /* DataBufferHeap.cpp in Sources */,
2689003713353E0400698AC0 /* DataBufferMemoryMap.cpp in Sources */,
2689003813353E0400698AC0 /* DataExtractor.cpp in Sources */,

View File

@ -5,6 +5,8 @@ add_lldb_library(lldbPluginObjCLanguage
CoreMedia.cpp
NSArray.cpp
NSDictionary.cpp
NSError.cpp
NSException.cpp
NSIndexPath.cpp
NSSet.cpp
NSString.cpp

View File

@ -79,6 +79,18 @@ namespace lldb_private {
bool
RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSError_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSException_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
SyntheticChildrenFrontEnd*
NSErrorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp);
SyntheticChildrenFrontEnd*
NSExceptionSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp);
} // namespace formatters
} // namespace lldb_private

View File

@ -0,0 +1,218 @@
//===-- NSError.cpp ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "Cocoa.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ProcessStructReader.h"
#include "clang/AST/DeclCXX.h"
#include "Plugins/Language/ObjC/NSString.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
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;
}
}
class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
NSErrorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp)
{}
virtual size_t
CalculateNumChildren ()
{
if (m_child_ptr)
return 1;
if (m_child_sp)
return 1;
return 0;
}
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx)
{
if (idx != 0)
return lldb::ValueObjectSP();
if (m_child_ptr)
return m_child_ptr->GetSP();
return m_child_sp;
}
virtual bool
Update()
{
m_child_ptr = nullptr;
m_child_sp.reset();
ProcessSP process_sp(m_backend.GetProcessSP());
if (!process_sp)
return false;
lldb::addr_t userinfo_location = LLDB_INVALID_ADDRESS;
CompilerType valobj_type(m_backend.GetCompilerType());
Flags type_flags(valobj_type.GetTypeInfo());
if (type_flags.AllClear(eTypeHasValue))
{
if (m_backend.IsBaseClass() && m_backend.GetParent())
userinfo_location = m_backend.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
}
else
userinfo_location = m_backend.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
if (userinfo_location == LLDB_INVALID_ADDRESS)
return false;
size_t ptr_size = process_sp->GetAddressByteSize();
userinfo_location += 4 * ptr_size;
Error error;
lldb::addr_t userinfo = process_sp->ReadPointerFromMemory(userinfo_location, error);
if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
return false;
InferiorSizedWord isw(userinfo,*process_sp);
m_child_sp = ValueObject::CreateValueObjectFromData("_userInfo",
isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
virtual bool
MightHaveChildren ()
{
return true;
}
virtual size_t
GetIndexOfChildWithName (const ConstString &name)
{
static ConstString g___userInfo("_userInfo");
if (name == g___userInfo)
return 0;
return UINT32_MAX;
}
virtual
~NSErrorSyntheticFrontEnd ()
{
// no need to delete m_child_ptr - it's kept alive by the cluster manager on our behalf
}
private:
// the child here can be "real" (i.e. an actual child of the root) or synthetized from raw memory
// if the former, I need to store a plain pointer to it - or else a loop of references will cause this entire hierarchy of values to leak
// if the latter, then I need to store a SharedPointer to it - so that it only goes away when everyone else in the cluster goes away
// oh joy!
ValueObject* m_child_ptr;
ValueObjectSP m_child_sp;
};
SyntheticChildrenFrontEnd*
lldb_private::formatters::NSErrorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
if (!process_sp)
return nullptr;
ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
if (!runtime)
return nullptr;
ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
if (!descriptor.get() || !descriptor->IsValid())
return nullptr;
const char* class_name = descriptor->GetClassName().GetCString();
if (!class_name || !*class_name)
return nullptr;
if (!strcmp(class_name,"NSError"))
return (new NSErrorSyntheticFrontEnd(valobj_sp));
else if (!strcmp(class_name,"__NSCFError"))
return (new NSErrorSyntheticFrontEnd(valobj_sp));
return nullptr;
}

View File

@ -0,0 +1,219 @@
//===-- NSException.cpp ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "Cocoa.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ProcessStructReader.h"
#include "clang/AST/DeclCXX.h"
#include "Plugins/Language/ObjC/NSString.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
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() == false &&
reason_str_summary.Empty() == false)
{
stream.Printf("name: %s - reason: %s", name_str_summary.GetData(), reason_str_summary.GetData());
return true;
}
else
return false;
}
class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
NSExceptionSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp)
{}
virtual size_t
CalculateNumChildren ()
{
if (m_child_ptr)
return 1;
if (m_child_sp)
return 1;
return 0;
}
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx)
{
if (idx != 0)
return lldb::ValueObjectSP();
if (m_child_ptr)
return m_child_ptr->GetSP();
return m_child_sp;
}
virtual bool
Update()
{
m_child_ptr = nullptr;
m_child_sp.reset();
ProcessSP process_sp(m_backend.GetProcessSP());
if (!process_sp)
return false;
lldb::addr_t userinfo_location = LLDB_INVALID_ADDRESS;
CompilerType valobj_type(m_backend.GetCompilerType());
Flags type_flags(valobj_type.GetTypeInfo());
if (type_flags.AllClear(eTypeHasValue))
{
if (m_backend.IsBaseClass() && m_backend.GetParent())
userinfo_location = m_backend.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
}
else
userinfo_location = m_backend.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
if (userinfo_location == LLDB_INVALID_ADDRESS)
return false;
size_t ptr_size = process_sp->GetAddressByteSize();
userinfo_location += 3 * ptr_size;
Error error;
lldb::addr_t userinfo = process_sp->ReadPointerFromMemory(userinfo_location, error);
if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
return false;
InferiorSizedWord isw(userinfo,*process_sp);
m_child_sp = ValueObject::CreateValueObjectFromData("userInfo",
isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
virtual bool
MightHaveChildren ()
{
return true;
}
virtual size_t
GetIndexOfChildWithName (const ConstString &name)
{
static ConstString g___userInfo("userInfo");
if (name == g___userInfo)
return 0;
return UINT32_MAX;
}
virtual
~NSExceptionSyntheticFrontEnd ()
{
// no need to delete m_child_ptr - it's kept alive by the cluster manager on our behalf
}
private:
// the child here can be "real" (i.e. an actual child of the root) or synthetized from raw memory
// if the former, I need to store a plain pointer to it - or else a loop of references will cause this entire hierarchy of values to leak
// if the latter, then I need to store a SharedPointer to it - so that it only goes away when everyone else in the cluster goes away
// oh joy!
ValueObject* m_child_ptr;
ValueObjectSP m_child_sp;
};
SyntheticChildrenFrontEnd*
lldb_private::formatters::NSExceptionSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
if (!process_sp)
return nullptr;
ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
if (!runtime)
return nullptr;
ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
if (!descriptor.get() || !descriptor->IsValid())
return nullptr;
const char* class_name = descriptor->GetClassName().GetCString();
if (!class_name || !*class_name)
return nullptr;
if (!strcmp(class_name,"NSException"))
return (new NSExceptionSyntheticFrontEnd(valobj_sp));
else if (!strcmp(class_name,"NSCFException"))
return (new NSExceptionSyntheticFrontEnd(valobj_sp));
else if (!strcmp(class_name,"__NSCFException"))
return (new NSExceptionSyntheticFrontEnd(valobj_sp));
return nullptr;
}

View File

@ -477,6 +477,9 @@ LoadObjCFormatters(TypeCategoryImplSP objc_category_sp)
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSOrderedSetI summary", ConstString("__NSOrderedSetI"), appkit_flags);
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSOrderedSetM summary", ConstString("__NSOrderedSetM"), appkit_flags);
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSError_SummaryProvider, "NSError summary provider", ConstString("NSError"), appkit_flags);
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSException_SummaryProvider, "NSException summary provider", ConstString("NSException"), appkit_flags);
// AddSummary(appkit_category_sp, "${var.key%@} -> ${var.value%@}", ConstString("$_lldb_typegen_nspair"), appkit_flags);
appkit_flags.SetDontShowChildren(true);
@ -498,6 +501,9 @@ LoadObjCFormatters(TypeCategoryImplSP objc_category_sp)
AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFDictionaryRef"), ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"), ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSErrorSyntheticFrontEndCreator, "NSError synthetic children", ConstString("NSError"), ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSExceptionSyntheticFrontEndCreator, "NSException synthetic children", ConstString("NSException"), ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "NSSet synthetic children", ConstString("NSSet"), ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSSetI synthetic children", ConstString("__NSSetI"), ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSSetM synthetic children", ConstString("__NSSetM"), ScriptedSyntheticChildren::Flags());