[Lldb-commits] [lldb] r115652 - in /lldb/trunk/test: foundation/TestDisassembly.py foundation/TestFoundationDisassembly.py lldbtest.py stl/TestDisassembly.py stl/TestStdCXXDisassembly.py

Johnny Chen johnny.chen at apple.com
Tue Oct 5 12:27:32 PDT 2010


Author: johnny
Date: Tue Oct  5 14:27:32 2010
New Revision: 115652

URL: http://llvm.org/viewvc/llvm-project?rev=115652&view=rev
Log:
Make the test module with unique name instead of just the generic name TestDisassembly.
Add a utility function to lldbtest.py to get the native pointer size of the host os.

Added:
    lldb/trunk/test/foundation/TestFoundationDisassembly.py
      - copied unchanged from r115636, lldb/trunk/test/foundation/TestDisassembly.py
    lldb/trunk/test/stl/TestStdCXXDisassembly.py
      - copied unchanged from r115636, lldb/trunk/test/stl/TestDisassembly.py
Removed:
    lldb/trunk/test/foundation/TestDisassembly.py
    lldb/trunk/test/stl/TestDisassembly.py
Modified:
    lldb/trunk/test/lldbtest.py

Removed: lldb/trunk/test/foundation/TestDisassembly.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassembly.py?rev=115651&view=auto
==============================================================================
--- lldb/trunk/test/foundation/TestDisassembly.py (original)
+++ lldb/trunk/test/foundation/TestDisassembly.py (removed)
@@ -1,129 +0,0 @@
-"""
-Test the lldb disassemble command on foundation framework.
-"""
-
-import os, time
-import unittest2
-import lldb
-from lldbtest import *
-
- at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
-class FoundationDisassembleTestCase(TestBase):
-
-    mydir = "foundation"
-
-    # rdar://problem/8504895
-    # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]"
-    @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test")
-    def test_foundation_disasm(self):
-        """Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework."""
-        self.buildDefault()
-        exe = os.path.join(os.getcwd(), "a.out")
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        self.runCmd("image list")
-        raw_output = self.res.GetOutput()
-        # Grok the full path to the foundation framework.
-        for line in raw_output.split(os.linesep):
-            match = re.search(" (/.*/Foundation.framework/.*)$", line)
-            if match:
-                foundation_framework = match.group(1)
-                break
-
-        self.assertTrue(match, "Foundation.framework path located")
-        self.runCmd("image dump symtab %s" % foundation_framework)
-        raw_output = self.res.GetOutput()
-        # Now, grab every 'Code' symbol and feed it into the command:
-        # 'disassemble -n func'.
-        #
-        # The symbol name is on the last column and trails the flag column which
-        # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits.
-        codeRE = re.compile(r"""
-                             \ Code\ {9}    # ' Code' followed by 9 SPCs,
-                             .*             # the wildcard chars,
-                             0x[0-9a-f]{8}  # the flag column, and
-                             \ (.+)$        # finally the function symbol.
-                             """, re.VERBOSE)
-        for line in raw_output.split(os.linesep):
-            match = codeRE.search(line)
-            if match:
-                func = match.group(1)
-                #print "line:", line
-                #print "func:", func
-                self.runCmd('disassemble -n "%s"' % func)
-        
-
-    def test_simple_disasm_with_dsym(self):
-        """Test the lldb 'disassemble' command"""
-        self.buildDsym()
-        self.do_simple_disasm()
-
-    def test_simple_disasm_with_dwarf(self):
-        """Test the lldb 'disassemble' command"""
-        self.buildDwarf()
-        self.do_simple_disasm()
-
-    def do_simple_disasm(self):
-        """Do a bunch of simple disassemble commands."""
-        exe = os.path.join(os.getcwd(), "a.out")
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-        # Stop at +[NSString stringWithFormat:].
-        self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1")
-
-        # Stop at -[MyString initWithNSString:].
-        self.expect("breakpoint set -n '-[MyString initWithNSString:]'", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 2: name = '-[MyString initWithNSString:]', locations = 1")
-
-        # Stop at the "description" selector.
-        self.expect("breakpoint set -S description", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 3: name = 'description', locations = 1")
-
-        # Stop at -[NSAutoreleasePool release].
-        self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1")
-
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        # First stop is +[NSString stringWithFormat:].
-        self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]",
-            substrs = ["Foundation`+[NSString stringWithFormat:]"])
-
-        # Do the disassemble for the currently stopped function.
-        self.runCmd("disassemble")
-
-        self.runCmd("process continue")
-
-        # Followed by a.out`-[MyString initWithNSString:].
-        self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]",
-            substrs = ["a.out`-[MyString initWithNSString:]"])
-
-        # Do the disassemble for the currently stopped function.
-        self.runCmd("disassemble")
-
-        self.runCmd("process continue")
-
-        # Followed by -[MyString description].
-        self.expect("thread backtrace", "Stop at -[MyString description]",
-            substrs = ["a.out`-[MyString description]"])
-
-        # Do the disassemble for the currently stopped function.
-        self.runCmd("disassemble")
-
-        self.runCmd("process continue")
-
-        # Followed by -[NSAutoreleasePool release].
-        self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]",
-            substrs = ["Foundation`-[NSAutoreleasePool release]"])
-
-        # Do the disassemble for the currently stopped function.
-        self.runCmd("disassemble")
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115652&r1=115651&r2=115652&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Tue Oct  5 14:27:32 2010
@@ -126,6 +126,8 @@
 
 RUN_COMPLETED = "Process exited successfully"
 
