Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb data formatter subsystem. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbtest import * |
| 9 | import datetime |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 10 | import lldbutil |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 11 | |
Enrico Granata | 54ed7e1 | 2015-08-25 23:55:10 +0000 | [diff] [blame] | 12 | class NSArraySyntheticTestCase(TestBase): |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 13 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 14 | mydir = TestBase.compute_mydir(__file__) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 15 | |
Robert Flack | 13c7ad9 | 2015-03-30 14:12:17 +0000 | [diff] [blame] | 16 | @skipUnlessDarwin |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 17 | @dsym_test |
| 18 | def test_rdar11086338_with_dsym_and_run_command(self): |
| 19 | """Test that NSArray reports its synthetic children properly.""" |
| 20 | self.buildDsym() |
| 21 | self.rdar11086338_tester() |
| 22 | |
Robert Flack | 13c7ad9 | 2015-03-30 14:12:17 +0000 | [diff] [blame] | 23 | @skipUnlessDarwin |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 24 | @dwarf_test |
| 25 | def test_rdar11086338_with_dwarf_and_run_command(self): |
| 26 | """Test that NSArray reports its synthetic children properly.""" |
| 27 | self.buildDwarf() |
| 28 | self.rdar11086338_tester() |
| 29 | |
| 30 | def setUp(self): |
| 31 | # Call super's setUp(). |
| 32 | TestBase.setUp(self) |
| 33 | # Find the line number to break at. |
| 34 | self.line = line_number('main.m', '// Set break point at this line.') |
| 35 | |
| 36 | def rdar11086338_tester(self): |
| 37 | """Test that NSArray reports its synthetic children properly.""" |
| 38 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 39 | |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 40 | 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] | 41 | |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 42 | self.runCmd("run", RUN_SUCCEEDED) |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 43 | |
| 44 | # The stop reason of the thread should be breakpoint. |
| 45 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 46 | substrs = ['stopped', |
| 47 | 'stop reason = breakpoint']) |
| 48 | |
| 49 | # This is the function to remove the custom formats in order to have a |
| 50 | # clean slate for the next test case. |
| 51 | def cleanup(): |
| 52 | self.runCmd('type format clear', check=False) |
| 53 | self.runCmd('type summary clear', check=False) |
| 54 | self.runCmd('type synth clear', check=False) |
| 55 | |
| 56 | # Execute the cleanup function during test case tear down. |
| 57 | self.addTearDownHook(cleanup) |
| 58 | |
| 59 | # Now check that we are displaying Cocoa classes correctly |
| 60 | self.expect('frame variable arr', |
| 61 | substrs = ['@"6 objects"']) |
| 62 | self.expect('frame variable other_arr', |
| 63 | substrs = ['@"4 objects"']) |
| 64 | self.expect('frame variable arr --ptr-depth 1', |
| 65 | substrs = ['@"6 objects"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x']) |
| 66 | self.expect('frame variable other_arr --ptr-depth 1', |
| 67 | substrs = ['@"4 objects"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x']) |
| 68 | self.expect('frame variable arr --ptr-depth 1 -d no-run-target', |
| 69 | substrs = ['@"6 objects"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) |
| 70 | self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target', |
| 71 | substrs = ['@"4 objects"','(int)5','@"a string"','@"6 objects"']) |
| 72 | self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target', |
| 73 | substrs = ['@"4 objects"','@"6 objects" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) |
| 74 | |
Enrico Granata | 4481816 | 2012-10-24 01:23:57 +0000 | [diff] [blame] | 75 | self.assertTrue(self.frame().FindVariable("arr").MightHaveChildren(), "arr says it does not have children!") |
| 76 | self.assertTrue(self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!") |
| 77 | |
Enrico Granata | b2698cd | 2012-09-13 18:27:09 +0000 | [diff] [blame] | 78 | |
| 79 | if __name__ == '__main__': |
| 80 | import atexit |
| 81 | lldb.SBDebugger.Initialize() |
| 82 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 83 | unittest2.main() |