summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorEnrico Granata <granata.enrico@gmail.com>2011-08-04 02:34:29 +0000
committerEnrico Granata <granata.enrico@gmail.com>2011-08-04 02:34:29 +0000
commit5dfd49ccba48bbfcfdfccf01deb0c513d113b180 (patch)
tree163387d8cd6c6f8453621c0e5994e72c789ddf3e /lldb/source/Core
parent6fd87d5d33c677badffcab70b60e8dcc169de07e (diff)
downloadbcm5719-llvm-5dfd49ccba48bbfcfdfccf01deb0c513d113b180.tar.gz
bcm5719-llvm-5dfd49ccba48bbfcfdfccf01deb0c513d113b180.zip
New formatting symbol %# can be used in summary strings to get the "count of children" of a variable
- accordingly, the test cases for the synthetic providers for the std:: containers have been edited to use ${svar%#} instead of ${svar.len} to print out the count of elements ; the .len synthetic child has been removed from the synthetic providers The synthetic children providers for the std:: containers now return None when asked for children indexes >= num_children() Basic code to support filter names based on regular expressions (WIP) llvm-svn: 136862
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Debugger.cpp2
-rw-r--r--lldb/source/Core/FormatClasses.cpp2
-rw-r--r--lldb/source/Core/FormatManager.cpp38
-rw-r--r--lldb/source/Core/ValueObject.cpp43
4 files changed, 71 insertions, 14 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 9442600a4d7..309afd4e87c 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -742,6 +742,8 @@ ScanFormatDescriptor(const char* var_name_begin,
// if this is an S, print the summary after all
else if (*format_name == 'S')
*val_obj_display = ValueObject::eDisplaySummary;
+ else if (*format_name == '#')
+ *val_obj_display = ValueObject::eDisplayChildrenCount;
else if (log)
log->Printf("%s is an error, leaving the previous value alone", format_name);
}
diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp
index 48097087253..aeace975932 100644
--- a/lldb/source/Core/FormatClasses.cpp
+++ b/lldb/source/Core/FormatClasses.cpp
@@ -84,7 +84,7 @@ StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
s.PutCString(", ");
s.PutCString(child_sp.get()->GetName().AsCString());
s.PutChar('=');
- s.PutCString(child_sp.get()->GetPrintableRepresentation());
+ child_sp.get()->GetPrintableRepresentation(s);
}
}
diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp
index e064534028f..47426fc49d5 100644
--- a/lldb/source/Core/FormatManager.cpp
+++ b/lldb/source/Core/FormatManager.cpp
@@ -192,6 +192,44 @@ FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Delete(const char* ty
return false;
}
+template<>
+bool
+FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>::Get(const char* key, SyntheticFilter::SharedPointer& value)
+{
+ Mutex::Locker(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++)
+ {
+ lldb::RegularExpressionSP regex = pos->first;
+ if (regex->Execute(key))
+ {
+ value = pos->second;
+ return true;
+ }
+ }
+ return false;
+}
+
+template<>
+bool
+FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>::Delete(const char* type)
+{
+ Mutex::Locker(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++)
+ {
+ lldb::RegularExpressionSP regex = pos->first;
+ if ( ::strcmp(type,regex->GetText()) == 0)
+ {
+ m_format_map.map().erase(pos);
+ if (m_format_map.listener)
+ m_format_map.listener->Changed();
+ return true;
+ }
+ }
+ return false;
+}
+
lldb::Format
FormatManager::GetSingleItemFormat(lldb::Format vector_format)
{
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index fce00f6d4f3..1453ee23714 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -941,11 +941,9 @@ ValueObject::GetValueAsUnsigned()
return 0;
}
-// this call should only return pointers to data that needs no special memory management
-// (either because they are hardcoded strings, or because they are backed by some other
-// object); returning any new()-ed or malloc()-ed data here, will lead to leaks!
-const char *
-ValueObject::GetPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display,
+bool
+ValueObject::GetPrintableRepresentation(Stream& s,
+ ValueObjectRepresentationStyle val_obj_display,
lldb::Format custom_format)
{
@@ -955,6 +953,7 @@ ValueObject::GetPrintableRepresentation(ValueObjectRepresentationStyle val_obj_d
SetFormat(custom_format);
const char * return_value;
+ std::auto_ptr<char> alloc_mem;
switch(val_obj_display)
{
@@ -970,6 +969,17 @@ ValueObject::GetPrintableRepresentation(ValueObjectRepresentationStyle val_obj_d
case eDisplayLocation:
return_value = GetLocationAsCString();
break;
+ case eDisplayChildrenCount:
+ // keep this out of the local scope so it will only get deleted when
+ // we exit the function (..and we have a copy of the data into the Stream)
+ alloc_mem = std::auto_ptr<char>((char*)(return_value = new char[512]));
+ {
+ int count = GetNumChildren();
+ snprintf(alloc_mem.get(), 512, "%d", count);
+ break;
+ }
+ default:
+ break;
}
// this code snippet might lead to endless recursion, thus we use a RefCounter here to
@@ -983,16 +993,26 @@ ValueObject::GetPrintableRepresentation(ValueObjectRepresentationStyle val_obj_d
{
if (ClangASTContext::IsAggregateType (GetClangType()) == true)
{
- // this thing has no value
- return_value = "<no summary defined for this datatype>";
+ // this thing has no value, and it seems to have no summary
+ // some combination of unitialized data and other factors can also
+ // raise this condition, so let's print a nice generic error message
+ return_value = "<no available summary>";
}
else
return_value = GetValueAsCString();
}
}
- return (return_value ? return_value : "<no printable representation>");
-
+ if (return_value)
+ s.PutCString(return_value);
+ else
+ s.PutCString("<no printable representation>");
+
+ // we should only return false here if we could not do *anything*
+ // even if we have an error message as output, that's a success
+ // from our callers' perspective, so return true
+ return true;
+
}
bool
@@ -1116,10 +1136,7 @@ ValueObject::DumpPrintableRepresentation(Stream& s,
(custom_format == lldb::eFormatDefault)) // use the [] operator
return false;
}
- const char *targetvalue = GetPrintableRepresentation(val_obj_display, custom_format);
- if (targetvalue)
- s.PutCString(targetvalue);
- bool var_success = (targetvalue != NULL);
+ bool var_success = GetPrintableRepresentation(s, val_obj_display, custom_format);
if (custom_format != eFormatInvalid)
SetFormat(eFormatDefault);
return var_success;
OpenPOWER on IntegriCloud