]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py
Vendor import of lldb trunk r338150:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / hexcaps / TestDataFormatterHexCaps.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 DataFormatterHexCapsTestCase(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', '// Set break point at this line.')
24
25     def test_with_run_command(self):
26         """Test that that file and class static variables display correctly."""
27         self.build()
28         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
29
30         lldbutil.run_break_set_by_file_and_line(
31             self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
32
33         self.runCmd("run", RUN_SUCCEEDED)
34
35         # The stop reason of the thread should be breakpoint.
36         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
37                     substrs=['stopped',
38                              'stop reason = breakpoint'])
39
40         # This is the function to remove the custom formats in order to have a
41         # clean slate for the next test case.
42         def cleanup():
43             self.runCmd('type format delete hex', check=False)
44             self.runCmd('type summary clear', check=False)
45
46         # Execute the cleanup function during test case tear down.
47         self.addTearDownHook(cleanup)
48
49         self.runCmd("type format add -f uppercase int")
50
51         self.expect('frame variable mine',
52                     substrs=['mine = ',
53                              'first = 0x001122AA', 'second = 0x1122BB44'])
54
55         self.runCmd("type format add -f hex int")
56
57         self.expect('frame variable mine',
58                     substrs=['mine = ',
59                              'first = 0x001122aa', 'second = 0x1122bb44'])
60
61         self.runCmd("type format delete int")
62
63         self.runCmd(
64             "type summary add -s \"${var.first%X} and ${var.second%x}\" foo")
65
66         self.expect('frame variable mine',
67                     substrs=['(foo) mine = 0x001122AA and 0x1122bb44'])
68
69         self.runCmd(
70             "type summary add -s \"${var.first%X} and ${var.second%X}\" foo")
71         self.runCmd("next")
72         self.runCmd("next")
73         self.expect('frame variable mine',
74                     substrs=['(foo) mine = 0xAABBCCDD and 0x1122BB44'])
75
76         self.runCmd(
77             "type summary add -s \"${var.first%x} and ${var.second%X}\" foo")
78         self.expect('frame variable mine',
79                     substrs=['(foo) mine = 0xaabbccdd and 0x1122BB44'])
80         self.runCmd("next")
81         self.runCmd("next")
82         self.runCmd(
83             "type summary add -s \"${var.first%x} and ${var.second%x}\" foo")
84         self.expect('frame variable mine',
85                     substrs=['(foo) mine = 0xaabbccdd and 0xff00ff00'])
86         self.runCmd(
87             "type summary add -s \"${var.first%X} and ${var.second%X}\" foo")
88         self.expect('frame variable mine',
89                     substrs=['(foo) mine = 0xAABBCCDD and 0xFF00FF00'])