+BACKTRACE_DISPLAYED_CORRECTLY = "Backtrace displayed correctly"
+
 BREAKPOINT_CREATED = "Breakpoint created successfully"
 
 BREAKPOINT_PENDING_CREATED = "Pending breakpoint created successfully"
@@ -260,6 +262,12 @@
         raise CalledProcessError(retcode, cmd)
     return output
 
+def pointer_size():
+    """Return the pointer size of the host system."""
+    import ctypes
+    a_pointer = ctypes.c_void_p(0xffff)
+    return 8 * ctypes.sizeof(a_pointer)
+
 
 class TestBase(unittest2.TestCase):
     """This LLDB abstract base class is meant to be subclassed."""

Removed: lldb/trunk/test/stl/TestDisassembly.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestDisassembly.py?rev=115651&view=auto
==============================================================================
--- lldb/trunk/test/stl/TestDisassembly.py (original)
+++ lldb/trunk/test/stl/TestDisassembly.py (removed)
@@ -1,100 +0,0 @@
-"""
-Test the lldb disassemble command on lib stdc++.
-"""
-
-import os, time
-import unittest2
-import lldb
-from lldbtest import *
-
-class StdCXXDisassembleTestCase(TestBase):
-
-    mydir = "stl"
-
-    # rdar://problem/8504895
-    # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]"
-    @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"])
-
-        # Disassemble the functions on the call stack.
-        self.runCmd("thread backtrace")
-        thread = process.GetThreadAtIndex(0)
-        depth = thread.GetNumFrames()
-        for i in range(depth - 1):
-            frame = thread.GetFrameAtIndex(i)
-            function = frame.GetFunction()
-            self.runCmd("disassemble -n '%s'" % function.GetName())
-
-        # 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++"])
-
-        self.runCmd("image dump symtab %s" % repr(fs))
-        raw_output = self.res.GetOutput()
-        # Now, look for every 'Code' symbol and feed its load address into the
-        # command: 'disassemble -s load_address -e end_address', where the
-        # end_address is taken from the next consecutive 'Code' symbol entry's
-        # load address.
-        #
-        # The load address column comes after the file address column, with both
-        # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits.
-        codeRE = re.compile(r"""
-                             \ Code\ {9}      # ' Code' followed by 9 SPCs,
-                             0x[0-9a-f]{16}   # the file address column, and
-                             \                # a SPC, and
-                             (0x[0-9a-f]{16}) # the load address column, and
-                             .*               # the rest.
-                             """, re.VERBOSE)
-        # Maintain a start address variable; if we arrive at a consecutive Code
-        # entry, then the load address of the that entry is fed as the end
-        # address to the 'disassemble -s SA -e LA' command.
-        SA = None
-        for line in raw_output.split(os.linesep):
-            match = codeRE.search(line)
-            if match:
-                LA = match.group(1)
-                print "line:", line
-                print "load address:", LA
-                print "SA:", SA
-                if SA and LA:
-                    self.runCmd("disassemble -s %s -e %s" % (SA, LA))
-                SA = LA
-            else:
-                # This entry is not a Code entry.  Reset SA = None.
-                SA = None
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()





More information about the lldb-commits mailing list