Fixed the DisassemblerLLVMC disassembler to parse more efficiently instead of parsing opcodes over and over. The InstructionLLVMC class now only reads the opcode in the InstructionLLVMC::Decode function. This can be done very efficiently for ARM and architectures that have fixed opcode sizes. For x64 it still calls the disassembler to get the byte size. Moved the lldb_private::Instruction::Dump(...) function up into the lldb_private::Instruction class and it now uses the function that gets the mnemonic, operandes and comments so that all disassembly is using the same code. Added StreamString::FillLastLineToColumn() to allow filling a line up to a column with a character (which is used by the lldb_private::Instruction::Dump(...) function). Modified the Opcode::GetData() fucntion to "do the right thing" for thumb instructions. llvm-svn: 156532
106 lines
2.7 KiB
C++
106 lines
2.7 KiB
C++
//===-- DisassemblerLLVM.h --------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef liblldb_DisassemblerLLVM_h_
|
|
#define liblldb_DisassemblerLLVM_h_
|
|
|
|
|
|
#include "llvm-c/EnhancedDisassembly.h"
|
|
|
|
#include "lldb/Core/Disassembler.h"
|
|
#include "lldb/Host/Mutex.h"
|
|
|
|
class InstructionLLVM : public lldb_private::Instruction
|
|
{
|
|
public:
|
|
InstructionLLVM (const lldb_private::Address &addr,
|
|
lldb::AddressClass addr_class,
|
|
EDDisassemblerRef disassembler,
|
|
llvm::Triple::ArchType arch_type);
|
|
|
|
virtual
|
|
~InstructionLLVM();
|
|
|
|
virtual bool
|
|
DoesBranch () const;
|
|
|
|
virtual size_t
|
|
Decode (const lldb_private::Disassembler &disassembler,
|
|
const lldb_private::DataExtractor &data,
|
|
uint32_t data_offset);
|
|
|
|
virtual void
|
|
CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext* exe_ctx);
|
|
|
|
protected:
|
|
EDDisassemblerRef m_disassembler;
|
|
EDInstRef m_inst;
|
|
llvm::Triple::ArchType m_arch_type;
|
|
};
|
|
|
|
|
|
class DisassemblerLLVM : public lldb_private::Disassembler
|
|
{
|
|
public:
|
|
//------------------------------------------------------------------
|
|
// Static Functions
|
|
//------------------------------------------------------------------
|
|
static void
|
|
Initialize();
|
|
|
|
static void
|
|
Terminate();
|
|
|
|
static const char *
|
|
GetPluginNameStatic();
|
|
|
|
static const char *
|
|
GetPluginDescriptionStatic();
|
|
|
|
static lldb_private::Disassembler *
|
|
CreateInstance(const lldb_private::ArchSpec &arch);
|
|
|
|
|
|
DisassemblerLLVM(const lldb_private::ArchSpec &arch);
|
|
|
|
virtual
|
|
~DisassemblerLLVM();
|
|
|
|
size_t
|
|
DecodeInstructions (const lldb_private::Address &base_addr,
|
|
const lldb_private::DataExtractor& data,
|
|
uint32_t data_offset,
|
|
uint32_t num_instructions,
|
|
bool append);
|
|
|
|
//------------------------------------------------------------------
|
|
// PluginInterface protocol
|
|
//------------------------------------------------------------------
|
|
virtual const char *
|
|
GetPluginName();
|
|
|
|
virtual const char *
|
|
GetShortPluginName();
|
|
|
|
virtual uint32_t
|
|
GetPluginVersion();
|
|
|
|
protected:
|
|
bool
|
|
IsValid() const
|
|
{
|
|
return m_disassembler != NULL;
|
|
}
|
|
|
|
EDDisassemblerRef m_disassembler;
|
|
EDDisassemblerRef m_disassembler_thumb;
|
|
};
|
|
|
|
#endif // liblldb_DisassemblerLLVM_h_
|