Introduction Problems and proposals Conclusions
Program slicing with exception handling Carlos S. Galindo Jim enez - - PowerPoint PPT Presentation
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
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
Introduction Problems and proposals Conclusions
Overview
Introduction Program slicing The System Dependence Graph Exception handling Problems and proposals Conclusions
3/21
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Introduction Problems and proposals Conclusions
Overview
Introduction Problems and proposals Conclusions
19/21
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
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
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
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
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
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
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
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
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
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
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
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