| 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 | |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 25 | @dsym_test |
| Johnny Chen | 3b83d63 | 2011-03-04 18:17:49 +0000 | [diff] [blame] | 26 | def test_break_with_dsym(self): |
| 27 | """Test 'expr member' continues to work for optimized build.""" |
| 28 | self.buildDsym() |
| 29 | self.objc_optimized() |
| 30 | |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 31 | @dwarf_test |
| Johnny Chen | 3b83d63 | 2011-03-04 18:17:49 +0000 | [diff] [blame] | 32 | def test_break_with_dwarf(self): |
| 33 | """Test 'expr member' continues to work for optimized build.""" |
| 34 | self.buildDwarf() |
| 35 | self.objc_optimized() |
| 36 | |
| 37 | def objc_optimized(self): |
| 38 | """Test 'expr member' continues to work for optimized build.""" |
| 39 | exe = os.path.join(os.getcwd(), "a.out") |
| 40 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 41 | |
| 42 | self.expect("breakpoint set -n '%s'" % self.method_spec, |
| 43 | BREAKPOINT_CREATED, |
| 44 | startstr = "Breakpoint created: 1: name = '%s', locations = 1" % self.method_spec) |
| 45 | |
| 46 | self.runCmd("run", RUN_SUCCEEDED) |
| 47 | self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, |
| 48 | substrs = ["stop reason = breakpoint"], |
| 49 | patterns = ["frame.*0:.*%s %s" % (self.myclass, self.mymethod)]) |
| 50 | |
| 51 | self.expect('expression member', |
| 52 | startstr = "(int) $0 = 5") |
| 53 | |
| 54 | self.expect('expression self', |
| 55 | startstr = "(%s *) $1 = " % self.myclass) |
| 56 | |
| 57 | self.expect('expression self->non_member', error=True, |
| 58 | substrs = ["does not have a member named 'non_member'"]) |
| 59 | |
| 60 | |
| 61 | if __name__ == '__main__': |
| 62 | import atexit |
| 63 | lldb.SBDebugger.Initialize() |
| 64 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 65 | unittest2.main() |