Program slicing with exception handling Carlos S. Galindo Jim enez - - PowerPoint PPT Presentation

program slicing with exception handling
SMART_READER_LITE
LIVE PREVIEW

Program slicing with exception handling Carlos S. Galindo Jim enez - - PowerPoint PPT Presentation

Introduction Problems and proposals Conclusions Program slicing with exception handling Carlos S. Galindo Jim enez Universidad Polit ecnica de Valencia Dec 18th, 2019 Introduction Problems and proposals Conclusions Table of Contents


slide-1
SLIDE 1

Introduction Problems and proposals Conclusions

Program slicing with exception handling

Carlos S. Galindo Jim´ enez

Universidad Polit´ ecnica de Valencia

Dec 18th, 2019

slide-2
SLIDE 2

Introduction Problems and proposals Conclusions

Table of Contents

Introduction Program slicing The System Dependence Graph Exception handling Problems and proposals Problem 1: incorrect slices with nested unconditional jumps Problem 2: incorrect weak slices Problem 3: incomplete catch treatment Conclusions

2/21

slide-3
SLIDE 3

Introduction Problems and proposals Conclusions

Overview

Introduction Program slicing The System Dependence Graph Exception handling Problems and proposals Conclusions

3/21

slide-4
SLIDE 4

Introduction Problems and proposals Conclusions

Program slicing

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 } 1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 }

Example adapted from [Tip95].

4/21

slide-5
SLIDE 5

Introduction Problems and proposals Conclusions

Program slicing

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 } 1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 }

Example adapted from [Tip95].

4/21

slide-6
SLIDE 6

Introduction Problems and proposals Conclusions

Program slicing

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 } 1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 }

Example adapted from [Tip95].

4/21

slide-7
SLIDE 7

Introduction Problems and proposals Conclusions

Program slicing

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 } 1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 }

Example adapted from [Tip95].

4/21

slide-8
SLIDE 8

Introduction Problems and proposals Conclusions

Program slicing

Applications

◮ Debugging ◮ Program specialization ◮ Software maintenance ◮ Code obfuscation ◮ Dead code removal ◮ Program parallelization

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x > 0) {

5

sum += x;

6

prod *= x;

7

x--;

8

}

9

log("sum: " + sum);

10

log(" prod: " + prod);

11 } 5/21

slide-9
SLIDE 9

Introduction Problems and proposals Conclusions

Program slicing

Metrics

  • Completeness. The slice includes all instructions that are necessary.
  • Correctness. The statements included affect the slicing criterion.

Correct and complete: Correct and incomplete: Incorrect and complete: Incorrect and incomplete:

6/21

slide-10
SLIDE 10

Introduction Problems and proposals Conclusions

Program slicing

Metrics

  • Completeness. The slice includes all instructions that are necessary.
  • Correctness. The statements included affect the slicing criterion.

Correct and complete: Correct and incomplete: Incorrect and complete: Incorrect and incomplete:

6/21

slide-11
SLIDE 11

Introduction Problems and proposals Conclusions

Program slicing

Metrics

  • Completeness. The slice includes all instructions that are necessary.
  • Correctness. The statements included affect the slicing criterion.

Correct and complete: Correct and incomplete: Incorrect and complete: Incorrect and incomplete:

6/21

slide-12
SLIDE 12

Introduction Problems and proposals Conclusions

Program slicing

Metrics

  • Completeness. The slice includes all instructions that are necessary.
  • Correctness. The statements included affect the slicing criterion.

Correct and complete: Correct and incomplete: Incorrect and complete: Incorrect and incomplete:

6/21

slide-13
SLIDE 13

Introduction Problems and proposals Conclusions

Program slicing

Metrics

  • Completeness. The slice includes all instructions that are necessary.
  • Correctness. The statements included affect the slicing criterion.

Correct and complete: Correct and incomplete: Incorrect and complete: Incorrect and incomplete:

6/21

