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