62bd058666b677b85959b77650c940747dae64bf
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.lldbtest import *
9 import lldbsuite.test.lldbutil as lldbutil
10
11
12 class LanguageCategoryUpdatesTestCase(TestBase):
13
14     mydir = TestBase.compute_mydir(__file__)
15
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', '// break here')
21
22     def test_with_run_command(self):
23         """Test that LLDB correctly cleans caches when language categories change."""
24         # This is the function to remove the custom formats in order to have a
25         # clean slate for the next test case.
26         def cleanup():
27             if hasattr(
28                     self,
29                     'type_category') and hasattr(
30                     self,
31                     'type_specifier'):
32                 self.type_category.DeleteTypeSummary(self.type_specifier)
33
34         # Execute the cleanup function during test case tear down.
35         self.addTearDownHook(cleanup)
36
37         self.build()
38         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
39
40         lldbutil.run_break_set_by_file_and_line(
41             self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
42
43         self.runCmd("run", RUN_SUCCEEDED)
44
45         # The stop reason of the thread should be breakpoint.
46         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
47                     substrs=['stopped',
48                              'stop reason = breakpoint'])
49
50         self.expect(
51             "frame variable",
52             substrs=[
53                 '(S)',
54                 'object',
55                 '123',
56                 '456'],
57             matching=True)
58
59         self.type_category = self.dbg.GetCategory(
60             lldb.eLanguageTypeC_plus_plus)
61         type_summary = lldb.SBTypeSummary.CreateWithSummaryString(
62             "this is an object of type S")
63         self.type_specifier = lldb.SBTypeNameSpecifier('S')
64         self.type_category.AddTypeSummary(self.type_specifier, type_summary)
65
66         self.expect(
67             "frame variable",
68             substrs=['this is an object of type S'],
69             matching=True)
70
71         self.type_category.DeleteTypeSummary(self.type_specifier)
72         self.expect(
73             "frame variable",
74             substrs=['this is an object of type S'],
75             matching=False)
76         self.expect(
77             "frame variable",
78             substrs=[
79                 '(S)',
80                 'object',
81                 '123',
82                 '456'],
83             matching=True)