OTAWA  2.0
Framework to perform machine analysis and compute WCET.
otawa::WorkSpace Class Reference

#include <otawa/prog/WorkSpace.h>

+ Inheritance diagram for otawa::WorkSpace:

Classes

struct  Dependency
 

Public Member Functions

void cancel (void)
 
void clearCancellation (void)
 
elm::xom::Elementconfig (void)
 Get the current configuration, if any, as an XML XOM element. More...
 
virtual InstfindInstAt (address_t addr)
 Find an instruction at the given address. More...
 
string format (Address addr, bool with_address=true)
 Format an address to make it human-readable. More...
 
ast::ASTInfo * getASTInfo (void)
 Get the AST of the project. More...
 
CFGInfogetCFGInfo (void)
 Get the CFG of the project. More...
 
ProcessorgetImpl (const AbstractFeature &feature) const
 Get the implementor of a feature (if provided). More...
 
CFGgetStartCFG (void)
 Get the entry CFG of the program. More...
 
bool implements (const AbstractFeature &feature)
 
void invalidate (const AbstractFeature &feature)
 Invalidate a feature (removing its dependencies) More...
 
bool isCancelled (void) const
 
bool isProvided (const AbstractFeature &feature)
 
void loadConfig (const elm::sys::Path &path)
 Load the given configuration in the process. More...
 
sys::Path makeWorkDir ()
 Build and return the working directory. More...
 
virtual Managermanager (void)
 Get the manager of the workspace. More...
 
string name () const
 
WorkSpacename (string name)
 
ilp::SystemnewILPSystem (bool max=true)
 Build an ILP system with the default ILP engine. More...
 
virtual hard::Platformplatform (void)
 Get the platform used by the process. More...
 
Processprocess (void) const
 
bool provides (const AbstractFeature &feature)
 Test if a feature is provided. More...
 
bool provides (cstring name)
 Test if the named feature is provided. More...
 
void require (const AbstractFeature &feature, const PropList &props=PropList::EMPTY)
 Ensure that a feature is provided. More...
 
template<class T >
T * run (const PropList &props=PropList::EMPTY)
 
Processorrun (cstring name, const PropList &props=PropList::EMPTY)
 Find and run the code processor corresponding to the given name with the given configuration. More...
 
void run (Processor &proc, const PropList &props, bool del_proc=false)
 
void run (Processor *proc, const PropList &props=PropList::EMPTY, bool del_proc=false)
 Processor *WorkSpace::run(const PropList& props); Create a processor of type T and run it in the current workspace using the given properties. More...
 
virtual void serialize (elm::serial2::Serializer &serializer)
 Serialize the workspace to the current serializer. More...
 
virtual Inststart (void)
 Get the start instruction of the program. More...
 
virtual void unserialize (elm::serial2::Unserializer &unserializer)
 Unserialize the workspace to the current unserializer. More...
 
sys::Path workDir ()
 Get the working directory. More...
 
WorkSpaceworkDir (sys::Path path)
 
 WorkSpace (const WorkSpace *ws)
 Build a new workspace on the same process as the given one. More...
 
 WorkSpace (Process *_proc)
 Build a new wokspace with the given process. More...
 
virtual ~WorkSpace (void)
 Delete the workspace and the associated process. More...
 
- Public Member Functions inherited from otawa::PropList
void addProp (Property *prop)
 Add property to the list without checking of duplication. More...
 
void addProps (const PropList &props)
 Add all properties from the given property list, in a reverse order. More...
 
GetterRange all (const AbstractIdentifier &id) const
 
void clearProps (void)
 Remove all properties from the list. More...
 
PropertyextractProp (const AbstractIdentifier &id)
 
PropertyextractProp (const AbstractIdentifier *id)
 Remove a property matching the given identifier and return it. More...
 
PropertygetProp (const AbstractIdentifier *id) const
 Find a property by its identifier. More...
 
bool hasProp (const AbstractIdentifier &id) const
 
PropListoperator= (const PropList &props)
 