slide-14
SLIDE 14

Introduction Problems and proposals Conclusions

Program slicing

Metrics

  • Completeness. The slice includes all instructions that are necessary.
  • Correctness. The statements included affect the slicing criterion.

Correct and complete: Correct and incomplete: Incorrect and complete: Incorrect and incomplete:

6/21

slide-15
SLIDE 15

Introduction Problems and proposals Conclusions

The System Dependence Graph

Creation

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x >0) {

5

sum += sum;

6

prod *= prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 } 7/21

slide-16
SLIDE 16

Introduction Problems and proposals Conclusions

The System Dependence Graph

Creation

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x >0) {

5

sum += sum;

6

prod *= prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) 5: sum += sum 6: prod *= prod 7: x--

7/21

slide-17
SLIDE 17

Introduction Problems and proposals Conclusions

The System Dependence Graph

Creation

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x >0) {

5

sum += sum;

6

prod *= prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) 5: sum += sum 6: prod *= prod 7: x--

7/21

slide-18
SLIDE 18

Introduction Problems and proposals Conclusions

The System Dependence Graph

Creation

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x >0) {

5

sum += sum;

6

prod *= prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

7/21

slide-19
SLIDE 19

Introduction Problems and proposals Conclusions

The System Dependence Graph

Creation

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x >0) {

5

sum += sum;

6

prod *= prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

7/21

slide-20
SLIDE 20

Introduction Problems and proposals Conclusions

The System Dependence Graph

Creation

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x >0) {

5

sum += sum;

6

prod *= prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

7/21

slide-21
SLIDE 21

Introduction Problems and proposals Conclusions

The System Dependence Graph

Creation

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x >0) {

5

sum += sum;

6

prod *= prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

7/21

slide-22
SLIDE 22

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-23
SLIDE 23

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-24
SLIDE 24

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-25
SLIDE 25

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-26
SLIDE 26

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-27
SLIDE 27

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-28
SLIDE 28

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-29
SLIDE 29

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-30
SLIDE 30

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-31
SLIDE 31

Introduction Problems and proposals Conclusions

The System Dependence Graph

Traversal

1 void f(int x) { 2

int sum = 0;

3

int prod = 0;

4

while (x>0) {

5

sum += sum;

6

prod*=prod;

7

x--;

8

}

9

log(sum);

10

log(prod);

11 }

Enter f() 2: int sum = 0 3: int prod = 0 4: while (x > 0) 9: log("sum: " + sum) 10: log("prod: " + prod) x = x_in 5: sum += sum 6: prod *= prod 7: x--

8/21

slide-32
SLIDE 32

Introduction Problems and proposals Conclusions

Exception Handling Systems

Java

1 void main () { 2

try {

3

f();

4

} catch (Exception e) {

5

log(" caught exception ");

6

} catch (Throwable e) {

7

log(" caught throwable ");

8

}

9 } 10 void f() throws Throwable { 11

switch(x) {

12

case A:

13

log("no error ");

14

break;

15

case B:

16

throw new Exception();

17

default:

18

throw new Throwable();

19

}

20 } 9/21

slide-33
SLIDE 33

Introduction Problems and proposals Conclusions

Exception Handling Systems

Java

1 void main () { 2

try {

3

f();

4

} catch (Exception e) {

5

log(" caught exception ");

6

} catch (Throwable e) {

7

log(" caught throwable ");

8

}

9 } 10 void f() throws Throwable { 11

switch(x) {

12

case A:

13

log("no error ");

14

break;

15

case B:

16

throw new Exception();

17

default:

18

throw new Throwable();

19

}

20 } 9/21

slide-34
SLIDE 34

Introduction Problems and proposals Conclusions

Exception Handling Systems

Java

1 void main () { 2

try {

3

f();

4

} catch (Exception e) {

5

log(" caught exception ");

6

} catch (Throwable e) {

7

log(" caught throwable ");

8

}

9 } 10 void f() throws Throwable { 11

switch(x) {

12

case A:

13

log("no error ");

14

break;

15

case B:

16

throw new Exception();

17

default:

18

throw new Throwable();

19

}

20 } 9/21

slide-35
SLIDE 35

Introduction Problems and proposals Conclusions

Exception Handling Systems

Java

1 void main () { 2

try {

3

f();

4

} catch (Exception e) {

5

log(" caught exception ");

6

} catch (Throwable e) {

7

log(" caught throwable ");

8

}

9 } 10 void f() throws Throwable { 11

switch(x) {

12

case A:

13

log("no error ");

14

break;

15

case B:

16

throw new Exception();

17

default:

18

throw new Throwable();

19

}

20 } 9/21

slide-36
SLIDE 36

Introduction Problems and proposals Conclusions

Exception Handling Systems

Java

1 void main () { 2

try {

3

f();

4

} catch (Exception e) {

5

log(" caught exception ");

6

} catch (Throwable e) {

7

log(" caught throwable ");

8

}

9 } 10 void f() throws Throwable { 11

switch(x) {

12

case A:

13

log("no error ");

14

break;

15

case B:

16

throw new Exception();

17

default:

18

throw new Throwable();

19

}

20 } 9/21

slide-37
SLIDE 37

Introduction Problems and proposals Conclusions

Exception Handling Systems

Java

1 void main () { 2

try {

3

f();

4

} catch (Exception e) {

5

log(" caught exception ");

6

} catch (Throwable e) {

7

log(" caught throwable ");

8

}

9 } 10 void f() throws Throwable { 11

switch(x) {

12

case A:

13

log("no error ");

14

break;

15

case B:

16

throw new Exception();

17

default:

18

throw new Throwable();

19

}

20 } 9/21

slide-38
SLIDE 38

Introduction Problems and proposals Conclusions

Exception Handling Systems

Java

Exception RuntimeException ... Error ... ... Throwable

◮ Checked (solid): must be caught (try-catch) or declared (f() throws T). ◮ Unchecked (dashed).

10/21

slide-39
SLIDE 39

Introduction Problems and proposals Conclusions

Exception Handling Systems

Other programming languages

Language % usage JavaScript 69.7 HTML/CSS 63.1 SQL 56.5 Python 39.4 Java 39.2 Bash/Shell/PowerShell 37.9 C# 31.9 PHP 25.8 TypeScript 23.5 C++ 20.4 Language % usage C 17.3 Ruby 8.9 Go 8.8 Swift 6.8 Kotlin 6.6 R 5.6 VBA 5.5 Objective-C 5.2 Assembly 5.0

Table: Programming language by usage in the software industry (StackOverflow’s 2019 Developer Survey)

11/21

slide-40
SLIDE 40

Introduction Problems and proposals Conclusions

Exception Handling Systems

Other programming languages

Language % usage JavaScript 69.7 HTML/CSS 63.1 SQL 56.5 Python 39.4 Java 39.2 Bash/Shell/PowerShell 37.9 C# 31.9 PHP 25.8 TypeScript 23.5 C++ 20.4 Language % usage C 17.3 Ruby 8.9 Go 8.8 Swift 6.8 Kotlin 6.6 R 5.6 VBA 5.5 Objective-C 5.2 Assembly 5.0

Table: Programming language by usage in the software industry (StackOverflow’s 2019 Developer Survey)

11/21

slide-41
SLIDE 41

Introduction Problems and proposals Conclusions

Exception Handling Systems

Other programming languages

Language % usage JavaScript 69.7 HTML/CSS 63.1 SQL 56.5 Python 39.4 Java 39.2 Bash/Shell/PowerShell 37.9 C# 31.9 PHP 25.8 TypeScript 23.5 C++ 20.4 Language % usage C 17.3 Ruby 8.9 Go 8.8 Swift 6.8 Kotlin 6.6 R 5.6 VBA 5.5 Objective-C 5.2 Assembly 5.0

Table: Programming language by usage in the software industry (StackOverflow’s 2019 Developer Survey)

11/21

slide-42
SLIDE 42

Introduction Problems and proposals Conclusions

Overview

Introduction Problems and proposals Problem 1: incorrect slices with nested unconditional jumps Problem 2: incorrect weak slices Problem 3: incomplete catch treatment Conclusions

12/21

slide-43
SLIDE 43

Introduction Problems and proposals Conclusions

Problem 1

The subsumption correctness error

1 public

void f() {

2

while (X) {

3

if (Y) {

4

if (Z) {

5

A;

6

break;

7

}

8

B;

9

break;

10

}

11

C;

12

}

13

D;

14 } 13/21

slide-44
SLIDE 44

Introduction Problems and proposals Conclusions

Problem 1

The subsumption correctness error

1 public

void f() {

2

while (X) {

3

if (Y) {

4

if (Z) {

5

A;

6

break;

7

}

8

B;

9

break;

10

}

11

C;

12

}

13

D;

14 }

enter f() while (X) D if (Y) C if (Z) break2 break1 A B

13/21

slide-45
SLIDE 45

Introduction Problems and proposals Conclusions

Problem 1

The subsumption correctness error

1 public

void f() {

2

while (X) {

3

if (Y) {

4

if (Z) {

5

A;

6

break;

7

}

8

B;

9

break;

10

}

11

C;

12

}

13

D;

14 }

enter f() while (X) D if (Y) C if (Z) break2 break1 A B

13/21

slide-46
SLIDE 46

Introduction Problems and proposals Conclusions

Problem 1

The subsumption correctness error

1 public

void f() {

2

while (X) {

3

if (Y) {

4

if (Z) {

5

A;

6

break;

7

}

8

B;

9

break;

10

}

11

C;

12

}

13

D;

14 }

enter f() while (X) D if (Y) C if (Z) break2 break1 A B

13/21

slide-47
SLIDE 47

Introduction Problems and proposals Conclusions

Problem 1: proposed solution

The subsumption correctness error

  • 1. Identify edges caused by

unconditional jumps.

  • 2. Remove from Ec all (a, b) such that

(a′, b) ∈ Ec ∧ a′, b ∈ J ∧ (a′, b), (a, b) ∈ Ea′ J: unconditional jumps Ec: control edges Ea′: edges caused by a′

14/21

slide-48
SLIDE 48

Introduction Problems and proposals Conclusions

Problem 1: proposed solution

The subsumption correctness error

  • 1. Identify edges caused by

unconditional jumps.

  • 2. Remove from Ec all (a, b) such that

(a′, b) ∈ Ec ∧ a′, b ∈ J ∧ (a′, b), (a, b) ∈ Ea′ J: unconditional jumps Ec: control edges Ea′: edges caused by a′

14/21

slide-49
SLIDE 49

Introduction Problems and proposals Conclusions

Problem 1: proposed solution

The subsumption correctness error

  • 1. Identify edges caused by

unconditional jumps.

  • 2. Remove from Ec all (a, b) such that

(a′, b) ∈ Ec ∧ a′, b ∈ J ∧ (a′, b), (a, b) ∈ Ea′ J: unconditional jumps Ec: control edges Ea′: edges caused by a′

enter f() while (X) D if (Y) C if (Z) break2 break1 A B 14/21

slide-50
SLIDE 50

Introduction Problems and proposals Conclusions

Problem 1: proposed solution

The subsumption correctness error

  • 1. Identify edges caused by

unconditional jumps.

  • 2. Remove from Ec all (a, b) such that

(a′, b) ∈ Ec ∧ a′, b ∈ J ∧ (a′, b), (a, b) ∈ Ea′ J: unconditional jumps Ec: control edges Ea′: edges caused by a′

enter f() while (X) D if (Y) C if (Z) break2 break1 A B 14/21

slide-51
SLIDE 51

Introduction Problems and proposals Conclusions

Problem 2

Unnecessary instructions in weak slicing

1 void g() { 2

int a = 1;

3

while (a > 0) {

4

if (a > 10)

5

break;

6

a++;

7

}

8

log(a);

9 } 15/21

slide-52
SLIDE 52

Introduction Problems and proposals Conclusions

Problem 2

Unnecessary instructions in weak slicing

1 void g() { 2

int a = 1;

3

while (a > 0) {

4

if (a > 10)

5

break;

6

a++;

7

}

8

log(a);

9 } f() int a = 1 while (a > 0) if (a > 10) log(a) a++ break 15/21

slide-53
SLIDE 53

Introduction Problems and proposals Conclusions

Problem 2

Unnecessary instructions in weak slicing

1 void g() { 2

int a = 1;

3

while (a > 0) {

4

if (a > 10)

5

break;

6

a++;

7

}

8

log(a);

9 } f() int a = 1 while (a > 0) if (a > 10) log(a) a++ break 15/21

slide-54
SLIDE 54

Introduction Problems and proposals Conclusions

Problem 2: proposed solution

Unnecessary instructions in weak slicing

  • 1. Remove all forward-jumping

unconditional jump’s nodes.

  • 2. Traverse the graph.
  • 3. Re-add all nodes removed if there is

any statement in the slice after their destination.

  • 4. If (3) changed the graph, goto (2).

f() int a = 1 while (a > 0) if (a > 10) log(a) a++ break

16/21

slide-55
SLIDE 55

Introduction Problems and proposals Conclusions

Problem 2: proposed solution

Unnecessary instructions in weak slicing

  • 1. Remove all forward-jumping

unconditional jump’s nodes.

  • 2. Traverse the graph.
  • 3. Re-add all nodes removed if there is

any statement in the slice after their destination.

  • 4. If (3) changed the graph, goto (2).

f() int a = 1 while (a > 0) if (a > 10) log(a) a++

16/21

slide-56
SLIDE 56

Introduction Problems and proposals Conclusions

Problem 2: proposed solution

Unnecessary instructions in weak slicing

  • 1. Remove all forward-jumping

unconditional jump’s nodes.

  • 2. Traverse the graph.
  • 3. Re-add all nodes removed if there is

any statement in the slice after their destination.

  • 4. If (3) changed the graph, goto (2).

f() int a = 1 while (a > 0) if (a > 10) log(a) a++

16/21

slide-57
SLIDE 57

Introduction Problems and proposals Conclusions

Problem 2: proposed solution

Unnecessary instructions in weak slicing

  • 1. Remove all forward-jumping

unconditional jump’s nodes.

  • 2. Traverse the graph.
  • 3. Re-add all nodes removed if there is

any statement in the slice after their destination.

  • 4. If (3) changed the graph, goto (2).

f() int a = 1 while (a > 0) if (a > 10) log(a) a++

16/21

slide-58
SLIDE 58

Introduction Problems and proposals Conclusions

Problem 2: proposed solution

Unnecessary instructions in weak slicing

  • 1. Remove all forward-jumping

unconditional jump’s nodes.

  • 2. Traverse the graph.
  • 3. Re-add all nodes removed if there is

any statement in the slice after their destination.

  • 4. If (3) changed the graph, goto (2).

f() int a = 1 while (a > 0) if (a > 10) log(a) a++

16/21

slide-59
SLIDE 59

Introduction Problems and proposals Conclusions

Problem 2: proposed solution

Unnecessary instructions in weak slicing

  • 1. Remove all forward-jumping

unconditional jump’s nodes.

  • 2. Traverse the graph.
  • 3. Re-add all nodes removed if there is

any statement in the slice after their destination.

  • 4. If (3) changed the graph, goto (2).

f() int a = 1 while (a > 0) if (a > 10) log(a) a++ break

16/21

slide-60
SLIDE 60

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 } 17/21

