tionals into C/C++ code (Mennie and Clarke, 2004).
Spinellis tackles the problem of global renaming of
variables (Spinellis, 2003).
There are remarkable contributions which offer
a solution to the opposite direction of our question:
when seeing a macro name in the source code, which
macro definitions take part in the expansion. The
GUPRO program understanding framework (Ebert
et al., 2002) implements a macro folding mechanism:
a macro can be hidden or revealed at the place of
the call (Kullbach and Riediger, 2001). Livadas and
Small identify mappings between the preprocessed
and the unprocessed code. The approach is imple-
mented in the GHINSU software maintenance en-
vironment, where by clicking on a macro invoca-
tion, the called definitions are highlighted (backward
macro slice using our terms) (Livadas and Small,
1994). A flexible solution is offered by Badros and
Notkin: the PCp
3
C analysis tool defines callback
perl functions for preprocessor activities (Badros and
Notkin, 2000). These methods require only the anal-
ysis of the compilation units. In our approach, how-
ever, we need to use information from the whole
source. (Note that by using our approach backward
slices can also be computed.)
The Understand for C++ reverse engineering tool
provides cross references between the use and defini-
tion of software entities (Understand for C++ Home-
page, 2007). This includes the step-by-step tracing
of macro calls in both directions. The user can track
back the usages of a given macro definition easily but
the information is not accurate. The program fails on
the problem shown in Figure 5 and, for example, it
misses calls using ## or shows a macro call where
a parameterized macro name is used without argu-
ments, so no macro expansion happens.
5 CONCLUSIONS
As a response to the lack of complete solution to the
macro change impact problem, we introduced an ap-
proach based on macro slices. Based on the relations
between macro invocations and definitions, we con-
struct a Macro Dependency Graph on which macro
slices can be computed. By using multiple edges and
edge coloring, this graph handles potential (and later
defined) macro names and macro re-definitions.
As a proof of concept, an experimental tool based
on the Columbus C/C++ frontend (FrontEndART
Homepage, 2007) has been developed. We have
already performed some preliminary experiments
which proved our concepts. In the future we plan to
evaluate the method in some more detailed case stud-
ies. We also plan to produce backward macro slices
and to implement an efficient algorithm for global
computation of macro slices (and not demand driven
as the current one).
REFERENCES
Agrawal, H. and Horgan, J. R. (1990). Dynamic program
slicing. In Proceedings of the ACM PLDI 1990, pages
246–256, New York, NY, USA. ACM Press.
Badros, G. J. and Notkin, D. (2000). A Framework for
Preprocessor-Aware C Source Code Analyses. Softw.
Pract. Exper., 30(8):907–924.
Besz
´
edes,
´
A., Gergely, T., and Gyim
´
othy, T. (2006). Graph-
less dynamic dependence-based dynamic slicing algo-
rithms. In Proceedings of SCAM 2006), pages 21–30.
Ebert, J., Kullbach, B., Riediger, V., and Winter, A. (2002).
GUPRO - Generic Understanding of Programs. In
Electronic Notes in Theoretical Computer Science,
volume 72. Elsevier.
FrontEndART Homepage (2007).
http://www.frontendart.com
.
Garrido, A. (2005). Program refactoring in the presence of
preprocessor directives. Ph.D. thesis, UIUC.
Horwitz, S., Reps, T., and Binkley, D. (1990). Inter-
procedural slicing using dependence graphs. ACM
Transactions on Programming Languages and Sys-
tems, 12(1):26–61.
Kullbach, B. and Riediger, V. (2001). Folding: An approach
to enable program understanding of preprocessed lan-
guages. In Proceedings of WCRE 2001, pages 3–12,
Los Alamitos. IEEE Computer Society.
Livadas, P. E. and Small, D. T. (1994). Understanding code
containing preprocessor constructs. In Proceedings of
IWPC 1994, pages 89–97. IEEE Computer Society.
Mennie, C. A. and Clarke, C. L. A. (2004). Giving meaning
to macros. In Proceedings of IWPC 2004, page 79,
Washington, DC, USA. IEEE Computer Society.
Rajlich, V. (1997). A model for change propagation based
on graph rewriting. In Proceedings of ICSM 1997),
pages 84–91.
Spencer, H. and Collyer, G. (1992). #ifdef considered harm-
ful, or portability experience with C News. In Techni-
cal Conference, pages 185–197.
Spinellis, D. (2003). Global analysis and transformations in
preprocessed languages. IEEE Transactions on Soft-
ware Engineering, 29(11):1019–1030.
Tip, F. (1995). A survey of program slicing techniques.
Journal of Programming Languages, 3(3):121–189.
Understand for C++ Homepage (2007).
http://www.scitools.com
.
Weiser, M. (1984). Program slicing. IEEE Transactions on
Software Engineering, SE-10(4):352–357.
Xu, B., Qian, J., Zhang, X., Wu, Z., and Chen, L. (2005).
A brief survey of program slicing. ACM SIGSOFT
Softw. Eng. Notes, 30(2):1–36.
MACRO IMPACT ANALYSIS USING MACRO SLICING
235