2 ##########################################################################
4 # Copyright 2011 Jose Fonseca
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 ##########################################################################/
37 def stripdump(trace, fifo):
38 dump = subprocess.Popen(
44 '--calls=' + options.calls,
47 stdout = subprocess.PIPE,
48 universal_newlines = True,
51 sed = subprocess.Popen(
55 '-e', r's/^[0-9]\+ //',
56 '-e', r's/hdc = \w\+/hdc/g',
59 stdout = open(fifo, 'wt')
60 universal_newlines = True,
65 fifodir = tempfile.mkdtemp()
68 for i in range(len(traces)):
70 fifo = os.path.join(fifodir, str(i))
71 stripdump(trace, fifo)
74 # TODO use difflib instead
75 sdiff = subprocess.Popen(
78 '--width=%u' % options.width,
79 '--speed-large-files',
81 stdout = subprocess.PIPE
82 universal_newlines = True,
85 less = subprocess.Popen(
86 args = ['less', '-FRXn'],
93 shutil.rmtree(fifodir)
99 return curses.tigetnum('cols')
106 default_width = columns()
108 # Parse command line options
109 optparser = optparse.OptionParser(
110 usage='\n\t%prog [options] -- TRACE_FILE TRACE_FILE',
112 optparser.add_option(
113 '-a', '--apitrace', metavar='PROGRAM',
114 type='string', dest='apitrace', default='apitrace',
115 help='apitrace command [default: %default]')
116 optparser.add_option(
117 '-c', '--calls', metavar='CALLSET',
118 type="string", dest="calls", default='1-10000',
119 help="calls to compare [default: %default]")
120 optparser.add_option(
121 '-w', '--width', metavar='NUM',
122 type="string", dest="width", default=default_width,
123 help="columns [default: %default]")
126 (options, args) = optparser.parse_args(sys.argv[1:])
128 optparser.error("incorrect number of arguments")
133 if __name__ == '__main__':