Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb data formatter subsystem. |
| 3 | """ |
| 4 | |
Zachary Turner | 35d017f | 2015-10-23 17:04:29 +0000 | [diff] [blame^] | 5 | from __future__ import print_function |
| 6 | |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame] | 7 | import lldb_shared |
| 8 | |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 9 | import os, time |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 10 | import lldb |
| 11 | from lldbtest import * |
| 12 | import datetime |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 13 | import lldbutil |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 14 | |
Enrico Granata | 54ed7e1 | 2015-08-25 23:55:10 +0000 | [diff] [blame] | 15 | class NSArraySyntheticTestCase(TestBase): |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 16 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 17 | mydir = TestBase.compute_mydir(__file__) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 18 | |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 19 | def setUp(self): |
| 20 | # Call super's setUp(). |
| 21 | TestBase.setUp(self) |
| 22 | # Find the line number to break at. |
| 23 | self.line = line_number('main.m', '// Set break point at this line.') |
| 24 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 25 | @skipUnlessDarwin |
| 26 | def test_rdar11086338_with_run_command(self): |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 27 | """Test that NSArray reports its synthetic children properly.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 28 | self.build() |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 29 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 30 | |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 31 | lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 32 | |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 33 | self.runCmd("run", RUN_SUCCEEDED) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 34 | |
| 35 | # The stop reason of the thread should be breakpoint. |
| 36 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 37 | substrs = ['stopped', |
| 38 | 'stop reason = breakpoint']) |
| 39 | |
| 40 | # This is the function to remove the custom formats in order to have a |
| 41 | # clean slate for the next test case. |
| 42 | def cleanup(): |
| 43 | self.runCmd('type format clear', check=False) |
| 44 | self.runCmd('type summary clear', check=False) |
| 45 | self.runCmd('type synth clear', check=False) |
| 46 | |
| 47 | # Execute the cleanup function during test case tear down. |
| 48 | self.addTearDownHook(cleanup) |
| 49 | |
| 50 | # Now check that we are displaying Cocoa classes correctly |
| 51 | self.expect('frame variable arr', |
Enrico Granata | 675f49b | 2015-10-07 18:36:53 +0000 | [diff] [blame] | 52 | substrs = ['@"6 elements"']) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 53 | self.expect('frame variable other_arr', |
Enrico Granata | 675f49b | 2015-10-07 18:36:53 +0000 | [diff] [blame] | 54 | substrs = ['@"4 elements"']) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 55 | self.expect('frame variable arr --ptr-depth 1', |
Enrico Granata | 675f49b | 2015-10-07 18:36:53 +0000 | [diff] [blame] | 56 | substrs = ['@"6 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x']) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 57 | self.expect('frame variable other_arr --ptr-depth 1', |
Enrico Granata | 675f49b | 2015-10-07 18:36:53 +0000 | [diff] [blame] | 58 | substrs = ['@"4 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x']) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 59 | self.expect('frame variable arr --ptr-depth 1 -d no-run-target', |
Enrico Granata | 675f49b | 2015-10-07 18:36:53 +0000 | [diff] [blame] | 60 | substrs = ['@"6 elements"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 61 | self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target', |
Enrico Granata | 675f49b | 2015-10-07 18:36:53 +0000 | [diff] [blame] | 62 | substrs = ['@"4 elements"','(int)5','@"a string"','@"6 elements"']) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 63 | self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target', |
Enrico Granata | 675f49b | 2015-10-07 18:36:53 +0000 | [diff] [blame] | 64 | substrs = ['@"4 elements"','@"6 elements" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 65 | |
Enrico Granata | 4481816 | 2012-10-24 01:23:57 +0000 | [diff] [blame] | 66 | self.assertTrue(self.frame().FindVariable("arr").MightHaveChildren(), "arr says it does not have children!") |
| 67 | self.assertTrue(self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!") |