This document discusses dynamic slicing of aspect-oriented programs. It introduces aspect-oriented programming and the AspectJ language. It presents an algorithm for dynamic slicing of aspect-oriented programs that uses an execution trace file to construct a dynamic aspect-oriented dependence graph (DADG) and then performs graph traversal to compute the dynamic slice. The algorithm maps the dynamic slice back to the original program. The document also discusses applications of program slicing and provides average runtime results for dynamic slicing on programs of different sizes.
1. 1
DYNAMIC SLICING OF ASPECT-
ORIENTED PROGRAMS
BY
www.carrertime.in
www.facebook.com/carrertime.in
2. 2
OUTLINE
• Introduction
• Introduction to AspectJ - An AOP Language
• Slicing of AOP
• Motivation of Research
• Objective of Research
• Work Done
• Conclusion
• Future Work
• References
3. 3
Introduction
•Finding all statements in a program that directly or
indirectly affect the value of a variable occurrence is
referred to as Program Slicing.
•The pair <s,v> is known as Slicing Criterion where s is a
program point of interest and v is a variable used or
defined at s.
4. 4
Categories of Slice
•Backward Slice: All statements that might have
affected the value of a variable at a program point
•Forward Slice: All statements that might be affected by
the value of a variable at a program point
•Static Slice: All statements that may affect the value of
a variable at a program point for all possible executions
•Dynamic Slice: All statements that actually affect the
value of a variable at a program point for a particular
execution
•Intra-Procedural Slice: Slice within a single procedure
•Inter-Procedural Slice: Slice within multiple procedure
5. 5
EXAMPLE
1 main( )
2 {
3 int i, sum;
4 sum = 0;
5 i = 1;
6 while(i <= 10)
7 {
8 sum = sum + 1;
9 ++ i;
10 }
11 printf(“%d”, sum);
12 printf(“%d”, i);
13 }
An Example program and its slice w.r.t. <12,i>
6. 6
APPLICATIONS OF PROGRAM SLICING
Debugging
Testing
Software Maintenance
Differencing
Reverse Engineering
7. 7
Approaches to Slicing
•Control Flow Graph (CFG) Based
Data flow equations are solved
•Dependence Graph Based
Dependence graph is used as the intermediate program
representation
Slice is computed as the graph reachability problem
Program Dependence Graph (PDG)
Used for intra-procedural slicing
Nodes represent statements
Edges represent data/control dependencies
System Dependence Graph (SDG)
Used for inter-procedural slicing
Same as PDG except that it includes vertices and edges for call
statements, parameter passing and transitive dependences due to
calls.
8. 8
Aspect-Oriented Programming
•Gregor Kiczales and his team at Xerox PARC originated the
concept of Aspect Oriented Programming (AOP).
•Aspect-oriented programming is a new programming technique
proposed for cleanly modularizing the cross-cutting structure of
concerns such as exception handling, synchronization and
resource sharing.
•An "aspect" is an "area of concern" that cuts across the structure
of a program.
•The main idea behind aspect-oriented programming (AOP) is to
allow a program to be constructed by describing each concern
separately.
9. 9
Fundamental goal of AOP
•Allow for the separation of concerns as appropriate for
a host language.
•Provide a mechanism for the description of concerns
that crosscut other components.
10. 10
AOP Vs. OOP
•Similarities- AOP utilizes advantages of OOP
AOP and OOP both use objects
Objects combine the behavior and data of a
concern into a single physical entity
•Differences- handling of cross-cutting concerns
OOP tries to push the scattered code for these
concerns up in the inheritance tree
This is often not possible and results in tangled
code
AOP collects scattered concerns into a single class
structure
11. 11
Benefits of AOP
•It improves performance because the operations are
more succinct
•It allows programmer to spend less time rewriting the
same code
•Separation of Concerns
AOP makes it possible to encapsulate cross-cutting
concerns
12. 12
Benefits of AOP (Cont.)
•Simpler System Evolution
Join points allow changes to programs to be
incorporated simply with aspects
•Reuse
Aspects can often be reused in other programs with
only slight modifications
13. 13
AspectJ: An AOP Language
•An aspect-oriented extension to the JAVA programming
language
•Created at Xerox PARC by Chris Maeda.
•Compatible with current JAVA platform.
•Compatibility includes
upward compatibility
platform compatibility
tool compatibility
programmer compatibility
15. 15
Motivation
•Slicing techniques need to be efficient because of its
use in debugging and testing
•Reports on slicing of AOPs are scarce
•This demands the development of efficient slicing
algorithm for AOPs
16. 16
Objectives
•An appropriate frame-work for computing slices
•Suitable intermediate representation of Aspect-oriented
program
•Development of suitable dynamic slicing technique
18. 18
Algorithm: Trace file Based algorithm
1. Creation of execution trace file: To create an execution trace
file, do the following:
a) For a given input, execute the program and store each
statement s in the order of execution in a file after it has
been executed.
b) If the program contains loops, then store each statement s
inside the loop in the trace file after each time it has been
executed.
2. Construction of DADG: To Construct the DADG of the aspect-
oriented program P with respect to the trace file, do the
following:
a) For each statement s in the trace file, create a vertex in the
DADG.
b) For each occurrence of a statement s in the trace file, create
a separate vertex.
19. 19
Algorithm: Trace file Based algorithm (Cont.)
c) Add all control dependence edges, data dependence edges
and weaving edges to these vertices.
1. Computation of dynamic slice: To compute the dynamic slice
over the DADG, do the following:
a) Perform the breadth-first or depth-first graph traversal over
the DADG taking any vertex corresponding to the statement
of interest as the starting point of traversal.
3. Mapping of the slice: To obtain the dynamic slice of the
aspect-oriented program P, do the following:
a) Define a mapping function f : DSG(p, q, e, n) → P .
b) Map the resulting slice obtained in step 3(a) over the DADG
to the source code P using f since the slice may contain
multiple occurrences of the same vertex.
25. 25
Conclusion
•Trace file is used for storing the execution history
•Separate vertices are created in the DADG for different
execution of the same statement
•Average run-time is more
26. 26
Future Work
•Modifying the algorithm to avoid the use of trace file
•Handling composite data types
•Handling unstructured programs
•Computing dynamic slices of concurrent AOPs
27. 27
REFERENCES
[1] Binkley D. W. and Gallagher K. B. Program Slicing.
Advances in Computers, 43, 1996. Academic Press, San
Diego, CA.
[2] Agarwal H. and Horgan J. R. Dynamic Program
Slicing. In ACM SIGPLAN Notices, Proceedings of the ACM
SIGPLAN 1990 Conference on Programming Language Design
and Implementation PLDI'90, volume 25 of 6, pages 246-256,
June 1990.
[3] Zhao J. Dynamic Slicing of Object-Oriented Programs.
Technical report, Information Processing Society of Japan,
May 1998.
28. 28
REFERENCES (Cont.)
[4] Horowitz S., Reps T., and Binkley D. Inter-Procedural
Slicing Using Dependence Graphs. ACM
Transactions on Programming Languages and Systems,
12(1):26-60, January 1990.
[5] Kiczales G., Irwin J., Lamping J., Loingtier J. M., Lopes C.
V., Maeda C., and Mendhekar Anurag. Aspect-Oriented
Programming. In Proceedings of the European
Conference on Object-Oriented Programming (ECOOP),
Finland, June 1997. Springer-Verlag.
[6] Zhao J. Slicing Aspect-Oriented Software. In Proceedings
of 10th International Workshop on Program
Comprehension, pages 251-260, June 2002.
29. 29
REFERENCES (Cont.)
[7] Zhao J. and Rinard M. System Dependence Graph
Construction for Aspect-Oriented Programs. Technical
report, Laboratory for Computer Science, Massachusetts
Institute of Technology, USA, March 2003.
[8] Braak T. T. Extending program slicing in aspect-oriented
programming with inter-type declarations. 5th TSCon IT
Program, June 2006.
[9] Korel B. and Laski J. Dynamic Program Slicing.
Information Processing Letters, 29(3):155-163, 1988.
[10] Mohapatra D. P. Dynamic Slicing of Object-Oriented
Programs. PhD thesis, Indian Institute of Technology,
Kharagpur, May 2005.
30. 30
REFERENCES (Cont.)
[11] Tip F. A Survey of Program Slicing Techniques. Journal of
Programming Languages, 3(3):121-189, 1995.
[12] Mohapatra D. P., Mall R., and Kumar R. Dynamic Slicing of
Concurrent Object-Oriented Programs. In Proceedings of
International Conference on Information Technology:
Progresses and Challenges (ITPC), pages 283-290.
Kathamandu, May 2003.
[13] Ishio T., Kusumoto S., and Inoue K. Application of Aspect-
Oriented Programming to Calculation of Program Slice.
Technical report, ICSE, 2003.
[14] AspectJ. www.eclipse.org/aspectj.
[15] Aspect-Oriented Programming. www.wikipedia.org.