ROSE 0.11.145.134
Classes | Public Member Functions | List of all members
Rose::BinaryAnalysis::InstructionCache Class Reference

Description

Cache of instruction ASTs.

A cache is responible for handing out pointers to managed instruction ASTs and evicting those ASTs from memory when they haven't been used recently and it's safe to do so. Each smart pointer handed out by the cache acts mostly like a raw pointer to a SgAsmInstruction node from the user's point of view, but under the covers, the smart pointers coordinate with the cache so the cache knows when to evict ASTs.

Definition at line 364 of file InstructionCache.h.

#include <Rose/BinaryAnalysis/InstructionCache.h>

Inheritance diagram for Rose::BinaryAnalysis::InstructionCache:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::InstructionCache:
Collaboration graph
[legend]

Classes

class  Exception
 Exceptions thrown by this layer. More...
 

Public Member Functions

 InstructionCache (const MemoryMapPtr &, const Disassembler::BasePtr &decoder)
 Construct a new instruction cache.
 
MemoryMapPtr memoryMap () const
 Property: memory map providing the opcodes for the instructions.
 
Disassembler::BasePtr decoder () const
 Property: the decoder used to construct the instruction ASTs from data in memory.
 
InstructionPtr get (rose_addr_t va)
 Obtain the instruction at a specified address.
 
LockedInstruction lock (rose_addr_t va)
 Shortcut to obtain a lock.
 
void evict ()
 Garbage collection.
 
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor.
 
 SharedObject (const SharedObject &)
 Copy constructor.
 
virtual ~SharedObject ()
 Virtual destructor.
 
SharedObjectoperator= (const SharedObject &)
 Assignment.
 

Constructor & Destructor Documentation

◆ InstructionCache()

Rose::BinaryAnalysis::InstructionCache::InstructionCache ( const MemoryMapPtr ,
const Disassembler::BasePtr decoder 
)

Construct a new instruction cache.

Each instruction cache is for a specific virtual memory and instruction decoder. The memory mapping and content should not change under the cache since doing so could cause reconstructed evicted instructions to be different than the original instruction.

Member Function Documentation

◆ memoryMap()

MemoryMapPtr Rose::BinaryAnalysis::InstructionCache::memoryMap ( ) const

Property: memory map providing the opcodes for the instructions.

The memory map is provided at construction time and neither the mapping nor the data should change (see constructor).

Thread safety: This function is thread safe.

◆ decoder()

Disassembler::BasePtr Rose::BinaryAnalysis::InstructionCache::decoder ( ) const

Property: the decoder used to construct the instruction ASTs from data in memory.

Thread safety: This function is thread safe.

◆ get()

InstructionPtr Rose::BinaryAnalysis::InstructionCache::get ( rose_addr_t  va)

Obtain the instruction at a specified address.

Returns a smart pointer for the instruction at the specified address. If the byte at the adress is not executable then a null pointer is returned (it's easy to change memory permissions in ROSE–they don't have to remain the same as how the ELF or PE container parsing instantiated them). If the address is valid but the decoder cannot form a valid instruction from the opcode in memory, then a special, non-null "unknown" instruction is returned.

Thread safety: This function is thread safe.

◆ lock()

LockedInstruction Rose::BinaryAnalysis::InstructionCache::lock ( rose_addr_t  va)

Shortcut to obtain a lock.

This is the same as calling get and then locking the return value.

◆ evict()

void Rose::BinaryAnalysis::InstructionCache::evict ( )

Garbage collection.

Runs one iteration of the cache eviction algorithm.


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