1. A method of compiling source code for debugging, the method comprising: receiving, by an optimizing compiler from a debugger, a variable value modification profile of the source code, the variable value modification profile specifying one or more locations in the source code at which variable values were modified during a debug session; compiling, by the optimizing compiler, the source code, including: inserting a plurality of snapshots including snapshots at one or more of the locations in the source code at which variable values were modified, each snapshot including a breakpoint; only for each snapshot at a location in the source code at which variable values were modified: inserting, between the breakpoint and the remaining source code at the location of the snapshot, a module of computer program instructions that when executed retrieves a current value of a variable and stores the current value in a register; and recording the location of each inserted snapshot; and providing, to the debugger by the optimizing compiler, the recorded locations of each inserted snapshot along with the compiled source code.