blob: a0154a4525152e4dce851991d3c83a95ddca7756 [file] [log] [blame]
Enrico Granatab2698cd2012-09-13 18:27:09 +00001"""
2Test lldb data formatter subsystem.
3"""
4
Zachary Turner35d017f2015-10-23 17:04:29 +00005from __future__ import print_function
6
Zachary Turner77db4a82015-10-22 20:06:20 +00007import lldb_shared
8
Enrico Granatab2698cd2012-09-13 18:27:09 +00009import os, time
Enrico Granatab2698cd2012-09-13 18:27:09 +000010import lldb
11from lldbtest import *
12import datetime
Jim Ingham63dfc722012-09-22 00:05:11 +000013import lldbutil
Enrico Granatab2698cd2012-09-13 18:27:09 +000014
Enrico Granata54ed7e12015-08-25 23:55:10 +000015class NSArraySyntheticTestCase(TestBase):
Enrico Granatab2698cd2012-09-13 18:27:09 +000016
Greg Clayton4570d3e2013-12-10 23:19:29 +000017 mydir = TestBase.compute_mydir(__file__)
Enrico Granatab2698cd2012-09-13 18:27:09 +000018
Enrico Granatab2698cd2012-09-13 18:27:09 +000019 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 Berghammerc8fd1302015-09-30 10:12:40 +000025 @skipUnlessDarwin
26 def test_rdar11086338_with_run_command(self):
Enrico Granatab2698cd2012-09-13 18:27:09 +000027 """Test that NSArray reports its synthetic children properly."""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000028 self.build()
Enrico Granatab2698cd2012-09-13 18:27:09 +000029 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
30
Jim Ingham63dfc722012-09-22 00:05:11 +000031 lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
Enrico Granatab2698cd2012-09-13 18:27:09 +000032
Sean Callanan05834cd2015-07-01 23:56:30 +000033 self.runCmd("run", RUN_SUCCEEDED)
Enrico Granatab2698cd2012-09-13 18:27:09 +000034
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 Granata675f49b2015-10-07 18:36:53 +000052 substrs = ['@"6 elements"'])
Enrico Granatab2698cd2012-09-13 18:27:09 +000053 self.expect('frame variable other_arr',
Enrico Granata675f49b2015-10-07 18:36:53 +000054 substrs = ['@"4 elements"'])
Enrico Granatab2698cd2012-09-13 18:27:09 +000055 self.expect('frame variable arr --ptr-depth 1',
Enrico Granata675f49b2015-10-07 18:36:53 +000056 substrs = ['@"6 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x'])
Enrico Granatab2698cd2012-09-13 18:27:09 +000057 self.expect('frame variable other_arr --ptr-depth 1',
Enrico Granata675f49b2015-10-07 18:36:53 +000058 substrs = ['@"4 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x'])
Enrico Granatab2698cd2012-09-13 18:27:09 +000059 self.expect('frame variable arr --ptr-depth 1 -d no-run-target',
Enrico Granata675f49b2015-10-07 18:36:53 +000060 substrs = ['@"6 elements"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
Enrico Granatab2698cd2012-09-13 18:27:09 +000061 self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target',
Enrico Granata675f49b2015-10-07 18:36:53 +000062 substrs = ['@"4 elements"','(int)5','@"a string"','@"6 elements"'])
Enrico Granatab2698cd2012-09-13 18:27:09 +000063 self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target',
Enrico Granata675f49b2015-10-07 18:36:53 +000064 substrs = ['@"4 elements"','@"6 elements" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
Enrico Granatab2698cd2012-09-13 18:27:09 +000065
Enrico Granata44818162012-10-24 01:23:57 +000066 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!")