Single step debugger?
ManAtWork
Posts: 2,176
in Propeller 2
I have to test and debug my arithmetic code for my servo controller. It's all fixed point math so there are lots of shifts and I have to check if every bit goes into the right place an no overflow occurs for all possible input values. I can feed in test cases from a table and print out the results but it would be very handy to have a single step debugger. It's not absolutely necessary but you find bugs a lot faster if you can look at all intermediate results and the C/Z flags while stepping through the code. Without a debugger you have to modify the code very often, add a print here and there... And when something crashes (write to the wrong address...) all you can do is "shotgun debugging", commenting part of the code out and see what happens.
I know that the P2 has hardware support for debugging but I haven't found a debugger so far, at least not a convenient one that works at the source level. I don't know if the ROM monitor could be used to step through assembler code.
But until a real debugger is avaliable we could probably put up some "manual single stepping". The CALL instructions of the P2 push the C/Z flags onto the stack so it's easy to make a "breakpoint" function that doesn't modify the state of the cog except for some hidden buffer pointer. It could then write all register/variables of interest and the flags to a buffer in hub RAM and wait for acknowledge to return and execute the next step. Then all we have to do is to insert a CALL #breakpoint between all instructions of the code to be tested. And of course we need a frontend running in another cog that prints out the buffer over the serial port.
I know that the P2 has hardware support for debugging but I haven't found a debugger so far, at least not a convenient one that works at the source level. I don't know if the ROM monitor could be used to step through assembler code.
But until a real debugger is avaliable we could probably put up some "manual single stepping". The CALL instructions of the P2 push the C/Z flags onto the stack so it's easy to make a "breakpoint" function that doesn't modify the state of the cog except for some hidden buffer pointer. It could then write all register/variables of interest and the flags to a buffer in hub RAM and wait for acknowledge to return and execute the next step. Then all we have to do is to insert a CALL #breakpoint between all instructions of the code to be tested. And of course we need a frontend running in another cog that prints out the buffer over the serial port.
Comments
Is this the latest version?
this Propeller 2 Debug system
Changes to Pnut broke my symbol parser.
Also working on getting it to work debugging Spin2.
Need a few more days to get it sorted.
Post a link in the sticky topic for tools.
Ah, perfect. No hurry. At the moment I only need asm single stepping. I've seen the old debugger supports watchlists. It's "self contained", I mean everything runs in the target and the code to be tested is compiled together with the debugger. That would be perfectly fine for me.
Do you see chances of getting it to run by fixing the compiler errors (There are some missing commands like setclk and setbrk...) Or do you think it's better to wait for the new one?