ROSE  0.9.11.56
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 179 of file AddressUsageMap.h.

#include <AddressUsageMap.h>

Public Member Functions

 AddressUsers ()
 Constructs an empty list. More...
 
 AddressUsers (SgAsmInstruction *insn, const BasicBlock::Ptr &bb)
 Constructs a list having one instruction user. More...
 
 AddressUsers (const DataBlock::Ptr &db)
 Constructs a list having one data block user. More...
 
AddressUser insertInstruction (SgAsmInstruction *, const BasicBlock::Ptr &)
 Insert an instruction/basic block pair. More...
 
AddressUser insertDataBlock (const DataBlock::Ptr &)
 Insert a data block. More...
 
void insert (const AddressUsers &)
 Insert one set of address users into another. More...
 
SgAsmInstructioneraseInstruction (SgAsmInstruction *, const BasicBlock::Ptr &)
 Erase an instruction/basic block pair from this list. More...
 
DataBlock::Ptr eraseDataBlock (const DataBlock::Ptr &)
 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< BasicBlock::PtrinstructionOwners () const
 Returns all basic blocks. More...
 
std::vector< DataBlock::PtrdataBlocks () 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...
 
BasicBlock::Ptr basicBlockExists (const BasicBlock::Ptr &) const
 Determines whether the specified basic block or an equivalent exists. More...
 
BasicBlock::Ptr basicBlockExists (rose_addr_t va) const
 Determines whether the specified basic block or an equivalent exists. More...
 
DataBlock::Ptr dataBlockExists (const DataBlock::Ptr &) const
 Determines whether the specified data block or an equivalent exists. More...
 
DataBlock::Ptr 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 BasicBlock::Ptr &) 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 DataBlock::Ptr &) 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 &user)
 Selector to select instructions and basic blocks. More...
 
static bool selectDataBlocks (const AddressUser &user)
 Selector to select data blocks. More...
 

Constructor & Destructor Documentation

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

Constructs an empty list.

Definition at line 194 of file AddressUsageMap.h.

Rose::BinaryAnalysis::Partitioner2::AddressUsers::AddressUsers ( SgAsmInstruction insn,
const BasicBlock::Ptr bb 
)
inlineexplicit

Constructs a list having one instruction user.

Definition at line 197 of file AddressUsageMap.h.

References insertInstruction().

Rose::BinaryAnalysis::Partitioner2::AddressUsers::AddressUsers ( const DataBlock::Ptr db)
inlineexplicit

Constructs a list having one data block user.

Definition at line 202 of file AddressUsageMap.h.

References insertDataBlock().

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.

BasicBlock::Ptr Rose::BinaryAnalysis::Partitioner2::AddressUsers::basicBlockExists ( const BasicBlock::Ptr ) 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.

BasicBlock::Ptr 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.

DataBlock::Ptr Rose::BinaryAnalysis::Partitioner2::AddressUsers::dataBlockExists ( const DataBlock::Ptr ) 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.

DataBlock::Ptr 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 BasicBlock::Ptr ) 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 DataBlock::Ptr ) 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 BasicBlock::Ptr  
)

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.

Referenced by AddressUsers().

AddressUser Rose::BinaryAnalysis::Partitioner2::AddressUsers::insertDataBlock ( const DataBlock::Ptr )

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.

Referenced by AddressUsers().

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 BasicBlock::Ptr  
)

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.

DataBlock::Ptr Rose::BinaryAnalysis::Partitioner2::AddressUsers::eraseDataBlock ( const DataBlock::Ptr )

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 )
inlinestatic

Selector to select all users.

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

Definition at line 303 of file AddressUsageMap.h.

Referenced by Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::containedIn(), Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::overlapping(), and Rose::BinaryAnalysis::Partitioner2::AddressUsageMap::spanning().

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

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.

Definition at line 311 of file AddressUsageMap.h.

References Rose::BinaryAnalysis::Partitioner2::AddressUser::isBasicBlock().

Referenced by instructionUsers().

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

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.

Definition at line 319 of file AddressUsageMap.h.

References Rose::BinaryAnalysis::Partitioner2::AddressUser::isDataBlock().

Referenced by dataBlockUsers().

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 327 of file AddressUsageMap.h.

Referenced by dataBlockUsers(), and instructionUsers().

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

Return all address users.

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

Definition at line 339 of file AddressUsageMap.h.

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

Returns all instruction users.

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

Definition at line 346 of file AddressUsageMap.h.

References select(), and selectBasicBlocks().

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

Returns all data block users.

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

Definition at line 353 of file AddressUsageMap.h.

References select(), and selectDataBlocks().

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<BasicBlock::Ptr> 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<DataBlock::Ptr> 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
inline

Number of address users.

Definition at line 377 of file AddressUsageMap.h.

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

Determines whether this address user list is empty.

Returns true if empty, false otherwise.

Definition at line 384 of file AddressUsageMap.h.

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: