From 5b12e62b64bed107b90bf64a5c1e6ff650f9722f Mon Sep 17 00:00:00 2001 From: Jakob Kummerow Date: Thu, 23 Jun 2022 16:14:38 +0200 Subject: [PATCH] [tools] grokdump: Fix objdump detection for Python3 Follow-up to 032dfb827aa3f07cb6b2a0f1eebffc06de673675. No-Try: true Change-Id: Ia12343a7ce9e1b865da4fbf562bdd9169892932c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3721816 Commit-Queue: Jakob Kummerow Auto-Submit: Jakob Kummerow Reviewed-by: Camillo Bruni Cr-Commit-Position: refs/heads/main@{#81332} --- tools/grokdump.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tools/grokdump.py b/tools/grokdump.py index 1e10b36f8b..ff7a15c22c 100755 --- a/tools/grokdump.py +++ b/tools/grokdump.py @@ -724,29 +724,25 @@ class MinidumpReader(object): disasm.OBJDUMP_BIN = objdump_bin def _FindThirdPartyObjdump(self): - # Try to find the platform specific objdump - third_party_dir = os.path.join( - os.path.dirname(os.path.dirname(__file__)), 'third_party') - objdumps = [] - for root, dirs, files in os.walk(third_party_dir): - for file in files: - if file.endswith("objdump"): - objdumps.append(os.path.join(root, file)) + # Try to find the platform specific objdump. if self.arch == MD_CPU_ARCHITECTURE_ARM: platform_filter = 'arm-linux' elif self.arch == MD_CPU_ARCHITECTURE_ARM64: platform_filter = 'aarch64' else: - # use default otherwise + # Use default otherwise. return None print(("# Looking for platform specific (%s) objdump in " "third_party directory.") % platform_filter) - objdumps = list(filter(lambda file: platform_filter in file >= 0, objdumps)) - if len(objdumps) == 0: - print("# Could not find platform specific objdump in third_party.") - print("# Make sure you installed the correct SDK.") - return None - return objdumps[0] + third_party_dir = os.path.join( + os.path.dirname(os.path.dirname(__file__)), 'third_party') + for root, dirs, files in os.walk(third_party_dir): + for file in files: + if file.endswith("objdump") and platform_filter in file: + return os.path.join(root, file) + print("# Could not find platform specific objdump in third_party.") + print("# Make sure you installed the correct SDK.") + return None def ContextDescriptor(self): if self.arch == MD_CPU_ARCHITECTURE_X86: