| Johnny Chen | 3b83d63 | 2011-03-04 18:17:49 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test that objective-c expression parser continues to work for optimized build. |
| 3 | |
| 4 | http://llvm.org/viewvc/llvm-project?rev=126973&view=rev |
| 5 | Fixed a bug in the expression parser where the 'this' |
| 6 | or 'self' variable was not properly read if the compiler |
| 7 | optimized it into a register. |
| 8 | """ |
| 9 | |
| 10 | import os, time |
| 11 | import unittest2 |
| 12 | import lldb |
| 13 | from 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") |
| 18 | class ObjcOptimizedTestCase(TestBase): |
| 19 | |
| Johnny Chen | 33e89de | 2011-06-25 20:16:38 +0000 | [diff] [blame] | 20 | mydir = os.path.join("lang", "objc", "objc-optimized") |
| Johnny Chen | 3b83d63 | 2011-03-04 18:17:49 +0000 | [diff] [blame] | 21 | 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 | |
| 59 | if __name__ == '__main__': |
| 60 | import atexit |
| 61 | lldb.SBDebugger.Initialize() |
| 62 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 63 | unittest2.main() |