[Lldb-commits] [lldb] r160180 - in /lldb/trunk: source/Core/FormatManager.cpp test/functionalities/data-formatter/rdar-11628688/ test/functionalities/data-formatter/rdar-11628688/Makefile test/functionalities/data-formatter/rdar-11628688/TestFormattersBoolRefPtr.py test/functionalities/data-formatter/rdar-11628688/main.mm

Enrico Granata egranata at apple.com
Fri Jul 13 11:54:40 PDT 2012


Author: enrico
Date: Fri Jul 13 13:54:40 2012
New Revision: 160180

URL: http://llvm.org/viewvc/llvm-project?rev=160180&view=rev
Log:
<rdar://problem/11628688> Making sure to use the ostype format for OSType values

Added:
    lldb/trunk/test/functionalities/data-formatter/rdar-11628688/
    lldb/trunk/test/functionalities/data-formatter/rdar-11628688/Makefile
    lldb/trunk/test/functionalities/data-formatter/rdar-11628688/TestFormattersBoolRefPtr.py
    lldb/trunk/test/functionalities/data-formatter/rdar-11628688/main.mm
Modified:
    lldb/trunk/source/Core/FormatManager.cpp

Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=160180&r1=160179&r2=160180&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Fri Jul 13 13:54:40 2012
@@ -834,6 +834,17 @@
     sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format);
     sys_category_sp->GetSummaryNavigator()->Add(ConstString("const char *"), string_format);
     sys_category_sp->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format);
+    
+    lldb::TypeSummaryImplSP ostype_summary(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
+                                                                   .SetSkipPointers(true)
+                                                                   .SetSkipReferences(true)
+                                                                   .SetDontShowChildren(true)
+                                                                   .SetDontShowValue(false)
+                                                                   .SetShowMembersOneLiner(false)
+                                                                   .SetHideItemNames(false),
+                                                                   "${var%O}"));
+    
+    sys_category_sp->GetSummaryNavigator()->Add(ConstString("OSType"), ostype_summary);
 }
 
 static void

Added: lldb/trunk/test/functionalities/data-formatter/rdar-11628688/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-11628688/Makefile?rev=160180&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-11628688/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-11628688/Makefile Fri Jul 13 13:54:40 2012
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJCXX_SOURCES := main.mm
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation

Added: lldb/trunk/test/functionalities/data-formatter/rdar-11628688/TestFormattersBoolRefPtr.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-11628688/TestFormattersBoolRefPtr.py?rev=160180&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-11628688/TestFormattersBoolRefPtr.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-11628688/TestFormattersBoolRefPtr.py Fri Jul 13 13:54:40 2012
@@ -0,0 +1,70 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+import datetime
+
+class DataFormatterOSTypeTestCase(TestBase):
+
+    mydir = os.path.join("functionalities", "data-formatter", "rdar-11628688")
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @dsym_test
+    def test_ostype_with_dsym_and_run_command(self):
+        """Test the formatters we use for OSType."""
+        self.buildDsym()
+        self.ostype_data_formatter_commands()
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @dwarf_test
+    def test_ostype_with_dwarf_and_run_command(self):
+        """Test the formatters we use for OSType."""
+        self.buildDwarf()
+        self.ostype_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.mm', '// Set break point at this line.')
+
+    def ostype_data_formatter_commands(self):
+        """Test the formatters we use for OSType."""
+        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+        self.expect("breakpoint set -f main.mm -l %d" % self.line,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.mm', line = %d, locations = 1" %
+                        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 format clear', check=False)
+            self.runCmd('type summary clear', check=False)
+            self.runCmd('type synth clear', check=False)
+
+        # Execute the cleanup function during test case tear down.
+        self.addTearDownHook(cleanup)
+
+        # Now check that we use the right summary for OSType
+        self.expect('frame variable',
+                    substrs = ["(OSType) a = 1952805748 'test'","(OSType) b = 1650815860 'best'"])
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/functionalities/data-formatter/rdar-11628688/main.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-11628688/main.mm?rev=160180&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-11628688/main.mm (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-11628688/main.mm Fri Jul 13 13:54:40 2012
@@ -0,0 +1,23 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+    
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+	OSType  a = 'test';
+	OSType b = 'best';
+	
+    [pool drain];// Set break point at this line.
+    return 0;
+}
+





More information about the lldb-commits mailing list