diff --git a/.gitignore b/.gitignore index 4404054..6bbd79b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,11 @@ *.toc *.fls *.fdb_latexmk -img/*.pdf +*.bbl +*.bcf +*.blg +*.run.xml +*.bib +*.vrb +figs/*.pdf beamer.pdf diff --git a/figs/example-sdg-1.dot b/figs/example-sdg-1.dot new file mode 100644 index 0000000..f561857 --- /dev/null +++ b/figs/example-sdg-1.dot @@ -0,0 +1,42 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + node [style=invis]; + edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + edge [style = invis]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-sdg-2.dot b/figs/example-sdg-2.dot new file mode 100644 index 0000000..600e8be --- /dev/null +++ b/figs/example-sdg-2.dot @@ -0,0 +1,42 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + node [style=invis]; + edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + edge [style = invis]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-sdg-3.dot b/figs/example-sdg-3.dot new file mode 100644 index 0000000..ec8f9e6 --- /dev/null +++ b/figs/example-sdg-3.dot @@ -0,0 +1,42 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + edge [style = invis]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-sdg-4.dot b/figs/example-sdg-4.dot new file mode 100644 index 0000000..d9410f8 --- /dev/null +++ b/figs/example-sdg-4.dot @@ -0,0 +1,41 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = blue, style = invis]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen, style = invis]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-sdg-5.dot b/figs/example-sdg-5.dot new file mode 100644 index 0000000..31d499c --- /dev/null +++ b/figs/example-sdg-5.dot @@ -0,0 +1,41 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen, style = invis]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-sdg-6.dot b/figs/example-sdg-6.dot new file mode 100644 index 0000000..3933f40 --- /dev/null +++ b/figs/example-sdg-6.dot @@ -0,0 +1,41 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-sdg.dot b/figs/example-sdg.dot new file mode 100644 index 0000000..3933f40 --- /dev/null +++ b/figs/example-sdg.dot @@ -0,0 +1,41 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-1.dot b/figs/example-slice-1.dot new file mode 100644 index 0000000..d2164fa --- /dev/null +++ b/figs/example-slice-1.dot @@ -0,0 +1,41 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-2.dot b/figs/example-slice-2.dot new file mode 100644 index 0000000..50f532d --- /dev/null +++ b/figs/example-slice-2.dot @@ -0,0 +1,45 @@ +digraph g { + l1 [label = "Enter f()"]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0"]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod"]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + edge [color = grey]; + l1 -> {l2 l3 l4 l9}; + l1 -> l10 [color = black, style = bold]; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + edge [color = grey]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = grey]; // sum + {l3 l6} -> {l6} [color = grey]; // prod + {l3 l6} -> {l10} [color = darkgreen, style = bold]; // prod + {x l7} -> {l4 l7} [color = grey]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-3.dot b/figs/example-slice-3.dot new file mode 100644 index 0000000..00cc1ca --- /dev/null +++ b/figs/example-slice-3.dot @@ -0,0 +1,45 @@ +digraph g { + l1 [label = "Enter f()", style = filled]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0", style = filled]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod", style = filled]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + edge [color = grey]; + l1 -> {l2 l3 l4 l9}; + l1 -> l10 [color = black, style = bold]; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + edge [color = grey]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = grey]; // sum + {l3 l6} -> {l6} [color = grey]; // prod + {l3 l6} -> {l10} [color = darkgreen, style = bold]; // prod + {x l7} -> {l4 l7} [color = grey]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-4.dot b/figs/example-slice-4.dot new file mode 100644 index 0000000..54923c6 --- /dev/null +++ b/figs/example-slice-4.dot @@ -0,0 +1,46 @@ +digraph g { + l1 [label = "Enter f()", style = filled]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0", style = filled]; + l4 [label = "4: while (x > 0)"]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod", style = filled]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + edge [color = grey]; + l1 -> {l2 l4 l9 l10}; + l1 -> l3 [color = black]; + l4 -> {l5 l7}; + l4 -> l6 [style = bold, color = black]; + } + + { // data input + node [style=dashed]; + edge [color = grey]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = grey]; // sum + {l3 l6} -> {l10} [color = grey]; // prod + {l3 l6} -> l6 [color = darkgreen]; + {x l7} -> {l4 l7} [color = grey]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-5.dot b/figs/example-slice-5.dot new file mode 100644 index 0000000..33b1127 --- /dev/null +++ b/figs/example-slice-5.dot @@ -0,0 +1,46 @@ +digraph g { + l1 [label = "Enter f()", style = filled]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0", style = filled]; + l4 [label = "4: while (x > 0)", style = filled]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod", style = filled]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + edge [color = grey]; + l1 -> {l2 l4 l9 l10}; + l1 -> l3 [color = black]; + l4 -> {l5 l7}; + l4 -> l6 [style = bold, color = black]; + } + + { // data input + node [style=dashed]; + edge [color = grey]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = grey]; // sum + {l3 l6} -> {l10} [color = grey]; // prod + {l3 l6} -> l6 [color = darkgreen]; + {x l7} -> {l4 l7} [color = grey]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-6.dot b/figs/example-slice-6.dot new file mode 100644 index 0000000..0ffbabf --- /dev/null +++ b/figs/example-slice-6.dot @@ -0,0 +1,45 @@ +digraph g { + l1 [label = "Enter f()", style = filled]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0", style = filled]; + l4 [label = "4: while (x > 0)", style = filled]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod", style = filled]; + l7 [label = "7: x--"]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + edge [color = grey]; + l1 -> {l2 l3 l9 l10}; + l1 -> l4 [color = black]; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + edge [color = grey]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in"]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = grey]; // sum + {l3 l6} -> {l6 l10} [color = grey]; // prod + {x l7} -> {l4} [color = red, style = bold]; // x + {x l7} -> {l7} [color = grey]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-7.dot b/figs/example-slice-7.dot new file mode 100644 index 0000000..c5eb08b --- /dev/null +++ b/figs/example-slice-7.dot @@ -0,0 +1,45 @@ +digraph g { + l1 [label = "Enter f()", style = filled]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0", style = filled]; + l4 [label = "4: while (x > 0)", style = filled]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod", style = filled]; + l7 [label = "7: x--", style = filled]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + edge [color = grey]; + l1 -> {l2 l3 l9 l10}; + l1 -> l4 [color = black]; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + edge [color = grey]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in", style = filled]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = grey]; // sum + {l3 l6} -> {l6 l10} [color = grey]; // prod + {x l7} -> {l4} [color = red, style = bold]; // x + {x l7} -> {l7} [color = grey]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice-8.dot b/figs/example-slice-8.dot new file mode 100644 index 0000000..0f5fa3f --- /dev/null +++ b/figs/example-slice-8.dot @@ -0,0 +1,45 @@ +digraph g { + l1 [label = "Enter f()", style = filled]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0", style = filled]; + l4 [label = "4: while (x > 0)", style = filled]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod", style = filled]; + l7 [label = "7: x--", style = filled]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = "bold,filled"]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + edge [color = grey]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6}; + l4 -> l7 [color = black]; + } + + { // data input + node [style=dashed]; + edge [color = grey]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in", style = filled]; + l1 -> x [color = black]; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = grey]; // sum + {l3 l6} -> {l6 l10} [color = grey]; // prod + {x l7} -> {l7} [color = red]; // x + {x l7} -> {l4} [color = grey]; // x + } +} \ No newline at end of file diff --git a/figs/example-slice.dot b/figs/example-slice.dot new file mode 100644 index 0000000..2aaf174 --- /dev/null +++ b/figs/example-slice.dot @@ -0,0 +1,41 @@ +digraph g { + l1 [label = "Enter f()", style = filled]; + l2 [label = "2: int sum = 0"]; + l3 [label = "3: int prod = 0", style = filled]; + l4 [label = "4: while (x > 0)", style = filled]; + l5 [label = "5: sum += sum"]; + l6 [label = "6: prod *= prod", style = filled]; + l7 [label = "7: x--", style = filled]; + l9 [label = "9: log(\"sum: \" + sum)"]; + l10 [label = "10: log(\"prod: \" + prod)", style = filled]; + // graph order + {rank=min; l1}; + {rank=same; l2 l3 l4 l9 l10}; + {rank=max; l5 l6 l7}; + { edge [style=invis]; + l2 -> l3 -> l4 -> l9 -> l10; + l5 -> l6 -> l7; + } + + { // control edges + // edge [style=invis]; + l1 -> {l2 l3 l4 l9 l10}; + l4 -> {l5 l6 l7}; + } + + { // data input + node [style=dashed]; + // node [style=invis]; + // edge [style=invis]; + x [label = "x = x_in", style = filled]; + l1 -> x; + x -> {l2} [style=invis]; + } + + { // data edges + edge [color=red,constraint=true]; + {l2 l5} -> {l5 l9} [color = blue]; // sum + {l3 l6} -> {l6 l10} [color = darkgreen]; // prod + {x l7} -> {l4 l7} [color = red]; // x + } +} \ No newline at end of file diff --git a/figs/exception-hierarchy.dot b/figs/exception-hierarchy.dot new file mode 100644 index 0000000..e31c5fe --- /dev/null +++ b/figs/exception-hierarchy.dot @@ -0,0 +1,14 @@ +digraph g { + node [shape = rect]; + Exception; + Error [style="dashed"]; + RuntimeException [style="dashed"]; + Throwable -> {Exception Error}; + Exception -> RuntimeException; + { node [label="...",style=dashed]; + a [style=""]; + Exception -> a; + Error -> b; + RuntimeException -> c; + } +} \ No newline at end of file diff --git a/listings-config.tex b/listings-config.tex index e30257e..fee1b78 100644 --- a/listings-config.tex +++ b/listings-config.tex @@ -10,6 +10,7 @@ % Style tabsize=2, basicstyle=\small\ttfamily, + showstringspaces=false, % Others language=Java, % Escape sequences (UTF-8 support) diff --git a/slides.tex b/slides.tex index 0b3f54a..22d7dd2 100644 --- a/slides.tex +++ b/slides.tex @@ -3,27 +3,32 @@ \documentclass[aspectratio=169,compress]{beamer} +% Basic packages \usepackage{pgfpages} \usepackage{listings} \usepackage[utf8]{inputenc} \usepackage[spanish,english]{babel} \usepackage{graphicx} +\usepackage{xcolor} +\usepackage{soul} -\newcommand{\bluebold}[1]{\textbf{\textcolor{blue}{#1}}} +% Bibliography settings +\usepackage[backend=bibtex,style=alphabetic,citestyle=alphabetic-verb]{biblatex} +\bibliography{biblio.bib} -% \usepackage{dot2texi} +% Graphics to create step-by-step graphs \usepackage{tikz} \usetikzlibrary{shapes,arrows} +% Beamer theme % \usetheme{beamertheme-bjeldbak/bjeldbak} \setbeamertemplate{note page}[plain] - % \setbeameroption{show notes on second screen=right} \usetheme{-bjeldbak/beamerthemebjeldbak} - % \usetheme{Madrid} % \usecolortheme{whale} +% Document metadata % \title[Program slicing with exceptions]{Fragmentación de programas con excepciones} \title{Program slicing with exception handling} \date{Dec 18th, 2019} @@ -32,6 +37,32 @@ Universidad Politécnica de Valencia } +% Escapable listing environment +\lstnewenvironment{java}[1][] +{\lstset{ + language=[LaTeX]TeX}\lstset{escapeinside={(*@}{@*)}, + numbers=left, + numberstyle=\tiny, + stepnumber=1, + numbersep=5pt, + breaklines=true, + %firstnumber=last, + %frame=tblr, + tabsize=2, + framesep=5pt, + basicstyle=\small\ttfamily, + showstringspaces=false, + %identifierstyle=\ttfamily, + stringstyle=\color{maroon}, + commentstyle=\color{black}, + rulecolor=\color{black}, + xleftmargin=0pt, + xrightmargin=0pt, + aboveskip=\medskipamount, + belowskip=\medskipamount, + backgroundcolor=\color{white}, #1 +}}{} + \begin{document} \input{listings-config} @@ -42,10 +73,8 @@ \begin{itemize} \item Proposal no, solution o proposed solution. + \item \ul{test} \end{itemize} - - - \end{frame} \begin{frame} @@ -53,33 +82,15 @@ \tableofcontents \end{frame} -% \begin{frame}{Index} -% \note{some other notes} -% \begin{itemize} -% \item Example of program slicing (w/o graphs) -% \item Usages of slicing -% \item Thesis' goal: program slicing in presence of exceptions -% \item Example of difference between complete/correct with Venn diagram -% \item Exception handling in Java, and minor mention to other languages -% \item Example of a SDG -% \item Unconditional control flow: add pseudo-predicates and example -% \item Exceptions: throw treatment and example, try-catch and example -% \item Problem 1, generalization and solution -% \item Problem 2, generalization and solution -% \item Problem 3, generalization and solution -% \end{itemize} -% \end{frame} - \section{Introduction} \subsection{Program slicing} -\begin{frame}[containsverbatim]{Program slicing} +\begin{frame}[fragile]{Program slicing} - \begin{minipage}{0.5\linewidth} - % Highlight using this, only useful line by line - % https://tex.stackexchange.com/questions/8851/how-can-i-highlight-some-lines-from-source-code#8860 - \begin{lstlisting} + \begin{columns} + \column{0.5\textwidth} + \begin{java} void f(int x) { int sum = 0; int prod = 0; @@ -89,29 +100,28 @@ void f(int x) { x--; } log("sum: " + sum); - log("prod: " + prod); + log("prod: " + (*@\textcolor<2->{blue}{prod}@*)); } - \end{lstlisting} - \end{minipage} - \begin{minipage}{0.49\linewidth} - \begin{lstlisting} + \end{java} + \column<3->{0.5\textwidth} + \begin{java} void f(int x) { - + (*@\invisible<4->{int sum = 0;}@*) int prod = 0; while (x > 0) { - + (*@\invisible<4->{sum += x;}@*) prod *= x; x--; } - + (*@\invisible<4->{log("sum: " + sum);}@*) log("prod: " + prod); } - \end{lstlisting} - \end{minipage} - - {\hfill Example adapted from [Tip 95].} + \end{java} + \end{columns} + {\hfill Example adapted from \cite{Tip95}.} \end{frame} +% TODO: posible addition of examples on the right side. \begin{frame}{Program slicing}{Applications} \begin{itemize} \item Debugging @@ -123,67 +133,106 @@ void f(int x) { \end{itemize} \end{frame} +% TODO: remove one of the notations in the examples. +% TODO: maybe use example 'block'? \begin{frame}{Program slicing}{Metrics} - \begin{itemize} - \item \textbf{Completeness.} The slice includes all instructions that are necessary. - \item \textbf{Correctness.} The slice excludes all instructions that are not necessary. - \end{itemize} + \begin{description} + \item[\textbf{Completeness.}] The slice includes all instructions that are necessary. + \item[\textbf{Correctness.}] The slice excludes all instructions that are not necessary. + \end{description} - If we have a program (complete but not correct) and its slice (complete and correct) we can show examples of (correct but not complete?) and (nor complete nor correct)---This is a graphics placeholder. + \vfill + \definecolor{minimalcolor}{rgb}{0.8588235294117647,0.3803921568627451,0.0784313725490196} + \definecolor{programcolor}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882} + \definecolor{slicecolor}{rgb}{0,0,0} + + \pause + \begin{columns} + \column{0.25\textwidth} + Correct and complete: \\ + \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45] + \draw [line width=2pt,color=programcolor,fill=programcolor,fill opacity=0.25] (0,0) circle (4em); + \draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); + \visible<3->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (0, 0) circle (2em);} + \end{tikzpicture} + $$c_m \wedge c_r$$ + % \includegraphics[width=\textwidth]{} + \column{0.25\textwidth} + Correct and incomplete: \\ + \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45] + \draw [line width=2pt,color=programcolor,fill=programcolor,fill opacity=0.25] (0,0) circle (4em); + \draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); + \visible<4->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (0, 0) circle (1.5em);} + \end{tikzpicture} + $$\neg c_m \wedge c_r$$ + % \includegraphics[width=\textwidth]{} + \column{0.25\textwidth} + Incorrect and complete: \\ + \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45] + \draw [line width=2pt,color=programcolor,fill=programcolor,fill opacity=0.25] (0,0) circle (4em); + \draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); + \visible<5->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (0, 0) circle (2.5em);} + \end{tikzpicture} + $$c_m \wedge \neg c_r$$ + % \includegraphics[width=\textwidth]{} + \column{0.25\textwidth} + Incorrect and incomplete: \\ + \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45] + \draw [line width=2pt,color=programcolor,fill=programcolor,fill opacity=0.25] (0,0) circle (4em); + \draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); + \visible<6->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (1em, 1em) circle (2em);} + \end{tikzpicture} + $$\neg c_m \wedge \neg c_r$$ + % \includegraphics[width=\textwidth]{} + \end{columns} \end{frame} -% \subsection{Goals} - -% \begin{frame}{Objectives} -% TODO; remove, this is the toc -% \begin{itemize} -% \item Analyse the state-of-the-art -% \item Analyse exception handling in program slicing -% \item Find problems with the state-of-the-art and propose solutions -% \end{itemize} -% \end{frame} - \subsection{Exception handling} -\begin{frame}[containsverbatim]{Exception handling systems}{Java} - \begin{minipage}{0.49\linewidth} - \begin{lstlisting} -try { +\begin{frame}[fragile]{Exception handling systems}{Java} + \begin{columns} + \column{0.5\textwidth} + \begin{java}[tabsize=2] +void main() { + (*@\textcolor<4->{blue}{try}@*) { f(); -} catch (Exception e) { + } (*@\textcolor<5->{blue}{catch}@*) ((*@\textcolor<6>{blue}{Exception e}@*)) { log("caught exception"); -} catch (Throwable e) { + } (*@\textcolor<5->{blue}{catch}@*) ((*@\textcolor<6>{blue}{Throwable e}@*)) { log("caught throwable"); + } } - \end{lstlisting} - \end{minipage} - \begin{minipage}{0.49\linewidth} - \begin{lstlisting} + \end{java} + \column{0.5\textwidth} + \begin{java}[firstnumber=10,tabsize=2] void f() throws Exception { - switch(x) { - case A: - log("no error"); - break; - case B: - throw new Exception(); - default: - throw new Throwable(); - } + switch(x) { + case A: + log("no error"); + break; + case B: + (*@\textcolor<2-3>{blue}{throw}@*) (*@\textcolor<3>{blue}{new Exception()}@*); + default: + (*@\textcolor<2-3>{blue}{throw}@*) (*@\textcolor<3>{blue}{new Throwable()}@*); + } } - \end{lstlisting} - \end{minipage} + \end{java} + \end{columns} \end{frame} +% TODO: extend with examples or replace by Exception hierarchy \begin{frame}{Exception handling systems}{Java} - Sources of exceptions: - \begin{itemize} - \item Array creation, array access, division, cast\dots - \item Method calls. - \item Field or method access on \texttt{null} variable. - \item Any instruction at any time. - \end{itemize} - - This should be removed. + \begin{columns} + \column{0.5\textwidth} + \begin{center} + \includegraphics[height=0.85\textheight]{figs/exception-hierarchy} + \end{center} + \column{0.5\textwidth} + \begin{itemize} + \item \textit{Checked} (solid): must be caught (\texttt{try-catch}) or declared (\texttt{f() throws T}). + \item \textit{Unchecked} (dashed). + \end{itemize} + \end{columns} \end{frame} \begin{frame}{Exception handling systems}{Other programming languages} @@ -193,11 +242,11 @@ void f() throws Exception { \begin{tabular}{r | r } \textbf{Language} & $\%$ usage \\ \hline JavaScript & 69.7 \\ \hline - HTML/CSS & 63.1 \\ \hline - SQL & 56.5 \\ \hline + \textcolor<2->{blue}{HTML/CSS} & 63.1 \\ \hline + \textcolor<2->{blue}{SQL} & 56.5 \\ \hline Python & 39.4 \\ \hline Java & 39.2 \\ \hline - \textbf<2->{\textcolor<2->{blue}{Bash/Shell}}/PowerShell & 37.9 \\ \hline + \textcolor<2->{blue}{Bash/Shell}/PowerShell & 37.9 \\ \hline C\# & 31.9 \\ \hline PHP & 25.8 \\ \hline TypeScript & 23.5 \\ \hline @@ -207,47 +256,106 @@ void f() throws Exception { \begin{minipage}{0.39\linewidth} \begin{tabular}{r | r } \textbf{Language} & $\%$ usage \\ \hline - \textbf<3->{\textcolor<3->{blue}{C}} & 17.3 \\ \hline + \textcolor<2->{blue}{C} & 17.3 \\ \hline Ruby & 8.9 \\ \hline - \textbf<4->{\textcolor<4->{blue}{Go}} & 8.8 \\ \hline + \textcolor<2->{blue}{Go} & 8.8 \\ \hline Swift & 6.8 \\ \hline Kotlin & 6.6 \\ \hline R & 5.6 \\ \hline - \textbf<5->{\textcolor<5->{blue}{VBA}} & 5.5 \\ \hline + \textcolor<2->{blue}{VBA} & 5.5 \\ \hline Objective-C & 5.2 \\ \hline - \textbf<6->{\textcolor<6->{blue}{Assembly}} & 5.0 \\ \hline + \textcolor<2->{blue}{Assembly} & 5.0 \\ \hline \end{tabular} \end{minipage} % The caption has a weird structure due to the fact that there's a footnote % inside of it. - \caption[Commonly used programming languages]{The most commonly used - programming languages by professional developers (Data from StackOverflow's 2019 Developer Survey)} + \caption[Commonly used programming languages]{Programming language by usage in the software industry (StackOverflow's 2019 Developer Survey)} \label{tab:popular-languages} \end{table} \end{frame} -\begin{frame}{Program slicing}{The system dependence graph} - \begin{enumerate} - \item Código a un lado - \item Aparecen nodos que corresponden a statements - \item Aparecen arcos (control y data o por pasos). - \item Añadir in-out - \item No añadir la llamada - \end{enumerate} +\subsection{The System Dependence Graph} + +\begin{frame}[fragile]{The System Dependence Graph}{Creation} +% \item Código a un lado +% \item Aparecen nodos que corresponden a statements +% \item Aparecen arcos (control y data o por pasos). +% \item Añadir in-out +% \item No añadir la llamada +\begin{columns} + \column{0.20\textwidth} + \begin{java}[basicstyle=\scriptsize\ttfamily,numberstyle=\tiny] +void f(int x) { + int sum = 0; + int prod = 0; + while (x>0) { + sum += sum; + prod*=prod; + x--; + } + log(sum); + log(prod); +} + \end{java} + \column{0.8\textwidth} \centering - \includegraphics[width=0.9\linewidth]{figs/parameter-passing} + \includegraphics<1>[width=1.1\linewidth]{figs/example-sdg-1} + \includegraphics<2>[width=1.1\linewidth]{figs/example-sdg-2} + \includegraphics<3>[width=1.1\linewidth]{figs/example-sdg-3} + \includegraphics<4>[width=1.1\linewidth]{figs/example-sdg-4} + \includegraphics<5>[width=1.1\linewidth]{figs/example-sdg-5} + \includegraphics<6>[width=1.1\linewidth]{figs/example-sdg-6} +\end{columns} \end{frame} -\begin{frame}{Program slicing}{Slicing the SDG} - \centering - \includegraphics[width=0.9\linewidth]{figs/parameter-passing} +\begin{frame}[fragile]{The System Dependence Graph}{Traversal} + \begin{columns} + \column{0.20\textwidth} + \definecolor{light-gray}{gray}{0.8} + \begin{java}[basicstyle=\scriptsize\ttfamily\color<2->{light-gray},numberstyle=\tiny\color{black}] +(*@\textcolor<4->{black}{void f(}@*)(*@\textcolor<8->{black}{int x}@*)(*@\textcolor<4->{black}{) \{}@*) + int sum = 0; + (*@\textcolor<4->{black}{int prod = 0;}@*) + (*@\textcolor<6->{black}{while (x>0) \{}@*) + sum += sum; + (*@\textcolor<4->{black}{prod*=prod;}@*) + (*@\textcolor<8->{black}{x--;}@*) + (*@\textcolor<6->{black}{\}}@*) + log(sum); + (*@\textcolor<2->{black}{log(prod);}@*) +(*@\textcolor<4->{black}{\}}@*) + \end{java} +% (*@\only<-11>{int sum = 0;}@*) +% (*@\textcolor<4-10>{blue}{int prod = 0;}@*) +% (*@\textcolor<6-10>{blue}{while (x>0) \{}@*) +% (*@\only<-11>sum += sum;}@*) +% (*@\textcolor<4-10>{blue}{prod*=prod;}@*) +% (*@\textcolor<8-10>{blue}{x--;}@*) +% (*@\textcolor<6-10>{blue}{\}}@*) +% (*@\only<-11>{log(sum);}@*) +% (*@\textcolor<2-10>{blue}{log(prod);}@*) +% } +% \end{java} + \column{0.8\textwidth} + \centering + \includegraphics<1>[width=1.1\linewidth]{figs/example-sdg} % original graph + \includegraphics<2>[width=1.1\linewidth]{figs/example-slice-1} % SC marked + \includegraphics<3>[width=1.1\linewidth]{figs/example-slice-2} % edges + \includegraphics<4>[width=1.1\linewidth]{figs/example-slice-3} % add 1, 3, 6 + \includegraphics<5>[width=1.1\linewidth]{figs/example-slice-4} % edges + \includegraphics<6>[width=1.1\linewidth]{figs/example-slice-5} % add 4 + \includegraphics<7>[width=1.1\linewidth]{figs/example-slice-6} % edges + \includegraphics<8>[width=1.1\linewidth]{figs/example-slice-7} % add 7, x + \includegraphics<9>[width=1.1\linewidth]{figs/example-slice-8} % edges + \includegraphics<10->[width=1.1\linewidth]{figs/example-slice} % final slice + \end{columns} \end{frame} \section{Problems and proposals} \subsection{Problem 1: incorrect slices with nested unconditional jumps} % TODO añadir nombres a los problemas -\begin{frame}[containsverbatim]{Problem 1}{The subsumption correctness error} +\begin{frame}[fragile]{Problem 1}{The subsumption correctness error} \begin{minipage}{0.39\linewidth} \begin{lstlisting} public void f() { @@ -277,7 +385,7 @@ public void f() { \subsection{Problem 2: incorrect weak slices} -\begin{frame}[containsverbatim]{Problem 2}{Unnecessary instructions in weak slicing} +\begin{frame}[fragile]{Problem 2}{Unnecessary instructions in weak slicing} \begin{minipage}{0.33\linewidth} \begin{lstlisting} void g() { @@ -309,7 +417,7 @@ void g() { \subsection{Problem 3: incomplete \texttt{catch} treatment} -\begin{frame}[containsverbatim]{Problem 3}{The lack of dependencies of \texttt{catch} statements} +\begin{frame}[fragile]{Problem 3}{The lack of dependencies of \texttt{catch} statements} \begin{minipage}{0.29\linewidth} \begin{lstlisting} void main() throws Exception { @@ -387,4 +495,9 @@ void main() throws Exception { Slide with definitions + examples (code and table w/ sequences). \end{frame} +\begin{frame} + \frametitle{Bibliography} + \printbibliography +\end{frame} + \end{document} \ No newline at end of file