[Lldb-commits] [lldb] r165252 - /lldb/trunk/source/Core/CXXFormatterFunctions.cpp

Enrico Granata egranata at apple.com
Thu Oct 4 14:04:46 PDT 2012


Author: enrico
Date: Thu Oct  4 16:04:46 2012
New Revision: 165252

URL: http://llvm.org/viewvc/llvm-project?rev=165252&view=rev
Log:
<rdar://problem/12424824> Making sure that we correctly update our synthetic children provider for NSArray - the same work will need to be done for NSDictionary

Modified:
    lldb/trunk/source/Core/CXXFormatterFunctions.cpp

Modified: lldb/trunk/source/Core/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CXXFormatterFunctions.cpp?rev=165252&r1=165251&r2=165252&view=diff
==============================================================================
--- lldb/trunk/source/Core/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/Core/CXXFormatterFunctions.cpp Thu Oct  4 16:04:46 2012
@@ -781,39 +781,11 @@
 m_data_32(NULL),
 m_data_64(NULL)
 {
-    if (!valobj_sp)
-        return;
-    if (valobj_sp->IsDynamic())
-        valobj_sp = valobj_sp->GetStaticValue();
-    if (!valobj_sp)
-        return;
-    m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
-    Error error;
-    if (valobj_sp->IsPointerType())
-    {
-        valobj_sp = valobj_sp->Dereference(error);
-        if (error.Fail() || !valobj_sp)
-            return;
-    }
-    error.Clear();
-    lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
-    if (!process_sp)
-        return;
-    m_ptr_size = process_sp->GetAddressByteSize();
-    uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
-    if (m_ptr_size == 4)
-    {
-        m_data_32 = new DataDescriptor_32();
-        process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
-    }
-    else
+    if (valobj_sp)
     {
-        m_data_64 = new DataDescriptor_64();
-        process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
+        m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
+        Update();
     }
-    if (error.Fail())
-        return;
-    m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
 }
 
 uint32_t
@@ -849,6 +821,42 @@
 lldb_private::formatters::NSArrayMSyntheticFrontEnd::Update()
 {
     m_children.clear();
+    ValueObjectSP valobj_sp = m_backend.GetSP();
+    m_ptr_size = 0;
+    delete m_data_32;
+    m_data_32 = NULL;
+    delete m_data_64;
+    m_data_64 = NULL;
+    if (valobj_sp->IsDynamic())
+        valobj_sp = valobj_sp->GetStaticValue();
+    if (!valobj_sp)
+        return false;
+    m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+    Error error;
+    if (valobj_sp->IsPointerType())
+    {
+        valobj_sp = valobj_sp->Dereference(error);
+        if (error.Fail() || !valobj_sp)
+            return false;
+    }
+    error.Clear();
+    lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+    if (!process_sp)
+        return false;
+    m_ptr_size = process_sp->GetAddressByteSize();
+    uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
+    if (m_ptr_size == 4)
+    {
+        m_data_32 = new DataDescriptor_32();
+        process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
+    }
+    else
+    {
+        m_data_64 = new DataDescriptor_64();
+        process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
+    }
+    if (error.Fail())
+        return false;
     return false;
 }
 
@@ -901,31 +909,11 @@
 m_items(0),
 m_data_ptr(0)
 {
-    if (!valobj_sp)
-        return;
-    if (valobj_sp->IsDynamic())
-        valobj_sp = valobj_sp->GetStaticValue();
-    if (!valobj_sp)
-        return;
-    m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
-    Error error;
-    if (valobj_sp->IsPointerType())
+    if (valobj_sp)
     {
-        valobj_sp = valobj_sp->Dereference(error);
-        if (error.Fail() || !valobj_sp)
-            return;
+        m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
+        Update();
     }
-    error.Clear();
-    lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
-    if (!process_sp)
-        return;
-    m_ptr_size = process_sp->GetAddressByteSize();
-    uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
-    m_items = process_sp->ReadPointerFromMemory(data_location, error);
-    if (error.Fail())
-        return;
-    m_data_ptr = data_location+m_ptr_size;
-    m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
 }
 
 lldb_private::formatters::NSArrayISyntheticFrontEnd::~NSArrayISyntheticFrontEnd ()
@@ -951,7 +939,33 @@
 bool
 lldb_private::formatters::NSArrayISyntheticFrontEnd::Update()
 {
+    m_ptr_size = 0;
+    m_items = 0;
+    m_data_ptr = 0;
     m_children.clear();
+    ValueObjectSP valobj_sp = m_backend.GetSP();
+    if (valobj_sp->IsDynamic())
+        valobj_sp = valobj_sp->GetStaticValue();
+    if (!valobj_sp)
+        return false;
+    m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+    Error error;
+    if (valobj_sp->IsPointerType())
+    {
+        valobj_sp = valobj_sp->Dereference(error);
+        if (error.Fail() || !valobj_sp)
+            return false;
+    }
+    error.Clear();
+    lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+    if (!process_sp)
+        return false;
+    m_ptr_size = process_sp->GetAddressByteSize();
+    uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
+    m_items = process_sp->ReadPointerFromMemory(data_location, error);
+    if (error.Fail())
+        return false;
+    m_data_ptr = data_location+m_ptr_size;
     return false;
 }
 





More information about the lldb-commits mailing list