LIEF: Library to Instrument Executable Formats Version 0.17.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
15#ifndef LIEF_ASM_INST_H
16#define LIEF_ASM_INST_H
39 public:
class Iterator final :
42 public iterator_facade_base<Iterator, std::forward_iterator_tag, std::unique_ptr<Instruction>,
43 std::ptrdiff_t, Instruction*, std::unique_ptr<Instruction>>
46 using implementation = details::InstructionIt;
55 LIEF_API Iterator& operator=(Iterator&&) noexcept;
61 friend
LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
63 friend
bool operator!=(const Iterator& LHS, const Iterator& RHS) {
72 std::unique_ptr<details::InstructionIt> impl_;
74 public:
enum class MemoryAccess : uint8_t {
80 READ_WRITE = READ | WRITE,
88 const std::vector<uint8_t>&
raw()
const;
94 std::string
to_string(
bool with_address =
true)
const;
162 const llvm::MCInst&
mcinst()
const;
178 const T*
as()
const {
179 static_assert(std::is_base_of<Instruction, T>::value,
180 "Require Instruction inheritance");
181 if (T::classof(
this)) {
182 return static_cast<const T*
>(
this);
193 static LIEF_LOCAL std::unique_ptr<Instruction>
196 create(std::unique_ptr<details::Instruction> impl);
197 LIEF_LOCAL const details::Instruction& impl()
const {
200 assert(impl_ !=
nullptr);
206 assert(impl_ !=
nullptr);
211 LIEF_LOCAL Instruction(std::unique_ptr<details::Instruction> impl);
212 std::unique_ptr<details::Instruction> impl_;
Iterator & operator=(const Iterator &)
Iterator(Iterator &&) noexcept
Iterator(const Iterator &)
std::unique_ptr< Instruction > operator*() const
Disassemble and output an Instruction at the current iterator's position.
Iterator(std::unique_ptr< details::InstructionIt > impl)
This class represents an assembly instruction.
Definition Instruction.hpp:38
MemoryAccess memory_access() const
Memory access flags.
bool is_move_reg() const
True if the instruction is a register to register move.
bool is_terminator() const
True if the instruction marks the end of a basic block.
const T * as() const
This function can be used to down cast an Instruction instance:
Definition Instruction.hpp:178
bool is_compare() const
True if the instruction is a comparison.
bool is_conditional_branch() const
True if the instruction is conditionally jumping to the next instruction or an instruction into some ...
bool is_move_immediate() const
True if the instruction is moving an immediate.
bool is_syscall() const
True if the instruction is a syscall.
bool is_indirect_branch() const
True if the instruction is and indirect branch.
const llvm::MCInst & mcinst() const
Return the underlying llvm::MCInst implementation.
bool is_branch() const
True if the instruction is a branch.
std::string mnemonic() const
Instruction mnemonic (e.g. br)
std::string to_string(bool with_address=true) const
Representation of the current instruction in a pretty assembly way.
bool is_bitcast() const
True if the instruction is doing a bitcast.
bool is_trap() const
True if the instruction is a trap.
bool is_unconditional_branch() const
True if the instruction is jumping (unconditionally) to some other basic block.
bool is_return() const
True if the instruction is a return.
uint64_t address() const
Address of the instruction.
bool is_add() const
True if the instruction performs an arithmetic addition.
bool is_call() const
True if the instruction is a call.
const std::vector< uint8_t > & raw() const
Raw bytes of the current instruction.
friend std::ostream & operator<<(std::ostream &os, const Instruction &inst)
Definition Instruction.hpp:187
bool is_memory_access() const
True if the instruction performs a memory access.
bool is_barrier() const
True if the instruction prevents executing the instruction that immediatly follows the current....
result< uint64_t > branch_target() const
Given a is_branch() instruction, try to evaluate the address of the destination.
size_t size() const
Size of the instruction in bytes.
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:43
LIEF namespace.
Definition Abstract/Binary.hpp:36
Definition Instruction.hpp:25
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42