Shop OBEX P1 Docs P2 Docs Learn Events
I need access to the Spin stack pointer. — Parallax Forums

I need access to the Spin stack pointer.

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2011-02-24 09:15 in Propeller 1
I have a Spin program which, I suspect, is having some deep (pardon the double entendre) stack issues, and I'd like to see what's going on. AFAIK, the Spin stack pointer is inaccessible. Is there an alternate Spin interpreter available that might make it easier to probe the stack for debugging purposes?

Thanks,
-Phil

Comments

  • jazzedjazzed Posts: 11,803
    edited 2011-02-23 09:51
    You could use a debugger :)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-23 10:03
    LOL! Jazzed, your steel-trap memory seems to be accompanied by a sight cruel streak! :)

    -Phil
  • jazzedjazzed Posts: 11,803
    edited 2011-02-23 10:12
    Just call me Rhett Butler.

    IIRC, You could just print the address of result within a method to get the current stack frame start.
    If that doesn't help I do have a version of an interpreter that traps this kind of stuff.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-23 10:20
    Thanks, jazzed. I decided to try a "virtualized" approach by starting my top-level program at a secondary level with a stack that I have easier access to. Then I can fill the stack ahead of time with a known value ($5555_5555) and monitor it from the new top-level program to see how deep it runs. If this doesn't give me enough info, I may hit you up for your interpreter.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-23 10:28
    ...and that did the trick. The program ran well past the point where it started misbehaving (in a way that suggested an overrun stack). But, upon dumping the stack, I discovered that only 48 longs had been used. So much for that theory.

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-02-23 11:22
    Phil,

    If your program doesn't use any pin inputs or counters you could run it under SpinSim and list out all the instructions that get executed. SpinSim is located at http://forums.parallax.com/showthread.php?127976-Spin-Simulator .

    Dave
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-23 11:28
    Thanks, Dave. It's a Spinneret program, and it requires an Ethernet connection to run/misbehave. Anyway, I've got a better net sniffer now and am getting a handle on the situation. But that's a discussion for my other thread.

    -Phil
  • AleAle Posts: 2,363
    edited 2011-02-23 11:37
    Dave... I just got this nice idea... If the SpinSim could be fed with a waveform it could for instance be used when IO is involved. You may want to know how you know when the signals have to change and if you for instance signal these event-points then a suitable waveform could be constructed from the saved event-points. I think it does not sound clear.. mmm I'll think of a better description and re-edit the post ? This needs elaboration but could be useful :) I haven't used SpinSim so pardom me if it is not suitable..
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-02-23 12:58
    Ale,

    I haven't thought much about driving the input pins, but I think I'll need to add that feature at some point. Gear has some way to add a plugin or a stimulus file. I haven't looked into it, so I don't know how that works. A stimulus file would be easy to add. Another method would be to use a cog to simulate an external device, and have it write certain pins, which are read by another cog. That would be easy to do also.

    Dave
  • AleAle Posts: 2,363
    edited 2011-02-24 00:25
    Dave and using a COG to simulate the external device means that it can be used in the real propeller... mmm, yes but I still find a stimulus (right name!) via a file (vcd for instance) very useful. Specially because such a file would be easier to write than some PASM/Spin :), but both would be ideal.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-02-24 02:26
    Phil: It is possible to patch the spin interpreter (or use the soft interpreter) by reclaiming a few unused methods in the interpreter. If you would like to follow this approach I can guide you through it.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-24 09:15
    Thanks, but I think I got the info I needed from the "virtualization" approach I took. I just wanted to see if the top-level stack was intruding somewhere it shouldn't, and it wasn't.

    -Phil
Sign In or Register to comment.