OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 } // namespace internal | 1394 } // namespace internal |
1395 } // namespace v8 | 1395 } // namespace v8 |
1396 | 1396 |
1397 | 1397 |
1398 //------------------------------------------------------------------------------ | 1398 //------------------------------------------------------------------------------ |
1399 | 1399 |
1400 namespace disasm { | 1400 namespace disasm { |
1401 | 1401 |
1402 | 1402 |
1403 const char* NameConverter::NameOfAddress(byte* addr) const { | 1403 const char* NameConverter::NameOfAddress(byte* addr) const { |
1404 v8::internal::SNPrintF(tmp_buffer_, "%p", addr); | 1404 v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr)); |
1405 return tmp_buffer_.start(); | 1405 return tmp_buffer_.start(); |
1406 } | 1406 } |
1407 | 1407 |
1408 | 1408 |
1409 const char* NameConverter::NameOfConstant(byte* addr) const { | 1409 const char* NameConverter::NameOfConstant(byte* addr) const { |
1410 return NameOfAddress(addr); | 1410 return NameOfAddress(addr); |
1411 } | 1411 } |
1412 | 1412 |
1413 | 1413 |
1414 const char* NameConverter::NameOfCPURegister(int reg) const { | 1414 const char* NameConverter::NameOfCPURegister(int reg) const { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 | 1454 |
1455 | 1455 |
1456 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) { | 1456 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) { |
1457 NameConverter converter; | 1457 NameConverter converter; |
1458 Disassembler d(converter); | 1458 Disassembler d(converter); |
1459 for (byte* pc = begin; pc < end;) { | 1459 for (byte* pc = begin; pc < end;) { |
1460 v8::internal::EmbeddedVector<char, 128> buffer; | 1460 v8::internal::EmbeddedVector<char, 128> buffer; |
1461 buffer[0] = '\0'; | 1461 buffer[0] = '\0'; |
1462 byte* prev_pc = pc; | 1462 byte* prev_pc = pc; |
1463 pc += d.InstructionDecode(buffer, pc); | 1463 pc += d.InstructionDecode(buffer, pc); |
1464 v8::internal::PrintF(f, "%p %08x %s\n", prev_pc, | 1464 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), |
1465 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1465 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
1466 } | 1466 } |
1467 } | 1467 } |
1468 | 1468 |
1469 | 1469 |
1470 } // namespace disasm | 1470 } // namespace disasm |
1471 | 1471 |
1472 #endif // V8_TARGET_ARCH_PPC | 1472 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |