|
The CRL2 library is a library for exchanging control flow graphs for static analyses, supporting mixed C++ and C usage.
The library is very generic: every sub-structure can be annotation with a map of key-value pairs, called attributes, containing arbitrary additional information.
The library in version 2 has greatly improved over version 1 in several aspects:
edges are now full-fledged members of the CRL: they can carry attributes
attribute values are now typed and allow comples sub-structure such as maps or vectors.
CFG items are possible attribute values. By this, arbitrary links between items can be established in the CFG.
Contexts are now part of the library: all attributes support contexts.
...much more...
The library makes heavy use of the Erwin template data structure library, providing vectors, hash tables and doubly linked lists for arbitrary element types. This is done in order to avoid the use of C++ specific data structures (e.g. stdc++) while still providing type safety by void*-free interfaces even in C.
For message handling, the Error library is used.
Both Erwin and the Error library are freely available as source code packages, too. For convenience, the binary package of the CRL2 library contains a compiled version of the Error library, so that only one installation procedure is necessary.
The CRL2 library uses the Error library for all message handling. Therefore, every program must initialise that library in main(), too, before initialising the CRL2 library. Please refer to the corresponding README file of the Error library. We do not give hints about this here fearing that it might become outdated and not in synch with the Error library.
To initialise CRL2, you need the following line at the beginning of main():
int main (int argc, char **argv)
{
...initialisation of Error library...
crl_init (&argc, &argv);
...
}To load a CRL2 file, use:
CrlGraph *graph= crl_graph_read (file_name);
crl_graph_t *graph= crl_graph_read (file_name);
To write a CRL2 file, use:
graph->print (file_name);
crl_graph_print (graph, file_name);
To generate an initial graph, use:
CrlGraph *graph= new CrlGraph;
crl_graph_t *graph= crl_graph_new();
To insert an empty routine into a graph, use:
CrlRoutine *routine= new Routine (graph);
crl_routine_t *routine= crl_routine_new (graph);
Insert of other sub-structure into their parent structure works accordingly.
The main structure of a control flow graph is assumed to be composed of the following items:
| name | C++ class | C type | |||
|---|---|---|---|---|---|
| graph | CrlGraph | crl_graph_t | |||
| routine | CrlRoutine | crl_routine_t | |||
| block | CrlBlock | crl_block_t | |||
| edge | CrlEdge | crl_edge_t | |||
| instruction | CrlInstruction | crl_instruction_t | |||
| operation | CrlOperation | crl_operation_t |
Additionally, there are items that store data:
| Name | C++ class | C type | |||
|---|---|---|---|---|---|
| data | CrlData | crl_data_t | |||
| bytes | CrlBytes | crl_bytes_t |
and meta data such as symbol tables and complex user annotations:
| Name | C++ class | C type | |||
|---|---|---|---|---|---|
| meta | CrlMeta | crl_meta_t | |||
| info | CrlInfo | crl_info_t |
For a full documentation of all functions, please refer to the HTML documentation.
| Generated by erwin-cgen | © AbsInt Angewandte Informatik GmbH |