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

Unified 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 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: tools/objdump-v8
diff --git a/tools/release/script_test.py b/tools/objdump-v8
similarity index 55%
copy from tools/release/script_test.py
copy to tools/objdump-v8
index cbb2134f6d92f9d7a8c8e7dda3a3a2e9e1c0a45c..185ce29cd38618a6239220045f29c5e113574a8f 100755
--- a/tools/release/script_test.py
+++ b/tools/objdump-v8
@@ -1,5 +1,6 @@
#!/usr/bin/env python
-# Copyright 2014 the V8 project authors. All rights reserved.
+#
+# Copyright 2016 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
@@ -26,29 +27,52 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# Wraps test execution with a coverage analysis. To get the best speed, the
-# native python coverage version >= 3.7.1 should be installed.
-
-import coverage
-import os
-import unittest
+import re
+import subprocess
import sys
-def Main(argv):
- script_path = os.path.dirname(os.path.abspath(__file__))
- cov = coverage.coverage(include=([os.path.join(script_path, '*.py')]))
- cov.start()
- import test_scripts
- alltests = map(unittest.TestLoader().loadTestsFromTestCase, [
- test_scripts.ToplevelTest,
- test_scripts.ScriptTest,
- test_scripts.SystemTest,
- ])
- unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(alltests))
- cov.stop()
- print cov.report()
+def get_address_bounds():
+ start = -1
+ end = -1
+ for arg in sys.argv:
+ if arg.startswith("--start-address="):
+ start = int(arg[-12:], 16)
+ if arg.startswith("--stop-address="):
+ end = int(arg[-12:], 16)
+ return start, end
+
+
+def format_line(line):
+ pieces = line.split(None, 3)
+ return " " + pieces[0][2:] + ":\t" + pieces[3]
+
+
+def is_comment(line):
+ stripped = line.strip()
+ return stripped.startswith("--") or stripped.startswith(";;;")
+def main():
+ filename = sys.argv[-1]
+ match = re.match(r"/tmp/perf-(.*)\.map", filename)
+ if match:
+ start, end = get_address_bounds()
+ 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
+ with open(codefile, "r") as code:
+ printing = False
+ for line in code:
+ if line.startswith("0x"):
+ addr = int(line.split()[0], 0)
+ if start <= addr <= end:
+ printing = True
+ sys.stdout.write(format_line(line))
+ elif printing:
+ break
+ elif printing and not is_comment(line):
+ break
+ else:
+ sys.argv[0] = "objdump"
+ sys.exit(subprocess.call(sys.argv))
-if __name__ == '__main__':
- sys.exit(Main(sys.argv))
+if __name__ == "__main__":
+ 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