slide-61
SLIDE 61

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 }

enter x = x_in try f() x_in = x f() x = x_out x = x_out normal return error return x_in = x catch (Exception e) log("error") x = x_out x = x_out normal return error return error exit

17/21

slide-62
SLIDE 62

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f() ;

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 }

enter x = x_in try f() x_in = x f() x = x_out x = x_out normal return error return x_in = x catch (Exception e) log("error") x = x_out x = x_out normal return error return error exit

17/21

slide-63
SLIDE 63

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f() ;

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 }

enter x = x_in try f() x_in = x f() x = x_out x = x_out normal return error return x_in = x catch (Exception e) log("error") x = x_out x = x_out normal return error return error exit

17/21

slide-64
SLIDE 64

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f() ;

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 }

enter x = x_in try f() x_in = x f() x = x_out x = x_out normal return error return x_in = x catch (Exception e) log("error") x = x_out x = x_out normal return error return error exit

17/21

slide-65
SLIDE 65

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f() ;

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 }

enter x = x_in try f() x_in = x f() x = x_out x = x_out normal return error return x_in = x catch (Exception e) log("error") x = x_out x = x_out normal return error return error exit

17/21

slide-66
SLIDE 66

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 }

enter x = x_in try f() x_in = x f() x = x_out x = x_out normal return error return x_in = x catch (Exception e) log("error") x = x_out x = x_out normal return error return error exit

