ROSE  0.9.9.139
Public Member Functions | Static Public Member Functions | Protected 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 (and function and basic block owners). The list is maintained in a sorted order according to instruction or data block starting address. The class ensures that all users in the list have valid pointers and that the list contains no duplicates.

Definition at line 161 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 OwnedDataBlock &odb)
 Constructs a list having one data block user. More...
 
Sawyer::Optional< AddressUserinstructionExists (rose_addr_t insnStart) const
 Determines if an instruction exists in the list. More...
 
Sawyer::Optional< OwnedDataBlockdataBlockExists (const DataBlock::Ptr &) const
 Determines if a data block exists in the list. More...
 
Sawyer::Optional< OwnedDataBlockdataBlockExists (rose_addr_t dbStart) const
 Determines if a data block exists in the list. More...
 
BasicBlock::Ptr findBasicBlock (rose_addr_t bbVa) const
 Find the basic block that starts at this address. More...
 
void insertInstruction (SgAsmInstruction *, const BasicBlock::Ptr &)
 Insert an instruction/basic block pair. More...
 
void insertDataBlock (const OwnedDataBlock &)
 Insert a data block. More...
 
void insert (const AddressUsers &)
 Inser a user. More...
 
void eraseInstruction (SgAsmInstruction *, const BasicBlock::Ptr &)
 Erase an instruction/basic block pair from the list. More...
 
void eraseDataBlock (const DataBlock::Ptr &)
 Erase a data block user. 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...
 

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...
 

Protected Member Functions

std::vector< AddressUser >::iterator findInstruction (SgAsmInstruction *)
 

Constructor & Destructor Documentation

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

Constructs an empty list.

Definition at line 176 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 179 of file AddressUsageMap.h.

References insertInstruction().

Rose::BinaryAnalysis::Partitioner2::AddressUsers::AddressUsers ( const OwnedDataBlock odb)
inlineexplicit

Constructs a list having one data block user.

Definition at line 182 of file AddressUsageMap.h.

References insertDataBlock().

Member Function Documentation

Sawyer::Optional<AddressUser> Rose::BinaryAnalysis::Partitioner2::AddressUsers::instructionExists ( rose_addr_t  insnStart) const

Determines if an instruction exists in the list.

If an instruction with the specified starting address exists in the list then the address user information is returned, otherwise nothing is returned.

Sawyer::Optional<OwnedDataBlock> Rose::BinaryAnalysis::Partitioner2::AddressUsers::dataBlockExists ( const DataBlock::Ptr ) const

Determines if a data block exists in the list.

If the specified data block exists then its ownership information is returned, otherwise nothing is returned.

Sawyer::Optional<OwnedDataBlock> Rose::BinaryAnalysis::Partitioner2::AddressUsers::dataBlockExists ( rose_addr_t  dbStart) const

Determines if a data block exists in the list.

If a data block with the specified starting address exists in the list then its ownership information is returned, otherwise nothing is returned. It is possible that multiple data blocks can exist at a particular address, in which case an arbitrary one is returned.

BasicBlock::Ptr Rose::BinaryAnalysis::Partitioner2::AddressUsers::findBasicBlock ( rose_addr_t  bbVa) const

Find the basic block that starts at this address.

If this user is an instruction, then scan through its basic block owners (usually just one) and return a pointer to any basic block that starts at this address. Basic blocks in the AUM have unique starting addresses, thus this function returns either the pointer to such a block or the null pointer.

void 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.

Referenced by AddressUsers().

void Rose::BinaryAnalysis::Partitioner2::AddressUsers::insertDataBlock ( const OwnedDataBlock )

Insert a data block.

The specified data block ownership information (which must be valid) is inserted into this list of users. If this list already contains an ownership record for the data block, then the specified record is merged into the existing record.

Referenced by AddressUsers().

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

Inser a user.

The specified user information is inserted into this list of users. If this list already contains an equal record then the specified record is not inserted.

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

void Rose::BinaryAnalysis::Partitioner2::AddressUsers::eraseInstruction ( SgAsmInstruction ,
const BasicBlock::Ptr  
)

Erase an instruction/basic block pair from the list.

Finds the specified instruction 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.

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

Erase a data block user.

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

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 250 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 256 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 262 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 268 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 280 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 285 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 290 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 312 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 317 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: