ROSE 0.11.145.192
Public Member Functions | List of all members
Rose::BinaryAnalysis::Partitioner2::AddressUsageMap Class Reference

Description

Address usage map.

Keeps track of which instructions and data span each virtual address. The AUM that's part of the partitioner is never modified directly by the user, and represents the instructions and basic blocks that are in the control flow graph as well as any data blocks they own.

Definition at line 371 of file AddressUsageMap.h.

#include <Rose/BinaryAnalysis/Partitioner2/AddressUsageMap.h>

Public Member Functions

bool isEmpty () const
 Determines whether a map is empty.
 
void clear ()
 Reset map to initial empty state.
 
size_t size () const
 Number of addresses represented by the map.
 
AddressInterval hull () const
 Minimum and maximum used addresses.
 
AddressIntervalSet extent () const
 Addresses represented.
 
bool exists (rose_addr_t) const
 Predicate to determine whether an address is used.
 
AddressInterval nextUnused (rose_addr_t minVa) const
 Next unused address interval.
 
AddressUser insertInstruction (SgAsmInstruction *, const BasicBlockPtr &)
 Insert the instruction along with an owning basic block.
 
AddressUser insertDataBlock (const DataBlockPtr &)
 Insert the data block.
 
SgAsmInstructioneraseInstruction (SgAsmInstruction *, const BasicBlockPtr &)
 Remove the specified instruction/basic block pair.
 
DataBlockPtr eraseDataBlock (const DataBlockPtr &)
 Remove the specified data block.
 
Sawyer::Optional< rose_addr_t > leastUnmapped (rose_addr_t startVa) const
 Returns the least unmapped address with specified lower limit.
 
void print (std::ostream &, const std::string &prefix="") const
 Dump the contents of this AUM to a stream.
 
void checkConsistency () const
 Check invariants.
 
bool anyExists (const AddressInterval &) const
 Predicate to determine whether any of the specified addresses are used.
 
bool anyExists (const AddressIntervalSet &) const
 Predicate to determine whether any of the specified addresses are used.
 
AddressIntervalSet unusedExtent (size_t nBits) const
 Addresses not represented.
 
AddressIntervalSet unusedExtent (const AddressInterval &) const
 Addresses not represented.
 
AddressIntervalSet unusedExtent (const AddressIntervalSet &) const
 Addresses not represented.
 
SgAsmInstructioninstructionExists (SgAsmInstruction *) const
 Determines whether the specified instruction or an equivalent exists.
 
SgAsmInstructioninstructionExists (rose_addr_t va) const
 Determines whether the specified instruction or an equivalent exists.
 
BasicBlockPtr basicBlockExists (const BasicBlockPtr &) const
 Determine if a basic block exists.
 
BasicBlockPtr basicBlockExists (rose_addr_t startOfBlock) const
 Determine if a basic block exists.
 
DataBlockPtr dataBlockExists (const DataBlockPtr &) const
 Determines if a data block exists.
 
DataBlockPtr dataBlockExists (rose_addr_t va, rose_addr_t size) const
 Determines if a data block exists.
 
AddressUser findInstruction (SgAsmInstruction *) const
 Find an AddressUser record for the specified instruction, or equivalent.
 
AddressUser findInstruction (rose_addr_t va) const
 Find an AddressUser record for the specified instruction, or equivalent.
 
AddressUser findBasicBlock (const BasicBlockPtr &) const
 Find an AddressUser record for the specified basic block, or equivalent.
 
AddressUser findBasicBlock (rose_addr_t va) const
 Find an AddressUser record for the specified basic block, or equivalent.
 
AddressUser findDataBlock (const DataBlockPtr &) const
 Find an AddressUser record for the specified data block, or equivalent.
 
AddressUser findDataBlock (rose_addr_t va, rose_addr_t size) const
 Find an AddressUser record for the specified data block, or equivalent.
 
AddressUsers spanning (const AddressInterval &) const
 Find address users that span the entire interval.
 
template<class UserPredicate >
AddressUsers spanning (const AddressInterval &interval, UserPredicate userPredicate) const
 Find address users that span the entire interval.
 