17/21

slide-67
SLIDE 67

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9 10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 }

enter x = x_in try f() x_in = x f() x = x_out x = x_out normal return error return x_in = x catch (Exception e) log("error") x = x_out x = x_out normal return error return error exit

17/21

slide-68
SLIDE 68

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9

x = 0;

10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 } enter x = x_in try x = 0 f() x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x_in = x x = x_out x = x_out normal return error return error exit 17/21

slide-69
SLIDE 69

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9

x = 0;

10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 } enter x = x_in try x = 0 f() x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x_in = x x = x_out x = x_out normal return error return error exit 17/21

slide-70
SLIDE 70

Introduction Problems and proposals Conclusions

Problem 3

The Lack of Dependencies of catch Statements

1 int x; 2 3 void

main () throws Exception {

4

try {

5

f();

6

} catch (Exception e) {

7

log("error");

8

}

9

x = 0;

10

f();

11 } 12 13 void f()

throws Exception {

14

x++;

15

if (x > 0)

16

throw new Exception ();

17

log(x);

18 } enter x = x_in try x = 0 f() x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x_in = x x = x_out x = x_out normal return error return error exit 17/21

slide-71
SLIDE 71

Introduction Problems and proposals Conclusions

Problem 3: proposed solution

The lack of dependencies of catch statements

