RAM write address detection

By fernandomanuel....

Master (191)

fernandomanuel.garciagarcia's picture

21-12-2015, 16:45

I am trying to keep track where abouts on RAM some games are writing (or try to write).
Basically we've got this functionality doing something like
debug set_watchpoint write_mem {0x0000 0xFFFF} { ... do something ...}
is it possible to exactly know what RAM address is about to be written (or it's already written)?
What I'd like it's storing that address into an boolean array or similar in order to get a sort of 'map' with all the memory written addresses .
I've been thinking of taking a RAM snapshot and compare with the previous snapshot what value has changed... but another way to do this?

Login or register to post comments

By Manuel

Ascended (18256)

Manuel's picture

21-12-2015, 22:43

Check the help on setting watchpoints (help debug set_watchpoint), it says:

debug set_watchpoint <type> <region> [<cond>] [<cmd>]
  Insert a new watchpoint of given type on the given region, there can be an optional condition and alternative command. See the 'set_bp' subcommand for details about these last two.
  Type must be one of the following:
    read_io    break when CPU reads from given IO port(s)
    write_io   break when CPU writes to given IO port(s)
    read_mem   break when CPU reads from given memory location(s)
    write_mem  break when CPU writes to given memory location(s)
  Region is either a single value, this corresponds to a single memory location or IO port. Otherwise region must be a list of two values (enclosed in braces) that specify a begin and end point of a whole memory region or a range of IO ports.
During the execution of <cmd>, the following global Tcl variables are set:
  ::wp_last_address   this is the actual address of the mem/io read/write that triggered the watchpoint
  ::wp_last_value     this is the actual value that was written by the mem/io write that triggered the watchpoint
  debug set_watchpoint write_io 0x99 {[reg A] == 0x81}
  debug set_watchpoint read_mem {0xfbe5 0xfbef}

So, I guess you can simply read $::wp_last_address to find out which address was written to?

By fernandomanuel.garciagarcia

Master (191)

fernandomanuel.garciagarcia's picture

22-12-2015, 15:08

That's exactly what I need Manuel!
Thanks a lot