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