enter x = x_in try x = 0 f() x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x_in = x x = x_out x = x_out normal return error return error exit 18/21

slide-72
SLIDE 72

Introduction Problems and proposals Conclusions

Problem 3: proposed solution

The lack of dependencies of catch statements

enter x = x_in try x = 0 f() x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x_in = x x = x_out x = x_out normal return error return error exit 18/21

slide-73
SLIDE 73

Introduction Problems and proposals Conclusions

Problem 3: proposed solution

The lack of dependencies of catch statements

enter x = x_in try x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x = 0 f() x_in = x x = x_out x = x_out normal return error return error exit

18/21

slide-74
SLIDE 74

Introduction Problems and proposals Conclusions

Problem 3: proposed solution

The lack of dependencies of catch statements

enter x = x_in try x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x = 0 f() x_in = x x = x_out x = x_out normal return error return error exit

18/21

slide-75
SLIDE 75

Introduction Problems and proposals Conclusions

Problem 3: proposed solution

The lack of dependencies of catch statements

enter x = x_in try x_in = x f() x = x_out x = x_out normal return error return catch (Exception e) log("error") x = 0 f() x_in = x x = x_out x = x_out normal return error return error exit

18/21

slide-76
SLIDE 76

Introduction Problems and proposals Conclusions

Overview

