Otawa  0.10
Contextual Information

OTAWA allows to define properties on a contextual base. More...

OTAWA allows to define properties on a contextual base.

A contextual path (ContextualPath) defines a situation when a property value applies. For example, a loop bound may depend on the call chain leading to the loop.

Contextual paths are more general than simple call chains. They may includes:

Getting a contextual property

Getting a property is almost as simple as getting a normal property. We first need to build a contextual path [c1, c2, ..., cn] with cn being the closest component of the property list receiving the contextual property. For example, c1 may be the main() function of the program to time while cn is the function containing the denoted item. In another example, the contextual path [FUNCTION "main", FUNCTION "f", FUNCTION "g"] applied on basic block B means that the property applies when "main" calls "f" that calls "g" that contains the basic block B.

With the last example, getting the property value (loop bound here) becomes:

BasicBlock *bb;
ContextualPath path;
path.push(ContextualStep::FUNCTION, main_cfg->address());
path.push(ContextualStep::FUNCTION, f_cfg->address());
path.push(ContextualStep::FUNCTION, g_cfg->address());
int loop_bound = path(MAX_ITERATION, bb);

Usually, contextual paths are not build explicitly as in the example above. They are obtained from algorithm traversing the program structure representation like otawa::ContextualProcessor .

Notice also that the contextual path may match imprecisely defined property. For example, the property defined at the contextual path [FUNCTION "f", FUNCTION "g"] may be obtained by the contextual path [FUNCTION "f", CALL 0xffff0010, FUNCTION "g"] as the second path is just a special case compared to the more general one of the first path.

Setting a contextual property

First, notice that you do not need to give the full path. For example, the path [FUNCTION "f", FUNCTION "g"] means that the property applies each time "g" is called from "f" whatever the previous call chain is.