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

Side by Side Diff: tools/objdump-v8

Issue 2159103007: Fix objdump assembly truncations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Prioritize process specific code.asm 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 # 2 #
3 # Copyright 2016 the V8 project authors. All rights reserved. 3 # Copyright 2016 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following 11 # copyright notice, this list of conditions and the following
12 # disclaimer in the documentation and/or other materials provided 12 # disclaimer in the documentation and/or other materials provided
13 # with the distribution. 13 # with the distribution.
14 # * Neither the name of Google Inc. nor the names of its 14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived 15 # contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission. 16 # from this software without specific prior written permission.
17 # 17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (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
28 # 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.
29 29
30 import os.path
30 import re 31 import re
31 import subprocess 32 import subprocess
32 import sys 33 import sys
33 34
34 35
35 def get_address_bounds(): 36 def get_address_bounds():
36 start = -1 37 start = -1
37 end = -1 38 end = -1
38 for arg in sys.argv: 39 for arg in sys.argv:
39 if arg.startswith("--start-address="): 40 if arg.startswith("--start-address="):
40 start = int(arg[-12:], 16) 41 start = int(arg[-12:], 16)
41 if arg.startswith("--stop-address="): 42 if arg.startswith("--stop-address="):
42 end = int(arg[-12:], 16) 43 end = int(arg[-12:], 16)
43 return start, end 44 return start, end
44 45
45 46
46 def format_line(line): 47 def format_line(line):
47 pieces = line.split(None, 3) 48 pieces = line.split(None, 3)
48 return " " + pieces[0][2:] + ":\t" + pieces[3] 49 return " " + pieces[0][2:] + ":\t" + pieces[3]
49 50
50 51
51 def is_comment(line): 52 def is_comment(line):
52 stripped = line.strip() 53 stripped = line.strip()
53 return stripped.startswith("--") or stripped.startswith(";;;") 54 return stripped.startswith("--") or stripped.startswith(";;")
54 55
55 def main(): 56 def main():
56 filename = sys.argv[-1] 57 filename = sys.argv[-1]
57 match = re.match(r"/tmp/perf-(.*)\.map", filename) 58 match = re.match(r"/tmp/perf-(.*)\.map", filename)
58 if match: 59 if match:
59 start, end = get_address_bounds() 60 start, end = get_address_bounds()
60 codefile = "code-" + match.group(1) + "-1.asm" 61 process_codefile = "code-" + match.group(1) + "-1.asm"
61 with open(codefile, "r") as code: 62 if os.path.exists(process_codefile):
63 codefile = open(process_codefile, "r")
64 else:
65 codefile = open("code.asm", "r")
66 with codefile:
62 printing = False 67 printing = False
63 for line in code: 68 for line in codefile:
64 if line.startswith("0x"): 69 if line.startswith("0x"):
65 addr = int(line.split()[0], 0) 70 addr = int(line.split()[0], 0)
66 if start <= addr <= end: 71 if start <= addr <= end:
67 printing = True 72 printing = True
68 sys.stdout.write(format_line(line)) 73 sys.stdout.write(format_line(line))
69 elif printing: 74 elif printing:
70 break 75 break
71 elif printing and not is_comment(line): 76 elif printing and not is_comment(line):
72 break 77 break
73 else: 78 else:
74 sys.argv[0] = "objdump" 79 sys.argv[0] = "objdump"
75 sys.exit(subprocess.call(sys.argv)) 80 sys.exit(subprocess.call(sys.argv))
76 81
77 if __name__ == "__main__": 82 if __name__ == "__main__":
78 main() 83 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