06-51r4_2010116csc

Upload: shashank-pathak

Post on 02-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 06-51R4_2010116csc

    1/7

    Dynamic Program Analysis Tool

    by

    Anushruti Sharma

    (Roll no-2010116)

    Supervisor:

    Dr.Atul Gupta

    Computer Science and Engineering

    PDPM Indian Institute of Information Technlogy,Design and Manufactring

    Jabalpur

    (23-7-2013 to 6-8-2013)

  • 7/27/2019 06-51R4_2010116csc

    2/7

    Dynamic Slicing of Object Oriented Program

    Introduction:

    Different program analysis techniques uses intermediate presentation of a code for analysing it.

    There are many program representation like SPG,PDG,CIDG but they only support structural

    languages. To represent object oriented features like inheritance,polymorphism,dynamic binding

    and encapsulation a special type of program representation is needed. Extended System

    Dependence Graph(ESDG),Object Program Dependence Graph(OPDG) supports object oriented

    feature in some extent. So there is need of a program representation which supports all the features

    of Object Oriented Programming Languages. Call based Object Oriented System Dependence

    Graph(COSDG) supports features of OOPLs. The main feature of COSDG is the method visibility

    of parent class to child class and it helps to distinguish between inherited and polymorphic method

    call. That helps to get a precise coverage of a program. The aim of this report is to study Call Based

    Object Oriented System Dependence Graph(COSDG) and comparison of COSDG with other

    program representation for OOP.

    Report on the Present Investigation/progress during 15 days-

    Call Based Object Oriented System Dependence Graph(COSDG)-

    COSDG is a directed graph G = (V,E) where V is the set of vertices and E is the set of edges.

    A vertex can be of three types-

    1.Statement vertices(VS)-These are of two types-

    Simple Statement Vertices(VS1).-assignment,loop,condition

    Call Vertices(VS2)-which call a methods.

    2..Entry vertices(Ve)-These are of two type-

    Class Entry Vertices(Ve1) Method Entry Vertices(Ve2)

    3.Parameter vertices(Vp)-These are of four type-

    Formal-in(Vp1)-Parameter which is defined by the procedure.

    Formal-out(Vp2)-Parameter which is modified by the procedure.

    Actual-in(Vp3)-Parameter which is defined by the Call site.

    Actual-out(Vp4)-Parameter which is modified by the call site.

    An edge can be of seven type-

    1. Control Dependence Edge.(EC)- If a vertex X is control dependent on Y then X and Y areconnected by the control dependence edge.

    Different cases are-

    A method and a statement defined within its body.

    An iterative (loop) or a conditional statement and a statement nested within the loop .

    A statement and itself (indicates a loop).

    A method and its formal parameter.

    A call site and its actual parameter.

    2. Data Dependence Edge(Ed)-Represent the data flow between two statement within a method.If

    statement X defines a variable v and statement Y is using it then X and Y are connected by Data

    Dependence Edge.

  • 7/27/2019 06-51R4_2010116csc

    3/7

    3. Parameter Dependence Edge(EP)-Value passing between the actual and formal parameters.

    These are of two type-

    Parameter-in(Ep1)-Connects Actual-in and Formal-in parameter.

    Parameter-out((Ep2)-Connects Actual-out and Formal-out parameter.

    4. Method Call Edge(Em)-These are of three type- Simple Call Edge(Em1)

    Inherited Call Edge(Em2)

    Polymorphic Call Edge(Em3)

    5.Class Member Edge(Eb)-Represents the membership between a class and it's methods.A class

    entry vertex is connected by a method entry vertex by class member edge.

    6.Summary Edge(ES)-Represent the transitive dependence between the Actual-in and Actual-out

    parameter. Transitive dependence means the value of Actual-out vertex may depend on the

    Actual-in vertex.

    7.Inheritance Edge(Ei)-It connects a child class to it's parent class. It is tagged with the methods in

    which are public and protected but should not override by the child class in parent class and

    visible in child class.

    Sample Program

    01:class A {

    02: A() { //constructor }

    03: int m2(int x) {

    04: return x+1;

    } }05:class B extends A {

    06: B() { //constructor }

    07: void m1() {

    08: int y = 10;

    09: y = m2(y);

    } }

    10:class C extends B {

    11: C() { //constructor }

    12: int m2(int x) {

    13: return ++x;} }

    14:public class Test {

    15: public static void

    main(String[] args) {

    //test driver code

    16: int x,y;

    17: x = args.length;

    18: B ObjRef = new B();

    19: ObjRef.m1();

    20: if (x == 1)

    21: ObjRef = new C();22: y = ObjRef.m2(x);

    } }

  • 7/27/2019 06-51R4_2010116csc

    4/7

    Construction of COSDG-

    1.Construct Class Dependence Graph(CIDG) for each class in the program.

    For each class-

    Construct a class entry vertex.

    Construct Method Dependence Graph

    For each method-Create a method entry vertex.

    1.Create formal parameter vertices.

    2.Add control dependence edges.

    3.Create statement vertices and call-site vertices.

    4.Add control dependence edges.

    5.Add data dependence edges.

    Add a class member edge between class entry and method entry vertex.

    2.Connect parent and child class with inheritance edge.

    3.Now connect all the call and callee site in the graph.

    At each call site

    Create actual parameter vertices /*Add actual-in, actual-out vertices */

    Add control dependence edges /* Call vertex to parameter vertices */

    Add a parameter edge for each pair of actual/formal vertices

    Determine transitive dependences; Add summary edges

    Process method calls; Add method call edges

    After Step 2

  • 7/27/2019 06-51R4_2010116csc

    5/7

    Complete COSDG after Step 3

  • 7/27/2019 06-51R4_2010116csc

    6/7

    Result and Discussion-

    Comparison with ESDG-

    The table shows that modification in COSDG .These modification provides a better and accurate

    traversal .

  • 7/27/2019 06-51R4_2010116csc

    7/7

    From the results, we can observe that both the memory required to store the COSDG and the time

    taken to construct it, increase almost linearly with increasing program size. These results have been

    illustrated in above figures The linear increase in COSDG size is quite obvious as every programstatement adds vertex and one or more edges to the graph, depending on the vertex type. The

    linear increase in time can be attributed to the combined effect of two components:

    code parsing time and the time needed to create graph components.

    Conclusion-

    For an efficient dynamic slicing tool the intermediate representation should be efficient. Call Based

    Object Oriented Graph(CODG) is suitable for the intermediate representation. As it is efficient and

    cover all the features of the OOPL.I will now work on the algorithm for dynamic slicing which is

    efficient .