diff options
author | Enrico Granata <egranata@apple.com> | 2013-05-06 17:18:22 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2013-05-06 17:18:22 +0000 |
commit | 36aa5ae625eeb638044bbda4aa8f27dfed0cd8d8 (patch) | |
tree | d0416d1cebecbe60871d2912f77bf9da4f7644ac /lldb/source/Core/Debugger.cpp | |
parent | eedfabd96e97c39080e4e91c21f17a7893932afa (diff) | |
download | bcm5719-llvm-36aa5ae625eeb638044bbda4aa8f27dfed0cd8d8.tar.gz bcm5719-llvm-36aa5ae625eeb638044bbda4aa8f27dfed0cd8d8.zip |
Converting ScanFormatDescriptor to use std::string instead of a manually managed buffer of bytes
llvm-svn: 181218
Diffstat (limited to 'lldb/source/Core/Debugger.cpp')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 09b4294e240..89c82ea76a5 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1143,34 +1143,40 @@ ScanFormatDescriptor (const char* var_name_begin, else { *var_name_final = *percent_position; - 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); + std::string format_name(*var_name_final+1, var_name_end-*var_name_final-1); if (log) - log->Printf("ScanFormatDescriptor] parsing %s as a format descriptor", format_name); - if ( !FormatManager::GetFormatFromCString(format_name, + log->Printf("ScanFormatDescriptor] parsing %s as a format descriptor", format_name.c_str()); + if ( !FormatManager::GetFormatFromCString(format_name.c_str(), true, *custom_format) ) { if (log) - 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; - // if this is a V, print the value using the default format - else if (*format_name == 'V') - *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue; - // if this is an L, print the location of the value - else if (*format_name == 'L') - *val_obj_display = ValueObject::eValueObjectRepresentationStyleLocation; - // if this is an S, print the summary after all - else if (*format_name == 'S') - *val_obj_display = ValueObject::eValueObjectRepresentationStyleSummary; - else if (*format_name == '#') - *val_obj_display = ValueObject::eValueObjectRepresentationStyleChildrenCount; - else if (*format_name == 'T') - *val_obj_display = ValueObject::eValueObjectRepresentationStyleType; - else if (log) - log->Printf("ScanFormatDescriptor] %s is an error, leaving the previous value alone", format_name); + log->Printf("ScanFormatDescriptor] %s is an unknown format", format_name.c_str()); + + switch (format_name.front()) + { + case '@': // if this is an @ sign, print ObjC description + *val_obj_display = ValueObject::eValueObjectRepresentationStyleLanguageSpecific; + break; + case 'V': // if this is a V, print the value using the default format + *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue; + break; + case 'L': // if this is an L, print the location of the value + *val_obj_display = ValueObject::eValueObjectRepresentationStyleLocation; + break; + case 'S': // if this is an S, print the summary after all + *val_obj_display = ValueObject::eValueObjectRepresentationStyleSummary; + break; + case '#': // if this is a '#', print the number of children + *val_obj_display = ValueObject::eValueObjectRepresentationStyleChildrenCount; + break; + case 'T': // if this is a 'T', print the type + *val_obj_display = ValueObject::eValueObjectRepresentationStyleType; + break; + default: + log->Printf("ScanFormatDescriptor] %s is an error, leaving the previous value alone", format_name.c_str()); + break; + } } // a good custom format tells us to print the value using it else @@ -1179,7 +1185,6 @@ ScanFormatDescriptor (const char* var_name_begin, log->Printf("ScanFormatDescriptor] will display value for this VO"); *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue; } - delete[] format_name; } if (log) log->Printf("ScanFormatDescriptor] final format description outcome: custom_format = %d, val_obj_display = %d", |