DavidSpickett updated this revision to Diff 327061. DavidSpickett added a comment.
Rename to be AArch64 specific. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97284/new/ 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 hasAArch64LinuxCPUFeature(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.hasAArch64LinuxCPUFeature("sve") + + def isAArch64MTE(self): + return self.hasAArch64LinuxCPUFeature("mte") def hasLinuxVmFlags(self): """ Check that the target machine has "VmFlags" lines in
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 hasAArch64LinuxCPUFeature(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.hasAArch64LinuxCPUFeature("sve") + + def isAArch64MTE(self): + return self.hasAArch64LinuxCPUFeature("mte") def hasLinuxVmFlags(self): """ Check that the target machine has "VmFlags" lines in
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits