Improvements to the data formatters logging - plus, new log messages when our dynamic type changes

llvm-svn: 166133
This commit is contained in:
Enrico Granata 2012-10-17 22:23:56 +00:00
parent c5069ad26c
commit d228483d8c
4 changed files with 63 additions and 49 deletions

View File

@ -476,18 +476,18 @@ protected:
sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize()); sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize());
ConstString bitfieldname = ConstString(sstring.GetData()); ConstString bitfieldname = ConstString(sstring.GetData());
if (log) 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 (Get(bitfieldname, entry))
{ {
if (log) if (log)
log->Printf("bitfield direct match found, returning"); log->Printf("[Get_BitfieldMatch] bitfield direct match found, returning");
return true; return true;
} }
else else
{ {
reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField; reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
if (log) if (log)
log->Printf("no bitfield direct match"); log->Printf("[Get_BitfieldMatch] no bitfield direct match");
return false; return false;
} }
} }
@ -501,27 +501,27 @@ protected:
if (runtime == NULL) if (runtime == NULL)
{ {
if (log) if (log)
log->Printf("no valid ObjC runtime, skipping dynamic"); log->Printf("[Get_ObjC] no valid ObjC runtime, skipping dynamic");
return false; return false;
} }
ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj)); ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
if (!objc_class_sp) if (!objc_class_sp)
{ {
if (log) if (log)
log->Printf("invalid ISA, skipping dynamic"); log->Printf("[Get_ObjC] invalid ISA, skipping dynamic");
return false; return false;
} }
ConstString name (objc_class_sp->GetClassName()); ConstString name (objc_class_sp->GetClassName());
if (log) 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 (Get(name, entry))
{ {
if (log) if (log)
log->Printf("direct dynamic match found, returning"); log->Printf("[Get_ObjC] direct dynamic match found, returning");
return true; return true;
} }
if (log) if (log)
log->Printf("no dynamic match"); log->Printf("[Get_ObjC] no dynamic match");
return false; return false;
} }
@ -535,7 +535,7 @@ protected:
if (type.isNull()) if (type.isNull())
{ {
if (log) if (log)
log->Printf("type is NULL, returning"); log->Printf("[Get] type is NULL, returning");
return false; return false;
} }
@ -544,7 +544,7 @@ protected:
if (!typePtr) if (!typePtr)
{ {
if (log) if (log)
log->Printf("type is NULL, returning"); log->Printf("[Get] type is NULL, returning");
return false; return false;
} }
ConstString typeName(ClangASTType::GetTypeNameForQualType(valobj.GetClangAST(), type).c_str()); ConstString typeName(ClangASTType::GetTypeNameForQualType(valobj.GetClangAST(), type).c_str());
@ -556,7 +556,7 @@ protected:
} }
if (log) 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(), m_name.c_str(),
valobj.GetName().AsCString(), valobj.GetName().AsCString(),
typeName.AsCString()); typeName.AsCString());
@ -564,17 +564,17 @@ protected:
if (Get(typeName, entry)) if (Get(typeName, entry))
{ {
if (log) if (log)
log->Printf("direct match found, returning"); log->Printf("[Get] direct match found, returning");
return true; return true;
} }
if (log) if (log)
log->Printf("no direct match"); log->Printf("[Get] no direct match");
// strip pointers and references and see if that helps // strip pointers and references and see if that helps
if (typePtr->isReferenceType()) if (typePtr->isReferenceType())
{ {
if (log) if (log)
log->Printf("stripping reference"); log->Printf("[Get] stripping reference");
if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences()) if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences())
{ {
reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference; reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
@ -584,7 +584,7 @@ protected:
else if (typePtr->isPointerType()) else if (typePtr->isPointerType())
{ {
if (log) if (log)
log->Printf("stripping pointer"); log->Printf("[Get] stripping pointer");
clang::QualType pointee = typePtr->getPointeeType(); clang::QualType pointee = typePtr->getPointeeType();
if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers()) if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
{ {
@ -604,7 +604,7 @@ protected:
if (use_dynamic != lldb::eNoDynamicValues) if (use_dynamic != lldb::eNoDynamicValues)
{ {
if (log) 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)) if (Get_ObjC(valobj,entry))
{ {
reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery; reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery;
@ -612,7 +612,7 @@ protected:
} }
} }
if (log) 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(); clang::QualType pointee = typePtr->getPointeeType();
if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers()) if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
{ {
@ -626,7 +626,7 @@ protected:
if (type_tdef) if (type_tdef)
{ {
if (log) if (log)
log->Printf("stripping typedef"); log->Printf("[Get] stripping typedef");
if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades()) if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades())
{ {
reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs; reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs;

View File

@ -1095,7 +1095,7 @@ ScanFormatDescriptor (const char* var_name_begin,
if (!*percent_position || *percent_position > var_name_end) if (!*percent_position || *percent_position > var_name_end)
{ {
if (log) 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; *var_name_final = var_name_end;
} }
else else
@ -1104,13 +1104,13 @@ ScanFormatDescriptor (const char* var_name_begin,
char* format_name = new char[var_name_end-*var_name_final]; format_name[var_name_end-*var_name_final-1] = '\0'; 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); memcpy(format_name, *var_name_final+1, var_name_end-*var_name_final-1);
if (log) 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, if ( !FormatManager::GetFormatFromCString(format_name,
true, true,
*custom_format) ) *custom_format) )
{ {
if (log) 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 this is an @ sign, print ObjC description
if (*format_name == '@') if (*format_name == '@')
*val_obj_display = ValueObject::eValueObjectRepresentationStyleLanguageSpecific; *val_obj_display = ValueObject::eValueObjectRepresentationStyleLanguageSpecific;
@ -1128,19 +1128,19 @@ ScanFormatDescriptor (const char* var_name_begin,
else if (*format_name == 'T') else if (*format_name == 'T')
*val_obj_display = ValueObject::eValueObjectRepresentationStyleType; *val_obj_display = ValueObject::eValueObjectRepresentationStyleType;
else if (log) 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 // a good custom format tells us to print the value using it
else else
{ {
if (log) if (log)
log->Printf("will display value for this VO"); log->Printf("ScanFormatDescriptor] will display value for this VO");
*val_obj_display = ValueObject::eValueObjectRepresentationStyleValue; *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue;
} }
delete format_name; delete format_name;
} }
if (log) 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, *custom_format,
*val_obj_display); *val_obj_display);
return true; return true;
@ -1169,7 +1169,7 @@ ScanBracketedRange (const char* var_name_begin,
if (*close_bracket_position - *open_bracket_position == 1) if (*close_bracket_position - *open_bracket_position == 1)
{ {
if (log) 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; *index_lower = 0;
} }
else if (*separator_position == NULL || *separator_position > var_name_end) else if (*separator_position == NULL || *separator_position > var_name_end)
@ -1178,7 +1178,7 @@ ScanBracketedRange (const char* var_name_begin,
*index_lower = ::strtoul (*open_bracket_position+1, &end, 0); *index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
*index_higher = *index_lower; *index_higher = *index_lower;
if (log) 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) else if (*close_bracket_position && *close_bracket_position < var_name_end)
{ {
@ -1186,25 +1186,25 @@ ScanBracketedRange (const char* var_name_begin,
*index_lower = ::strtoul (*open_bracket_position+1, &end, 0); *index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
*index_higher = ::strtoul (*separator_position+1, &end, 0); *index_higher = ::strtoul (*separator_position+1, &end, 0);
if (log) if (log)
log->Printf("[%lld-%lld] detected", *index_lower, *index_higher); log->Printf("[ScanBracketedRange] [%lld-%lld] detected", *index_lower, *index_higher);
} }
else else
{ {
if (log) 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; return false;
} }
if (*index_lower > *index_higher && *index_higher > 0) if (*index_lower > *index_higher && *index_higher > 0)
{ {
if (log) if (log)
log->Printf("swapping indices"); log->Printf("[ScanBracketedRange] swapping indices");
int temp = *index_lower; int temp = *index_lower;
*index_lower = *index_higher; *index_lower = *index_higher;
*index_higher = temp; *index_higher = temp;
} }
} }
else if (log) else if (log)
log->Printf("no bracketed range, skipping entirely"); log->Printf("[ScanBracketedRange] no bracketed range, skipping entirely");
return true; return true;
} }
@ -1219,7 +1219,7 @@ ExpandIndexedExpression (ValueObject* valobj,
std::auto_ptr<char> ptr_deref_buffer(new char[10]); std::auto_ptr<char> ptr_deref_buffer(new char[10]);
::sprintf(ptr_deref_buffer.get(), ptr_deref_format, index); ::sprintf(ptr_deref_buffer.get(), ptr_deref_format, index);
if (log) 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; const char* first_unparsed;
ValueObject::GetValueForExpressionPathOptions options; ValueObject::GetValueForExpressionPathOptions options;
ValueObject::ExpressionPathEndResultType final_value_type; ValueObject::ExpressionPathEndResultType final_value_type;
@ -1234,14 +1234,14 @@ ExpandIndexedExpression (ValueObject* valobj,
if (!item) if (!item)
{ {
if (log) 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", " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type); first_unparsed, reason_to_stop, final_value_type);
} }
else else
{ {
if (log) 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", " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type); first_unparsed, reason_to_stop, final_value_type);
} }
@ -1354,7 +1354,7 @@ Debugger::FormatPrompt
break; break;
if (log) 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 // check for *var and *svar
if (*var_name_begin == '*') if (*var_name_begin == '*')
@ -1364,7 +1364,7 @@ Debugger::FormatPrompt
} }
if (log) 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') if (*var_name_begin == 's')
{ {
@ -1376,14 +1376,14 @@ Debugger::FormatPrompt
} }
if (log) 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 // should be a 'v' by now
if (*var_name_begin != 'v') if (*var_name_begin != 'v')
break; break;
if (log) 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::ExpressionPathAftermath what_next = (do_deref_pointer ?
ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing); ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing);
@ -1457,7 +1457,7 @@ Debugger::FormatPrompt
memcpy(expr_path.get(), var_name_begin+3,var_name_final-var_name_begin-3); memcpy(expr_path.get(), var_name_begin+3,var_name_final-var_name_begin-3);
if (log) 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(), target = valobj->GetValueForExpressionPath(expr_path.get(),
&first_unparsed, &first_unparsed,
@ -1469,7 +1469,7 @@ Debugger::FormatPrompt
if (!target) if (!target)
{ {
if (log) 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", " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type); first_unparsed, reason_to_stop, final_value_type);
break; break;
@ -1477,7 +1477,7 @@ Debugger::FormatPrompt
else else
{ {
if (log) 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", " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type); first_unparsed, reason_to_stop, final_value_type);
} }
@ -1500,7 +1500,7 @@ Debugger::FormatPrompt
if (error.Fail()) if (error.Fail())
{ {
if (log) if (log)
log->Printf("ERROR: %s\n", error.AsCString("unknown")); \ log->Printf("[Debugger::FormatPrompt] ERROR: %s\n", error.AsCString("unknown")); \
break; break;
} }
do_deref_pointer = false; do_deref_pointer = false;
@ -1529,7 +1529,7 @@ Debugger::FormatPrompt
{ {
StreamString str_temp; StreamString str_temp;
if (log) 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, if (target->HasSpecialPrintableRepresentation(val_obj_display,
custom_format)) custom_format))
@ -1539,7 +1539,7 @@ Debugger::FormatPrompt
val_obj_display, val_obj_display,
custom_format); custom_format);
if (log) 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 // should not happen
if (!var_success) if (!var_success)
@ -1591,17 +1591,17 @@ Debugger::FormatPrompt
if (!is_array_range) if (!is_array_range)
{ {
if (log) 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); var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format);
} }
else else
{ {
if (log) 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) if (!is_array && !is_pointer)
break; break;
if (log) if (log)
log->Printf("handle as array"); log->Printf("[Debugger::FormatPrompt] handle as array");
const char* special_directions = NULL; const char* special_directions = NULL;
StreamString special_directions_writer; StreamString special_directions_writer;
if (close_bracket_position && (var_name_end-close_bracket_position > 1)) if (close_bracket_position && (var_name_end-close_bracket_position > 1))
@ -1633,12 +1633,12 @@ Debugger::FormatPrompt
if (!item) if (!item)
{ {
if (log) 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 else
{ {
if (log) 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) if (!special_directions)

View File

@ -239,8 +239,9 @@ ValueObject::UpdateFormatsIfNeeded(DynamicValueType use_dynamic)
{ {
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
if (log) 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(), GetName().GetCString(),
this,
m_last_format_mgr_revision, m_last_format_mgr_revision,
DataVisualization::GetCurrentRevision()); DataVisualization::GetCurrentRevision());

View File

@ -14,6 +14,7 @@
// C++ Includes // C++ Includes
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h" #include "lldb/Core/Module.h"
#include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/Value.h" #include "lldb/Core/Value.h"
@ -287,10 +288,17 @@ ValueObjectDynamicValue::UpdateValue ()
Value old_value(m_value); Value old_value(m_value);
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
if (!m_type_sp) if (!m_type_sp)
{ {
m_type_sp = dynamic_type_sp; m_type_sp = dynamic_type_sp;
ResetCompleteTypeInfo (); 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) else if (dynamic_type_sp != m_type_sp)
{ {
@ -298,6 +306,11 @@ ValueObjectDynamicValue::UpdateValue ()
m_type_sp = dynamic_type_sp; m_type_sp = dynamic_type_sp;
SetValueDidChange (true); SetValueDidChange (true);
ResetCompleteTypeInfo (); 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) if (!m_address.IsValid() || m_address != dynamic_address)