blob: bbdf585484980df71014cb951261fc10f3c4b9c1 [file] [log] [blame]
Johnny Chen3b83d632011-03-04 18:17:49 +00001"""
2Test that objective-c expression parser continues to work for optimized build.
3
4http://llvm.org/viewvc/llvm-project?rev=126973&view=rev
5Fixed a bug in the expression parser where the 'this'
6or 'self' variable was not properly read if the compiler
7optimized it into a register.
8"""
9
10import os, time
11import unittest2
12import lldb
13from lldbtest import *
14
15# rdar://problem/9087739
16# test failure: objc_optimized does not work for "-C clang -A i386"
17@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
18class ObjcOptimizedTestCase(TestBase):
19
Johnny Chen33e89de2011-06-25 20:16:38 +000020 mydir = os.path.join("lang", "objc", "objc-optimized")
Johnny Chen3b83d632011-03-04 18:17:49 +000021 myclass = "MyClass"
22 mymethod = "description"
23 method_spec = "-[%s %s]" % (myclass, mymethod)
24
25 def test_break_with_dsym(self):
26 """Test 'expr member' continues to work for optimized build."""
27 self.buildDsym()
28 self.objc_optimized()
29
30 def test_break_with_dwarf(self):
31 """Test 'expr member' continues to work for optimized build."""
32 self.buildDwarf()
33 self.objc_optimized()
34
35 def objc_optimized(self):
36 """Test 'expr member' continues to work for optimized build."""
37 exe = os.path.join(os.getcwd(), "a.out")
38 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
39
40 self.expect("breakpoint set -n '%s'" % self.method_spec,
41 BREAKPOINT_CREATED,
42 startstr = "Breakpoint created: 1: name = '%s', locations = 1" % self.method_spec)
43
44 self.runCmd("run", RUN_SUCCEEDED)
45 self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
46 substrs = ["stop reason = breakpoint"],
47 patterns = ["frame.*0:.*%s %s" % (self.myclass, self.mymethod)])
48
49 self.expect('expression member',
50 startstr = "(int) $0 = 5")
51
52 self.expect('expression self',
53 startstr = "(%s *) $1 = " % self.myclass)
54
55 self.expect('expression self->non_member', error=True,
56 substrs = ["does not have a member named 'non_member'"])
57
58
59if __name__ == '__main__':
60 import atexit
61 lldb.SBDebugger.Initialize()
62 atexit.register(lambda: lldb.SBDebugger.Terminate())
63 unittest2.main()