[Lldb-commits] [lldb] r166133 - in /lldb/trunk: include/lldb/Core/FormatNavigator.h source/Core/Debugger.cpp source/Core/ValueObject.cpp source/Core/ValueObjectDynamicValue.cpp

Enrico Granata egranata at apple.com
Wed Oct 17 15:23:56 PDT 2012


Author: enrico
Date: Wed Oct 17 17:23:56 2012
New Revision: 166133

URL: http://llvm.org/viewvc/llvm-project?rev=166133&view=rev
Log:
Improvements to the data formatters logging - plus, new log messages when our dynamic type changes

Modified:
    lldb/trunk/include/lldb/Core/FormatNavigator.h
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Core/ValueObjectDynamicValue.cpp

Modified: lldb/trunk/include/lldb/Core/FormatNavigator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatNavigator.h?rev=166133&r1=166132&r2=166133&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/Core/FormatNavigator.h Wed Oct 17 17:23:56 2012
@@ -476,18 +476,18 @@
         sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize());
         ConstString bitfieldname = ConstString(sstring.GetData());
         if (log)
-            log->Printf("appended bitfield info, final result is %s", bitfieldname.GetCString());
+            log->Printf("[Get_BitfieldMatch] appended bitfield info, final result is %s", bitfieldname.GetCString());
         if (Get(bitfieldname, entry))
         {
             if (log)
-                log->Printf("bitfield direct match found, returning");
+                log->Printf("[Get_BitfieldMatch] bitfield direct match found, returning");
             return true;
         }
         else
         {
             reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
             if (log)
-                log->Printf("no bitfield direct match");
+                log->Printf("[Get_BitfieldMatch] no bitfield direct match");
             return false;
         }
     }
@@ -501,27 +501,27 @@
         if (runtime == NULL)
         {
             if (log)
-                log->Printf("no valid ObjC runtime, skipping dynamic");
+                log->Printf("[Get_ObjC] no valid ObjC runtime, skipping dynamic");
             return false;
         }
         ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
         if (!objc_class_sp)
         {
             if (log)
-                log->Printf("invalid ISA, skipping dynamic");
+                log->Printf("[Get_ObjC] invalid ISA, skipping dynamic");
             return false;
         }
         ConstString name (objc_class_sp->GetClassName());
         if (log)
-            log->Printf("dynamic type inferred is %s - looking for direct dynamic match", name.GetCString());
+            log->Printf("[Get_ObjC] dynamic type inferred is %s - looking for direct dynamic match", name.GetCString());
         if (Get(name, entry))
         {
             if (log)
-                log->Printf("direct dynamic match found, returning");
+                log->Printf("[Get_ObjC] direct dynamic match found, returning");
             return true;
         }
         if (log)
-            log->Printf("no dynamic match");
+            log->Printf("[Get_ObjC] no dynamic match");
         return false;
     }
     
@@ -535,7 +535,7 @@
         if (type.isNull())
         {
             if (log)
-                log->Printf("type is NULL, returning");
+                log->Printf("[Get] type is NULL, returning");
             return false;
         }
 
@@ -544,7 +544,7 @@
         if (!typePtr)
         {
             if (log)
-                log->Printf("type is NULL, returning");
+                log->Printf("[Get] type is NULL, returning");
             return false;
         }
         ConstString typeName(ClangASTType::GetTypeNameForQualType(valobj.GetClangAST(), type).c_str());
@@ -556,7 +556,7 @@
         }
         
         if (log)
