LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
llvm::MCDisassembler Class Referenceabstract

#include <MCDisassembler.h>

Inheritance diagram for llvm::MCDisassembler:
Inheritance graph
[legend]
Collaboration diagram for llvm::MCDisassembler:
Collaboration graph
[legend]

Public Types

enum  DecodeStatus { Fail = 0, SoftFail = 1, Success = 3 }
 

Public Member Functions

 MCDisassembler (const MCSubtargetInfo &STI)
 Constructor - Performs initial setup for the disassembler. More...
 
virtual ~MCDisassembler ()
 
virtual DecodeStatus getInstruction (MCInst &instr, uint64_t &size, const MemoryObject &region, uint64_t address, raw_ostream &vStream, raw_ostream &cStream) const =0
 
bool tryAddingSymbolicOperand (MCInst &Inst, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t InstSize) const
 
void tryAddingPcLoadReferenceComment (int64_t Value, uint64_t Address) const
 
void setSymbolizer (OwningPtr< MCSymbolizer > &Symzer)
 
void setupForSymbolicDisassembly (LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, OwningPtr< MCRelocationInfo > &RelInfo)
 Sets up an external symbolizer that uses the C API callbacks. More...
 
LLVMOpInfoCallback getLLVMOpInfoCallback () const
 
LLVMSymbolLookupCallback getLLVMSymbolLookupCallback () const
 
void * getDisInfoBlock () const
 
MCContextgetMCContext () const
 
const MCSubtargetInfogetSubtargetInfo () const
 

Public Attributes

raw_ostreamCommentStream
 

Protected Attributes

const MCSubtargetInfoSTI
 
OwningPtr< MCSymbolizerSymbolizer
 

Detailed Description

MCDisassembler - Superclass for all disassemblers. Consumes a memory region and provides an array of assembly instructions.

Definition at line 28 of file MCDisassembler.h.

Member Enumeration Documentation

Ternary decode status. Most backends will just use Fail and Success, however some have a concept of an instruction with understandable semantics but which is architecturally incorrect. An example of this is ARM UNPREDICTABLE instructions which are disassemblable but cause undefined behaviour.

Because it makes sense to disassemble these instructions, there is a "soft fail" failure mode that indicates the MCInst& is valid but architecturally incorrect.

The enum numbers are deliberately chosen such that reduction from Success->SoftFail ->Fail can be done with a simple bitwise-AND:

LEFT & TOP = | Success Unpredictable Fail -----------—+--------------------------------— Success | Success Unpredictable Fail Unpredictable | Unpredictable Unpredictable Fail Fail | Fail Fail Fail

An easy way of encoding this is as 0b11, 0b01, 0b00 for Success, SoftFail, Fail respectively.

Enumerator
Fail 
SoftFail 
Success 

Definition at line 52 of file MCDisassembler.h.

Constructor & Destructor Documentation

llvm::MCDisassembler::MCDisassembler ( const MCSubtargetInfo STI)
inline

Constructor - Performs initial setup for the disassembler.

Definition at line 59 of file MCDisassembler.h.

MCDisassembler::~MCDisassembler ( )
virtual

Definition at line 16 of file MCDisassembler.cpp.

Member Function Documentation

void* llvm::MCDisassembler::getDisInfoBlock ( ) const
inline

Definition at line 131 of file MCDisassembler.h.

virtual DecodeStatus llvm::MCDisassembler::getInstruction ( MCInst instr,
uint64_t &  size,
const MemoryObject region,
uint64_t  address,
raw_ostream vStream,
raw_ostream cStream 
) const
pure virtual

getInstruction - Returns the disassembly of a single instruction.

Parameters
instr- An MCInst to populate with the contents of the instruction.
size- A value to populate with the size of the instruction, or the number of bytes consumed while attempting to decode an invalid instruction.
region- The memory object to use as a source for machine code.
address- The address, in the memory space of region, of the first byte of the instruction.
vStream- The stream to print warnings and diagnostic messages on.
cStream- The stream to print comments and annotations on.
Returns
- MCDisassembler::Success if the instruction is valid, MCDisassembler::SoftFail if the instruction was disassemblable but invalid, MCDisassembler::Fail if the instruction was invalid.

Implemented in llvm::X86Disassembler::X86GenericDisassembler.

Referenced by LLVMDisasmInstruction().

LLVMOpInfoCallback llvm::MCDisassembler::getLLVMOpInfoCallback ( ) const
inline

Definition at line 127 of file MCDisassembler.h.

LLVMSymbolLookupCallback llvm::MCDisassembler::getLLVMSymbolLookupCallback ( ) const
inline

Definition at line 128 of file MCDisassembler.h.

MCContext* llvm::MCDisassembler::getMCContext ( ) const
inline

Definition at line 132 of file MCDisassembler.h.

const MCSubtargetInfo& llvm::MCDisassembler::getSubtargetInfo ( ) const
inline

Definition at line 134 of file MCDisassembler.h.

References STI.

void MCDisassembler::setSymbolizer ( OwningPtr< MCSymbolizer > &  Symzer)

Set Symzer as the current symbolizer. This takes ownership of Symzer, and deletes the previously set one.

Definition at line 54 of file MCDisassembler.cpp.

References Symbolizer, and llvm::OwningPtr< T >::take().

Referenced by LLVMCreateDisasmCPU().

void MCDisassembler::setupForSymbolicDisassembly ( LLVMOpInfoCallback  GetOpInfo,
LLVMSymbolLookupCallback  SymbolLookUp,
void *  DisInfo,
MCContext Ctx,
OwningPtr< MCRelocationInfo > &  RelInfo 
)

Sets up an external symbolizer that uses the C API callbacks.

Definition at line 20 of file MCDisassembler.cpp.

References Symbolizer.

Referenced by LLVMCreateDisasmCPU().

void MCDisassembler::tryAddingPcLoadReferenceComment ( int64_t  Value,
uint64_t  Address 
) const

Definition at line 47 of file MCDisassembler.cpp.

References CommentStream, llvm::nulls(), and Symbolizer.

Referenced by tryAddingPcLoadReferenceComment().

bool MCDisassembler::tryAddingSymbolicOperand ( MCInst Inst,
int64_t  Value,
uint64_t  Address,
bool  IsBranch,
uint64_t  Offset,
uint64_t  InstSize 
) const

Definition at line 36 of file MCDisassembler.cpp.

References CommentStream, llvm::nulls(), and Symbolizer.

Referenced by tryAddingSymbolicOperand().

Member Data Documentation

raw_ostream* llvm::MCDisassembler::CommentStream
mutable
const MCSubtargetInfo& llvm::MCDisassembler::STI
protected

Definition at line 104 of file MCDisassembler.h.

Referenced by getSubtargetInfo().

OwningPtr<MCSymbolizer> llvm::MCDisassembler::Symbolizer
protected

The documentation for this class was generated from the following files: