summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/FormatManager.h2
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp38
-rw-r--r--lldb/test/functionalities/data-formatter/data-formatter-disabling/Makefile5
-rw-r--r--lldb/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py106
-rw-r--r--lldb/test/functionalities/data-formatter/data-formatter-disabling/main.cpp18
5 files changed, 156 insertions, 13 deletions
diff --git a/lldb/include/lldb/Core/FormatManager.h b/lldb/include/lldb/Core/FormatManager.h
index 9b77ab13f4d..e021e0abe9d 100644
--- a/lldb/include/lldb/Core/FormatManager.h
+++ b/lldb/include/lldb/Core/FormatManager.h
@@ -357,7 +357,7 @@ public:
if (category.get())
{
Position pos_w = pos;
- if (pos == First)
+ if (pos == First || m_active_categories.size() == 0)
m_active_categories.push_front(category);
else if (pos == Last || pos == m_active_categories.size())
m_active_categories.push_back(category);
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 10056b7353b..6b77736c182 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -1985,10 +1985,10 @@ public:
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
-
+
type_style_arg.arg_type = eArgTypeName;
type_style_arg.arg_repetition = eArgRepeatPlus;
-
+
type_arg.push_back (type_style_arg);
m_arguments.push_back (type_arg);
@@ -2083,19 +2083,33 @@ public:
return false;
}
- // the order is not relevant here
- for (int i = argc - 1; i >= 0; i--)
+ if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
{
- const char* typeA = command.GetArgumentAtIndex(i);
- ConstString typeCS(typeA);
-
- if (!typeCS)
+ uint32_t num_categories = DataVisualization::Categories::GetCount();
+ for (uint32_t i = 0; i < num_categories; i++)
{
- result.AppendError("empty category name not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
+ 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);
+ }
+ }
+ else
+ {
+ // the order is not relevant here
+ for (int i = argc - 1; i >= 0; i--)
+ {
+ const char* typeA = command.GetArgumentAtIndex(i);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ DataVisualization::Categories::Disable(typeCS);
}
- DataVisualization::Categories::Disable(typeCS);
}
result.SetStatus(eReturnStatusSuccessFinishResult);
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-disabling/Makefile b/lldb/test/functionalities/data-formatter/data-formatter-disabling/Makefile
new file mode 100644
index 00000000000..314f1cb2f07
--- /dev/null
+++ b/lldb/test/functionalities/data-formatter/data-formatter-disabling/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py b/lldb/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py
new file mode 100644
index 00000000000..3cf5bd5db44
--- /dev/null
+++ b/lldb/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py
@@ -0,0 +1,106 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class DataFormatterDisablingTestCase(TestBase):
+
+ mydir = os.path.join("functionalities", "data-formatter", "data-formatter-disabling")
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @dsym_test
+ def test_with_dsym_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDsym()
+ self.data_formatter_commands()
+
+ @dwarf_test
+ def test_with_dwarf_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDwarf()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Check that we can properly disable all data formatter categories."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" %
+ self.line)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type category enable default', check=False)
+ self.runCmd('type category enable system', check=False)
+ self.runCmd('type category enable VectorTypes', check=False)
+ self.runCmd('type category enable libcxx', check=False)
+ self.runCmd('type category enable gnu-libstdc++', check=False)
+ self.runCmd('type category enable CoreGraphics', check=False)
+ self.runCmd('type category enable CoreServices', check=False)
+ self.runCmd('type category enable AppKit', check=False)
+ self.runCmd('type category enable CoreFoundation', check=False)
+ self.runCmd('type category enable objc', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ #self.runCmd('type category enable system VectorTypes libcxx gnu-libstdc++ CoreGraphics CoreServices AppKit CoreFoundation objc default', check=False)
+
+ self.expect('type category list', substrs = ['system is enabled', 'gnu-libstdc++ is enabled', 'AppKit is enabled'])
+
+ self.expect("frame variable numbers",
+ substrs = ['[0] = 1', '[3] = 1234'])
+
+ self.expect('frame variable string1', substrs = ['hello world'])
+
+ # now disable them all and check that nothing is formatted
+ self.runCmd('type category disable *')
+
+ self.expect("frame variable numbers", matching=False,
+ substrs = ['[0] = 1', '[3] = 1234'])
+
+ self.expect('frame variable string1', matching=False, substrs = ['hello world'])
+
+ self.expect('type category list', substrs = ['system is not enabled', 'gnu-libstdc++ is not enabled', 'AppKit is not enabled'])
+
+ # now enable and check that we are back to normal
+ cleanup()
+
+ self.expect('type category list', substrs = ['system is enabled', 'gnu-libstdc++ is enabled', 'AppKit is enabled'])
+
+ self.expect("frame variable numbers",
+ substrs = ['[0] = 1', '[3] = 1234'])
+
+ self.expect('frame variable string1', substrs = ['hello world'])
+
+ self.expect('type category list', substrs = ['system is enabled', 'gnu-libstdc++ is enabled', 'AppKit is enabled'])
+
+ # last check - our cleanup will re-enable everything
+ self.runCmd('type category disable *')
+ self.expect('type category list', substrs = ['system is not enabled', 'gnu-libstdc++ is not enabled', 'AppKit is not enabled'])
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-disabling/main.cpp b/lldb/test/functionalities/data-formatter/data-formatter-disabling/main.cpp
new file mode 100644
index 00000000000..9374642fb0d
--- /dev/null
+++ b/lldb/test/functionalities/data-formatter/data-formatter-disabling/main.cpp
@@ -0,0 +1,18 @@
+#include <vector>
+
+int main()
+{
+
+ const char* string1 = "hello world";
+
+ std::vector<int> numbers;
+ numbers.push_back(1);
+ numbers.push_back(12);
+ numbers.push_back(123);
+ numbers.push_back(1234);
+ numbers.push_back(12345);
+ numbers.push_back(123456);
+ numbers.push_back(1234567); // Set break point at this line.
+
+ return 0;
+}
OpenPOWER on IntegriCloud