[Lldb-commits] [lldb] r175227 - <rdar://problem/13204647>

Enrico Granata egranata at apple.com
Thu Feb 14 16:06:04 PST 2013


Author: enrico
Date: Thu Feb 14 18:06:04 2013
New Revision: 175227

URL: http://llvm.org/viewvc/llvm-project?rev=175227&view=rev
Log:
<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.


Modified:
    lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
    lldb/trunk/source/DataFormatters/FormatManager.cpp

Modified: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?rev=175227&r1=175226&r2=175227&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Thu Feb 14 18:06:04 2013
@@ -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());
+    
+    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);
+    }
     
-    ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar));
+    if (!valobj_sp)
+        return false;
     
     stream.Printf("%s",valobj_sp->GetSummaryAsCString());
     return true;

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=175227&r1=175226&r2=175227&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Thu Feb 14 18:06:04 2013
@@ -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





More information about the lldb-commits mailing list