Add debug state save and replay