Project

General

Profile

Bug #339 ยป lttng.c

David Goulet, 09/17/2012 04:08 PM

 
#define _GNU_SOURCE
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <lttng/lttng.h>

int main(int argc, char **argv)
{
int ret;
struct lttng_handle *handle;
struct lttng_channel chan;
struct lttng_domain domain;

domain.type = LTTNG_DOMAIN_UST;

ret = lttng_create_session("mysession", "/tmp/mytraces");
if (ret < 0) {
fprintf(stderr, "Create session: %s", lttng_strerror(ret));
goto end;
}

handle = lttng_create_handle("mysession", &domain);
assert(handle);

strcpy(chan.name, "mychan");
chan.enabled = 1;

chan.attr.overwrite = 0;
chan.attr.subbuf_size = 1024;
chan.attr.num_subbuf = 2;
chan.attr.switch_timer_interval = 2000;
chan.attr.read_timer_interval = 0;
chan.attr.output = LTTNG_EVENT_MMAP;

ret = lttng_enable_channel(handle, &chan);
if (ret < 0) {
fprintf(stderr, "Enable channel: %s", lttng_strerror(ret));
goto end;
}

end:
return 0;
}
    (1-1/1)