V8 Project
disasm.h
Go to the documentation of this file.
1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_DISASM_H_
6 #define V8_DISASM_H_
7 
8 namespace disasm {
9 
10 typedef unsigned char byte;
11 
12 // Interface and default implementation for converting addresses and
13 // register-numbers to text. The default implementation is machine
14 // specific.
16  public:
17  virtual ~NameConverter() {}
18  virtual const char* NameOfCPURegister(int reg) const;
19  virtual const char* NameOfByteCPURegister(int reg) const;
20  virtual const char* NameOfXMMRegister(int reg) const;
21  virtual const char* NameOfAddress(byte* addr) const;
22  virtual const char* NameOfConstant(byte* addr) const;
23  virtual const char* NameInCode(byte* addr) const;
24 
25  protected:
27 };
28 
29 
30 // A generic Disassembler interface
31 class Disassembler {
32  public:
33  // Caller deallocates converter.
34  explicit Disassembler(const NameConverter& converter);
35 
36  virtual ~Disassembler();
37 
38  // Writes one disassembled instruction into 'buffer' (0-terminated).
39  // Returns the length of the disassembled machine instruction in bytes.
40  int InstructionDecode(v8::internal::Vector<char> buffer, byte* instruction);
41 
42  // Returns -1 if instruction does not mark the beginning of a constant pool,
43  // or the number of entries in the constant pool beginning here.
44  int ConstantPoolSizeAt(byte* instruction);
45 
46  // Write disassembly into specified file 'f' using specified NameConverter
47  // (see constructor).
48  static void Disassemble(FILE* f, byte* begin, byte* end);
49  private:
51 
53 };
54 
55 } // namespace disasm
56 
57 #endif // V8_DISASM_H_
Disassembler(const NameConverter &converter)
static void Disassemble(FILE *f, byte *begin, byte *end)
DISALLOW_IMPLICIT_CONSTRUCTORS(Disassembler)
int InstructionDecode(v8::internal::Vector< char > buffer, byte *instruction)
const NameConverter & converter_
Definition: disasm.h:50
int ConstantPoolSizeAt(byte *instruction)
v8::internal::EmbeddedVector< char, 128 > tmp_buffer_
Definition: disasm.h:26
virtual const char * NameInCode(byte *addr) const
virtual const char * NameOfByteCPURegister(int reg) const
virtual const char * NameOfXMMRegister(int reg) const
virtual const char * NameOfAddress(byte *addr) const
virtual ~NameConverter()
Definition: disasm.h:17
virtual const char * NameOfCPURegister(int reg) const
virtual const char * NameOfConstant(byte *addr) const
Definition: disasm.h:8
unsigned char byte
Definition: disasm.h:10