[Lldb-commits] [lldb] r222548 - Do some cleanup of DumpValueObjectOptions. The whole concept of raw printing was split between feature-specific flags, and an m_be_raw flag, which then drove some other changes in printing behavior. Clean that up, so that each functionality has its own flag .. oh, and make the bools all go in a bitfield since I may want to add more of those over time

Enrico Granata egranata at apple.com
Fri Nov 21 10:47:26 PST 2014


Author: enrico
Date: Fri Nov 21 12:47:26 2014
New Revision: 222548

URL: http://llvm.org/viewvc/llvm-project?rev=222548&view=rev
Log:
Do some cleanup of DumpValueObjectOptions. The whole concept of raw printing was split between feature-specific flags, and an m_be_raw flag, which then drove some other changes in printing behavior. Clean that up, so that each functionality has its own flag .. oh, and make the bools all go in a bitfield since I may want to add more of those over time

Modified:
    lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h
    lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
    lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h?rev=222548&r1=222547&r2=222548&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h Fri Nov 21 12:47:26 2014
@@ -26,46 +26,43 @@ namespace lldb_private {
 
 struct DumpValueObjectOptions
 {
-    uint32_t m_max_ptr_depth;
-    uint32_t m_max_depth;
-    bool m_show_types;
-    bool m_show_location;
-    bool m_use_objc;
-    lldb::DynamicValueType m_use_dynamic;
-    bool m_use_synthetic;
-    bool m_scope_already_checked;
-    bool m_flat_output;
-    uint32_t m_omit_summary_depth;
-    bool m_ignore_cap;
-    lldb::Format m_format;
+    uint32_t m_max_ptr_depth = 0;
+    uint32_t m_max_depth = UINT32_MAX;
+    lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
+    uint32_t m_omit_summary_depth = 0;
+    lldb::Format m_format = lldb::eFormatDefault;
     lldb::TypeSummaryImplSP m_summary_sp;
     std::string m_root_valobj_name;
-    bool m_hide_root_type;
-    bool m_hide_name;
-    bool m_hide_value;
-    bool m_be_raw;
-    bool m_run_validator;
+    bool m_use_synthetic : 1;
+    bool m_scope_already_checked : 1;
+    bool m_flat_output : 1;
+    bool m_ignore_cap : 1;
+    bool m_show_types : 1;
+    bool m_show_location : 1;
+    bool m_use_objc : 1;
+    bool m_hide_root_type : 1;
+    bool m_hide_name : 1;
+    bool m_hide_value : 1;
+    bool m_run_validator : 1;
+    bool m_use_type_display_name : 1;
+    bool m_allow_oneliner_mode : 1;
     
     DumpValueObjectOptions() :
-    m_max_ptr_depth(0),
-    m_max_depth(UINT32_MAX),
-    m_show_types(false),
-    m_show_location(false),
-    m_use_objc(false),
-    m_use_dynamic(lldb::eNoDynamicValues),
+    m_summary_sp(),
+    m_root_valobj_name(),
     m_use_synthetic(true),
     m_scope_already_checked(false),
     m_flat_output(false),
-    m_omit_summary_depth(0),
     m_ignore_cap(false),
-    m_format (lldb::eFormatDefault),
-    m_summary_sp(),
-    m_root_valobj_name(),
-    m_hide_root_type(false),  // provide a special compact display for "po"
-    m_hide_name(false), // provide a special compact display for "po"
-    m_hide_value(false), // provide a special compact display for "po"
-    m_be_raw(false),
-    m_run_validator(false)
+    m_show_types(false),
+    m_show_location(false),
+    m_use_objc(false),
+    m_hide_root_type(false),
+    m_hide_name(false),
+    m_hide_value(false),
+    m_run_validator(false),
+    m_use_type_display_name(true),
+    m_allow_oneliner_mode(true)
     {}
     
     static const DumpValueObjectOptions
@@ -76,27 +73,7 @@ struct DumpValueObjectOptions
         return g_default_options;
     }
     
-    DumpValueObjectOptions (const DumpValueObjectOptions& rhs) :
-    m_max_ptr_depth(rhs.m_max_ptr_depth),
-    m_max_depth(rhs.m_max_depth),
-    m_show_types(rhs.m_show_types),
-    m_show_location(rhs.m_show_location),
-    m_use_objc(rhs.m_use_objc),
-    m_use_dynamic(rhs.m_use_dynamic),
-    m_use_synthetic(rhs.m_use_synthetic),
-    m_scope_already_checked(rhs.m_scope_already_checked),
-    m_flat_output(rhs.m_flat_output),
-    m_omit_summary_depth(rhs.m_omit_summary_depth),
-    m_ignore_cap(rhs.m_ignore_cap),
-    m_format(rhs.m_format),
-    m_summary_sp(rhs.m_summary_sp),
-    m_root_valobj_name(rhs.m_root_valobj_name),
-    m_hide_root_type(rhs.m_hide_root_type),
-    m_hide_name(rhs.m_hide_name),
-    m_hide_value(rhs.m_hide_value),
-    m_be_raw(rhs.m_be_raw),
-    m_run_validator(rhs.m_run_validator)
-    {}
+    DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
     
     DumpValueObjectOptions&
     SetMaximumPointerDepth(uint32_t depth = 0)
@@ -186,26 +163,15 @@ struct DumpValueObjectOptions
     }
     
     DumpValueObjectOptions&
