1 / 12

An Algorithmic Debugger for Java

An Algorithmic Debugger for Java. David Insa Cabrera. Contents. Introduction. Algorithmic Debugging. AD Strategies. A Debugging Session. Adaptation to Java. This, arguments and return value. System Demo. DDJ. Algorithmic Debugging.

hedya
Download Presentation

An Algorithmic Debugger for Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AnAlgorithmic Debuggerfor Java David Insa Cabrera

  2. Contents Introduction Algorithmic Debugging • AD Strategies • A Debugging Session Adaptation to Java This, arguments and return value System Demo DDJ

  3. Algorithmic Debugging • Algorithmic Debugging [Shapiro 82]Logic Paradigm • TWO PHASES: • Generate an execution tree • Traverse the execution tree asking questions until the bug is found If the effect of a bug is detected then AD will find the bug main = 4 What is an Execution Tree? listSum [1,2] = 4 Example: main = listSum [1,2] listSum [] = 1 listSum (x:xs) = x + (listSumxs) 1+3 = 4 listSum [2] = 3 2+1 = 3 listSum [] = 1

  4. Algorithmic Debugging • Traversing Execution Trees • GOLDEN RULE: When a wrong equation has not • wrong children, then this equation is buggy main = 4 listSum [1,2] = 4 Example: main = listSum [1,2] listSum [] = 1 listSum (x:xs) = x + (listSumxs) 1+3 = 4 listSum [2] = 3 2+1 = 3 listSum [] = 1

  5. Algorithmic Debugging • Traversing Execution Trees • GOLDEN RULE: When a wrong equation has not • wrong children, then this equation is buggy main = 5 listSum [1,2] = 5 Example: main = listSum [1,2] listSum [] = 0 listSum (x:xs) = x + (listSum xs) + 1 1+3+1 = 5 listSum [2] = 3 2+0+1 = 3 listSum [] = 0

  6. Contents Introduction Algorithmic Debugging • AD Strategies • A Debugging session Adaptation to Java This, arguments and return value System Demo DDJ

  7. Algorithmic Debugging Strategies Strategies Single Stepping Single Stepping Divide & Query Top Down Top Down Left to Right Top Down Heaviest First Top Down More Rules First Divide & Query Shapiro Divide & Query Hirunkitti Divide by Rules & Query Hat Delta Hat Delta More Wrongs Hat Delta Less Rights Hat Delta Best Division

  8. A Debugging Session A Debugging Session main = sqrTest [1,2] sqrTest x = test (squares (listSum x)) test (x,y,z) = (x==y) && (y==z) listSum [] = 0 listSum (x:xs) = x + (listSumxs) squares x = ((square1 x),(square2 x),(square3 x)) square1 x = square x square x = x*x square2 x = listSum (list x x) list x y | y==0 = [] | otherwise = x:list x (y-1) square3 x = listSum (partialSums x) partialSums x = [(sum1 x),(sum2 x)] sum1 x = div (x * (incr x)) 2 sum2 x = div (x + (decr x)) 2 incr x = x + 1 decr x = x - 1

  9. A Debugging Session A Debugging Session with Top-Down Left to Right search. main = False Starting Debugging Session… main = False? NO sqrTest [1,2] = False? NO test [9,9,8] = False? YES squares 3 = [9,9,8]? NO square1 3 = 9? YES square2 3 = 9? YES square3 3 = 8? NO listSum [6,2] = 8? YES partialSums 3 = [6,2]? NO sum1 3 = 6? YES sum2 3 = 2? NO decr 3 = 2? YES Bug found in rule: sum2 x = div (x + (decr x)) 2 sqrTest [1,2] = False test (9,9,8) = False squares 3 = (9,9,8) listSum [1,2] = 3 listSum [2] = 2 squares1 3 = 9 squares2 3 = 9 squares3 3 = 8 listSum [] = 0 square 3 = 9 listSum [3,3,3] = 9 list 3 3 = [3,3,3] partialSums 3 = [6,2] listSum [6,2] = 8 listSum [3,3] = 6 list 3 2 = [3,3] listSum [2] = 2 sum1 3 = 6 sum2 3 = 2 decr 3 = 2 listSum [3] = 3 list 3 1 = [3] listSum [] = 0 incr 3 = 4 listSum [] = 0 list 3 0 = []

  10. Contents Introduction Algorithmic Debugging • AD Strategies • A Debugging Session Adaptation to Java This, arguments and return value System Demo DDJ

  11. Adaptation to Java public class Class { private intatribute; public void procedure(AnObjectarg1, AnObjectarg2) { this.atribute = 5; } public intfunction(MyObjectarg1, AnObjectarg2) { arg1.setProperty(this.atribute); arg2.atribute = this.atribute; return this.atribute; } } public class MyObject { private int property; public void setProperty(int argument) { this.property = argument; } }

  12. Contents Introduction Algorithmic Debugging • AD Strategies • A Debugging Session Adaptation to Java This, arguments and return value System Demo DDJ

More Related