The GDB tool bar shares many buttons with the other GUD debuggers for tasks like stepping and printing expressions. It also has a further set of buttons that allow reverse debugging (see). This is useful when it takes a long time to reproduce the conditions where your program fails or for transient problems, like race conditions in multi-threaded programs, where a failure might otherwise be hard to reproduce.
To use reverse debugging, set a breakpoint slightly before the location of interest and run your program to that point. Enable process recording by clicking on the record button. At this point, a new set of buttons appear. These buttons allow program execution in the reverse direction. Run your program over the code where the problem occurs, and then use the new set of buttons to retrace your steps, examine values, and analyze the problem. When analysis is complete, turn off process recording by clicking on the record button again.blog comments powered by Disqus