OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/disassembler.h" | 5 #include "vm/disassembler.h" |
6 | 6 |
7 #if !defined(_WIN32) // Disassembler is not yet supported under WIN32. | 7 #if !defined(_WIN32) // Disassembler is not yet supported under WIN32. |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 remove(tmp); | 47 remove(tmp); |
48 return; | 48 return; |
49 } | 49 } |
50 close(fd); | 50 close(fd); |
51 | 51 |
52 // Disassemble tmp file to stdout. | 52 // Disassemble tmp file to stdout. |
53 char cmd[256]; | 53 char cmd[256]; |
54 #if defined(__APPLE__) | 54 #if defined(__APPLE__) |
55 snprintf(cmd, sizeof(cmd), | 55 snprintf(cmd, sizeof(cmd), |
56 "( cat %1$s | " | 56 "( cat %1$s | " |
57 " hexdump -v -e '\".byte \" 1/1 \"0x%%02x\" \"\n\"' | " | 57 " hexdump -v -e '\".byte \" 1/1 \"0x%%02x\" \"\\n\"' | " |
58 " as - -arch x86_64 -o %1$s.o ; otool -tV %1$s.o" | 58 " as - -arch x86_64 -o %1$s.o ; otool -tV %1$s.o" |
59 ") </dev/null 2>&1", tmp); | 59 ") </dev/null 2>&1", tmp); |
60 #else | 60 #else |
61 snprintf(cmd, sizeof(cmd), "( /usr/bin/objdump -b binary -m i386:x86-64 -D %s" | 61 snprintf(cmd, sizeof(cmd), "( /usr/bin/objdump -b binary -m i386:x86-64 -D %s" |
62 " ) </dev/null 2>&1", tmp); | 62 " ) </dev/null 2>&1", tmp); |
63 #endif | 63 #endif |
64 FILE* output = popen(cmd, "r"); | 64 FILE* output = popen(cmd, "r"); |
65 if (output == NULL) { | 65 if (output == NULL) { |
66 int errsv = errno; | 66 int errsv = errno; |
67 formatter->Print("Could not run \"%s\", errno=%s\n", cmd, strerror(errsv)); | 67 formatter->Print("Could not run \"%s\", errno=%s\n", cmd, strerror(errsv)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 int Disassembler::DecodeInstruction(char* hexa_buffer, intptr_t hexa_size, | 101 int Disassembler::DecodeInstruction(char* hexa_buffer, intptr_t hexa_size, |
102 char* human_buffer, intptr_t human_size, | 102 char* human_buffer, intptr_t human_size, |
103 uword pc) { | 103 uword pc) { |
104 UNIMPLEMENTED(); | 104 UNIMPLEMENTED(); |
105 return 0; | 105 return 0; |
106 } | 106 } |
107 | 107 |
108 } // namespace dart | 108 } // namespace dart |
109 | 109 |
110 #endif // defined TARGET_ARCH_X64 | 110 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |