Single step debugger?

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.

Comments

  • I will make an interactive debugger, eventually, but Ozpropdev already has one working.
  • Ah, thanks. It's always good to know what to search for. A simple search for "debugger" only showed old posts for P1 stuff (at least on the 1st page). And Ozpropdev's work was not listed in the resources thread.

    Is this the latest version?
  • That looks three years old, so it must have been for an earlier version of the P2 design.
  • You might be looking for
    this Propeller 2 Debug system
  • I'm working on Version 8.1 right now.
    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.
  • Brian,
    Post a link in the sticky topic for tools.
  • evanh wrote: »
    Brian,
    Post a link in the sticky topic for tools.
    Yes, I will do that for sure. :)

  • ozpropdev wrote: »
    I'm working on Version 8.1 right now.
    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.

    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?
Sign In or Register to comment.