AddressUsers overlapping (const AddressInterval &) const
 Users that overlap the interval.
 
template<class UserPredicate >
AddressUsers overlapping (const AddressInterval &interval, UserPredicate userPredicate) const
 Users that overlap the interval.
 
AddressUsers containedIn (const AddressInterval &) const
 Users that are fully contained in the interval.
 

Member Function Documentation

◆ isEmpty()

bool Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::isEmpty ( ) const

Determines whether a map is empty.

Returns true if the map contains no instructions or data, false if it contains at least one instruction or at least one data block.

◆ size()

size_t Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::size ( ) const

Number of addresses represented by the map.

Returns the number of addresses that have at least one user. This is a constant-time operation.

◆ hull()

AddressInterval Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::hull ( ) const

Minimum and maximum used addresses.

Returns minimum and maximum addresses that exist in this address usage map. If the map is empty then the returned interval is empty, containing neither a minimum nor maximum address.

◆ extent()

AddressIntervalSet Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::extent ( ) const

Addresses represented.

Returns the set of addresses that are represented.

◆ exists()

bool Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::exists ( rose_addr_t  ) const

Predicate to determine whether an address is used.

Returns true if the specified address belongs to any instruction, basic block, or data block. This is a O(log N) operation where N is the number of contiguous intervals in this address usage map. It may be slightly faster than some of the other methods since it doesn't need to construct a non-POD return value.

◆ anyExists() [1/2]

bool Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::anyExists ( const AddressInterval ) const

Predicate to determine whether any of the specified addresses are used.

Returns true if any address in the specified set or interval belongs to any instruction, basic block, or data block. This may be slightly faster than some of the other predicates because it doesn't need to construct a non-POD return value.

◆ anyExists() [2/2]

bool Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::anyExists ( const AddressIntervalSet ) const

Predicate to determine whether any of the specified addresses are used.

Returns true if any address in the specified set or interval belongs to any instruction, basic block, or data block. This may be slightly faster than some of the other predicates because it doesn't need to construct a non-POD return value.

◆ unusedExtent() [1/3]

AddressIntervalSet Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::unusedExtent ( size_t  nBits) const

Addresses not represented.

Returns the set of addresses that are not represented. The nBits argument is the number of bits in the virtual address space, usually 32 or 64, and must be between 1 and 64, inclusive. Alternatively, an interval or interval set can be supplied to limit the return value.

◆ unusedExtent() [2/3]

AddressIntervalSet Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::unusedExtent ( const AddressInterval ) const

Addresses not represented.

Returns the set of addresses that are not represented. The nBits argument is the number of bits in the virtual address space, usually 32 or 64, and must be between 1 and 64, inclusive. Alternatively, an interval or interval set can be supplied to limit the return value.

◆ unusedExtent() [3/3]

AddressIntervalSet Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::unusedExtent ( const AddressIntervalSet ) const

Addresses not represented.

Returns the set of addresses that are not represented. The nBits argument is the number of bits in the virtual address space, usually 32 or 64, and must be between 1 and 64, inclusive. Alternatively, an interval or interval set can be supplied to limit the return value.

◆ nextUnused()

AddressInterval Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::nextUnused ( rose_addr_t  minVa) const

Next unused address interval.

Returns the next address interval that begins at or after the specified address and which does not correspond to any instruction, basic block, data block, or function. The largest such interval is returned, but it will not contain any values less than minVa. Returns an empty interval if no such interval exists.

◆ instructionExists() [1/2]

SgAsmInstruction * Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::instructionExists ( SgAsmInstruction ) const

Determines whether the specified instruction or an equivalent exists.

Returns the instruction or equivalent that exists, otherwise null.

◆ instructionExists() [2/2]

SgAsmInstruction * Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::instructionExists ( rose_addr_t  va) const

Determines whether the specified instruction or an equivalent exists.

Returns the instruction or equivalent that exists, otherwise null.

◆ basicBlockExists() [1/2]

BasicBlockPtr Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::basicBlockExists ( const BasicBlockPtr ) const

