| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 1 | """ | 
|  | 2 | Set breakpoints on objective-c class and instance methods in foundation. | 
|  | 3 | Also lookup objective-c data types and evaluate expressions. | 
|  | 4 | """ | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 5 |  | 
|  | 6 | import os, time | 
|  | 7 | import unittest2 | 
|  | 8 | import lldb | 
|  | 9 | from lldbtest import * | 
|  | 10 |  | 
|  | 11 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") | 
|  | 12 | class FoundationTestCase(TestBase): | 
|  | 13 |  | 
| Johnny Chen | 23beac3 | 2011-06-25 20:55:22 +0000 | [diff] [blame] | 14 | mydir = os.path.join("lang", "objc", "foundation") | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 15 |  | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 16 | @dsym_test | 
| Johnny Chen | b219d28 | 2010-09-17 21:14:02 +0000 | [diff] [blame] | 17 | def test_break_with_dsym(self): | 
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 18 | """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 19 | self.buildDsym() | 
|  | 20 | self.break_on_objc_methods() | 
|  | 21 |  | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 22 | @dwarf_test | 
| Johnny Chen | b219d28 | 2010-09-17 21:14:02 +0000 | [diff] [blame] | 23 | def test_break_with_dwarf(self): | 
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 24 | """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 25 | self.buildDwarf() | 
|  | 26 | self.break_on_objc_methods() | 
|  | 27 |  | 
| Johnny Chen | 2769a42 | 2010-10-15 23:35:32 +0000 | [diff] [blame] | 28 | #@unittest2.expectedFailure | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 29 | # rdar://problem/8542091 | 
| Johnny Chen | 8eb3850 | 2010-09-29 17:58:12 +0000 | [diff] [blame] | 30 | # rdar://problem/8492646 | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 31 | @dsym_test | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 32 | def test_data_type_and_expr_with_dsym(self): | 
|  | 33 | """Lookup objective-c data types and evaluate expressions.""" | 
|  | 34 | self.buildDsym() | 
|  | 35 | self.data_type_and_expr_objc() | 
|  | 36 |  | 
| Johnny Chen | 2769a42 | 2010-10-15 23:35:32 +0000 | [diff] [blame] | 37 | #@unittest2.expectedFailure | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 38 | # rdar://problem/8542091 | 
| Johnny Chen | 8eb3850 | 2010-09-29 17:58:12 +0000 | [diff] [blame] | 39 | # rdar://problem/8492646 | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 40 | @dwarf_test | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 41 | def test_data_type_and_expr_with_dwarf(self): | 
|  | 42 | """Lookup objective-c data types and evaluate expressions.""" | 
|  | 43 | self.buildDwarf() | 
|  | 44 | self.data_type_and_expr_objc() | 
|  | 45 |  | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 46 | @python_api_test | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 47 | @dsym_test | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 48 | def test_print_ivars_correctly_with_dsym (self): | 
|  | 49 | self.buildDsym() | 
|  | 50 | self.print_ivars_correctly() | 
|  | 51 |  | 
|  | 52 | @python_api_test | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 53 | @dwarf_test | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 54 | def test_print_ivars_correctly_with_dwarf (self): | 
|  | 55 | self.buildDwarf() | 
|  | 56 | self.print_ivars_correctly() | 
|  | 57 |  | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 58 | def break_on_objc_methods(self): | 
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 59 | """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 60 | exe = os.path.join(os.getcwd(), "a.out") | 
|  | 61 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) | 
|  | 62 |  | 
|  | 63 | # Stop at +[NSString stringWithFormat:]. | 
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 64 | self.expect("_regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, | 
| Johnny Chen | f062c2f | 2010-10-12 19:29:49 +0000 | [diff] [blame] | 65 | substrs = ["Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1"]) | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 66 |  | 
| Johnny Chen | 2756d60 | 2010-09-16 23:57:33 +0000 | [diff] [blame] | 67 | # Stop at -[MyString initWithNSString:]. | 
|  | 68 | self.expect("breakpoint set -n '-[MyString initWithNSString:]'", BREAKPOINT_CREATED, | 
|  | 69 | startstr = "Breakpoint created: 2: name = '-[MyString initWithNSString:]', locations = 1") | 
|  | 70 |  | 
|  | 71 | # Stop at the "description" selector. | 
|  | 72 | self.expect("breakpoint set -S description", BREAKPOINT_CREATED, | 
|  | 73 | startstr = "Breakpoint created: 3: name = 'description', locations = 1") | 
|  | 74 |  | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 75 | # Stop at -[NSAutoreleasePool release]. | 
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 76 | self.expect("_regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, | 
| Johnny Chen | f062c2f | 2010-10-12 19:29:49 +0000 | [diff] [blame] | 77 | substrs = ["Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1"]) | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 78 |  | 
|  | 79 | self.runCmd("run", RUN_SUCCEEDED) | 
|  | 80 |  | 
|  | 81 | # First stop is +[NSString stringWithFormat:]. | 
|  | 82 | self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", | 
|  | 83 | substrs = ["Foundation`+[NSString stringWithFormat:]"]) | 
|  | 84 |  | 
|  | 85 | self.runCmd("process continue") | 
|  | 86 |  | 
| Johnny Chen | 73b7b93 | 2010-12-06 22:09:04 +0000 | [diff] [blame] | 87 | # Second stop is still +[NSString stringWithFormat:]. | 
|  | 88 | self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", | 
|  | 89 | substrs = ["Foundation`+[NSString stringWithFormat:]"]) | 
|  | 90 |  | 
|  | 91 | self.runCmd("process continue") | 
|  | 92 |  | 
| Johnny Chen | 2756d60 | 2010-09-16 23:57:33 +0000 | [diff] [blame] | 93 | # Followed by a.out`-[MyString initWithNSString:]. | 
|  | 94 | self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", | 
|  | 95 | substrs = ["a.out`-[MyString initWithNSString:]"]) | 
|  | 96 |  | 
|  | 97 | self.runCmd("process continue") | 
|  | 98 |  | 
|  | 99 | # Followed by -[MyString description]. | 
|  | 100 | self.expect("thread backtrace", "Stop at -[MyString description]", | 
|  | 101 | substrs = ["a.out`-[MyString description]"]) | 
|  | 102 |  | 
|  | 103 | self.runCmd("process continue") | 
|  | 104 |  | 
| Johnny Chen | 73b7b93 | 2010-12-06 22:09:04 +0000 | [diff] [blame] | 105 | # Followed by the same -[MyString description]. | 
|  | 106 | self.expect("thread backtrace", "Stop at -[MyString description]", | 
|  | 107 | substrs = ["a.out`-[MyString description]"]) | 
|  | 108 |  | 
|  | 109 | self.runCmd("process continue") | 
|  | 110 |  | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 111 | # Followed by -[NSAutoreleasePool release]. | 
|  | 112 | self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", | 
|  | 113 | substrs = ["Foundation`-[NSAutoreleasePool release]"]) | 
|  | 114 |  | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 115 | def setUp(self): | 
| Johnny Chen | aadcef5 | 2010-10-14 17:31:24 +0000 | [diff] [blame] | 116 | # Call super's setUp(). | 
|  | 117 | TestBase.setUp(self) | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 118 | # Find the line number to break inside main(). | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 119 | self.main_source = "main.m" | 
|  | 120 | self.line = line_number(self.main_source, '// Set break point at this line.') | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 121 |  | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 122 | def data_type_and_expr_objc(self): | 
|  | 123 | """Lookup objective-c data types and evaluate expressions.""" | 
|  | 124 | exe = os.path.join(os.getcwd(), "a.out") | 
|  | 125 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) | 
|  | 126 |  | 
|  | 127 | # Stop at -[MyString description]. | 
|  | 128 | self.expect("breakpoint set -n '-[MyString description]", BREAKPOINT_CREATED, | 
|  | 129 | startstr = "Breakpoint created: 1: name = '-[MyString description]', locations = 1") | 
|  | 130 |  | 
|  | 131 | self.runCmd("run", RUN_SUCCEEDED) | 
|  | 132 |  | 
|  | 133 | # The backtrace should show we stop at -[MyString description]. | 
|  | 134 | self.expect("thread backtrace", "Stop at -[MyString description]", | 
|  | 135 | substrs = ["a.out`-[MyString description]"]) | 
|  | 136 |  | 
|  | 137 | # Lookup objc data type MyString and evaluate some expressions. | 
|  | 138 |  | 
|  | 139 | self.expect("image lookup -t NSString", DATA_TYPES_DISPLAYED_CORRECTLY, | 
| Johnny Chen | 620f9d1 | 2010-09-29 17:50:35 +0000 | [diff] [blame] | 140 | substrs = ['name = "NSString"', | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 141 | 'clang_type = "@interface NSString']) | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 142 |  | 
|  | 143 | self.expect("image lookup -t MyString", DATA_TYPES_DISPLAYED_CORRECTLY, | 
| Johnny Chen | 620f9d1 | 2010-09-29 17:50:35 +0000 | [diff] [blame] | 144 | substrs = ['name = "MyString"', | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 145 | 'clang_type = "@interface MyString', | 
|  | 146 | 'NSString * str;', | 
|  | 147 | 'NSDate * date;']) | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 148 |  | 
| Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 149 | self.expect("frame variable -T -s", VARIABLES_DISPLAYED_CORRECTLY, | 
| Johnny Chen | 7fce877 | 2010-10-01 23:34:28 +0000 | [diff] [blame] | 150 | substrs = ["ARG: (MyString *) self"], | 
|  | 151 | patterns = ["ARG: \(.*\) _cmd", | 
| Greg Clayton | e305594 | 2011-06-30 02:28:26 +0000 | [diff] [blame] | 152 | "(objc_selector *)|(SEL)"]) | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 153 |  | 
| Johnny Chen | 07f06c4 | 2010-11-11 19:15:04 +0000 | [diff] [blame] | 154 | # rdar://problem/8651752 | 
|  | 155 | # don't crash trying to ask clang how many children an empty record has | 
|  | 156 | self.runCmd("frame variable *_cmd") | 
|  | 157 |  | 
| Johnny Chen | 8eb3850 | 2010-09-29 17:58:12 +0000 | [diff] [blame] | 158 | # rdar://problem/8492646 | 
|  | 159 | # test/foundation fails after updating to tot r115023 | 
|  | 160 | # self->str displays nothing as output | 
| Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 161 | self.expect("frame variable -T self->str", VARIABLES_DISPLAYED_CORRECTLY, | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 162 | startstr = "(NSString *) self->str") | 
|  | 163 |  | 
|  | 164 | # rdar://problem/8447030 | 
|  | 165 | # 'frame variable self->date' displays the wrong data member | 
| Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 166 | self.expect("frame variable -T self->date", VARIABLES_DISPLAYED_CORRECTLY, | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 167 | startstr = "(NSDate *) self->date") | 
|  | 168 |  | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 169 | # This should display the str and date member fields as well. | 
| Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 170 | self.expect("frame variable -T *self", VARIABLES_DISPLAYED_CORRECTLY, | 
| Johnny Chen | 8e74416 | 2010-12-15 22:50:54 +0000 | [diff] [blame] | 171 | substrs = ["(MyString) *self", | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 172 | "(NSString *) str", | 
|  | 173 | "(NSDate *) date"]) | 
| Sean Callanan | 3c88eae | 2012-01-05 22:35:40 +0000 | [diff] [blame] | 174 |  | 
|  | 175 | # isa should be accessible. | 
|  | 176 | self.expect("expression self->isa", VARIABLES_DISPLAYED_CORRECTLY, | 
|  | 177 | substrs = ["(Class)"]) | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 178 |  | 
|  | 179 | # This should fail expectedly. | 
| Johnny Chen | a8807f9 | 2010-10-19 00:52:07 +0000 | [diff] [blame] | 180 | self.expect("expression self->non_existent_member", | 
|  | 181 | COMMAND_FAILED_AS_EXPECTED, error=True, | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 182 | startstr = "error: 'MyString' does not have a member named 'non_existent_member'") | 
|  | 183 |  | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 184 | # Use expression parser. | 
| Johnny Chen | 99ff489 | 2010-11-12 00:55:31 +0000 | [diff] [blame] | 185 | self.runCmd("expression self->str") | 
|  | 186 | self.runCmd("expression self->date") | 
| Johnny Chen | 2e566e0 | 2010-09-29 18:05:03 +0000 | [diff] [blame] | 187 |  | 
| Johnny Chen | a8807f9 | 2010-10-19 00:52:07 +0000 | [diff] [blame] | 188 | # (lldb) expression self->str | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 189 | # error: instance variable 'str' is protected | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 190 | # error: 1 errors parsing expression | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 191 | # | 
| Johnny Chen | a8807f9 | 2010-10-19 00:52:07 +0000 | [diff] [blame] | 192 | # (lldb) expression self->date | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 193 | # error: instance variable 'date' is protected | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 194 | # error: 1 errors parsing expression | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 195 | # | 
|  | 196 |  | 
| Johnny Chen | 7987c61 | 2010-10-15 19:29:15 +0000 | [diff] [blame] | 197 | self.runCmd("breakpoint delete 1") | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 198 | self.expect("breakpoint set -f main.m -l %d" % self.line, | 
|  | 199 | BREAKPOINT_CREATED, | 
|  | 200 | startstr = "Breakpoint created: 2: file ='main.m', line = %d, locations = 1" % | 
|  | 201 | self.line) | 
|  | 202 | self.runCmd("process continue") | 
|  | 203 |  | 
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 204 | # rdar://problem/8542091 | 
|  | 205 | # test/foundation: expr -o -- my not working? | 
|  | 206 | # | 
|  | 207 | # Test new feature with r115115: | 
|  | 208 | # Add "-o" option to "expression" which prints the object description if available. | 
| Johnny Chen | a8807f9 | 2010-10-19 00:52:07 +0000 | [diff] [blame] | 209 | self.expect("expression -o -- my", "Object description displayed correctly", | 
| Johnny Chen | 2769a42 | 2010-10-15 23:35:32 +0000 | [diff] [blame] | 210 | patterns = ["Hello from.*a.out.*with timestamp: "]) | 
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 211 |  | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 212 | # See: <rdar://problem/8717050> lldb needs to use the ObjC runtime symbols for ivar offsets | 
|  | 213 | # Only fails for the ObjC 2.0 runtime. | 
|  | 214 | def print_ivars_correctly(self) : | 
|  | 215 | exe = os.path.join(os.getcwd(), "a.out") | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 216 |  | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 217 | target = self.dbg.CreateTarget(exe) | 
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 218 | self.assertTrue(target, VALID_TARGET) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 219 |  | 
|  | 220 | break1 = target.BreakpointCreateByLocation(self.main_source, self.line) | 
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 221 | self.assertTrue(break1, VALID_BREAKPOINT) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 222 |  | 
|  | 223 | # Now launch the process, and do not stop at entry point. | 
| Johnny Chen | 1d3e880 | 2011-07-11 23:38:23 +0000 | [diff] [blame] | 224 | process = target.LaunchSimple(None, None, os.getcwd()) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 225 |  | 
| Johnny Chen | 5a0bee7 | 2011-06-15 22:14:12 +0000 | [diff] [blame] | 226 | self.assertTrue(process, PROCESS_IS_VALID) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 227 |  | 
|  | 228 | # The stop reason of the thread should be breakpoint. | 
| Johnny Chen | 5a0bee7 | 2011-06-15 22:14:12 +0000 | [diff] [blame] | 229 | thread = process.GetThreadAtIndex(0) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 230 | if thread.GetStopReason() != lldb.eStopReasonBreakpoint: | 
| Johnny Chen | de90f1d | 2011-04-27 17:43:07 +0000 | [diff] [blame] | 231 | from lldbutil import stop_reason_to_str | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 232 | self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % | 
| Johnny Chen | de90f1d | 2011-04-27 17:43:07 +0000 | [diff] [blame] | 233 | stop_reason_to_str(thread.GetStopReason())) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 234 |  | 
|  | 235 | # Make sure we stopped at the first breakpoint. | 
|  | 236 |  | 
|  | 237 | cur_frame = thread.GetFrameAtIndex(0) | 
|  | 238 |  | 
|  | 239 | line_number = cur_frame.GetLineEntry().GetLine() | 
|  | 240 | self.assertTrue (line_number == self.line, "Hit the first breakpoint.") | 
|  | 241 |  | 
|  | 242 | my_var = cur_frame.FindVariable("my") | 
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 243 | self.assertTrue(my_var, "Made a variable object for my") | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 244 |  | 
|  | 245 | str_var = cur_frame.FindVariable("str") | 
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 246 | self.assertTrue(str_var, "Made a variable object for str") | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 247 |  | 
|  | 248 | # Now make sure that the my->str == str: | 
|  | 249 |  | 
|  | 250 | my_str_var = my_var.GetChildMemberWithName("str") | 
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 251 | self.assertTrue(my_str_var, "Found a str ivar in my") | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 252 |  | 
| Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 253 | str_value = int(str_var.GetValue(), 0) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 254 |  | 
| Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 255 | my_str_value = int(my_str_var.GetValue(), 0) | 
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 256 |  | 
|  | 257 | self.assertTrue(str_value == my_str_value, "Got the correct value for my->str") | 
|  | 258 |  | 
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 259 | if __name__ == '__main__': | 
|  | 260 | import atexit | 
|  | 261 | lldb.SBDebugger.Initialize() | 
|  | 262 | atexit.register(lambda: lldb.SBDebugger.Terminate()) | 
|  | 263 | unittest2.main() |