[Lldb-commits] [lldb] r115536 - /lldb/trunk/test/stl/TestDisassemble.py

Johnny Chen johnny.chen at apple.com
Mon Oct 4 11:39:14 PDT 2010


Author: johnny
Date: Mon Oct  4 13:39:14 2010
New Revision: 115536

URL: http://llvm.org/viewvc/llvm-project?rev=115536&view=rev
Log:
Initial version of a test case meant to disassemble each and every function from
the stdc++ library module.  Right now, it doesn't do any disassembly at all.  It
merely locates the stdc++ library.  Also tests the SBProcess object description
and verifies it is in a 'Stopped' state.

Added:
    lldb/trunk/test/stl/TestDisassemble.py

Added: lldb/trunk/test/stl/TestDisassemble.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestDisassemble.py?rev=115536&view=auto
==============================================================================
--- lldb/trunk/test/stl/TestDisassemble.py (added)
+++ lldb/trunk/test/stl/TestDisassemble.py Mon Oct  4 13:39:14 2010
@@ -0,0 +1,56 @@
+"""
+Test the lldb disassemble command.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+ at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+class StdCXXDisassembleTestCase(TestBase):
+
+    mydir = "stl"
+
+    @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test")
+    def test_stdcxx_disasm(self):
+        """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib."""
+        self.buildDefault()
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # Break on line 13 of main.cpp.
+        self.expect("breakpoint set -f main.cpp -l 13", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1")
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # Now let's get the target as well as the process objects.
+        target = self.dbg.GetSelectedTarget()
+        process = target.GetProcess()
+
+        # The process should be in a 'Stopped' state.
+        self.expect(repr(process), STOPPED_DUE_TO_BREAKPOINT, exe=False,
+            substrs = ["a.out",
+                       "state: Stopped"])
+
+        # Iterate through the available modules, looking for stdc++ library...
+        for i in range(target.GetNumModules()):
+            module = target.GetModuleAtIndex(i)
+            fs = module.GetFileSpec()
+            if (fs.GetFilename().startswith("libstdc++")):
+                lib_stdcxx = repr(fs)
+                break
+
+        # At this point, lib_stdcxx is the full path to the stdc++ library and
+        # module is the corresponding SBModule.
+
+        self.expect(fs.GetFilename(), "Libraray StdC++ is located", exe=False,
+            substrs = ["libstdc++"])
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()





More information about the lldb-commits mailing list