[Lldb-commits] [lldb] r149644 - in /lldb/trunk: include/lldb/Core/FormatClasses.h include/lldb/Core/FormatNavigator.h source/Commands/CommandObjectType.cpp source/Core/FormatClasses.cpp source/Core/FormatManager.cpp test/functionalities/data-formatter/rdar-10642615/ test/functionalities/data-formatter/rdar-10642615/Makefile test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py test/functionalities/data-formatter/rdar-10642615/main.cpp

Enrico Granata granata.enrico at gmail.com
Thu Feb 2 15:34:52 PST 2012


Author: enrico
Date: Thu Feb  2 17:34:52 2012
New Revision: 149644

URL: http://llvm.org/viewvc/llvm-project?rev=149644&view=rev
Log:
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.

Added:
    lldb/trunk/test/functionalities/data-formatter/rdar-10642615/
    lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Makefile
    lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py
    lldb/trunk/test/functionalities/data-formatter/rdar-10642615/main.cpp
Modified:
    lldb/trunk/include/lldb/Core/FormatClasses.h
    lldb/trunk/include/lldb/Core/FormatNavigator.h
    lldb/trunk/source/Commands/CommandObjectType.cpp
    lldb/trunk/source/Core/FormatClasses.cpp
    lldb/trunk/source/Core/FormatManager.cpp

Modified: lldb/trunk/include/lldb/Core/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=149644&r1=149643&r2=149644&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/Core/FormatClasses.h Thu Feb  2 17:34:52 2012
@@ -566,55 +566,206 @@
 };
 
 
