diff options
author | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 07:33:03 +0000 |
---|---|---|
committer | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 07:33:03 +0000 |
commit | d902e4dcc8e60bbd462448b8e37c8bfa8986dfa7 (patch) | |
tree | 4b8f660d8185a3c7794097f76f861a090588c59e /tools | |
parent | ba5cd2efae8265144df973eda152251774930635 (diff) | |
download | chromium_src-d902e4dcc8e60bbd462448b8e37c8bfa8986dfa7.zip chromium_src-d902e4dcc8e60bbd462448b8e37c8bfa8986dfa7.tar.gz chromium_src-d902e4dcc8e60bbd462448b8e37c8bfa8986dfa7.tar.bz2 |
[Telemetry] Fix finding of minidump_stackwalk binary on mac.
The mac binary is in a subdirectory of the build directory, so it doesn't
work to simply take the dirname of the chrome executable. Instead, factor
out a FindSupportBinary() method that knows about the build directories.
We should use this for finding any other binaries like forwarder, md5sum, etc.
BUG=223572
Review URL: https://chromiumcodereview.appspot.com/23064005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217962 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
3 files changed, 24 insertions, 23 deletions
diff --git a/tools/telemetry/telemetry/core/chrome/desktop_browser_backend.py b/tools/telemetry/telemetry/core/chrome/desktop_browser_backend.py index 61644c1..7a154b9 100644 --- a/tools/telemetry/telemetry/core/chrome/desktop_browser_backend.py +++ b/tools/telemetry/telemetry/core/chrome/desktop_browser_backend.py @@ -149,9 +149,8 @@ class DesktopBrowserBackend(chrome_browser_backend.ChromeBrowserBackend): return '' def GetStackTrace(self): - executable_dir = os.path.dirname(self._executable) - stackwalk = os.path.join(executable_dir, 'minidump_stackwalk') - if not os.path.exists(stackwalk): + stackwalk = util.FindSupportBinary('minidump_stackwalk') + if not stackwalk: logging.warning('minidump_stackwalk binary not found. Must build it to ' 'symbolize crash dumps. Returning browser stdout.') return self.GetStandardOutput() @@ -169,17 +168,18 @@ class DesktopBrowserBackend(chrome_browser_backend.ChromeBrowserBackend): with open(minidump, 'wb') as outfile: outfile.write(''.join(infile.read().partition('MDMP')[1:])) - symbols = glob.glob(os.path.join(executable_dir, 'chrome.breakpad.*'))[0] + symbols = glob.glob(os.path.join(os.path.dirname(stackwalk), + 'chrome.breakpad.*')) if not symbols: logging.warning('No breakpad symbols found. Returning browser stdout.') return self.GetStandardOutput() symbols_path = os.path.join(self._tmp_minidump_dir, 'symbols') - with open(symbols, 'r') as f: + with open(symbols[0], 'r') as f: _, _, _, sha, binary = f.readline().split() symbol_path = os.path.join(symbols_path, binary, sha) os.makedirs(symbol_path) - shutil.copyfile(symbols, os.path.join(symbol_path, binary + '.sym')) + shutil.copyfile(symbols[0], os.path.join(symbol_path, binary + '.sym')) error = tempfile.NamedTemporaryFile('w', 0) return subprocess.Popen( diff --git a/tools/telemetry/telemetry/core/platform/desktop_platform_backend.py b/tools/telemetry/telemetry/core/platform/desktop_platform_backend.py index b71deab..e2bceaa 100644 --- a/tools/telemetry/telemetry/core/platform/desktop_platform_backend.py +++ b/tools/telemetry/telemetry/core/platform/desktop_platform_backend.py @@ -17,26 +17,10 @@ class DesktopPlatformBackend(platform_backend.PlatformBackend): def GetFlushUtilityName(self): return NotImplementedError() - def _FindNewestFlushUtility(self): - flush_command = None - flush_command_mtime = 0 - - chrome_root = util.GetChromiumSrcDir() - for build_dir, build_type in util.GetBuildDirectories(): - candidate = os.path.join(chrome_root, build_dir, build_type, - self.GetFlushUtilityName()) - if os.access(candidate, os.X_OK): - candidate_mtime = os.stat(candidate).st_mtime - if candidate_mtime > flush_command_mtime: - flush_command = candidate - flush_command_mtime = candidate_mtime - - return flush_command - def FlushSystemCacheForDirectory(self, directory, ignoring=None): assert directory and os.path.exists(directory), \ 'Target directory %s must exist' % directory - flush_command = self._FindNewestFlushUtility() + flush_command = util.FindSupportBinary(self.GetFlushUtilityName()) assert flush_command, \ 'You must build %s first' % self.GetFlushUtilityName() diff --git a/tools/telemetry/telemetry/core/util.py b/tools/telemetry/telemetry/core/util.py index 3e60e75..fe20924 100644 --- a/tools/telemetry/telemetry/core/util.py +++ b/tools/telemetry/telemetry/core/util.py @@ -124,3 +124,20 @@ def GetBuildDirectories(): for build_dir in build_dirs: for build_type in build_types: yield build_dir, build_type + +def FindSupportBinary(binary_name): + """Returns the path to the given binary name.""" + # TODO(tonyg/dtu): This should support finding binaries in cloud storage. + command = None + command_mtime = 0 + + chrome_root = GetChromiumSrcDir() + for build_dir, build_type in GetBuildDirectories(): + candidate = os.path.join(chrome_root, build_dir, build_type, binary_name) + if os.path.isfile(candidate) and os.access(candidate, os.X_OK): + candidate_mtime = os.stat(candidate).st_mtime + if candidate_mtime > command_mtime: + command = candidate + command_mtime = candidate_mtime + + return command |