ROSE 0.11.145.134
|
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>
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. | |
SharedObject & | operator= (const SharedObject &) |
Assignment. | |
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.
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.
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.
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.
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.
void Rose::BinaryAnalysis::InstructionCache::evict | ( | ) |
Garbage collection.
Runs one iteration of the cache eviction algorithm.