ROSE  0.11.145.0
Public Member Functions | Static Public Member Functions | List of all members
Rose::BinaryAnalysis::Partitioner2::AddressUsers Class Reference

Description

List of virtual address users.

This is a list of users of virtual addresses. A user is either an instruction (and basic block owners) or a data block The list is maintained in a sorted order according to instruction or data block comparators. The class ensures that all users in the list have valid pointers and that the list contains no duplicates.

Definition at line 165 of file AddressUsageMap.h.

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

Public Member Functions

 AddressUsers ()
 Constructs an empty list. More...
 
 AddressUsers (SgAsmInstruction *insn, const BasicBlockPtr &)
 Constructs a list having one instruction user. More...
 
 AddressUsers (const DataBlockPtr &)
 Constructs a list having one data block user. More...
 
AddressUser insertInstruction (SgAsmInstruction *, const BasicBlockPtr &)
 Insert an instruction/basic block pair. More...
 
AddressUser insertDataBlock (const DataBlockPtr &)
 Insert a data block. More...
 
void insert (const AddressUsers &)
 Insert one set of address users into another. More...
 
SgAsmInstructioneraseInstruction (SgAsmInstruction *, const BasicBlockPtr &)
 Erase an instruction/basic block pair from this list. More...
 
DataBlockPtr eraseDataBlock (const DataBlockPtr &)
 Erase a data block from this list. More...
 
template<class UserPredicate >
AddressUsers select (UserPredicate predicate) const
 Selects certain users from a list. More...
 
const std::vector< AddressUser > & addressUsers () const
 Return all address users. More...
 
AddressUsers instructionUsers () const
 Returns all instruction users. More...
 
AddressUsers dataBlockUsers () const
 Returns all data block users. More...
 
std::vector< SgAsmInstruction * > instructions () const
 Returns all instructions. More...
 
std::vector< BasicBlockPtrinstructionOwners () const
 Returns all basic blocks. More...
 
std::vector< DataBlockPtrdataBlocks () const
 Returns all data blocks. More...
 
size_t size () const
 Number of address users. More...
 
bool isEmpty () const
 Determines whether this address user list is empty. More...
 
AddressUsers intersection (const AddressUsers &) const
 Computes the intersection of this list with another. More...
 
AddressUsers union_ (const AddressUsers &) const
 Computes the union of this list with another. More...
 
bool operator== (const AddressUsers &other) const
 True if two lists are equal. More...
 
void print (std::ostream &) const
 Prints pairs space separated on a single line. More...
 
bool isConsistent () const
 Check logical consistency. More...
 
SgAsmInstructioninstructionExists (SgAsmInstruction *) const
 Determines whether the specified instruction or an equivalent exists. More...
 
SgAsmInstructioninstructionExists (rose_addr_t va) const
 Determines whether the specified instruction or an equivalent exists. More...
 
BasicBlockPtr basicBlockExists (const BasicBlockPtr &) const
 Determines whether the specified basic block or an equivalent exists. More...
 
BasicBlockPtr basicBlockExists (rose_addr_t va) const
 Determines whether the specified basic block or an equivalent exists. More...
 
DataBlockPtr dataBlockExists (const DataBlockPtr &) const
 Determines whether the specified data block or an equivalent exists. More...
 
DataBlockPtr dataBlockExists (rose_addr_t va, rose_addr_t size) const
 Determines whether the specified data block or an equivalent exists. More...
 
AddressUser findInstruction (SgAsmInstruction *) const
 Find an AddressUser record for the specified instruction, or equivalent. More...
 
AddressUser findInstruction (rose_addr_t va) const
 Find an AddressUser record for the specified instruction, or equivalent. More...
 
AddressUser findBasicBlock (const BasicBlockPtr &) const
 Find an AddressUser record for the specified basic block, or equivalent. More...
 
AddressUser findBasicBlock (rose_addr_t va) const
 Find an AddressUser record for the specified basic block, or equivalent. More...
 
AddressUser findDataBlock (const DataBlockPtr &) const
 Find an AddressUser record for the specified data block, or equivalent. More...
 
AddressUser findDataBlock (rose_addr_t va, rose_addr_t size) const
 Find an AddressUser record for the specified data block, or equivalent. More...
 

Static Public Member Functions

static bool selectAllUsers (const AddressUser &)
 Selector to select all users. More...
 
static bool selectBasicBlocks (const AddressUser &)
 Selector to select instructions and basic blocks. More...
 
static bool selectDataBlocks (const AddressUser &)
 Selector to select data blocks. More...
 

Constructor & Destructor Documentation

Rose::BinaryAnalysis::Partitioner2::AddressUsers::AddressUsers ( )

Constructs an empty list.

Rose::BinaryAnalysis::Partitioner2::AddressUsers::AddressUsers ( SgAsmInstruction insn,
const BasicBlockPtr  
)
explicit

Constructs a list having one instruction user.

Rose::BinaryAnalysis::Partitioner2::AddressUsers::AddressUsers ( const DataBlockPtr )
explicit

Constructs a list having one data block user.

Member Function Documentation

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

Determines whether the specified instruction or an equivalent exists.

Returns a non-null pointer to the instruction contained in this object if the specified instruction or an equivalent can be found, otherwise returns a null pointer. The search can be done by SgAsmInstruction pointer or a starting address.

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

Determines whether the specified instruction or an equivalent exists.

Returns a non-null pointer to the instruction contained in this object if the specified instruction or an equivalent can be found, otherwise returns a null pointer. The search can be done by SgAsmInstruction pointer or a starting address.

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

