2010-08-24 22:07:56 +00:00
|
|
|
"""Test aspects of lldb commands on universal binaries."""
|
|
|
|
|
|
|
|
import os, time
|
|
|
|
import unittest2
|
|
|
|
import lldb
|
|
|
|
from lldbtest import *
|
|
|
|
|
2010-09-01 19:59:58 +00:00
|
|
|
class UniversalTestCase(TestBase):
|
2010-08-24 22:07:56 +00:00
|
|
|
|
2010-11-09 17:09:20 +00:00
|
|
|
mydir = os.path.join("macosx", "universal")
|
2010-08-24 22:07:56 +00:00
|
|
|
|
2010-10-12 22:39:52 +00:00
|
|
|
def setUp(self):
|
2010-10-14 17:31:24 +00:00
|
|
|
# Call super's setUp().
|
|
|
|
TestBase.setUp(self)
|
2010-10-12 22:39:52 +00:00
|
|
|
# Find the line number to break inside main().
|
|
|
|
self.line = line_number('main.c', '// Set break point at this line.')
|
|
|
|
|
2010-12-01 00:03:17 +00:00
|
|
|
# rdar://problem/8689814 test failure: test/macosx/universal (the i386 slice does not break?)
|
2010-09-03 23:49:16 +00:00
|
|
|
@unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4]=='i386',
|
|
|
|
"requires Darwin & i386")
|
2010-08-24 22:07:56 +00:00
|
|
|
def test_process_launch_for_universal(self):
|
|
|
|
"""Test process launch of a universal binary."""
|
|
|
|
|
2010-09-03 23:49:16 +00:00
|
|
|
# Invoke the default build rule.
|
|
|
|
self.buildDefault()
|
|
|
|
|
2010-08-24 22:07:56 +00:00
|
|
|
# Note that "testit" is a universal binary.
|
|
|
|
exe = os.path.join(os.getcwd(), "testit")
|
|
|
|
|
|
|
|
# By default, x86_64 is assumed if no architecture is specified.
|
|
|
|
self.expect("file " + exe, CURRENT_EXECUTABLE_SET,
|
|
|
|
startstr = "Current executable set to ",
|
|
|
|
substrs = ["testit' (x86_64)."])
|
|
|
|
|
|
|
|
# Break inside the main.
|
2010-10-12 22:39:52 +00:00
|
|
|
self.expect("breakpoint set -f main.c -l %d" % self.line,
|
|
|
|
BREAKPOINT_CREATED,
|
|
|
|
startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
|
|
|
|
self.line)
|
2010-08-24 22:07:56 +00:00
|
|
|
|
|
|
|
# We should be able to launch the x86_64 executable.
|
2010-08-27 23:47:36 +00:00
|
|
|
self.runCmd("run", RUN_SUCCEEDED)
|
2010-08-25 22:52:45 +00:00
|
|
|
|
|
|
|
# Check whether we have a 64-bit process launched.
|
2010-08-26 22:06:03 +00:00
|
|
|
target = self.dbg.GetSelectedTarget()
|
2010-08-25 22:52:45 +00:00
|
|
|
process = target.GetProcess()
|
|
|
|
self.assertTrue(target.IsValid() and process.IsValid() and
|
|
|
|
self.invoke(process, 'GetAddressByteSize') == 8,
|
|
|
|
"64-bit process launched")
|
|
|
|
|
2010-08-24 22:07:56 +00:00
|
|
|
self.runCmd("continue")
|
|
|
|
|
|
|
|
# Now specify i386 as the architecture for "testit".
|
|
|
|
self.expect("file " + exe + " -a i386", CURRENT_EXECUTABLE_SET,
|
|
|
|
startstr = "Current executable set to ",
|
|
|
|
substrs = ["testit' (i386)."])
|
|
|
|
|
|
|
|
# Break inside the main.
|
2010-10-12 22:39:52 +00:00
|
|
|
self.expect("breakpoint set -f main.c -l %d" % self.line,
|
|
|
|
BREAKPOINT_CREATED,
|
|
|
|
startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
|
|
|
|
self.line)
|
2010-08-24 22:07:56 +00:00
|
|
|
|
2010-08-24 23:14:47 +00:00
|
|
|
# We should be able to launch the i386 executable as well.
|
2010-08-27 23:47:36 +00:00
|
|
|
self.runCmd("run", RUN_SUCCEEDED)
|
2010-08-25 22:52:45 +00:00
|
|
|
|
|
|
|
# Check whether we have a 32-bit process launched.
|
2010-08-26 22:06:03 +00:00
|
|
|
target = self.dbg.GetSelectedTarget()
|
2010-08-25 22:52:45 +00:00
|
|
|
process = target.GetProcess()
|
|
|
|
self.assertTrue(target.IsValid() and process.IsValid() and
|
|
|
|
self.invoke(process, 'GetAddressByteSize') == 4,
|
|
|
|
"32-bit process launched")
|
|
|
|
|
2010-08-24 22:07:56 +00:00
|
|
|
self.runCmd("continue")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import atexit
|
|
|
|
lldb.SBDebugger.Initialize()
|
|
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
|
|
|
unittest2.main()
|