Otawa  0.10
otawa::Symbol Class Reference

A symbol is a name of a location in a program. More...

#include <otawa/prog/Symbol.h>

Inheritance diagram for otawa::Symbol:
otawa::PropList

Public Types

enum  kind_t { NONE = 0, FUNCTION = 1, LABEL = 2, DATA = 3 }
 This type describes the kind of existing symbol. More...
 
typedef enum otawa::Symbol::kind_t kind_t
 

Public Member Functions

 Symbol (File &file, String name, kind_t kind, address_t address, ot::size size=0)
 Build a symbol. More...
 
Filefile (void) const
 Get the owner file of the given symbol. More...
 
kind_t kind (void) const
 Get the kind of the symbol. More...
 
const Stringname (void) const
 Get the name of the symbol. More...
 
address_t address (void) const
 Get the address of the location referenced by this symbol. More...
 
ot::size size (void) const
 Get the size of the item referenced by this symbol. More...
 
InstfindInst (void) const
 If the symbol points to code memory, return the matching instruction. More...
 
bool doesNotReturn (void) const
 Test if it is a no returning function. More...
 
void setNoReturn (void)
 Set the no-return property to this symbol. More...
 
void print (io::Output &out) 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...
 

Static Public Attributes

static Identifier< Symbol * > ID
 This property is used to attach a symbol to an instruction. More...
 
static const PropList EMPTY
 This is an empty proplist for convenience. More...
 

Private Attributes

File_file
 
String _name
 
kind_t _kind
 
address_t _address
 
size_t _size
 
bool no_return
 

Detailed Description

A symbol is a name of a location in a program.

Currently, only function and label symbols are supported.

To fit with the OTAWA low-level abstraction architecture, this class is only an empty interface implemented by the program loader.

Member Typedef Documentation

Member Enumeration Documentation

This type describes the kind of existing symbol.

Enumerator
NONE 

Unknown symbol.

FUNCTION 

Denotes a function symbol.

LABEL 

Denotes a label symbol.

DATA 

Constructor & Destructor Documentation

otawa::Symbol::Symbol ( File file,
String  name,
kind_t  kind,
address_t  address,
ot::size  size = 0 
)

Build a symbol.

Parameters
fileOwner file.
nameSymbol name.
kindSymbol kind.
addressAddress in the memory space.
sizeObject size (null for code).

Member Function Documentation

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

Get the address of the location referenced by this symbol.

Returns
Symbol address.

References _address.

Referenced by otawa::File::findLabel(), otawa::FlowFactLoader::scanAddress(), and otawa::LabelAddress::toAddress().

void otawa::PropList::clearProps ( void  )
inherited
bool otawa::Symbol::doesNotReturn ( void  ) const
inline

Test if it is a no returning function.

Returns
True if the function never returns, false else.

References no_return.

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

File & otawa::Symbol::file ( void  ) const
inline

Get the owner file of the given symbol.

Returns
Owern file.

References _file.

Inst * otawa::Symbol::findInst ( void  ) const

If the symbol points to code memory, return the matching instruction.

Returns
Pointed instruction if any, null else.

References _address, _file, and otawa::File::findByAddress().

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

kind_t otawa::Symbol::kind ( void  ) const
inline

Get the kind of the symbol.

Returns
Symbol kind.

References _kind.

elm::String otawa::Symbol::name ( void  ) const
inline

Get the name of the symbol.

Returns
Symbol name.

References _name.

Referenced by otawa::File::addSymbol(), print(), and otawa::File::removeSymbol().

void otawa::Symbol::print ( io::Output out) const

References name().

Referenced by otawa::operator<<().

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::Symbol::setNoReturn ( void  )

Set the no-return property to this symbol.

References _address, _file, _kind, _name, otawa::File::findInstAt(), FUNCTION, no_return, and otawa::NO_RETURN.

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::Symbol::size ( void  ) const
inline

Get the size of the item referenced by this symbol.

Returns
Symbol size.

References _size.

Referenced by otawa::FlowFactLoader::scanAddress().

Member Data Documentation

address_t otawa::Symbol::_address
private

Referenced by address(), findInst(), and setNoReturn().

File& otawa::Symbol::_file
private

Referenced by file(), findInst(), and setNoReturn().

kind_t otawa::Symbol::_kind
private

Referenced by kind(), and setNoReturn().

String otawa::Symbol::_name
private

Referenced by name(), and setNoReturn().

size_t otawa::Symbol::_size
private

Referenced by size().

const PropList otawa::PropList::EMPTY
staticinherited

This is an empty proplist for convenience.

Identifier< Symbol * > otawa::Symbol::ID
static

This property is used to attach a symbol to an instruction.

Hooks

Referenced by otawa::WorkSpace::format().

bool otawa::Symbol::no_return
private

Referenced by doesNotReturn(), and setNoReturn().


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