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 #include <assert.h> | 5 #include <assert.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdarg.h> | 7 #include <stdarg.h> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 AppendToBuffer("'Unimplemented Instruction'"); | 350 AppendToBuffer("'Unimplemented Instruction'"); |
351 } | 351 } |
352 } | 352 } |
353 }; | 353 }; |
354 | 354 |
355 | 355 |
356 void DisassemblerIA32::AppendToBuffer(const char* format, ...) { | 356 void DisassemblerIA32::AppendToBuffer(const char* format, ...) { |
357 v8::internal::Vector<char> buf = tmp_buffer_ + tmp_buffer_pos_; | 357 v8::internal::Vector<char> buf = tmp_buffer_ + tmp_buffer_pos_; |
358 va_list args; | 358 va_list args; |
359 va_start(args, format); | 359 va_start(args, format); |
360 int result = v8::internal::OS::VSNPrintF(buf, format, args); | 360 int result = v8::internal::VSNPrintF(buf, format, args); |
361 va_end(args); | 361 va_end(args); |
362 tmp_buffer_pos_ += result; | 362 tmp_buffer_pos_ += result; |
363 } | 363 } |
364 | 364 |
365 int DisassemblerIA32::PrintRightOperandHelper( | 365 int DisassemblerIA32::PrintRightOperandHelper( |
366 byte* modrmp, | 366 byte* modrmp, |
367 RegisterNameMapping direct_register_name) { | 367 RegisterNameMapping direct_register_name) { |
368 int mod, regop, rm; | 368 int mod, regop, rm; |
369 get_modrm(*modrmp, &mod, ®op, &rm); | 369 get_modrm(*modrmp, &mod, ®op, &rm); |
370 RegisterNameMapping register_name = (mod == 3) ? direct_register_name : | 370 RegisterNameMapping register_name = (mod == 3) ? direct_register_name : |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 | 1638 |
1639 int instr_len = data - instr; | 1639 int instr_len = data - instr; |
1640 if (instr_len == 0) { | 1640 if (instr_len == 0) { |
1641 printf("%02x", *data); | 1641 printf("%02x", *data); |
1642 } | 1642 } |
1643 ASSERT(instr_len > 0); // Ensure progress. | 1643 ASSERT(instr_len > 0); // Ensure progress. |
1644 | 1644 |
1645 int outp = 0; | 1645 int outp = 0; |
1646 // Instruction bytes. | 1646 // Instruction bytes. |
1647 for (byte* bp = instr; bp < data; bp++) { | 1647 for (byte* bp = instr; bp < data; bp++) { |
1648 outp += v8::internal::OS::SNPrintF(out_buffer + outp, | 1648 outp += v8::internal::SNPrintF(out_buffer + outp, |
1649 "%02x", | 1649 "%02x", |
1650 *bp); | 1650 *bp); |
1651 } | 1651 } |
1652 for (int i = 6 - instr_len; i >= 0; i--) { | 1652 for (int i = 6 - instr_len; i >= 0; i--) { |
1653 outp += v8::internal::OS::SNPrintF(out_buffer + outp, | 1653 outp += v8::internal::SNPrintF(out_buffer + outp, " "); |
1654 " "); | |
1655 } | 1654 } |
1656 | 1655 |
1657 outp += v8::internal::OS::SNPrintF(out_buffer + outp, | 1656 outp += v8::internal::SNPrintF(out_buffer + outp, |
1658 " %s", | 1657 " %s", |
1659 tmp_buffer_.start()); | 1658 tmp_buffer_.start()); |
1660 return instr_len; | 1659 return instr_len; |
1661 } // NOLINT (function is too long) | 1660 } // NOLINT (function is too long) |
1662 | 1661 |
1663 | 1662 |
1664 //------------------------------------------------------------------------------ | 1663 //------------------------------------------------------------------------------ |
1665 | 1664 |
1666 | 1665 |
1667 static const char* cpu_regs[8] = { | 1666 static const char* cpu_regs[8] = { |
1668 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" | 1667 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" |
1669 }; | 1668 }; |
1670 | 1669 |
1671 | 1670 |
1672 static const char* byte_cpu_regs[8] = { | 1671 static const char* byte_cpu_regs[8] = { |
1673 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" | 1672 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" |
1674 }; | 1673 }; |
1675 | 1674 |
1676 | 1675 |
1677 static const char* xmm_regs[8] = { | 1676 static const char* xmm_regs[8] = { |
1678 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" | 1677 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
1679 }; | 1678 }; |
1680 | 1679 |
1681 | 1680 |
1682 const char* NameConverter::NameOfAddress(byte* addr) const { | 1681 const char* NameConverter::NameOfAddress(byte* addr) const { |
1683 v8::internal::OS::SNPrintF(tmp_buffer_, "%p", addr); | 1682 v8::internal::SNPrintF(tmp_buffer_, "%p", addr); |
1684 return tmp_buffer_.start(); | 1683 return tmp_buffer_.start(); |
1685 } | 1684 } |
1686 | 1685 |
1687 | 1686 |
1688 const char* NameConverter::NameOfConstant(byte* addr) const { | 1687 const char* NameConverter::NameOfConstant(byte* addr) const { |
1689 return NameOfAddress(addr); | 1688 return NameOfAddress(addr); |
1690 } | 1689 } |
1691 | 1690 |
1692 | 1691 |
1693 const char* NameConverter::NameOfCPURegister(int reg) const { | 1692 const char* NameConverter::NameOfCPURegister(int reg) const { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 fprintf(f, " "); | 1752 fprintf(f, " "); |
1754 } | 1753 } |
1755 fprintf(f, " %s\n", buffer.start()); | 1754 fprintf(f, " %s\n", buffer.start()); |
1756 } | 1755 } |
1757 } | 1756 } |
1758 | 1757 |
1759 | 1758 |
1760 } // namespace disasm | 1759 } // namespace disasm |
1761 | 1760 |
1762 #endif // V8_TARGET_ARCH_IA32 | 1761 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |