Cleaned up code that was getting SBData for an SBInstruction.

llvm-svn: 154535
This commit is contained in:
Greg Clayton
2012-04-11 21:13:31 +00:00
parent aaf4d69ac1
commit d1411e1aa2
4 changed files with 77 additions and 34 deletions

View File

@@ -13,6 +13,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/Endian.h"
@@ -79,3 +81,36 @@ Opcode::GetDataByteOrder () const
return eByteOrderInvalid;
}
uint32_t
Opcode::GetData (DataExtractor &data) const
{
uint32_t byte_size = GetByteSize ();
DataBufferSP buffer_sp;
if (byte_size > 0)
{
switch (m_type)
{
case Opcode::eTypeInvalid:
break;
case Opcode::eType8: buffer_sp.reset (new DataBufferHeap (&m_data.inst8, byte_size)); break;
case Opcode::eType16: buffer_sp.reset (new DataBufferHeap (&m_data.inst16, byte_size)); break;
case Opcode::eType32: buffer_sp.reset (new DataBufferHeap (&m_data.inst32, byte_size)); break;
case Opcode::eType64: buffer_sp.reset (new DataBufferHeap (&m_data.inst64, byte_size)); break;
case Opcode::eTypeBytes:buffer_sp.reset (new DataBufferHeap (GetOpcodeBytes(), byte_size)); break;
break;
}
}
if (buffer_sp)
{
data.SetByteOrder(GetDataByteOrder());
data.SetData (buffer_sp);
return byte_size;
}
data.Clear();
return 0;
}