Introduction Problems and proposals Conclusions

19/21

slide-77
SLIDE 77

Introduction Problems and proposals Conclusions

Conclusions

◮ Program slicing: a powerful technique, not yet complete for commonly used programming languages. ◮ Efficiency vs. completeness and correctness. ◮ Results: 3 problems and proposed solutions.

20/21

slide-78
SLIDE 78

Introduction Problems and proposals Conclusions

Conclusions

◮ Program slicing: a powerful technique, not yet complete for commonly used programming languages. ◮ Efficiency vs. completeness and correctness. ◮ Results: 3 problems and proposed solutions.

20/21

slide-79
SLIDE 79

Introduction Problems and proposals Conclusions

Future work

◮ Improve correctness of try-catch. ◮ Implement into existing software tools, benchmark against state of the art. ◮ Adapt to other variants of program slicing. ◮ Redefine control dependence (extend Danicic’s work [Dan+11]), execution dependence vs. presence dependence.

21/21

slide-80
SLIDE 80

References

Related work

Change to state of the art and move to introduction ◮ 1988: Horwitz, Reps and Ball [HRB88] present the SDG. ◮ 1993: Ball and Horwitz [BH93] present SDG with unconditional jumps ◮ 1998: Sinha and Harrold [SH98]; [SHR99] present SDG with exceptions. ◮ 2003: Allen and Horwitz [AH03] improves [SH98]. ◮ 2004: Jo and Chang [JC04] present an alternative construction of the graph (not demonstrated, not an improvement). ◮ 2006: Jiang et al. [Jia+06] propose a solution for C++, not applicable. ◮ 2011: Prabhy, Maeda and Blakrishnan [PMB11] propose another solution for C++, no notable improvement. ◮ 2011: Jie and Shu-juan [JSJ11] introduce Object-Oriented + Exception SDG, same errors as [AH03].

