是否可以在没有 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