Menu ▾ ▴

#522 Enhance CPU History binary command

SDL2x
open
nobody
new feature (Monitor)
2026-09-26
2026-09-26
No

I'm looking at new CPU History binary monitor instruction. While it provides insight into history, it probably lacks usefulness.

Imagine I have an IDE and would like to track how my app performs. The obstacle is, if I'm not mistaken, limited history length (8192? instructions). Let's say I start recording history - how can I retrieve all the history items as I don't know when the buffer is being overwritten?

So I propose this feature:
Have a history checkpoint which is triggered when buffer is full (optional, of course).

I can imagine my scenario like this:
a) set condition that stops emulator when CPU history buffer is full (my proposal)
b) run app
c) each time buffer is full, retrieve history
d) eventually stop app
e) unset condition that stops emulator when CPU history buffer is full (my proposal)
f) call CPU History instruction and retrieve only the last 0...index history items.
g) analyze complete history programmatically

I might be missing something and there is already a solution for this? But if not, it shouldn't be that hard to add such an addition. FYI I have an IDE and would like to add profiling.

TIA

Discussion

  • gpz

    gpz - 2026-09-26

    you can configure the buffer size :)

     
  • gpz

    gpz - 2026-09-26

    Other than that:

    • configure the size of the buffer (use the "MonitorChisLines" resource)
    • use the "advance instruction" command to run as many instructions as you like

    That should enable you to do what you want

     
  • Miha Markič

    Miha Markič - 2026-09-26

    Setting buffer size will only slightly help, will allocate everything upfront (it might be huge) and it's still a fixed buffer size.
    Advance instructions might actually do the trick, good idea.
    I assume (the docs for IC) mean "How many instructions to execute or to step over based on SO"?
    IOW if I set SO to false, it will just execute N instructions whatever they are.

    From docs:
    SO: 1 byte: Step over subroutines?
    Should subroutines count as a single instruction?
    IC: 2 bytes: How many instructions to step over.

    Thanks for ideas!

     
  • Miha Markič

    Miha Markič - 2026-09-26

    Hm, OTOH there is one more issue - the last fetch. When app stops collecting, how does it know how many items to retrieve? It's certainly N<BufferSize, but how would it know?

     
  • Miha Markič

    Miha Markič - 2026-09-26

    OTOH OTOH recording 8192 instructions takes roughly half a second (including communication through binary monitor) so stopping only when buffer is full shouldn't mater.

     
  • Miha Markič

    Miha Markič - 2026-09-26

    Perhaps one more question.
    I'm trying to figure out how to best start profiling right before my app starts.
    Here is one plan:

    1. put VICE in paused mode
    2. Autoload (with run after load = true) the app
    3. Issue AdvancedInstructions command

    Now, this does not work because autoload with run after load doesn't honor paused state and restarts the emulator.
    What would be the proper way to start an autoloaded app (run after load=false)? By setting a PC register to its start location?
    TIA

     

Log in to post a comment.