mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 12:25:46 +08:00
plugin by name on the command line for when there is more than one disassembler plugin. Taught the Opcode class to dump itself so that "disassembler -b" will dump the bytes correctly for each opcode type. Modified all places that were passing the opcode bytes buffer in so that the bytes could be displayed to just pass in a bool that indicates if we should dump the opcode bytes since the opcode now lives inside llvm_private::Instruction. llvm-svn: 128290
110 lines
2.2 KiB
C++
110 lines
2.2 KiB
C++
//===-- SBInstruction.cpp ---------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/API/SBInstruction.h"
|
|
|
|
#include "lldb/API/SBAddress.h"
|
|
#include "lldb/API/SBInstruction.h"
|
|
#include "lldb/API/SBStream.h"
|
|
|
|
#include "lldb/Core/Disassembler.h"
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
SBInstruction::SBInstruction ()
|
|
{
|
|
}
|
|
|
|
SBInstruction::SBInstruction (const lldb::InstructionSP& inst_sp) :
|
|
m_opaque_sp (inst_sp)
|
|
{
|
|
}
|
|
|
|
SBInstruction::SBInstruction(const SBInstruction &rhs) :
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
|
{
|
|
}
|
|
|
|
const SBInstruction &
|
|
SBInstruction::operator = (const SBInstruction &rhs)
|
|
{
|
|
if (this != &rhs)
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
return *this;
|
|
}
|
|
|
|
SBInstruction::~SBInstruction ()
|
|
{
|
|
}
|
|
|
|
bool
|
|
SBInstruction::IsValid()
|
|
{
|
|
return (m_opaque_sp.get() != NULL);
|
|
}
|
|
|
|
SBAddress
|
|
SBInstruction::GetAddress()
|
|
{
|
|
SBAddress sb_addr;
|
|
if (m_opaque_sp && m_opaque_sp->GetAddress().IsValid())
|
|
sb_addr.SetAddress(&m_opaque_sp->GetAddress());
|
|
return sb_addr;
|
|
}
|
|
|
|
size_t
|
|
SBInstruction::GetByteSize ()
|
|
{
|
|
if (m_opaque_sp)
|
|
return m_opaque_sp->GetOpcode().GetByteSize();
|
|
return 0;
|
|
}
|
|
|
|
bool
|
|
SBInstruction::DoesBranch ()
|
|
{
|
|
if (m_opaque_sp)
|
|
return m_opaque_sp->DoesBranch ();
|
|
return false;
|
|
}
|
|
|
|
void
|
|
SBInstruction::SetOpaque (const lldb::InstructionSP &inst_sp)
|
|
{
|
|
m_opaque_sp = inst_sp;
|
|
}
|
|
|
|
bool
|
|
SBInstruction::GetDescription (lldb::SBStream &s)
|
|
{
|
|
if (m_opaque_sp)
|
|
{
|
|
// Use the "ref()" instead of the "get()" accessor in case the SBStream
|
|
// didn't have a stream already created, one will get created...
|
|
m_opaque_sp->Dump (&s.ref(), true, false, NULL, false);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void
|
|
SBInstruction::Print (FILE *out)
|
|
{
|
|
if (out == NULL)
|
|
return;
|
|
|
|
if (m_opaque_sp)
|
|
{
|
|
StreamFile out_stream (out, false);
|
|
m_opaque_sp->Dump (&out_stream, true, false, NULL, false);
|
|
}
|
|
}
|