diff --git a/libs/utils/android/system.py b/libs/utils/android/system.py index 42e8c4dec7516ea88b6011d7bedb357baa55a72f..f863ca3ef7c065c5c04f9aaf44f38be7130d9642 100644 --- a/libs/utils/android/system.py +++ b/libs/utils/android/system.py @@ -47,8 +47,12 @@ class System(object): return None # Format the command according to the specified arguments - systrace_pattern = "{} -e {} -o {} {}" - trace_cmd = systrace_pattern.format(systrace_path, target.conf['device'], + try: + device = "-e {}".format(target.conf['device']) + except: + device = '' + systrace_pattern = "{} {} -o {} {}" + trace_cmd = systrace_pattern.format(systrace_path, device, trace_file, " ".join(events)) if time is not None: trace_cmd += " -t {}".format(time) diff --git a/libs/utils/android/workload.py b/libs/utils/android/workload.py index 626b65d501df675cf85f668540eb26a570539430..a42f772564259959059865321aaba00193da6850 100644 --- a/libs/utils/android/workload.py +++ b/libs/utils/android/workload.py @@ -134,4 +134,31 @@ class Workload(object): # Dump a platform description self._te.platform_dump(self.out_dir) + def traceShow(self): + """ + Open the collected trace using the most appropriate native viewer. + + The native viewer depends on the specified trace format: + - ftrace: open using kernelshark + - systrace: open using a browser + + In both cases the native viewer is assumed to be available in the host + machine. + """ + + if 'ftrace' in self.collect: + os.popen("kernelshark {}".format(self.trace_file)) + return + + if 'systrace' in self.collect: + if os.name == 'posix': + os.popen("xdg-open {}".format(self.trace_file)) + elif sys.platform.startswith('darwin'): + os.popen("open {}".format(self.trace_file)) + elif os.name == 'nt': + os.startfile(self.trace_file) + return + + self._log.warning('No trace collected since last run') + # vim :set tabstop=4 shiftwidth=4 expandtab