21/21

slide-81
SLIDE 81

References

Related work

Change to state of the art and move to introduction ◮ 1988: Horwitz, Reps and Ball [HRB88] present the SDG. ◮ 1993: Ball and Horwitz [BH93] present SDG with unconditional jumps ◮ 1998: Sinha and Harrold [SH98]; [SHR99] present SDG with exceptions. ◮ 2003: Allen and Horwitz [AH03] improves [SH98]. ◮ 2004: Jo and Chang [JC04] present an alternative construction of the graph (not demonstrated, not an improvement). ◮ 2006: Jiang et al. [Jia+06] propose a solution for C++, not applicable. ◮ 2011: Prabhy, Maeda and Blakrishnan [PMB11] propose another solution for C++, no notable improvement. ◮ 2011: Jie and Shu-juan [JSJ11] introduce Object-Oriented + Exception SDG, same errors as [AH03].

21/21

slide-82
SLIDE 82

References

Program slicing

Strong and Weak Slices

Definition (Strong slice [Wei81])

Given a program P, its slice S w.r.t. a slicing criterion SC is a subset of the statements (S ⊆ P) such that the execution of S yields the same sequence of values

  • n SC as the execution of P.

Definition (Weak slice [BG96])

Given a program P, its slice S w.r.t. a slicing criterion SC is a subset of the statements (S ⊆ P) such that the execution of S yields a sequence of values on SC (seqS), the execution of P yields a sequence of values on SC (seqP), and seqP is a prefix of seqS.

21/21

slide-83
SLIDE 83

References

Program Slicing

Strong and Weak Slices: Example

Original program 1 2 6

  • Slice A

1 2 6

  • Slice B

1 2 6 24 120 Slice C 1 1 1 1 1

Table: Sequences of values produced on the slicing criterion.

21/21

slide-84
SLIDE 84

References

Bibliography I