void print (elm::io::Output &out) const
 Display the current property list. More...
 
PropRange properties (void) const
 
 PropList (const PropList &props)
 Initialize a property list from a sequence of (identifier, value) pairs passed as variable arguments. More...
 
 PropList (void)
 
void removeAllProp (const AbstractIdentifier *id)
 Remove all the properties matching the given identifier. More...
 
void removeProp (const AbstractIdentifier &id)
 
void removeProp (const AbstractIdentifier *id)
 Remove a property matching the given identifier. More...
 
void setProp (const AbstractIdentifier *id)
 
void setProp (Property *prop)
 Set the property in the property list removing any double. More...
 
void takeProps (PropList &props)
 Take properties from props to the current property list. More...
 
 ~PropList (void)
 

Static Public Member Functions

static WorkSpaceload (sys::Path path, const PropList &props=PropList::EMPTY)
 Build a workspace for the given binary file using the default manager. More...
 
static WorkSpaceload (sys::Path path, const PropList *props)
 
static void remove (Property *prop)
 Remove a property in a thread-safe way. More...
 
static sys::Threadrun (sys::Runnable &run)
 Launch in a different thread the given runnable. More...
 
static void runAll (sys::Runnable &run)
 Run all threads with the given runnable. More...
 

Static Public Attributes

static rtti::Type__type = workspace_class
 
- Static Public Attributes inherited from otawa::PropList
static rtti::Type__type = prop_list_class
 
static const PropList EMPTY
 This is an empty proplist for convenience. More...
 

Private Types

typedef HashMap< const AbstractFeature *, Dependency * > dep_map_t
 
typedef struct otawa::WorkSpace::Dependency Dependency
 

Private Member Functions

void add (Processor *proc, bool del_proc)
 Add a new dependency. More...
 
void invalidate (Dependency *dep)
 Invalidate a dependency (removing its dependencies) More...
 
void remove (Dependency *dep)
 Remove a dependency. More...
 

Private Attributes

string _name
 
bool cancelled
 
dep_map_t dep_map
 
LockPtr< Processproc
 
sys::Path wdir
 

Detailed Description

A workspace represents a program, its run-time and all information about WCET computation or any other analysis.

Member Typedef Documentation

◆ dep_map_t

◆ Dependency

Constructor & Destructor Documentation

◆ WorkSpace() [1/2]

otawa::WorkSpace::WorkSpace ( Process _proc)

Build a new wokspace with the given process.

Parameters
_procProcess to use.

References dep_map, otawa::Process::features(), elm::HashMap< class, class, class, class, class >::put(), and TRACE.

◆ WorkSpace() [2/2]

otawa::WorkSpace::WorkSpace ( const WorkSpace ws)

Build a new workspace on the same process as the given one.

Parameters
wsWorkspace to get the process form.

References dep_map, otawa::Process::features(), proc, process(), elm::HashMap< class, class, class, class, class >::put(), and TRACE.

◆ ~WorkSpace()

otawa::WorkSpace::~WorkSpace ( void  )
virtual

Delete the workspace and the associated process.

References elm::Vector< class, class, class >::add(), elm::Vector< class, class, class >::contains(), dep_map, invalidate(), and TRACE.

Member Function Documentation

◆ add()

void otawa::WorkSpace::add ( Processor proc,
bool  del_proc 
)
private

◆ cancel()

void otawa::WorkSpace::cancel ( void  )
inline

Informs the current computation to stop as soon as possible. This feature has not direct on the workspace but is used by code processor to change their behaviour. It may be used to stop a computation in a parallel or a GUI context.

◆ clearCancellation()

void otawa::WorkSpace::clearCancellation ( void  )
inline

Reset the cancellation bit. This function must be called before starting a long running time computation.

◆ config()

xom::Element * otawa::WorkSpace::config ( void  )

Get the current configuration, if any, as an XML XOM element.

Returns
Configuration XML element or null.

References otawa::CONFIG_ELEMENT.

◆ findInstAt()

Inst * otawa::WorkSpace::findInstAt ( address_t  addr)
virtual

