| 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 * |
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 10 | import lldbutil |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 11 | |
| 12 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
| 13 | class FoundationTestCase(TestBase): |
| 14 | |
| Johnny Chen | 23beac3 | 2011-06-25 20:55:22 +0000 | [diff] [blame] | 15 | mydir = os.path.join("lang", "objc", "foundation") |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 16 | |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 17 | @dsym_test |
| Johnny Chen | b219d28 | 2010-09-17 21:14:02 +0000 | [diff] [blame] | 18 | def test_break_with_dsym(self): |
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 19 | """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 20 | self.buildDsym() |
| 21 | self.break_on_objc_methods() |
| 22 | |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 23 | @dwarf_test |
| Johnny Chen | b219d28 | 2010-09-17 21:14:02 +0000 | [diff] [blame] | 24 | def test_break_with_dwarf(self): |
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 25 | """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 26 | self.buildDwarf() |
| 27 | self.break_on_objc_methods() |
| 28 | |
| Johnny Chen | 2769a42 | 2010-10-15 23:35:32 +0000 | [diff] [blame] | 29 | #@unittest2.expectedFailure |
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 30 | # rdar://problem/8542091 |
| Johnny Chen | 8eb3850 | 2010-09-29 17:58:12 +0000 | [diff] [blame] | 31 | # rdar://problem/8492646 |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 32 | @dsym_test |
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 33 | def test_data_type_and_expr_with_dsym(self): |
| 34 | """Lookup objective-c data types and evaluate expressions.""" |
| 35 | self.buildDsym() |
| 36 | self.data_type_and_expr_objc() |
| 37 | |
| Johnny Chen | 2769a42 | 2010-10-15 23:35:32 +0000 | [diff] [blame] | 38 | #@unittest2.expectedFailure |
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 39 | # rdar://problem/8542091 |
| Johnny Chen | 8eb3850 | 2010-09-29 17:58:12 +0000 | [diff] [blame] | 40 | # rdar://problem/8492646 |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 41 | @dwarf_test |
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 42 | def test_data_type_and_expr_with_dwarf(self): |
| 43 | """Lookup objective-c data types and evaluate expressions.""" |
| 44 | self.buildDwarf() |
| 45 | self.data_type_and_expr_objc() |
| 46 | |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 47 | @python_api_test |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 48 | @dsym_test |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 49 | def test_print_ivars_correctly_with_dsym (self): |
| 50 | self.buildDsym() |
| 51 | self.print_ivars_correctly() |
| 52 | |
| 53 | @python_api_test |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 54 | @dwarf_test |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 55 | def test_print_ivars_correctly_with_dwarf (self): |
| 56 | self.buildDwarf() |
| 57 | self.print_ivars_correctly() |
| 58 | |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 59 | def break_on_objc_methods(self): |
| Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 60 | """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 61 | exe = os.path.join(os.getcwd(), "a.out") |
| 62 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 63 | |
| 64 | # Stop at +[NSString stringWithFormat:]. |
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 65 | break_results = lldbutil.run_break_set_command(self, "_regexp-break +[NSString stringWithFormat:]") |
| 66 | lldbutil.check_breakpoint_result (self, break_results, symbol_name='+[NSString stringWithFormat:]', num_locations=1) |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 67 | |
| Johnny Chen | 2756d60 | 2010-09-16 23:57:33 +0000 | [diff] [blame] | 68 | # Stop at -[MyString initWithNSString:]. |
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 69 | lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True) |
| Johnny Chen | 2756d60 | 2010-09-16 23:57:33 +0000 | [diff] [blame] | 70 | |
| 71 | # Stop at the "description" selector. |
| Greg Clayton | c1b2ccf | 2013-01-08 00:01:36 +0000 | [diff] [blame] | 72 | lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1, module_name='a.out') |
| Johnny Chen | 2756d60 | 2010-09-16 23:57:33 +0000 | [diff] [blame] | 73 | |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 74 | # Stop at -[NSAutoreleasePool release]. |
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 75 | break_results = lldbutil.run_break_set_command(self, "_regexp-break -[NSAutoreleasePool release]") |
| 76 | lldbutil.check_breakpoint_result (self, break_results, symbol_name='-[NSAutoreleasePool release]', num_locations=1) |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 77 | |
| 78 | self.runCmd("run", RUN_SUCCEEDED) |
| 79 | |
| 80 | # First stop is +[NSString stringWithFormat:]. |
| 81 | self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", |
| 82 | substrs = ["Foundation`+[NSString stringWithFormat:]"]) |
| 83 | |
| 84 | self.runCmd("process continue") |
| 85 | |
| Johnny Chen | 73b7b93 | 2010-12-06 22:09:04 +0000 | [diff] [blame] | 86 | # Second stop is still +[NSString stringWithFormat:]. |
| 87 | self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", |
| 88 | substrs = ["Foundation`+[NSString stringWithFormat:]"]) |
| 89 | |
| 90 | self.runCmd("process continue") |
| 91 | |
| Johnny Chen | 2756d60 | 2010-09-16 23:57:33 +0000 | [diff] [blame] | 92 | # Followed by a.out`-[MyString initWithNSString:]. |
| 93 | self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", |
| 94 | substrs = ["a.out`-[MyString initWithNSString:]"]) |
| 95 | |
| 96 | self.runCmd("process continue") |
| 97 | |
| 98 | # Followed by -[MyString description]. |
| 99 | self.expect("thread backtrace", "Stop at -[MyString description]", |
| 100 | substrs = ["a.out`-[MyString description]"]) |
| 101 | |
| 102 | self.runCmd("process continue") |
| 103 | |
| Johnny Chen | 73b7b93 | 2010-12-06 22:09:04 +0000 | [diff] [blame] | 104 | # Followed by the same -[MyString description]. |
| 105 | self.expect("thread backtrace", "Stop at -[MyString description]", |
| 106 | substrs = ["a.out`-[MyString description]"]) |
| 107 | |
| 108 | self.runCmd("process continue") |
| 109 | |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 110 | # Followed by -[NSAutoreleasePool release]. |
| 111 | self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", |
| 112 | substrs = ["Foundation`-[NSAutoreleasePool release]"]) |
| 113 | |
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 114 | def setUp(self): |
| Johnny Chen | aadcef5 | 2010-10-14 17:31:24 +0000 | [diff] [blame] | 115 | # Call super's setUp(). |
| 116 | TestBase.setUp(self) |
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 117 | # Find the line number to break inside main(). |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 118 | self.main_source = "main.m" |
| 119 | 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] | 120 | |
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 121 | def data_type_and_expr_objc(self): |
| 122 | """Lookup objective-c data types and evaluate expressions.""" |
| 123 | exe = os.path.join(os.getcwd(), "a.out") |
| 124 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 125 | |
| 126 | # Stop at -[MyString description]. |
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 127 | lldbutil.run_break_set_by_symbol (self, '-[MyString description]', num_expected_locations=1, sym_exact=True) |
| 128 | # self.expect("breakpoint set -n '-[MyString description]", BREAKPOINT_CREATED, |
| 129 | # startstr = "Breakpoint created: 1: name = '-[MyString description]', locations = 1") |
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 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 | |
| Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 149 | self.expect("frame variable --show-types --scope", 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 |
| Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 161 | self.expect("frame variable --show-types 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 |
| Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 166 | self.expect("frame variable --show-types 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. |
| Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 170 | self.expect("frame variable --show-types *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") |
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 198 | lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) |
| Jim Ingham | 493dffe | 2012-09-22 00:14:47 +0000 | [diff] [blame] | 199 | |
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 200 | self.runCmd("process continue") |
| 201 | |
| Johnny Chen | f8afe89 | 2010-10-12 21:20:11 +0000 | [diff] [blame] | 202 | # rdar://problem/8542091 |
| 203 | # test/foundation: expr -o -- my not working? |
| 204 | # |
| 205 | # Test new feature with r115115: |
| 206 | # Add "-o" option to "expression" which prints the object description if available. |
| Enrico Granata | 7b8c513 | 2012-12-12 03:23:37 +0000 | [diff] [blame] | 207 | self.expect("expression --object-description -- my", "Object description displayed correctly", |
| Johnny Chen | 2769a42 | 2010-10-15 23:35:32 +0000 | [diff] [blame] | 208 | patterns = ["Hello from.*a.out.*with timestamp: "]) |
| Johnny Chen | b330786 | 2010-09-17 22:28:51 +0000 | [diff] [blame] | 209 | |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 210 | # See: <rdar://problem/8717050> lldb needs to use the ObjC runtime symbols for ivar offsets |
| 211 | # Only fails for the ObjC 2.0 runtime. |
| 212 | def print_ivars_correctly(self) : |
| 213 | exe = os.path.join(os.getcwd(), "a.out") |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 214 | |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 215 | target = self.dbg.CreateTarget(exe) |
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 216 | self.assertTrue(target, VALID_TARGET) |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 217 | |
| 218 | break1 = target.BreakpointCreateByLocation(self.main_source, self.line) |
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 219 | self.assertTrue(break1, VALID_BREAKPOINT) |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 220 | |
| 221 | # Now launch the process, and do not stop at entry point. |
| Johnny Chen | 1d3e880 | 2011-07-11 23:38:23 +0000 | [diff] [blame] | 222 | process = target.LaunchSimple(None, None, os.getcwd()) |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 223 | |
| Johnny Chen | 5a0bee7 | 2011-06-15 22:14:12 +0000 | [diff] [blame] | 224 | self.assertTrue(process, PROCESS_IS_VALID) |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 225 | |
| 226 | # The stop reason of the thread should be breakpoint. |
| Johnny Chen | 5a0bee7 | 2011-06-15 22:14:12 +0000 | [diff] [blame] | 227 | thread = process.GetThreadAtIndex(0) |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 228 | if thread.GetStopReason() != lldb.eStopReasonBreakpoint: |
| Johnny Chen | de90f1d | 2011-04-27 17:43:07 +0000 | [diff] [blame] | 229 | from lldbutil import stop_reason_to_str |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 230 | self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % |
| Johnny Chen | de90f1d | 2011-04-27 17:43:07 +0000 | [diff] [blame] | 231 | stop_reason_to_str(thread.GetStopReason())) |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 232 | |
| 233 | # Make sure we stopped at the first breakpoint. |
| 234 | |
| 235 | cur_frame = thread.GetFrameAtIndex(0) |
| 236 | |
| 237 | line_number = cur_frame.GetLineEntry().GetLine() |
| 238 | self.assertTrue (line_number == self.line, "Hit the first breakpoint.") |
| 239 | |
| 240 | my_var = cur_frame.FindVariable("my") |
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 241 | self.assertTrue(my_var, "Made a variable object for my") |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 242 | |
| 243 | str_var = cur_frame.FindVariable("str") |
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 244 | self.assertTrue(str_var, "Made a variable object for str") |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 245 | |
| 246 | # Now make sure that the my->str == str: |
| 247 | |
| 248 | my_str_var = my_var.GetChildMemberWithName("str") |
| Johnny Chen | 4ebd019 | 2011-05-24 18:22:45 +0000 | [diff] [blame] | 249 | self.assertTrue(my_str_var, "Found a str ivar in my") |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 250 | |
| Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 251 | str_value = int(str_var.GetValue(), 0) |
| 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 | my_str_value = int(my_str_var.GetValue(), 0) |
| Jim Ingham | 5949cfe | 2010-12-15 20:47:34 +0000 | [diff] [blame] | 254 | |
| 255 | self.assertTrue(str_value == my_str_value, "Got the correct value for my->str") |
| 256 | |
| Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 257 | if __name__ == '__main__': |
| 258 | import atexit |
| 259 | lldb.SBDebugger.Initialize() |
| 260 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 261 | unittest2.main() |