blob: fa9000410e0bbd4fffd0ff5af4891210ea58f329 [file] [log] [blame]
Enrico Granata79328442013-04-19 17:24:11 +00001"""
2Test lldb data formatter subsystem.
3"""
4
Zachary Turner77db4a82015-10-22 20:06:20 +00005import lldb_shared
6
Enrico Granata79328442013-04-19 17:24:11 +00007import os, time
Enrico Granata79328442013-04-19 17:24:11 +00008import lldb
9from lldbtest import *
10import lldbutil
11
12class ValueObjectRecursionTestCase(TestBase):
13
Greg Clayton4570d3e2013-12-10 23:19:29 +000014 mydir = TestBase.compute_mydir(__file__)
Enrico Granata79328442013-04-19 17:24:11 +000015
Enrico Granata79328442013-04-19 17:24:11 +000016 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 Berghammerc8fd1302015-09-30 10:12:40 +000022 def test_with_run_command(self):
23 """Test that deeply nested ValueObjects still work."""
24 self.build()
Enrico Granata79328442013-04-19 17:24:11 +000025 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 Callanan05834cd2015-07-01 23:56:30 +000029 self.runCmd("run", RUN_SUCCEEDED)
Enrico Granata79328442013-04-19 17:24:11 +000030
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")