[Dwarf-Discuss] Does gcc optimization impacts retriving Dwarf information?

Arnab Ganguly 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.
Thanks
-A

On Thu, May 28, 2009 at 2:22 PM, M. Mohan Kumar <mohan at in.ibm.com> wrote:

> Hi,
>
>
> 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
> the
> 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
> compiled
> 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
> arch/powerpc/platforms/pseries/setup.c:510
>        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:
> https://www.redhat.com/archives/crash-utility/2009-May/msg00012.html
> https://www.redhat.com/archives/crash-utility/2009-May/msg00013.html
> https://www.redhat.com/archives/crash-utility/2009-May/msg00014.html
> https://www.redhat.com/archives/crash-utility/2009-May/msg00015.html
>
> The location information is accessed in the function in variable_address in
> the file local.c
>
> Regards,
> M. Mohan Kumar
> _______________________________________________
> Dwarf-Discuss mailing list
> Dwarf-Discuss at lists.dwarfstd.org
> http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20090528/da60eeb9/attachment-0002.htm>


More information about the Dwarf-Discuss mailing list