OLD | NEW |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 "arm64": "-m aarch64" | 53 "arm64": "-m aarch64" |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 def GetDisasmLines(filename, offset, size, arch, inplace, arch_flags=""): | 57 def GetDisasmLines(filename, offset, size, arch, inplace, arch_flags=""): |
58 tmp_name = None | 58 tmp_name = None |
59 if not inplace: | 59 if not inplace: |
60 # Create a temporary file containing a copy of the code. | 60 # Create a temporary file containing a copy of the code. |
61 assert arch in _ARCH_MAP, "Unsupported architecture '%s'" % arch | 61 assert arch in _ARCH_MAP, "Unsupported architecture '%s'" % arch |
62 arch_flags = arch_flags + " " + _ARCH_MAP[arch] | 62 arch_flags = arch_flags + " " + _ARCH_MAP[arch] |
63 tmp_name = tempfile.mktemp(".v8code") | 63 tmp_file = tempfile.NamedTemporaryFile(prefix=".v8code", delete=False) |
| 64 tmp_name = tmp_file.name |
| 65 tmp_file.close() |
64 command = "dd if=%s of=%s bs=1 count=%d skip=%d && " \ | 66 command = "dd if=%s of=%s bs=1 count=%d skip=%d && " \ |
65 "%s %s -D -b binary %s %s" % ( | 67 "%s %s -D -b binary %s %s" % ( |
66 filename, tmp_name, size, offset, | 68 filename, tmp_name, size, offset, |
67 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), arch_flags, | 69 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), arch_flags, |
68 tmp_name) | 70 tmp_name) |
69 else: | 71 else: |
70 command = "%s %s %s --start-address=%d --stop-address=%d -d %s " % ( | 72 command = "%s %s %s --start-address=%d --stop-address=%d -d %s " % ( |
71 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), arch_flags, | 73 OBJDUMP_BIN, ' '.join(_COMMON_DISASM_OPTIONS), arch_flags, |
72 offset, | 74 offset, |
73 offset + size, | 75 offset + size, |
(...skipping 11 matching lines...) Expand all Loading... |
85 break | 87 break |
86 if tmp_name: | 88 if tmp_name: |
87 os.unlink(tmp_name) | 89 os.unlink(tmp_name) |
88 split_lines = [] | 90 split_lines = [] |
89 for line in lines[header_line + 1:]: | 91 for line in lines[header_line + 1:]: |
90 match = _DISASM_LINE_RE.match(line) | 92 match = _DISASM_LINE_RE.match(line) |
91 if match: | 93 if match: |
92 line_address = int(match.group(1), 16) | 94 line_address = int(match.group(1), 16) |
93 split_lines.append((line_address, match.group(2))) | 95 split_lines.append((line_address, match.group(2))) |
94 return split_lines | 96 return split_lines |
OLD | NEW |