blob: 69fb47dc5e1cd181c90a13c9a7c25362b2ebd9aa [file] [log] [blame]
Dennis Kempin1a8a5be2013-06-18 11:00:02 -07001#! /usr/bin/env python
2# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
Harry Cutts87cc6002020-02-04 15:50:20 -08006from __future__ import absolute_import
7from __future__ import division
Harry Cutts0edf1572020-01-21 15:42:10 -08008from __future__ import print_function
9
Dennis Kempin1a8a5be2013-06-18 11:00:02 -070010from mtreplay import MTReplay
Dennis Kempind0b722a2014-04-15 11:54:48 -070011from mtlib import Log, PlatformDatabase
Dennis Kempin1a8a5be2013-06-18 11:00:02 -070012from optparse import OptionParser
13import sys
14
15
16usage = """Multitouch Replay Usage Examples:
17
18Replaying logs and print activity_log:
19$ %prog filename.log (from file)
20$ %prog 172.22.75.0 (from device ip address)
21$ %prog http://feedback.google.com/... (from feedback report url)
22
23Print which platform this log is replayed on:
24$ %prog log -p
25
26View gestures log
27$ %prog log -v gestures-log
28$ %prog log -vgl
29
30View evdev log
31$ %prog log -v evdev-log
32$ %prog log -vel
33
34View activity in MTEdit:
35$ %prog log -v activity
36$ %prog log -va"""
37
38
39def main(argv):
40 parser = OptionParser(usage=usage)
41 parser.add_option('-p', '--platform',
42 dest='platform', action='store_true', default=False,
43 help='print platform this log is replayed on')
44 parser.add_option('-v', '--view',
45 dest='view', default=None,
46 help='select output of relay to view')
Dennis Kempin41b3ddd2013-07-01 15:08:32 -070047 parser.add_option('--gdb',
48 dest='gdb', action='store_true', default=False,
49 help='setup gdb session to run replay')
Dennis Kempind1e56a22013-07-17 14:11:46 -070050 parser.add_option('--force', '-f',
51 dest='force', default=None,
52 help='force platform for replay')
Dennis Kempind0b722a2014-04-15 11:54:48 -070053 parser.add_option('--add-platform', '-a',
54 dest='add', default=None,
55 help='add platform of device to database')
Dennis Kempin1a8a5be2013-06-18 11:00:02 -070056 (options, args) = parser.parse_args()
57
Dennis Kempind0b722a2014-04-15 11:54:48 -070058 if options.add:
59 PlatformDatabase.RegisterPlatformFromDevice(options.add)
60 return
61
Dennis Kempin1a8a5be2013-06-18 11:00:02 -070062 replay = MTReplay()
Dennis Kempin41b3ddd2013-07-01 15:08:32 -070063 replay.Recompile()
Dennis Kempin1a8a5be2013-06-18 11:00:02 -070064
65 if len(args) != 1:
66 parser.print_help()
67 exit(-1)
68
69 log = Log(args[0])
70
71 if options.platform:
Dennis Kempin55af9cc2013-06-20 15:07:21 -070072 platform = replay.PlatformOf(log, True)
73 if platform:
Harry Cutts0edf1572020-01-21 15:42:10 -080074 print(platform.name)
Dennis Kempin1a8a5be2013-06-18 11:00:02 -070075 return
76
Dennis Kempind1e56a22013-07-17 14:11:46 -070077 results = replay.Replay(log, force_platform=options.force, gdb=options.gdb)
Dennis Kempin55af9cc2013-06-20 15:07:21 -070078 if results:
79 results.View(options.view)
Dennis Kempin1a8a5be2013-06-18 11:00:02 -070080
81
82if __name__ == '__main__':
83 main(sys.argv)