Determine if a basic block exists.

If the specified basic block's starting address exists in this AUM and is the starting instruction of this basic block or an equivalent then returns a pointer to the existing basic block, otherwise the null pointer is returned. A basic block exists only when it has at least one instruction; this is contrary to the CFG, where a basic block can be represented by a placeholder with no instructions.

◆ basicBlockExists() [2/2]

BasicBlockPtr Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::basicBlockExists ( rose_addr_t  startOfBlock) const

Determine if a basic block exists.

If the specified basic block's starting address exists in this AUM and is the starting instruction of this basic block or an equivalent then returns a pointer to the existing basic block, otherwise the null pointer is returned. A basic block exists only when it has at least one instruction; this is contrary to the CFG, where a basic block can be represented by a placeholder with no instructions.

◆ dataBlockExists() [1/2]

DataBlockPtr Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::dataBlockExists ( const DataBlockPtr ) const

Determines if a data block exists.

If the specified data block or an equivalent exists in the map then a pointer to the exsiting data block is returned, otherwise a null pointer is returned.

◆ dataBlockExists() [2/2]

DataBlockPtr Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::dataBlockExists ( rose_addr_t  va,
rose_addr_t  size 
) const

Determines if a data block exists.

If the specified data block or an equivalent exists in the map then a pointer to the exsiting data block is returned, otherwise a null pointer is returned.

◆ findInstruction() [1/2]

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::findInstruction ( SgAsmInstruction ) const

Find an AddressUser record for the specified instruction, or equivalent.

If the specified instruction or an equivalent instruction exists in this object, then its record is returned, otherwise an empty record is returned. The instruction can be indicated by either an SgAsmInstruction object or a starting address.

◆ findInstruction() [2/2]

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::findInstruction ( rose_addr_t  va) const

Find an AddressUser record for the specified instruction, or equivalent.

If the specified instruction or an equivalent instruction exists in this object, then its record is returned, otherwise an empty record is returned. The instruction can be indicated by either an SgAsmInstruction object or a starting address.

◆ findBasicBlock() [1/2]

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::findBasicBlock ( const BasicBlockPtr ) const

Find an AddressUser record for the specified basic block, or equivalent.

If the specified basic block or an equivalent basic block (based on starting address) is present in this list, then return its record, otherwise return an empty record. This looks up the basic block by looking for its first instruction, therefore returns a record only if the first instruction is present. The basic block can be specified by either a BasicBlock object or a starting address.

◆ findBasicBlock() [2/2]

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::findBasicBlock ( rose_addr_t  va) const

Find an AddressUser record for the specified basic block, or equivalent.

If the specified basic block or an equivalent basic block (based on starting address) is present in this list, then return its record, otherwise return an empty record. This looks up the basic block by looking for its first instruction, therefore returns a record only if the first instruction is present. The basic block can be specified by either a BasicBlock object or a starting address.

◆ findDataBlock() [1/2]

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::findDataBlock ( const DataBlockPtr ) const

Find an AddressUser record for the specified data block, or equivalent.

If the specified data block or an equivalent data block exists in this object, then its record is returned, otherwise an empty record is returned. The data block can be specified by either a DataBlock object or a starting address and size.

◆ findDataBlock() [2/2]

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::findDataBlock ( rose_addr_t  va,
rose_addr_t  size 
) const

Find an AddressUser record for the specified data block, or equivalent.

If the specified data block or an equivalent data block exists in this object, then its record is returned, otherwise an empty record is returned. The data block can be specified by either a DataBlock object or a starting address and size.

◆ insertInstruction()

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::insertInstruction ( SgAsmInstruction ,
const BasicBlockPtr  
)

Insert the instruction along with an owning basic block.

Inserts the specified instruction and its owning basic block if the information is not already present in this AUM. Returns the relavent address user information since this method might substitute existing equivalent instruction and owner.

◆ insertDataBlock()

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::insertDataBlock ( const DataBlockPtr )

Insert the data block.

Inserts the specified data block if an equivalent data block is not already present. Returns the relevant address user information since this method might substitute an existing equivalent data block.