Find an instruction at the given address.

Parameters
addrLooked address.
Returns
Found instruction or null (bad instruction or not in code memory).

References proc.

Referenced by otawa::AbstractCFGBuilder::cleanup(), otawa::FlowFactLoader::findCall(), format(), otawa::VarTextDecoder::processWorkSpace(), otawa::AbstractCFGBuilder::scanCFG(), otawa::CFGBuilder::setup(), otawa::AbstractCFGBuilder::setup(), and otawa::CFGCollector::setup().

◆ format()

string otawa::WorkSpace::format ( Address  addr,
bool  with_address = true 
)

Format an address to make it human-readable.

First look for debugging information, else try to build the form label + offset else fall back to address itself.

Parameters
addrAddress to display.
with_addressSet to true to ever display the address.
Returns
Formatted string.

References buf, findInstAt(), otawa::Process::getSourceLine(), hex(), otawa::Address::isNull(), process(), otawa::SYMBOL, and elm::StringBuffer::toString().

◆ getASTInfo()

ast::ASTInfo * otawa::WorkSpace::getASTInfo ( void  )

Get the AST of the project.

Deprecated:

Referenced by otawa::FunProcessor::processWorkSpace().

◆ getCFGInfo()

CFGInfo * otawa::WorkSpace::getCFGInfo ( void  )

Get the CFG of the project.

If it does not exists, built it.

Deprecated:

References otawa::CFGInfo::ID.

Referenced by getStartCFG().

◆ getImpl()

Processor * otawa::WorkSpace::getImpl ( const AbstractFeature feature) const

Get the implementor of a feature (if provided).

Parameters
featureFeature for which the implementor is looked.
Returns
Found implementor or null pointer.

References otawa::WorkSpace::Dependency::_proc, dep_map, and elm::HashMap< class, class, class, class, class >::get().

Referenced by otawa::p::get_impl().

◆ getStartCFG()

CFG * otawa::WorkSpace::getStartCFG ( void  )

Get the entry CFG of the program.

Returns
Entry CFG if any or null.
Deprecated:

References otawa::CFGInfo::findCFG(), getCFGInfo(), and start().

◆ implements()

bool otawa::WorkSpace::implements ( const AbstractFeature feature)
inline

Test if a feature is provided.

Parameters
featureFeature to test.
Returns
True if it is provided, false else.

◆ invalidate() [1/2]

void otawa::WorkSpace::invalidate ( const AbstractFeature feature)

Invalidate a feature (removing its dependencies)

Parameters
featureProvided feature.

References dep_map, elm::HashMap< class, class, class, class, class >::get(), and otawa::AbstractIdentifier::name().

Referenced by run(), otawa::Processor::~Processor(), and ~WorkSpace().

◆ invalidate() [2/2]

◆ isCancelled()

bool otawa::WorkSpace::isCancelled ( void  ) const
inline

Test if the cancel() method has been called on the workspace. This method is usually called by code processor to know if the computation has been canceled.

Returns
True if the computation has been cancelled, false else.

Referenced by run().

◆ isProvided()

◆ load() [1/2]

WorkSpace * otawa::WorkSpace::load ( sys::Path  path,
const PropList props = PropList::EMPTY 
)
static

Build a workspace for the given binary file using the default manager.

Parameters
pathPath to the file.
propsConfiguration properties (optional).
Returns
Built workspace.
Exceptions
otawa::ExceptionIn case of error.

◆ load() [2/2]

static WorkSpace* otawa::WorkSpace::load ( sys::Path  path,
const PropList props 
)
inlinestatic

◆ loadConfig()

void otawa::WorkSpace::loadConfig ( const elm::sys::Path path)

Load the given configuration in the process.

Parameters
pathPath to the XML configuration file.
Exceptions
LoadExceptionIf the file cannot be found or if it does not match the OTAWA XML type.

◆ makeWorkDir()

sys::Path otawa::WorkSpace::makeWorkDir ( )

Build and return the working directory.

