1
Rscript: a Relational Approach to Program and System Understanding
Rscript: a Relational Approach to Program and System Understanding - - PowerPoint PPT Presentation
Rscript: a Relational Approach to Program and System Understanding Paul Klint 1 Rscript: a Relational Approach to Program and System Understanding Structure of Presentation Background and context About program understanding Roadmap:
1
Rscript: a Relational Approach to Program and System Understanding
2
Rscript: a Relational Approach to Program and System Understanding
3
Rscript: a Relational Approach to Program and System Understanding
4
Rscript: a Relational Approach to Program and System Understanding
– just-in-time compilation – energy-aware code generation
– interprocedural pointer analysis – slicing
5
Rscript: a Relational Approach to Program and System Understanding
– standard compilation techniques and – the needs for understanding and restructuring
6
Rscript: a Relational Approach to Program and System Understanding
7
Rscript: a Relational Approach to Program and System Understanding
8
Rscript: a Relational Approach to Program and System Understanding
– system artifacts (source, documentation, tests, ...) – implicit knowledge of its designers or maintainers
– Extract elementary facts – Abstract to get derived facts needed for analysis – View derived facts through visualization or browsing
9
Rscript: a Relational Approach to Program and System Understanding
10
Rscript: a Relational Approach to Program and System Understanding
11
Rscript: a Relational Approach to Program and System Understanding
12
Rscript: a Relational Approach to Program and System Understanding
13
Rscript: a Relational Approach to Program and System Understanding
– All based on untyped, binary, relation algebra – Mostly used for architectural, coarse grain, queries
14
Rscript: a Relational Approach to Program and System Understanding
– relations can represent graphs in the rewriting world
15
Rscript: a Relational Approach to Program and System Understanding
16
Rscript: a Relational Approach to Program and System Understanding
17
Rscript: a Relational Approach to Program and System Understanding
18
Rscript: a Relational Approach to Program and System Understanding
– type: set[int]
– type: set[str]
– type: rel[str,int]
19
Rscript: a Relational Approach to Program and System Understanding
– 3
– {<3, ”y”>, <3, ”x”>, <5, ”z”>}
– {”y”, ”x”, ”z”}
20
Rscript: a Relational Approach to Program and System Understanding
– A generator is an enumerator or a test – Enumerators: V : SetExp or <V1,V2> : RelExp – Tests: any predicate – consider all combinations of values in Gen1, Gen2,... – if some Geni is false, reject that combination – compute Exp for all legal combinations
21
Rscript: a Relational Approach to Program and System Understanding
– yields {1,2,3,4,5}
– yields {4,5}
– yields {<10,1>,<20,2>}
22
Rscript: a Relational Approach to Program and System Understanding
– inv({1,10>, <2,20>} yields {<10,1>,<20,2>}
– inv({<1,”a”>, <2,”b”>}) yields {<”a”,1>,<”b”,2>}
23
Rscript: a Relational Approach to Program and System Understanding
24
Rscript: a Relational Approach to Program and System Understanding
25
Rscript: a Relational Approach to Program and System Understanding
26
Rscript: a Relational Approach to Program and System Understanding
– int ncalls = # calls – 8
– int nprocs = # carrier(calls) – 7
27
Rscript: a Relational Approach to Program and System Understanding
– set[str] entryPoints = top(calls) – {“a”, “f”}
– set[str] bottomCalls = bottom(calls) – {“c”, “e”}
28
Rscript: a Relational Approach to Program and System Understanding
29
Rscript: a Relational Approach to Program and System Understanding
30
Rscript: a Relational Approach to Program and System Understanding
– rel[str,str] closureCalls = calls+ – {<"a", "b">, <"b", "c">, <"b", "d">, <"d", "c">,
– set[str] calledFromA = closureCalls["a"] – {"b", "c", "d", "e"}
31
Rscript: a Relational Approach to Program and System Understanding
32
Rscript: a Relational Approach to Program and System Understanding
33
Rscript: a Relational Approach to Program and System Understanding
– set[str] callsToE = closureCalls[-,"e"] – {"a", "b", "d", "f", "g"}
34
Rscript: a Relational Approach to Program and System Understanding
– set[str] calledFromF = closureCalls["f"] – {"e", "g"}
– set[str] commonProcs =
– {"e"}
35
Rscript: a Relational Approach to Program and System Understanding
36
Rscript: a Relational Approach to Program and System Understanding
37
Rscript: a Relational Approach to Program and System Understanding
38
Rscript: a Relational Approach to Program and System Understanding
39
Rscript: a Relational Approach to Program and System Understanding
40
Rscript: a Relational Approach to Program and System Understanding
41
Rscript: a Relational Approach to Program and System Understanding
42
Rscript: a Relational Approach to Program and System Understanding
43
Rscript: a Relational Approach to Program and System Understanding
44
Rscript: a Relational Approach to Program and System Understanding
45
Rscript: a Relational Approach to Program and System Understanding
46
Rscript: a Relational Approach to Program and System Understanding
47
Rscript: a Relational Approach to Program and System Understanding
48
Rscript: a Relational Approach to Program and System Understanding
– the call relation between procedures (Calls) – the component of each procedure (PartOf)
– Can we lift the relation between procedures to a
49
Rscript: a Relational Approach to Program and System Understanding
50
Rscript: a Relational Approach to Program and System Understanding
51
Rscript: a Relational Approach to Program and System Understanding
52
Rscript: a Relational Approach to Program and System Understanding
53
Rscript: a Relational Approach to Program and System Understanding
54
Rscript: a Relational Approach to Program and System Understanding
55
Rscript: a Relational Approach to Program and System Understanding
56
Rscript: a Relational Approach to Program and System Understanding
– rel[str,str] CALL
– rel[str,str] INHERITANCE
– rel[str,str] CONTAINMENT
57
Rscript: a Relational Approach to Program and System Understanding
– rel[str,str] USE = CALL union CONTAINMENT
– set[str] ClassesInCycle =
58
Rscript: a Relational Approach to Program and System Understanding
59
Rscript: a Relational Approach to Program and System Understanding
60
Rscript: a Relational Approach to Program and System Understanding
61
Rscript: a Relational Approach to Program and System Understanding
62
Rscript: a Relational Approach to Program and System Understanding
63
Rscript: a Relational Approach to Program and System Understanding
64
Rscript: a Relational Approach to Program and System Understanding
65
Rscript: a Relational Approach to Program and System Understanding
66
Rscript: a Relational Approach to Program and System Understanding
67
Rscript: a Relational Approach to Program and System Understanding
68
Rscript: a Relational Approach to Program and System Understanding
– In the example so far we have worked with statement
– How do we extract relations like PRED and USE
69
Rscript: a Relational Approach to Program and System Understanding
70
Rscript: a Relational Approach to Program and System Understanding
<PRED, rel[loc,loc], {<area-in-file("/home/paulk/.../example.pico", area(4, 2,4, 8,84, 6)), area-in-file("/home/paulk/.../example.pico", area(5, 2,5, 8,94, 6))>, <area-in-file("/home/paulk/.../example.pico", area(5, 2,5, 8, 94, 6)), area-in-file("/home/paulk/.../example.pico", area(6, 2,10, 4, 104, 56))>, ... }>, <DEFS, { <OCCURS, rel[str,loc], {<"y", area-in-file("/home/paulk/.../example.pico",area(11, 2,11, 3,164, 1))>, <"z", area-in-file("/home/paulk/.../example.pico", area(11, 7,11, 8,169, 1))>, ... } } rstore( )
71
Rscript: a Relational Approach to Program and System Understanding
72
Rscript: a Relational Approach to Program and System Understanding
Obtain sources of SUI Obtain grammar for source language of SUI Validate grammar Improve Write queries Determine needed facts Obtain fact extractor Validate extracted facts Improve Execute queries Validate answers Use answers Improve Improve Grammar Facts Queries
SUI = System Under Investigation
73
Rscript: a Relational Approach to Program and System Understanding
74
Rscript: a Relational Approach to Program and System Understanding
75
Rscript: a Relational Approach to Program and System Understanding
(Courtesy: Arie van Deursen)
76
Rscript: a Relational Approach to Program and System Understanding
77
Rscript: a Relational Approach to Program and System Understanding
78
Rscript: a Relational Approach to Program and System Understanding
79
Rscript: a Relational Approach to Program and System Understanding
80
Rscript: a Relational Approach to Program and System Understanding
81
Rscript: a Relational Approach to Program and System Understanding
82
Rscript: a Relational Approach to Program and System Understanding
– an instance of The Meta-Environment
83
Rscript: a Relational Approach to Program and System Understanding
– reaching definitions – live variables
84
Rscript: a Relational Approach to Program and System Understanding
85
Rscript: a Relational Approach to Program and System Understanding