◆ eraseInstruction()

SgAsmInstruction * Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::eraseInstruction ( SgAsmInstruction ,
const BasicBlockPtr  
)

Remove the specified instruction/basic block pair.

If the specified instruction or equivalent is found in this AUM then the specified basic block is removed as one of its owners. If this leaves the instruction with no owning basic blocks, then the instruction itself is also removed. Returns the affected instruction.

◆ eraseDataBlock()

DataBlockPtr Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::eraseDataBlock ( const DataBlockPtr )

Remove the specified data block.

Removes the specified data block or an equivalent from this AUM. Returns the data block that was erased.

◆ spanning() [1/2]

AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::spanning ( const AddressInterval ) const

Find address users that span the entire interval.

The return value is a vector of address users (instructions and/or data blocks) sorted by starting address where each user starts at or before the beginning of the interval and ends at or after the end of the interval. The specified predicate is used to select which users are inserted into the result and should be a functor that takes an AddressUser as an argument and returns true to select that user for inclusion in the result.

◆ spanning() [2/2]

template<class UserPredicate >
AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::spanning ( const AddressInterval interval,
UserPredicate  userPredicate 
) const
inline

Find address users that span the entire interval.

The return value is a vector of address users (instructions and/or data blocks) sorted by starting address where each user starts at or before the beginning of the interval and ends at or after the end of the interval. The specified predicate is used to select which users are inserted into the result and should be a functor that takes an AddressUser as an argument and returns true to select that user for inclusion in the result.

Definition at line 549 of file AddressUsageMap.h.

References Sawyer::Container::IntervalMap< I, T, Policy >::findAll(), Rose::BinaryAnalysis::Partitioner2::AddressUsers::intersection(), Rose::BinaryAnalysis::Partitioner2::AddressUsers::isEmpty(), and Rose::BinaryAnalysis::Partitioner2::AddressUsers::select().

◆ overlapping() [1/2]

AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::overlapping ( const AddressInterval ) const

Users that overlap the interval.

The return value is a vector of address users (instructions and/or data blocks) sorted by starting address where each user overlaps with the interval. That is, at least one byte of the instruction or data block came from the specified interval of byte addresses. The specified predicate is used to select which users are inserted into the result and should be a functor that takes an AddressUser as an argument and returns true to select that user for inclusion in the result.

◆ overlapping() [2/2]

template<class UserPredicate >
AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::overlapping ( const AddressInterval interval,
UserPredicate  userPredicate 
) const
inline

Users that overlap the interval.

The return value is a vector of address users (instructions and/or data blocks) sorted by starting address where each user overlaps with the interval. That is, at least one byte of the instruction or data block came from the specified interval of byte addresses. The specified predicate is used to select which users are inserted into the result and should be a functor that takes an AddressUser as an argument and returns true to select that user for inclusion in the result.

Definition at line 574 of file AddressUsageMap.h.

References Sawyer::Container::IntervalMap< I, T, Policy >::findAll(), and Rose::BinaryAnalysis::Partitioner2::AddressUsers::insert().

◆ containedIn()

AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::containedIn ( const AddressInterval ) const

Users that are fully contained in the interval.

The return value is a vector of address users (instructions and/or data blocks) sorted by starting address where each user is fully contained within the specified interval. That is, each user starts at or after the beginning of the interval and ends at or before the end of the interval. The specified predicate is used to select which users are inserted into the result and should be a functor that takes an AddressUser as an argument and returns true to select that user for inclusion in the result.

◆ leastUnmapped()

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::leastUnmapped ( rose_addr_t  startVa) const

Returns the least unmapped address with specified lower limit.

Returns the smallest unmapped address that is greater than or equal to startVa. If no such address exists then nothing is returned.

◆ print()

void Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::print ( std::ostream &  ,
const std::string &  prefix = "" 
) const

Dump the contents of this AUM to a stream.

The output contains one entry per line and the last line is terminated with a linefeed.

◆ checkConsistency()

void Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::checkConsistency ( ) const

Check invariants.

Aborts if invariants are not satisified.


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