dynamic slicing of aspect-oriented programs

31
1 DYNAMIC SLICING OF ASPECT- ORIENTED PROGRAMS BY www.carrertime.in www.facebook.com/carrertime.in

Upload: praveen-penumathsa

Post on 07-Aug-2015

36 views

Category:

Engineering


1 download

TRANSCRIPT

1

DYNAMIC SLICING OF ASPECT-ORIENTED PROGRAMS

BY

www.carrertime.inwww.facebook.com/carrertime.in

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

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

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

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

APPLICATIONS OF PROGRAM SLICING

Debugging

Testing

Software Maintenance

Differencing

Reverse Engineering

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 slicingSame as PDG except that it includes vertices and edges for call statements, parameter passing and transitive dependences due to calls.

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

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

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 concernsOOP 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

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 ConcernsAOP makes it possible to encapsulate cross-cutting concerns

12

Benefits of AOP (Cont.)

•Simpler System EvolutionJoin points allow changes to programs to be incorporated simply with aspects

•ReuseAspects can often be reused in other programs with only slight modifications

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 compatibilityplatform compatibilitytool compatibilityprogrammer compatibility

14

Features of AspectJ

•Join Points

•Pointcut

•Advice

•Introduction/Inter-type declaration

•Aspect

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

Objectives

•An appropriate frame-work for computing slices

•Suitable intermediate representation of Aspect-oriented program

•Development of suitable dynamic slicing technique

17

An Example AspectJ Program

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

Algorithm: Trace file Based algorithm (Cont.)

c) Add all control dependence edges, data dependence edges and weaving edges to these vertices.

3. 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.

4. 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.

20

Working of the Algorithm

Input data: argv[0]=4.

Executed statements in order: 1, 2, 3, 13, 14, 15, 4, 5, 6, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 16, 17, 11.

Slicing criterion: < 11, p >.

Breadth-first search algorithm: 11, 17, 8, 16, 7, 8, 9, 7, 13, 5, 9, 7, 8, 9, 9, 3, 2, 4, 7, 8, 9, 1, 15, 7, 6, 14.

Depth-first search algorithm: 11, 8, 9, 9, 9, 4, 15, 14, 2, 1, 7, 5, 7, 7, 8, 8, 8, 6, 7, 17, 16, 13, 3, 7, 9.

Map: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 14, 15, 16, 17.

21

Execution Trace File

22

Dynamic Aspect-Oriented Dependence Graph (DADG)

23

Dynamic Slice

24

Average Runtime

Sl. No. Prg. Size (# stmts)

Avg. Runtime(in sec.)

1 17 0.11

2 43 0.71

3 69 0.89

4 97 1.07

5 123 1.36

6 245 2.46

7 387 3.96

8 562 5.52

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

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

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

REFERENCES (Cont.)

[4] Horowitz S., Reps T., and Binkley D. Inter-ProceduralSlicing Using Dependence Graphs. ACMTransactions 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-OrientedProgramming. In Proceedings of the EuropeanConference on Object-Oriented Programming (ECOOP),Finland, June 1997. Springer-Verlag.

[6] Zhao J. Slicing Aspect-Oriented Software. In Proceedingsof 10th International Workshop on Program

Comprehension, pages 251-260, June 2002.

29

REFERENCES (Cont.)

[7] Zhao J. and Rinard M. System Dependence Graph Construction for Aspect-Oriented Programs. Technical report, Laboratory for Computer Science, MassachusettsInstitute of Technology, USA, March 2003. [8] Braak T. T. Extending program slicing in aspect-oriented

programming with inter-type declarations. 5th TSCon ITProgram, 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

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 ofConcurrent 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.

31

www.carrertime.inwww.facebook.com/carrertime.in