[lttng-dev] The problem with compiling multiple tracepoint sources with app directly

zhenyu.ren zhenyu.ren at aliyun.com
Mon Oct 28 21:50:05 EDT 2013


Hi,dev-list
   It seems work well if there is only one tracepoint file(sample_tracepoint.h) including in app .i.esample_tracepoint.h#undef TRACEPOINT_PROVIDER
#define TRACEPOINT_PROVIDER sample

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

#include <lttng/tracepoint.h>

TRACEPOINT_EVENT(
        sample,
        bytes_in, // C++ Style comment
        TP_ARGS(char *, text),
        TP_FIELDS(
                ctf_string(message, text)
                  )
)
#endif /* SAMPLE_TRACEPOINT_H */
#undef TRACEPOINT_INCLUDE
#define TRACEPOINT_INCLUDE "./sample_tracepoint.h"

#include <lttng/tracepoint-event.h>
sample.c#include <unistd.h>
#define TRACEPOINT_DEFINE
#define TRACEPOINT_CREATE_PROBES
#include "sample_tracepoint.h"
int main(int argc, char **argv)
{
        int i = 0;
        for (i = 0; i < 100000; i++) {
                tracepoint(sample, bytes_in,  "bytes in");
                sleep(1);
        }
        return 0;
}
compile: gcc -I. -o sample sample.c -ldl -llttng-ustHowever,If one more tracepoint include file(sample_tracepoint2.h) added in app,compile failed.sample_tracepoint2.h#undef TRACEPOINT_PROVIDER
#define TRACEPOINT_PROVIDER sample2
#if !defined(SAMPLE_TRACEPOINT2_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
#define SAMPLE_TRACEPOINT2_H

#include <lttng/tracepoint.h>

TRACEPOINT_EVENT(
        sample2,
        bytes_in, // C++ Style comment
        TP_ARGS(char *, text),
        TP_FIELDS(
                ctf_string(message, text)
                  )
)
#endif /* SAMPLE_TRACEPOINT2_H */
#undef TRACEPOINT_INCLUDE
#define TRACEPOINT_INCLUDE "./sample_tracepoint2.h"
#include <lttng/tracepoint-event.h>
sample.c#include <unistd.h>
#define TRACEPOINT_DEFINE
#define TRACEPOINT_CREATE_PROBES
#include "sample_tracepoint.h"
#include "sample_tracepoint2.h"

int main(int argc, char **argv)
{
        int i = 0;
        for (i = 0; i < 100000; i++) {
                tracepoint(sample, bytes_in,  "bytes in");
                tracepoint(sample2, bytes_in,  "bytes in");
                sleep(1);
        }
        return 0;
}
compile:gcc -I. -o sample sample.c -ldl -llttng-ustsample.c: In function˜main:
sample.c:12: error: __tracepoint_sample2___bytes_in undeclared (first use in this function)
sample.c:12: error: (Each undeclared identifier is reported only once
sample.c:12: error: for each function it appears in.)   Does LTTng support compiling multiple tracepoint sources with app directly?   Yes,I can compile multiple tracepoint providers to share libs and link them to app through TRACEPOINT_PROBE_DYNAMIC_LINKAGE  such as what doc/examples/demo does. Thankszhenyu.ren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20131029/4548ea9e/attachment-0001.html>


More information about the lttng-dev mailing list