9a812a146b632653502c490919c65c28daad21fc
[openbsd] /
1 """
2 Test the Intel(R) MPX bound violation signal.
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_boundary_violation(self):
22         """Test Intel(R) MPX bound violation signal."""
23         self.build()
24         self.mpx_boundary_violation()
25
26     def mpx_boundary_violation(self):
27         exe = self.getBuildArtifact("a.out")
28         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
29
30         self.runCmd("run", RUN_SUCCEEDED)
31
32         target = self.dbg.GetSelectedTarget()
33         process = target.GetProcess()
34
35         if (process.GetState() == lldb.eStateExited):
36             self.skipTest("Intel(R) MPX is not supported.")
37
38         if (process.GetState() == lldb.eStateStopped):
39             self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL,
40                         substrs = ['stop reason = signal SIGSEGV: upper bound violation',
41                                    'fault address:', 'lower bound:', 'upper bound:'])
42
43         self.runCmd("continue")
44
45         if (process.GetState() == lldb.eStateStopped):
46             self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL,
47                         substrs = ['stop reason = signal SIGSEGV: lower bound violation',
48                                    'fault address:', 'lower bound:', 'upper bound:'])
49
50         self.runCmd("continue")
51         self.assertTrue(process.GetState() == lldb.eStateExited,
52                         PROCESS_EXITED)