Matthew Allen and Susan Horwitz. “Slicing Java Programs That Throw and Catch Exceptions”. In: SIGPLAN Not. 38.10 (2003),

  • pp. 44–54. issn: 0362-1340.

David Binkley and Keith Brian Gallagher. “Program Slicing”. In: Advances in Computers 43.2 (1996), pp. 1–50. doi: 10.1016/S0065-2458(08)60641-5. url: http://dx.doi.org/10.1016/S0065-2458(08)60641-5. Thomas Ball and Susan Horwitz. “Slicing Programs with Arbitrary Control-flow”. In: Proceedings of the First International Workshop on Automated and Algorithmic Debugging. AADEBUG ’93. London, UK, UK: Springer-Verlag, 1993, pp. 206–222. isbn: 3-540-57417-4.

21/21

slide-85
SLIDE 85

References

Bibliography II

Sebastian Danicic et al. “A unifying theory of control dependence and its application to arbitrary program structures”. In: Theoretical Computer Science 412 (Nov. 2011), pp. 6809–6842. doi: 10.1016/j.tcs.2011.08.033. Susan Horwitz, Thomas Reps, and David Binkley. “Interprocedural Slicing Using Dependence Graphs”. In: Proceedings of the ACM SIGPLAN 1988 Conference on Programming Language Design and

  • Implementation. PLDI ’88. Atlanta, Georgia, USA: ACM, 1988,
  • pp. 35–46. isbn: 0-89791-269-1. doi: 10.1145/53990.53994. url:

http://doi.acm.org/10.1145/53990.53994. Jang-Wu Jo and Byeong-mo Chang. “Constructing Control Flow Graph for Java by Decoupling Exception Flow from Normal Flow”. In: May 2004, pp. 106–113. doi: 10.1007/978-3-540-24707-4_14.

21/21

slide-86
SLIDE 86

References

Bibliography III

  • S. Jiang et al. “Improving the Preciseness of Dependence Analysis

Using Exception Analysis”. In: 2006 15th International Conference on

  • Computing. IEEE, 2006, pp. 277–282. doi: 10.1109/CIC.2006.40.
  • H. Jie, J. Shu-juan, and H. Jie. “An approach of slicing for

Object-Oriented language with exception handling”. In: 2011 International Conference on Mechatronic Science, Electric Engineering and Computer (MEC). 2011, pp. 883–886. doi: 10.1109/MEC.2011.6025605. Prakash Prabhu, Naoto Maeda, and Gogul Balakrishnan. “Interprocedural Exception Analysis for C++”. In: Proceedings of the 25th European Conference on Object-oriented Programming. ECOOP’11. Berlin, Heidelberg: Springer-Verlag, 2011, pp. 583–608. isbn: 978-3-642-22654-0. url: http://dl.acm.org/citation.cfm?id=2032497.2032536.

21/21

slide-87
SLIDE 87

References

Bibliography IV

  • S. Sinha and M. J. Harrold. “Analysis of programs with

exception-handling constructs”. In: Proceedings. International Conference on Software Maintenance (Cat. No. 98CB36272). IEEE, 1998,

  • pp. 348–357. doi: 10.1109/ICSM.1998.738526.
  • S. Sinha, M. J. Harrold, and G. Rothermel.

“System-dependence-graph-based slicing of programs with arbitrary interprocedural control flow”. In: Proceedings of the 1999 International Conference on Software Engineering (IEEE Cat. No.99CB37002). IEEE, 1999, pp. 432–441. doi: 10.1145/302405.302675. Frank Tip. “A Survey of Program Slicing Techniques”. In: Journal of Programming Languages 3.3 (1995), pp. 121–189.

21/21

slide-88
SLIDE 88

References

Bibliography V

Mark Weiser. “Program Slicing”. In: Proceedings of the 5th international conference on Software engineering (ICSE ’81). San Diego, California, United States: IEEE Press, 1981, pp. 439–449. isbn: 0-89791-146-6.

21/21