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() |