[stella] Stella Debugger RFC

Subject: [stella] Stella Debugger RFC
From: "B. Watson" <atari@xxxxxxxxxxxxxx>
Date: Mon, 13 Jun 2005 11:03:21 -0400
Grr. If this turns out to be a dup, please ignore. List moderator(s),
please don't approve the posting from my other (e-verifile.com) email
address, I really didn't mean to use it here.

Anyway, here's what I was trying to say:

Hello everybody...

I'm working on the debugger support that's going to be in the next release
of Stella. One of the features of the debugger is the Trace command,
which is like a single-step except that it treats subroutine calls as
a single instruction (so you can trace the logic of your code without
having to single-step over the whole subroutine).

I've implemented the trace command like so:

// trace is just like step, except it treats a subroutine call as one
// instruction.

// This implementation is not perfect: it just watches the program counter,
// instead of tracking (possibly) nested JSR/RTS pairs. In particular, it
// will fail for recursive subroutine calls. However, with 128 bytes of RAM
// to share between stack and variables, I doubt any 2600 games will ever
// use recursion...

void Debugger::trace()
   // 32 is the 6502 JSR instruction:
   if(mySystem->peek(myDebugger->pc()) == 32) {
     int targetPC = myDebugger->pc() + 3; // return address
     while(myDebugger->pc() != targetPC)
   } else {

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?

Of course, 2600 code is full of neat tricks: sometime on this list I
read of someone using a JSR just to strobe the RESPx registers closer
together than would normally be possible. I can imagine someone doing
this and never executing an RTS, in which case my trace() method will
never return...

BTW, if anyone's interested, the current CVS version of Stella has an
incomplete but useful debugger already. The GUI isn't done, but the
command prompt already supports maybe 60% of the bare essentials you'd
want in a 2600 debugger. It'll be a good while before the 2.0 release,
but we'd welcome comments and feedback on what we have so far.


Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://stella.biglist.com

Current Thread