[lttng-dev] Userspace Tracing and Backtraces

Francis Giraldeau francis.giraldeau at gmail.com
Fri Mar 6 10:12:49 EST 2015


2015-03-05 17:39 GMT-05:00 Brian Robbins <brianrob at microsoft.com>:

>  Hello,
>
>
>
> I’m looking into using the userspace tracing capabilities of LTTng, and I
> wanted to find out if it is possible to capture a stack backtrace when a
> userspace tracepoint is hit.
>


The simple way is to use a tracepoint, where there is an array of
addresses. Symbols resolution can be done offline using the baddr events
indicating the address of shared libraries, and using libdwarf to parse
ELF.

To get the actual backtrace, you can use either frame pointers, but most
linux distributions compiles with -fomit-frame-pointers, and then this
method does not work (even of your own program is compiled with
-fno-omit-frame-pointer, a shared library, like libc, without frame pointer
in the middle of the stack does break the frame chain). Then, stack unwind
(using libunwind for instance) is necessary.

It could be nice to add such feature an event context to lttng-ust, it
would allow to record the ELF callstack for any userspace event. The
question is whether doing the unwind online (but it is quite costly in
time), or do it offline, like perf is doing, by recording 2 pages of the
stack with registers (but records much more data, and may not work if there
are large variables on the stack, and requires additional support for JIT
code).

Cheers,

Francis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150306/94dae305/attachment.html>


More information about the lttng-dev mailing list