Returns
Working directory path.
Exceptions
elm::sys::SystemExceptionIf there is an IO error.

References p(), and workDir().

◆ manager()

Manager * otawa::WorkSpace::manager ( void  )
virtual

Get the manager of the workspace.

Returns
Workspace manager.

References proc.

Referenced by newILPSystem().

◆ name() [1/2]

string otawa::WorkSpace::name ( ) const
inline

Get the name of the workspace (if any) or an empty string.

Returns
Workspace name.

Referenced by otawa::CFGCollector::cleanup(), provides(), run(), and workDir().

◆ name() [2/2]

WorkSpace & otawa::WorkSpace::name ( string  name)
inline

Set the name of the workspace.

Parameters
nameNew name of the workspace.

References name().

Referenced by name().

◆ newILPSystem()

ilp::System * otawa::WorkSpace::newILPSystem ( bool  max = true)

Build an ILP system with the default ILP engine.

Parameters
maxTrue for a maximized system, false for a minimized.
Returns
ILP system ready to use, NULL fi there is no support for ILP.
Deprecated:

References manager(), and otawa::Manager::newILPSystem().

◆ platform()

hard::Platform * otawa::WorkSpace::platform ( void  )
virtual

◆ process()

Process* otawa::WorkSpace::process ( void  ) const
inline

◆ provides() [1/2]

bool otawa::WorkSpace::provides ( const AbstractFeature feature)

Test if a feature is provided.

Parameters
featureFeature to test.
Returns
True if it is provided, false else.

References dep_map, and elm::HashMap< class, class, class, class, class >::hasKey().

Referenced by otawa::ipet::WCETComputation::collectStats(), provides(), run(), otawa::StandardEventBuilder::setup(), and otawa::etime::StandardEventBuilder::setup().

◆ provides() [2/2]

bool otawa::WorkSpace::provides ( cstring  name)

Test if the named feature is provided.

Parameters
nameName of the look feature.
Returns
True if the feature is available, false else.

References otawa::AbstractIdentifier::find(), otawa::p::is_feature(), name(), and provides().

◆ remove() [1/2]

◆ remove() [2/2]

void otawa::WorkSpace::remove ( Property prop)
static

Remove a property in a thread-safe way.

Parameters
propProperty to remove.

Referenced by invalidate().

◆ require()

void otawa::WorkSpace::require ( const AbstractFeature feature,
const PropList props = PropList::EMPTY 
)

Ensure that a feature is provided.

Parameters
featureRequired feature.
propsConfiguration properties (optional).

References isProvided(), and otawa::AbstractFeature::process().

Referenced by otawa::Application::require(), run(), and otawa::script::Script::work().

◆ run() [1/5]

template<class T >
T* otawa::WorkSpace::run ( const PropList props = PropList::EMPTY)
inline

References p().

◆ run() [2/5]

Processor * otawa::WorkSpace::run ( cstring  name,
const PropList props = PropList::EMPTY 
)

Find and run the code processor corresponding to the given name with the given configuration.

Parameters
propsProperty list to use (optional).
Returns
The built processor.
Exceptions
otawa::Exception– if there is an error in the processor or the processor cannot be found.

References _, otawa::ProcessorPlugin::getProcessor(), name(), p(), and run().

◆ run() [3/5]

void otawa::WorkSpace::run ( Processor proc,
const PropList props,
bool  del_proc = false 
)
inline

References run().

Referenced by run().

◆ run() [4/5]

void otawa::WorkSpace::run ( Processor proc,
const PropList props = PropList::EMPTY,
bool  del_proc = false 
)

Processor *WorkSpace::run(const PropList& props); Create a processor of type T and run it in the current workspace using the given properties.

As locally declared processor are no more allowed, this function is the easier to call a processor which class is known.

Parameters
TClass of the processor.
propsConfiguration properties (optional).
Returns
The built processor.
Exceptions
otawa::ExceptionAs thrown by the code processor during its execution. Run the given in the current workspace.

