Skip to content

Commit 1dbf5bd

Browse files
committed
WIP debugging
1 parent b5322bc commit 1dbf5bd

4 files changed

Lines changed: 55 additions & 46 deletions

File tree

code/jvm/src/main/scala/maf/cli/runnables/IncrementalRun.scala

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -174,29 +174,13 @@ object IncrementalRun extends App:
174174
false
175175

176176
List(
177-
// Different results with and without LitAddr.
178-
// SOME IGNORE TIMEOUT?
179-
//"test/changes/scheme/generated/R5RS_gambit_matrix-1.scm",
180-
//"test/changes/scheme/generated/R5RS_scp1_draw-umbrella-4.scm",
181-
//"test/changes/scheme/generated/R5RS_scp1_draw-umbrella-5.scm",
182-
//"test/changes/scheme/generated/R5RS_scp1_insert-2.scm",
183-
//"test/changes/scheme/generated/R5RS_scp1_list-compare-n-1.scm",
184-
//"test/changes/scheme/generated/R5RS_scp1_list-compare-n-3.scm",
185-
//"test/changes/scheme/generated/R5RS_various_work-1.scm",
186-
//"test/changes/scheme/generated/R5RS_various_work-3.scm",
187-
188-
//"test/changes/scheme/generated/R5RS_scp1_organigram-4.scm",
189-
//"test/changes/scheme/generated/R5RS_various_four-in-a-row-2.scm",
190-
//"test/changes/scheme/generated/R5RS_various_four-in-a-row-4.scm",
191-
//"test/changes/scheme/generated/R5RS_various_rsa-1.scm",
192-
//"test/changes/scheme/generated/R5RS_various_rsa-3.scm",
193-
194177
// Nog imprecies zelfs met bottomen van cycles. Niet door heuristieken.
195178
//"test/changes/scheme/generated/R5RS_WeiChenRompf2019_the-little-schemer_ch3-5.scm",
196179

197-
"test/DEBUG2.scm",
180+
//"test/DEBUG3.scm",
181+
//"test/DEBUG1.scm",
198182
//"test/changes/scheme/generated/R5RS_scp1_count-pairs2-1.scm",
199-
183+
"test/DEBUG1.scm",
200184
/*
201185
// Not precise yet.
202186
"test/DEBUG2.scm",
@@ -219,6 +203,8 @@ object IncrementalRun extends App:
219203
val anly = true // Switch between analysing and delta debugging
220204
val logging = false
221205
val images = true
206+
207+
// Update the flags above!
222208
if anly
223209
then
224210
println(text)

code/shared/src/main/scala/maf/modular/incremental/IncrementalLogging.scala

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import maf.core.Expression
44
import maf.language.change.CodeVersion.*
55
import maf.language.scheme.SchemeExp
66
import maf.modular.*
7+
import maf.modular.scheme.FlowAddr
78
import maf.util.ColouredFormatting.*
89
import maf.util.Logger
910
import maf.util.Logger.*
@@ -55,21 +56,22 @@ trait IncrementalLogging[Expr <: Expression] extends IncrementalDataFlowVisualis
5556
private def legend(): String =
5657
"""***** LEGEND OF ABBREVIATIONS *****
5758
|ADEP An address value dependency is registered. Includes the "source" address and the address where the value flows to.
58-
|ADP* Similar to ADEP, but the address dependency originates from an implicit value flow (e.g., due to a conditional).
5959
|ANLY Analysis of a component, indicating the step of the analysis and the number of times the current component is now analysed.
6060
|CINV Component invalidation: the given component is deleted.
6161
|COMI Indicates the component's analysis is committed.
6262
|DELA Indicates the removal of a given address.
6363
|DINV Dependency invalidation: the component is no longer dependent on the dependency.
6464
|ICFL The components called in a non-empty flow context.
65+
|IFLW The implicit flows added to compute the SCAs.
6566
|IUPD Incremental update of the given address, indicating the value now residing in the store and the value actually written.
6667
|NEWC Discovery of a new, not yet existing component.
6768
|PROV Registration of provenance, including the address and new provenance value, for values that did not cause store changes.
6869
|READ Address read, includes the address and value retrieved from the store.
6970
|RSAD Indicates the address dependencies for a given component are reset.
70-
|RSCA Indicates (an address in) a SCA is refined. The number indicates the number of SCA refinement.
71+
|RSCA Indicates (an address in) an SCA is refined. The number indicates the number of SCA refinement.
7172
|SCAC Computed SCA. Shows the algorithm used for this computation.
7273
|SCAR Finds that an SCA needs to be refined and gives the addresses because of which.
74+
|SKIP SCA computation skipped (due to heuristic).
7375
|TRIG Indicates the given dependency has been triggered.
7476
|WRIT Address write, including the address, value written and value now residing in the store.
7577
|
@@ -226,6 +228,19 @@ trait IncrementalLogging[Expr <: Expression] extends IncrementalDataFlowVisualis
226228
if (mode != Summary && (mode != Step || stepSelect())) && !visited(cmp) then logger.log(s"NEWC ${crop(cmp.toString)}")
227229
super.spawn(cmp)
228230

231+
override def computeInformationFlow(): Map[W, Set[R]] =
232+
// Combines the information stored on a per-component basis in dataFlowR.
233+
val flowsR: Map[W, Set[R]] = dataFlowR.foldLeft(Map().withDefaultValue(Set[R]())) { case (res, (_, map)) =>
234+
map.foldLeft(res) { case (res, (w, rs)) => res + (w -> SmartUnion.sunion(res(w), rs)) }
235+
}
236+
val res = super.computeInformationFlow()
237+
res.foreach { (w, rs) =>
238+
rs.diff(flowsR.getOrElse(w, Set())).foreach { r =>
239+
logger.log(s"IFLW $w ~> $r")
240+
}
241+
}
242+
res
243+
229244
override def computeSCAs(fullComputation: Boolean): Set[SCA] =
230245
val res = super.computeSCAs(fullComputation)
231246
val algo = if fullComputation then "TARJAN" else "INCREMENTAL"
@@ -251,9 +266,24 @@ trait IncrementalLogging[Expr <: Expression] extends IncrementalDataFlowVisualis
251266
rs.exists { r => !lattice.subsumes(store.getOrElse(r, lattice.bottom), oldStore.getOrElse(r, lattice.bottom)) }
252267
}
253268
if (mode != Summary || stepSelect()) && reasons.nonEmpty
254-
then logger.log(s"SCAR $sca because of flows to ${reasons.keySet.mkString(", ")}")
269+
then
270+
reasons.foreach { (w, rs) =>
271+
val gone: Set[Addr] = rs.diff(flowsR(w))
272+
val nonM: Set[Addr] = rs.filter { r => !lattice.subsumes(store.getOrElse(r, lattice.bottom), oldStore.getOrElse(r, lattice.bottom)) }
273+
gone.foreach { r =>
274+
logger.log(s"SCAR $r ~\\~> $w: $sca")
275+
}
276+
nonM.foreach { r =>
277+
logger.log(s"SCAR $r (${oldStore.getOrElse(r, lattice.bottom)} => ${store.getOrElse(r, lattice.bottom)}) ~> $w: $sca")
278+
}
279+
}
255280
super.refiningNeeded(sca, oldStore, oldDataFlowR)
256281

282+
override def updateSCAs(oldStore: Map[Addr, Value], oldDataFlowR: Map[Component, Map[W, Set[R]]], cmp: Component): Unit =
283+
val flowDeleted = oldDataFlowR(cmp).exists((w, rs) => rs.diff(dataFlowR(cmp).getOrElse(w, Set())).nonEmpty)
284+
if !(flowDeleted || nonIncrementalUpdate) then logger.log("SKIP")
285+
super.updateSCAs(oldStore, oldDataFlowR, cmp)
286+
257287
private var rSCAcount = 0
258288
override def refineSCA(sca: SCA, refinedEntries: Set[Addr]): Unit =
259289
rSCAcount = rSCAcount + 1
@@ -297,10 +327,6 @@ trait IncrementalLogging[Expr <: Expression] extends IncrementalDataFlowVisualis
297327
if (mode != Select || focus(addr)) && (mode != Step || stepSelect()) then
298328
logger.log(s"ADEP ${crop(r.toString)} ~> ${crop(addr.toString)}")
299329
)
300-
//implicitFlows.flatten.foreach(f =>
301-
// if (mode != Select || focus(addr)) && (mode != Step || stepSelect()) then
302-
// logger.log(s"ADP* ${crop(f.toString)} ~> ${crop(addr.toString)}")
303-
//)
304330
val b = super.writeAddr(addr, value)
305331
if mode == Fine || select(addr) || stepSelect() then
306332
logger.log(

test/DEBUG1.scm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
(let* ((last (<change>
2-
()
3-
(cons 'box ()))))
4-
(if =
5-
(set-cdr! ((lambda (x) x) last) ())))
1+
; Verder aangepaste WCR 3-5 reductie
2+
(letrec ((fun
3+
(lambda (l)
4+
(if (null? l)
5+
(set! l l)
6+
(<change> (fun (cdr l)) ())))))
7+
(fun (cons 'f ())))

test/DEBUG3.scm

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
(letrec ((__toplevel_cons cons)
2-
(_0 (letrec ((init (lambda (ipats)
3-
(let ()
4-
(letrec ((__do_loop (lambda (p)
5-
(<change>
6-
(if (null? ())
7-
(set-cdr! p #f)
8-
(() (() ())))
9-
(set-cdr! p ())))))
10-
(__do_loop ipats))
11-
generate-symbol)))
12-
(database (init
13-
(__toplevel_cons 'a ()))))
14-
())))
15-
())
1+
; Aangapaste WCR 3-5 reductie
2+
(letrec ((fun
3+
(lambda (l)
4+
(if (null? l)
5+
(fun2 l)
6+
(<change> (fun2 (cdr l)) ()))))
7+
(fun2
8+
(lambda (l2)
9+
(fun l2))))
10+
(fun (cons 'f ())))

0 commit comments

Comments
 (0)