GTIRB  v1.10.4
GrammaTech Intermediate Representation for Binaries: C++ API
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
gtirb::CodeBlock Class Reference

A basic block. More...

#include <CodeBlock.hpp>

Inheritance diagram for gtirb::CodeBlock:
Inheritance graph
[legend]
Collaboration diagram for gtirb::CodeBlock:
Collaboration graph
[legend]

Public Types

template<typename T >
using bytes_iterator = ByteInterval::bytes_iterator< T >
 Iterator over bytes in this block. More...
 
template<typename T >
using bytes_range = ByteInterval::bytes_range< T >
 Range over bytes in this block. More...
 
template<typename T >
using const_bytes_iterator = ByteInterval::const_bytes_iterator< T >
 Const iterator over bytes in this block. More...
 
template<typename T >
using const_bytes_range = ByteInterval::const_bytes_range< T >
 Const range over bytes in this block. More...
 

Public Member Functions

template<typename T >
bytes_range< T > bytes ()
 Get a range of the bytes in this block. More...
 
template<typename T >
const_bytes_range< T > bytes () const
 Get a range of the bytes in this block. More...
 
template<typename T >
bytes_range< T > bytes (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native)
 Get a range of the bytes in this block. More...
 
template<typename T >
const_bytes_range< T > bytes (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native) const
 Get a range of the bytes in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_begin ()
 Get an iterator to the first byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_begin () const
 Get an iterator to the first byte in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_begin (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native)
 Get an iterator to the first byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_begin (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native) const
 Get an iterator to the first byte in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_end ()
 Get an iterator past the last byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_end () const
 Get an iterator past the last byte in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_end (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native)
 Get an iterator past the last byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_end (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native) const
 Get an iterator past the last byte in this block. More...
 
std::optional< AddrgetAddress () const
 Get the address of this block, if present. See ByteInterval::getAddress for details on why this address may not be present. More...
 
ByteIntervalgetByteInterval ()
 Get the ByteInterval this block belongs to. More...
 
const ByteIntervalgetByteInterval () const
 Get the ByteInterval this block belongs to. More...
 
uint64_t getDecodeMode () const
 Get the decode mode from a CodeBlock. More...
 
uint64_t getOffset () const
 Get the offset from the beginning of the ByteInterval this block belongs to. More...
 
uint64_t getSize () const
 Get the size from a CodeBlock. More...
 
template<typename T >
T * rawBytes ()
 Return the raw data underlying this block's byte vector. More...
 
template<typename T >
const T * rawBytes () const
 Return the raw data underlying this block's byte vector. More...
 
void setDecodeMode (uint64_t DM)
 Set the decode mode of this block. More...
 
void setSize (uint64_t S)
 Set the size of this block. More...
 
- Public Member Functions inherited from gtirb::Node
 Node (const Node &)=delete
 Copying Nodes is explicitly disabled. More...
 
 Node (Node &&)=delete
 Move-constructing Nodes is explicitly disabled. More...
 
 ~Node () noexcept
 Cleans up resources no longer needed by the Node object. More...
 
const UUIDgetUUID () const
 Get the Universally Unique ID (UUID) for this. More...
 
Nodeoperator= (const Node &)=delete
 Copying Nodes is explicilty disabled. More...
 
Nodeoperator= (Node &&)=delete
 Move-assigning Nodes is explicilty disabled. More...
 

Static Public Member Functions

static CodeBlockCreate (Context &C)
 Create an unitialized CodeBlock object. More...
 
static CodeBlockCreate (Context &C, uint64_t Size, uint64_t DecodeMode=0)
 Create a CodeBlock object. More...
 
- Static Public Member Functions inherited from gtirb::Node
static NodeCreate (Context &C)
 Create a Node object in its default state. More...
 
static const NodegetByUUID (const Context &C, const UUID &Uuid)
 Retrieve a node by its UUID. More...
 
static NodegetByUUID (Context &C, const UUID &Uuid)
 Retrieve a node by its UUID. More...
 

Friends

class ByteInterval
 
class Context
 
class SerializationTestHarness
 

Additional Inherited Members

- Protected Member Functions inherited from gtirb::CfgNode
 CfgNode (Context &C, Kind Knd)
 
 CfgNode (Context &C, Kind Knd, const UUID &U)
 

Detailed Description

A basic block.

See also
Control Flow Graphs (CFGs)

Member Typedef Documentation

◆ bytes_iterator

Iterator over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_range

template<typename T >
using gtirb::CodeBlock::bytes_range = ByteInterval::bytes_range<T>

Range over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ const_bytes_iterator

Const iterator over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ const_bytes_range

Const range over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

Member Function Documentation

◆ bytes() [1/4]

template<typename T >
bytes_range<T> gtirb::CodeBlock::bytes ( )
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes() [2/4]

