I have implemented a tool for helping me debug some algorithms that are
very similar but I need some help in improving how it works. I have a set of implementations of algorithms that all compute the same result. I normally run two implementations (lets say C and E) at a time and compare the runs for speed, space used, and other characteristics. If the implementations are correct both runs return the same result but if there is a bug the results may be different. If the results are different I track down the problem by running a method called traceBug. (Tracebug is started by pressing a button). The high level part of each implementation is the same but they each invoke a method which is different for each implementation. Let's say C invokes Mc and E invokes Me where Mc and Me are different. Note that Mc (if it has no bugs) always computes the same result for the same input parameters. Similarly for Me. Conceptually, TraceBug works as follows. Repeat If C has not been started start it. Continue running C until Mc is invoked. Store the result of Mc, in Ac. If E has not been started start it. Continue running E until Me is invoked. Store the result of Me in Ae. Until Ac and Ae are different. // since there is a bug this must happen Ac and Ae are arrays. Since they are different, for some index i, Ac[i] != Ae[i]. TraceBug now invokes M'c where is M'c takes the same parameters as Mc except for one additional parameter i. M'c does the same computations as Mc except that when the value Ac[i] is about to be computed a halt is invoked thus bringing up the debugger. I can now use the debugger to investigate how Ac[i] is computed! I also invoke traceBug so that the halt occurs when Ae[i] is about to be computed. Thus by running traceBug twice I am able to bring up two debuggers somewhere near where my bug is! Having two debuggers up at the same time is very useful in finding where my bug is! I would like to be able to improve traceBug in two ways. First, I would like to only press the traceBug button once. This means that once the debugger is brought up traceBug needs to be restarted so that it can cause the second debugger to come up. Obviously this can be done but I don't know how to do it. Second, instead of restarting traceBug from the beginning, I would like to have it be restarted at the point immediately after the line where M'c is invoked. It could then immediately invoke M'e. This would avoid running C and E twice and thus be faster. This is not that important to me since C and E are usually fast (a few seconds), but I would like to know how to do this and I may deal with slower algorithms in the future. Thanks in advance for any advice. Ralph |
> [...]
This is too complicated that I can fully understand just from reading. I would love to see a screencast of the thing in action debugging a real-world example ... > First, I would like to only press the traceBug button once. > This means that once the debugger is brought up traceBug needs to be > restarted > so that it can cause the second debugger to come up. > Obviously this can be done but I don't know how to do it. You can avoid restarting the calculation by capturing a (or multiple) continuation(s) at the right place(s). Then you can resume from that point anytime, open a debugger, etc. HTH, Lukas -- Lukas Renggli http://www.lukas-renggli.ch |
In reply to this post by Ralph Boland
Have a look at what Andreas Zeller is doing for automatic debugging.
This would be great to have that in squeak. Stef On 5 janv. 07, at 15:43, Ralph Boland wrote: > I have implemented a tool for helping me debug some algorithms that > are > very similar but I need some help in improving how it works. > > I have a set of implementations of algorithms that all compute the > same result. > I normally run two implementations (lets say C and E) at a time > and > compare the runs for speed, space used, and other characteristics. > If the implementations are correct both runs return the same result > but > if there is a bug the results may be different. > > If the results are different I track down the problem by running a > method > called traceBug. (Tracebug is started by pressing a button). > The high level part of each implementation is the same but they > each invoke a method > which is different for each implementation. > Let's say C invokes Mc and E invokes Me where Mc and Me > are different. > Note that Mc (if it has no bugs) always computes the same result > for the same > input parameters. Similarly for Me. > > Conceptually, TraceBug works as follows. > Repeat > If C has not been started start it. Continue running C > until Mc is invoked. > Store the result of Mc, in Ac. > If E has not been started start it. Continue running E > until Me is invoked. > Store the result of Me in Ae. > Until Ac and Ae are different. // since there is a bug this > must happen > > Ac and Ae are arrays. Since they are different, for some index > i, Ac[i] != Ae[i]. > TraceBug now invokes M'c where is M'c takes the same > parameters as Mc > except for one additional parameter i. M'c does the same > computations as Mc > except that when the value Ac[i] is about to be computed a halt is > invoked thus > bringing up the debugger. > > I can now use the debugger to investigate how Ac[i] is computed! > I also invoke traceBug so that the halt occurs when Ae[i] is about > to be computed. > > Thus by running traceBug twice I am able to bring up two debuggers > somewhere > near where my bug is! Having two debuggers up at the same time > is very useful in finding where my bug is! > > I would like to be able to improve traceBug in two ways. > > First, I would like to only press the traceBug button once. > This means that once the debugger is brought up traceBug needs to > be restarted > so that it can cause the second debugger to come up. > Obviously this can be done but I don't know how to do it. > > Second, instead of restarting traceBug from the beginning, I would > like to > have it be restarted at the point immediately after the line where > M'c is invoked. > It could then immediately invoke M'e. This would avoid running > C and E twice > and thus be faster. This is not that important to me since C > and E are > usually fast (a few seconds), but I would like to know how to do > this and I may > deal with slower algorithms in the future. > > Thanks in advance for any advice. > > Ralph > > > > > |
Free forum by Nabble | Edit this page |