Top   Types   Functions   Classes   Index 

Read Me!


CRL2 Library
Introduction
Getting started

CRL2 Library

Introduction

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:

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.

Getting started

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:

C++
CrlGraph *graph= crl_graph_read (file_name);
C
crl_graph_t *graph= crl_graph_read (file_name);

To write a CRL2 file, use:

C++
graph->print (file_name);
C
crl_graph_print (graph, file_name);

To generate an initial graph, use:

C++
CrlGraph *graph= new CrlGraph;
C
crl_graph_t *graph= crl_graph_new();

To insert an empty routine into a graph, use:

C++
CrlRoutine *routine= new Routine (graph);
C
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:

nameC++ classC type
graphCrlGraphcrl_graph_t
routineCrlRoutinecrl_routine_t
blockCrlBlockcrl_block_t
edgeCrlEdgecrl_edge_t
instructionCrlInstructioncrl_instruction_t
operationCrlOperationcrl_operation_t

Additionally, there are items that store data:

NameC++ classC type
dataCrlDatacrl_data_t
bytesCrlBytescrl_bytes_t

and meta data such as symbol tables and complex user annotations:

NameC++ classC type
metaCrlMetacrl_meta_t
infoCrlInfocrl_info_t

For a full documentation of all functions, please refer to the HTML documentation.


Generated by erwin-cgen © AbsInt Angewandte Informatik GmbH