Setting the Program Counter
To resume execution at a different statement than at stopped execution, reset the value of the program counter (PC). This is useful in the event that you want to skip over some code, execute some code again after changing certain variables, or restart a thread that is in an error state.
Setting the PC can be critical when restarting a thread that is in an error state. Although the PC symbol in the line number area points to the source statement that caused the error, the PC actually points to the failed machine instruction in the source statement. You need to explicitly reset the PC to the correct instruction. (You can verify the actual location of the PC before and after resetting it by displaying it in the Call Stack, or displaying the source code in the Source pane.)
Set the PC of a stopped thread to either a selected source line or a selected instruction. When you set the PC to a selected line, the PC points to the memory location where the statement begins. For most situations, setting the PC to a selected line of source code is the best choice.
To set the PC to a selected line:
1. Select the source line or instruction in the Source pane to highlight the line.
2. Select the
Thread > Set PC command.
The PC moves to the selected line.
When resetting the PC to a selected line, TotalView attempts to force the thread to continue execution at that statement in the currently selected stack frame. If the currently selected frame is not the top stack frame, TotalView prompts to unwind the stack:
This frame is buried. Should we attempt to unwind the stack?
For
Yes, TotalView discards deeper stack frames (that is, all stack frames that are more deeply nested than the selected stack frame) and resets the machine registers to their values for the selected frame.
For
No, TotalView sets the PC to the selected line, but leaves the stack and registers in their current state. Since you can’t assume that the stack and registers have the right values, selecting No is not recommended.