-            log->Printf("trying to get %s for VO name %s of type %s",
+            log->Printf("[Get] trying to get %s for VO name %s of type %s",
                         m_name.c_str(),
                         valobj.GetName().AsCString(),
                         typeName.AsCString());
@@ -564,17 +564,17 @@
         if (Get(typeName, entry))
         {
             if (log)
-                log->Printf("direct match found, returning");
+                log->Printf("[Get] direct match found, returning");
             return true;
         }
         if (log)
-            log->Printf("no direct match");
+            log->Printf("[Get] no direct match");
 
         // strip pointers and references and see if that helps
         if (typePtr->isReferenceType())
         {
             if (log)
-                log->Printf("stripping reference");
+                log->Printf("[Get] stripping reference");
             if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences())
             {
                 reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
@@ -584,7 +584,7 @@
         else if (typePtr->isPointerType())
         {
             if (log)
-                log->Printf("stripping pointer");
+                log->Printf("[Get] stripping pointer");
             clang::QualType pointee = typePtr->getPointeeType();
             if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
             {
@@ -604,7 +604,7 @@
             if (use_dynamic != lldb::eNoDynamicValues)
             {
                 if (log)
-                    log->Printf("allowed to figure out dynamic ObjC type");
+                    log->Printf("[Get] allowed to figure out dynamic ObjC type");
                 if (Get_ObjC(valobj,entry))
                 {
                     reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery;
@@ -612,7 +612,7 @@
                 }
             }
             if (log)
-                log->Printf("dynamic disabled or failed - stripping ObjC pointer");
+                log->Printf("[Get] dynamic disabled or failed - stripping ObjC pointer");
             clang::QualType pointee = typePtr->getPointeeType();
             if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
             {
@@ -626,7 +626,7 @@
         if (type_tdef)
         {
             if (log)
-                log->Printf("stripping typedef");
+                log->Printf("[Get] stripping typedef");
             if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades())
             {
                 reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs;

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=166133&r1=166132&r2=166133&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Oct 17 17:23:56 2012
@@ -1095,7 +1095,7 @@
     if (!*percent_position || *percent_position > var_name_end)
     {
         if (log)
-            log->Printf("no format descriptor in string, skipping");
+            log->Printf("[ScanFormatDescriptor] no format descriptor in string, skipping");
         *var_name_final = var_name_end;
     }
     else
@@ -1104,13 +1104,13 @@
         char* format_name = new char[var_name_end-*var_name_final]; format_name[var_name_end-*var_name_final-1] = '\0';
         memcpy(format_name, *var_name_final+1, var_name_end-*var_name_final-1);
         if (log)
-            log->Printf("parsing %s as a format descriptor", format_name);
+            log->Printf("ScanFormatDescriptor] parsing %s as a format descriptor", format_name);
         if ( !FormatManager::GetFormatFromCString(format_name,
                                                   true,
                                                   *custom_format) )
         {
             if (log)
-                log->Printf("%s is an unknown format", format_name);
+                log->Printf("ScanFormatDescriptor] %s is an unknown format", format_name);
             // if this is an @ sign, print ObjC description
             if (*format_name == '@')
                 *val_obj_display = ValueObject::eValueObjectRepresentationStyleLanguageSpecific;
@@ -1128,19 +1128,19 @@
             else if (*format_name == 'T')
                 *val_obj_display = ValueObject::eValueObjectRepresentationStyleType;
             else if (log)
-                log->Printf("%s is an error, leaving the previous value alone", format_name);
+                log->Printf("ScanFormatDescriptor] %s is an error, leaving the previous value alone", format_name);
         }
         // a good custom format tells us to print the value using it
         else
         {
             if (log)
-                log->Printf("will display value for this VO");
+                log->Printf("ScanFormatDescriptor] will display value for this VO");
             *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue;
         }
         delete format_name;
     }
     if (log)
-        log->Printf("final format description outcome: custom_format = %d, val_obj_display = %d",
+        log->Printf("ScanFormatDescriptor] final format description outcome: custom_format = %d, val_obj_display = %d",
                     *custom_format,
                     *val_obj_display);
     return true;
@@ -1169,7 +1169,7 @@
         if (*close_bracket_position - *open_bracket_position == 1)
         {
             if (log)
-                log->Printf("[] detected.. going from 0 to end of data");
+                log->Printf("[ScanBracketedRange] '[]' detected.. going from 0 to end of data");
             *index_lower = 0;
         }
         else if (*separator_position == NULL || *separator_position > var_name_end)
@@ -1178,7 +1178,7 @@
             *index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
             *index_higher = *index_lower;
             if (log)
-                log->Printf("[%lld] detected, high index is same", *index_lower);
+                log->Printf("[ScanBracketedRange] [%lld] detected, high index is same", *index_lower);
         }
         else if (*close_bracket_position && *close_bracket_position < var_name_end)
         {
@@ -1186,25 +1186,25 @@
             *index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
             *index_higher = ::strtoul (*separator_position+1, &end, 0);
             if (log)
-                log->Printf("[%lld-%lld] detected", *index_lower, *index_higher);
+                log->Printf("[ScanBracketedRange] [%lld-%lld] detected", *index_lower, *index_higher);
         }
         else
         {
             if (log)
-                log->Printf("expression is erroneous, cannot extract indices out of it");
+                log->Printf("[ScanBracketedRange] expression is erroneous, cannot extract indices out of it");
             return false;
         }
         if (*index_lower > *index_higher && *index_higher > 0)
         {
             if (log)
-                log->Printf("swapping indices");
+                log->Printf("[ScanBracketedRange] swapping indices");
             int temp = *index_lower;
             *index_lower = *index_higher;
             *index_higher = temp;
         }
     }
     else if (log)
-            log->Printf("no bracketed range, skipping entirely");
+            log->Printf("[ScanBracketedRange] no bracketed range, skipping entirely");
     return true;
 }
 
@@ -1219,7 +1219,7 @@
     std::auto_ptr<char> ptr_deref_buffer(new char[10]);
     ::sprintf(ptr_deref_buffer.get(), ptr_deref_format, index);
     if (log)
-        log->Printf("name to deref: %s",ptr_deref_buffer.get());
+        log->Printf("[ExpandIndexedExpression] name to deref: %s",ptr_deref_buffer.get());
     const char* first_unparsed;
     ValueObject::GetValueForExpressionPathOptions options;
     ValueObject::ExpressionPathEndResultType final_value_type;
@@ -1234,14 +1234,14 @@
     if (!item)
     {
         if (log)
-            log->Printf("ERROR: unparsed portion = %s, why stopping = %d,"
+            log->Printf("[ExpandIndexedExpression] ERROR: unparsed portion = %s, why stopping = %d,"
                " final_value_type %d",
                first_unparsed, reason_to_stop, final_value_type);
     }
     else
     {
         if (log)
-            log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
+            log->Printf("[ExpandIndexedExpression] ALL RIGHT: unparsed portion = %s, why stopping = %d,"
                " final_value_type %d",
                first_unparsed, reason_to_stop, final_value_type);
     }
@@ -1354,7 +1354,7 @@
                                     break;
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                 
                                 // check for *var and *svar
                                 if (*var_name_begin == '*')
@@ -1364,7 +1364,7 @@
                                 }
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                 
                                 if (*var_name_begin == 's')
                                 {
@@ -1376,14 +1376,14 @@
                                 }
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                 
                                 // should be a 'v' by now
                                 if (*var_name_begin != 'v')
                                     break;
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                                                 
                                 ValueObject::ExpressionPathAftermath what_next = (do_deref_pointer ?
                                                                                   ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing);
@@ -1457,7 +1457,7 @@
                                     memcpy(expr_path.get(), var_name_begin+3,var_name_final-var_name_begin-3);
                                                                         
                                     if (log)
-                                        log->Printf("symbol to expand: %s",expr_path.get());
+                                        log->Printf("[Debugger::FormatPrompt] symbol to expand: %s",expr_path.get());
                                     
                                     target = valobj->GetValueForExpressionPath(expr_path.get(),
                                                                              &first_unparsed,
@@ -1469,7 +1469,7 @@
                                     if (!target)
                                     {
                                         if (log)
-                                            log->Printf("ERROR: unparsed portion = %s, why stopping = %d,"
+                                            log->Printf("[Debugger::FormatPrompt] ERROR: unparsed portion = %s, why stopping = %d,"
                                                " final_value_type %d",
                                                first_unparsed, reason_to_stop, final_value_type);
                                         break;
@@ -1477,7 +1477,7 @@
                                     else
                                     {
                                         if (log)
-                                            log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
+                                            log->Printf("[Debugger::FormatPrompt] ALL RIGHT: unparsed portion = %s, why stopping = %d,"
                                                " final_value_type %d",
                                                first_unparsed, reason_to_stop, final_value_type);
                                     }
@@ -1500,7 +1500,7 @@
                                     if (error.Fail())
                                     {
                                         if (log)
-                                            log->Printf("ERROR: %s\n", error.AsCString("unknown")); \
+                                            log->Printf("[Debugger::FormatPrompt] ERROR: %s\n", error.AsCString("unknown")); \
                                         break;
                                     }
                                     do_deref_pointer = false;
@@ -1529,7 +1529,7 @@
                                 {
                                     StreamString str_temp;
                                     if (log)
-                                        log->Printf("I am into array || pointer && !range");
+                                        log->Printf("[Debugger::FormatPrompt] I am into array || pointer && !range");
                                     
                                     if (target->HasSpecialPrintableRepresentation(val_obj_display,
                                                                                   custom_format))
@@ -1539,7 +1539,7 @@
                                                                                           val_obj_display,
                                                                                           custom_format);
                                         if (log)
-                                            log->Printf("special cases did%s match", var_success ? "" : "n't");
+                                            log->Printf("[Debugger::FormatPrompt] special cases did%s match", var_success ? "" : "n't");
                                         
                                         // should not happen
                                         if (!var_success)
@@ -1591,17 +1591,17 @@
                                 if (!is_array_range)
                                 {
                                     if (log)
-                                        log->Printf("dumping ordinary printable output");
+                                        log->Printf("[Debugger::FormatPrompt] dumping ordinary printable output");
                                     var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format);
                                 }
                                 else
                                 {   
                                     if (log)
-                                        log->Printf("checking if I can handle as array");
+                                        log->Printf("[Debugger::FormatPrompt] checking if I can handle as array");
                                     if (!is_array && !is_pointer)
                                         break;
                                     if (log)
-                                        log->Printf("handle as array");
+                                        log->Printf("[Debugger::FormatPrompt] handle as array");
                                     const char* special_directions = NULL;
                                     StreamString special_directions_writer;
                                     if (close_bracket_position && (var_name_end-close_bracket_position > 1))
@@ -1633,12 +1633,12 @@
                                         if (!item)
                                         {
                                             if (log)
-                                                log->Printf("ERROR in getting child item at index %lld", index_lower);
+                                                log->Printf("[Debugger::FormatPrompt] ERROR in getting child item at index %lld", index_lower);
                                         }
                                         else
                                         {
                                             if (log)
-                                                log->Printf("special_directions for child item: %s",special_directions);
+                                                log->Printf("[Debugger::FormatPrompt] special_directions for child item: %s",special_directions);
                                         }
 
                                         if (!special_directions)

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=166133&r1=166132&r2=166133&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Wed Oct 17 17:23:56 2012
@@ -239,8 +239,9 @@
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     if (log)
-        log->Printf("checking for FormatManager revisions. VO named %s is at revision %d, while the format manager is at revision %d",
+        log->Printf("[%s %p] checking for FormatManager revisions. ValueObject rev: %d - Global rev: %d",
            GetName().GetCString(),
+           this,
            m_last_format_mgr_revision,
            DataVisualization::GetCurrentRevision());
     

Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=166133&r1=166132&r2=166133&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Wed Oct 17 17:23:56 2012
@@ -14,6 +14,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ValueObjectList.h"
 #include "lldb/Core/Value.h"
@@ -287,10 +288,17 @@
     
     Value old_value(m_value);
 
+    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    
     if (!m_type_sp)
     {
         m_type_sp = dynamic_type_sp;
         ResetCompleteTypeInfo ();
+        if (log)
+            log->Printf("[%s %p] now has a dynamic type %s",
+                        GetName().GetCString(),
+                        this,
+                        GetTypeName().AsCString(""));
     }
     else if (dynamic_type_sp != m_type_sp)
     {
@@ -298,6 +306,11 @@
         m_type_sp = dynamic_type_sp;
         SetValueDidChange (true);
         ResetCompleteTypeInfo ();
+        if (log)
+            log->Printf("[%s %p] has a new dynamic type %s",
+                        GetName().GetCString(),
+                        this,
+                        GetTypeName().AsCString(""));
     }
     
     if (!m_address.IsValid() || m_address != dynamic_address)





More information about the lldb-commits mailing list