8fa509d311
Currently the disassembler tests continue on unimplemented instructions, fix to abort instead as most bugs in the disassemblers will appear as unimplemented instructions. - Localize testing disassembler method to abort on unimplemented - Fix failing x64 disassembler tests Change-Id: I703cca9709c528327ec381d05a78cf3314ea4fa9 Reviewed-on: https://chromium-review.googlesource.com/907489 Reviewed-by: Ben Titzer <titzer@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Deepti Gandluri <gdeepti@chromium.org> Cr-Commit-Position: refs/heads/master@{#51162}
68 lines
2.1 KiB
C++
68 lines
2.1 KiB
C++
// Copyright 2007-2008 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef V8_DISASM_H_
|
|
#define V8_DISASM_H_
|
|
|
|
#include "src/utils.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;
|
|
virtual const char* NameOfByteCPURegister(int reg) const;
|
|
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;
|
|
|
|
protected:
|
|
v8::internal::EmbeddedVector<char, 128> tmp_buffer_;
|
|
};
|
|
|
|
|
|
// 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.
|
|
int InstructionDecode(v8::internal::Vector<char> buffer, byte* instruction);
|
|
|
|
// Disassemblers on ia32/x64 need a separate method for testing, as
|
|
// instruction decode method above continues on unimplemented opcodes, and
|
|
// does not test the disassemblers. Basic functionality of the method remains
|
|
// the same.
|
|
int InstructionDecodeForTesting(v8::internal::Vector<char> buffer,
|
|
byte* instruction);
|
|
|
|
// 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);
|
|
|
|
// Write disassembly into specified file 'f' using specified NameConverter
|
|
// (see constructor).
|
|
static void Disassemble(FILE* f, byte* begin, byte* end);
|
|
|
|
private:
|
|
const NameConverter& converter_;
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Disassembler);
|
|
};
|
|
|
|
} // namespace disasm
|
|
|
|
#endif // V8_DISASM_H_
|