[Lldb-commits] [lldb] r156044 - in /lldb/trunk: include/lldb/Core/FormatManager.h source/Commands/CommandObjectType.cpp test/functionalities/data-formatter/data-formatter-disabling/ test/functionalities/data-formatter/data-formatter-disabling/Makefile test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py test/functionalities/data-formatter/data-formatter-disabling/main.cpp
Enrico Granata
egranata at apple.com
Wed May 2 18:08:44 PDT 2012
Author: enrico
Date: Wed May 2 20:08:44 2012
New Revision: 156044
URL: http://llvm.org/viewvc/llvm-project?rev=156044&view=rev
Log:
Adding a new 'type category disable *' feature that disables all categories - This is intended as a quick kill switch for data formatters for cases where the user wants as little extra processing as possible to be done on their target, or to override major data formatters bug, should they occur
Added:
lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/
lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/Makefile
lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/main.cpp
Modified:
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/source/Commands/CommandObjectType.cpp
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=156044&r1=156043&r2=156044&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Wed May 2 20:08:44 2012
@@ -357,7 +357,7 @@
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);
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=156044&r1=156043&r2=156044&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed May 2 20:08:44 2012
@@ -1985,10 +1985,10 @@
{
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 @@
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);
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/Makefile?rev=156044&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/Makefile Wed May 2 20:08:44 2012
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py?rev=156044&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py Wed May 2 20:08:44 2012
@@ -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()
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/main.cpp?rev=156044&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/main.cpp (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-disabling/main.cpp Wed May 2 20:08:44 2012
@@ -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;
+}
More information about the lldb-commits
mailing list