ROSE 0.11.145.192
|
Data block information.
A data block represents static data with a type. Data blocks are identified by a key consisting of their starting address and total size. Data blocks can be either attached to the partitioner or in a detached state. A block that is attached will be present in the Address Usage Map (AUM), but the AUM will store only one DataBlock object per distinct key.
A data block can be owned by multiple basic blocks and/or functions. If an owning basic block or function is attached to the partitioner then the data block will also be attached. However, data blocks can be attached when some or all of their owners are in the detached state. When attaching a basic block or function that owns a data block, if the AUM already has a different but equivaent (by keys) data block then the owning basic block or function will be adjusted to point to the equivalent data block.
Definition at line 35 of file DataBlock.h.
#include <Rose/BinaryAnalysis/Partitioner2/DataBlock.h>
Public Types | |
typedef Sawyer::SharedPointer< DataBlock > | Ptr |
Shared pointer to a data block. | |
Public Types inherited from Sawyer::Attribute::Storage< SyncTag > | |
typedef SynchronizationTraits< SyncTag > | Sync |
Public Member Functions | |
bool | isFrozen () const |
Determine if data block is read-only. | |
rose_addr_t | address () const |
Returns the starting address. | |
size_t | size () const |
Returns the size in bytes. | |
size_t | nAttachedOwners () const |
Number of attached basic block and function owners. | |
const std::vector< FunctionPtr > & | attachedFunctionOwners () const |
Functions that are attached to the partitioner and own this data block. | |
const std::vector< BasicBlockPtr > & | attachedBasicBlockOwners () const |
Basic blocks that are attached to the partitioner and own this data block. | |
AddressInterval | extent () const |
Addresses represented. | |
std::string | printableName () const |
A printable name for this data block. | |
std::vector< uint8_t > | read (const MemoryMapPtr &) const |
Read static data from a memory map. | |
SgAsmType * | type () const |
Property: Type of data stored in this block. | |
void | type (SgAsmType *t) |
Property: Type of data stored in this block. | |
const std::string & | comment () const |
Property: Comment. | |
void | comment (const std::string &s) |
Property: Comment. | |
const SourceLocation & | sourceLocation () const |
Property: Optional location of data in source code. | |
void | sourceLocation (const SourceLocation &) |
Property: Optional location of data in source code. | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. | |
SharedObject (const SharedObject &) | |
Copy constructor. | |
virtual | ~SharedObject () |
Virtual destructor. | |
SharedObject & | operator= (const SharedObject &) |
Assignment. | |
Public Member Functions inherited from Sawyer::Attribute::Storage< SyncTag > | |
Storage () | |
Default constructor. | |
Storage (const Storage &other) | |
Copy constructor. | |
Storage & | operator= (const Storage &other) |
Assignment operator. | |
bool | attributeExists (Id id) const |
Check attribute existence. | |
void | eraseAttribute (Id id) |
Erase an attribute. | |
void | clearAttributes () |
Erase all attributes. | |
template<typename T > | |
void | setAttribute (Id id, const T &value) |
Store an attribute. | |
template<typename T > | |
bool | setAttributeMaybe (Id id, const T &value) |
Store an attribute if not already present. | |
template<typename T > | |
T | getAttribute (Id id) const |
Get an attribute that is known to exist. | |
template<typename T > | |
Sawyer::Optional< T > | getAttributeMaybe (const Id id) const |
Return an attribute if it exists, or else nothing. | |
template<typename T > | |
T | attributeOrElse (Id id, const T &dflt) const |
Return an attribute or a specified value. | |
template<typename T > | |
T | attributeOrDefault (Id id) const |
Return an attribute or a default-constructed value. | |
template<typename T > | |
Sawyer::Optional< T > | optionalAttribute (Id id) const |
Return the attribute as an optional value. | |
size_t | nAttributes () const |
Number of attributes stored. | |
std::vector< Id > | attributeIds () const |
Returns ID numbers for all IDs stored in this container. | |
Static Public Member Functions | |
static Ptr | instance (rose_addr_t startVa, SgAsmType *) |
Static allocating constructor. | |
static Ptr | instanceBytes (rose_addr_t startVa, size_t nBytes) |
Static allocating constructor. | |
Protected Member Functions | |
DataBlock (rose_addr_t startVa, SgAsmType *type) | |
Shared pointer to a data block.
Definition at line 38 of file DataBlock.h.
|
static |
Static allocating constructor.
Creates a data block whose type is just an array of bytes.
The startVa
is the starting address of the data block.
|
inline |
Determine if data block is read-only.
Returns true if read-only, false otherwise.
Definition at line 78 of file DataBlock.h.
|
inline |
Returns the starting address.
Definition at line 81 of file DataBlock.h.
|
inline |
Property: Type of data stored in this block.
The type can only be changed when the data block is in a detached state (i.e., when isFrozen is false).
Definition at line 91 of file DataBlock.h.
void Rose::BinaryAnalysis::Partitioner2::DataBlock::type | ( | SgAsmType * | t | ) |
Property: Type of data stored in this block.
The type can only be changed when the data block is in a detached state (i.e., when isFrozen is false).
size_t Rose::BinaryAnalysis::Partitioner2::DataBlock::nAttachedOwners | ( | ) | const |
Number of attached basic block and function owners.
Returns the number of basic blocks and functions that are attached to the CFG/AUM and that own this data block.
const std::vector< FunctionPtr > & Rose::BinaryAnalysis::Partitioner2::DataBlock::attachedFunctionOwners | ( | ) | const |
Functions that are attached to the partitioner and own this data block.
The returned vector is sorted and has unique elements.
const std::vector< BasicBlockPtr > & Rose::BinaryAnalysis::Partitioner2::DataBlock::attachedBasicBlockOwners | ( | ) | const |
Basic blocks that are attached to the partitioner and own this data block.
The returned vector is sorted and has unique elements.
std::string Rose::BinaryAnalysis::Partitioner2::DataBlock::printableName | ( | ) | const |
A printable name for this data block.
Returns a string like 'data block 0x10001234'.
std::vector< uint8_t > Rose::BinaryAnalysis::Partitioner2::DataBlock::read | ( | const MemoryMapPtr & | ) | const |
Read static data from a memory map.
This is a simple wrapper around memory map reading functionality so that the data for this static data block can be retrieved from the memory map without needing to know how to use the quite extensive memory map API. This method reads this object's data from the provided memory map and returns a vector of the bytes. The returned vector will be truncated if any of the bytes of this data block are not present in the map.