2 * Copyright (c) 2011 David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <lttng/lttng.h>
32 int main(int argc
, char **argv
)
34 struct lttng_handle
*handle
= NULL
;
35 struct lttng_domain dom
;
36 struct lttng_event event
;
37 char *channel_name
= "channel0";
40 dom
.type
= LTTNG_DOMAIN_KERNEL
;
42 memset(&event
, 0, sizeof(struct lttng_event
));
43 event
.type
= LTTNG_EVENT_TRACEPOINT
;
45 printf("\nTesting tracing all kernel events:\n");
46 printf("-----------\n");
49 printf("Root access is needed.\nPlease run 'sudo make check' -- Aborting!\n");
54 printf("Missing session trace path\n");
58 printf("Creating tracing session (%s): ", argv
[1]);
59 if ((ret
= lttng_create_session("test", argv
[1])) < 0) {
60 printf("error creating the session : %s\n", lttng_strerror(ret
));
65 printf("Creating session handle: ");
66 if ((handle
= lttng_create_handle("test", &dom
)) == NULL
) {
67 printf("error creating handle: %s\n", lttng_strerror(ret
));
72 printf("Enabling all kernel events: ");
73 if ((ret
= lttng_enable_event(handle
, &event
, channel_name
)) < 0) {
74 printf("error enabling event: %s\n", lttng_strerror(ret
));
79 printf("Start tracing: ");
80 if ((ret
= lttng_start_tracing("test")) < 0) {
81 printf("error starting tracing: %s\n", lttng_strerror(ret
));
88 printf("Stop tracing: ");
89 if ((ret
= lttng_stop_tracing("test")) < 0) {
90 printf("error stopping tracing: %s\n", lttng_strerror(ret
));
95 printf("Destroy tracing session: ");
96 if ((ret
= lttng_destroy_session("test")) < 0) {
97 printf("error destroying session: %s\n", lttng_strerror(ret
));
106 assert(handle
!= NULL
);
111 lttng_destroy_session("test");
112 lttng_destroy_handle(handle
);
This page took 0.034067 seconds and 4 git commands to generate.