0

是否可以在没有 LD_PRELOADing liblttng-ust-cyg-profile 并使用 -finstrument-functions 编译的情况下从 lttng 获取回溯?

我无法从 lttng 代码中看到它在预加载该库以允许跟踪查看器(tracecompass)显示回溯时有什么不同!?

这是我的测试应用程序:

test_tracepoints.h:

#undef TRACEPOINT_PROVIDER
#define TRACEPOINT_PROVIDER test

#undef TRACEPOINT_INCLUDE
#define TRACEPOINT_INCLUDE "test_tracepoints.h"

#if !defined(TEST_TRACEPOINTS_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
#define TEST_TRACEPOINTS_H

#include <lttng/tracepoint.h>

TRACEPOINT_EVENT_CLASS(
    test,
    test_tc,
    TP_ARGS(const char *, str_arg, void *, func_addr),
    TP_FIELDS(ctf_integer_hex(unsigned long, addr, (unsigned long) func_addr)
              ctf_integer_hex(unsigned long, call_site, __builtin_return_address(0))
              ctf_string(str, str_arg)))

TRACEPOINT_EVENT_INSTANCE(
    test,
    test_tc,
    test_tp_start,
    TP_ARGS(const char *, str_arg, void *, func_addr))

TRACEPOINT_EVENT_INSTANCE(
    test,
    test_tc,
    test_tp_end,
    TP_ARGS(const char *, str_arg, void *, func_addr))

#endif

#include <lttng/tracepoint-event.h>

test_tracepoints.c:

#define TRACEPOINT_DEFINE
#define TRACEPOINT_CREATE_PROBES

#define TP_IP_PARAM func_addr

#include "test_tracepoints.h"

测试.lttng.c:

#include "test_tracepoints.h"

#include <unistd.h>

void f(useconds_t usec)
{
    const char * str = "f";
    tracepoint(test, test_tp_start, str, f);
    usleep(usec);
    tracepoint(test, test_tp_end, str, f);
}

int main()
{
    for (unsigned n = 0; n != 10000; ++n)
    {
        f(100);
        f(200);
    }

    return 0;
}

我正在测试这个:

gcc -O0 -g -fno-omit-frame-pointer -I . test_tracepoints.c test.lttng.c -o test.lttng -llttng-ust -ldl
lttng-sessiond --daemonize
lttng create -o lttng.session.test test
lttng enable-event -u -a
lttng add-context -s test -u -t procname -t vtid
lttng list test
lttng start test
./test.lttng
lttng destroy test
pkill lttng-sessiond
4

1 回答 1

1

不,目前不直接支持。但它绝对在愿望清单上。

当您预加载函数跟踪助手liblttng-ust-cyg-profile.so或其-fast版本)时,LTTng 事件会lttng_ust_cyg_profile在每个函数进入/退出时发出(以 为前缀)。您需要创建一个事件规则以显式启用它们:

lttng enable-event --userspace lttng_ust_cyg_profile'*'

不过,我不确定Trace Compass是否在其分析中使用了这些事件记录。

于 2016-11-30T14:14:54.380 回答