From 3de08c5f0c972ade61b6dd0ea4561c33e09c58fc Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 18 Nov 2015 19:42:44 +0000 Subject: [PATCH] Reapply r253423 and r253424 (which cleanup the data formatters iteration model, as well as the type X list commands), along with a change by Zachary Turner to bypass a MSVC bug with SFINAE llvm-svn: 253493 --- .../lldb/DataFormatters/DataVisualization.h | 5 +- .../lldb/DataFormatters/FormatManager.h | 5 - .../lldb/DataFormatters/FormattersContainer.h | 25 - .../lldb/DataFormatters/TypeCategory.h | 71 +- .../lldb/DataFormatters/TypeCategoryMap.h | 5 - lldb/include/lldb/DataFormatters/TypeFormat.h | 3 - .../include/lldb/DataFormatters/TypeSummary.h | 2 - .../lldb/DataFormatters/TypeSynthetic.h | 3 +- .../lldb/DataFormatters/TypeValidator.h | 2 - lldb/source/API/SBTypeCategory.cpp | 2 +- lldb/source/Commands/CommandObjectType.cpp | 967 ++++-------------- .../DataFormatters/DataVisualization.cpp | 10 +- lldb/source/DataFormatters/FormatManager.cpp | 15 - .../source/DataFormatters/TypeCategoryMap.cpp | 33 - 14 files changed, 231 insertions(+), 917 deletions(-) diff --git a/lldb/include/lldb/DataFormatters/DataVisualization.h b/lldb/include/lldb/DataFormatters/DataVisualization.h index 0b956b693beb..856156670c96 100644 --- a/lldb/include/lldb/DataFormatters/DataVisualization.h +++ b/lldb/include/lldb/DataFormatters/DataVisualization.h @@ -101,7 +101,7 @@ public: Clear (); static void - LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton); + ForEach (std::function callback); static uint32_t GetCount (); @@ -157,9 +157,6 @@ public: static void DisableStar (); - static void - LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton); - static void ForEach (TypeCategoryMap::ForEachCallback callback); diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h index ef58520010b6..c8c92be8b4ba 100644 --- a/lldb/include/lldb/DataFormatters/FormatManager.h +++ b/lldb/include/lldb/DataFormatters/FormatManager.h @@ -43,8 +43,6 @@ class FormatManager : public IFormatChangeListener public: typedef std::map LanguageCategories; - typedef TypeCategoryMap::CallbackType CategoryCallback; - FormatManager(); ~FormatManager() override = default; @@ -139,9 +137,6 @@ public: return m_categories_map.GetAtIndex(index); } - void - LoopThroughCategories (CategoryCallback callback, void* param); - void ForEachCategory (TypeCategoryMap::ForEachCallback callback); diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h index f36751287025..dcd08211f19b 100644 --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -80,8 +80,6 @@ public: typedef typename ValueType::SharedPointer ValueSP; typedef std::map MapType; typedef typename MapType::iterator MapIterator; - typedef std::function CallbackType; - typedef std::function ForEachCallback; FormatMap(IFormatChangeListener* lst) : @@ -140,22 +138,6 @@ public: return true; } - void - LoopThrough (CallbackType callback, void* param) - { - if (callback) - { - Mutex::Locker locker(m_map_mutex); - MapIterator pos, end = m_map.end(); - for (pos = m_map.begin(); pos != end; pos++) - { - KeyType type = pos->first; - if (!callback(param, type, pos->second)) - break; - } - } - } - void ForEach (ForEachCallback callback) { @@ -242,7 +224,6 @@ public: typedef typename MapType::iterator MapIterator; typedef typename MapType::key_type MapKeyType; typedef typename MapType::mapped_type MapValueType; - typedef typename BackEndType::CallbackType CallbackType; typedef typename BackEndType::ForEachCallback ForEachCallback; typedef typename std::shared_ptr > SharedPointer; @@ -315,12 +296,6 @@ public: m_format_map.Clear(); } - void - LoopThrough (CallbackType callback, void* param) - { - m_format_map.LoopThrough(callback,param); - } - void ForEach (ForEachCallback callback) { diff --git a/lldb/include/lldb/DataFormatters/TypeCategory.h b/lldb/include/lldb/DataFormatters/TypeCategory.h index 3089c4df915f..075d31d1cf6f 100644 --- a/lldb/include/lldb/DataFormatters/TypeCategory.h +++ b/lldb/include/lldb/DataFormatters/TypeCategory.h @@ -67,14 +67,6 @@ namespace lldb_private { return m_regex_sp; } - void - LoopThrough (typename ExactMatchContainer::CallbackType exact_callback, - typename RegexMatchContainer::CallbackType regex_callback) - { - GetExactMatch()->LoopThrough(exact_callback); - GetRegexMatch()->LoopThrough(regex_callback); - } - uint32_t GetCount () { @@ -95,7 +87,7 @@ namespace lldb_private { typedef FormatterContainerPair ValidatorContainer; #ifndef LLDB_DISABLE_PYTHON - typedef FormatterContainerPair SynthContainer; + typedef FormatterContainerPair SynthContainer; #endif // LLDB_DISABLE_PYTHON public: @@ -118,74 +110,84 @@ namespace lldb_private { typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP; typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP; - class ForEach + template + class ForEachCallbacks { public: - ForEach () = default; - ~ForEach () = default; + ForEachCallbacks () = default; + ~ForEachCallbacks () = default; - ForEach& - SetFormatExactCallback (FormatContainer::ExactMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetExact (FormatContainer::ExactMatchForEachCallback callback) { m_format_exact = callback; return *this; } - ForEach& - SetFormatRegexCallback (FormatContainer::RegexMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetWithRegex (FormatContainer::RegexMatchForEachCallback callback) { m_format_regex = callback; return *this; } - ForEach& - SetSummaryExactCallback (SummaryContainer::ExactMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetExact (SummaryContainer::ExactMatchForEachCallback callback) { m_summary_exact = callback; return *this; } - ForEach& - SetSummaryRegexCallback (SummaryContainer::RegexMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetWithRegex (SummaryContainer::RegexMatchForEachCallback callback) { m_summary_regex = callback; return *this; } - ForEach& - SetFilterExactCallback (FilterContainer::ExactMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetExact (FilterContainer::ExactMatchForEachCallback callback) { m_filter_exact = callback; return *this; } - ForEach& - SetFilterRegexCallback (FilterContainer::RegexMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetWithRegex (FilterContainer::RegexMatchForEachCallback callback) { m_filter_regex = callback; return *this; } #ifndef LLDB_DISABLE_PYTHON - ForEach& - SetSynthExactCallback (SynthContainer::ExactMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetExact (SynthContainer::ExactMatchForEachCallback callback) { m_synth_exact = callback; return *this; } - ForEach& - SetSynthRegexCallback (SynthContainer::RegexMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetWithRegex (SynthContainer::RegexMatchForEachCallback callback) { m_synth_regex = callback; return *this; } #endif // LLDB_DISABLE_PYTHON - - ForEach& - SetValidatorExactCallback (ValidatorContainer::ExactMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetExact (ValidatorContainer::ExactMatchForEachCallback callback) { m_validator_exact = callback; return *this; } - ForEach& - SetValidatorRegexCallback (ValidatorContainer::RegexMatchForEachCallback callback) + template + typename std::enable_if::value, ForEachCallbacks&>::type + SetWithRegex (ValidatorContainer::RegexMatchForEachCallback callback) { m_validator_regex = callback; return *this; @@ -271,8 +273,9 @@ namespace lldb_private { ConstString name, std::initializer_list langs = {}); + template void - ForEach (const ForEach &foreach) + ForEach (const ForEachCallbacks &foreach) { GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback()); GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback()); diff --git a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h index 62b8ce8b3304..8afeaf87cec5 100644 --- a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h @@ -37,8 +37,6 @@ namespace lldb_private { public: typedef std::map MapType; typedef MapType::iterator MapIterator; - typedef bool(*CallbackType)(void*, const ValueSP&); - typedef std::function ForEachCallback; typedef uint32_t Position; @@ -87,9 +85,6 @@ namespace lldb_private { Get (uint32_t pos, ValueSP& entry); - void - LoopThrough (CallbackType callback, void* param); - void ForEach (ForEachCallback callback); diff --git a/lldb/include/lldb/DataFormatters/TypeFormat.h b/lldb/include/lldb/DataFormatters/TypeFormat.h index ba07f7001f3b..4ed28b692061 100644 --- a/lldb/include/lldb/DataFormatters/TypeFormat.h +++ b/lldb/include/lldb/DataFormatters/TypeFormat.h @@ -151,7 +151,6 @@ namespace lldb_private { TypeFormatImpl (const Flags& flags = Flags()); typedef std::shared_ptr SharedPointer; - typedef std::function ValueCallback; virtual ~TypeFormatImpl (); @@ -259,7 +258,6 @@ namespace lldb_private { const TypeFormatImpl::Flags& flags = Flags()); typedef std::shared_ptr SharedPointer; - typedef std::function ValueCallback; ~TypeFormatImpl_Format() override; @@ -302,7 +300,6 @@ namespace lldb_private { const TypeFormatImpl::Flags& flags = Flags()); typedef std::shared_ptr SharedPointer; - typedef std::function ValueCallback; ~TypeFormatImpl_EnumType() override; diff --git a/lldb/include/lldb/DataFormatters/TypeSummary.h b/lldb/include/lldb/DataFormatters/TypeSummary.h index 3ee936076374..e5bf4ecadfdf 100644 --- a/lldb/include/lldb/DataFormatters/TypeSummary.h +++ b/lldb/include/lldb/DataFormatters/TypeSummary.h @@ -406,8 +406,6 @@ namespace lldb_private { } typedef std::shared_ptr SharedPointer; - typedef std::function SummaryCallback; - typedef std::function RegexSummaryCallback; protected: uint32_t m_my_revision; diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 61310503d1cc..90e5730288c4 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -348,7 +348,6 @@ namespace lldb_private { GetFrontEnd (ValueObject &backend) = 0; typedef std::shared_ptr SharedPointer; - typedef std::function SyntheticChildrenCallback; uint32_t& GetRevision () @@ -479,6 +478,8 @@ namespace lldb_private { return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend)); } + typedef std::shared_ptr SharedPointer; + private: DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl); }; diff --git a/lldb/include/lldb/DataFormatters/TypeValidator.h b/lldb/include/lldb/DataFormatters/TypeValidator.h index 60ca9b75a6cb..f1f9a11049db 100644 --- a/lldb/include/lldb/DataFormatters/TypeValidator.h +++ b/lldb/include/lldb/DataFormatters/TypeValidator.h @@ -150,7 +150,6 @@ public: TypeValidatorImpl (const Flags& flags = Flags()); typedef std::shared_ptr SharedPointer; - typedef std::function ValueCallback; virtual ~TypeValidatorImpl (); @@ -265,7 +264,6 @@ public: TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags()); typedef std::shared_ptr SharedPointer; - typedef std::function ValueCallback; ~TypeValidatorImpl_CXX() override; diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp index 287edfe140b5..33dada8da39d 100644 --- a/lldb/source/API/SBTypeCategory.cpp +++ b/lldb/source/API/SBTypeCategory.cpp @@ -180,7 +180,7 @@ SBTypeCategory::GetFilterForType (SBTypeNameSpecifier spec) if (!spec.IsValid()) return SBTypeFilter(); - lldb::SyntheticChildrenSP children_sp; + lldb::TypeFilterImplSP children_sp; if (spec.IsRegex()) m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 2ee3b5628e96..52d8fe37f629 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -1089,13 +1089,6 @@ CommandObjectTypeFormatterDelete::CommandOptions::g_option_table[] = { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; - - - - - - - class CommandObjectTypeFormatterClear : public CommandObjectParsed { private: @@ -1224,10 +1217,6 @@ CommandObjectTypeFormatterClear::CommandOptions::g_option_table[] = { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; - - - - //------------------------------------------------------------------------- // CommandObjectTypeFormatDelete //------------------------------------------------------------------------- @@ -1264,26 +1253,11 @@ public: } }; -//------------------------------------------------------------------------- -// CommandObjectTypeFormatList -//------------------------------------------------------------------------- - -bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry); -bool CommandObjectTypeRXFormatList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeFormatImplSP& entry); - -class CommandObjectTypeFormatList; - -struct CommandObjectTypeFormatList_LoopCallbackParam { - CommandObjectTypeFormatList* self; - CommandReturnObject* result; - RegularExpression* regex; - RegularExpression* cate_regex; - CommandObjectTypeFormatList_LoopCallbackParam(CommandObjectTypeFormatList* S, CommandReturnObject* R, - RegularExpression* X = NULL, RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {} -}; - -class CommandObjectTypeFormatList : public CommandObjectParsed +template +class CommandObjectTypeFormatterList : public CommandObjectParsed { + typedef typename FormatterType::SharedPointer FormatterSharedPointer; + class CommandOptions : public Options { public: @@ -1323,6 +1297,12 @@ class CommandObjectTypeFormatList : public CommandObjectParsed const OptionDefinition* GetDefinitions () override { + static OptionDefinition g_option_table[] = + { + { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."}, + { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } + }; + return g_option_table; } @@ -1345,10 +1325,12 @@ class CommandObjectTypeFormatList : public CommandObjectParsed } public: - CommandObjectTypeFormatList (CommandInterpreter &interpreter) : + CommandObjectTypeFormatterList (CommandInterpreter &interpreter, + const char* name, + const char* help) : CommandObjectParsed (interpreter, - "type format list", - "Show a list of current formatting styles.", + name, + help, NULL), m_options(interpreter) { @@ -1363,115 +1345,141 @@ public: m_arguments.push_back (type_arg); } - ~CommandObjectTypeFormatList () override + ~CommandObjectTypeFormatterList () override { } protected: + virtual void + FormatterSpecificList (CommandReturnObject &result) + { + } + bool DoExecute (Args& command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); - CommandObjectTypeFormatList_LoopCallbackParam *param; - RegularExpression* cate_regex = - m_options.m_category_regex.empty() ? NULL : - new RegularExpression(m_options.m_category_regex.c_str()); + std::unique_ptr category_regex; + std::unique_ptr formatter_regex; + + if (m_options.m_category_regex.size() > 0) + { + category_regex.reset(new RegularExpression()); + if (!category_regex->Compile(m_options.m_category_regex.c_str())) + { + result.AppendErrorWithFormat("syntax error in category regular expression '%s'", m_options.m_category_regex.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } + } if (argc == 1) { - RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); - regex->Compile(command.GetArgumentAtIndex(0)); - param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,regex,cate_regex); + const char* arg = command.GetArgumentAtIndex(1); + formatter_regex.reset(new RegularExpression()); + if (!formatter_regex->Compile(arg)) + { + result.AppendErrorWithFormat("syntax error in regular expression '%s'", arg); + result.SetStatus(eReturnStatusFailed); + return false; + } } - else - param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,NULL,cate_regex); - DataVisualization::Categories::LoopThrough(PerCategoryCallback,param); - delete param; + DataVisualization::Categories::ForEach( [this, &command, &result, &category_regex, &formatter_regex] (const lldb::TypeCategoryImplSP& category) -> bool { + if (category_regex) + { + bool escape = true; + if (0 == strcmp(category->GetName(), category_regex->GetText())) + { + escape = false; + } + else if (category_regex->Execute(category->GetName())) + { + escape = false; + } + + if (escape) + return true; + } - if (cate_regex) - delete cate_regex; + result.GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", category->GetName()); + + typedef const std::shared_ptr Bar; + typedef std::function Func1Type; + typedef std::function Func2Type; + + TypeCategoryImpl::ForEachCallbacks foreach; + foreach.SetExact([&result, &formatter_regex] (ConstString name, const FormatterSharedPointer& format_sp) -> bool { + if (formatter_regex) + { + bool escape = true; + if (0 == strcmp(name.AsCString(), formatter_regex->GetText())) + { + escape = false; + } + else if (formatter_regex->Execute(name.AsCString())) + { + escape = false; + } + + if (escape) + return true; + } + + result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), format_sp->GetDescription().c_str()); + + return true; + }); + + foreach.SetWithRegex( [&result, &formatter_regex] (RegularExpressionSP regex_sp, const FormatterSharedPointer& format_sp) -> bool { + if (formatter_regex) + { + bool escape = true; + if (0 == strcmp(regex_sp->GetText(), formatter_regex->GetText())) + { + escape = false; + } + else if (formatter_regex->Execute(regex_sp->GetText())) + { + escape = false; + } + + if (escape) + return true; + } + + result.GetOutputStream().Printf ("%s: %s\n", regex_sp->GetText(), format_sp->GetDescription().c_str()); + + return true; + }); + + category->ForEach(foreach); + + return true; + }); + FormatterSpecificList(result); + result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); } - -private: - - static bool - PerCategoryCallback(void* param_vp, - const lldb::TypeCategoryImplSP& cate) - { - - CommandObjectTypeFormatList_LoopCallbackParam* param = - (CommandObjectTypeFormatList_LoopCallbackParam*)param_vp; - CommandReturnObject* result = param->result; - - const char* cate_name = cate->GetName(); - - // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemValue | eFormatCategoryItemRegexValue) == 0) && param->cate_regex == NULL) - return true; - - // if we have a regex and this category does not match it, just skip it - if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false) - return true; - - result->GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", cate->GetDescription().c_str()); - - cate->GetTypeFormatsContainer()->LoopThrough(CommandObjectTypeFormatList_LoopCallback, param_vp); - - if (cate->GetRegexTypeFormatsContainer()->GetCount() > 0) - { - result->GetOutputStream().Printf("Regex-based formats (slower):\n"); - cate->GetRegexTypeFormatsContainer()->LoopThrough(CommandObjectTypeRXFormatList_LoopCallback, param_vp); - } - return true; - } - - - bool - LoopCallback (const char* type, - const lldb::TypeFormatImplSP& entry, - RegularExpression* regex, - CommandReturnObject *result) - { - if (regex == NULL || strcmp(type,regex->GetText()) == 0 || regex->Execute(type)) - result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str()); - return true; - } - - friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry); - friend bool CommandObjectTypeRXFormatList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeFormatImplSP& entry); - }; -bool -CommandObjectTypeFormatList_LoopCallback ( - void* pt2self, - ConstString type, - const lldb::TypeFormatImplSP& entry) -{ - CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); -} +//------------------------------------------------------------------------- +// CommandObjectTypeFormatList +//------------------------------------------------------------------------- -bool -CommandObjectTypeRXFormatList_LoopCallback ( - void* pt2self, - lldb::RegularExpressionSP regex, - const lldb::TypeFormatImplSP& entry) +class CommandObjectTypeFormatList : public CommandObjectTypeFormatterList { - CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); -} - -OptionDefinition -CommandObjectTypeFormatList::CommandOptions::g_option_table[] = -{ - { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +public: + + CommandObjectTypeFormatList (CommandInterpreter &interpreter) : + CommandObjectTypeFormatterList(interpreter, + "type format list", + "Show a list of current formats.") + { + } }; #ifndef LLDB_DISABLE_PYTHON @@ -2046,226 +2054,30 @@ protected: // CommandObjectTypeSummaryList //------------------------------------------------------------------------- -bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const StringSummaryFormat::SharedPointer& entry); -bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const StringSummaryFormat::SharedPointer& entry); - -class CommandObjectTypeSummaryList; - -struct CommandObjectTypeSummaryList_LoopCallbackParam { - CommandObjectTypeSummaryList* self; - CommandReturnObject* result; - RegularExpression* regex; - RegularExpression* cate_regex; - CommandObjectTypeSummaryList_LoopCallbackParam(CommandObjectTypeSummaryList* S, CommandReturnObject* R, - RegularExpression* X = NULL, - RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {} -}; - -class CommandObjectTypeSummaryList : public CommandObjectParsed +class CommandObjectTypeSummaryList : public CommandObjectTypeFormatterList { - - class CommandOptions : public Options - { - public: - - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) - { - } - - ~CommandOptions () override {} - - Error - SetOptionValue (uint32_t option_idx, const char *option_arg) override - { - Error error; - const int short_option = m_getopt_table[option_idx].val; - - switch (short_option) - { - case 'w': - m_category_regex = std::string(option_arg); - break; - default: - error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); - break; - } - - return error; - } - - void - OptionParsingStarting () override - { - m_category_regex = ""; - } - - const OptionDefinition* - GetDefinitions () override - { - return g_option_table; - } - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; - - // Instance variables to hold the values for command options. - - std::string m_category_regex; - - }; - - CommandOptions m_options; - - Options * - GetOptions () override - { - return &m_options; - } - public: - CommandObjectTypeSummaryList (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "type summary list", - "Show a list of current summary styles.", - NULL), - m_options(interpreter) - { - CommandArgumentEntry type_arg; - CommandArgumentData type_style_arg; - - type_style_arg.arg_type = eArgTypeName; - type_style_arg.arg_repetition = eArgRepeatOptional; - - type_arg.push_back (type_style_arg); - - m_arguments.push_back (type_arg); - } - ~CommandObjectTypeSummaryList () override + CommandObjectTypeSummaryList (CommandInterpreter &interpreter) : + CommandObjectTypeFormatterList(interpreter, + "type summary list", + "Show a list of current summaries.") { } protected: - bool - DoExecute (Args& command, CommandReturnObject &result) override + void + FormatterSpecificList (CommandReturnObject &result) override { - const size_t argc = command.GetArgumentCount(); - - CommandObjectTypeSummaryList_LoopCallbackParam *param; - RegularExpression* cate_regex = - m_options.m_category_regex.empty() ? NULL : - new RegularExpression(m_options.m_category_regex.c_str()); - - if (argc == 1) - { - RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); - regex->Compile(command.GetArgumentAtIndex(0)); - param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex,cate_regex); - } - else - param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,NULL,cate_regex); - - DataVisualization::Categories::LoopThrough(PerCategoryCallback,param); - delete param; - if (DataVisualization::NamedSummaryFormats::GetCount() > 0) { result.GetOutputStream().Printf("Named summaries:\n"); - if (argc == 1) - { - RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); - regex->Compile(command.GetArgumentAtIndex(0)); - param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex); - } - else - param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result); - DataVisualization::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param); - delete param; + DataVisualization::NamedSummaryFormats::ForEach( [&result] (ConstString name, const TypeSummaryImplSP& summary_sp) -> bool { + result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), summary_sp->GetDescription().c_str()); + return true; + }); } - - if (cate_regex) - delete cate_regex; - - result.SetStatus(eReturnStatusSuccessFinishResult); - return result.Succeeded(); } - -private: - - static bool - PerCategoryCallback(void* param_vp, - const lldb::TypeCategoryImplSP& cate) - { - - CommandObjectTypeSummaryList_LoopCallbackParam* param = - (CommandObjectTypeSummaryList_LoopCallbackParam*)param_vp; - CommandReturnObject* result = param->result; - - const char* cate_name = cate->GetName(); - - // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary) == 0) && param->cate_regex == NULL) - return true; - - // if we have a regex and this category does not match it, just skip it - if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false) - return true; - - result->GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", cate->GetDescription().c_str()); - - cate->GetTypeSummariesContainer()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp); - - if (cate->GetRegexTypeSummariesContainer()->GetCount() > 0) - { - result->GetOutputStream().Printf("Regex-based summaries (slower):\n"); - cate->GetRegexTypeSummariesContainer()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp); - } - return true; - } - - - bool - LoopCallback (const char* type, - const lldb::TypeSummaryImplSP& entry, - RegularExpression* regex, - CommandReturnObject *result) - { - if (regex == NULL || strcmp(type,regex->GetText()) == 0 || regex->Execute(type)) - result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str()); - return true; - } - - friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeSummaryImplSP& entry); - friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeSummaryImplSP& entry); -}; - -bool -CommandObjectTypeSummaryList_LoopCallback ( - void* pt2self, - ConstString type, - const lldb::TypeSummaryImplSP& entry) -{ - CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); -} - -bool -CommandObjectTypeRXSummaryList_LoopCallback ( - void* pt2self, - lldb::RegularExpressionSP regex, - const lldb::TypeSummaryImplSP& entry) -{ - CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); -} - -OptionDefinition -CommandObjectTypeSummaryList::CommandOptions::g_option_table[] = -{ - { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; //------------------------------------------------------------------------- @@ -2786,37 +2598,6 @@ CommandObjectTypeCategoryDisable::CommandOptions::g_option_table[] = class CommandObjectTypeCategoryList : public CommandObjectParsed { -private: - - struct CommandObjectTypeCategoryList_CallbackParam - { - CommandReturnObject* result; - RegularExpression* regex; - - CommandObjectTypeCategoryList_CallbackParam(CommandReturnObject* res, - RegularExpression* rex = NULL) : - result(res), - regex(rex) - { - } - - }; - - static bool - PerCategoryCallback(void* param_vp, - const lldb::TypeCategoryImplSP& cate) - { - CommandObjectTypeCategoryList_CallbackParam* param = - (CommandObjectTypeCategoryList_CallbackParam*)param_vp; - CommandReturnObject* result = param->result; - RegularExpression* regex = param->regex; - - const char* cate_name = cate->GetName(); - - if (regex == NULL || strcmp(cate_name, regex->GetText()) == 0 || regex->Execute(cate_name)) - result->GetOutputStream().Printf("Category: %s\n", cate->GetDescription().c_str()); - return true; - } public: CommandObjectTypeCategoryList (CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, @@ -2844,26 +2625,48 @@ protected: DoExecute (Args& command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); - RegularExpression* regex = NULL; + + std::unique_ptr regex; - if (argc == 0) - ; - else if (argc == 1) - regex = new RegularExpression(command.GetArgumentAtIndex(0)); - else + if (argc == 1) + { + regex.reset(new RegularExpression()); + const char* arg = command.GetArgumentAtIndex(0); + if (!regex->Compile(arg)) + { + result.AppendErrorWithFormat("syntax error in category regular expression '%s'", arg); + result.SetStatus(eReturnStatusFailed); + return false; + } + } + else if (argc != 0) { result.AppendErrorWithFormat ("%s takes 0 or one arg.\n", m_cmd_name.c_str()); result.SetStatus(eReturnStatusFailed); return false; } - CommandObjectTypeCategoryList_CallbackParam param(&result, - regex); - - DataVisualization::Categories::LoopThrough(PerCategoryCallback, ¶m); - - if (regex) - delete regex; + DataVisualization::Categories::ForEach( [®ex, &result] (const lldb::TypeCategoryImplSP& category_sp) -> bool { + if (regex) + { + bool escape = true; + if (0 == strcmp(category_sp->GetName(), regex->GetText())) + { + escape = false; + } + else if (regex->Execute(category_sp->GetName())) + { + escape = false; + } + + if (escape) + return true; + } + + result.GetOutputStream().Printf("Category: %s\n", category_sp->GetDescription().c_str()); + + return true; + }); result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); @@ -2875,210 +2678,16 @@ protected: // CommandObjectTypeFilterList //------------------------------------------------------------------------- -bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); -bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); - -class CommandObjectTypeFilterList; - -struct CommandObjectTypeFilterList_LoopCallbackParam { - CommandObjectTypeFilterList* self; - CommandReturnObject* result; - RegularExpression* regex; - RegularExpression* cate_regex; - CommandObjectTypeFilterList_LoopCallbackParam(CommandObjectTypeFilterList* S, CommandReturnObject* R, - RegularExpression* X = NULL, - RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {} -}; - -class CommandObjectTypeFilterList : public CommandObjectParsed +class CommandObjectTypeFilterList : public CommandObjectTypeFormatterList { - - class CommandOptions : public Options - { - public: - - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) - { - } - - ~CommandOptions () override {} - - Error - SetOptionValue (uint32_t option_idx, const char *option_arg) override - { - Error error; - const int short_option = m_getopt_table[option_idx].val; - - switch (short_option) - { - case 'w': - m_category_regex = std::string(option_arg); - break; - default: - error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); - break; - } - - return error; - } - - void - OptionParsingStarting () override - { - m_category_regex = ""; - } - - const OptionDefinition* - GetDefinitions () override - { - return g_option_table; - } - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; - - // Instance variables to hold the values for command options. - - std::string m_category_regex; - - }; - - CommandOptions m_options; - - Options * - GetOptions () override - { - return &m_options; - } - public: + CommandObjectTypeFilterList (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "type filter list", - "Show a list of current filters.", - NULL), - m_options(interpreter) - { - CommandArgumentEntry type_arg; - CommandArgumentData type_style_arg; - - type_style_arg.arg_type = eArgTypeName; - type_style_arg.arg_repetition = eArgRepeatOptional; - - type_arg.push_back (type_style_arg); - - m_arguments.push_back (type_arg); - } - - ~CommandObjectTypeFilterList () override + CommandObjectTypeFormatterList(interpreter, + "type filter list", + "Show a list of current filters.") { } - -protected: - bool - DoExecute (Args& command, CommandReturnObject &result) override - { - const size_t argc = command.GetArgumentCount(); - - CommandObjectTypeFilterList_LoopCallbackParam *param; - RegularExpression* cate_regex = - m_options.m_category_regex.empty() ? NULL : - new RegularExpression(m_options.m_category_regex.c_str()); - - if (argc == 1) - { - RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); - regex->Compile(command.GetArgumentAtIndex(0)); - param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,regex,cate_regex); - } - else - param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,NULL,cate_regex); - - DataVisualization::Categories::LoopThrough(PerCategoryCallback,param); - delete param; - - if (cate_regex) - delete cate_regex; - - result.SetStatus(eReturnStatusSuccessFinishResult); - return result.Succeeded(); - } - -private: - - static bool - PerCategoryCallback(void* param_vp, - const lldb::TypeCategoryImplSP& cate) - { - - const char* cate_name = cate->GetName(); - - CommandObjectTypeFilterList_LoopCallbackParam* param = - (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp; - CommandReturnObject* result = param->result; - - // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter) == 0) && param->cate_regex == NULL) - return true; - - // if we have a regex and this category does not match it, just skip it - if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false) - return true; - - result->GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", cate->GetDescription().c_str()); - - cate->GetTypeFiltersContainer()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp); - - if (cate->GetRegexTypeFiltersContainer()->GetCount() > 0) - { - result->GetOutputStream().Printf("Regex-based filters (slower):\n"); - cate->GetRegexTypeFiltersContainer()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp); - } - - return true; - } - - bool - LoopCallback (const char* type, - const SyntheticChildren::SharedPointer& entry, - RegularExpression* regex, - CommandReturnObject *result) - { - if (regex == NULL || regex->Execute(type)) - result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str()); - return true; - } - - friend bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); - friend bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); -}; - -bool -CommandObjectTypeFilterList_LoopCallback (void* pt2self, - ConstString type, - const SyntheticChildren::SharedPointer& entry) -{ - CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); -} - -bool -CommandObjectTypeFilterRXList_LoopCallback (void* pt2self, - lldb::RegularExpressionSP regex, - const SyntheticChildren::SharedPointer& entry) -{ - CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); -} - - -OptionDefinition -CommandObjectTypeFilterList::CommandOptions::g_option_table[] = -{ - { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; #ifndef LLDB_DISABLE_PYTHON @@ -3087,210 +2696,16 @@ CommandObjectTypeFilterList::CommandOptions::g_option_table[] = // CommandObjectTypeSynthList //------------------------------------------------------------------------- -bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); -bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); - -class CommandObjectTypeSynthList; - -struct CommandObjectTypeSynthList_LoopCallbackParam { - CommandObjectTypeSynthList* self; - CommandReturnObject* result; - RegularExpression* regex; - RegularExpression* cate_regex; - CommandObjectTypeSynthList_LoopCallbackParam(CommandObjectTypeSynthList* S, CommandReturnObject* R, - RegularExpression* X = NULL, - RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {} -}; - -class CommandObjectTypeSynthList : public CommandObjectParsed +class CommandObjectTypeSynthList : public CommandObjectTypeFormatterList { - - class CommandOptions : public Options - { - public: - - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) - { - } - - ~CommandOptions () override {} - - Error - SetOptionValue (uint32_t option_idx, const char *option_arg) override - { - Error error; - const int short_option = m_getopt_table[option_idx].val; - - switch (short_option) - { - case 'w': - m_category_regex = std::string(option_arg); - break; - default: - error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); - break; - } - - return error; - } - - void - OptionParsingStarting () override - { - m_category_regex = ""; - } - - const OptionDefinition* - GetDefinitions () override - { - return g_option_table; - } - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; - - // Instance variables to hold the values for command options. - - std::string m_category_regex; - - }; - - CommandOptions m_options; - - Options * - GetOptions () override - { - return &m_options; - } - public: + CommandObjectTypeSynthList (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "type synthetic list", - "Show a list of current synthetic providers.", - NULL), - m_options(interpreter) - { - CommandArgumentEntry type_arg; - CommandArgumentData type_style_arg; - - type_style_arg.arg_type = eArgTypeName; - type_style_arg.arg_repetition = eArgRepeatOptional; - - type_arg.push_back (type_style_arg); - - m_arguments.push_back (type_arg); - } - - ~CommandObjectTypeSynthList () override + CommandObjectTypeFormatterList(interpreter, + "type synthetic list", + "Show a list of current synthetic providers.") { } - -protected: - bool - DoExecute (Args& command, CommandReturnObject &result) override - { - const size_t argc = command.GetArgumentCount(); - - CommandObjectTypeSynthList_LoopCallbackParam *param; - RegularExpression* cate_regex = - m_options.m_category_regex.empty() ? NULL : - new RegularExpression(m_options.m_category_regex.c_str()); - - if (argc == 1) - { - RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); - regex->Compile(command.GetArgumentAtIndex(0)); - param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,regex,cate_regex); - } - else - param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,NULL,cate_regex); - - DataVisualization::Categories::LoopThrough(PerCategoryCallback,param); - delete param; - - if (cate_regex) - delete cate_regex; - - result.SetStatus(eReturnStatusSuccessFinishResult); - return result.Succeeded(); - } - -private: - - static bool - PerCategoryCallback(void* param_vp, - const lldb::TypeCategoryImplSP& cate) - { - - CommandObjectTypeSynthList_LoopCallbackParam* param = - (CommandObjectTypeSynthList_LoopCallbackParam*)param_vp; - CommandReturnObject* result = param->result; - - const char* cate_name = cate->GetName(); - - // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth) == 0) && param->cate_regex == NULL) - return true; - - // if we have a regex and this category does not match it, just skip it - if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false) - return true; - - result->GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", cate->GetDescription().c_str()); - - cate->GetTypeSyntheticsContainer()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp); - - if (cate->GetRegexTypeSyntheticsContainer()->GetCount() > 0) - { - result->GetOutputStream().Printf("Regex-based synthetic providers (slower):\n"); - cate->GetRegexTypeSyntheticsContainer()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp); - } - - return true; - } - - bool - LoopCallback (const char* type, - const SyntheticChildren::SharedPointer& entry, - RegularExpression* regex, - CommandReturnObject *result) - { - if (regex == NULL || regex->Execute(type)) - result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str()); - return true; - } - - friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); - friend bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); -}; - -bool -CommandObjectTypeSynthList_LoopCallback (void* pt2self, - ConstString type, - const SyntheticChildren::SharedPointer& entry) -{ - CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); -} - -bool -CommandObjectTypeSynthRXList_LoopCallback (void* pt2self, - lldb::RegularExpressionSP regex, - const SyntheticChildren::SharedPointer& entry) -{ - CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); -} - - -OptionDefinition -CommandObjectTypeSynthList::CommandOptions::g_option_table[] = -{ - { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; #endif // #ifndef LLDB_DISABLE_PYTHON @@ -3664,7 +3079,7 @@ private: bool AddFilter(ConstString type_name, - SyntheticChildrenSP entry, + TypeFilterImplSP entry, FilterFormatType type, std::string category_name, Error* error) @@ -3787,19 +3202,15 @@ protected: return false; } - SyntheticChildrenSP entry; - - TypeFilterImpl* impl = new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade). - SetSkipPointers(m_options.m_skip_pointers). - SetSkipReferences(m_options.m_skip_references)); - - entry.reset(impl); + TypeFilterImplSP entry(new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade). + SetSkipPointers(m_options.m_skip_pointers). + SetSkipReferences(m_options.m_skip_references))); // go through the expression paths CommandOptions::ExpressionPathsIterator begin, end = m_options.m_expr_paths.end(); for (begin = m_options.m_expr_paths.begin(); begin != end; begin++) - impl->AddExpressionPath(*begin); + entry->AddExpressionPath(*begin); // now I have a valid provider, let's add it to every type @@ -4289,5 +3700,3 @@ CommandObjectType::CommandObjectType (CommandInterpreter &interpreter) : CommandObjectType::~CommandObjectType () { } - - diff --git a/lldb/source/DataFormatters/DataVisualization.cpp b/lldb/source/DataFormatters/DataVisualization.cpp index 581ef3f851ab..14cf13d2f185 100644 --- a/lldb/source/DataFormatters/DataVisualization.cpp +++ b/lldb/source/DataFormatters/DataVisualization.cpp @@ -225,12 +225,6 @@ DataVisualization::Categories::DisableStar () GetFormatManager().DisableAllCategories(); } -void -DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton) -{ - GetFormatManager().LoopThroughCategories(callback, callback_baton); -} - void DataVisualization::Categories::ForEach (TypeCategoryMap::ForEachCallback callback) { @@ -274,9 +268,9 @@ DataVisualization::NamedSummaryFormats::Clear () } void -DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton) +DataVisualization::NamedSummaryFormats::ForEach (std::function callback) { - GetFormatManager().GetNamedSummaryContainer().LoopThrough(callback, callback_baton); + GetFormatManager().GetNamedSummaryContainer().ForEach(callback); } uint32_t diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 3237f73f64e8..8edc8e5ca8bd 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -485,21 +485,6 @@ FormatManager::GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp) return validator_chosen_sp; } -void -FormatManager::LoopThroughCategories (CategoryCallback callback, void* param) -{ - m_categories_map.LoopThrough(callback, param); - Mutex::Locker locker(m_language_categories_mutex); - for (const auto& entry : m_language_categories_map) - { - if (auto category_sp = entry.second->GetCategory()) - { - if (!callback(param, category_sp)) - break; - } - } -} - void FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback) { diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index 19164a3c0030..58e4e2117bb6 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -372,39 +372,6 @@ TypeCategoryMap::GetValidator (FormattersMatchData& match_data) return lldb::TypeValidatorImplSP(); } -void -TypeCategoryMap::LoopThrough(CallbackType callback, void* param) -{ - if (callback) - { - Mutex::Locker locker(m_map_mutex); - - // loop through enabled categories in respective order - { - ActiveCategoriesIterator begin, end = m_active_categories.end(); - for (begin = m_active_categories.begin(); begin != end; begin++) - { - lldb::TypeCategoryImplSP category = *begin; - if (!callback(param, category)) - break; - } - } - - // loop through disabled categories in just any order - { - MapIterator pos, end = m_map.end(); - for (pos = m_map.begin(); pos != end; pos++) - { - if (pos->second->IsEnabled()) - continue; - KeyType type = pos->first; - if (!callback(param, pos->second)) - break; - } - } - } -} - void TypeCategoryMap::ForEach(ForEachCallback callback) {