template<typename T >
const_bytes_range<T> gtirb::CodeBlock::bytes ( ) const
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes() [3/4]

template<typename T >
bytes_range<T> gtirb::CodeBlock::bytes ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
)
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes() [4/4]

template<typename T >
const_bytes_range<T> gtirb::CodeBlock::bytes ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
) const
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_begin() [1/4]

template<typename T >
bytes_iterator<T> gtirb::CodeBlock::bytes_begin ( )
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_begin() [2/4]

template<typename T >
const_bytes_iterator<T> gtirb::CodeBlock::bytes_begin ( ) const
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_begin() [3/4]

template<typename T >
bytes_iterator<T> gtirb::CodeBlock::bytes_begin ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
)
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_begin() [4/4]

template<typename T >
const_bytes_iterator<T> gtirb::CodeBlock::bytes_begin ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
) const
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_end() [1/4]

template<typename T >
bytes_iterator<T> gtirb::CodeBlock::bytes_end ( )
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_end() [2/4]

template<typename T >
const_bytes_iterator<T> gtirb::CodeBlock::bytes_end ( ) const
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_end() [3/4]

template<typename T >
bytes_iterator<T> gtirb::CodeBlock::bytes_end ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
)
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_end() [4/4]

template<typename T >
const_bytes_iterator<T> gtirb::CodeBlock::bytes_end ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
) const
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ Create() [1/2]

static CodeBlock* gtirb::CodeBlock::Create ( Context C)
inlinestatic

Create an unitialized CodeBlock object.

Parameters
CThe Context in which this CodeBlock will be held.
Returns
The newly created CodeBlock.

◆ Create() [2/2]

static CodeBlock* gtirb::CodeBlock::Create ( Context C,
uint64_t  Size,
uint64_t  DecodeMode = 0 
)
inlinestatic

Create a CodeBlock object.

Parameters
CThe Context in which this block will be held.
SizeThe size of the block in bytes.
DecodeModeThe decode mode of the block.
Returns
The newly created CodeBlock.

◆ getAddress()

std::optional<Addr> gtirb::CodeBlock::getAddress ( ) const

Get the address of this block, if present. See ByteInterval::getAddress for details on why this address may not be present.

◆ getByteInterval() [1/2]

ByteInterval* gtirb::CodeBlock::getByteInterval ( )
inline

Get the ByteInterval this block belongs to.

◆ getByteInterval() [2/2]

const ByteInterval* gtirb::CodeBlock::getByteInterval ( ) const
inline

Get the ByteInterval this block belongs to.

◆ getDecodeMode()

uint64_t gtirb::CodeBlock::getDecodeMode ( ) const
inline

Get the decode mode from a CodeBlock.

This field is used in some ISAs where it is used to differentiate between sub-ISAs; ARM and Thumb, for example.

Returns
The decode mode.

◆ getOffset()

uint64_t gtirb::CodeBlock::getOffset ( ) const

Get the offset from the beginning of the ByteInterval this block belongs to.

◆ getSize()

uint64_t gtirb::CodeBlock::getSize ( ) const
inline

Get the size from a CodeBlock.

Returns
The size in bytes.

Use with CodeBlock::getAddress() to obtain arguments to pass to ByteMap::data() for an iterator over the contents of a CodeBlock.

◆ rawBytes() [1/2]

template<typename T >
T* gtirb::CodeBlock::rawBytes ( )
inline

Return the raw data underlying this block's byte vector.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Much like std::vector::data, this function is low-level and potentially unsafe. This pointer refers to valid memory only where an iterator would be valid to point to. Modifying the size of the byte vector may invalidate this pointer. Any endian conversions will not be performed.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type.

\retrurn A pointer to raw data.

◆ rawBytes() [2/2]

template<typename T >
const T* gtirb::CodeBlock::rawBytes ( ) const
inline

Return the raw data underlying this block's byte vector.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Much like std::vector::data, this function is low-level and potentially unsafe. This pointer refers to valid memory only where an iterator would be valid to point to. Modifying the size of the byte vector may invalidate this pointer. Any endian conversions will not be performed.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type.

\retrurn A pointer to raw data.

◆ setDecodeMode()

void gtirb::CodeBlock::setDecodeMode ( uint64_t  DM)
inline

Set the decode mode of this block.

This field is used in some ISAs where it is used to differentiate between sub-ISAs; ARM and Thumb, for example.

◆ setSize()

void gtirb::CodeBlock::setSize ( uint64_t  S)
inline

Set the size of this block.

Note that this does not automatically update any ByteInterval's size, bytes, or symbolic expressions. This simply changes the extents of a block in its ByteInterval.

Friends And Related Function Documentation

◆ ByteInterval

friend class ByteInterval
friend

◆ Context

friend class Context
friend

◆ SerializationTestHarness

friend class SerializationTestHarness
friend

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