Otawa  0.10
otawa::Segment Class Reference

In usual file format like ELF, COFF and so on, the program file is divided in segment according platform needs or memory propertes. More...

#include <otawa/prog/Segment.h>

Inheritance diagram for otawa::Segment:
otawa::PropList

Classes

class  ItemIter
 

Public Types

typedef t::uint32 flags_t
 

Public Member Functions

 Segment (CString name, address_t address, ot::size size, flags_t flags)
 Build a segment with the given information. More...
 
CString name (void) const
 Get tne name of the segment. More...
 
flags_t flags (void) const
 Get flag information about the segment. More...
 
bool isExecutable (void) const
 Test if the segment is executable. More...
 
bool isWritable (void) const
 Test if the segment is writable. More...
 
bool isInitialized (void) const
 Test if the segment is initialized. More...
 
address_t address (void) const
 Get the base address of the segment. More...
 
ot::size size (void) const
 Get the size of the segment. More...
 
address_t topAddress (void) const
 
ProgItemfindItemAt (const Address &addr)
 Find an item by its address. More...
 
InstfindInstAt (const Address &addr)
 Find an instruction by its address. More...
 
bool contains (const Address &addr) const
 
PropertygetProp (const AbstractIdentifier *id) const
 Find a property by its identifier. More...
 
void setProp (Property *prop)
 Set the property in the property list removing any double. More...
 
void setProp (const AbstractIdentifier *id)
 
void removeProp (const AbstractIdentifier *id)
 Remove a property matching the given identifier. More...
 
void removeProp (const AbstractIdentifier &id)
 
PropertyextractProp (const AbstractIdentifier *id)
 Remove a property matching the given identifier and return it. More...
 
PropertyextractProp (const AbstractIdentifier &id)
 Remove a property matching the given identifier and return it. More...
 
void addProp (Property *prop)
 Add property to the list without checking of duplication. More...
 
void removeAllProp (const AbstractIdentifier *id)
 Remove all the properties matching the given identifier. More...
 
bool hasProp (const AbstractIdentifier &id) const
 Test if the property list contains a property matching the given identifier. More...
 
void clearProps (void)
 Remove all properties from the list. More...
 
void addProps (const PropList &props)
 Add all properties from the given property list, in a reverse order. More...
 
void print (elm::io::Output &out) const
 Display the current property list. More...
 

Static Public Attributes

static const flags_t EXECUTABLE = 0x01
 Segment flags denoting an executable segment. More...
 
static const flags_t WRITABLE = 0x02
 Segment flags denoting a writable segment. More...
 
static const flags_t INITIALIZED = 0x04
 Segment flags denoting an initialzied segment. More...
 
static const PropList EMPTY
 This is an empty proplist for convenience. More...
 

Protected Member Functions

virtual Instdecode (address_t address)
 Decode the instruction at the given address. More...
 
virtual ~Segment (void)
 Protected destructor for avoiding implementation unexpected deletion. More...
 
void insert (ProgItem *item)
 Insert the item in the list. More...
 

Private Attributes

flags_t _flags
 
CString _name
 
Address _address
 
ot::size _size
 
inhstruct::DLList items
 
ProgItem ** map
 

Friends

class File
 

Detailed Description

In usual file format like ELF, COFF and so on, the program file is divided in segment according platform needs or memory propertes.

Usually, we find a ".text" segment containing program code,
".data" containing initialized data, ".bss" containing uninitialized data, ".rodata" containing read-only data. Yet, more segments may be available.

Member Typedef Documentation

Constructor & Destructor Documentation

otawa::Segment::Segment ( CString  name,
address_t  address,
ot::size  size,
flags_t  flags 
)

Build a segment with the given information.

Parameters
nameSegment name in the file format (".text", ".data", ...).
addressSegment address in the process memory space.
sizeSegment size (in bytes).
flagsAs returned by the flags() accessor. A combination of WRITABLE, EXECUTABLE and INITIALIZED .

References map, and MAP_SIZE.

otawa::Segment::~Segment ( void  )
protectedvirtual

Protected destructor for avoiding implementation unexpected deletion.

References elm::inhstruct::DLList::first(), elm::inhstruct::DLList::isEmpty(), items, map, and elm::inhstruct::DLList::removeFirst().

Member Function Documentation

address_t otawa::Segment::address ( void  ) const
inline

Get the base address of the segment.

Returns
Base address of the segment or 0 if no address has been assigned to the segment.

Referenced by findItemAt(), and insert().

void otawa::PropList::clearProps ( void  )
inherited
bool otawa::Segment::contains ( const Address addr) const
inline

References otawa::ot::address().

Inst * otawa::Segment::decode ( address_t  address)
protectedvirtual

