It’s been a while since OzCode released a major new version, but OzCode 4.0 will make up for the long wait – big time.
OzCode 4 introduces a new game-changing feature that we have been working on very hard: Time Travel Debugging.
OzCode v4 is now available as an Early Access Preview. We plan to sim-ship the final release alongside Visual Studio 2019.
In classic debugging, once a breakpoint hits, we are able to see the state of the program as it is now. We can evaluate any expression and get its value as it is when the program hit our breakpoint. Time Travel Debugging in OzCode changes the game and allows you to Predict the Future.
Predicting the Future
This is best explained with a picture:
What is it that we see here?
The breakpoint was hit all the way at the top of the method. OzCode predicts code execution all the way to the end of the method, predicting the values of everything along the way. This means we can see in advance the result of the method and all the method calls and variables. In our case, we see that the assertion failed and we probably have a bug.
Let’s take a moment to consider the implications of this. For one thing, we will no longer have to Step Over with F10 and go over all the method lines, remembering the various changes the variables make. With time travel, we can see the value of the expressions throughout time:
This is just the tip of the iceberg though. OzCode’s time travel has many features, let’s dive in and discover its full potential.
- Predictive DataTip
- Love Coding – “Editing the Future”
- Quick & easy time-travel across loop iterations
- Analyzing execution flow (If and Switch statements within loops)
- Go to Execution
The regular DataTip (and QuickWatch, and Immediate Window) in Visual Studio show you the value of an expression at the present (meaning, the current execution point, or in less fancy terms: the debugger’s yellow line). Not so in Time Travel mode! The Predictive DataTip will show the value of the expression at time it is evaluated:
Editing the Future
You probably know the excellent Edit and Continue feature in Visual Studio, that allows you to change code during debugging, without stopping the program and rebuilding it. It’s an awesome time saver that really tighten your developer inner loop.
OzCode time-travel debugging goes one step further. This is best shown with a video:
Like with Edit and Continue, you can continue debugging (F5) and your changes will be compiled on the fly. With OzCode’s Live Coding, you don’t have to actually run the code, you can see whether your bug-fix was good or not as soon as you lift your fingers off the keyboard.
Ever find yourself frantically hitting F10, stepping through a big loop, just to find the particular iteration where things go awry? That is not a fun way to spend an afternoon. Sure, Conditional Breakpoints can help out, but are often too cumbersome to set up. No problem, OzCode allows you to time travel across loop iterations without having to Step Over, so you can never go “too far”:
Once you time travel, the Predictive DataTip will show values that are relevant to the particular iterations you traveled to.
If and Switch statements within loops
When debugging, we often ask ourselves “How did I get here?”. When we have an if statement in a loop, it’s often interesting to know which iterations returned True and False. In classic debugging, we often need to place a breakpoint within the If statement’s body. Wouldn’t it be great to just graphically see all the iterations where the if expression evaluated to True or False? OzCode gives you just that:
The same goes for else clauses and case clauses within switch statements. In this example, OzCode folds time and space and shows us we had 30 iterations, of which 18 went inside the first case caluse, of which 12 went into the if branch and 6 went into the else branch. Simply hovering over any of the numeric indicators will show us which loop iterations went into that branch, and allow us to time pivot into that particular point in time.
If you’re like me, then you’re probably thinking about all the times this could have saved you an hour of debugging…
Go to Execution
I mentioned that OzCode’s time-travel will save you from doing Step Overs (F10) while debugging. But what about Step Into (F11)? Debugging is full of Step Into‘s and Step Outs (Shift + F11). Each time you step in or out of a method, you lose context. Your mental load increases. Time-travel debugging allows you Step Into a method, without changing the yellow debugger line:
We call this Go to Execution. Here are some features it allows:
- The method parameters are highlighted to clarify where each argument from the calling method ended up.
- Go to Execution will work more than once. You can Go to Execution as many levels deep as you want.
- When using Go to Execution on a method within a loop, changing the loop iteration in the top level will change the prediction in the inner method accordingly.
- All the predictions done by OzCode are done in virtually executed, so the program state isn’t affected.
- Time-travel debugging is asynchronous, so it doesn’t slow you down while you’re stepping through code.
- Native code can’t be predicted, so the prediction will end at the first line of native code (or at end of the method).
With OzCode’s time-travel debugging, we aim to transform the way developers debug code.
OzCode now supports visualizing as the code executes throughout time, with full fidelity time travel.
- We can see the values changing across time while staying on the same breakpoint.
- We can navigate through loop iterations without any need to mindlessly step through code, print to the console or setting conditional breakpoints.
- When investigating if statements, we see instantly which iterations that returned true on the condition, and which did not.
- Editing the Future is like Edit and Continue on steroids. Edit the code and see the changes throughout the entire method, without the need to stop the program or even step through code.
With time-travel debugging, you can bend time and space and find bugs quicker than ever before.
OzCode v4.0 is now available! Get it here.