2008-09-09 20:08:45 +00:00
|
|
|
// Copyright 2007-2008 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_DISASM_H_
|
|
|
|
#define V8_DISASM_H_
|
|
|
|
|
|
|
|
namespace disasm {
|
|
|
|
|
|
|
|
typedef unsigned char byte;
|
|
|
|
|
|
|
|
// Interface and default implementation for converting addresses and
|
|
|
|
// register-numbers to text. The default implementation is machine
|
|
|
|
// specific.
|
|
|
|
class NameConverter {
|
|
|
|
public:
|
|
|
|
virtual ~NameConverter() {}
|
|
|
|
virtual const char* NameOfCPURegister(int reg) const;
|
2009-02-27 13:00:32 +00:00
|
|
|
virtual const char* NameOfByteCPURegister(int reg) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual const char* NameOfXMMRegister(int reg) const;
|
|
|
|
virtual const char* NameOfAddress(byte* addr) const;
|
|
|
|
virtual const char* NameOfConstant(byte* addr) const;
|
|
|
|
virtual const char* NameInCode(byte* addr) const;
|
2011-03-18 20:35:07 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
v8::internal::EmbeddedVector<char, 128> tmp_buffer_;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// A generic Disassembler interface
|
|
|
|
class Disassembler {
|
|
|
|
public:
|
|
|
|
// Caller deallocates converter.
|
|
|
|
explicit Disassembler(const NameConverter& converter);
|
|
|
|
|
|
|
|
virtual ~Disassembler();
|
|
|
|
|
|
|
|
// Writes one disassembled instruction into 'buffer' (0-terminated).
|
|
|
|
// Returns the length of the disassembled machine instruction in bytes.
|
2008-09-11 14:34:48 +00:00
|
|
|
int InstructionDecode(v8::internal::Vector<char> buffer, byte* instruction);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
// Returns -1 if instruction does not mark the beginning of a constant pool,
|
|
|
|
// or the number of entries in the constant pool beginning here.
|
|
|
|
int ConstantPoolSizeAt(byte* instruction);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Write disassembly into specified file 'f' using specified NameConverter
|
|
|
|
// (see constructor).
|
|
|
|
static void Disassemble(FILE* f, byte* begin, byte* end);
|
|
|
|
private:
|
|
|
|
const NameConverter& converter_;
|
2008-11-05 19:18:10 +00:00
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Disassembler);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace disasm
|
|
|
|
|
|
|
|
#endif // V8_DISASM_H_
|