Notice that, after this call, the workspace is the owner of the passed processor object and, therefore, will be in charge of releasing it at the right time.

Parameters
procProcessor to run.
propsConfiguration to use.
del_procSet to true if the processor needs to be deleted when it is no more used.

References _, elm::Vector< class, class, class >::add(), add(), elm::Vector< class, class, class >::contains(), endl, otawa::FeatureUsage::invalidate, invalidate(), otawa::Processor::IS_DONE, isCancelled(), isProvided(), kind, otawa::Monitor::LOG_DEPS, otawa::AbstractRegistration::name(), proc, otawa::FeatureUsage::provide, provides(), elm::Vector< class, class, class >::remove(), otawa::FeatureUsage::require, require(), otawa::FeatureUsage::use, and otawa::AbstractRegistration::uses().

Referenced by otawa::DynProcessor::process(), otawa::Feature< T, C >::process(), otawa::p::feature::process(), otawa::TextDecoder::processWorkSpace(), otawa::Application::run(), run(), otawa::Application::stats(), and otawa::script::Script::work().

◆ run() [5/5]

sys::Thread * otawa::WorkSpace::run ( sys::Runnable runnable)
static

Launch in a different thread the given runnable.

If no more thread is available, launch the runnable in the current thread.

Using this method to start a thread allows the management of property in thread-safe way.

Parameters
runnableRunnable to launch.
Returns
Started thread or null if the runnable has been launched in the current thread.

References elm::sys::Runnable::run().

◆ runAll()

void otawa::WorkSpace::runAll ( sys::Runnable runnable)
static

Run all threads with the given runnable.

Return only when all threads has stopped.

Using this method to start a thread allows the management of property in thread-safe way.

Parameters
runnableRunnable to launch.

References elm::sys::Runnable::run().

Referenced by otawa::ConcurrentCFGProcessor::processWorkSpace().

◆ serialize()

void otawa::WorkSpace::serialize ( elm::serial2::Serializer serializer)
virtual

Serialize the workspace to the current serializer.

Parameters
serializerSerializer to serialize to.

References elm::serial2::Serializer::beginField(), elm::serial2::Serializer::endField(), otawa::Process::loader(), elm::sys::Plugin::path(), process(), and elm::sys::Path::toString().

◆ start()

Inst * otawa::WorkSpace::start ( void  )
virtual

Get the start instruction of the program.

Returns
Program start instruciton.

References proc.

Referenced by getStartCFG(), and otawa::VarTextDecoder::processWorkSpace().

◆ unserialize()

void otawa::WorkSpace::unserialize ( elm::serial2::Unserializer unserializer)
virtual

Unserialize the workspace to the current unserializer.

Parameters
unserializerUnserializer to unserialize to.

◆ workDir() [1/2]

sys::Path otawa::WorkSpace::workDir ( )

Get the working directory.

If the binary has for path DIR/FILE.EXT and if the workspace has for name NAME, the working directory is:

DIR/NAME-otawa

If the workspace has no name, the working directory is:

DIR/FILE-otwaa

Returns
Working directory path.

References _name, elm::sys::Path::isEmpty(), name(), elm::sys::Path::namePart(), elm::sys::Path::parent(), process(), wdir, and elm::sys::Path::withoutExt().

Referenced by makeWorkDir(), otawa::Application::run(), and otawa::Application::stats().

◆ workDir() [2/2]

WorkSpace & otawa::WorkSpace::workDir ( sys::Path  path)
inline

Set the path of the working directory.

Parameters
pathnew path to the working directory.

Member Data Documentation

◆ __type

rtti::Type & otawa::WorkSpace::__type = workspace_class
static

◆ _name

string otawa::WorkSpace::_name
private

Referenced by workDir().

◆ cancelled

bool otawa::WorkSpace::cancelled
private

◆ dep_map

dep_map_t otawa::WorkSpace::dep_map
private

◆ proc

LockPtr<Process> otawa::WorkSpace::proc
private

◆ wdir

sys::Path otawa::WorkSpace::wdir
private

Referenced by workDir().


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