diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/Core/FormatManager.h | 42 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectType.cpp | 32 | ||||
-rw-r--r-- | lldb/source/Core/FormatManager.cpp | 40 |
3 files changed, 65 insertions, 49 deletions
diff --git a/lldb/include/lldb/Core/FormatManager.h b/lldb/include/lldb/Core/FormatManager.h index f11ac7dcc6c..df16ba9c5ac 100644 --- a/lldb/include/lldb/Core/FormatManager.h +++ b/lldb/include/lldb/Core/FormatManager.h @@ -934,7 +934,7 @@ private: class CategoryMap { private: - typedef const char* KeyType; + typedef ConstString KeyType; typedef FormatCategory ValueType; typedef ValueType::SharedPointer ValueSP; typedef std::list<lldb::FormatCategorySP> ActiveCategoriesList; @@ -943,7 +943,7 @@ private: public: typedef std::map<KeyType, ValueSP> MapType; typedef MapType::iterator MapIterator; - typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); + typedef bool(*CallbackType)(void*, const ValueSP&); CategoryMap(IFormatChangeListener* lst = NULL) : m_map_mutex(Mutex::eMutexTypeRecursive), @@ -1149,7 +1149,7 @@ private: public: - typedef bool (*CategoryCallback)(void*, const char*, const lldb::FormatCategorySP&); + typedef CategoryMap::CallbackType CategoryCallback; FormatManager (); @@ -1172,18 +1172,30 @@ public: } void - EnableCategory (const char* category_name) + EnableCategory (const ConstString& category_name) { m_categories_map.EnableCategory(category_name); } void - DisableCategory (const char* category_name) + DisableCategory (const ConstString& category_name) { m_categories_map.DisableCategory(category_name); } void + EnableCategory (const char* category_name) + { + EnableCategory(ConstString(category_name)); + } + + void + DisableCategory (const char* category_name) + { + DisableCategory(ConstString(category_name)); + } + + void LoopThroughCategories (CategoryCallback callback, void* param) { m_categories_map.LoopThrough(callback, param); @@ -1206,10 +1218,18 @@ public: { if (!category_name) return Category(m_default_category_name); + return Category(ConstString(category_name)); + } + + lldb::FormatCategorySP + Category (const ConstString& category_name) + { + if (!category_name) + return Category(m_default_category_name); lldb::FormatCategorySP category; if (m_categories_map.Get(category_name, category)) return category; - Categories().Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name))); + Categories().Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); return Category(category_name); } @@ -1287,13 +1307,9 @@ private: uint32_t m_last_revision; CategoryMap m_categories_map; - const char* m_default_category_name; - const char* m_system_category_name; - const char* m_gnu_cpp_category_name; - - ConstString m_default_cs; - ConstString m_system_cs; - ConstString m_gnu_stdcpp_cs; + ConstString m_default_category_name; + ConstString m_system_category_name; + ConstString m_gnu_cpp_category_name; }; class DataVisualization diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index abc613b511e..23157f8e8d2 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -1166,7 +1166,6 @@ private: static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; @@ -1322,7 +1321,6 @@ private: static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { cate->GetSummaryNavigator()->Clear(); @@ -1532,7 +1530,6 @@ private: static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { @@ -1540,6 +1537,8 @@ private: (CommandObjectTypeSummaryList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; + const char* cate_name = cate->GetName().c_str(); + // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSummary | FormatCategory::eRegexSummary) == 0) && param->cate_regex == NULL) return true; @@ -1615,7 +1614,7 @@ public: CommandObjectTypeCategoryEnable (CommandInterpreter &interpreter) : CommandObject (interpreter, "type category enable", - "Enable a category as a source of summaries.", + "Enable a category as a source of formatters.", NULL) { CommandArgumentEntry type_arg; @@ -1658,6 +1657,14 @@ public: return false; } DataVisualization::Categories::Enable(typeCS); + lldb::FormatCategorySP cate; + if (DataVisualization::Categories::Get(typeCS, cate) && cate.get()) + { + if (cate->GetCount() == 0) + { + result.AppendWarning("empty category enabled (typo?)"); + } + } } result.SetStatus(eReturnStatusSuccessFinishResult); @@ -1676,7 +1683,7 @@ public: CommandObjectTypeCategoryDelete (CommandInterpreter &interpreter) : CommandObject (interpreter, "type category delete", - "Delete a category and all associated summaries.", + "Delete a category and all associated formatters.", NULL) { CommandArgumentEntry type_arg; @@ -1748,7 +1755,7 @@ public: CommandObjectTypeCategoryDisable (CommandInterpreter &interpreter) : CommandObject (interpreter, "type category disable", - "Disable a category as a source of summaries.", + "Disable a category as a source of formatters.", NULL) { CommandArgumentEntry type_arg; @@ -1824,7 +1831,6 @@ private: static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { CommandObjectTypeCategoryList_CallbackParam* param = @@ -1832,6 +1838,8 @@ private: CommandReturnObject* result = param->result; RegularExpression* regex = param->regex; + const char* cate_name = cate->GetName().c_str(); + if (regex == NULL || regex->Execute(cate_name)) result->GetOutputStream().Printf("Category %s is%s enabled\n", cate_name, @@ -2028,10 +2036,11 @@ private: static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { + const char* cate_name = cate->GetName().c_str(); + CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; @@ -2237,7 +2246,6 @@ private: static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { @@ -2245,6 +2253,8 @@ private: (CommandObjectTypeSynthList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; + const char* cate_name = cate->GetName().c_str(); + // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSynth | FormatCategory::eRegexSynth) == 0) && param->cate_regex == NULL) return true; @@ -2384,7 +2394,6 @@ private: static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; @@ -2547,7 +2556,6 @@ private: static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { ConstString* name = (ConstString*)param; @@ -2706,7 +2714,6 @@ private: static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { cate->Clear(FormatCategory::eFilter | FormatCategory::eRegexFilter); @@ -2833,7 +2840,6 @@ private: static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { cate->Clear(FormatCategory::eSynth | FormatCategory::eRegexSynth); diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index 27ed7841060..93b737076fc 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -321,8 +321,8 @@ CategoryMap::LoopThrough(CallbackType callback, void* param) for (begin = m_active_categories.begin(); begin != end; begin++) { lldb::FormatCategorySP category = *begin; - const char* type = category->GetName().c_str(); - if (!callback(param, type, category)) + ConstString type = ConstString(category->GetName().c_str()); + if (!callback(param, category)) break; } } @@ -335,7 +335,7 @@ CategoryMap::LoopThrough(CallbackType callback, void* param) if (pos->second->IsEnabled()) continue; KeyType type = pos->first; - if (!callback(param, type, pos->second)) + if (!callback(param, pos->second)) break; } } @@ -383,17 +383,11 @@ FormatManager::FormatManager() : m_named_summaries_map(this), m_last_revision(0), m_categories_map(this), - m_default_cs(ConstString("default")), - m_system_cs(ConstString("system")), - m_gnu_stdcpp_cs(ConstString("gnu-libstdc++")) + m_default_category_name(ConstString("default")), + m_system_category_name(ConstString("system")), + m_gnu_cpp_category_name(ConstString("gnu-libstdc++")) { - // build default categories - - m_default_category_name = m_default_cs.GetCString(); - m_system_category_name = m_system_cs.GetCString(); - m_gnu_cpp_category_name = m_gnu_stdcpp_cs.AsCString(); - // add some default stuff // most formats, summaries, ... actually belong to the users' lldbinit file rather than here lldb::SummaryFormatSP string_format(new StringSummaryFormat(false, @@ -553,21 +547,21 @@ DataVisualization::AnyMatches(ConstString type_name, bool DataVisualization::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) { - entry = GetFormatManager().Category(category.GetCString()); + entry = GetFormatManager().Category(category); return true; } void DataVisualization::Categories::Add(const ConstString &category) { - GetFormatManager().Category(category.GetCString()); + GetFormatManager().Category(category); } bool DataVisualization::Categories::Delete(const ConstString &category) { - GetFormatManager().DisableCategory(category.GetCString()); - return GetFormatManager().Categories().Delete(category.GetCString()); + GetFormatManager().DisableCategory(category); + return GetFormatManager().Categories().Delete(category); } void @@ -579,26 +573,26 @@ DataVisualization::Categories::Clear() void DataVisualization::Categories::Clear(ConstString &category) { - GetFormatManager().Category(category.GetCString())->ClearSummaries(); + GetFormatManager().Category(category)->ClearSummaries(); } void DataVisualization::Categories::Enable(ConstString& category) { - if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false) - GetFormatManager().EnableCategory(category.GetCString()); + if (GetFormatManager().Category(category)->IsEnabled() == false) + GetFormatManager().EnableCategory(category); else { - GetFormatManager().DisableCategory(category.GetCString()); - GetFormatManager().EnableCategory(category.GetCString()); + GetFormatManager().DisableCategory(category); + GetFormatManager().EnableCategory(category); } } void DataVisualization::Categories::Disable(ConstString& category) { - if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true) - GetFormatManager().DisableCategory(category.GetCString()); + if (GetFormatManager().Category(category)->IsEnabled() == true) + GetFormatManager().DisableCategory(category); } void |