Re: [stella] Stella Debugger RFC

Subject: Re: [stella] Stella Debugger RFC
From: "B. Watson" <atari@xxxxxxxxxxxxxx>
Date: Wed, 15 Jun 2005 17:34:34 -0400
On Wed, 15 Jun 2005, Erik Mooney wrote:

>> Can anyone think of a better way to implement this? Should I be watching
>> the stack pointer instead? Or should I actually be looking for an RTS
>> instruction, maybe?
> Why not have the trace execution stop upon reaching _either_ the target
> PC or an RTS instruction?  Neither method by itself is foolproof.  There's
> a few code cases where a subroutine modifies its return address on the
> stack which would miss your target PC.  And looking for an RTS isn't 100%
> reliable either as some subroutines manually reset the stack pointer then
> JMP or Bxx based on a known flag (sometimes this can be faster than RTS.)

Well, I'd have to count JSR/RTS pairs, in case the subroutine calls
another subroutine(s). This still wouldn't be foolproof...

Also, isn't there a "trick" where you use JSR to strobe two registers
faster than normally possible? Hrm, or is that RTS? Of course, if the
subroutine never returns, or blows away the stack pointer or its contents,
it wasn't truly a subroutine call in the first place...

> But if you look for either, it should be reliable in all but the most
> spaghetti code structures.  RTS really doesn't have any application for
> 2600 programming besides its stated use; the only real exception is certain
> methods of bankswitching, and I'd argue that a trace command should stop and
> wait for user input upon such an unusual circumstance.

I think for the 2.0 release I'll leave it as-is, and just document it
as being limited to "legal" uses of JSR. If you're using the debugger
on your own code, presumably you'll know if you used tricks like that,
especially if the debugger's showing you your own labels and/or source.
In that case, you just use the single-step instead of trace.

> Of course, the ultimate solution would be to let the user choose (either
> via configuration or by issuing different commands like Shift-T or something)
> any combination of RTS or target PC or target stack pointer.

Eventually, there's going to be a "little language" that can handle
stuff like this in general. You'd say something like...

break inst=rts or pc=@pc+3 or sp=@sp

OK, that's probably not quite how it'll look, but you get the idea I

Anyway the mini-language won't be in the 2.0 release, particularly if
I'm the one that has to design it :)

BTW, thanks for the response. I was starting to wonder if anyone was
paying attention...


Archives (includes files) at
Unsub & more at

Current Thread