OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import signal | 7 import signal |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 perf_profile) | 157 perf_profile) |
158 if not required_libs: | 158 if not required_libs: |
159 logging.warning('No libraries required by perf trace. Most likely there ' | 159 logging.warning('No libraries required by perf trace. Most likely there ' |
160 'are no samples in the trace.') | 160 'are no samples in the trace.') |
161 | 161 |
162 # Build a symfs with all the necessary libraries. | 162 # Build a symfs with all the necessary libraries. |
163 kallsyms = android_profiling_helper.CreateSymFs(self._device, | 163 kallsyms = android_profiling_helper.CreateSymFs(self._device, |
164 symfs_dir, | 164 symfs_dir, |
165 required_libs, | 165 required_libs, |
166 use_symlinks=False) | 166 use_symlinks=False) |
167 perfhost_path = support_binaries.FindPath('perfhost', 'linux') | 167 perfhost_path = support_binaries.FindPath( |
| 168 android_profiling_helper.GetPerfhostName(), 'linux') |
168 | 169 |
169 ui.PrintMessage('\nNote: to view the profile in perf, run:') | 170 ui.PrintMessage('\nNote: to view the profile in perf, run:') |
170 ui.PrintMessage(' ' + self._GetInteractivePerfCommand(perfhost_path, | 171 ui.PrintMessage(' ' + self._GetInteractivePerfCommand(perfhost_path, |
171 perf_profile, symfs_dir, required_libs, kallsyms)) | 172 perf_profile, symfs_dir, required_libs, kallsyms)) |
172 | 173 |
173 # Convert the perf profile into JSON. | 174 # Convert the perf profile into JSON. |
174 perf_script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), | 175 perf_script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
175 'third_party', 'perf_to_tracing.py') | 176 'third_party', 'perf_to_tracing.py') |
176 json_file_name = os.path.basename(perf_profile) | 177 json_file_name = os.path.basename(perf_profile) |
177 with open(os.devnull, 'w') as dev_null, \ | 178 with open(os.devnull, 'w') as dev_null, \ |
178 open(json_file_name, 'w') as json_file: | 179 open(json_file_name, 'w') as json_file: |
179 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', | 180 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', |
180 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] | 181 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] |
181 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): | 182 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): |
182 logging.warning('Perf data to JSON conversion failed. The result will ' | 183 logging.warning('Perf data to JSON conversion failed. The result will ' |
183 'not contain any perf samples. You can still view the ' | 184 'not contain any perf samples. You can still view the ' |
184 'perf data manually as shown above.') | 185 'perf data manually as shown above.') |
185 return None | 186 return None |
186 | 187 |
187 return json_file_name | 188 return json_file_name |
OLD | NEW |