Final version

This commit is contained in:
Carlos Galindo 2019-12-19 13:03:04 +01:00
parent e888551e89
commit 201ee44277
25 changed files with 1058 additions and 285 deletions

2
.gitignore vendored
View file

@ -14,4 +14,4 @@
*.bib *.bib
*.vrb *.vrb
figs/*.pdf figs/*.pdf
beamer.pdf slides.pdf

1
beamertheme-bjeldbak Submodule

@ -0,0 +1 @@
Subproject commit e2cea55a3837e29f92324b2f18d98482474b99e1

24
figs/problem1-sliced.dot Normal file
View file

@ -0,0 +1,24 @@
digraph pdf {
entry [label="enter f()",style=filled];
entry -> {while; D};
while [label="while (X)",style=filled];
C [style="bold,filled"]
"if (Y)" [style=filled]
"if (Z)" [style=filled]
while -> {"if (Y)"} -> while;
break2 [style=filled]
break1 [style=filled]
"if (Y)" -> {"if (Z)" C};
"if (Y)" -> break2 [constraint = false];
"if (Z)" -> {A break1 B break2};
break1 -> B;
break1 -> break2;
break2 -> {C while};
{rank=same; A break1 B break2}
{rank=same; "if (Z)" C}
{rank=same; while D}
{edge [style=invis];
A -> break1 -> B -> break2;
}
}

View file

@ -0,0 +1,25 @@
digraph pdf {
entry [label="enter f()", style = filled];
entry -> while [style = bold];
entry -> D [color = grey];
while [label="while (X)", style = filled];
C [style="bold,filled"]
"if (Y)" [style = filled];
"if (Z)"
while -> {"if (Y)"} -> while [style = bold];
break2 [style = filled];
break1
"if (Y)" -> {"if (Z)"} [color = grey];
"if (Y)" -> C [style = bold];
"if (Y)" -> break2 [constraint = false, style = bold];
"if (Z)" -> {A break1 B} [color = grey];
{break1 "if (Z)"} -> break2 [color = lightgrey, style = dashed];
break1 -> B [color = grey];
break2 -> {C while} [style = bold];
{rank=same; A break1 B break2}
{rank=same; "if (Z)" C}
{rank=same; while D}
{edge [style=invis];
A -> break1 -> B -> break2;
}
}

View file

@ -0,0 +1,23 @@
digraph pdf {
entry [label="enter f()"];
entry -> {while; D};
while [label="while (X)"];
C [style="bold"]
"if (Y)"
"if (Z)"
while -> {"if (Y)"} -> while;
break2
break1
"if (Y)" -> {"if (Z)" C};
"if (Y)" -> break2 [constraint = false];
"if (Z)" -> {A break1 B};
{break1 "if (Z)"} -> break2 [color = lightgrey, style = dashed];
break1 -> B;
break2 -> {C while};
{rank=same; A break1 B break2}
{rank=same; "if (Z)" C}
{rank=same; while D}
{edge [style=invis];
A -> break1 -> B -> break2;
}
}

View file

@ -1,15 +1,16 @@
digraph pdf { digraph pdf {
entry [label="enter f()",style=filled]; entry [label="enter f()"];
entry -> {while; D}; entry -> {while; D};
while [label="while (X)",style=filled]; while [label="while (X)"];
C [style="bold,filled"] C [style="bold"]
"if (Y)" [style=filled] "if (Y)"
"if (Z)" [style=filled] "if (Z)"
while -> {"if (Y)" C}; while -> "if (Y)" -> while;
break2 [style=filled] break2
break1 [style=filled] break1
"if (Y)" -> {"if (Z)"}; "if (Y)" -> {"if (Z)" C};
"if (Z)" -> {A break1}; "if (Y)" -> break2 [constraint = false];
"if (Z)" -> {A break1 B break2};
break1 -> B; break1 -> B;
break1 -> break2; break1 -> break2;
break2 -> {C while}; break2 -> {C while};

30
figs/problem2-sol1.dot Normal file
View file

@ -0,0 +1,30 @@
digraph g {
"f()" [shape=box, rank=min]; // , style = filled];
// Rank adjustment
{ node []; // [style=filled]
{ rank = same; "int a = 1"; "while (a > 0)"; }
"if (a > 10)"; break;
}
{ rank = same; "log(a)"; "a++"; }
{ rank = max; "a++"; "log(a)"; }
"a++" [style="bold"];
// Control flow
"f()" -> "while (a > 0)";
"f()" -> "int a = 1";
"while (a > 0)" -> "if (a > 10)";
"if (a > 10)" -> "break";
"break" -> "log(a)";
"break" -> "a++";
"break" -> "while (a > 0)";
// Data flow
{ edge [color = red];
"int a = 1" -> "while (a > 0)";
"int a = 1" -> "if (a > 10)";
"int a = 1" -> "log(a)";
"int a = 1" -> "a++";
"a++" -> "a++";
"a++" -> "while (a > 0)";
"a++" -> "if (a > 10)";
"a++" -> "log(a)" [constraint = true];
}
}

29
figs/problem2-sol2.dot Normal file
View file

@ -0,0 +1,29 @@
digraph g {
"f()" [shape=box, rank=min]; // , style = filled];
// Rank adjustment
{ node []; // [style=filled]
{ rank = same; "int a = 1"; "while (a > 0)"; }
"if (a > 10)";
break [style = invis];
}
{ rank = same; "log(a)"; "a++"; }
{ rank = max; "a++"; "log(a)"; }
"a++" [style="bold"];
// Control flow
"f()" -> "while (a > 0)";
"f()" -> "int a = 1";
"while (a > 0)" -> "if (a > 10)";
"if (a > 10)" -> "break";
break -> {"log(a)" "a++" "while (a > 0)"} [color = grey]
// Data flow
{ edge [color = red];
"int a = 1" -> "while (a > 0)";
"int a = 1" -> "if (a > 10)";
"int a = 1" -> "log(a)";
"int a = 1" -> "a++";
"a++" -> "a++";
"a++" -> "while (a > 0)";
"a++" -> "if (a > 10)";
"a++" -> "log(a)" [constraint = true];
}
}

29
figs/problem2-sol3.dot Normal file
View file

@ -0,0 +1,29 @@
digraph g {
"f()" [shape=box, rank=min, style = filled];
// Rank adjustment
{ node []; // [style=filled]
{ rank = same; "int a = 1" [style = filled]; "while (a > 0)"; }
"if (a > 10)";
break [style = invis];
}
{ rank = same; "log(a)"; "a++"; }
{ rank = max; "a++"; "log(a)"; }
"a++" [style="bold,filled"];
// Control flow
"f()" -> "while (a > 0)";
"f()" -> "int a = 1";
"while (a > 0)" -> "if (a > 10)";
"if (a > 10)" -> "break";
break -> {"log(a)" "a++" "while (a > 0)"} [color = grey]
// Data flow
{ edge [color = red];
"int a = 1" -> "while (a > 0)";
"int a = 1" -> "if (a > 10)";
"int a = 1" -> "log(a)";
"int a = 1" -> "a++";
"a++" -> "a++";
"a++" -> "while (a > 0)";
"a++" -> "if (a > 10)";
"a++" -> "log(a)" [constraint = true];
}
}

29
figs/problem2-sol4.dot Normal file
View file

@ -0,0 +1,29 @@
digraph g {
"f()" [shape=box, rank=min, style = filled];
// Rank adjustment
{ node []; // [style=filled]
{ rank = same; "int a = 1" [style = filled]; "while (a > 0)"; }
"if (a > 10)";
break;
}
{ rank = same; "log(a)"; "a++"; }
{ rank = max; "a++"; "log(a)"; }
"a++" [style="bold,filled"];
// Control flow
"f()" -> "while (a > 0)";
"f()" -> "int a = 1";
"while (a > 0)" -> "if (a > 10)";
"if (a > 10)" -> "break";
break -> {"log(a)" "a++" "while (a > 0)"}
// Data flow
{ edge [color = red];
"int a = 1" -> "while (a > 0)";
"int a = 1" -> "if (a > 10)";
"int a = 1" -> "log(a)";
"int a = 1" -> "a++";
"a++" -> "a++";
"a++" -> "while (a > 0)";
"a++" -> "if (a > 10)";
"a++" -> "log(a)" [constraint = true];
}
}

View file

@ -5,25 +5,26 @@ digraph g {
{ rank = same; "int a = 1"; "while (a > 0)"; } { rank = same; "int a = 1"; "while (a > 0)"; }
"if (a > 10)"; break; "if (a > 10)"; break;
} }
{ rank = same; "print(a)"; "a++"; } { rank = same; "log(a)"; "a++"; }
{ rank = max; "a++"; "print(a)"; } { rank = max; "a++"; "log(a)"; }
"a++" [style="filled,bold"]; "a++" [style="filled,bold"];
// Control flow // Control flow
"f()" -> "while (a > 0)"; "f()" -> "while (a > 0)";
"f()" -> "int a = 1"; "f()" -> "int a = 1";
"while (a > 0)" -> "if (a > 10)"; "while (a > 0)" -> "if (a > 10)";
"if (a > 10)" -> "break"; "if (a > 10)" -> "break";
"break" -> "print(a)"; "break" -> "log(a)";
"break" -> "a++"; "break" -> "a++";
"break" -> "while (a > 0)"; "break" -> "while (a > 0)";
// Data flow // Data flow
{ edge [color = red]; { edge [color = red];
"int a = 1" -> "while (a > 0)"; "int a = 1" -> "while (a > 0)";
"int a = 1" -> "if (a > 10)"; "int a = 1" -> "if (a > 10)";
"int a = 1" -> "print(a)"; "int a = 1" -> "log(a)";
"int a = 1" -> "a++";
"a++" -> "a++"; "a++" -> "a++";
"a++" -> "while (a > 0)"; "a++" -> "while (a > 0)";
"a++" -> "if (a > 10)"; "a++" -> "if (a > 10)";
"a++" -> "print(a)" [constraint = true]; "a++" -> "log(a)" [constraint = true];
} }
} }

View file

@ -0,0 +1,40 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", ];
f [label = "f()", ];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = filled, fillcolor = lightgreen];
x_in2 [label = "x_in = x", ];
f2 [label = "f()", ];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {x_0 f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
x_0 -> x_in2;
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

40
figs/problem3-color.dot Normal file
View file

@ -0,0 +1,40 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", ];
f [label = "f()", ];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", fillcolor = lightgreen, style = filled];
x_in2 [label = "x_in = x", fillcolor = lightgreen, style = filled];
f2 [label = "f()", fillcolor = lightgreen, style = filled];
nr2 [label = "normal return", fillcolor = lightgreen, style = filled];
er2 [label = "error return", fillcolor = lightgreen, style = filled];
ee [label = "error exit", fillcolor = lightgreen, style = filled];
x_out_nr2 [label = "x = x_out", fillcolor = lightgreen, style = filled];
x_out_ee [label = "x = x_out", fillcolor = lightgreen, style = filled];
enter -> {mxin try};
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {x_0 f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
x_0 -> x_in2;
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,42 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", style = filled, fillcolor = lightgreen];
f [label = "f()", style = filled, fillcolor = lightgreen];
nr [label = "normal return", style = filled, fillcolor = lightgreen];
x_out_nr [label = "x = x_out", style = filled, fillcolor = lightgreen];
er [label = "error return", style = filled, fillcolor = lightgreen];
catch [label = "catch (Exception e)", style = filled, fillcolor = pink];
x_out_catch [label = "x = x_out", style = filled, fillcolor = lightgreen];
log [label = "log(\"error\")", style = filled, fillcolor = pink];
x_0 [label = "x = 0", style = invis];
x_in2 [label = "x_in = x", ];
f2 [label = "f()", ];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
enter -> x_0 [style = invis];
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
{x_out_catch x_out_nr} -> x_in2;
x_0 -> x_in2 [style = invis];
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,42 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", style = filled, fillcolor = lightgreen];
f [label = "f()", style = filled, fillcolor = lightgreen];
nr [label = "normal return", style = filled, fillcolor = lightgreen];
x_out_nr [label = "x = x_out", style = filled, fillcolor = lightgreen];
er [label = "error return", style = filled, fillcolor = lightgreen];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out", style = filled, fillcolor = lightgreen];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = invis];
x_in2 [label = "x_in = x", ];
f2 [label = "f()", ];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
enter -> x_0 [style = invis];
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
{x_out_catch x_out_nr} -> x_in2;
x_0 -> x_in2 [style = invis];
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,42 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", ];
f [label = "f()", ];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = invis];
x_in2 [label = "x_in = x", style = filled, fillcolor = lightgreen];
f2 [label = "f()", style = filled, fillcolor = lightgreen];
nr2 [label = "normal return", style = filled, fillcolor = lightgreen];
er2 [label = "error return", style = filled, fillcolor = lightgreen];
ee [label = "error exit", style = filled, fillcolor = pink];
x_out_nr2 [label = "x = x_out", style = filled, fillcolor = lightgreen];
x_out_ee [label = "x = x_out", style = filled, fillcolor = lightgreen];
enter -> {mxin try};
enter -> x_0 [style = invis];
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
{x_out_catch x_out_nr} -> x_in2;
x_0 -> x_in2 [style = invis];
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,42 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", ];
f [label = "f()", ];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = invis];
x_in2 [label = "x_in = x", style = filled, fillcolor = lightgreen];
f2 [label = "f()", style = filled, fillcolor = lightgreen];
nr2 [label = "normal return", style = filled, fillcolor = lightgreen];
er2 [label = "error return", style = filled, fillcolor = lightgreen];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out", style = filled, fillcolor = lightgreen];
x_out_ee [label = "x = x_out", style = filled, fillcolor = lightgreen];
enter -> {mxin try};
enter -> x_0 [style = invis];
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
{x_out_catch x_out_nr} -> x_in2;
x_0 -> x_in2 [style = invis];
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,42 @@
digraph g {
enter [style = filled];
mxin [label = "x = x_in", style = filled];
try [style = filled];
x_in [label = "x_in = x", style = filled];
f [label = "f()", style = filled];
nr [label = "normal return", style = filled];
x_out_nr [label = "x = x_out", style = filled];
er [label = "error return", style = filled];
catch [label = "catch (Exception e)", style = filled];
x_out_catch [label = "x = x_out", style = filled];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = invis];
x_in2 [label = "x_in = x", style = filled];
f2 [label = "f()", style = filled];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
enter -> x_0 [style = invis];
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
{x_out_catch x_out_nr} -> x_in2;
x_0 -> x_in2 [style = invis]
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,42 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", ];
f [label = "f()", ];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = invis];
x_in2 [label = "x_in = x", ];
f2 [label = "f()", ];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
enter -> x_0 [style = invis];
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
{x_out_catch x_out_nr} -> x_in2;
x_0 -> x_in2 [style = invis];
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

40
figs/problem3-sliced.dot Normal file
View file

@ -0,0 +1,40 @@
digraph g {
enter [style = filled];
mxin [label = "x = x_in", style = filled];
try [style = filled];
x_in [label = "x_in = x", style = filled];
f [label = "f()", style = filled];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = filled];
x_in2 [label = "x_in = x", style = filled];
f2 [label = "f()", style = filled];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {x_0 f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
x_0 -> x_in2;
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,40 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", ];
f [label = "f()", ];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", fillcolor = lightgreen, style = filled];
x_in2 [label = "x_in = x", fillcolor = lightgreen, style = filled];
f2 [label = "f()", fillcolor = lightgreen, style = filled];
nr2 [label = "normal return", fillcolor = lightgreen, style = filled];
er2 [label = "error return", fillcolor = lightgreen, style = filled];
ee [label = "error exit", fillcolor = lightgreen, style = filled];
x_out_nr2 [label = "x = x_out", fillcolor = lightgreen, style = filled];
x_out_ee [label = "x = x_out", fillcolor = lightgreen, style = filled];
enter -> {mxin try};
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
{catch} -> {x_0 f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
x_0 -> x_in2;
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -0,0 +1,40 @@
digraph g {
enter [style = filled];
mxin [label = "x = x_in", style = filled];
try [style = filled];
x_in [label = "x_in = x", style = filled];
f [label = "f()", style = filled];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return", style = filled];
catch [label = "catch (Exception e)", style = filled];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = filled];
x_in2 [label = "x_in = x", style = filled];
f2 [label = "f()", style = filled];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
{catch} -> {x_0 f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
x_0 -> x_in2;
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

40
figs/problem3-sol.dot Normal file
View file

@ -0,0 +1,40 @@
digraph g {
enter [];
mxin [label = "x = x_in", ];
try [];
x_in [label = "x_in = x", ];
f [label = "f()", ];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0"];
x_in2 [label = "x_in = x"];
f2 [label = "f()"];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
{catch} -> {x_0 f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
x_0 -> x_in2;
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

View file

@ -1,18 +1,18 @@
digraph g { digraph g {
enter [style = filled]; enter [];
mxin [label = "x = x_in", style = filled]; mxin [label = "x = x_in", ];
try [style = filled]; try [];
x_in [label = "x_in = x", style = filled]; x_in [label = "x_in = x", ];
f [label = "f()", style = filled]; f [label = "f()", ];
nr [label = "normal return"]; nr [label = "normal return"];
x_out_nr [label = "x = x_out"]; x_out_nr [label = "x = x_out"];
er [label = "error return"]; er [label = "error return"];
catch [label = "catch (Exception e)"]; catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"]; x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"]; log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = filled]; x_0 [label = "x = 0", ];
x_in2 [label = "x_in = x", style = filled]; x_in2 [label = "x_in = x", ];
f2 [label = "f()", style = filled]; f2 [label = "f()", ];
nr2 [label = "normal return"]; nr2 [label = "normal return"];
er2 [label = "error return"]; er2 [label = "error return"];
ee [label = "error exit"]; ee [label = "error exit"];

View file

@ -3,6 +3,8 @@
\documentclass[aspectratio=169,compress]{beamer} \documentclass[aspectratio=169,compress]{beamer}
% TODO: Titles Must Be Titlecase.
% Basic packages % Basic packages
\usepackage{pgfpages} \usepackage{pgfpages}
\usepackage{listings} \usepackage{listings}
@ -12,6 +14,14 @@
\usepackage{xcolor} \usepackage{xcolor}
\usepackage{soul} \usepackage{soul}
% Color definitions
\definecolor{criterion}{rgb}{1,0,0}
\definecolor{light-gray}{gray}{0.8}
\definecolor{color1}{rgb}{1,0.5,0}
\definecolor{color2}{rgb}{0.9,0.2,0}
\definecolor{hasExcClr}{rgb}{0,0.5,0}
\definecolor{lightgreen}{RGB}{144,238,144}
% Bibliography settings % Bibliography settings
\usepackage[backend=bibtex,style=alphabetic,citestyle=alphabetic-verb]{biblatex} \usepackage[backend=bibtex,style=alphabetic,citestyle=alphabetic-verb]{biblatex}
\bibliography{biblio.bib} \bibliography{biblio.bib}
@ -38,9 +48,8 @@
} }
% Escapable listing environment % Escapable listing environment
\lstnewenvironment{java}[1][] \lstnewenvironment{java}[1][]{
{\lstset{ \lstset{language=[LaTeX]TeX}\lstset{escapeinside={(*@}{@*)},
language=[LaTeX]TeX}\lstset{escapeinside={(*@}{@*)},
numbers=left, numbers=left,
numberstyle=\tiny, numberstyle=\tiny,
stepnumber=1, stepnumber=1,
@ -68,17 +77,7 @@
\maketitle \maketitle
\begin{frame} \begin{frame}{Table of Contents}
\frametitle{TODO}
\begin{itemize}
\item Proposal no, solution o proposed solution.
\item \ul{test}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents \tableofcontents
\end{frame} \end{frame}
@ -87,11 +86,10 @@
\subsection{Program slicing} \subsection{Program slicing}
\begin{frame}[fragile]{Program slicing} \begin{frame}[fragile]{Program slicing}
\begin{columns} \begin{columns}
\column{0.5\textwidth} \column{0.5\textwidth}
\begin{java} \begin{java}[gobble=16]
void f(int x) { void f(int x) {
int sum = 0; int sum = 0;
int prod = 0; int prod = 0;
while (x > 0) { while (x > 0) {
@ -100,29 +98,30 @@ void f(int x) {
x--; x--;
} }
log("sum: " + sum); log("sum: " + sum);
log("prod: " + (*@\textcolor<2->{blue}{prod}@*)); log("prod: " + (*@\textcolor<2->{criterion}{prod}@*));
} }
\end{java} \end{java}
\column<3->{0.5\textwidth} \column<3->{0.5\textwidth}
\begin{java} \begin{java}[gobble=16]
void f(int x) { void f(int x) {
(*@\invisible<4->{int sum = 0;}@*) (*@\textcolor<4->{light-gray}{int sum = 0;}@*)
int prod = 0; int prod = 0;
while (x > 0) { while (x > 0) {
(*@\invisible<4->{sum += x;}@*) (*@\textcolor<4->{light-gray}{sum += x;}@*)
prod *= x; prod *= x;
x--; x--;
} }
(*@\invisible<4->{log("sum: " + sum);}@*) (*@\textcolor<4->{light-gray}{log("sum: " + sum);}@*)
log("prod: " + prod); log("prod: " + prod);
} }
\end{java} \end{java}
\end{columns} \end{columns}
{\hfill Example adapted from \cite{Tip95}.} {\hfill Example adapted from \cite{Tip95}.}
\end{frame} \end{frame}
% TODO: posible addition of examples on the right side. \begin{frame}[containsverbatim]{Program slicing}{Applications}
\begin{frame}{Program slicing}{Applications} \begin{columns}
\column{0.5\linewidth}
\begin{itemize} \begin{itemize}
\item Debugging \item Debugging
\item Program specialization \item Program specialization
@ -131,14 +130,28 @@ void f(int x) {
\item Dead code removal \item Dead code removal
\item Program parallelization \item Program parallelization
\end{itemize} \end{itemize}
\column{0.5\linewidth}
\begin{java}[gobble=12]
void f(int x) {
(*@\textcolor{light-gray}{int sum = 0;}@*)
int prod = 0;
while (x > 0) {
(*@\textcolor{light-gray}{sum += x;}@*)
prod *= x;
x--;
}
(*@\textcolor{light-gray}{log("sum: " + sum);}@*)
log("prod: " + prod);
}
\end{java}
\end{columns}
% Clone detection (examenes, copyright)
\end{frame} \end{frame}
% TODO: remove one of the notations in the examples.
% TODO: maybe use example 'block'?
\begin{frame}{Program slicing}{Metrics} \begin{frame}{Program slicing}{Metrics}
\begin{description} \begin{description}
\item[\textbf{Completeness.}] The slice includes all instructions that are necessary. \item[\textbf{Completeness.}] The slice includes all instructions that are necessary.
\item[\textbf{Correctness.}] The slice excludes all instructions that are not necessary. \item[\textbf{Correctness.}] The statements included affect the slicing criterion.
\end{description} \end{description}
\vfill \vfill
@ -155,8 +168,6 @@ void f(int x) {
\draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); \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);} \visible<3->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (0, 0) circle (2em);}
\end{tikzpicture} \end{tikzpicture}
$$c_m \wedge c_r$$
% \includegraphics[width=\textwidth]{}
\column{0.25\textwidth} \column{0.25\textwidth}
Correct and incomplete: \\ Correct and incomplete: \\
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45] \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
@ -164,7 +175,6 @@ void f(int x) {
\draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); \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);} \visible<4->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (0, 0) circle (1.5em);}
\end{tikzpicture} \end{tikzpicture}
$$\neg c_m \wedge c_r$$
% \includegraphics[width=\textwidth]{} % \includegraphics[width=\textwidth]{}
\column{0.25\textwidth} \column{0.25\textwidth}
Incorrect and complete: \\ Incorrect and complete: \\
@ -173,7 +183,6 @@ void f(int x) {
\draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); \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);} \visible<5->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (0, 0) circle (2.5em);}
\end{tikzpicture} \end{tikzpicture}
$$c_m \wedge \neg c_r$$
% \includegraphics[width=\textwidth]{} % \includegraphics[width=\textwidth]{}
\column{0.25\textwidth} \column{0.25\textwidth}
Incorrect and incomplete: \\ Incorrect and incomplete: \\
@ -182,98 +191,10 @@ void f(int x) {
\draw [line width=2pt,color=minimalcolor,fill=minimalcolor,fill opacity=0.4] (0,0) circle (2em); \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);} \visible<6->{\draw [line width=1pt,dotted,color=slicecolor,fill=slicecolor,fill opacity=0.2] (1em, 1em) circle (2em);}
\end{tikzpicture} \end{tikzpicture}
$$\neg c_m \wedge \neg c_r$$
% \includegraphics[width=\textwidth]{} % \includegraphics[width=\textwidth]{}
\end{columns} \end{columns}
\end{frame} \end{frame}
\subsection{Exception handling}
\begin{frame}[fragile]{Exception handling systems}{Java}
\begin{columns}
\column{0.5\textwidth}
\begin{java}[tabsize=2]
void main() {
(*@\textcolor<4->{blue}{try}@*) {
f();
} (*@\textcolor<5->{blue}{catch}@*) ((*@\textcolor<6>{blue}{Exception e}@*)) {
log("caught exception");
} (*@\textcolor<5->{blue}{catch}@*) ((*@\textcolor<6>{blue}{Throwable e}@*)) {
log("caught throwable");
}
}
\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:
(*@\textcolor<2-3>{blue}{throw}@*) (*@\textcolor<3>{blue}{new Exception()}@*);
default:
(*@\textcolor<2-3>{blue}{throw}@*) (*@\textcolor<3>{blue}{new Throwable()}@*);
}
}
\end{java}
\end{columns}
\end{frame}
% TODO: extend with examples or replace by Exception hierarchy
\begin{frame}{Exception handling systems}{Java}
\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}
\begin{table}
\begin{minipage}{0.6\linewidth}
\centering
\begin{tabular}{r | r }
\textbf{Language} & $\%$ usage \\ \hline
JavaScript & 69.7 \\ \hline
\textcolor<2->{blue}{HTML/CSS} & 63.1 \\ \hline
\textcolor<2->{blue}{SQL} & 56.5 \\ \hline
Python & 39.4 \\ \hline
Java & 39.2 \\ \hline
\textcolor<2->{blue}{Bash/Shell}/PowerShell & 37.9 \\ \hline
C\# & 31.9 \\ \hline
PHP & 25.8 \\ \hline
TypeScript & 23.5 \\ \hline
C++ & 20.4 \\ \hline
\end{tabular}
\end{minipage}
\begin{minipage}{0.39\linewidth}
\begin{tabular}{r | r }
\textbf{Language} & $\%$ usage \\ \hline
\textcolor<2->{blue}{C} & 17.3 \\ \hline
Ruby & 8.9 \\ \hline
\textcolor<2->{blue}{Go} & 8.8 \\ \hline
Swift & 6.8 \\ \hline
Kotlin & 6.6 \\ \hline
R & 5.6 \\ \hline
\textcolor<2->{blue}{VBA} & 5.5 \\ \hline
Objective-C & 5.2 \\ \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]{Programming language by usage in the software industry (StackOverflow's 2019 Developer Survey)}
\label{tab:popular-languages}
\end{table}
\end{frame}
\subsection{The System Dependence Graph} \subsection{The System Dependence Graph}
\begin{frame}[fragile]{The System Dependence Graph}{Creation} \begin{frame}[fragile]{The System Dependence Graph}{Creation}
@ -297,23 +218,23 @@ void f(int x) {
log(prod); log(prod);
} }
\end{java} \end{java}
\column{0.8\textwidth} \column{0.8\textwidth}<+->
\centering \centering
\includegraphics<1>[width=1.1\linewidth]{figs/example-sdg-1} % TODO: leyenda de data dependence
\includegraphics<2>[width=1.1\linewidth]{figs/example-sdg-2} \includegraphics<+>[width=1.1\linewidth]{figs/example-sdg-1}
\includegraphics<3>[width=1.1\linewidth]{figs/example-sdg-3} \includegraphics<+>[width=1.1\linewidth]{figs/example-sdg-2}
\includegraphics<4>[width=1.1\linewidth]{figs/example-sdg-4} \includegraphics<+>[width=1.1\linewidth]{figs/example-sdg-3}
\includegraphics<5>[width=1.1\linewidth]{figs/example-sdg-5} \includegraphics<+>[width=1.1\linewidth]{figs/example-sdg-4}
\includegraphics<6>[width=1.1\linewidth]{figs/example-sdg-6} \includegraphics<+>[width=1.1\linewidth]{figs/example-sdg-5}
\includegraphics<+>[width=1.1\linewidth]{figs/example-sdg-6}
\end{columns} \end{columns}
\end{frame} \end{frame}
\begin{frame}[fragile]{The System Dependence Graph}{Traversal} \begin{frame}[fragile]{The System Dependence Graph}{Traversal}
\begin{columns} \begin{columns}
\column{0.20\textwidth} \column{0.20\textwidth}
\definecolor{light-gray}{gray}{0.8} \begin{java}[basicstyle=\scriptsize\ttfamily\color<2->{light-gray},numberstyle=\tiny\color{black},gobble=12]
\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}{) \{}@*)
(*@\textcolor<4->{black}{void f(}@*)(*@\textcolor<8->{black}{int x}@*)(*@\textcolor<4->{black}{) \{}@*)
int sum = 0; int sum = 0;
(*@\textcolor<4->{black}{int prod = 0;}@*) (*@\textcolor<4->{black}{int prod = 0;}@*)
(*@\textcolor<6->{black}{while (x>0) \{}@*) (*@\textcolor<6->{black}{while (x>0) \{}@*)
@ -322,20 +243,9 @@ void f(int x) {
(*@\textcolor<8->{black}{x--;}@*) (*@\textcolor<8->{black}{x--;}@*)
(*@\textcolor<6->{black}{\}}@*) (*@\textcolor<6->{black}{\}}@*)
log(sum); log(sum);
(*@\textcolor<2->{black}{log(prod);}@*) (*@\textcolor<2->{black}{log(\textcolor<1>{criterion}{prod});}@*)
(*@\textcolor<4->{black}{\}}@*) (*@\textcolor<4->{black}{\}}@*)
\end{java} \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} \column{0.8\textwidth}
\centering \centering
\includegraphics<1>[width=1.1\linewidth]{figs/example-sdg} % original graph \includegraphics<1>[width=1.1\linewidth]{figs/example-sdg} % original graph
@ -351,152 +261,331 @@ void f(int x) {
\end{columns} \end{columns}
\end{frame} \end{frame}
\subsection{Exception handling}
\begin{frame}[fragile]{Exception Handling Systems}{Java}
\begin{columns}
\column{0.5\textwidth}
\begin{java}[tabsize=2,gobble=12]
void main() {
(*@\textcolor<5->{color1}{try}@*) {
f();
} (*@\textcolor<5->{color1}{catch}@*) ((*@\textcolor<6>{color1}{Exception e}@*)) {
log("caught exception");
} (*@\textcolor<5->{color1}{catch}@*) ((*@\textcolor<6>{color1}{Throwable e}@*)) {
log("caught throwable");
}
}
\end{java}
\column{0.5\textwidth}
\begin{java}[firstnumber=10,tabsize=2,gobble=12]
void f() (*@\textcolor<4>{color1}{throws Throwable}@*) {
switch(x) {
case A:
log("no error");
break;
case B:
(*@\textcolor<2-4>{color1}{throw}@*) (*@\textcolor<3-4>{color1}{new Exception()}@*);
default:
(*@\textcolor<2-4>{color1}{throw}@*) (*@\textcolor<3-4>{color1}{new Throwable()}@*);
}
}
\end{java}
\end{columns}
\end{frame}
% TODO: possible animation; selecting each named exception and explaining its contents, then splitting into checked/unchecked.
% TODO: título: jerarquía de herencia
\begin{frame}{Exception Handling Systems}{Java}
\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}
% TODO: iluminar las que si en otro color
\begin{frame}{Exception Handling Systems}{Other programming languages}
\begin{table}
\begin{columns}
\column{0.6\linewidth}
\centering
\begin{tabular}{r | r }
\textbf{Language} & $\%$ usage \\ \hline
\textcolor<2->{hasExcClr}{JavaScript} & 69.7 \\ \hline
\textcolor<3->{color2}{HTML/CSS} & 63.1 \\ \hline
\textcolor<3->{color2}{SQL} & 56.5 \\ \hline
\textcolor<2->{hasExcClr}{Python} & 39.4 \\ \hline
\textcolor<2->{hasExcClr}{Java} & 39.2 \\ \hline
\textcolor<3->{color2}{Bash/Shell}/\textcolor<2->{hasExcClr}{PowerShell} & 37.9 \\ \hline
\textcolor<2->{hasExcClr}{C\#} & 31.9 \\ \hline
\textcolor<2->{hasExcClr}{PHP} & 25.8 \\ \hline
\textcolor<2->{hasExcClr}{TypeScript} & 23.5 \\ \hline
\textcolor<2->{hasExcClr}{C++} & 20.4 \\ \hline
\end{tabular}
\column{0.4\linewidth}
\begin{tabular}{r | r }
\textbf{Language} & $\%$ usage \\ \hline
\textcolor<3->{color2}{C} & 17.3 \\ \hline
\textcolor<2->{hasExcClr}{Ruby} & 8.9 \\ \hline
\textcolor<3->{color2}{Go} & 8.8 \\ \hline
\textcolor<2->{hasExcClr}{Swift} & 6.8 \\ \hline
\textcolor<2->{hasExcClr}{Kotlin} & 6.6 \\ \hline
\textcolor<2->{hasExcClr}{R} & 5.6 \\ \hline
\textcolor<3->{color2}{VBA} & 5.5 \\ \hline
\textcolor<2->{hasExcClr}{Objective-C} & 5.2 \\ \hline
\textcolor<3->{color2}{Assembly} & 5.0 \\ \hline
\end{tabular}
\end{columns}
\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}
\section{Problems and proposals} \section{Problems and proposals}
\subsection{Problem 1: incorrect slices with nested unconditional jumps} \subsection{Problem 1: incorrect slices with nested unconditional jumps}
% TODO añadir nombres a los problemas
\begin{frame}[fragile]{Problem 1}{The subsumption correctness error} \begin{frame}[fragile]{Problem 1}{The subsumption correctness error}
\begin{minipage}{0.39\linewidth} \begin{minipage}{0.39\linewidth}
\begin{lstlisting} \begin{java}[gobble=8]
public void f() { public void f() {
while (X) { while (X) {
if (Y) { if (Y) {
if (Z) { (*@\textcolor<4->{light-gray}{if (Z) \{}@*)
A; (*@\textcolor<3->{light-gray}{A;}@*)
(*@\textcolor<4->{light-gray}{break;}@*)
(*@\textcolor<4->{light-gray}{\}}@*)
(*@\textcolor<3->{light-gray}{B;}@*)
break; break;
} }
B; (*@\textcolor<2->{criterion}{C}@*);
break;
} }
C; (*@\textcolor<3->{light-gray}{D;}@*)
} }
D; \end{java}
}
\end{lstlisting}
\end{minipage} \end{minipage}
\begin{minipage}{0.59\linewidth} \begin{minipage}{0.59\linewidth}
\includegraphics[width=0.8\linewidth]{figs/problem1} \includegraphics<2>[width=0.9\linewidth]{figs/problem1}
\includegraphics<3->[width=0.9\linewidth]{figs/problem1-sliced}
\end{minipage} \end{minipage}
\end{frame} \end{frame}
\begin{frame}{Problem 1: proposed solution}{The subsumption correctness error} \begin{frame}{Problem 1: proposed solution}{The subsumption correctness error}
TODO: show graph here, label the edges caused by each jump and then remove some. \begin{columns}
\column{0.5\textwidth}
\begin{enumerate}
\item Identify edges caused by unconditional jumps. \pause
\item Remove from $E_c$ all $(a, b)$ such that $(a', b) \in E_c \wedge a', b \in J \wedge (a', b), (a, b) \in E_{a'}$
\\ $J$: unconditional jumps
\\ $E_c$: control edges
\\ $E_{a'}$: edges caused by $a'$
\end{enumerate}
\column{0.5\textwidth}
\includegraphics<3>[width=0.9\linewidth]{figs/problem1-solution}
\includegraphics<4->[width=0.9\linewidth]{figs/problem1-solution-sliced}
\end{columns}
\end{frame} \end{frame}
\subsection{Problem 2: incorrect weak slices} \subsection{Problem 2: incorrect weak slices}
\begin{frame}[fragile]{Problem 2}{Unnecessary instructions in weak slicing} \begin{frame}[fragile]{Problem 2}{Unnecessary instructions in weak slicing}
\begin{minipage}{0.33\linewidth} \begin{minipage}{0.33\linewidth}
\begin{lstlisting} \begin{java}[gobble=12]
void g() { void g() {
int x = 0; int a = 1;
while (x > 0) { while (a > 0) {
if (x > 10) (*@\textcolor<3->{light-gray}{if (a > 10)}@*)
break; (*@\textcolor<3->{light-gray}{break;}@*)
x++; (*@\textcolor{red}{a}@*)++;
} }
log(x); (*@\textcolor<2->{light-gray}{log(a);}@*)
} }
\end{lstlisting} \end{java}
\end{minipage} \end{minipage}
\begin{minipage}{0.66\linewidth} \begin{minipage}{0.66\textwidth}
\centering \centering
\includegraphics[width=0.6\linewidth]{figs/problem2} \includegraphics<2->[width=0.5\textwidth]{figs/problem2}
\end{minipage} \end{minipage}
\end{frame} \end{frame}
\begin{frame}{Problem 2: proposed solution}{Unnecessary instructions in weak slicing} \begin{frame}{Problem 2: proposed solution}{Unnecessary instructions in weak slicing}
TODO: animate the multi-pass solution. \begin{columns}
\column{0.5\textwidth}
\begin{enumerate} \begin{enumerate}
\item Remove all forward-jumping unconditional jump's nodes. \item Remove all forward-jumping unconditional jump's nodes.
\item Traverse the graph. \pause[3] \item Traverse the graph.
\item Re-add all nodes that fulfil the condition of having something selected after them. \pause \item Re-add all nodes removed if there is any statement in the slice after their destination.
\item Goto 2. \pause \item If (3) changed the graph, goto (2).
\end{enumerate} \end{enumerate}
\column{0.5\textwidth}
\includegraphics<1>[width=0.7\linewidth]{figs/problem2-sol1}
\includegraphics<2>[width=0.7\linewidth]{figs/problem2-sol2}
\includegraphics<3-5>[width=0.7\linewidth]{figs/problem2-sol3}
\includegraphics<6>[width=0.7\linewidth]{figs/problem2-sol4}
\end{columns}
\end{frame} \end{frame}
\subsection{Problem 3: incomplete \texttt{catch} treatment} \subsection{Problem 3: incomplete \texttt{catch} treatment}
\begin{frame}[fragile]{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{columns}
\begin{lstlisting} \column{0.4\textwidth}
void main() throws Exception { \begin{java}[gobble=12,basicstyle=\scriptsize\ttfamily]
int x;
void main() (*@\alt<6>{\fcolorbox{black}{pink}{throws Exception}}{throws Exception}@*) {
try { try {
f(); (*@\alt<3-4>{\fcolorbox{black}{lightgreen}{f()}}{f()}@*);
} catch (Exception e) { } (*@\textcolor<11->{light-gray}{\alt<4>{\fcolorbox{black}{pink}{catch (Exception e)}}{catch (Exception e)} \{}@*)
log("error"); (*@\textcolor<8,11->{light-gray}{log("error");}@*)
(*@\textcolor<11->{light-gray}{\}}@*)
(*@\visible<9->{\alt<9>{\fcolorbox{black}{lightgreen}{x = 0;}}{x = 0;}}@*)
(*@\alt<5-6>{\fcolorbox{black}{lightgreen}{f()}}{f()}@*);
} }
x = 0;
f(); void f() throws Exception {
} x++;
\end{lstlisting} if (x > 0)
\end{minipage} throw new Exception();
\begin{minipage}{0.7\linewidth} log((*@\textcolor{criterion}{x}@*));
\includegraphics[width=\linewidth]{figs/problem3} }
\end{minipage} \end{java}
\column<+->{0.6\textwidth}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-data-edge}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-data-edge-color-f1}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-data-edge-color-f1-error}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-data-edge-color-f2}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-data-edge-color-f2-error}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-data-edge}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-data-edge-sliced}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-color-x0}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3}
\includegraphics<+>[width=1.1\textwidth]{figs/problem3-sliced}
\end{columns}
\end{frame} \end{frame}
% \begin{frame}[fragile,label=p3]{Problem 3}{The lack of dependencies of \texttt{catch} statements}
% \begin{columns}
% \column{0.4\textwidth}
% \begin{java}[gobble=12,basicstyle=\scriptsize\ttfamily]
% void main() throws Exception {
% try {
% f();
% } (*@\textcolor<2->{light-gray}{catch (Exception e) \{}@*)
% (*@\textcolor<2->{light-gray}{log("error");}@*)
% (*@\textcolor<2->{light-gray}{\}}@*)
% x = 0;
% f();
% }
% void f() throws Exception {
% x++;
% if (x < 0)
% throw new Exception();
% log((*@\textcolor{criterion}{x}@*));
% }
% \end{java}
% % TODO: highlight each section of the graph.
% \column{0.6\textwidth}
% \includegraphics<1>[height=0.9\textheight]{figs/problem3}
% \includegraphics<2>[height=0.9\textheight]{figs/problem3-sliced}
% \end{columns}
% \end{frame}
% % TODO: reorder, good approach, error, solution
% \begin{frame}{Problem 3}{The lack of dependencies of \texttt{catch} statements}
% \centering
% \includegraphics<+>[height=0.9\textheight]{figs/problem3}
% \includegraphics<+>[height=0.9\textheight]{figs/problem3-data-edge}
% \includegraphics<+>[height=0.9\textheight]{figs/problem3-data-edge-sliced}
% \end{frame}
% \againframe<1>{p3}
\begin{frame}{Problem 3: proposed solution}{The lack of dependencies of \texttt{catch} statements} \begin{frame}{Problem 3: proposed solution}{The lack of dependencies of \texttt{catch} statements}
TODO: animate the conversion to the new dependencies and a slice. \centering
\begin{enumerate} \includegraphics<+>[height=0.9\textheight]{figs/problem3}
\item Organize \texttt{catch} statements in a tree. \includegraphics<+>[height=0.9\textheight]{figs/problem3-color}
\item Add a path to the exit on the root. \includegraphics<+>[height=0.9\textheight]{figs/problem3-sol-color}
\item Maybe reference parallelism with the treatment of unconditional statements. \includegraphics<+>[height=0.9\textheight]{figs/problem3-sol}
\end{enumerate} \includegraphics<+>[height=0.9\textheight]{figs/problem3-sol-sliced}
\end{frame} \end{frame}
\section{Conclusions} \section{Conclusions}
\begin{frame}{Conclusions} \begin{frame}{Conclusions}
\begin{itemize} \begin{itemize}
\item Program slicing: a powerful technique, not yet complete for commonly used programming languages. \item<+-> Program slicing: a powerful technique, not yet complete for commonly used programming languages.
\item Any proposal exchanges efficiency for completeness/correctness. \item Efficiency vs. completeness and correctness.
\item Complete is required, correct is nice. \item<+-> Results: 3 problems and proposed solutions.
\item Unconditional jumps are complete: let's correct them. % \begin{itemize}
\item Results % \item
\begin{itemize} % \item Problem 1: submitted to LCTES 2020 (ACM SIGPLAN Languages, Compilers and Tools for Embedded Systems).
\item 3 problems and proposed solutions. % \end{itemize}
\item NOMBRE PAPER, submitted to BLA BLA.
\item OTHER WORK, to be submitted to BLA BLA.
\end{itemize}
\end{itemize} \end{itemize}
\end{frame} \end{frame}
\begin{frame}{Future work} \begin{frame}{Future work}
\begin{itemize} \begin{itemize}
% \item Publish Problem 2 and Problem 3.
\item Improve correctness of \texttt{try-catch}. \item Improve correctness of \texttt{try-catch}.
\item Implement into existing software tools, benchmark against state of the art. \item Implement into existing software tools, benchmark against state of the art.
\item Adapt to other variants of program slicing. \item Adapt to other variants of program slicing.
\item Redefine control dependence: Danicic TODO (nº cita) tried, \textit{execution dependence} vs. \textit{presence dependence}. \item Redefine control dependence (extend Danicic's work \cite{DanBHHKL11}), \textit{execution dependence} vs. \textit{presence dependence}.
\end{itemize} \end{itemize}
\end{frame} \end{frame}
\begin{frame}{The End}
\end{frame}
\appendix \appendix
% \section*{Extra slides} % \section*{Extra slides}
\begin{frame}[noframenumbering]{Related work} \begin{frame}[noframenumbering]{Related work}
Change to state of the art and move to introduction Change to state of the art and move to introduction
\begin{itemize} \begin{itemize}
\item SinH98 and SinH99 introduce the field slicing + exceptions \item 1988: Horwitz, Reps and Ball \cite{HorwitzRB88} present the SDG.
\item AllH03 improves the existing techniques \item 1993: Ball and Horwitz \cite{BalH93} present SDG with unconditional jumps
\item HorwitzRB88 introduces the current handling of unconditional jumps \item 1998: Sinha and Harrold \cite{SinH98,SinHR99} present SDG with exceptions.
\item JoC04 presents an alternative way to compute the CFG, but does not demonstrate the effects for program slicing. \item 2003: Allen and Horwitz \cite{AllH03} improves \cite{SinH98}.
\item JiaZSJ06 propose a solution in C++, ... TODO \pause
\item PraMB11 also work in C++, no notable improvement TODO \item 2004: Jo and Chang \cite{JoC04} present an alternative construction of the graph (not demonstrated, not an improvement).
\item JieS11 introduces OO + Exception SDG, but treats exceptions similar to Horwitz, leaving the original problems unresolved. \item 2006: Jiang et al. \cite{JiaZSJ06} propose a solution for C++, not applicable.
\item 2011: Prabhy, Maeda and Blakrishnan \cite{PraMB11} propose another solution for C++, no notable improvement.
\item 2011: Jie and Shu-juan \cite{JieS11} introduce Object-Oriented + Exception SDG, same errors as \cite{AllH03}.
\end{itemize} \end{itemize}
\end{frame} \end{frame}
\begin{frame}[noframenumbering]{Program slicing}{Strong and weak slices} \begin{frame}[noframenumbering]{Program slicing}{Strong and Weak Slices}
Slide with definitions + examples (code and table w/ sequences). \begin{definition}[Strong slice \cite{Wei81}]
Given a program $P$, its slice $S$ w.r.t. a slicing criterion $SC$ is a subset of the statements ($S \subseteq P$) such that the execution of $S$ yields the same sequence of values on $SC$ as the execution of $P$.
\end{definition}
\begin{definition}[Weak slice \cite{BinG96}]
Given a program $P$, its slice $S$ w.r.t. a slicing criterion $SC$ is a subset of the statements ($S \subseteq P$) such that the execution of $S$ yields a sequence of values on $SC$ ($\textit{seq}_S$), the execution of $P$ yields a sequence of values on $SC$ ($\textit{seq}_P$), and $\textit{seq}_P$ is a prefix of $\textit{seq}_S$.
\end{definition}
\end{frame} \end{frame}
\begin{frame} \begin{frame}[noframenumbering]{Program Slicing}{Strong and Weak Slices: Example}
\frametitle{Bibliography} \begin{table}
\centering
\label{tab:slice-weak}
\begin{tabular}{r | r | r | r | r | r }
Original program & 1 & 2 & 6 & - & - \\ \hline
Slice A & 1 & 2 & 6 & - & - \\ \hline
Slice B & 1 & 2 & 6 & 24 & 120 \\ \hline
Slice C & 1 & 1 & 1 & 1 & 1 \\
\end{tabular}
\caption{Sequences of values produced on the slicing criterion.}
\end{table}
\end{frame}
\begin{frame}[noframenumbering,allowframebreaks]{Bibliography}
\printbibliography \printbibliography
\end{frame} \end{frame}