diff options
author | Jamie Gennis <jgennis@google.com> | 2012-06-12 13:15:28 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-12 13:15:28 -0700 |
commit | e85cb47ac81a2e3c44d4ddf2670c8d16c1fb00c1 (patch) | |
tree | 21d3d6ac1877292f127783bebc5a7e43ad45099f | |
parent | 67c4914c2d5e45439d08eb269a2dd957b33b5920 (diff) | |
parent | 1f5d4e97822266b682a8a599b532b3b6460f9e3f (diff) | |
download | chromium-trace-ics-plus-aosp.tar.gz |
am 1f5d4e97: systrace: handle user builds more gracefullyandroid-sdk-adt_r20tools_r20ics-plus-aosp
* commit '1f5d4e97822266b682a8a599b532b3b6460f9e3f':
systrace: handle user builds more gracefully
-rwxr-xr-x | systrace.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/systrace.py b/systrace.py index af82c6f0..3e71bbee 100755 --- a/systrace.py +++ b/systrace.py @@ -35,7 +35,7 @@ def main(): parser.add_option('-b', '--buf-size', dest='trace_buf_size', type='int', help='use a trace buffer size of N KB', metavar='N') parser.add_option('-d', '--disk', dest='trace_disk', default=False, - action='store_true', help='trace disk I/O') + action='store_true', help='trace disk I/O (requires root)') parser.add_option('-f', '--cpu-freq', dest='trace_cpu_freq', default=False, action='store_true', help='trace CPU frequency changes') parser.add_option('-i', '--cpu-idle', dest='trace_cpu_idle', default=False, @@ -47,7 +47,8 @@ def main(): 'scheduler (allows longer trace times by reducing data ' + 'rate into buffer)') parser.add_option('-w', '--workqueue', dest='trace_workqueue', default=False, - action='store_true', help='trace the kernel workqueues') + action='store_true', help='trace the kernel workqueues ' + + '(requires root)') parser.add_option('--set-tags', dest='set_tags', action='store', help='set the enabled trace tags and exit; set to a ' + 'comma separated list of: ' + @@ -70,7 +71,7 @@ def main(): try: subprocess.check_call(atrace_args) except subprocess.CalledProcessError, e: - print sys.stderr, 'unable to set tags: %s' % e + print >> sys.stderr, 'unable to set tags: %s' % e print '\nSet enabled tags to: %s\n' % ', '.join(tags) print ('You will likely need to restart the Android framework for this to ' + 'take effect:\n\n adb shell stop\n adb shell ' + @@ -113,8 +114,6 @@ def main(): js = compiled_js_tag % (open(js_filename).read()) html_filename = options.output_file - html_file = open(html_filename, 'w') - html_file.write(html_prefix % (css, js)) trace_started = False leftovers = '' @@ -143,6 +142,8 @@ def main(): sys.stdout.write("downloading trace...") sys.stdout.flush() out = ''.join(lines[i+1:]) + html_file = open(html_filename, 'w') + html_file.write(html_prefix % (css, js)) trace_started = True break elif 'TRACE:'.startswith(line) and i == len(lines) - 1: @@ -159,14 +160,17 @@ def main(): if result is not None: break if result != 0: - print sys.stderr, 'adb returned error code %d' % result - else: + print >> sys.stderr, 'adb returned error code %d' % result + elif trace_started: html_out = dec.flush().replace('\n', '\\n\\\n').replace('\r', '') if len(html_out) > 0: html_file.write(html_out) html_file.write(html_suffix) html_file.close() print " done\n\n wrote file://%s/%s\n" % (os.getcwd(), options.output_file) + else: + print >> sys.stderr, ('An error occured while capturing the trace. Output ' + + 'file was not written.') html_prefix = """<!DOCTYPE HTML> <html> |