From 75dfb43270088043e6c7d39abc0e302ad8ba00af Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Fri, 15 Feb 2013 00:06:04 +0000 Subject: [PATCH] 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 --- .../DataFormatters/CXXFormatterFunctions.cpp | 33 ++++++++++++++-------- 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 d03d761..8fb7528 100644 --- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp +++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp @@ -1175,22 +1175,33 @@ template 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 eb8a3386..391b3ee 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, "SEL summary provider", ConstString("struct objc_selector"), objc_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider, "SEL summary provider", ConstString("objc_selector"), objc_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider, "SEL summary provider", ConstString("objc_selector *"), objc_flags); + AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider, "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 -- 2.7.4