Otawa  0.10
Application Writing

OTAWA may be used from an graphical user interface like Eclipse or from the command line. More...

Classes

class  otawa::LogOption
 Defines a command line option supporting log level thanks to strings 'proc', 'cfg' or 'bb'. More...
 
class  otawa::Application
 A class making easier the use of applications built on OTAWA. More...
 

Detailed Description

OTAWA may be used from an graphical user interface like Eclipse or from the command line.

In the latter case, you can either use the existing commands (dumpcfg Command, owcet Command, etc) but you can also write your own commands adapted to a specific process not already provided by OTAWA.

Although the usual way to write a command with a main function works, you can save a tedious task of handling parameters, opening the executable, processing error by using the otawa::app::Application class.

Just define your own class inheriting and specializing app::Application like below and you do neither need to declare the main function yourself thanks to the OTAWA_RUN macro.

using namespace otawa;
class MyCommand: public Application {
public:
MyCommand(void): Application("my-command", Version(1, 0, 2)) { }
protected:
void work(PropList &props) throw(elm::Exception) {
// do_something useful on the opened workspace
}
};
OTAWA_RUN(MyApp)

Basically, the produced command takes as first argument the executable and as other free arguments the function to process. The functions to process are described either by their name, or by their address (integer address or 0x-prefixed hexadecimal address). If no other free argument is provided, the command is applied on the main function of the executable. For each function name, a call to work() method is performed, the passed property list is initialized accordingly and a workspace ready to use is created. To get it, just call the Application::workspace() method. You can now perform any required analysis.

In addition, the app::Application class provides standards options like:

In addition, you can also defines your own options using the elm::option classes:

using namespace elm;
class MyCommand: public app::Application {
public:
MyCommand(void): app::Application("my-command", Version(1, 0, 2)),
option1(*this),
option2(*this), ... { }
private:
...
};

Finally, just compile your OTAWA application and it is ready to run and to process an executable.