libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libunwind-devel] Unwinding and inline functions


From: Milian Wolff
Subject: Re: [Libunwind-devel] Unwinding and inline functions
Date: Tue, 31 May 2016 14:14:06 +0200
User-agent: KMail/5.2.66 (Linux/4.5.4-1-ARCH; KDE/5.22.0; x86_64; git-f93c931; 2016-05-24)

On Tuesday, May 31, 2016 11:27:46 AM CEST Milian Wolff wrote:
> Hey all,
> 
> Can libunwind be configured to include "fake" frames from debug information
> in the face of inlined functions? Meaning for code like this:
> 
> ~~~~
> #define forceinline inline __attribute__((always_inline))
> 
> forceinline void asdf()
> {
>     new int[123];
> }
> 
> forceinline void bar()
> {
>     asdf();
> }
> 
> forceinline void foo()
> {
>     bar();
> }
> 
> int main()
> {
>     foo();
>     return 0;
> }
> ~~~~
> 
> If I now use my heaptrack tool to grab a backtrace with libunwind on the
> memory allocation, I'll see the following for an optimized build:
> 
> g++ -O3 -flto -ggdb3 inlining.cpp
> 
> main
>   at /home/milian/projects/src/heaptrack/tests/manual/inlining.cpp:20
>   in /ssd/milian/projects/build/heaptrack/a.out
> 
> GDB is capable of giving me a much more useful backtrace:
> 
> ~~~~
> Breakpoint 3, 0x00007ffff720f180 in malloc () from /usr/lib/libc.so.6
> (gdb) bt
> #0  0x00007ffff720f180 in malloc () from /usr/lib/libc.so.6
> #1  0x00007ffff7ae1968 in operator new (sz=492) at /build/gcc-multilib/src/
> gcc/libstdc++-v3/libsupc++/new_op.cc:50
> #2  0x000000000040050e in asdf () at /home/milian/projects/src/heaptrack/
> tests/manual/inlining.cpp:5
> #3  bar () at
> /home/milian/projects/src/heaptrack/tests/manual/inlining.cpp:10 #4  foo ()
> at /home/milian/projects/src/heaptrack/tests/manual/inlining.cpp:15 #5 
> main () at /home/milian/projects/src/heaptrack/tests/manual/inlining.cpp:
> 20
> ~~~~
> 
> Can I configure libunwind to give me an equivalent backtrace? If not, does
> someone know if the unwinding method of GDB is accessible to third-parties
> as a library?

Thinking more about this, I now believe that this lies outside of libunwind's 
scope. A secondary library, like libdw(fl) or libbacktrace should in theory be 
able to expand the minimal backtrace from libunwind with the inlined frames. 
Now I just need to figure out how this can be done :)

Cheers

-- 
Milian Wolff
address@hidden
http://milianw.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]