class MCDisassembler
Declaration
class MCDisassembler { /* full declaration omitted */ };
Description
Superclass for all disassemblers. Consumes a memory region and provides an array of assembly instructions.
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:85
Member Variables
- private llvm::MCContext& Ctx
- protected const llvm::MCSubtargetInfo& STI
- protected std::unique_ptr<MCSymbolizer> Symbolizer
- public llvm::raw_ostream* CommentStream = nullptr
Method Overview
- public MCDisassembler(const llvm::MCSubtargetInfo & STI, llvm::MCContext & Ctx)
- public llvm::MCContext & getContext() const
- public virtual llvm::MCDisassembler::DecodeStatus getInstruction(llvm::MCInst & Instr, uint64_t & Size, ArrayRef<uint8_t> Bytes, uint64_t Address, llvm::raw_ostream & CStream) const
- public const llvm::MCSubtargetInfo & getSubtargetInfo() const
- public virtual Optional<llvm::MCDisassembler::DecodeStatus> onSymbolStart(llvm::SymbolInfoTy & Symbol, uint64_t & Size, ArrayRef<uint8_t> Bytes, uint64_t Address, llvm::raw_ostream & CStream) const
- public void setSymbolizer(std::unique_ptr<MCSymbolizer> Symzer)
- public virtual uint64_t suggestBytesToSkip(ArrayRef<uint8_t> Bytes, uint64_t Address) const
- public void tryAddingPcLoadReferenceComment(int64_t Value, uint64_t Address) const
- public bool tryAddingSymbolicOperand(llvm::MCInst & Inst, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t OpSize, uint64_t InstSize) const
- public virtual ~MCDisassembler()
Methods
¶MCDisassembler(const llvm::MCSubtargetInfo& STI,
llvm::MCContext& Ctx)
MCDisassembler(const llvm::MCSubtargetInfo& STI,
llvm::MCContext& Ctx)
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:115
Parameters
- const llvm::MCSubtargetInfo& STI
- llvm::MCContext& Ctx
¶llvm::MCContext& getContext() const
llvm::MCContext& getContext() const
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:217
¶virtual llvm::MCDisassembler::DecodeStatus
getInstruction(llvm::MCInst& Instr,
uint64_t& Size,
ArrayRef<uint8_t> Bytes,
uint64_t Address,
llvm::raw_ostream& CStream) const
virtual llvm::MCDisassembler::DecodeStatus
getInstruction(llvm::MCInst& Instr,
uint64_t& Size,
ArrayRef<uint8_t> Bytes,
uint64_t Address,
llvm::raw_ostream& CStream) const
Description
Returns the disassembly of a single instruction.
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:135
Parameters
- llvm::MCInst& Instr
- - An MCInst to populate with the contents of the instruction.
- uint64_t& Size
- - A value to populate with the size of the instruction, or the number of bytes consumed while attempting to decode an invalid instruction.
- ArrayRef<uint8_t> Bytes
- - A reference to the actual bytes of the instruction.
- uint64_t Address
- - The address, in the memory space of region, of the first byte of the instruction.
- llvm::raw_ostream& 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.
¶const llvm::MCSubtargetInfo& getSubtargetInfo()
const
const llvm::MCSubtargetInfo& getSubtargetInfo()
const
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:219
¶virtual Optional<
llvm::MCDisassembler::DecodeStatus>
onSymbolStart(llvm::SymbolInfoTy& Symbol,
uint64_t& Size,
ArrayRef<uint8_t> Bytes,
uint64_t Address,
llvm::raw_ostream& CStream) const
virtual Optional<
llvm::MCDisassembler::DecodeStatus>
onSymbolStart(llvm::SymbolInfoTy& Symbol,
uint64_t& Size,
ArrayRef<uint8_t> Bytes,
uint64_t Address,
llvm::raw_ostream& CStream) const
Description
Used to perform separate target specific disassembly for a particular symbol. May parse any prelude that precedes instructions after the start of a symbol, or the entire symbol. This is used for example by WebAssembly to decode preludes. Base implementation returns None. So all targets by default ignore to treat symbols separately.
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:163
Parameters
- llvm::SymbolInfoTy& Symbol
- - The symbol.
- uint64_t& Size
- - The number of bytes consumed.
- ArrayRef<uint8_t> Bytes
- - A reference to the actual bytes at the symbol location.
- uint64_t Address
- - The address, in the memory space of region, of the first byte of the symbol.
- llvm::raw_ostream& CStream
- - The stream to print comments and annotations on.
Returns
- MCDisassembler::Success if bytes are decoded successfully. Size must hold the number of bytes that were decoded. - MCDisassembler::Fail if the bytes are invalid. Size must hold the number of bytes that were decoded before failing. The target must print nothing. This can be done by buffering the output if needed. - None if the target doesn't want to handle the symbol separately. Value of Size is ignored in this case.
¶void setSymbolizer(
std::unique_ptr<MCSymbolizer> Symzer)
void setSymbolizer(
std::unique_ptr<MCSymbolizer> Symzer)
Description
Set \p Symzer as the current symbolizer. This takes ownership of \p Symzer, and deletes the previously set one.
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:215
Parameters
- std::unique_ptr<MCSymbolizer> Symzer
¶virtual uint64_t suggestBytesToSkip(
ArrayRef<uint8_t> Bytes,
uint64_t Address) const
virtual uint64_t suggestBytesToSkip(
ArrayRef<uint8_t> Bytes,
uint64_t Address) const
Description
Suggest a distance to skip in a buffer of data to find the next place to look for the start of an instruction. For example, if all instructions have a fixed alignment, this might advance to the next multiple of that alignment. If not overridden, the default is 1.
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:194
Parameters
- ArrayRef<uint8_t> Bytes
- - A reference to the actual bytes at Address. May be needed in order to determine the width of an unrecognized instruction (e.g. in Thumb this is a simple consistent criterion that doesn't require knowing the specific instruction). The caller can pass as much data as they have available, and the function is required to make a reasonable default choice if not enough data is available to make a better one.
- uint64_t Address
- - The address, in the memory space of region, of the starting point (typically the first byte of something that did not decode as a valid instruction at all).
Returns
- A number of bytes to skip. Must always be greater than zero. May be greater than the size of Bytes.
¶void tryAddingPcLoadReferenceComment(
int64_t Value,
uint64_t Address) const
void tryAddingPcLoadReferenceComment(
int64_t Value,
uint64_t Address) const
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:211
Parameters
- int64_t Value
- uint64_t Address
¶bool tryAddingSymbolicOperand(
llvm::MCInst& Inst,
int64_t Value,
uint64_t Address,
bool IsBranch,
uint64_t Offset,
uint64_t OpSize,
uint64_t InstSize) const
bool tryAddingSymbolicOperand(
llvm::MCInst& Inst,
int64_t Value,
uint64_t Address,
bool IsBranch,
uint64_t Offset,
uint64_t OpSize,
uint64_t InstSize) const
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:207
Parameters
- llvm::MCInst& Inst
- int64_t Value
- uint64_t Address
- bool IsBranch
- uint64_t Offset
- uint64_t OpSize
- uint64_t InstSize
¶virtual ~MCDisassembler()
virtual ~MCDisassembler()
Declared at: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:118