[Lldb-commits] [lldb] r232137 - Don't require AVX registers if the target CPU doesn't have them

Vince Harron vince at nethacker.com
Thu Mar 12 20:43:46 PDT 2015


Author: vharron
Date: Thu Mar 12 22:43:46 2015
New Revision: 232137

URL: http://llvm.org/viewvc/llvm-project?rev=232137&view=rev
Log:
Don't require AVX registers if the target CPU doesn't have them

TestLldbGdbServer was failing because it always assumed AVX is available on
x86_64 Linux. This patch checks the target before asserting that AVX
registers are available.


Modified:
    lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py

Modified: lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py?rev=232137&r1=232136&r2=232137&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py (original)
+++ lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py Thu Mar 12 22:43:46 2015
@@ -474,7 +474,27 @@ class LldbGdbServerTestCase(gdbremote_te
         self.buildDwarf()
         self.qRegisterInfo_contains_at_least_one_register_set()
 
-    def qRegisterInfo_contains_avx_registers_on_linux_x86_64(self):
+    def targetHasAVX(self):
+        # TODO we should be asking for targetGetSystem() 
+        # instead of platform.system()
+        # TODO other platforms, please implement this function
+        if platform.system() in ['Linux']:
+            return True
+
+        # Need to do something different for non-Linux/Android targets
+        if lldb.remote_platform:
+            self.runCmd('platform get-file "/proc/cpuinfo" "cpuinfo"')
+            cpuinfo_path = "cpuinfo"
+            self.addTearDownHook(lambda: os.unlink("cpuinfo"))
+        else:
+            cpuinfo_path = "/proc/cpuinfo"
+
+        f = open(cpuinfo_path, 'r')
+        cpuinfo = f.read()
+        f.close()
+        return " avx " in cpuinfo
+
+    def qRegisterInfo_contains_avx_registers(self):
         launch_args = self.install_and_create_launch_args()
 
         server = self.connect_to_debug_monitor()
@@ -494,18 +514,14 @@ class LldbGdbServerTestCase(gdbremote_te
 
         # Collect all generics found.
         register_sets = { reg_info['set']:1 for reg_info in reg_infos if 'set' in reg_info }
-        self.assertTrue("Advanced Vector Extensions" in register_sets)
+        self.assertEquals(self.targetHasAVX(), "Advanced Vector Extensions" in register_sets)
 
     @llgs_test
     @dwarf_test
-    def test_qRegisterInfo_contains_avx_registers_on_linux_x86_64_llgs_dwarf(self):
-        # Skip this test if not Linux x86_64.
-        if platform.system() != "Linux" or platform.processor() != "x86_64":
-            self.skipTest("linux x86_64 test")
-
+    def test_qRegisterInfo_contains_avx_registers_llgs_dwarf(self):
         self.init_llgs_test()
         self.buildDwarf()
-        self.qRegisterInfo_contains_avx_registers_on_linux_x86_64()
+        self.qRegisterInfo_contains_avx_registers()
 
     def qThreadInfo_contains_thread(self):
         procs = self.prep_debug_monitor_and_inferior()





More information about the lldb-commits mailing list