

The debugging data in ELF files follows DWARF format. Linux executables are in ELF file format. We will review a simple example program compiled into a Linux executable. Each such expression is valid only within a defined range of instruction pointer (aka program counter) values.īut let's get specific. One bit of such information is a table which specifies the expression which the debugger can use to obtain the value of a variable. How does it work?īinaries of executable formats contain special sections of information to facilitate debugging. This, in turn, brings a paradigm shift in troubleshooting workflow: the reverse debugging. With UDB (Undo's reverse debugger), you can examine the state of your process at any moment in time - at a granularity of single machine instruction. Of course you don't have to go backwards to reach your goal, but it is much more efficient in debugging practice. Naturally, when you step in the reverse direction, you can see how your optimized out value becomes reachable!


You can see this if you execute your program step by step, starting with the time when the variable is set, until some later time when its value becomes optimized out. In fact, even in an optimized build, you can see such values, but just for small amount of execution steps until these values are displaced from registers or memory by other values handled by the program later on. If you try to recover the value manually, you need to be fluent in assembly-level debugging, and then you just have a tedious and error-prone job to do, with chances of just not being able to gather enough data.įortunately, today there's a better option - process recording and reverse debugging! Just keep reversing
#Atollic truestudio turn off optimization code#
If you go for a rebuild, you throw away your current reproduced case (a core dump or a live process), spend time rebuilding the code (which can be a long open-ended journey), and then hope that your issue reproduces with debug-enabled binaries (some bugs become just not reproducible this way).
#Atollic truestudio turn off optimization manual#
try to recover the value by manual inspection of registers and memory contents.rebuild the code with optimizations disabled.This message is of course a legitimate outcome of compilers making our code efficient at runtime, and even in a perfect world, we are not going to get rid of this.īut what if you are debugging an issue right now, and desperately need to see the value? There are two well-known options, both with huge downsides: If you ever used a debugger, I bet you know how frequent, and how annoying "optimized out" messages are when you are looking for values of your variables.
