aboutsummaryrefslogtreecommitdiff
path: root/source/DataFormatters/TypeCategoryMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/DataFormatters/TypeCategoryMap.cpp')
-rw-r--r--source/DataFormatters/TypeCategoryMap.cpp65
1 files changed, 31 insertions, 34 deletions
diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp
index 58e4e2117bb6..984c7f213ded 100644
--- a/source/DataFormatters/TypeCategoryMap.cpp
+++ b/source/DataFormatters/TypeCategoryMap.cpp
@@ -20,22 +20,19 @@
using namespace lldb;
using namespace lldb_private;
-TypeCategoryMap::TypeCategoryMap (IFormatChangeListener* lst) :
-m_map_mutex(Mutex::eMutexTypeRecursive),
-listener(lst),
-m_map(),
-m_active_categories()
+TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst)
+ : m_map_mutex(), listener(lst), m_map(), m_active_categories()
{
ConstString default_cs("default");
lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs));
- Add(default_cs,default_sp);
- Enable(default_cs,First);
+ Add(default_cs, default_sp);
+ Enable(default_cs, First);
}
void
TypeCategoryMap::Add (KeyType name, const ValueSP& entry)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
m_map[name] = entry;
if (listener)
listener->Changed();
@@ -44,7 +41,7 @@ TypeCategoryMap::Add (KeyType name, const ValueSP& entry)
bool
TypeCategoryMap::Delete (KeyType name)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.find(name);
if (iter == m_map.end())
return false;
@@ -58,7 +55,7 @@ TypeCategoryMap::Delete (KeyType name)
bool
TypeCategoryMap::Enable (KeyType category_name, Position pos)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
ValueSP category;
if (!Get(category_name,category))
return false;
@@ -68,7 +65,7 @@ TypeCategoryMap::Enable (KeyType category_name, Position pos)
bool
TypeCategoryMap::Disable (KeyType category_name)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
ValueSP category;
if (!Get(category_name,category))
return false;
@@ -78,7 +75,7 @@ TypeCategoryMap::Disable (KeyType category_name)
bool
TypeCategoryMap::Enable (ValueSP category, Position pos)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
if (category.get())
{
Position pos_w = pos;
@@ -107,7 +104,7 @@ TypeCategoryMap::Enable (ValueSP category, Position pos)
bool
TypeCategoryMap::Disable (ValueSP category)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
if (category.get())
{
m_active_categories.remove_if(delete_matching_categories(category));
@@ -120,7 +117,7 @@ TypeCategoryMap::Disable (ValueSP category)
void
TypeCategoryMap::EnableAllCategories ()
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(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)
@@ -148,7 +145,7 @@ TypeCategoryMap::EnableAllCategories ()
void
TypeCategoryMap::DisableAllCategories ()
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
Position p = First;
for (; false == m_active_categories.empty(); p++)
{
@@ -160,7 +157,7 @@ TypeCategoryMap::DisableAllCategories ()
void
TypeCategoryMap::Clear ()
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
m_map.clear();
m_active_categories.clear();
if (listener)
@@ -170,7 +167,7 @@ TypeCategoryMap::Clear ()
bool
TypeCategoryMap::Get (KeyType name, ValueSP& entry)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.find(name);
if (iter == m_map.end())
return false;
@@ -181,7 +178,7 @@ TypeCategoryMap::Get (KeyType name, ValueSP& entry)
bool
TypeCategoryMap::Get (uint32_t pos, ValueSP& entry)
{
- Mutex::Locker locker(m_map_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.begin();
MapIterator end = m_map.end();
while (pos > 0)
@@ -202,8 +199,8 @@ TypeCategoryMap::AnyMatches (ConstString type_name,
const char** matching_category,
TypeCategoryImpl::FormatCategoryItems* matching_type)
{
- Mutex::Locker locker(m_map_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+
MapIterator pos, end = m_map.end();
for (pos = m_map.begin(); pos != end; pos++)
{
@@ -220,8 +217,8 @@ TypeCategoryMap::AnyMatches (ConstString type_name,
lldb::TypeFormatImplSP
TypeCategoryMap::GetFormat (FormattersMatchData& match_data)
{
- Mutex::Locker locker(m_map_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
@@ -231,7 +228,7 @@ TypeCategoryMap::GetFormat (FormattersMatchData& match_data)
{
for (auto match : match_data.GetMatchesVector())
{
- log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+ log->Printf("[CategoryMap::GetFormat] candidate match = %s %s %s %s reason = %" PRIu32,
match.GetTypeName().GetCString(),
match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
match.DidStripReference() ? "strip-reference" : "no-strip-reference",
@@ -258,8 +255,8 @@ TypeCategoryMap::GetFormat (FormattersMatchData& match_data)
lldb::TypeSummaryImplSP
TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data)
{
- Mutex::Locker locker(m_map_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
@@ -297,8 +294,8 @@ TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data)
lldb::SyntheticChildrenSP
TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data)
{
- Mutex::Locker locker(m_map_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
@@ -309,7 +306,7 @@ TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data)
{
for (auto match : match_data.GetMatchesVector())
{
- log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+ log->Printf("[CategoryMap::GetSyntheticChildren] candidate match = %s %s %s %s reason = %" PRIu32,
match.GetTypeName().GetCString(),
match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
match.DidStripReference() ? "strip-reference" : "no-strip-reference",
@@ -337,8 +334,8 @@ TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data)
lldb::TypeValidatorImplSP
TypeCategoryMap::GetValidator (FormattersMatchData& match_data)
{
- Mutex::Locker locker(m_map_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
@@ -377,8 +374,8 @@ TypeCategoryMap::ForEach(ForEachCallback callback)
{
if (callback)
{
- Mutex::Locker locker(m_map_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+
// loop through enabled categories in respective order
{
ActiveCategoriesIterator begin, end = m_active_categories.end();
@@ -408,8 +405,8 @@ TypeCategoryMap::ForEach(ForEachCallback callback)
TypeCategoryImplSP
TypeCategoryMap::GetAtIndex (uint32_t index)
{
- Mutex::Locker locker(m_map_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+
if (index < m_map.size())
{
MapIterator pos, end = m_map.end();