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

Side by Side Diff: tools/objdump-v8

Issue 2167553002: Custom objdump to enable perf annotation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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 V8 project authors. All rights reserved. 2 #
3 # Copyright 2016 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
5 # met: 6 # met:
6 # 7 #
7 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following 11 # copyright notice, this list of conditions and the following
11 # disclaimer in the documentation and/or other materials provided 12 # disclaimer in the documentation and/or other materials provided
12 # with the distribution. 13 # with the distribution.
13 # * Neither the name of Google Inc. nor the names of its 14 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived 15 # contributors may be used to endorse or promote products derived
15 # from this software without specific prior written permission. 16 # from this software without specific prior written permission.
16 # 17 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 29
29 # Wraps test execution with a coverage analysis. To get the best speed, the 30 import re
30 # native python coverage version >= 3.7.1 should be installed. 31 import subprocess
31
32 import coverage
33 import os
34 import unittest
35 import sys 32 import sys
36 33
37 34
38 def Main(argv): 35 def get_address_bounds():
39 script_path = os.path.dirname(os.path.abspath(__file__)) 36 start = -1
40 cov = coverage.coverage(include=([os.path.join(script_path, '*.py')])) 37 end = -1
41 cov.start() 38 for arg in sys.argv:
42 import test_scripts 39 if arg.startswith("--start-address="):
43 alltests = map(unittest.TestLoader().loadTestsFromTestCase, [ 40 start = int(arg[-12:], 16)
44 test_scripts.ToplevelTest, 41 if arg.startswith("--stop-address="):
45 test_scripts.ScriptTest, 42 end = int(arg[-12:], 16)
46 test_scripts.SystemTest, 43 return start, end
47 ])
48 unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(alltests))
49 cov.stop()
50 print cov.report()
51 44
52 45
53 if __name__ == '__main__': 46 def format_line(line):
54 sys.exit(Main(sys.argv)) 47 pieces = line.split(None, 3)
48 return " " + pieces[0][2:] + ":\t" + pieces[3]
49
50
51 def is_comment(line):
52 stripped = line.strip()
53 return stripped.startswith("--") or stripped.startswith(";;;")
54
55 def main():
56 filename = sys.argv[-1]
57 match = re.match(r"/tmp/perf-(.*)\.map", filename)
58 if match:
59 start, end = get_address_bounds()
60 codefile = "code-" + match.group(1) + "-1.asm"
Benedikt Meurer 2016/07/21 03:50:34 d8 hardcodes code.asm as output, so this will not
61 with open(codefile, "r") as code:
62 printing = False
63 for line in code:
64 if line.startswith("0x"):
65 addr = int(line.split()[0], 0)
66 if start <= addr <= end:
67 printing = True
68 sys.stdout.write(format_line(line))
69 elif printing:
70 break
71 elif printing and not is_comment(line):
72 break
73 else:
74 sys.argv[0] = "objdump"
75 sys.exit(subprocess.call(sys.argv))
76
77 if __name__ == "__main__":
78 main()
OLDNEW
« 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