]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / synthupdate / TestSyntheticFilterRecompute.py
1 """
2 Test lldb data formatter subsystem.
3 """
4
5 from __future__ import print_function
6
7
8 import datetime
9 import os
10 import time
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
15
16
17 class SyntheticFilterRecomputingTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     def setUp(self):
22         # Call super's setUp().
23         TestBase.setUp(self)
24         # Find the line number to break at.
25         self.line = line_number('main.m', '// Set break point at this line.')
26
27     @skipUnlessDarwin
28     def test_rdar12437442_with_run_command(self):
29         """Test that we update SBValues correctly as dynamic types change."""
30         self.build()
31         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
32
33         lldbutil.run_break_set_by_file_and_line(
34             self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
35
36         self.runCmd("run", RUN_SUCCEEDED)
37
38         # The stop reason of the thread should be breakpoint.
39         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
40                     substrs=['stopped',
41                              'stop reason = breakpoint'])
42
43         # This is the function to remove the custom formats in order to have a
44         # clean slate for the next test case.
45         def cleanup():
46             self.runCmd('type format clear', check=False)
47             self.runCmd('type summary clear', check=False)
48             self.runCmd('type synth clear', check=False)
49
50         # Execute the cleanup function during test case tear down.
51         self.addTearDownHook(cleanup)
52
53         # Now run the bulk of the test
54         id_x = self.dbg.GetSelectedTarget().GetProcess(
55         ).GetSelectedThread().GetSelectedFrame().FindVariable("x")
56         id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
57         id_x.SetPreferSyntheticValue(True)
58
59         if self.TraceOn():
60             self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x")
61
62         self.assertTrue(
63             id_x.GetSummary() == '@"5 elements"',
64             "array does not get correct summary")
65
66         self.runCmd("next")
67         self.runCmd("frame select 0")
68
69         id_x = self.dbg.GetSelectedTarget().GetProcess(
70         ).GetSelectedThread().GetSelectedFrame().FindVariable("x")
71         id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
72         id_x.SetPreferSyntheticValue(True)
73
74         if self.TraceOn():
75             self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x")
76
77         self.assertTrue(
78             id_x.GetNumChildren() == 7,
79             "dictionary does not have 7 children")
80         id_x.SetPreferSyntheticValue(False)
81         self.assertFalse(
82             id_x.GetNumChildren() == 7,
83             "dictionary still looks synthetic")
84         id_x.SetPreferSyntheticValue(True)
85         self.assertTrue(
86             id_x.GetSummary() == "7 key/value pairs",
87             "dictionary does not get correct summary")