blob: 8774ff7bd9f663f553fcf087e10f8b66ea635ac9 [file] [log] [blame]
Enrico Granata79328442013-04-19 17:24:11 +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 Granata79328442013-04-19 17:24:11 +00009import os, time
Enrico Granata79328442013-04-19 17:24:11 +000010import lldb
11from lldbtest import *
12import lldbutil
13
14class ValueObjectRecursionTestCase(TestBase):
15
Greg Clayton4570d3e2013-12-10 23:19:29 +000016 mydir = TestBase.compute_mydir(__file__)
Enrico Granata79328442013-04-19 17:24:11 +000017
Enrico Granata79328442013-04-19 17:24:11 +000018 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 Berghammerc8fd1302015-09-30 10:12:40 +000024 def test_with_run_command(self):
25 """Test that deeply nested ValueObjects still work."""
26 self.build()
Enrico Granata79328442013-04-19 17:24:11 +000027 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 Callanan05834cd2015-07-01 23:56:30 +000031 self.runCmd("run", RUN_SUCCEEDED)
Enrico Granata79328442013-04-19 17:24:11 +000032
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 Turner35d017f2015-10-23 17:04:29 +000050 print(root)
51 print(child)
Enrico Granata79c4ee42015-10-24 00:15:57 +000052 for i in range(0,15000):
Enrico Granata79328442013-04-19 17:24:11 +000053 child = child.GetChildAtIndex(1)
54 if self.TraceOn():
Zachary Turner35d017f2015-10-23 17:04:29 +000055 print(child)
Enrico Granata79328442013-04-19 17:24:11 +000056 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")