-struct SummaryFormat
+class SummaryFormat
 {
+public:
+    class Flags
+    {
+    public:
+        
+        Flags () :
+            m_flags (FVCascades)
+        {}
+        
+        Flags (const Flags& other) :
+            m_flags (other.m_flags)
+        {}
+        
+        Flags&
+        operator = (const Flags& rhs)
+        {
+            if (&rhs != this)
+                m_flags = rhs.m_flags;
+            
+            return *this;
+        }
+        
+        Flags&
+        Clear()
+        {
+            m_flags = 0;
+            return *this;
+        }
+        
+        bool
+        GetCascades () const
+        {
+            return (m_flags & FVCascades) == FVCascades;
+        }
+        
+        Flags&
+        SetCascades (bool value = true)
+        {
+            if (value)
+                m_flags |= FVCascades;
+            else
+                m_flags &= ~FVCascades;
+            return *this;
+        }
+
+        bool
+        GetSkipPointers () const
+        {
+            return (m_flags & FVSkipPointers) == FVSkipPointers;
+        }
+
+        Flags&
+        SetSkipPointers (bool value = true)
+        {
+            if (value)
+                m_flags |= FVSkipPointers;
+            else
+                m_flags &= ~FVSkipPointers;
+            return *this;
+        }
+        
+        bool
+        GetSkipReferences () const
+        {
+            return (m_flags & FVSkipReferences) == FVSkipReferences;
+        }
+        
+        Flags&
+        SetSkipReferences (bool value = true)
+        {
+            if (value)
+                m_flags |= FVSkipReferences;
+            else
+                m_flags &= ~FVSkipReferences;
+            return *this;
+        }
+        
+        bool
+        GetDontShowChildren () const
+        {
+            return (m_flags & FVDontShowChildren) == FVDontShowChildren;
+        }
+        
+        Flags&
+        SetDontShowChildren (bool value = true)
+        {
+            if (value)
+                m_flags |= FVDontShowChildren;
+            else
+                m_flags &= ~FVDontShowChildren;
+            return *this;
+        }
+        
+        bool
+        GetDontShowValue () const
+        {
+            return (m_flags & FVDontShowValue) == FVDontShowValue;
+        }
+        
+        Flags&
+        SetDontShowValue (bool value = true)
+        {
+            if (value)
+                m_flags |= FVDontShowValue;
+            else
+                m_flags &= ~FVDontShowValue;
+            return *this;
+        }
+        
+        bool
+        GetShowMembersOneLiner () const
+        {
+            return (m_flags & FVShowMembersOneLiner) == FVShowMembersOneLiner;
+        }
+        
+        Flags&
+        SetShowMembersOneLiner (bool value = true)
+        {
+            if (value)
+                m_flags |= FVShowMembersOneLiner;
+            else
+                m_flags &= ~FVShowMembersOneLiner;
+            return *this;
+        }
+        
+        bool
+        GetHideItemNames () const
+        {
+            return (m_flags & FVHideItemNames) == FVHideItemNames;
+        }
+        
+        Flags&
+        SetHideItemNames (bool value = true)
+        {
+            if (value)
+                m_flags |= FVHideItemNames;
+            else
+                m_flags &= ~FVHideItemNames;
+            return *this;
+        }
+                
+    private:
+        uint32_t m_flags;
+        enum FlagValues
+        {
+            FVCascades            = 0x0001u,
+            FVSkipPointers        = 0x0002u,
+            FVSkipReferences      = 0x0004u,
+            FVDontShowChildren    = 0x0008u,
+            FVDontShowValue       = 0x0010u,
+            FVShowMembersOneLiner = 0x0020u,
+            FVHideItemNames       = 0x0040u
+        };
+    };
+    
     uint32_t m_my_revision;
-    bool m_cascades;
-    bool m_skip_pointers;
-    bool m_skip_references;
-    bool m_dont_show_children;
-    bool m_dont_show_value;
-    bool m_show_members_oneliner;
-    
-    SummaryFormat(bool casc = false,
-                  bool skipptr = false,
-                  bool skipref = false,
-                  bool nochildren = true,
-                  bool novalue = true,
-                  bool oneliner = false);
+    Flags m_flags;
+    
+    SummaryFormat(const SummaryFormat::Flags& flags);
     
     bool
     Cascades() const
     {
-        return m_cascades;
+        return m_flags.GetCascades();
     }
     bool
     SkipsPointers() const
     {
-        return m_skip_pointers;
+        return m_flags.GetSkipPointers();
     }
     bool
     SkipsReferences() const
     {
-        return m_skip_references;
+        return m_flags.GetSkipReferences();
     }
     
     bool
     DoesPrintChildren() const
     {
-        return !m_dont_show_children;
+        return !m_flags.GetDontShowChildren();
     }
     
     bool
     DoesPrintValue() const
     {
-        return !m_dont_show_value;
+        return !m_flags.GetDontShowValue();
     }
     
     bool
     IsOneliner() const
     {
-        return m_show_members_oneliner;
+        return m_flags.GetShowMembersOneLiner();
+    }
+    
+    bool
+    HideNames() const
+    {
+        return m_flags.GetHideItemNames();
     }
             
     virtual
@@ -639,13 +790,8 @@
 {
     std::string m_format;
     
-    StringSummaryFormat(bool casc = false,
-                        bool skipptr = false,
-                        bool skipref = false,
-                        bool nochildren = true,
-                        bool novalue = true,
-                        bool oneliner = false,
-                        std::string f = "");
+    StringSummaryFormat(const SummaryFormat::Flags& flags,
+                        std::string f);
     
     std::string
     GetFormat() const
@@ -674,14 +820,9 @@
     std::string m_function_name;
     std::string m_python_script;
     
-    ScriptSummaryFormat(bool casc = false,
-                        bool skipptr = false,
-                        bool skipref = false,
-                        bool nochildren = true,
-                        bool novalue = true,
-                        bool oneliner = false,
-                        std::string fname = "",
-                        std::string pscri = "");
+    ScriptSummaryFormat(const SummaryFormat::Flags& flags,
+                        std::string fname,
+                        std::string pscri);
     
     std::string
     GetFunctionName() const

Modified: lldb/trunk/include/lldb/Core/FormatNavigator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatNavigator.h?rev=149644&r1=149643&r2=149644&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/Core/FormatNavigator.h Thu Feb  2 17:34:52 2012
@@ -511,7 +511,7 @@
         {
             if (log)
                 log->Printf("stripping reference");
-            if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->m_skip_references)
+            if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences())
             {
                 reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
                 return true;
@@ -554,7 +554,7 @@
             if (log)
                 log->Printf("stripping pointer");
             clang::QualType pointee = typePtr->getPointeeType();
-            if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->m_skip_pointers)
+            if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
             {
                 reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
                 return true;
@@ -596,7 +596,7 @@
             ValueObject* target = valobj.Dereference(error).get();
             if (error.Fail() || !target)
                 return false;
-            if (Get(*target, typePtr->getPointeeType(), entry, use_dynamic, reason) && !entry->m_skip_pointers)
+            if (Get(*target, typePtr->getPointeeType(), entry, use_dynamic, reason) && !entry->SkipsPointers())
             {
                 reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
                 return true;
@@ -621,7 +621,7 @@
                         if (log)
                             log->Printf("got a parent class for this ObjC class");
                         clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl));
-                        if (Get(valobj, ivar_qual_type, entry, use_dynamic, reason) && entry->m_cascades)
+                        if (Get(valobj, ivar_qual_type, entry, use_dynamic, reason) && entry->Cascades())
                         {
                             reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses;
                             return true;
@@ -650,7 +650,7 @@
                         end = record->bases_end();
                         for (pos = record->bases_begin(); pos != end; pos++)
                         {
-                            if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades)
+                            if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->Cascades())
                             {
                                 reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses;
                                 return true;
@@ -664,7 +664,7 @@
                         end = record->vbases_end();
                         for (pos = record->vbases_begin(); pos != end; pos++)
                         {
-                            if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades)
+                            if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->Cascades())
                             {
                                 reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses;
                                 return true;
@@ -680,7 +680,7 @@
         {
             if (log)
                 log->Printf("stripping typedef");
-            if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->m_cascades)
+            if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades())
             {
                 reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs;
                 return true;

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=149644&r1=149643&r2=149644&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Feb  2 17:34:52 2012
@@ -37,38 +37,22 @@
     
 public:
     
-    bool m_skip_pointers;
-    bool m_skip_references;
-    bool m_cascade;
+    SummaryFormat::Flags m_flags;
+    
     StringList m_target_types;
     StringList m_user_source;
     
-    bool m_no_children;
-    bool m_no_value;
-    bool m_one_liner;
     bool m_regex;
-    
+        
     ConstString m_name;
     
     std::string m_category;
     
-    ScriptAddOptions(bool sptr,
-                     bool sref,
-                     bool casc,
-                     bool noch,
-                     bool novl,
-                     bool onel,
+    ScriptAddOptions(const SummaryFormat::Flags& flags,
                      bool regx,
                      const ConstString& name,
                      std::string catg) :
-        m_skip_pointers(sptr),
-        m_skip_references(sref),
-        m_cascade(casc),
-        m_target_types(),
-        m_user_source(),
-        m_no_children(noch),
-        m_no_value(novl),
-        m_one_liner(onel),
+        m_flags(flags),
         m_regex(regx),
         m_name(name),
         m_category(catg)
@@ -149,12 +133,7 @@
         
         // Instance variables to hold the values for command options.
         
-        bool m_cascade;
-        bool m_no_children;
-        bool m_no_value;
-        bool m_one_liner;
-        bool m_skip_references;
-        bool m_skip_pointers;
+        SummaryFormat::Flags m_flags;
         bool m_regex;
         std::string m_format_string;
         ConstString m_name;
@@ -872,12 +851,7 @@
         // now I have a valid function name, let's add this as script for every type in the list
         
         SummaryFormatSP script_format;
-        script_format.reset(new ScriptSummaryFormat(options->m_cascade,
-                                                    options->m_skip_pointers,
-                                                    options->m_skip_references,
-                                                    options->m_no_children,
-                                                    options->m_no_value,
-                                                    options->m_one_liner,
+        script_format.reset(new ScriptSummaryFormat(options->m_flags,
                                                     std::string(funct_name),
                                                     options->m_user_source.CopyList("     ")));
         
@@ -951,27 +925,27 @@
     switch (short_option)
     {
         case 'C':
-            m_cascade = Args::StringToBoolean(option_arg, true, &success);
+            m_flags.SetCascades(Args::StringToBoolean(option_arg, true, &success));
             if (!success)
                 error.SetErrorStringWithFormat("invalid value for cascade: %s", option_arg);
             break;
         case 'e':
-            m_no_children = false;
+            m_flags.SetDontShowChildren(false);
             break;
         case 'v':
-            m_no_value = true;
+            m_flags.SetDontShowValue(true);
             break;
         case 'c':
-            m_one_liner = true;
+            m_flags.SetShowMembersOneLiner(true);
             break;
         case 's':
             m_format_string = std::string(option_arg);
             break;
         case 'p':
-            m_skip_pointers = true;
+            m_flags.SetSkipPointers(true);
             break;
         case 'r':
-            m_skip_references = true;
+            m_flags.SetSkipReferences(true);
             break;
         case 'x':
             m_regex = true;
@@ -993,6 +967,9 @@
         case 'w':
             m_category = std::string(option_arg);
             break;
+        case 'O':
+            m_flags.SetHideItemNames(true);
+            break;
         default:
             error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
             break;
@@ -1004,12 +981,9 @@
 void
 CommandObjectTypeSummaryAdd::CommandOptions::OptionParsingStarting ()
 {
-    m_cascade = true;
-    m_no_children = true;
-    m_no_value = false;
-    m_one_liner = false;
-    m_skip_references = false;
-    m_skip_pointers = false;
+    m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(false);
+    m_flags.SetShowMembersOneLiner(false).SetSkipPointers(false).SetSkipReferences(false).SetHideItemNames(false);
+
     m_regex = false;
     m_name.Clear();
     m_python_script = "";
@@ -1080,12 +1054,7 @@
             return false;
         }
         
-        script_format.reset(new ScriptSummaryFormat(m_options.m_cascade,
-                                                    m_options.m_skip_pointers,
-                                                    m_options.m_skip_references,
-                                                    m_options.m_no_children,
-                                                    m_options.m_no_value,
-                                                    m_options.m_one_liner,
+        script_format.reset(new ScriptSummaryFormat(m_options.m_flags,
                                                     std::string(funct_name),
                                                     "     " + m_options.m_python_function + "(valobj,dict)"));
     }
@@ -1122,23 +1091,13 @@
             return false;
         }
         
-        script_format.reset(new ScriptSummaryFormat(m_options.m_cascade,
-                                                    m_options.m_skip_pointers,
-                                                    m_options.m_skip_references,
-                                                    m_options.m_no_children,
-                                                    m_options.m_no_value,
-                                                    m_options.m_one_liner,
+        script_format.reset(new ScriptSummaryFormat(m_options.m_flags,
                                                     std::string(funct_name),
                                                     "     " + m_options.m_python_script));
     }
     else // use an InputReader to grab Python code from the user
     {        
-        ScriptAddOptions *options = new ScriptAddOptions(m_options.m_skip_pointers,
-                                                         m_options.m_skip_references,
-                                                         m_options.m_cascade,
-                                                         m_options.m_no_children,
-                                                         m_options.m_no_value,
-                                                         m_options.m_one_liner,
+        ScriptAddOptions *options = new ScriptAddOptions(m_options.m_flags,
                                                          m_options.m_regex,
                                                          m_options.m_name,
                                                          m_options.m_category);
@@ -1211,14 +1170,14 @@
         return false;
     }
     
-    if (!m_options.m_one_liner && m_options.m_format_string.empty())
+    if (!m_options.m_flags.GetShowMembersOneLiner() && m_options.m_format_string.empty())
     {
         result.AppendError("empty summary strings not allowed");
         result.SetStatus(eReturnStatusFailed);
         return false;
     }
     
-    const char* format_cstr = (m_options.m_one_liner ? "" : m_options.m_format_string.c_str());
+    const char* format_cstr = (m_options.m_flags.GetShowMembersOneLiner() ? "" : m_options.m_format_string.c_str());
     
     // ${var%S} is an endless recursion, prevent it
     if (strcmp(format_cstr, "${var%S}") == 0)
@@ -1230,15 +1189,10 @@
     
     Error error;
     
-    lldb::SummaryFormatSP entry(new StringSummaryFormat(m_options.m_cascade,
-                                                               m_options.m_skip_pointers,
-                                                               m_options.m_skip_references,
-                                                               m_options.m_no_children,
-                                                               m_options.m_no_value,
-                                                               m_options.m_one_liner,
-                                                               format_cstr));
+    lldb::SummaryFormatSP entry(new StringSummaryFormat(m_options.m_flags,
+                                                        format_cstr));
     
-    if (error.Fail()) 
+    if (error.Fail())
     {
         result.AppendError(error.AsCString());
         result.SetStatus(eReturnStatusFailed);
@@ -1435,6 +1389,7 @@
     { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeNone,         "Don't use this format for references-to-type objects."},
     { LLDB_OPT_SET_ALL, false,  "regex", 'x', no_argument, NULL, 0, eArgTypeNone,    "Type names are actually regular expressions."},
     { LLDB_OPT_SET_1  , true, "inline-children", 'c', no_argument, NULL, 0, eArgTypeNone,    "If true, inline all child values into summary string."},
+    { LLDB_OPT_SET_1  , false, "omit-names", 'O', no_argument, NULL, 0, eArgTypeNone,    "If true, omit value names in the summary display."},
     { LLDB_OPT_SET_2  , true, "summary-string", 's', required_argument, NULL, 0, eArgTypeSummaryString,    "Summary string used to display text and object contents."},
     { LLDB_OPT_SET_3, false, "python-script", 'o', required_argument, NULL, 0, eArgTypePythonScript, "Give a one-liner Python script as part of the command."},
     { LLDB_OPT_SET_3, false, "python-function", 'F', required_argument, NULL, 0, eArgTypePythonFunction, "Give the name of a Python function to use for this type."},

Modified: lldb/trunk/source/Core/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=149644&r1=149643&r2=149644&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatClasses.cpp (original)
+++ lldb/trunk/source/Core/FormatClasses.cpp Thu Feb  2 17:34:52 2012
@@ -55,34 +55,14 @@
 {
 }
 
-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 @@
     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 @@
                 {
                     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 @@
 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 @@
 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();
     

Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=149644&r1=149643&r2=149644&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Thu Feb  2 17:34:52 2012
@@ -566,22 +566,24 @@
     
     // 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_array_format(new StringSummaryFormat(false,
-                                                                             true,
-                                                                             false,
-                                                                             false,
-                                                                             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(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 @@
     // 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 @@
                                                 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 @@
                                                                                      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);

Added: lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Makefile?rev=149644&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Makefile Thu Feb  2 17:34:52 2012
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Accelerate
\ No newline at end of file

Added: lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py?rev=149644&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py Thu Feb  2 17:34:52 2012
@@ -0,0 +1,93 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class Radar10642615DataFormatterTestCase(TestBase):
+
+    # test for rdar://problem/10642615 ()
+    mydir = os.path.join("functionalities", "data-formatter", "rdar-10642615")
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    def test_with_dsym_and_run_command(self):
+        """Test data formatter commands."""
+        self.buildDsym()
+        self.data_formatter_commands()
+
+    def test_with_dwarf_and_run_command(self):
+        """Test data formatter commands."""
+        self.buildDwarf()
+        self.data_formatter_commands()
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to break at.
+        self.line = line_number('main.cpp', '// Set break point at this line.')
+
+    def data_formatter_commands(self):
+        """Test that that file and class static variables display correctly."""
+        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+        self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" %
+                        self.line)
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # The stop reason of the thread should be breakpoint.
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['stopped',
+                       'stop reason = breakpoint'])
+
+        # This is the function to remove the custom formats in order to have a
+        # clean slate for the next test case.
+        def cleanup():
+            self.runCmd('type summary clear', check=False)
+
+        # Execute the cleanup function during test case tear down.
+        self.addTearDownHook(cleanup)
+
+        self.expect('frame variable value',
+            substrs = ['[0] = 1', '[2] = 4'])
+
+        self.runCmd("type summary add vFloat --inline-children")
+     
+        self.expect('frame variable value',
+            substrs = ['[0]=1, [1]', ', [2]=4'])
+
+        self.runCmd("type summary add vFloat --inline-children --omit-names")
+
+        self.expect('frame variable value',
+            substrs = ['1, 0, 4, 0'])
+
+        self.runCmd("type summary add vFloat --inline-children")
+
+        self.expect('frame variable value',
+	            substrs = ['[0]=1, [1]', ', [2]=4'])
+
+        self.runCmd("type summary delete vFloat")
+
+        self.expect('frame variable value',
+            substrs = ['[0] = 1', '[2] = 4'])
+
+        self.runCmd("type summary add vFloat --omit-names", check=False) # should not work since we're not inlining children
+
+        self.expect('frame variable value',
+            substrs = ['[0] = 1', '[2] = 4'])
+
+        self.runCmd("type summary add vFloat --inline-children --omit-names")
+
+        self.expect('frame variable value',
+            substrs = ['1, 0, 4, 0'])
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/functionalities/data-formatter/rdar-10642615/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-10642615/main.cpp?rev=149644&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-10642615/main.cpp (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-10642615/main.cpp Thu Feb  2 17:34:52 2012
@@ -0,0 +1,20 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <Accelerate/Accelerate.h>
+
+int main()
+{
+	float f[4] __attribute__((__aligned__(16)));
+    f[0] = 1;
+    f[2] = 4;
+	vFloat *vPointer = (vFloat *) f;
+	vFloat value = *vPointer;
+	return 0; // Set break point at this line.
+}





More information about the lldb-commits mailing list