Professional Documents
Culture Documents
• Introduction
• Inter-procedural slicing
• Static Slicing of OOP
• Dynamic Slicing of OOP
• Dynamic Slicing of Concurrent OOPs
• Dynamic Slicing of Distributed OOPs
• Dynamic Slicing of AOPs
• Current Research Direction
• Conclusion
Program Slicing
• Debugging
• Program understanding
• Testing
• Software maintenance
• Complexity measurement
• Program integration
• Reverse engineering
• Software reuse
Approaches to Slicing
• Dependence graph-based:
-PDG is used as intermediate representation
-Slice is computed as a reachability problem
44
Some Definitions (cont …)
45
EMDS Algorithm
1. Construct the ESDG of the OOP statically.
2. Do the following before execution of the program starts:
(a) unmark all the edges
(b) set dslice(u)=Φ for every node u of ESDG
(c) set RecentDef(var) = Φ for each variable
3. Run the Program & carry out the following after execution
of each statement:
(a) for each variable var used at u, do
(i) unmark the marked data dependence edges
corresponding to the previous execution of u.
(ii) mark the dep. edge (x,u) where x=RecentDef(var)
(RecentDef(var)-node corr.to most recent defn of var)
46
EMDS Algorithm (cont …)
47
EMDS Algorithm (cont …)
48
EMDS Algorithm (cont …)
(f) If u is a node representing a polymorphic method call, then
do the following:
(i) unmark the data dependence edges for the
previous execution.
(ii) mark the data dependence edges for the present
execution
(iii) mark the polymorphic call edge for the
present execution
(iv) mark the associated parameter edges
(v) mark the associated summary edges
49
EMDS Algorithm (cont …)
50
Example
1 class Elevator { 23 class AlarmElevator : public Elevator {
public public
2 Elevator(int1_top_floor) 24 AlarmElevator ( int top_floor)
3 {current_floor = 1; 25 Elevator (top_floor)
4 current_direction = UP; 26 {alarm_on = 0;}
5 top_floor = 1_top_floor; } 27 void set_alarm( )
6 virtual ~Elevator 28 {alarm_on = 1;}
7 void up( ) 29 void reset_alarm( )
8 {current_direction = UP;} 30 {alarm_on = 0;}
9 void down( ) 31 void go (int floor)
10 int which_floor( ) 32 { if (!alarm_on)
11 {current_direction = DOWN;} 33 Elevator :: go (floor)
12 {return current_floor; } };
13 Direction direction( ) protected:
14 {return current_direction; } int alarm_on;
15 virtual void go(int floor ) };
16 {if (current_direction = =UP) 34 main( int argc, char **argv) {
17 {while(current_floor != floor) Elevator *e_ptr;
&& (current_floor < = top_floor) 35 If (argv[1])
18 add(current_floor, 1); } 36 e_ptr = new Elevator (10);
else else
19 {while(current_floor != floor) && (current_floor > 0) 37 e_ptr = new AlarmElevator (10);
20 add(current_floor, -1); } 38 e_ptr - > go(5);
} 39 c_out << “\n currently on floor :” << e_ptr -> which_floor ( );
private: }
21 add(int &a, const int &b)
22 { a = a + b; }
protected:
int current_floor;
Direction current_direction
int top_floor; };
51
CLDG for Elevator
52
ESDG of the Example Program
53
Working of the Algorithm
• Consider input data argv[1] = 3.
- the program will execute statements 34, 35,
36, 2, 3, 4, 5, 38, 15, 16,17, 18, 21, 22, 17,
18, 21, 22,17, 39, 11,12.
- the algorithm marks the corresponding edges
• Let us compute dynamic slice at statement 39.
dslice(39)={39 A4_in,12, 1} dslice(39 A4_in)
dslice(12) dslice(1)
• The dynamic slice is shown as shaded vertices
in the figure.
54
Node-Marking Dynamic Slicing Algorithm
55
Algorithm
1. Construct the ESDG of the OOP statically.
56
Algorithm (cont…)
(b) if u is a def(var) node (definition node of var), then
(i) unmark the node RecentDef(var).
(ii) update RecentDef(var) = u.
(RecentDef(var)- node corr.to most recent defn of var)
(c) mark the node u.
(d) if u is a call vertex, then do the following:
(i) mark the vertex u.
(ii) mark the corresponding actual-in/out
vertices.
(iii) mark the method entry vertex of the
corresponding called method.
(iv) mark the corresponding formal-in/out
vertices.
4. Exit when the execution of program P terminates.
57
ESDG of the Example
58
Complexity Analysis
59
Comparison with Existing Algorithms
• The worst case space complexity of Zhao’s
algorithm is O(S).
- S is the length of execution.
60
Comparison (cont …)
61
EMDS vs NMDS Algorithm
62
Implementation
63
Implementation (cont …)
• We store the following information along with the
ESDG.
- the set defset(var) for each variable.
- label number of the statement.
- dslice(u) for every node u of ESDG.
64
Experimental Results
Table 1: Avg. Run-Time (in sec)
2 39 19 1 1
3 62 32 1 1
4 81 48 1 1
5 102 74 2 2
66
Experimental Analysis
67
Experimental Analysis (cont …)
68
Dynamic Slicing of Concurrent OOPs
• Many of the real life programs are concurrent
which run on different nodes connected to a N/W
• Debugging of concurrent OOPs are much harder
compared to sequential programs due to:
- non-deterministic nature
- lack of global states
- synchronization dependence
- multiple threads of control
- dynamically varying no.of processes
• No algorithm exists for dynamic slicing of
concurrent OOPs
69
Dynamic Slicing of Concurrent OOPs
• Many of the real life programs are concurrent
which run on different nodes connected to a N/W
• Debugging of concurrent OOPs are much harder
compared to sequential programs due to:
- non-deterministic nature
- lack of global states
- synchronization dependence
- multiple threads of control
- dynamically varying no.of processes
• No algorithm exists for dynamic slicing of
concurrent OOPs
Concurrent System Dependence
Graph (CSDG)
• A CSDG of a concurrent OOP is a directed
graph (NC, EC), where each node n NC
represents a statement. x, y NC, (y,x) EC,
iff one of the following holds:
- y is control dependent on x.
- y is data dependent on x.
- y is synchronization dependent on x.
- y is communication dependent on x.
Class Thread1 extends Thread {
private SyncObject O;
private CompObject C;
Example
void Thread1(SyncObject O, CompObject a1,
CompObject a2, CompObject a3)
{
this.O=O;
this.a1=a1;
this.a2=a2;
this.a3=a3;
} 14 class example {
1. public void run() { 15 public static void main(mstring[] argm) {
2. a2.mul(a1,a2); //a2=a1*a2 CompObject a1,a2,a3;
3. O.notify(); SyncObject o1;
4. a1.mul(a1,a3); //a1=a1*a3 O1.reset();
5. O.wait(); 16 a1=new CompObject(Integer.ParseInt(argm[0]);
6. a3.mul(a2,a2); //a3=a2*a2 17 a2=new CompObject(Integer.parseInt(argm[1]);
} 18 a3=new CompObject(Integer.ParseInt(argm[2]);
} 19 Thread t1=new Thread(o1,a1,a2,a3);
class Thread2 extends Thread {
20 Thread t2=new Thread(o1,a1,a2,a3);
private SyncObject O;
private CompObject C; 21 t1.start();
void Thread1(SyncObject O, CompObject a1, 22 t2.start();
CompObject a2, CompObject a3) }
{ }
this.O=O;
this.a1=a1;
this.a2=a2;
this.a3=a3;
}
7 public void run() {
8 O.wait();
9 a2.mul(a1,a1);
10 O.notify();
11 if(a1=a2)
12 a3.mul(a2,a1);
else
13 a2.mul(a1,a1);
}
}
Some Definitions
21 1
19 2 3 4 5 6
16
14 15
17
13
18
8 9 10 11
20
2. Runtime Updations: Run the program and carry out the following after
each statement u of the program P is executed.
(a) Unmark all outgoing marked dependence edges excluding the control
dependence edges, if any, associated with the variable var,
corresponding to the previous execution of the node u.
(b) Updating data dependencies:For every variable var used at node u,
mark the data dependence edge corresponding to the most
recent definition RecentDef(var) of the variable var.
(c) Updating synchronization dependencies: If u is a wait( ) node,
then mark the outgoing synchronization dependence edge
corresponding to the associated notify( ) node.
(d) Updating communication dependencies: If u is a Use(var) node,
then mark the outgoing communication dependence edge, if any,
corresponding to the associated Def(var) node.
(e) Updating dynamic slice for different dependencies:
21 1
Slice point
19 2 3 4 5 6
16
14 15
17
13
18
8 9 10 11
20
• We propose an algorithm
- parallel dynamic slicing (PDS)
algorithm for distributed OOPs.
2. Runtime Updations: Run the program and carry out the following after
each statement (p,u) of the sub-program Pi is executed.
(a) Unmark all marked dependence edges excluding the control
dependence edges, if any, associated with the variable var,
corresponding to the previous execution of the node u.
(b) Updating data dependencies:For every variable var used at node u,
mark the data dependence edge corresponding to the most
recent definition RecentDef(var) of the variable var.
(c) Updating synchronization dependencies: If u is a wait( ) node,
then mark the synchronization dependence edge
corresponding to the associated notify( ) node.
(d) Updating communication dependencies: If u is a receive node,
then mark the communication dependence edge, if any,
corresponding to the associated C-node.
(e) Updating dynamic slice for different dependencies:
125
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
•Separation of Concerns
AOP makes it possible to encapsulate cross-cutting
concerns
127
Benefits of AOP (Cont.)
•Reuse
Aspects can often be reused in other programs with
only slight modifications
128
An Example AspectJ Program
129
Algorithm: Trace file Based algorithm
133
Dynamic Aspect-Oriented Dependence Graph (DADG)
134
Dynamic Slice
135
Average Runtime
• Discussed
- the intermediate representation for OOPs.
- static slicing of OOPs.
- dynamic slicing of OOPs.
- dynamic slicing of concurrent OOPs.
- dynamic slicing of distributed OOPs.
- dynamic slicing of AOPs.
• The edge marking algorithms do not use trace
files to store the execution history.
• No extra file I/O operation is required.
References
[1] H. Agrawal, R. Demilo and E. Spafford, “Debugging with Dynamic Slicing
and Backtracking,”Software- Practice and Experience, Vol.23, No.6, pp.589-
616, 1993.
[2] S. Horwitz, T. Reps and D. Binkley, “Interprocedural Slicing Using
Dependence Graphs,” ACM Transaction on Programming Language and
System, Vol.12, No.1,pp.26-60, 1990 .
[3] L. D. Larson and M. J. Harrold, “Slicing Object-Oriented Software,”
Proceedings of the18th International Conference on Software
Engineering, German, March, 1996.
[4] J. Zhao, J. Cheng and K. Ushijima, “Static Slicing of Concurrent Object-
Oriented Programs,” Proceedings of the 20th IEEE Annual International
Computer Software and Applications Conference, pp. 312-320, August-
1996 .
[5] J. Zhao, “Applying Program Dependence Analysis to Java Software,”
Proceedings of the Workshop on Software Engineering and Data base
Systems, International Computer Symposium, pp.162-169, Tainan, Taiwan,
December-1998.
[
References
[6] J. Zhao, “Dynamic Slicing of Object-Oriented Programs,” Technical Report,
Software Engg.,pp.98-119,Information Processing Society of Japan, May–
1998.
[7] K. B. Gallagher and J. R. Lyle, “Using Program Slicing in Software
Maintenance,” IEEE Transaction on Software Engineering, Vol.17, No. 8,
pp.751-761, 1991.
[8] R. Chatterjee and B.Ryder, “Scalable Flow-sensitive Type Inference for
Statically Typed Object-Oriented Languages,” Technical Report DCS-TR-
326, Rutgers University, August-1994.
[9] W.Landi, B.Ryder, and S. Zhang, “Interprocedural Modification side effect
analysis with pointer aliasing,” Proceedings of SIGPLAN’93 Conference on
Programming Languages Design and Implementation, pp.56-57, June-
1993.
[10] T. Reps, S. Horwitz, M. Sagiv, and D. Rosay, “Speeding up Slicing,”
Proceedings of the 2nd ACM Conference on Software Engineering, pp. 11-
20, December- 1994.
References
[11] P. Tonella, G.Antoniol, R.Fiutem, and E.Merlo, “Flow Insensitive C++
Pointers and Polymorphism Analysis and it’s Application to Slicing,”
Proceedings of the 19th International Conference on Software
Engineering, pp. 433-443,May-1997.
[12] J.T.Chan, and W.Yang, “A Program Slicing System for Object-Oriented
Programs,” Proceedings of the 1996 International Computer Symposium,
Taiwan, Dec-1996.
[13] J.T.Chen, F.J.Wang, and Y.L.Chen, “Slicing Object-Oriented Programs,”
Proceedings of the APSEC’97, PP. 395-404, Hongkong, China, December-
1997.
[14] A.Krishnaswamy, “Program Slicing: An Application of Object-Oriented
Program Dependency Graphs,” Technical Report TR94-108, Department of
Computer Science, Clemson University, August-1994.
[15] F. Tip, “A Survey on Program Slicing Techniques,” Journal of Programming
Languages, Vol.3, No.3, pp.121-189, September-1995.
References
16]D. Goswami and R. Mall, “An Efficient Method for Computing Dynamic
Program Slices,” Information Processing Letters, Vol.81, pp.111-117, 2002.
[17]M. Weiser, “Programmers Use Slices When Debugging,” Communications
of the ACM, Vol.25, pp.446-452, 1982.
[18]R. Mall, Fundamentals of Software Engineering, Prentice-Hall, India, 1999.
[19]A. Aho, R.Sethi, J.Ullman, Compilers, Principles and Techniques, Addison-
Wesley,1986.
[20]G. B. Mund, R. Mall and S. Sarakar “An Efficient Technique for Dynamic
Slicing of Programs,” Information and Software Technology, March, 2002.
Thank You