stella-emu / stella

A multi-platform Atari 2600 Emulator
https://stella-emu.github.io
GNU General Public License v2.0
624 stars 111 forks source link

Trace mode (Z26 style) #204

Closed ale-79 closed 1 year ago

ale-79 commented 7 years ago

This has been brought up up a few times in the past so maybe it's worth checking if developers are still interested in such feature (maybe a thread on AA would get more visibility). It has the advantage of showing info about several frames all in one place (the downside being that the filesize tends to became HUGE in a few seconds...)

z26 trace log file example:

Loaded ROM: /home/alex/data/atari/roms/Roms/Stargate (1984) (Atari, Andrew Fuchs) (CX26120) ~.bin

(Frame Line Cycle Clock) (P0_Pos P1_Pos M0_Pos M1_Pos BL_Pos)  flags  A X Y SP  Code  Disasm

(  0   1   0 -68) ( 97  97  96  96  96) nvbdiZc 00 00 00 ff  d103: a0 b5    ldy #b5      
(  0   1   2 -62) ( 97  97  96  96  96) Nvbdizc 00 00 b5 ff  d105: 78       sei          
(  0   1   4 -56) ( 97  97  96  96  96) NvbdIzc 00 00 b5 ff  d106: d8       cld          
(  0   1   6 -50) ( 97  97  96  96  96) NvbdIzc 00 00 b5 ff  d107: a2 00    ldx #00      
(  0   1   8 -44) ( 97  97  96  96  96) nvbdIZc 00 00 b5 ff  d109: a9 00    lda #00      
(  0   1  10 -38) ( 97  97  96  96  96) nvbdIZc 00 00 b5 ff  d10b: 95 00    sta  00,x    = VSYNC   
(  0   1  14 -26) ( 97  97  96  96  96) nvbdIZc 00 00 b5 ff  d10d: 9d 80 ef sta  ef80,x  = ef80    
(  0   1  19 -11) ( 97  97  96  96  96) nvbdIZc 00 00 b5 ff  d110: e8       inx          
(  0   1  21  -5) ( 97  97  96  96  96) nvbdIzc 00 01 b5 ff  d111: d0 f8    bne  d10b    
(  0   1  24   4) ( 97  97  96  96  96) nvbdIzc 00 01 b5 ff  d10b: 95 00    sta  00,x    = VBLANK  
(  0   1  28  16) ( 97  97  96  96  96) nvbdIzc 00 01 b5 ff  d10d: 9d 80 ef sta  ef80,x  = ef81    
(  0   1  33  31) ( 97  97  96  96  96) nvbdIzc 00 01 b5 ff  d110: e8       inx          
(  0   1  35  37) ( 97  97  96  96  96) nvbdIzc 00 02 b5 ff  d111: d0 f8    bne  d10b    
(  0   1  38  46) ( 97  97  96  96  96) nvbdIzc 00 02 b5 ff  d10b: 95 00    sta  00,x    = WSYNC   
(  0   2   0 -68) ( 97  97  96  96  96) nvbdIzc 00 02 b5 ff  d10d: 9d 80 ef sta  ef80,x  = ef82    
(  0   2   5 -53) ( 97  97  96  96  96) nvbdIzc 00 02 b5 ff  d110: e8       inx          
(  0   2   7 -47) ( 97  97  96  96  96) nvbdIzc 00 03 b5 ff  d111: d0 f8    bne  d10b    
(  0   2  10 -38) ( 97  97  96  96  96) nvbdIzc 00 03 b5 ff  d10b: 95 00    sta  00,x    = *RSYNC* 
(  0   2  14 -26) ( 97  97  96  96  96) nvbdIzc 00 03 b5 ff  d10d: 9d 80 ef sta  ef80,x  = ef83    
(  0   2  19 -11) ( 97  97  96  96  96) nvbdIzc 00 03 b5 ff  d110: e8       inx          
(  0   2  21  -5) ( 97  97  96  96  96) nvbdIzc 00 04 b5 ff  d111: d0 f8    bne  d10b    
...

There could be additional information added next to each line, for example queued writes, dummy reads (when using indexed addressing modes), bankswitch triggering, etc. If there's enough interest in implementing it, I think there's no need for an UI item, just a command to toggle it ON or OFF from the debugger prompt. (maybe it should print a warning about filesize)

thrust26 commented 7 years ago

The log file was very flexible, but IMO most things are covered in Stella already.

The main things missing are frame rewinds and late WSYNCs.

sa666666 commented 7 years ago

While in general I'm not opposed to the idea, I think that if the same functionality is already in Stella, I wouldn't want to waste valuable development time on redundant features. And if the same functionality isn't already present, perhaps it can be done differently/better than the old approach.

EDIT: IOW, we need to analyze what advantages the trace file gives over the current functionality in Stella, and perhaps extend Stella to fix those deficiencies (not necessarily by implementing the trace file, but not necessarily against the idea either).

ale-79 commented 7 years ago

Good points. Implementing #71, #169 (and maybe #203) would probably cover the few cases where I think the trace log currently has some advantages over the debugger.

thrust26 commented 7 years ago

I am sure we cannot cover everything 1:1, but for most we sure can offer alternatives. And all other languages only need a debugger too. :)

Here is what I used z26.log for, which is not covered in Stella yet (I opened some issue for those in the past):

  1. ~I wrote a parser based on the file, which analyzed which ROM and RAM addresses where used (code and data) and which not. (#167)~ #221 reports the required details
  2. compare two trace files in parallel (can be done with two instances of Stella) with the help of a file compare (you have to do that manually in Stella)
  3. ~late WSYNCs (#169) or HMOVE not happening at cycle 0~ done
  4. ~determine stack usage (minimal SP value)~ #221 reports the required details
  5. probably more I can't remember now...
thrust26 commented 7 years ago

Maybe we could do something like a conditional logging in Stella, e.g. instead of a break or breakif, log the info (registers, flags etc.). That would work also with traps and maybe more.

thrust26 commented 7 years ago

Creating a savestate instead of break/trap/log would also be cool.

sa666666 commented 5 years ago

Revisiting some older issues. Is this one still valid? Now that we have rewind fully working, have we finally duplicated all the functionality of a trace file?

sa666666 commented 5 years ago

Bump on this; is this one still valid??

thrust26 commented 5 years ago

Prio 3 or close. I will leave that up to you.

sa666666 commented 5 years ago

If you're satisfied that Stella does everything you need (as a developer), then I guess we're done with this one. I don't develop 2600 games, so I have no idea what a typical developer needs. I guess it is sufficient as-is (wrt this, of course there are many improvements to be made in other areas).

thrust26 commented 1 year ago

Given the lastest discussion here, I reopen this issue.