How to Jump to the Last Time a Variable Was Changed Using Undo’s ‘last’ Command

How to Jump to the Last Time a Variable Was Changed Using Undo’s ‘last’ Command

It’s quite common when diagnosing an issue in your application to come across an unexpected value in a variable or data structure, and to wonder “How did that value get there?” 

In Undo (our time travel debugger), you will find the last command that, when used, jumps to the last time in execution history when the value of a variable or expression was modified. 

Crazy, right! 

You can repeat last to keep jumping back to previous times that value changed. 

Don’t believe us? Watch the short demo here!

Or read the docs to learn more

Using “last” to find a memory corruption quicker

One way last provides great value is when trying to find a memory corruption. 

Tracking down unexpected values in memory is like looking for a needle in a haystack. The bad write is often nowhere near where the error shows up. In the most frustrating of cases, the corruption may have happened minutes (millions of lines of executed code!) before the crash.  

An Undo recording can answer any questions you have about program execution. 

Use the last command to find out when a bad value was written. This rewinds history to take you directly to what you want to see – the code that last changed a variable:

last remembers what data you’re looking at between invocations, so you can resume your search backwards by simply running it again without arguments. You can keep hitting the Enter key to see how the value develops over time. The command stops automatically on allocations and frees affecting the locations of interest, so you can catch memory management bugs in the act.

If you’re debugging via VS Code, the same functionality is available via the toolbar:

Use last to quickly understand what is modified and where when investigating changes in complex data structures.

Want to try this on your own application? Get started in under two minutes with our free trial

Free Trial

Stay informed. Get the latest in your inbox.