<rdar://problem/11330621>

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
This commit is contained in:
Greg Clayton
2012-05-10 02:52:23 +00:00
parent c67f223c9e
commit ba812f4284
17 changed files with 490 additions and 704 deletions

View File

@@ -1,4 +1,4 @@
//===-- Baton.cpp -----------------------------------------------*- C++ -*-===//
//===-- Opcode.cpp ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,12 +12,15 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/Triple.h"
// Project includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/Endian.h"
using namespace lldb;
using namespace lldb_private;
@@ -82,9 +85,10 @@ Opcode::GetDataByteOrder () const
}
uint32_t
Opcode::GetData (DataExtractor &data) const
Opcode::GetData (DataExtractor &data, lldb::AddressClass address_class) const
{
uint32_t byte_size = GetByteSize ();
DataBufferSP buffer_sp;
if (byte_size > 0)
{
@@ -95,7 +99,27 @@ Opcode::GetData (DataExtractor &data) const
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::eType32:
{
// The only thing that uses eAddressClassCodeAlternateISA currently
// is Thumb. If this ever changes, we will need to pass in more
// information like an additional "const ArchSpec &arch". For now
// this will do
if (address_class == eAddressClassCodeAlternateISA)
{
// 32 bit thumb instruction, we need to sizzle this a bit
uint8_t buf[4];
buf[0] = m_data.inst.bytes[2];
buf[1] = m_data.inst.bytes[3];
buf[2] = m_data.inst.bytes[0];
buf[3] = m_data.inst.bytes[1];
buffer_sp.reset (new DataBufferHeap (buf, byte_size));
break;
}
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;