Decode the instruction at the given address.

This method must overriden by the ISA plugins to provide the actual decoding of the instruction. This method returns null as the default.

Parameters
addressAddress of the instruction to decode.
Returns
Decoded instruction or null if the address is invalid.

Referenced by findInstAt().

Property * otawa::PropList::extractProp ( const AbstractIdentifier id)
inherited

Remove a property matching the given identifier and return it.

Caller is responsible of the management of the obtained property.

Parameters
idIdentifier of the property to extract.

References otawa::Property::_next, and otawa::Property::next().

Referenced by otawa::script::Script::makeConfig().

Property * otawa::PropList::extractProp ( const AbstractIdentifier id)
inlineinherited

Remove a property matching the given identifier and return it.

Caller is responsible of the management of the obtained property.

Parameters
idIdentifier of the property to extract.

References otawa::PropList::extractProp().

Referenced by otawa::PropList::extractProp().

Inst * otawa::Segment::findInstAt ( const Address addr)

Find an instruction by its address.

Parameters
addrAddress to find an instruction for.
Returns
Found instruction or null.

References decode(), findItemAt(), insert(), and otawa::ProgItem::toInst().

ProgItem * otawa::Segment::findItemAt ( const Address addr)

Find an item by its address.

Parameters
addrAddress to find an instruction for.
Returns
Found item or null.

References otawa::ProgItem::address(), address(), map, MAP_INDEX, otawa::ProgItem::next(), otawa::Address::page(), and topAddress().

Referenced by findInstAt().

int otawa::Segment::flags ( void  ) const
inline

Get flag information about the segment.

This flags are composed by OR'ing the constants EXECUTABLE, WRITABLE and INITIALIZED .

Returns
Flags value.
bool otawa::PropList::hasProp ( const AbstractIdentifier id) const
inlineinherited

Test if the property list contains a property matching the given identifier.

Parameters
idProperty identifier to look for.
Returns
True if the list contains the matching property, false else.

References otawa::PropList::getProp().

Referenced by otawa::ipet::BasicConstraintsBuilder::addEntryConstraint(), otawa::Monitor::configure(), otawa::ImmutableRef< T, I >::exists(), and otawa::Manager::setVerbosity().

bool otawa::Segment::isExecutable ( void  ) const
inline

Test if the segment is executable.

Returns
True if the segment is executable, false else.
bool otawa::Segment::isInitialized ( void  ) const
inline

Test if the segment is initialized.

Returns
True if the segment is initialized, false else.
bool otawa::Segment::isWritable ( void  ) const
inline

Test if the segment is writable.

Returns
True if the segment is writable, false else.
CString otawa::Segment::name ( void  ) const
inline

Get tne name of the segment.

Returns
Name of the segment.

Referenced by otawa::CFGBuilder::buildCFG().

void otawa::PropList::print ( elm::io::Output out) const
inherited

Display the current property list.

Parameters
outOutput to use.

Referenced by otawa::operator<<(), and otawa::ContextualProperty::print().

void otawa::PropList::removeAllProp ( const AbstractIdentifier id)
inherited

Remove all the properties matching the given identifier.

Parameters
idIdentifier of properties to remove.

References otawa::Property::_next, and otawa::Property::next().

Referenced by otawa::LoopUnroller::unroll().

void otawa::PropList::removeProp ( const AbstractIdentifier id)
inherited
void otawa::PropList::removeProp ( const AbstractIdentifier id)
inlineinherited
void otawa::PropList::setProp ( Property prop)
inherited

Set the property in the property list removing any double.

Parameters
propProperty to set.

References otawa::Property::_next, otawa::Property::id(), and otawa::Property::next().

void otawa::PropList::setProp ( const AbstractIdentifier id)
inlineinherited
size_t otawa::Segment::size ( void  ) const
inline

Get the size of the segment.

Returns
Size of the segment.
address_t otawa::Segment::topAddress ( void  ) const
inline

Friends And Related Function Documentation

friend class File
friend

Member Data Documentation

Address otawa::Segment::_address
private
flags_t otawa::Segment::_flags
private
CString otawa::Segment::_name
private
ot::size otawa::Segment::_size
private
const PropList otawa::PropList::EMPTY
staticinherited

This is an empty proplist for convenience.

otawa::Segment::EXECUTABLE = 0x01
static

Segment flags denoting an executable segment.

otawa::Segment::INITIALIZED = 0x04
static

Segment flags denoting an initialzied segment.

inhstruct::DLList otawa::Segment::items
private
ProgItem** otawa::Segment::map
private

Referenced by findItemAt(), insert(), Segment(), and ~Segment().

otawa::Segment::WRITABLE = 0x02
static

Segment flags denoting a writable segment.


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