[Lldb-commits] [lldb] r246580 - Add logging to a couple of regions of code

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 1 13:11:13 PDT 2015


Author: enrico
Date: Tue Sep  1 15:11:13 2015
New Revision: 246580

URL: http://llvm.org/viewvc/llvm-project?rev=246580&view=rev
Log:
Add logging to a couple of regions of code


Modified:
    lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

Modified: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=246580&r1=246579&r2=246580&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Tue Sep  1 15:11:13 2015
@@ -229,6 +229,19 @@ TypeCategoryMap::GetFormat (ValueObject&
     
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     
+    if (log)
+    {
+        for (auto match : matches)
+        {
+            log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+                        match.GetTypeName().GetCString(),
+                        match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+                        match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+                        match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+                        match.GetReason());
+        }
+    }
+
     for (begin = m_active_categories.begin(); begin != end; begin++)
     {
         lldb::TypeCategoryImplSP category_sp = *begin;
@@ -256,6 +269,19 @@ TypeCategoryMap::GetSummaryFormat (Value
     
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     
+    if (log)
+    {
+        for (auto match : matches)
+        {
+            log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+                        match.GetTypeName().GetCString(),
+                        match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+                        match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+                        match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+                        match.GetReason());
+        }
+    }
+
     for (begin = m_active_categories.begin(); begin != end; begin++)
     {
         lldb::TypeCategoryImplSP category_sp = *begin;
@@ -285,6 +311,19 @@ TypeCategoryMap::GetSyntheticChildren (V
     
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     
+    if (log)
+    {
+        for (auto match : matches)
+        {
+            log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+                        match.GetTypeName().GetCString(),
+                        match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+                        match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+                        match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+                        match.GetReason());
+        }
+    }
+
     for (begin = m_active_categories.begin(); begin != end; begin++)
     {
         lldb::TypeCategoryImplSP category_sp = *begin;
@@ -313,6 +352,19 @@ TypeCategoryMap::GetValidator (ValueObje
     
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     
+    if (log)
+    {
+        for (auto match : matches)
+        {
+            log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+                        match.GetTypeName().GetCString(),
+                        match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+                        match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+                        match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+                        match.GetReason());
+        }
+    }
+
     for (begin = m_active_categories.begin(); begin != end; begin++)
     {
         lldb::TypeCategoryImplSP category_sp = *begin;

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp?rev=246580&r1=246579&r2=246580&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp Tue Sep  1 15:11:13 2015
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "AppleObjCClassDescriptorV2.h"
+#include "lldb/Core/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -518,6 +519,9 @@ ClassDescriptorV2::iVarsStorage::fill (A
     if (m_filled)
         return;
     Mutex::Locker lock(m_mutex);
+    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_VERBOSE));
+    if (log)
+        log->Printf("[ClassDescriptorV2::iVarsStorage::fill] class_name = %s", descriptor.GetClassName().AsCString("<unknown"));
     m_filled = true;
     ObjCLanguageRuntime::EncodingToTypeSP encoding_to_type_sp(runtime.GetEncodingToType());
     Process* process(runtime.GetProcess());
@@ -526,17 +530,33 @@ ClassDescriptorV2::iVarsStorage::fill (A
     descriptor.Describe(nullptr,
                         nullptr,
                         nullptr,
-                        [this,process,encoding_to_type_sp](const char * name, const char * type, lldb::addr_t offset_ptr, uint64_t size) -> bool {
+                        [this,process,encoding_to_type_sp,log](const char * name, const char * type, lldb::addr_t offset_ptr, uint64_t size) -> bool {
                  const bool for_expression = false;
                  const bool stop_loop = false;
+                 if (log)
+                     log->Printf("[ClassDescriptorV2::iVarsStorage::fill] name = %s, encoding = %s, offset_ptr = %" PRIx64 ", size = %" PRIu64,
+                                 name,type,offset_ptr,size);
                  CompilerType ivar_type = encoding_to_type_sp->RealizeType(type, for_expression);
                  if (ivar_type)
                  {
+                     if (log)
+                         log->Printf("[ClassDescriptorV2::iVarsStorage::fill] name = %s, encoding = %s, offset_ptr = %" PRIx64 ", size = %" PRIu64 " , type_size = %" PRIu64,
+                                     name,type,offset_ptr,size,ivar_type.GetByteSize(nullptr));
                      Scalar offset_scalar;
                      Error error;
-                     size_t read = process->ReadScalarIntegerFromMemory(offset_ptr, 4, true, offset_scalar, error);
+                     const int offset_ptr_size = 4;
+                     const bool is_signed = false;
+                     size_t read = process->ReadScalarIntegerFromMemory(offset_ptr, offset_ptr_size, is_signed, offset_scalar, error);
                      if (error.Success() && 4 == read)
+                     {
+                         if (log)
+                             log->Printf("[ClassDescriptorV2::iVarsStorage::fill] offset_ptr = %" PRIx64 " --> %" PRIu32,
+                                         offset_ptr, offset_scalar.SInt());
                          m_ivars.push_back({ ConstString(name), ivar_type, size, offset_scalar.SInt() });
+                     }
+                     else if (log)
+                         log->Printf("[ClassDescriptorV2::iVarsStorage::fill] offset_ptr = %" PRIx64 " --> read fail, read = %zu",
+                                     offset_ptr, read);
                  }
                  return stop_loop;
              });




More information about the lldb-commits mailing list