-    SetRawDisplay(bool raw = false)
+    SetRawDisplay()
     {
-        if (raw)
-        {
-            SetUseSyntheticValue(false);
-            SetOmitSummaryDepth(UINT32_MAX);
-            SetIgnoreCap(true);
-            SetHideName(false);
-            SetHideValue(false);
-            m_be_raw = true;
-        }
-        else
-        {
-            SetUseSyntheticValue(true);
-            SetOmitSummaryDepth(0);
-            SetIgnoreCap(false);
-            SetHideName(false);
-            SetHideValue(false);
-            m_be_raw = false;
-        }
+        SetUseSyntheticValue(false);
+        SetOmitSummaryDepth(UINT32_MAX);
+        SetIgnoreCap(true);
+        SetHideName(false);
+        SetHideValue(false);
+        SetUseTypeDisplayName(false);
+        SetAllowOnelinerMode(false);
         return *this;
     }
     
@@ -260,8 +226,23 @@ struct DumpValueObjectOptions
         m_run_validator = run;
         return *this;
     }
-};
     
+    DumpValueObjectOptions&
+    SetUseTypeDisplayName (bool dis = false)
+    {
+        m_use_type_display_name = dis;
+        return *this;
+    }
+    
+    DumpValueObjectOptions&
+    SetAllowOnelinerMode (bool oneliner = false)
+    {
+        m_allow_oneliner_mode = oneliner;
+        return *this;
+    }
+    
+};
+
 class ValueObjectPrinter
 {
 public:

Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=222548&r1=222547&r2=222548&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original)
+++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Fri Nov 21 12:47:26 2014
@@ -245,13 +245,13 @@ ValueObjectPrinter::PrintTypeIfNeeded ()
     {
         // Some ValueObjects don't have types (like registers sets). Only print
         // the type if there is one to print
-        ConstString qualified_type_name;
-        if (options.m_be_raw)
-            qualified_type_name = m_valobj->GetQualifiedTypeName();
+        ConstString type_name;
+        if (options.m_use_type_display_name)
+            type_name = m_valobj->GetDisplayTypeName();
         else
-            qualified_type_name = m_valobj->GetDisplayTypeName();
-        if (qualified_type_name)
-            m_stream->Printf("(%s) ", qualified_type_name.GetCString());
+            type_name = m_valobj->GetQualifiedTypeName();
+        if (type_name)
+            m_stream->Printf("(%s) ", type_name.GetCString());
         else
             show_type = false;
     }
@@ -631,7 +631,7 @@ ValueObjectPrinter::PrintChildrenIfNeede
     
     uint32_t curr_ptr_depth = m_ptr_depth;
     bool print_children = ShouldPrintChildren (is_failed_description,curr_ptr_depth);
-    bool print_oneline = (curr_ptr_depth > 0 || options.m_show_types || options.m_be_raw) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
+    bool print_oneline = (curr_ptr_depth > 0 || options.m_show_types || !options.m_allow_oneliner_mode) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
     
     if (print_children)
     {

Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=222548&r1=222547&r2=222548&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Fri Nov 21 12:47:26 2014
@@ -185,7 +185,7 @@ OptionGroupValueObjectDisplay::GetAsDump
         .SetHideValue(use_objc);
     
     if (be_raw)
-        options.SetRawDisplay(true);
+        options.SetRawDisplay();
     
     options.SetRunValidator(run_validator);
 





More information about the lldb-commits mailing list