OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 | 1931 |
1932 } // namespace internal | 1932 } // namespace internal |
1933 } // namespace v8 | 1933 } // namespace v8 |
1934 | 1934 |
1935 | 1935 |
1936 //------------------------------------------------------------------------------ | 1936 //------------------------------------------------------------------------------ |
1937 | 1937 |
1938 namespace disasm { | 1938 namespace disasm { |
1939 | 1939 |
1940 const char* NameConverter::NameOfAddress(byte* addr) const { | 1940 const char* NameConverter::NameOfAddress(byte* addr) const { |
1941 v8::internal::SNPrintF(tmp_buffer_, "%p", addr); | 1941 v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr)); |
1942 return tmp_buffer_.start(); | 1942 return tmp_buffer_.start(); |
1943 } | 1943 } |
1944 | 1944 |
1945 | 1945 |
1946 const char* NameConverter::NameOfConstant(byte* addr) const { | 1946 const char* NameConverter::NameOfConstant(byte* addr) const { |
1947 return NameOfAddress(addr); | 1947 return NameOfAddress(addr); |
1948 } | 1948 } |
1949 | 1949 |
1950 | 1950 |
1951 const char* NameConverter::NameOfCPURegister(int reg) const { | 1951 const char* NameConverter::NameOfCPURegister(int reg) const { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 | 1994 |
1995 | 1995 |
1996 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) { | 1996 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) { |
1997 NameConverter converter; | 1997 NameConverter converter; |
1998 Disassembler d(converter); | 1998 Disassembler d(converter); |
1999 for (byte* pc = begin; pc < end;) { | 1999 for (byte* pc = begin; pc < end;) { |
2000 v8::internal::EmbeddedVector<char, 128> buffer; | 2000 v8::internal::EmbeddedVector<char, 128> buffer; |
2001 buffer[0] = '\0'; | 2001 buffer[0] = '\0'; |
2002 byte* prev_pc = pc; | 2002 byte* prev_pc = pc; |
2003 pc += d.InstructionDecode(buffer, pc); | 2003 pc += d.InstructionDecode(buffer, pc); |
2004 v8::internal::PrintF(f, "%p %08x %s\n", | 2004 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), |
2005 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 2005 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
2006 } | 2006 } |
2007 } | 2007 } |
2008 | 2008 |
2009 | 2009 |
2010 #undef UNSUPPORTED | 2010 #undef UNSUPPORTED |
2011 | 2011 |
2012 } // namespace disasm | 2012 } // namespace disasm |
2013 | 2013 |
2014 #endif // V8_TARGET_ARCH_MIPS64 | 2014 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |