[Lldb-commits] [lldb] r127904 - in /lldb/trunk/test/unique-types: TestUniqueTypes.py main.cpp

Johnny Chen johnny.chen at apple.com
Fri Mar 18 13:51:13 PDT 2011


Author: johnny
Date: Fri Mar 18 15:51:13 2011
New Revision: 127904

URL: http://llvm.org/viewvc/llvm-project?rev=127904&view=rev
Log:
Add cases to test that two template instantiations of std::vector<long> and std::vector<short>
in the same compilation module show up as different types for lldb debugger.

Added:
    lldb/trunk/test/unique-types/TestUniqueTypes.py
Modified:
    lldb/trunk/test/unique-types/main.cpp

Added: lldb/trunk/test/unique-types/TestUniqueTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unique-types/TestUniqueTypes.py?rev=127904&view=auto
==============================================================================
--- lldb/trunk/test/unique-types/TestUniqueTypes.py (added)
+++ lldb/trunk/test/unique-types/TestUniqueTypes.py Fri Mar 18 15:51:13 2011
@@ -0,0 +1,73 @@
+"""
+Test that template instaniations of std::vector<long> and <short> in the same module have the correct types.
+"""
+
+import unittest2
+import lldb
+from lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+
+    mydir = "unique-types"
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    def test_with_dsym(self):
+        """Test for unique types of std::vector<long> and std::vector<short>."""
+        self.buildDsym()
+        self.unique_types()
+
+    def test_with_dwarf(self):
+        """Test for unique types of std::vector<long> and std::vector<short>."""
+        self.buildDwarf()
+        self.unique_types()
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number inside main.cpp.
+        self.line = line_number("main.cpp",
+          "// Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types.")
+
+    def unique_types(self):
+        """Test for unique types of std::vector<long> and std::vector<short>."""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, 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, 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 = ['state is stopped',
+                       'stop reason = breakpoint'])
+
+        # Do a "frame variable -t longs" and verify "long" is in each line of output.
+        self.runCmd("frame variable -t longs")
+        output = self.res.GetOutput()
+        for x in [line.strip() for line in output.split(os.linesep)]:
+            # Skip empty line or closing brace.
+            if not x or x == '}':
+                continue
+            self.expect(x, "Expect type 'long'", exe=False,
+                substrs = ['long'])
+
+        # Do a "frame variable -t shorts" and verify "short" is in each line of output.
+        self.runCmd("frame variable -t shorts")
+        output = self.res.GetOutput()
+        for x in [line.strip() for line in output.split(os.linesep)]:
+            # Skip empty line or closing brace.
+            if not x or x == '}':
+                continue
+            self.expect(x, "Expect type 'short'", exe=False,
+                substrs = ['short'])
+        
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Modified: lldb/trunk/test/unique-types/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unique-types/main.cpp?rev=127904&r1=127903&r2=127904&view=diff
==============================================================================
--- lldb/trunk/test/unique-types/main.cpp (original)
+++ lldb/trunk/test/unique-types/main.cpp Fri Mar 18 15:51:13 2011
@@ -1,3 +1,11 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
 #include <vector>
 
 #include <stdio.h>
@@ -12,5 +20,5 @@
         longs.push_back(i);
         shorts.push_back(i);
     }
-    return 0;
+    return 0; // Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types.
 }





More information about the lldb-commits mailing list