[Dwarf-Discuss] Does gcc optimization impacts retriving Dwarf information?
aganguly01 at gmail.com
Thu May 28 03:03:38 PDT 2009
Compiler optimization will have impact on variables (volatile non volatile),
inline functions etc... for reference take a look on the various gcc
compiler options hence DWARF result will be impacted.Best is propose a
standard compiler settings across all the builds to get equivalent
traces.Also try out the dwarfdump tool and verify the output generated when
the compiler settings are being changed.
On Thu, May 28, 2009 at 2:22 PM, M. Mohan Kumar <mohan at in.ibm.com> wrote:
> We are implementing a feature in the crash utility to display the
> information about local variables for a selected stack frame in a kernel
> crash dump.
> Even though we could retrive the local variable information (like variable
> name, type), most of the time we were not able to retrive the values for
> variables. The dwarf library function 'dwarf_attr_integrate'
> (dwarf_attr_integrate(var_die, DW_AT_location, &loc_attr)) returns error.
> The kernel is compiled with -O2 option. We tested this case with gdb, gdb
> prints 'optimized out' for most of the local variables.
> We tried testing this functionality in a user space application. We
> a program using -O0 and -O2 and generated dumps core.o0 and core.o2. While
> we could watch the local variables values using core.o0, we could not get
> the variables value using core.o2. Does it mean that compiling with -O2
> option removes some of the information needed by DWARF library functions?
> A sample output from our crash extension local:
> crash> local locals
> display locals for function .pseries_dedicated_idle_sleep
> cpu unsigned int
> start_snooze long unsigned int value:1
> in_purr long unsigned int
> out_purr long unsigned int
> In above output, we could retrieve value for 'start_snooze' variable only,
> for all other variables some of the dwarf APIs fail.
> When checked with gdb,
> (gdb) bt full
> #0 0xc00000000003b118 in pseries_dedicated_idle_sleep () at
> cpu = <value optimized out>
> start_snooze = 1
> This problem (unable to retrieve variable values) raises two questions:
> 1. Does it mean that compiling with -O2 option removes some of the
> information needed by DWARF library functions?
> 2. Does it require handling it differently in our implementation?
> Patch url:
> The location information is accessed in the function in variable_address in
> the file local.c
> M. Mohan Kumar
> Dwarf-Discuss mailing list
> Dwarf-Discuss at lists.dwarfstd.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Dwarf-Discuss