]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / register / intel_xtended_registers / mpx_bound_violation / TestBoundViolation.py
1 """
2 Test the Intel(R) MPX bound violation signal.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import sys
10 import time
11 import re
12 import lldb
13 from lldbsuite.test.decorators import *
14 from lldbsuite.test.lldbtest import *
15 from lldbsuite.test import lldbutil
16
17
18 class RegisterCommandsTestCase(TestBase):
19
20     mydir = TestBase.compute_mydir(__file__)
21
22     @skipIf(compiler="clang")
23     @skipIf(oslist=no_match(['linux']))
24     @skipIf(archs=no_match(['i386', 'x86_64']))
25     @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports Intel(R) MPX.
26     def test_mpx_boundary_violation(self):
27         """Test Intel(R) MPX bound violation signal."""
28         self.build()
29         self.mpx_boundary_violation()
30
31     def mpx_boundary_violation(self):
32         exe = os.path.join(os.getcwd(), "a.out")
33         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
34
35         self.runCmd("run", RUN_SUCCEEDED)
36
37         target = self.dbg.GetSelectedTarget()
38         process = target.GetProcess()
39
40         if (process.GetState() == lldb.eStateExited):
41             self.skipTest("Intel(R) MPX is not supported.")
42
43         if (process.GetState() == lldb.eStateStopped):
44             self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL,
45                         substrs = ['stop reason = signal SIGSEGV: upper bound violation',
46                                    'fault address:', 'lower bound:', 'upper bound:'])
47
48         self.runCmd("continue")
49
50         if (process.GetState() == lldb.eStateStopped):
51             self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL,
52                         substrs = ['stop reason = signal SIGSEGV: lower bound violation',
53                                    'fault address:', 'lower bound:', 'upper bound:'])
54
55         self.runCmd("continue")
56         self.assertTrue(process.GetState() == lldb.eStateExited,
57                         PROCESS_EXITED)