User guide
Variable Tracking at Assignments
59
Note
Not all documented characteristics will apply to all instances of GDB because it is still in active
development, and as such the capabilities vary (to some extent) depending on the platform and
target for which it is built.
5.3. Variable Tracking at Assignments
Variable Tracking at Assignments (VTA) is a new infrastructure included in GCC used to improve
variable tracking during optimizations. This allows GCC to produce more precise, meaningful, and
useful debugging information for GDB, SystemTap, and other debugging tools.
When GCC compiles code with optimizations enabled, variables are renamed, moved around, or even
removed altogether. As such, optimized compiling can cause a debugger to report that some variables
have been "optimized out". With VTA enabled, optimized code is internally annotated to ensure that
optimization passes to transparently keep track of each variable's value, regardless of whether the
variable is moved or removed.
VTA's benefits are more pronounced when debugging applications with inlined functions. Without
VTA, optimization could completely remove some arguments of an inlined function, preventing the
debugger from inspecting its value. With VTA, optimization will still happen, and appropriate debugging
information will be generated for any missing arguments.
VTA is enabled by default when compiling code with optimizations and debugging information enabled.
To disable VTA during such builds, add the -fno-var-tracking-assignments. In addition, the
VTA infrastructure includes the new gcc option -fcompare-debug. This option tests code compiled
by GCC with debug information and without debug information: the test passes if the two binaries
are identical. This test ensures that executable code is not affected by any debugging options, which
further ensures that there are no hidden bugs in the debug code. Note that -fcompare-debug adds
significant cost in compilation time. Refer to man gcc for details about this option.
For more information about the infrastructure and development of VTA, refer to A Plan to Fix Local
Variable Debug Information in GCC, available at the following link:
http://gcc.gnu.org/wiki/Var_Tracking_Assignments
A slide deck version of this whitepaper is also available at http://people.redhat.com/aoliva/papers/vta/
slides.pdf.
5.4. Python Pretty-Printers
The GDB command print outputs comprehensive debugging information for a target application.
GDB aims to provide as much debugging data as it can to users; however, this means that for highly
complex programs the amount of data can become very cryptic.
In addition, GDB does not provide any tools that help decipher GDB print output. GDB does not
even empower users to easily create tools that can help decipher program data. This makes the
practice of reading and understanding debugging data quite arcane, particularly for large, complex
projects.
For most developers, the only way to customize GDB print output (and make it more meaningful)
is to revise and recompile GDB. However, very few developers can actually do this. Further, this
practice will not scale well, particularly if the developer needs to also debug other programs that are
heterogenous and contain equally complex debugging data.