CS510 Software Engineering
Program Representations
- Asst. Prof. Mathias Payer
Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-CS510-SE
CS510 Software Engineering Program Representations Asst. Prof. - - PowerPoint PPT Presentation
CS510 Software Engineering Program Representations Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-CS510-SE Spring 2015 Why
Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-CS510-SE
Mathias Payer (Purdue University) CS510 Software Engineering 2015 2 / 35
Control-Flow Graph
1
2
3
4
5
6
Mathias Payer (Purdue University) CS510 Software Engineering 2015 3 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 4 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 5 / 35
Control-Flow Graph
1Note that the graph is directed.
Mathias Payer (Purdue University) CS510 Software Engineering 2015 6 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 7 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 8 / 35
Control-Flow Graph
1 i n t
2
3
4
5
6 }
Mathias Payer (Purdue University) CS510 Software Engineering 2015 9 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 10 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 11 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 12 / 35
Control-Flow Graph
1 i n t sum = 0; 2 i n t
3 while
4
5
6 } 7 p r i n t f ( ”Sum: %d” , sum) ;
Mathias Payer (Purdue University) CS510 Software Engineering 2015 13 / 35
Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 14 / 35
Control-Flow Graph
1 i n t sum = 0; 2 i n t
3 while
4
5
6 } 7 p r i n t f ( ”Sum: %d” , sum) ;
Mathias Payer (Purdue University) CS510 Software Engineering 2015 15 / 35
Control-Flow Graph
1 i n t sum = 0; 2 i n t
3 while
4
5
6 } 7 p r i n t f ( ”Sum: %d” , sum) ;
2Back edges often identify loops.
Mathias Payer (Purdue University) CS510 Software Engineering 2015 16 / 35
Cyclomatic Complexity
1
2
3
4
5
6
Mathias Payer (Purdue University) CS510 Software Engineering 2015 17 / 35
Cyclomatic Complexity
Mathias Payer (Purdue University) CS510 Software Engineering 2015 18 / 35
Cyclomatic Complexity
1 i n t sum = 0; 2 i n t
3 while
4
5
6 } 7 p r i n t f ( ”Sum: %d” , sum) ;
Mathias Payer (Purdue University) CS510 Software Engineering 2015 19 / 35
Program Dependence Graph
1
2
3
4
5
6
Mathias Payer (Purdue University) CS510 Software Engineering 2015 20 / 35
Program Dependence Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 21 / 35
Program Dependence Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 22 / 35
Program Dependence Graph
1 i n t sum = 0; 2 i n t
3 while
4
5
6 } 7 p r i n t f ( ”Sum: %d” , sum) ;
Mathias Payer (Purdue University) CS510 Software Engineering 2015 23 / 35
Program Dependence Graph
1 i n t
2 x = . . . ; 3 y = . . . ; 4 p = &x ; 5 p = p + z ; 6 . . . = ∗p ; Mathias Payer (Purdue University) CS510 Software Engineering 2015 24 / 35
Program Dependence Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 25 / 35
Program Dependence Graph
all nodes post-dominated by Y X not post-dominated by Y
Mathias Payer (Purdue University) CS510 Software Engineering 2015 26 / 35
Program Dependence Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 27 / 35
Super Control-Flow Graph
1
2
3
4
5
6
Mathias Payer (Purdue University) CS510 Software Engineering 2015 28 / 35
Super Control-Flow Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 29 / 35
Call Graph
1
2
3
4
5
6
Mathias Payer (Purdue University) CS510 Software Engineering 2015 30 / 35
Call Graph
Mathias Payer (Purdue University) CS510 Software Engineering 2015 31 / 35
Other Representations and Tools
1
2
3
4
5
6
Mathias Payer (Purdue University) CS510 Software Engineering 2015 32 / 35
Other Representations and Tools
Mathias Payer (Purdue University) CS510 Software Engineering 2015 33 / 35
Other Representations and Tools
Mathias Payer (Purdue University) CS510 Software Engineering 2015 34 / 35
Other Representations and Tools
Mathias Payer (Purdue University) CS510 Software Engineering 2015 35 / 35