diff options
author | Enrico Granata <granata.enrico@gmail.com> | 2012-02-02 23:34:52 +0000 |
---|---|---|
committer | Enrico Granata <granata.enrico@gmail.com> | 2012-02-02 23:34:52 +0000 |
commit | a6a60d0d87192d1cd99e46664c00e8e1d8d21da3 (patch) | |
tree | a68c05857e652796984fad930d2af47063d444c4 /lldb/source/Core | |
parent | e30365bfc28be0ab425ab1dc24a6fd726b796abb (diff) | |
download | bcm5719-llvm-a6a60d0d87192d1cd99e46664c00e8e1d8d21da3.tar.gz bcm5719-llvm-a6a60d0d87192d1cd99e46664c00e8e1d8d21da3.zip |
Added a new --omit-names (-O, uppercase letter o) option to "type summary add".
When used in conjunction with --inline-children, this option will cause the names of the values to be omitted from the output. This can be beneficial in cases such as vFloat, where it will compact the representation from
([0]=1,[1]=2,[2]=3,[3]=4) to (1, 2, 3, 4).
Added a test case to check that the new option works correctly.
Also took some time to revisit SummaryFormat and related classes and tweak them for added readability and maintainability.
Finally, added a new class name to which the std::string summary should be applied.
llvm-svn: 149644
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/FormatClasses.cpp | 80 | ||||
-rw-r--r-- | lldb/source/Core/FormatManager.cpp | 59 |
2 files changed, 61 insertions, 78 deletions
diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp index 30254d36994..07fcb4140c5 100644 --- a/lldb/source/Core/FormatClasses.cpp +++ b/lldb/source/Core/FormatClasses.cpp @@ -55,34 +55,14 @@ ValueFormat::ValueFormat (lldb::Format f, { } -SummaryFormat::SummaryFormat(bool casc, - bool skipptr, - bool skipref, - bool nochildren, - bool novalue, - bool oneliner) : - m_cascades(casc), - m_skip_pointers(skipptr), - m_skip_references(skipref), - m_dont_show_children(nochildren), - m_dont_show_value(novalue), - m_show_members_oneliner(oneliner) +SummaryFormat::SummaryFormat(const SummaryFormat::Flags& flags) : + m_flags(flags) { } -StringSummaryFormat::StringSummaryFormat(bool casc, - bool skipptr, - bool skipref, - bool nochildren, - bool novalue, - bool oneliner, +StringSummaryFormat::StringSummaryFormat(const SummaryFormat::Flags& flags, std::string f) : - SummaryFormat(casc, - skipptr, - skipref, - nochildren, - novalue, - oneliner), + SummaryFormat(flags), m_format(f) { } @@ -102,7 +82,7 @@ StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) if (frame) sc = frame->GetSymbolContext(lldb::eSymbolContextEverything); - if (m_show_members_oneliner) + if (IsOneliner()) { ValueObjectSP synth_valobj = object->GetSyntheticValue(lldb::eUseSyntheticFilter); const uint32_t num_children = synth_valobj->GetNumChildren(); @@ -117,8 +97,11 @@ StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) { if (idx) s.PutCString(", "); - s.PutCString(child_sp.get()->GetName().AsCString()); - s.PutChar('='); + if (!HideNames()) + { + s.PutCString(child_sp.get()->GetName().AsCString()); + s.PutChar('='); + } child_sp.get()->GetPrintableRepresentation(s); } } @@ -144,32 +127,24 @@ std::string StringSummaryFormat::GetDescription() { StreamString sstr; - sstr.Printf ("`%s`%s%s%s%s%s%s", m_format.c_str(), - m_cascades ? "" : " (not cascading)", - m_dont_show_children ? "" : " (show children)", - m_dont_show_value ? " (hide value)" : "", - m_show_members_oneliner ? " (one-line printout)" : "", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : ""); + + sstr.Printf ("`%s`%s%s%s%s%s%s%s", m_format.c_str(), + Cascades() ? "" : " (not cascading)", + !DoesPrintChildren() ? "" : " (show children)", + !DoesPrintValue() ? " (hide value)" : "", + IsOneliner() ? " (one-line printout)" : "", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : "", + HideNames() ? " (hide member names)" : ""); return sstr.GetString(); } #ifndef LLDB_DISABLE_PYTHON -ScriptSummaryFormat::ScriptSummaryFormat(bool casc, - bool skipptr, - bool skipref, - bool nochildren, - bool novalue, - bool oneliner, +ScriptSummaryFormat::ScriptSummaryFormat(const SummaryFormat::Flags& flags, std::string fname, std::string pscri) : - SummaryFormat(casc, - skipptr, - skipref, - nochildren, - novalue, - oneliner), + SummaryFormat(flags), m_function_name(fname), m_python_script(pscri) { @@ -187,12 +162,13 @@ std::string ScriptSummaryFormat::GetDescription() { StreamString sstr; - sstr.Printf ("%s%s%s%s%s%s\n%s", m_cascades ? "" : " (not cascading)", - m_dont_show_children ? "" : " (show children)", - m_dont_show_value ? " (hide value)" : "", - m_show_members_oneliner ? " (one-line printout)" : "", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : "", + sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)", + !DoesPrintChildren() ? "" : " (show children)", + !DoesPrintValue() ? " (hide value)" : "", + IsOneliner() ? " (one-line printout)" : "", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : "", + HideNames() ? " (hide member names)" : "", m_python_script.c_str()); return sstr.GetString(); diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index 90762965d10..fb24f17d3ee 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -566,22 +566,24 @@ FormatManager::FormatManager() : // add some default stuff // most formats, summaries, ... actually belong to the users' lldbinit file rather than here - lldb::SummaryFormatSP string_format(new StringSummaryFormat(false, - true, - false, - true, - false, - false, - "${var%s}")); + lldb::SummaryFormatSP string_format(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(false) + .SetSkipPointers(true) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(false) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var%s}")); - lldb::SummaryFormatSP string_array_format(new StringSummaryFormat(false, - true, - false, - false, - false, - false, - "${var%s}")); + lldb::SummaryFormatSP string_array_format(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(false) + .SetSkipPointers(true) + .SetSkipReferences(false) + .SetDontShowChildren(false) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var%s}")); lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]")); @@ -600,12 +602,13 @@ FormatManager::FormatManager() : // the GNU libstdc++ are defined regardless, and enabled by default // This is going to be moved to some platform-dependent location // (in the meanwhile, these formatters should work for Mac OS X & Linux) - lldb::SummaryFormatSP std_string_summary_sp(new StringSummaryFormat(true, - false, - false, - true, - true, - false, + lldb::SummaryFormatSP std_string_summary_sp(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(true) + .SetSkipPointers(false) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), "${var._M_dataplus._M_p}")); FormatCategory::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name); @@ -616,6 +619,9 @@ FormatManager::FormatManager() : std_string_summary_sp); gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"), std_string_summary_sp); + gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char, class std::char_traits<char>, class std::allocator<char> >"), + std_string_summary_sp); + #ifndef LLDB_DISABLE_PYTHON gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::)?vector<.+>$")), @@ -634,12 +640,13 @@ FormatManager::FormatManager() : false, "gnu_libstdcpp.StdListSynthProvider"))); - lldb::SummaryFormatSP ObjC_BOOL_summary(new ScriptSummaryFormat(false, - false, - false, - true, - true, - false, + lldb::SummaryFormatSP ObjC_BOOL_summary(new ScriptSummaryFormat(SummaryFormat::Flags().SetCascades(false) + .SetSkipPointers(false) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), "objc.BOOL_SummaryProvider", "")); FormatCategory::SharedPointer objc_category_sp = GetCategory(m_objc_category_name); |