diff options
author | Enrico Granata <granata.enrico@gmail.com> | 2011-08-04 02:34:29 +0000 |
---|---|---|
committer | Enrico Granata <granata.enrico@gmail.com> | 2011-08-04 02:34:29 +0000 |
commit | 5dfd49ccba48bbfcfdfccf01deb0c513d113b180 (patch) | |
tree | 163387d8cd6c6f8453621c0e5994e72c789ddf3e /lldb/source/Core/ValueObject.cpp | |
parent | 6fd87d5d33c677badffcab70b60e8dcc169de07e (diff) | |
download | bcm5719-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/ValueObject.cpp')
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
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; |