| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A Disassembler object is used to disassemble a block of code instruction by | 5 // A Disassembler object is used to disassemble a block of code instruction by |
| 6 // instruction. The default implementation of the NameConverter object can be | 6 // instruction. The default implementation of the NameConverter object can be |
| 7 // overriden to modify register names or to do symbol lookup on addresses. | 7 // overriden to modify register names or to do symbol lookup on addresses. |
| 8 // | 8 // |
| 9 // The example below will disassemble a block of code and print it to stdout. | 9 // The example below will disassemble a block of code and print it to stdout. |
| 10 // | 10 // |
| (...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 } // namespace internal | 2041 } // namespace internal |
| 2042 } // namespace v8 | 2042 } // namespace v8 |
| 2043 | 2043 |
| 2044 | 2044 |
| 2045 //------------------------------------------------------------------------------ | 2045 //------------------------------------------------------------------------------ |
| 2046 | 2046 |
| 2047 namespace disasm { | 2047 namespace disasm { |
| 2048 | 2048 |
| 2049 | 2049 |
| 2050 const char* NameConverter::NameOfAddress(byte* addr) const { | 2050 const char* NameConverter::NameOfAddress(byte* addr) const { |
| 2051 v8::internal::SNPrintF(tmp_buffer_, "%p", addr); | 2051 v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr)); |
| 2052 return tmp_buffer_.start(); | 2052 return tmp_buffer_.start(); |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 | 2055 |
| 2056 const char* NameConverter::NameOfConstant(byte* addr) const { | 2056 const char* NameConverter::NameOfConstant(byte* addr) const { |
| 2057 return NameOfAddress(addr); | 2057 return NameOfAddress(addr); |
| 2058 } | 2058 } |
| 2059 | 2059 |
| 2060 | 2060 |
| 2061 const char* NameConverter::NameOfCPURegister(int reg) const { | 2061 const char* NameConverter::NameOfCPURegister(int reg) const { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 | 2104 |
| 2105 | 2105 |
| 2106 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) { | 2106 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) { |
| 2107 NameConverter converter; | 2107 NameConverter converter; |
| 2108 Disassembler d(converter); | 2108 Disassembler d(converter); |
| 2109 for (byte* pc = begin; pc < end;) { | 2109 for (byte* pc = begin; pc < end;) { |
| 2110 v8::internal::EmbeddedVector<char, 128> buffer; | 2110 v8::internal::EmbeddedVector<char, 128> buffer; |
| 2111 buffer[0] = '\0'; | 2111 buffer[0] = '\0'; |
| 2112 byte* prev_pc = pc; | 2112 byte* prev_pc = pc; |
| 2113 pc += d.InstructionDecode(buffer, pc); | 2113 pc += d.InstructionDecode(buffer, pc); |
| 2114 v8::internal::PrintF( | 2114 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), |
| 2115 f, "%p %08x %s\n", | 2115 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 2116 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | |
| 2117 } | 2116 } |
| 2118 } | 2117 } |
| 2119 | 2118 |
| 2120 | 2119 |
| 2121 } // namespace disasm | 2120 } // namespace disasm |
| 2122 | 2121 |
| 2123 #endif // V8_TARGET_ARCH_ARM | 2122 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |