Author: valentinagiusti
Date: Thu Oct  6 10:49:10 2016
New Revision: 283461

URL: http://llvm.org/viewvc/llvm-project?rev=283461&view=rev
Log:
Improve test for Intel(R) MPX registers.

Summary:
Let the inferior test code determine if CPU and kernel support Intel(R)
MPX and cleanup test script.

Differential Revision: https://reviews.llvm.org/D25328

Modified:
    
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
    
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py?rev=283461&r1=283460&r2=283461&view=diff
==============================================================================
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
 Thu Oct  6 10:49:10 2016
@@ -1,5 +1,5 @@
 """
-Test the MPX registers.
+Test the Intel(R) MPX registers.
 """
 
 from __future__ import print_function
@@ -21,23 +21,18 @@ class RegisterCommandsTestCase(TestBase)
 
     def setUp(self):
         TestBase.setUp(self)
-        self.has_teardown = False
-
-    def tearDown(self):
-        self.dbg.GetSelectedTarget().GetProcess().Destroy()
-        TestBase.tearDown(self)
 
     @skipIf(compiler="clang")
-    @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) 
#GCC version >= 5 supports MPX.
     @skipIf(oslist=no_match(['linux']))
     @skipIf(archs=no_match(['i386', 'x86_64']))
+    @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) 
#GCC version >= 5 supports Intel(R) MPX.
     def test_mpx_registers_with_example_code(self):
-        """Test MPX registers with example code."""
+        """Test Intel(R) MPX registers with example code."""
         self.build()
         self.mpx_registers_with_example_code()
 
     def mpx_registers_with_example_code(self):
-        """Test MPX registers after running example code."""
+        """Test Intel(R) MPX registers after running example code."""
         self.line = line_number('main.cpp', '// Set a break point here.')
 
         exe = os.path.join(os.getcwd(), "a.out")
@@ -50,7 +45,7 @@ class RegisterCommandsTestCase(TestBase)
         process = target.GetProcess()
 
         if (process.GetState() == lldb.eStateExited):
-            self.skipTest("HW doesn't support MPX feature.")
+            self.skipTest("Intel(R) MPX is not supported.")
         else:
             self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
                         substrs = ["stop reason = breakpoint 1."])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp?rev=283461&r1=283460&r2=283461&view=diff
==============================================================================
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp
 Thu Oct  6 10:49:10 2016
@@ -14,23 +14,11 @@
 int
 main(int argc, char const *argv[])
 {
-    unsigned int rax, rbx, rcx, rdx;
-
-    // Check if XSAVE is enabled.
-    if (!__get_cpuid(1, &rax, &rbx, &rcx, &rdx) || (rcx & bit_OSXSAVE) != 
bit_OSXSAVE)
-        return -1;
-
-    // Check if MPX is enabled.
-    if (__get_cpuid_max(0, NULL) > 7)
-    {
-        __cpuid_count(7, 0, rax, rbx, rcx, rdx);
-        if ((rbx & bit_MPX) != bit_MPX)
-            return -1;
-    }
-    else
+    // This call returns 0 only if the CPU and the kernel support Intel(R) MPX.
+    if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
         return -1;
 
-// Run MPX test code.
+// Run Intel(R) MPX test code.
 #if defined(__x86_64__)
     asm("mov $16, %rax\n\t"
         "mov $9, %rdx\n\t"


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to