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
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
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits