5644855868b3a56d1e2c82eee9767779ebf040f8
[openbsd] /
1 """
2 Test the Intel(R) MPX registers.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class RegisterCommandsTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     @skipIf(compiler="clang")
18     @skipIf(oslist=no_match(['linux']))
19     @skipIf(archs=no_match(['i386', 'x86_64']))
20     @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports Intel(R) MPX.
21     def test_mpx_registers_with_example_code(self):
22         """Test Intel(R) MPX registers with example code."""
23         self.build()
24         self.mpx_registers_with_example_code()
25
26     def mpx_registers_with_example_code(self):
27         """Test Intel(R) MPX registers after running example code."""
28         self.line = line_number('main.cpp', '// Set a break point here.')
29
30         exe = self.getBuildArtifact("a.out")
31         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
32
33         lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line, num_expected_locations=1)
34         self.runCmd("run", RUN_SUCCEEDED)
35
36         target = self.dbg.GetSelectedTarget()
37         process = target.GetProcess()
38
39         if (process.GetState() == lldb.eStateExited):
40             self.skipTest("Intel(R) MPX is not supported.")
41         else:
42             self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
43                         substrs = ["stop reason = breakpoint 1."])
44
45         if self.getArchitecture() == 'x86_64':
46             self.expect("register read -s 3",
47                         substrs = ['bnd0 = {0x0000000000000010 0xffffffffffffffe6}',
48                                    'bnd1 = {0x0000000000000020 0xffffffffffffffd6}',
49                                    'bnd2 = {0x0000000000000030 0xffffffffffffffc6}',
50                                    'bnd3 = {0x0000000000000040 0xffffffffffffffb6}',
51                                    'bndcfgu = {0x01 0x80 0xb5 0x76 0xff 0x7f 0x00 0x00}',
52                                    'bndstatus = {0x02 0x80 0xb5 0x76 0xff 0x7f 0x00 0x00}'])
53         if self.getArchitecture() == 'i386':
54             self.expect("register read -s 3",
55                         substrs = ['bnd0 = {0x0000000000000010 0x00000000ffffffe6}',
56                                    'bnd1 = {0x0000000000000020 0x00000000ffffffd6}',
57                                    'bnd2 = {0x0000000000000030 0x00000000ffffffc6}',
58                                    'bnd3 = {0x0000000000000040 0x00000000ffffffb6}',
59                                    'bndcfgu = {0x01 0xd0 0x7d 0xf7 0x00 0x00 0x00 0x00}',
60                                    'bndstatus = {0x02 0xd0 0x7d 0xf7 0x00 0x00 0x00 0x00}'])
61