Enrico Granata | 7932844 | 2013-04-19 17:24:11 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb data formatter subsystem. |
| 3 | """ |
| 4 | |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame] | 5 | import lldb_shared |
| 6 | |
Enrico Granata | 7932844 | 2013-04-19 17:24:11 +0000 | [diff] [blame] | 7 | import os, time |
Enrico Granata | 7932844 | 2013-04-19 17:24:11 +0000 | [diff] [blame] | 8 | import lldb |
| 9 | from lldbtest import * |
| 10 | import lldbutil |
| 11 | |
| 12 | class ValueObjectRecursionTestCase(TestBase): |
| 13 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 14 | mydir = TestBase.compute_mydir(__file__) |
Enrico Granata | 7932844 | 2013-04-19 17:24:11 +0000 | [diff] [blame] | 15 | |
Enrico Granata | 7932844 | 2013-04-19 17:24:11 +0000 | [diff] [blame] | 16 | def setUp(self): |
| 17 | # Call super's setUp(). |
| 18 | TestBase.setUp(self) |
| 19 | # Find the line number to break at. |
| 20 | self.line = line_number('main.cpp', '// Set break point at this line.') |
| 21 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 22 | def test_with_run_command(self): |
| 23 | """Test that deeply nested ValueObjects still work.""" |
| 24 | self.build() |
Enrico Granata | 7932844 | 2013-04-19 17:24:11 +0000 | [diff] [blame] | 25 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 26 | |
| 27 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) |
| 28 | |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 29 | self.runCmd("run", RUN_SUCCEEDED) |
Enrico Granata | 7932844 | 2013-04-19 17:24:11 +0000 | [diff] [blame] | 30 | |
| 31 | # The stop reason of the thread should be breakpoint. |
| 32 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 33 | substrs = ['stopped', |
| 34 | 'stop reason = breakpoint']) |
| 35 | |
| 36 | # This is the function to remove the custom formats in order to have a |
| 37 | # clean slate for the next test case. |
| 38 | def cleanup(): |
| 39 | self.runCmd('type format clear', check=False) |
| 40 | self.runCmd('type summary clear', check=False) |
| 41 | |
| 42 | # Execute the cleanup function during test case tear down. |
| 43 | self.addTearDownHook(cleanup) |
| 44 | |
| 45 | root = self.frame().FindVariable("root") |
| 46 | child = root.GetChildAtIndex(1) |
| 47 | if self.TraceOn(): |
| 48 | print root |
| 49 | print child |
| 50 | for i in range(0,24500): |
| 51 | child = child.GetChildAtIndex(1) |
| 52 | if self.TraceOn(): |
| 53 | print child |
| 54 | self.assertTrue(child.IsValid(),"could not retrieve the deep ValueObject") |
| 55 | self.assertTrue(child.GetChildAtIndex(0).IsValid(),"the deep ValueObject has no value") |
| 56 | self.assertTrue(child.GetChildAtIndex(0).GetValueAsUnsigned() != 0,"the deep ValueObject has a zero value") |
| 57 | self.assertTrue(child.GetChildAtIndex(1).GetValueAsUnsigned() != 0, "the deep ValueObject has no next") |