[Lldb-commits] [lldb] r218949 - Issuing a "type category disable *" command followed by a "type category enable *" command does not honor the order in which categories were previously enabled
Enrico Granata
egranata at apple.com
Thu Oct 2 18:48:33 PDT 2014
Author: enrico
Date: Thu Oct 2 20:48:32 2014
New Revision: 218949
URL: http://llvm.org/viewvc/llvm-project?rev=218949&view=rev
Log:
Issuing a "type category disable *" command followed by a "type category enable *" command does not honor the order in which categories were previously enabled
While we didn't really promise it would, it seems like it should
This checkin enables just that, and fixes rdar://18527468
Modified:
lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
lldb/trunk/include/lldb/DataFormatters/FormatManager.h
lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/DataFormatters/DataVisualization.cpp
lldb/trunk/source/DataFormatters/TypeCategory.cpp
lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
Modified: lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DataVisualization.h?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/DataVisualization.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/DataVisualization.h Thu Oct 2 20:48:32 2014
@@ -144,6 +144,12 @@ public:
Disable (const lldb::TypeCategoryImplSP& category);
static void
+ EnableStar ();
+
+ static void
+ DisableStar ();
+
+ static void
LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton);
static uint32_t
Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Thu Oct 2 20:48:32 2014
@@ -86,6 +86,18 @@ public:
m_categories_map.Disable(category);
}
+ void
+ EnableAllCategories ()
+ {
+ m_categories_map.EnableAllCategories ();
+ }
+
+ void
+ DisableAllCategories ()
+ {
+ m_categories_map.DisableAllCategories ();
+ }
+
bool
DeleteCategory (const ConstString& category_name)
{
Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategory.h?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategory.h Thu Oct 2 20:48:32 2014
@@ -302,6 +302,18 @@ namespace lldb_private {
Enable(false, UINT32_MAX);
}
+ uint32_t
+ GetLastEnabledPosition ()
+ {
+ return m_enabled_position;
+ }
+
+ void
+ SetEnabledPosition (uint32_t p)
+ {
+ m_enabled_position = p;
+ }
+
friend class TypeCategoryMap;
friend class FormattersContainer<ConstString, TypeFormatImpl>;
Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h Thu Oct 2 20:48:32 2014
@@ -63,6 +63,12 @@ namespace lldb_private {
bool
Disable (ValueSP category);
+
+ void
+ EnableAllCategories ();
+
+ void
+ DisableAllCategories ();
void
Clear ();
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Oct 2 20:48:32 2014
@@ -2465,22 +2465,7 @@ protected:
if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
{
- // we want to make sure to enable "system" last and "default" first
- DataVisualization::Categories::Enable(ConstString("default"), TypeCategoryMap::First);
- uint32_t num_categories = DataVisualization::Categories::GetCount();
- for (uint32_t i = 0; i < num_categories; i++)
- {
- lldb::TypeCategoryImplSP category_sp = DataVisualization::Categories::GetCategoryAtIndex(i);
- if (category_sp)
- {
- if ( ::strcmp(category_sp->GetName(), "system") == 0 ||
- ::strcmp(category_sp->GetName(), "default") == 0 )
- continue;
- else
- DataVisualization::Categories::Enable(category_sp, TypeCategoryMap::Default);
- }
- }
- DataVisualization::Categories::Enable(ConstString("system"), TypeCategoryMap::Last);
+ DataVisualization::Categories::EnableStar();
}
else
{
@@ -2630,14 +2615,7 @@ protected:
if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
{
- uint32_t num_categories = DataVisualization::Categories::GetCount();
- for (uint32_t i = 0; i < num_categories; i++)
- {
- lldb::TypeCategoryImplSP category_sp = DataVisualization::Categories::GetCategoryAtIndex(i);
- // no need to check if the category is enabled - disabling a disabled category has no effect
- if (category_sp)
- DataVisualization::Categories::Disable(category_sp);
- }
+ DataVisualization::Categories::DisableStar();
}
else
{
Modified: lldb/trunk/source/DataFormatters/DataVisualization.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/DataVisualization.cpp?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/DataVisualization.cpp (original)
+++ lldb/trunk/source/DataFormatters/DataVisualization.cpp Thu Oct 2 20:48:32 2014
@@ -196,6 +196,18 @@ DataVisualization::Categories::Disable (
}
void
+DataVisualization::Categories::EnableStar ()
+{
+ GetFormatManager().EnableAllCategories ();
+}
+
+void
+DataVisualization::Categories::DisableStar ()
+{
+ GetFormatManager().DisableAllCategories();
+}
+
+void
DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton)
{
GetFormatManager().LoopThroughCategories(callback, callback_baton);
Modified: lldb/trunk/source/DataFormatters/TypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategory.cpp?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategory.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategory.cpp Thu Oct 2 20:48:32 2014
@@ -564,8 +564,8 @@ void
TypeCategoryImpl::Enable (bool value, uint32_t position)
{
Mutex::Locker locker(m_mutex);
- m_enabled = value;
- m_enabled_position = position;
+ if ( (m_enabled = value) )
+ m_enabled_position = position;
if (m_change_listener)
m_change_listener->Changed();
}
Modified: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=218949&r1=218948&r2=218949&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Thu Oct 2 20:48:32 2014
@@ -120,6 +120,31 @@ TypeCategoryMap::Disable (ValueSP catego
}
void
+TypeCategoryMap::EnableAllCategories ()
+{
+ Mutex::Locker locker(m_map_mutex);
+ std::vector<ValueSP> sorted_categories(m_map.size(), ValueSP());
+ MapType::iterator iter = m_map.begin(), end = m_map.end();
+ for (; iter != end; ++iter)
+ sorted_categories.at(iter->second->GetLastEnabledPosition()) = iter->second;
+ decltype(sorted_categories)::iterator viter = sorted_categories.begin(), vend = sorted_categories.end();
+ for (; viter != vend; viter++)
+ Enable(*viter, Last);
+}
+
+void
+TypeCategoryMap::DisableAllCategories ()
+{
+ Mutex::Locker locker(m_map_mutex);
+ Position p = First;
+ for (; false == m_active_categories.empty(); p++)
+ {
+ m_active_categories.front()->SetEnabledPosition(p);
+ Disable(m_active_categories.front());
+ }
+}
+
+void
TypeCategoryMap::Clear ()
{
Mutex::Locker locker(m_map_mutex);
More information about the lldb-commits
mailing list