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

Side by Side Diff: tools/disasm.py

Issue 11565014: Add ARM support to tools/grokdump.py (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unify objdump architecture specific flags. Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/grokdump.py » ('j') | 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 2011 the V8 project authors. All rights reserved. 3 # Copyright 2011 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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 # Keys must match constants in Logger::LogCodeInfo. 47 # Keys must match constants in Logger::LogCodeInfo.
48 _ARCH_MAP = { 48 _ARCH_MAP = {
49 "ia32": "-m i386", 49 "ia32": "-m i386",
50 "x64": "-m i386 -M x86-64", 50 "x64": "-m i386 -M x86-64",
51 "arm": "-m arm", # Not supported by our objdump build. 51 "arm": "-m arm", # Not supported by our objdump build.
52 "mips": "-m mips" # Not supported by our objdump build. 52 "mips": "-m mips" # Not supported by our objdump build.
53 } 53 }
54 54
55 55
56 def GetDisasmLines(filename, offset, size, arch, inplace): 56 def GetDisasmLines(filename, offset, size, arch, inplace, arch_flags=""):
57 tmp_name = None 57 tmp_name = None
58 if not inplace: 58 if not inplace:
59 # Create a temporary file containing a copy of the code. 59 # Create a temporary file containing a copy of the code.
60 assert arch in _ARCH_MAP, "Unsupported architecture '%s'" % arch 60 assert arch in _ARCH_MAP, "Unsupported architecture '%s'" % arch
61 arch_flags = _ARCH_MAP[arch] 61 arch_flags = arch_flags + " " + _ARCH_MAP[arch]
62 tmp_name = tempfile.mktemp(".v8code") 62 tmp_name = tempfile.mktemp(".v8code")
63 command = "dd if=%s of=%s bs=1 count=%d skip=%d && " \ 63 command = "dd if=%s of=%s bs=1 count=%d skip=%d && " \
64 "%s %s -D -b binary %s %s" % ( 64 "%s %s -D -b binary %s %s" % (
65 filename, tmp_name, size, offset, 65 filename, tmp_name, size, offset,
66 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), arch_flags, 66 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), arch_flags,
67 tmp_name) 67 tmp_name)
68 else: 68 else:
69 command = "%s %s --start-address=%d --stop-address=%d -d %s " % ( 69 command = "%s %s %s --start-address=%d --stop-address=%d -d %s " % (
70 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), 70 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), arch_flags,
71 offset, 71 offset,
72 offset + size, 72 offset + size,
73 filename) 73 filename)
74 process = subprocess.Popen(command, 74 process = subprocess.Popen(command,
75 shell=True, 75 shell=True,
76 stdout=subprocess.PIPE, 76 stdout=subprocess.PIPE,
77 stderr=subprocess.STDOUT) 77 stderr=subprocess.STDOUT)
78 out, err = process.communicate() 78 out, err = process.communicate()
79 lines = out.split("\n") 79 lines = out.split("\n")
80 header_line = 0 80 header_line = 0
81 for i, line in enumerate(lines): 81 for i, line in enumerate(lines):
82 if _DISASM_HEADER_RE.match(line): 82 if _DISASM_HEADER_RE.match(line):
83 header_line = i 83 header_line = i
84 break 84 break
85 if tmp_name: 85 if tmp_name:
86 os.unlink(tmp_name) 86 os.unlink(tmp_name)
87 split_lines = [] 87 split_lines = []
88 for line in lines[header_line + 1:]: 88 for line in lines[header_line + 1:]:
89 match = _DISASM_LINE_RE.match(line) 89 match = _DISASM_LINE_RE.match(line)
90 if match: 90 if match:
91 line_address = int(match.group(1), 16) 91 line_address = int(match.group(1), 16)
92 split_lines.append((line_address, match.group(2))) 92 split_lines.append((line_address, match.group(2)))
93 return split_lines 93 return split_lines
OLDNEW
« no previous file with comments | « no previous file | tools/grokdump.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698