Hi, On Tue, 2007-07-10 at 12:50 +0200, Mark Wielaard wrote: > I think I know how this can be made way easier. The current setup > inserts labels at every instruction. This makes it really hard to > combine with the generic funit-asm.h assembly instructions since it > introduces 2 layers of macros to write a simple test. And the test has > to be marked up fully with the labels and a path through the program > that can be checked. But the current setup already shows an easier way > to do this. In TestInstructions we already do a full step through the > assembly and double check that all the labels are hit in the right > order. But this can be turned around. We can first do this full step > through the assembly instructions and record all addresses, then we put > breakpoints at every instruction that we just past and do another run > with the breakpoints inserted that should then run exactly the same as > before (except for hitting a breakpoint at every step of course). > > If we do it that way then we just need the start and end address of the > instruction stream and can hopefully completely reuse funit-asm.h as > long as the test writer makes sure the program always ends at the same > address. The above is what the following patch implements. The test is replaced by a full .S assembly file that only uses instructions as defined in frysk-asm.h. It creates 2 global labels istart and iend inside the test function (instructions) that are used by the rewitten TestInstructions harness which now assumes setting a breakpoint, stopping and removing it (to detect istart) and instruction stepping (till iend is detected) work (which is a good assumption to make since we have other unit tests that explicitly test this) in setup(). Then each different test then sets breakpoints on the addresses collected between istart and iend and the test function is called again by funit-instructions and each test checks that the same instruction sequence is hit independent from which Code breakpoint (and/or other) observers are inserted. frysk-core/frysk/proc/ChangeLog 2007-07-13 Mark Wielaard * TestInstructions.java (pid, proc, in, out, labels): Removed fields. (addresses, io, start_address, end_address): New fields. (getGlobalLabelAddress): New method. (Symbol): New static class. (setup): Rewritten to no use ForkLib and to use Code and Instruction observer to find code instruction path. (tearDown): Clear addresses. (testBreakAndStepInstructions): Renamed to... (testBreakOnStartThenStepAllInstructions): Rewriten to use addresses, breakpoint on first, delete, then step all. (testAllBreakpoints): Rewritten to use addresses. (testInsertAllBreakpointsAndStepAll): New test. (InstructionObserver.block): New field. (InstructionObserver.deletedFrom): Don't stop event loop. (InstructionObserver.updateExecuted): Check block field. (InstructionObserver.setBlock): New method. frysk-core/frysk/pkglibdir/ChangeLog 2007-07-13 Mark Wielaard * funit-instructions.c: Removed. * funit-instructions.S: New file. Tested on x86_64 and x86. The instruction sequences have been extended a bit to exercise many of the generic instructions found in frysk-asm.h. The next thing would be extending these sequences with full architecture specific instructions. Which has to be added when we have a full ssol instruction parser. When cross 32-64 bit tests are enabled funit-instructions should now just compile and run as is in either 32 or 64 bit mode. Cheers, Mark