Remove trailing spaces
llvm-svn: 206278
This commit is contained in:
parent
5ac35ae6f7
commit
a3e4cebd96
@ -48,7 +48,7 @@ class InstructionLLVMC : public lldb_private::Instruction
|
||||
{
|
||||
public:
|
||||
InstructionLLVMC (DisassemblerLLVMC &disasm,
|
||||
const lldb_private::Address &address,
|
||||
const lldb_private::Address &address,
|
||||
AddressClass addr_class) :
|
||||
Instruction (address, addr_class),
|
||||
m_disasm_sp (disasm.shared_from_this()),
|
||||
@ -57,12 +57,12 @@ public:
|
||||
m_using_file_addr (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual
|
||||
~InstructionLLVMC ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool
|
||||
DoesBranch ()
|
||||
{
|
||||
@ -99,7 +99,7 @@ public:
|
||||
}
|
||||
return m_does_branch == eLazyBoolYes;
|
||||
}
|
||||
|
||||
|
||||
DisassemblerLLVMC::LLVMCDisassembler *
|
||||
GetDisasmToUse (bool &is_alternate_isa)
|
||||
{
|
||||
@ -108,7 +108,7 @@ public:
|
||||
if (llvm_disasm.m_alternate_disasm_ap.get() != NULL)
|
||||
{
|
||||
const AddressClass address_class = GetAddressClass ();
|
||||
|
||||
|
||||
if (address_class == eAddressClassCodeAlternateISA)
|
||||
{
|
||||
is_alternate_isa = true;
|
||||
@ -117,7 +117,7 @@ public:
|
||||
}
|
||||
return llvm_disasm.m_disasm_ap.get();
|
||||
}
|
||||
|
||||
|
||||
virtual size_t
|
||||
Decode (const lldb_private::Disassembler &disassembler,
|
||||
const lldb_private::DataExtractor &data,
|
||||
@ -129,7 +129,7 @@ public:
|
||||
DisassemblerLLVMC &llvm_disasm = GetDisassemblerLLVMC();
|
||||
const ArchSpec &arch = llvm_disasm.GetArchitecture();
|
||||
const lldb::ByteOrder byte_order = data.GetByteOrder();
|
||||
|
||||
|
||||
const uint32_t min_op_byte_size = arch.GetMinimumOpcodeByteSize();
|
||||
const uint32_t max_op_byte_size = arch.GetMaximumOpcodeByteSize();
|
||||
if (min_op_byte_size == max_op_byte_size)
|
||||
@ -170,7 +170,7 @@ public:
|
||||
{
|
||||
bool is_alternate_isa = false;
|
||||
DisassemblerLLVMC::LLVMCDisassembler *mc_disasm_ptr = GetDisasmToUse (is_alternate_isa);
|
||||
|
||||
|
||||
const llvm::Triple::ArchType machine = arch.GetMachine();
|
||||
if (machine == llvm::Triple::arm || machine == llvm::Triple::thumb)
|
||||
{
|
||||
@ -204,7 +204,7 @@ public:
|
||||
const size_t opcode_data_len = data.BytesLeft(data_offset);
|
||||
const addr_t pc = m_address.GetFileAddress();
|
||||
llvm::MCInst inst;
|
||||
|
||||
|
||||
llvm_disasm.Lock(this, NULL);
|
||||
const size_t inst_size = mc_disasm_ptr->GetMCInst(opcode_data,
|
||||
opcode_data_len,
|
||||
@ -222,7 +222,7 @@ public:
|
||||
}
|
||||
return m_opcode.GetByteSize();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AppendComment (std::string &description)
|
||||
{
|
||||
@ -234,7 +234,7 @@ public:
|
||||
m_comment.append(description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void
|
||||
CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx)
|
||||
{
|
||||
@ -244,19 +244,19 @@ public:
|
||||
if (m_opcode.GetData(data))
|
||||
{
|
||||
char out_string[512];
|
||||
|
||||
|
||||
DisassemblerLLVMC &llvm_disasm = GetDisassemblerLLVMC();
|
||||
|
||||
DisassemblerLLVMC::LLVMCDisassembler *mc_disasm_ptr;
|
||||
|
||||
|
||||
if (address_class == eAddressClassCodeAlternateISA)
|
||||
mc_disasm_ptr = llvm_disasm.m_alternate_disasm_ap.get();
|
||||
else
|
||||
mc_disasm_ptr = llvm_disasm.m_disasm_ap.get();
|
||||
|
||||
|
||||
lldb::addr_t pc = m_address.GetFileAddress();
|
||||
m_using_file_addr = true;
|
||||
|
||||
|
||||
const bool data_from_file = GetDisassemblerLLVMC().m_data_from_file;
|
||||
bool use_hex_immediates = true;
|
||||
Disassembler::HexImmediateStyle hex_style = Disassembler::eHexStyleC;
|
||||
@ -280,9 +280,9 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
llvm_disasm.Lock(this, exe_ctx);
|
||||
|
||||
|
||||
const uint8_t *opcode_data = data.GetDataStart();
|
||||
const size_t opcode_data_len = data.GetByteSize();
|
||||
llvm::MCInst inst;
|
||||
@ -298,7 +298,7 @@ public:
|
||||
}
|
||||
|
||||
llvm_disasm.Unlock();
|
||||
|
||||
|
||||
if (inst_size == 0)
|
||||
{
|
||||
m_comment.assign ("unknown opcode");
|
||||
@ -371,11 +371,11 @@ public:
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static RegularExpression s_regex("[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
|
||||
|
||||
|
||||
RegularExpression::Match matches(3);
|
||||
|
||||
|
||||
if (s_regex.Execute(out_string, &matches))
|
||||
{
|
||||
matches.GetMatchAtIndex(out_string, 1, m_opcode_name);
|
||||
@ -383,13 +383,13 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
IsValid () const
|
||||
{
|
||||
return m_is_valid;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
UsingFileAddress() const
|
||||
{
|
||||
@ -400,14 +400,14 @@ public:
|
||||
{
|
||||
return m_opcode.GetByteSize();
|
||||
}
|
||||
|
||||
|
||||
DisassemblerLLVMC &
|
||||
GetDisassemblerLLVMC ()
|
||||
{
|
||||
return *(DisassemblerLLVMC *)m_disasm_sp.get();
|
||||
}
|
||||
protected:
|
||||
|
||||
|
||||
DisassemblerSP m_disasm_sp; // for ownership
|
||||
LazyBool m_does_branch;
|
||||
bool m_is_valid;
|
||||
@ -426,15 +426,15 @@ DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, uns
|
||||
m_is_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_instr_info_ap.reset(curr_target->createMCInstrInfo());
|
||||
m_reg_info_ap.reset (curr_target->createMCRegInfo(triple));
|
||||
|
||||
|
||||
std::string features_str;
|
||||
|
||||
m_subtarget_info_ap.reset(curr_target->createMCSubtargetInfo(triple, "",
|
||||
features_str));
|
||||
|
||||
|
||||
std::unique_ptr<llvm::MCRegisterInfo> reg_info(curr_target->createMCRegInfo(triple));
|
||||
m_asm_info_ap.reset(curr_target->createMCAsmInfo(*reg_info, triple));
|
||||
|
||||
@ -443,9 +443,9 @@ DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, uns
|
||||
m_is_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_context_ap.reset(new llvm::MCContext(m_asm_info_ap.get(), m_reg_info_ap.get(), 0));
|
||||
|
||||
|
||||
m_disasm_ap.reset(curr_target->createMCDisassembler(*m_subtarget_info_ap.get(), *m_context_ap.get()));
|
||||
if (m_disasm_ap.get() && m_context_ap.get())
|
||||
{
|
||||
@ -457,7 +457,7 @@ DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, uns
|
||||
}
|
||||
m_disasm_ap->setSymbolizer(std::unique_ptr<llvm::MCSymbolizer>(new llvm::MCExternalSymbolizer(*m_context_ap.get(),std::move(RelInfo),NULL,DisassemblerLLVMC::SymbolLookupCallback,(void *) &owner)));
|
||||
|
||||
|
||||
|
||||
unsigned asm_printer_variant;
|
||||
if (flavor == ~0U)
|
||||
asm_printer_variant = m_asm_info_ap->getAssemblerDialect();
|
||||
@ -465,7 +465,7 @@ DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, uns
|
||||
{
|
||||
asm_printer_variant = flavor;
|
||||
}
|
||||
|
||||
|
||||
m_instr_printer_ap.reset(curr_target->createMCInstPrinter(asm_printer_variant,
|
||||
*m_asm_info_ap.get(),
|
||||
*m_instr_info_ap.get(),
|
||||
@ -494,7 +494,7 @@ namespace {
|
||||
public:
|
||||
LLDBDisasmMemoryObject(const uint8_t *bytes, uint64_t size, uint64_t basePC) :
|
||||
m_bytes(bytes), m_size(size), m_base_PC(basePC) {}
|
||||
|
||||
|
||||
uint64_t getBase() const { return m_base_PC; }
|
||||
uint64_t getExtent() const { return m_size; }
|
||||
|
||||
@ -542,7 +542,7 @@ DisassemblerLLVMC::LLVMCDisassembler::PrintMCInst (llvm::MCInst &mc_inst,
|
||||
const size_t output_size = std::min(dst_len - 1, inst_string.size());
|
||||
std::memcpy(dst, inst_string.data(), output_size);
|
||||
dst[output_size] = '\0';
|
||||
|
||||
|
||||
return output_size;
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ DisassemblerLLVMC::FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, c
|
||||
llvm::Triple triple = arch.GetTriple();
|
||||
if (flavor == NULL || strcmp (flavor, "default") == 0)
|
||||
return true;
|
||||
|
||||
|
||||
if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64)
|
||||
{
|
||||
if (strcmp (flavor, "intel") == 0 || strcmp (flavor, "att") == 0)
|
||||
@ -580,7 +580,7 @@ DisassemblerLLVMC::FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, c
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Disassembler *
|
||||
DisassemblerLLVMC::CreateInstance (const ArchSpec &arch, const char *flavor)
|
||||
@ -588,7 +588,7 @@ DisassemblerLLVMC::CreateInstance (const ArchSpec &arch, const char *flavor)
|
||||
if (arch.GetTriple().getArch() != llvm::Triple::UnknownArch)
|
||||
{
|
||||
std::unique_ptr<DisassemblerLLVMC> disasm_ap (new DisassemblerLLVMC(arch, flavor));
|
||||
|
||||
|
||||
if (disasm_ap.get() && disasm_ap->IsValid())
|
||||
return disasm_ap.release();
|
||||
}
|
||||
@ -605,10 +605,10 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
|
||||
{
|
||||
m_flavor.assign("default");
|
||||
}
|
||||
|
||||
|
||||
const char *triple = arch.GetTriple().getTriple().c_str();
|
||||
unsigned flavor = ~0U;
|
||||
|
||||
|
||||
// So far the only supported flavor is "intel" on x86. The base class will set this
|
||||
// correctly coming in.
|
||||
if (arch.GetTriple().getArch() == llvm::Triple::x86
|
||||
@ -623,7 +623,7 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
|
||||
flavor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ArchSpec thumb_arch(arch);
|
||||
if (arch.GetTriple().getArch() == llvm::Triple::arm)
|
||||
{
|
||||
@ -640,15 +640,15 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
|
||||
}
|
||||
thumb_arch.GetTriple().setArchName(llvm::StringRef(thumb_arch_name.c_str()));
|
||||
}
|
||||
|
||||
// Cortex-M3 devices (e.g. armv7m) can only execute thumb (T2) instructions,
|
||||
|
||||
// Cortex-M3 devices (e.g. armv7m) can only execute thumb (T2) instructions,
|
||||
// so hardcode the primary disassembler to thumb mode. Same for Cortex-M4 (armv7em).
|
||||
//
|
||||
// Handle the Cortex-M0 (armv6m) the same; the ISA is a subset of the T and T32
|
||||
// instructions defined in ARMv7-A.
|
||||
// instructions defined in ARMv7-A.
|
||||
|
||||
if (arch.GetTriple().getArch() == llvm::Triple::arm
|
||||
&& (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
|
||||
&& (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
|
||||
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
|
||||
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
|
||||
{
|
||||
@ -690,33 +690,33 @@ DisassemblerLLVMC::DecodeInstructions (const Address &base_addr,
|
||||
{
|
||||
if (!append)
|
||||
m_instruction_list.Clear();
|
||||
|
||||
|
||||
if (!IsValid())
|
||||
return 0;
|
||||
|
||||
|
||||
m_data_from_file = data_from_file;
|
||||
uint32_t data_cursor = data_offset;
|
||||
const size_t data_byte_size = data.GetByteSize();
|
||||
uint32_t instructions_parsed = 0;
|
||||
Address inst_addr(base_addr);
|
||||
|
||||
|
||||
while (data_cursor < data_byte_size && instructions_parsed < num_instructions)
|
||||
{
|
||||
|
||||
|
||||
AddressClass address_class = eAddressClassCode;
|
||||
|
||||
|
||||
if (m_alternate_disasm_ap.get() != NULL)
|
||||
address_class = inst_addr.GetAddressClass ();
|
||||
|
||||
|
||||
InstructionSP inst_sp(new InstructionLLVMC(*this,
|
||||
inst_addr,
|
||||
inst_addr,
|
||||
address_class));
|
||||
|
||||
|
||||
if (!inst_sp)
|
||||
break;
|
||||
|
||||
|
||||
uint32_t inst_size = inst_sp->Decode(*this, data, data_cursor);
|
||||
|
||||
|
||||
if (inst_size == 0)
|
||||
break;
|
||||
|
||||
@ -725,7 +725,7 @@ DisassemblerLLVMC::DecodeInstructions (const Address &base_addr,
|
||||
inst_addr.Slide(inst_size);
|
||||
instructions_parsed++;
|
||||
}
|
||||
|
||||
|
||||
return data_cursor - data_offset;
|
||||
}
|
||||
|
||||
@ -735,7 +735,7 @@ DisassemblerLLVMC::Initialize()
|
||||
PluginManager::RegisterPlugin (GetPluginNameStatic(),
|
||||
"Disassembler that uses LLVM MC to disassemble i386, x86_64, ARM, and ARM64.",
|
||||
CreateInstance);
|
||||
|
||||
|
||||
llvm::InitializeAllTargetInfos();
|
||||
llvm::InitializeAllTargetMCs();
|
||||
llvm::InitializeAllAsmParsers();
|
||||
@ -807,7 +807,7 @@ const char *DisassemblerLLVMC::SymbolLookup (uint64_t value,
|
||||
if (*type_ptr)
|
||||
{
|
||||
if (m_exe_ctx && m_inst)
|
||||
{
|
||||
{
|
||||
//std::string remove_this_prior_to_checkin;
|
||||
Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : NULL;
|
||||
Address value_so_addr;
|
||||
@ -821,16 +821,16 @@ const char *DisassemblerLLVMC::SymbolLookup (uint64_t value,
|
||||
{
|
||||
target->GetSectionLoadList().ResolveLoadAddress(value, value_so_addr);
|
||||
}
|
||||
|
||||
|
||||
if (value_so_addr.IsValid() && value_so_addr.GetSection())
|
||||
{
|
||||
StreamString ss;
|
||||
|
||||
|
||||
value_so_addr.Dump (&ss,
|
||||
target,
|
||||
Address::DumpStyleResolvedDescriptionNoModule,
|
||||
Address::DumpStyleSectionNameOffset);
|
||||
|
||||
|
||||
if (!ss.GetString().empty())
|
||||
{
|
||||
m_inst->AppendComment(ss.GetString());
|
||||
@ -858,4 +858,3 @@ DisassemblerLLVMC::GetPluginVersion()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -42,9 +42,9 @@ class DisassemblerLLVMC : public lldb_private::Disassembler
|
||||
{
|
||||
public:
|
||||
LLVMCDisassembler (const char *triple, unsigned flavor, DisassemblerLLVMC &owner);
|
||||
|
||||
|
||||
~LLVMCDisassembler();
|
||||
|
||||
|
||||
uint64_t GetMCInst (const uint8_t *opcode_data, size_t opcode_data_len, lldb::addr_t pc, llvm::MCInst &mc_inst);
|
||||
uint64_t PrintMCInst (llvm::MCInst &mc_inst, char *output_buffer, size_t out_buffer_len);
|
||||
void SetStyle (bool use_hex_immed, HexImmediateStyle hex_style);
|
||||
@ -53,7 +53,7 @@ class DisassemblerLLVMC : public lldb_private::Disassembler
|
||||
{
|
||||
return m_is_valid;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
bool m_is_valid;
|
||||
std::unique_ptr<llvm::MCContext> m_context_ap;
|
||||
@ -71,21 +71,21 @@ public:
|
||||
//------------------------------------------------------------------
|
||||
static void
|
||||
Initialize();
|
||||
|
||||
|
||||
static void
|
||||
Terminate();
|
||||
|
||||
|
||||
static lldb_private::ConstString
|
||||
GetPluginNameStatic();
|
||||
|
||||
|
||||
static lldb_private::Disassembler *
|
||||
CreateInstance(const lldb_private::ArchSpec &arch, const char *flavor);
|
||||
|
||||
|
||||
DisassemblerLLVMC(const lldb_private::ArchSpec &arch, const char *flavor /* = NULL */);
|
||||
|
||||
|
||||
virtual
|
||||
~DisassemblerLLVMC();
|
||||
|
||||
|
||||
virtual size_t
|
||||
DecodeInstructions (const lldb_private::Address &base_addr,
|
||||
const lldb_private::DataExtractor& data,
|
||||
@ -93,72 +93,72 @@ public:
|
||||
size_t num_instructions,
|
||||
bool append,
|
||||
bool data_from_file);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// PluginInterface protocol
|
||||
//------------------------------------------------------------------
|
||||
virtual lldb_private::ConstString
|
||||
GetPluginName();
|
||||
|
||||
|
||||
virtual uint32_t
|
||||
GetPluginVersion();
|
||||
|
||||
|
||||
protected:
|
||||
friend class InstructionLLVMC;
|
||||
|
||||
|
||||
virtual bool
|
||||
FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor);
|
||||
|
||||
|
||||
bool
|
||||
IsValid()
|
||||
{
|
||||
return (m_disasm_ap.get() != NULL && m_disasm_ap->IsValid());
|
||||
}
|
||||
|
||||
|
||||
int OpInfo(uint64_t PC,
|
||||
uint64_t Offset,
|
||||
uint64_t Size,
|
||||
int TagType,
|
||||
void *TagBug);
|
||||
|
||||
|
||||
const char *SymbolLookup (uint64_t ReferenceValue,
|
||||
uint64_t *ReferenceType,
|
||||
uint64_t ReferencePC,
|
||||
const char **ReferenceName);
|
||||
|
||||
|
||||
static int OpInfoCallback (void *DisInfo,
|
||||
uint64_t PC,
|
||||
uint64_t Offset,
|
||||
uint64_t Size,
|
||||
int TagType,
|
||||
void *TagBug);
|
||||
|
||||
|
||||
static const char *SymbolLookupCallback(void *DisInfo,
|
||||
uint64_t ReferenceValue,
|
||||
uint64_t *ReferenceType,
|
||||
uint64_t ReferencePC,
|
||||
const char **ReferenceName);
|
||||
|
||||
void Lock(InstructionLLVMC *inst,
|
||||
|
||||
void Lock(InstructionLLVMC *inst,
|
||||
const lldb_private::ExecutionContext *exe_ctx)
|
||||
{
|
||||
m_mutex.Lock();
|
||||
m_inst = inst;
|
||||
m_exe_ctx = exe_ctx;
|
||||
}
|
||||
|
||||
|
||||
void Unlock()
|
||||
{
|
||||
m_inst = NULL;
|
||||
m_exe_ctx = NULL;
|
||||
m_mutex.Unlock();
|
||||
}
|
||||
|
||||
|
||||
const lldb_private::ExecutionContext *m_exe_ctx;
|
||||
InstructionLLVMC *m_inst;
|
||||
lldb_private::Mutex m_mutex;
|
||||
bool m_data_from_file;
|
||||
|
||||
|
||||
std::unique_ptr<LLVMCDisassembler> m_disasm_ap;
|
||||
std::unique_ptr<LLVMCDisassembler> m_alternate_disasm_ap;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user