Determines whether the specified basic block or an equivalent exists.

Returns a non-null pointer to the basic block contained in this object if the specified basic block or an equivalent can be found, otherwise returns a null pointer. The search can be done by BasicBlock object or a starting address. The basic block is found only if its first instruction is present.

BasicBlockPtr Rose::BinaryAnalysis::Partitioner2::AddressUsers::basicBlockExists ( rose_addr_t  va) const

Determines whether the specified basic block or an equivalent exists.

Returns a non-null pointer to the basic block contained in this object if the specified basic block or an equivalent can be found, otherwise returns a null pointer. The search can be done by BasicBlock object or a starting address. The basic block is found only if its first instruction is present.

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

Determines whether the specified data block or an equivalent exists.

Returns a non-null pointer to the data block contained in this object if the specified data block or an equivalent can be found, otherwise returns a null pointer. The search can be done by DataBlock object or a starting address and size.

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

Determines whether the specified data block or an equivalent exists.

Returns a non-null pointer to the data block contained in this object if the specified data block or an equivalent can be found, otherwise returns a null pointer. The search can be done by DataBlock object or a starting address and size.

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsers::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.

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsers::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.

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsers::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.

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsers::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.

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsers::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.

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsers::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.

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

Insert an instruction/basic block pair.

Neither the instruction nor the basic block may be null. If this list already contains the specified instruction, then the specified basic block is merged into its owner list and a reference to that user is returned.

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

Insert a data block.

The specified data block is inserted into this list of users unless it or an equivalent data block is already present. Returns the record describing the data block.

void Rose::BinaryAnalysis::Partitioner2::AddressUsers::insert ( const AddressUsers )

Insert one set of address users into another.

Referenced by Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::overlapping().

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

Erase an instruction/basic block pair from this list.

Finds the specified instruction or equivalent in the list and removes the specified basic block owner. If this results in the instruction not being owned by any blocks then the instruction is removed. Returns the affected instruction.

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

Erase a data block from this list.

Erases the specified data block or equivalent from this list. If the data block is null or the list does not contain the data block then this is a no-op. Returns the erased data block.

static bool Rose::BinaryAnalysis::Partitioner2::AddressUsers::selectAllUsers ( const AddressUser )
static

Selector to select all users.

This selector is the default for methods like AddressUsageMap::overlapping, and causes all users to be selected.

static bool Rose::BinaryAnalysis::Partitioner2::AddressUsers::selectBasicBlocks ( const AddressUser )
static

Selector to select instructions and basic blocks.

This selector can be passed as the argument to the select method, or to methods like AddressUsageMap::overlapping to select only those users that are instructions and basic blocks.

static bool Rose::BinaryAnalysis::Partitioner2::AddressUsers::selectDataBlocks ( const AddressUser )
static

Selector to select data blocks.

This selector can be passed as the argument to the select method, or to methods like AddressUsageMap::overlapping to select only those users that are data blocks.

template<class UserPredicate >
AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsers::select ( UserPredicate  predicate) const
inline

Selects certain users from a list.

Returns a new address users list containing only those users for which the predicate returns true.

Definition at line 304 of file AddressUsageMap.h.

Referenced by Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::spanning().

const std::vector<AddressUser>& Rose::BinaryAnalysis::Partitioner2::AddressUsers::addressUsers ( ) const

Return all address users.

Returns all address users as a vector sorted by starting address.

AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsers::instructionUsers ( ) const

Returns all instruction users.

Returns a new list of address users that contains only the instruction users from this list.

AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsers::dataBlockUsers ( ) const

Returns all data block users.

Returns a new list of address users that contains only the data block users from this list.

std::vector<SgAsmInstruction*> Rose::BinaryAnalysis::Partitioner2::AddressUsers::instructions ( ) const

Returns all instructions.

Returns a list of distinct instructions sorted by starting address. The return value is not an AddressUsers because it is more useful to have a list of distinct instructions, and because the instructionUsers method returns the other information already.

std::vector<BasicBlockPtr> Rose::BinaryAnalysis::Partitioner2::AddressUsers::instructionOwners ( ) const

Returns all basic blocks.

Returns a list of pointers to distinct basic blocks sorted by starting address. The return value is not an AddressUsers because it is more useful to have a list of distinct basic blocks, and because the instructionUsers method returns the other information already.

std::vector<DataBlockPtr> Rose::BinaryAnalysis::Partitioner2::AddressUsers::dataBlocks ( ) const

Returns all data blocks.

Returns a list of pointers to distinct data blocks sorted by starting address.

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

Number of address users.

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

Determines whether this address user list is empty.

Returns true if empty, false otherwise.

Referenced by Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::spanning().

AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsers::intersection ( const AddressUsers ) const

Computes the intersection of this list with another.

Referenced by Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::spanning().

AddressUsers Rose::BinaryAnalysis::Partitioner2::AddressUsers::union_ ( const AddressUsers ) const

Computes the union of this list with another.

bool Rose::BinaryAnalysis::Partitioner2::AddressUsers::operator== ( const AddressUsers other) const

True if two lists are equal.

void Rose::BinaryAnalysis::Partitioner2::AddressUsers::print ( std::ostream &  ) const

Prints pairs space separated on a single line.

bool Rose::BinaryAnalysis::Partitioner2::AddressUsers::isConsistent ( ) const

Check logical consistency.

Ensures that this object is logically consistent. If assertions are enabled this asserts, otherwise it returns false.


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