I have implemented a tool for helping me debug some algorithms that are <br>very similar but I need some help in improving how it works.<br><br>I have a set of implementations of algorithms that all compute the same result.
<br>I normally run two implementations (lets say C and E) at a time and <br>compare the runs for speed, space used, and other characteristics.<br>If the implementations are correct both runs return the same result but
<br>if there is a bug the results may be different.<br><br>If the results are different I track down the problem by running a method<br>called traceBug. (Tracebug is started by pressing a button).<br>The high level part of each implementation is the same but they each invoke a method
<br>which is different for each implementation. <br>Let's say C invokes Mc and E invokes Me where Mc and Me are different.<br>Note that Mc (if it has no bugs) always computes the same result for the same
<br>
input parameters. Similarly for Me.<br><br>Conceptually, TraceBug works as follows. <br>Repeat<br> If C has not been started start it. Continue running C until Mc is invoked.<br> Store the result of Mc, in Ac.
<br> If E has not been started start it. Continue running E until Me is invoked.<br> Store the result of Me in Ae.<br>Until Ac and Ae are different. // since there is a bug this must happen<br><br>Ac and Ae are arrays. Since they are different, for some index i, Ac[i] != Ae[i].
<br>TraceBug now invokes M'c where is M'c takes the same parameters as Mc<br>except for one additional parameter i. M'c does the same computations as Mc<br>except that when the value Ac[i] is about to be computed a halt is invoked thus
<br>bringing up the debugger.<br><br>I can now use the debugger to investigate how Ac[i] is computed!<br>I also invoke traceBug so that the halt occurs when Ae[i] is about to be computed.<br><br>Thus by running traceBug twice I am able to bring up two debuggers somewhere
<br>near where my bug is! Having two debuggers up at the same time<br>is very useful in finding where my bug is!<br><br>I would like to be able to improve traceBug in two ways.<br><br>First, I would like to only press the traceBug button once.
<br>This means that once the debugger is brought up traceBug needs to be restarted<br>so that it can cause the second debugger to come up.<br>Obviously this can be done but I don't know how to do it.<br><br>Second, instead of restarting traceBug from the beginning, I would like to
<br>have it be restarted at the point immediately after the line where M'c is invoked.<br>It could then immediately invoke M'e. This would avoid running C and E twice<br>and thus be faster. This is not that important to me since C and E are
<br>usually fast (a few seconds), but I would like to know how to do this and I may <br>deal with slower algorithms in the future.<br><br>Thanks in advance for any advice.<br><br>Ralph<br><br><br><br><br>