From: Konstantin S. <kon...@gm...> - 2009-06-30 13:22:02
|
Hello, Valgrind developers. Currently, if memcheck is run on a program which is compiled with inlining enabled, the stack traces are not precise. Example: % cat inl_test.c #include <stdio.h> inline void foo(int *p) { if (*p == 777) printf("777\n"); } __attribute__ ((noinline)) void bar (int *p) { foo(p); } int main() { int uninitialized_stack[10]; bar(&uninitialized_stack[1]); return 0; } % gcc -g -O0 inl_test.c && ~/valgrind/trunk/inst/bin/valgrind -q ./a.out ==27322== Conditional jump or move depends on uninitialised value(s) ==27322== at 0x400523: foo (inl_test.c:4) ==27322== by 0x400545: bar (inl_test.c:9) ==27322== by 0x40055C: main (inl_test.c:14) % gcc -g -O2 inl_test.c && ~/valgrind/trunk/inst/bin/valgrind -q ./a.out ==27380== Conditional jump or move depends on uninitialised value(s) ==27380== at 0x400536: bar (inl_test.c:4) ==27380== by 0x40055D: main (inl_test.c:14) You can see that with -O0 the stack trace contains foo and with -O2 it doers not. But the DWARF info contains the information about inlining: % readelf -w a.out <1><421>: Abbrev Number: 14 (DW_TAG_subprogram) <422> DW_AT_external : 1 <423> DW_AT_name : foo ... <1><465>: Abbrev Number: 18 (DW_TAG_subprogram) <466> DW_AT_external : 1 <467> DW_AT_name : bar ... <2><492>: Abbrev Number: 20 (DW_TAG_inlined_subroutine) <493> DW_AT_abstract_origin: <421> <497> DW_AT_low_pc : 0x400530 <49f> DW_AT_high_pc : 0x40054a <4a7> DW_AT_call_file : 1 <4a8> DW_AT_call_line : 9 So, it is theoreticlally possible to produce a precise stack trace even in presence of inlining. Or I miss something? Shall I file a bug (feature request)? Thanks, --kcc |