Sgenmi / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[arm] not able to se caller information (stacktrace is never longer than 1 frame) #572

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am running google cpu profiler latest version (2.1) on linux AM3517 ARM 
Cortex A8 processor. 
The binary prof file  seems to be created correctly. Anyway decoding it I don't 
see any caller information in the kcachegrind call graph window (please see 
attached ).
For compiling the gperftool sources I used: 
./configure --enable-frame-pointers --host=arm-none-linux-gnueabi- 
The binary I want to profile is also compiled with no omit frame pointer flag. 

Thanks. 

Original issue reported on code.google.com by bontamar...@gmail.com on 18 Sep 2013 at 12:20

Attachments:

GoogleCodeExporter commented 9 years ago
It would be useful to know your exact steps. Also have you tried pprof to 
output graph or something similar ?

Original comment by alkondratenko on 18 Sep 2013 at 4:54

GoogleCodeExporter commented 9 years ago
1. I decoded the binary prof file using --callgrind option.
pprof --lib_prefix=/home/marian/work/sitarafs_for_flashing/ --callgrind 
sitara_debug/cpp/Engine/engine.so streamer.prof > targetProf

2. I tried to visualize the call graph using kcachegrind but it does not 
display any caller info. 
kcachegrind targetProf (please see the attached picture from the last comment )

Trying to decode the binary prof file I get the same result. I have the feeling 
that libprof does not know to parse the entire stack (this is why I specified 
that I used no omit frame pointer flag) .

Original comment by bontamar...@gmail.com on 18 Sep 2013 at 5:35

GoogleCodeExporter commented 9 years ago
I'm seeing exactly same issue. Even with -fno-omit-frame-pointer.

However the following patch enables use of libunwind and make it work for me:

diff --git a/src/stacktrace_config.h b/src/stacktrace_config.h
index 787cdd2..26a7433 100644
--- a/src/stacktrace_config.h
+++ b/src/stacktrace_config.h
@@ -68,6 +68,10 @@
 #   define STACKTRACE_INL_HEADER "stacktrace_generic-inl.h"
 # endif

+# elif defined(HAVE_LIBUNWIND_H)  // a proxy for having libunwind installed
+#   define STACKTRACE_INL_HEADER "stacktrace_libunwind-inl.h"
+#   define STACKTRACE_USES_LIBUNWIND 1
+
 // The ARM case
 #elif defined(__arm__)  && __GNUC__ >= 2
 # if !defined(NO_FRAME_POINTER)

I have plans to make stacktrace backends pluggable at runtime which will enable 
libunwind option on arm too. For now try with libunwind and patch above

Original comment by alkondratenko on 21 Sep 2013 at 7:17

GoogleCodeExporter commented 9 years ago
Thanks for the fix but it seems that when trying to use libunwind the gpertools 
is crashing when UNW_ARM_UNWIND_METHOD>1. When UNW_ARM_UNWIND_METHOD is set to 
one i get
the same result I get when I don;t use libunwind (no caller info). 

/tmp/sharedobject.7mxTSZ/engine.so(_ZN2OS9BacktraceC1Ev+0x20)[0x4079f784]
/tmp/sharedobject.7mxTSZ/engine.so(_ZN2OS11CrashReport13signalHandlerEi+0x5c)[0x
40815188]
/lib/libc.so.6(__default_sa_restorer_v2+0x0)[0x4014c610]
/usr/lib/libunwind.so.8[0x40957684]
/usr/lib/libunwind.so.8(_ULarm_is_signal_frame+0x70)[0x4095970c]
/usr/lib/libunwind.so.8(_ULarm_step+0xdc)[0x4095b3ec]
/usr/lib/libprofiler.so.0(_Z24GetStackTraceWithContextPPviiPKv+0x254)[0x409319dc
]
/usr/lib/libprofiler.so.0(_ZN11CpuProfiler12prof_handlerEiP7siginfoPvS2_+0xa8)[0
x4092c764]

Original comment by bontamar...@gmail.com on 25 Sep 2013 at 4:34

GoogleCodeExporter commented 9 years ago
Ok,

Finally, I succeeded to make it work changing stacktrace_config.h in this way:

// The ARM case
#elif defined(__arm__)  && __GNUC__ >= 2
# if !defined(NO_FRAME_POINTER)
#   define STACKTRACE_INL_HEADER "stacktrace_arm-inl.h"
# elif defined(HAVE_LIBUNWIND_H)  // a proxy for having libunwind installed
#   define STACKTRACE_INL_HEADER "stacktrace_arm-inl.h"
#   define STACKTRACE_USES_LIBUNWIND 1
# else
#   error stacktrace without frame pointer is not supported on ARM
# endif

Thank you very much for your support. 

Original comment by bontamar...@gmail.com on 25 Sep 2013 at 5:04

GoogleCodeExporter commented 9 years ago
Issue 590 has been merged into this issue.

Original comment by alkondratenko on 22 Nov 2013 at 6:24

GoogleCodeExporter commented 9 years ago
Hi everybody,
I have the same problem executing gperftool (the generated graph doesn't show 
the caller to callee relations). 
If I understand, the solution is compiling with frame pointer and LIBUNWIND 
enabled. Is this the only way to fix the issue? I had some problem compiling 
LIBUNWIND... 
Regards

Original comment by aldobiziak on 25 Nov 2013 at 4:05

GoogleCodeExporter commented 9 years ago
It's possible that arm "native" backtrace capturing code is subtly or even not 
so subtly broken.

I'd suggest the following:

* see if you can bisect for a change that broke it

* see if it differs from backtracing in other notable code bases. E.g. android.

Original comment by alkondratenko on 26 Nov 2013 at 10:57

GoogleCodeExporter commented 9 years ago
Ok, thank you alkondratenko, I'll try to do what you suggested. Regards

Original comment by aldobiziak on 27 Nov 2013 at 10:04