Fast symbolic evaluation of C/C++ preprocessing using conditional values

C/C++ code relying on preprocessing can be quite complex to analyze. This is often due to free preprocessing variables set at compile time. In general, preprocessing selectively compile parts of the source code based on the values of preprocessing variables which may be free. In this case, the relations between these parts can only be represented by conditional expressions using the free variables. Traditional symbolic evaluation can be used to infer these expressions, but its best case time complexity is exponential. We present a new approach for symbolic evaluation that can efficiently compute these conditions by binding variables to conditional values and avoiding the path feasibility analysis of traditional symbolic evaluation. It infers the exact conditional expressions for which the lines of code are compiled and the (conditional) values of preprocessing variables at each point of the source code. Our prototype shows the approach as practical and scaleable to large C/C++ software.

[1]  D. H. Bartley,et al.  Revised4 report on the algorithmic language scheme , 1991, LIPO.

[2]  Harold Abelson,et al.  Revised5 report on the algorithmic language scheme , 1998, SIGP.

[3]  Michel Dagenais,et al.  C/C++ conditional compilation analysis using symbolic execution , 2000, Proceedings 2000 International Conference on Software Maintenance.

[4]  R. Kent Dybvig,et al.  Revised5 Report on the Algorithmic Language Scheme , 1986, SIGP.

[5]  Raymond Lo,et al.  Register promotion by sparse partial redundancy elimination of loads and stores , 1998, PLDI.

[6]  P. David Coward Symbolic execution systems-a review , 1988, Softw. Eng. J..

[7]  Henry Spencer,et al.  #ifdef Considered Harmful, or Portability Experience with C News , 1992, USENIX Summer.

[8]  Ulrik Pagh Schultz,et al.  Harissa: A Hybrid Approach to Java Execution , 1999, IEEE Softw..

[9]  Volker Riediger,et al.  Folding: an approach to enable program understanding of preprocessed languages , 2001, Proceedings Eighth Working Conference on Reverse Engineering.

[10]  James C. King,et al.  Symbolic execution and program testing , 1976, CACM.

[11]  Panos E. Livadas,et al.  Understanding code containing preprocessor constructs , 1994, Proceedings 1994 IEEE 3rd Workshop on Program Comprehension- WPC '94.

[12]  Jonathan Rees,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.

[13]  Gregor Snelting,et al.  On the inference of configuration structures from source code , 1994, Proceedings of 16th International Conference on Software Engineering.

[14]  Maarit Harsu Translation of conditional compilation , 1999 .