diff options
author | Enrico Granata <egranata@apple.com> | 2013-02-15 00:06:04 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2013-02-15 00:06:04 +0000 |
commit | 75dfb43270088043e6c7d39abc0e302ad8ba00af (patch) | |
tree | 7f63af1c52b923bf2ca0d63b5afff4170d70200e /lldb/source/DataFormatters | |
parent | 30f05f3dc7db1c1ab803bf541960952e9ac46281 (diff) | |
download | bcm5719-llvm-75dfb43270088043e6c7d39abc0e302ad8ba00af.tar.gz bcm5719-llvm-75dfb43270088043e6c7d39abc0e302ad8ba00af.zip |
<rdar://problem/13204647>
The SEL data formatter was working hard to ensure that pointers-to-selectors could be formatted by the same block of code. In that effort, we were taking the address-of a SEL.
This operation fails when the SEL lives in a register, and was causing problems.
The formatter has been fixed to work correctly without assuming &selector will be a valid object.
llvm-svn: 175227
Diffstat (limited to 'lldb/source/DataFormatters')
-rw-r--r-- | lldb/source/DataFormatters/CXXFormatterFunctions.cpp | 33 | ||||
-rw-r--r-- | lldb/source/DataFormatters/FormatManager.cpp | 1 |
2 files changed, 23 insertions, 11 deletions
diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp index d03d76156a0..8fb75289d35 100644 --- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp +++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp @@ -1175,22 +1175,33 @@ template <bool is_sel_ptr> bool lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream) { - lldb::addr_t data_address = LLDB_INVALID_ADDRESS; - - if (is_sel_ptr) - data_address = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); - else - data_address = valobj.GetAddressOf(); + lldb::ValueObjectSP valobj_sp; - if (data_address == LLDB_INVALID_ADDRESS) + if (!valobj.GetClangAST()) return false; - - ExecutionContext exe_ctx(valobj.GetExecutionContextRef()); - void* char_opaque_type = valobj.GetClangAST()->CharTy.getAsOpaquePtr(); + if (!char_opaque_type) + return false; ClangASTType charstar(valobj.GetClangAST(),ClangASTType::GetPointerType(valobj.GetClangAST(), char_opaque_type)); + + ExecutionContext exe_ctx(valobj.GetExecutionContextRef()); - ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar)); + if (is_sel_ptr) + { + lldb::addr_t data_address = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + if (data_address == LLDB_INVALID_ADDRESS) + return false; + valobj_sp = ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar); + } + else + { + DataExtractor data; + valobj.GetData(data); + valobj_sp = ValueObject::CreateValueObjectFromData("text", data, exe_ctx, charstar); + } + + if (!valobj_sp) + return false; stream.Printf("%s",valobj_sp->GetSummaryAsCString()); return true; diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index eb8a3386a25..391b3ee981e 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -753,6 +753,7 @@ FormatManager::LoadObjCFormatters() AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("struct objc_selector"), objc_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("objc_selector"), objc_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary provider", ConstString("objc_selector *"), objc_flags); + AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary provider", ConstString("SEL *"), objc_flags); AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Class.Class_Summary", ConstString("Class"), objc_flags); #endif // LLDB_DISABLE_PYTHON |