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

Side by Side Diff: sky/tools/skydb

Issue 812573006: Sky should symbolize pprof traces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « sky/tools/debugger/prompt/prompt.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 from skypy.skyserver import SkyServer 6 from skypy.skyserver import SkyServer
7 import argparse 7 import argparse
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if not urlparse.urlparse(args.url_or_path).scheme: 313 if not urlparse.urlparse(args.url_or_path).scheme:
314 # The load happens on the remote device, use the remote port. 314 # The load happens on the remote device, use the remote port.
315 remote_sky_server_port = self.pids.get('remote_sky_server_port', 315 remote_sky_server_port = self.pids.get('remote_sky_server_port',
316 self.pids['sky_server_port']) 316 self.pids['sky_server_port'])
317 url = SkyServer.url_for_path(remote_sky_server_port, 317 url = SkyServer.url_for_path(remote_sky_server_port,
318 self.pids['sky_server_root'], args.url_or_path) 318 self.pids['sky_server_root'], args.url_or_path)
319 else: 319 else:
320 url = args.url_or_path 320 url = args.url_or_path
321 self._send_command_to_sky('/load', url) 321 self._send_command_to_sky('/load', url)
322 322
323 def stop_profiling_command(self, args):
324 self._send_command_to_sky('/stop_profiling')
325 # We need to munge the profile to replace foo.mojo with libfoo.so so
326 # that pprof knows this represents an SO.
327 with open("sky_viewer.pprof", "r+") as profile_file:
328 data = profile_file.read()
329 profile_file.seek(0)
330 profile_file.write(re.sub(r'(\w+)\.mojo', r'lib\1_library.so', data) )
331 profile_file.truncate()
332
323 def _command_base_url(self): 333 def _command_base_url(self):
324 return 'http://localhost:%s' % self.pids['sky_command_port'] 334 return 'http://localhost:%s' % self.pids['sky_command_port']
325 335
326 def _send_command_to_sky(self, command_path, payload=None): 336 def _send_command_to_sky(self, command_path, payload=None):
327 url = 'http://localhost:%s%s' % ( 337 url = 'http://localhost:%s%s' % (
328 self.pids['sky_command_port'], command_path) 338 self.pids['sky_command_port'], command_path)
329 if payload: 339 if payload:
330 response = requests.post(url, payload) 340 response = requests.post(url, payload)
331 else: 341 else:
332 response = requests.get(url) 342 response = requests.get(url)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 gdb_attach_parser.set_defaults(func=self.gdb_attach_command) 510 gdb_attach_parser.set_defaults(func=self.gdb_attach_command)
501 511
502 self._add_basic_command(subparsers, 'trace', '/trace', 512 self._add_basic_command(subparsers, 'trace', '/trace',
503 'toggle tracing') 513 'toggle tracing')
504 self._add_basic_command(subparsers, 'reload', '/reload', 514 self._add_basic_command(subparsers, 'reload', '/reload',
505 'reload the current page') 515 'reload the current page')
506 self._add_basic_command(subparsers, 'inspect', '/inspect', 516 self._add_basic_command(subparsers, 'inspect', '/inspect',
507 'stop the running sky instance') 517 'stop the running sky instance')
508 self._add_basic_command(subparsers, 'start_profiling', '/start_profiling ', 518 self._add_basic_command(subparsers, 'start_profiling', '/start_profiling ',
509 'starts profiling the running sky instance (Linux only)') 519 'starts profiling the running sky instance (Linux only)')
510 self._add_basic_command(subparsers, 'stop_profiling', '/stop_profiling', 520
511 'stios profiling the running sky instance (Linux only)') 521 stop_profiling_parser = subparsers.add_parser('stop_profiling',
522 help='stops profiling the running sky instance (Linux only)')
523 stop_profiling_parser.set_defaults(func=self.stop_profiling_command)
512 524
513 load_parser = subparsers.add_parser('load', 525 load_parser = subparsers.add_parser('load',
514 help='load a new page in the currently running sky') 526 help='load a new page in the currently running sky')
515 load_parser.add_argument('url_or_path', type=str) 527 load_parser.add_argument('url_or_path', type=str)
516 load_parser.set_defaults(func=self.load_command) 528 load_parser.set_defaults(func=self.load_command)
517 529
518 args = parser.parse_args() 530 args = parser.parse_args()
519 args.func(args) 531 args.func(args)
520 532
521 self._write_pid_file(PID_FILE_PATH, self.pids) 533 self._write_pid_file(PID_FILE_PATH, self.pids)
522 534
523 535
524 if __name__ == '__main__': 536 if __name__ == '__main__':
525 SkyDebugger().main() 537 SkyDebugger().main()
OLDNEW
« no previous file with comments | « sky/tools/debugger/prompt/prompt.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698