Added the start of the plug-in interface to EmulateInstruction
and implemented it for the EmulateInstructionARM class. llvm-svn: 124563
This commit is contained in:
parent
7d478e0851
commit
b30438aa2b
|
@ -11,7 +11,7 @@
|
||||||
#define lldb_EmulateInstruction_h_
|
#define lldb_EmulateInstruction_h_
|
||||||
|
|
||||||
#include "lldb/lldb-include.h"
|
#include "lldb/lldb-include.h"
|
||||||
|
#include "lldb/Core/PluginInterface.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
/// @class EmulateInstruction EmulateInstruction.h "lldb/Core/EmulateInstruction.h"
|
/// @class EmulateInstruction EmulateInstruction.h "lldb/Core/EmulateInstruction.h"
|
||||||
|
@ -75,9 +75,14 @@
|
||||||
|
|
||||||
namespace lldb_private {
|
namespace lldb_private {
|
||||||
|
|
||||||
class EmulateInstruction
|
class EmulateInstruction :
|
||||||
|
public PluginInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static Disassembler*
|
||||||
|
FindPlugin (const ArchSpec &arch);
|
||||||
|
|
||||||
enum ContextType
|
enum ContextType
|
||||||
{
|
{
|
||||||
eContextInvalid = 0,
|
eContextInvalid = 0,
|
||||||
|
@ -188,6 +193,9 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool
|
||||||
|
SetTargetTriple (const ConstString &triple) = 0;
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
ReadInstruction () = 0;
|
ReadInstruction () = 0;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "EmulateInstructionARM.h"
|
#include "EmulateInstructionARM.h"
|
||||||
#include "ARMDefines.h"
|
#include "ARMDefines.h"
|
||||||
#include "ARMUtils.h"
|
#include "ARMUtils.h"
|
||||||
|
#include "lldb/Core/ConstString.h"
|
||||||
|
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
@ -881,6 +882,44 @@ static ARMOpcode g_thumb_opcodes[] =
|
||||||
static const size_t k_num_arm_opcodes = sizeof(g_arm_opcodes)/sizeof(ARMOpcode);
|
static const size_t k_num_arm_opcodes = sizeof(g_arm_opcodes)/sizeof(ARMOpcode);
|
||||||
static const size_t k_num_thumb_opcodes = sizeof(g_thumb_opcodes)/sizeof(ARMOpcode);
|
static const size_t k_num_thumb_opcodes = sizeof(g_thumb_opcodes)/sizeof(ARMOpcode);
|
||||||
|
|
||||||
|
bool
|
||||||
|
EmulateInstructionARM::SetTargetTriple (const ConstString &triple)
|
||||||
|
{
|
||||||
|
m_arm_isa = 0;
|
||||||
|
const char *triple_cstr = triple.GetCString();
|
||||||
|
if (triple_cstr)
|
||||||
|
{
|
||||||
|
const char *dash = ::strchr (triple_cstr, '-');
|
||||||
|
if (dash)
|
||||||
|
{
|
||||||
|
std::string arch (triple_cstr, dash);
|
||||||
|
const char *arch_cstr = arch.c_str();
|
||||||
|
if (strcasecmp(arch_cstr, "armv4t") == 0)
|
||||||
|
m_arm_isa = ARMv4T;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv4") == 0)
|
||||||
|
m_arm_isa = ARMv4;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv5tej") == 0)
|
||||||
|
m_arm_isa = ARMv5TEJ;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv5te") == 0)
|
||||||
|
m_arm_isa = ARMv5TE;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv5t") == 0)
|
||||||
|
m_arm_isa = ARMv5T;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv6k") == 0)
|
||||||
|
m_arm_isa = ARMv6K;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv6") == 0)
|
||||||
|
m_arm_isa = ARMv6;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv6t2") == 0)
|
||||||
|
m_arm_isa = ARMv6T2;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv7") == 0)
|
||||||
|
m_arm_isa = ARMv7;
|
||||||
|
else if (strcasecmp(arch_cstr, "armv8") == 0)
|
||||||
|
m_arm_isa = ARMv8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m_arm_isa != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EmulateInstructionARM::ReadInstruction ()
|
EmulateInstructionARM::ReadInstruction ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,11 +13,51 @@
|
||||||
#include "EmulateInstruction.h"
|
#include "EmulateInstruction.h"
|
||||||
#include "ARM_DWARF_Registers.h"
|
#include "ARM_DWARF_Registers.h"
|
||||||
|
|
||||||
|
#include "lldb/Core/Error.h"
|
||||||
|
|
||||||
namespace lldb_private {
|
namespace lldb_private {
|
||||||
|
|
||||||
class EmulateInstructionARM : public EmulateInstruction
|
class EmulateInstructionARM : public EmulateInstruction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual const char *
|
||||||
|
GetPluginName()
|
||||||
|
{
|
||||||
|
return "EmulateInstructionARM";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual const char *
|
||||||
|
GetShortPluginName()
|
||||||
|
{
|
||||||
|
return "lldb.emulate-instruction.arm";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual uint32_t
|
||||||
|
GetPluginVersion()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
GetPluginCommandHelp (const char *command, Stream *strm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual lldb_private::Error
|
||||||
|
ExecutePluginCommand (Args &command, Stream *strm)
|
||||||
|
{
|
||||||
|
Error error;
|
||||||
|
error.SetErrorString("no plug-in commands are supported");
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Log *
|
||||||
|
EnablePluginLogging (Stream *strm, Args &command)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
enum Mode
|
enum Mode
|
||||||
{
|
{
|
||||||
eModeInvalid,
|
eModeInvalid,
|
||||||
|
@ -37,9 +77,15 @@ public:
|
||||||
write_mem_callback,
|
write_mem_callback,
|
||||||
read_reg_callback,
|
read_reg_callback,
|
||||||
write_reg_callback),
|
write_reg_callback),
|
||||||
m_inst_mode (eModeInvalid)
|
m_arm_isa (0),
|
||||||
|
m_inst_mode (eModeInvalid),
|
||||||
|
m_inst_cpsr (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool
|
||||||
|
SetTargetTriple (const ConstString &triple);
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
ReadInstruction ();
|
ReadInstruction ();
|
||||||
|
@ -54,7 +100,7 @@ public:
|
||||||
CurrentCond ();
|
CurrentCond ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
uint32_t m_arm_isa;
|
||||||
Mode m_inst_mode;
|
Mode m_inst_mode;
|
||||||
uint32_t m_inst_cpsr;
|
uint32_t m_inst_cpsr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue