[Lldb-commits] [lldb] r264957 - Enhance the 'type X list' commands such that they actually alert the user if no formatters matching the constraints could be found
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 30 15:45:13 PDT 2016
Author: enrico
Date: Wed Mar 30 17:45:13 2016
New Revision: 264957
URL: http://llvm.org/viewvc/llvm-project?rev=264957&view=rev
Log:
Enhance the 'type X list' commands such that they actually alert the user if no formatters matching the constraints could be found
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py
lldb/trunk/source/Commands/CommandObjectType.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py?rev=264957&r1=264956&r2=264957&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py Wed Mar 30 17:45:13 2016
@@ -155,6 +155,7 @@ class CategoriesDataFormatterTestCase(Te
self.runCmd("type category enable Category1")
self.runCmd("type summary list -w Category1")
+ self.expect("type summary list -w NoSuchCategoryHere", substrs=['no matching results found'])
self.expect("frame variable r1 r2 r3",
substrs = ['r1 = Category1',
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py?rev=264957&r1=264956&r2=264957&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py Wed Mar 30 17:45:13 2016
@@ -48,7 +48,9 @@ class NamedSummariesDataFormatterTestCas
self.runCmd("type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First")
self.runCmd("type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second")
self.runCmd("type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third")
-
+
+ self.expect('type summary list', substrs=['AllUseIt'])
+
self.expect("frame variable first",
substrs = ['First: x=12'])
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=264957&r1=264956&r2=264957&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Mar 30 17:45:13 2016
@@ -1310,9 +1310,10 @@ public:
~CommandObjectTypeFormatterList() override = default;
protected:
- virtual void
+ virtual bool
FormatterSpecificList (CommandReturnObject &result)
{
+ return false;
}
bool
@@ -1346,10 +1347,13 @@ protected:
}
}
- auto category_closure = [&result, &formatter_regex] (const lldb::TypeCategoryImplSP& category) -> void {
+ bool any_printed = false;
+
+ auto category_closure = [&result, &formatter_regex, &any_printed] (const lldb::TypeCategoryImplSP& category) -> void {
result.GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", category->GetName());
+
TypeCategoryImpl::ForEachCallbacks<FormatterType> foreach;
- foreach.SetExact([&result, &formatter_regex] (ConstString name, const FormatterSharedPointer& format_sp) -> bool {
+ foreach.SetExact([&result, &formatter_regex, &any_printed] (ConstString name, const FormatterSharedPointer& format_sp) -> bool {
if (formatter_regex)
{
bool escape = true;
@@ -1365,13 +1369,13 @@ protected:
if (escape)
return true;
}
-
+
+ any_printed = 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 {
+ foreach.SetWithRegex([&result, &formatter_regex, &any_printed] (RegularExpressionSP regex_sp, const FormatterSharedPointer& format_sp) -> bool {
if (formatter_regex)
{
bool escape = true;
@@ -1388,8 +1392,8 @@ protected:
return true;
}
+ any_printed = true;
result.GetOutputStream().Printf ("%s: %s\n", regex_sp->GetText(), format_sp->GetDescription().c_str());
-
return true;
});
@@ -1427,10 +1431,16 @@ protected:
return true;
});
- FormatterSpecificList(result);
+ any_printed = FormatterSpecificList(result) | any_printed;
}
- result.SetStatus(eReturnStatusSuccessFinishResult);
+ if (any_printed)
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ {
+ result.GetOutputStream().PutCString("no matching results found.");
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ }
return result.Succeeded();
}
};
@@ -2028,7 +2038,7 @@ public:
}
protected:
- void
+ bool
FormatterSpecificList (CommandReturnObject &result) override
{
if (DataVisualization::NamedSummaryFormats::GetCount() > 0)
@@ -2038,7 +2048,9 @@ protected:
result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), summary_sp->GetDescription().c_str());
return true;
});
+ return true;
}
+ return false;
}
};
More information about the lldb-commits
mailing list