[Lldb-commits] [PATCH] D97284: [lldb][AArch64] Add MTE CPU feature test predicate

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 23 06:34:44 PST 2021


DavidSpickett created this revision.
Herald added subscribers: danielkiss, kristof.beyls.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Change the logic slightly so that the feature can
be anywhere in the list.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97284

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1269,7 +1269,7 @@
             return True
         return False
 
-    def isAArch64SVE(self):
+    def hasLinuxCPUInfoFeature(self, feature):
         triple = self.dbg.GetSelectedPlatform().GetTriple()
 
         # TODO other platforms, please implement this function
@@ -1283,14 +1283,18 @@
         else:
             cpuinfo_path = "/proc/cpuinfo"
 
-        try:
-            f = open(cpuinfo_path, 'r')
-            cpuinfo = f.read()
-            f.close()
-        except:
+        with open(cpuinfo_path, 'r') as f:
+            for line in f.readlines():
+                if line.startswith("Features"):
+                    features = line.split(':')[1].split()
+                    return feature in features
             return False
 
-        return " sve " in cpuinfo
+    def isAArch64SVE(self):
+        return self.hasLinuxCPUInfoFeature("sve")
+
+    def isAArch64MTE(self):
+        return self.hasLinuxCPUInfoFeature("mte")
 
     def hasLinuxVmFlags(self):
         """ Check that the target machine has "VmFlags" lines in


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97284.325770.patch
Type: text/x-patch
Size: 1279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210223/21dad6af/attachment.bin>


More information about the lldb-commits mailing list