Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: mojo/devtools/common/debugger

Issue 1156823004: Add a cli for a running mojo:debugger. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/debugger
diff --git a/mojo/devtools/common/debugger b/mojo/devtools/common/debugger
new file mode 100755
index 0000000000000000000000000000000000000000..17f11c9eb824b11262e5f525378182f676f23f07
--- /dev/null
+++ b/mojo/devtools/common/debugger
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import requests
+import sys
+
+_MOJO_DEBUGGER_PORT = 7777
+
+
+def _send_request(request, payload=None):
+ url = 'http://localhost:%s/%s' % (_MOJO_DEBUGGER_PORT, request)
+ if payload:
+ response = requests.post(url, payload)
+ else:
+ response = requests.get(url)
+ return response
qsr 2015/06/03 15:20:40 You probably should remove payload as you do not u
ppi 2015/06/03 15:24:04 Done.
+
+
+def start_tracing_command(args):
+ _send_request('start_tracing')
+ print "Started tracing."
+
+
+def stop_tracing_command(args):
+ file_name = args.file_name
+ trace = _send_request('stop_tracing').content
+ with open(file_name, "wb") as trace_file:
+ trace_file.write('{"traceEvents":[')
+ trace_file.write(trace)
+ trace_file.write(']}')
+ print "Trace saved in %s" % file_name
+
+
+def main():
+ parser = argparse.ArgumentParser(description='Command-line interface for '
+ 'mojo:debugger')
+ subparsers = parser.add_subparsers(help='sub-command help')
+
+ start_tracing_parser = subparsers.add_parser('start_tracing',
+ help='starts tracing')
+ start_tracing_parser.set_defaults(func=start_tracing_command)
+
+ stop_tracing_parser = subparsers.add_parser('stop_tracing',
+ help='stops tracing')
+ stop_tracing_parser.add_argument('file_name', type=str, default='mojo.trace')
+ stop_tracing_parser.set_defaults(func=stop_tracing_command)
+
+ args = parser.parse_args()
+ args.func(args)
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698