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>
34 int main(int argc
, char **argv
)
36 struct lttng_handle
*handle
= NULL
;
37 struct lttng_domain dom
;
38 struct lttng_event event
, ev2
;
39 char *channel_name
= "channel0";
40 char *channel_name2
= "channel2";
41 char *session_name
= "ust_global_all_events_basic";
44 memset(&dom
, 0, sizeof(dom
));
45 memset(&event
, 0, sizeof(event
));
46 memset(&ev2
, 0, sizeof(ev2
));
48 dom
.type
= LTTNG_DOMAIN_UST
;
50 event
.type
= LTTNG_EVENT_TRACEPOINT
;
51 event
.loglevel_type
= LTTNG_EVENT_LOGLEVEL_ALL
;
52 strcpy(event
.name
, "*");
54 ev2
.type
= LTTNG_EVENT_TRACEPOINT
;
55 ev2
.loglevel_type
= LTTNG_EVENT_LOGLEVEL_RANGE
;
56 ev2
.loglevel
= LTTNG_LOGLEVEL_NOTICE
;
57 strcpy(ev2
.name
, "abc*");
59 printf("\nTesting tracing all UST events:\n");
60 printf("-----------\n");
63 printf("Missing session trace path\n");
67 printf("Creating tracing session (%s): ", argv
[1]);
68 if ((ret
= lttng_create_session(session_name
, argv
[1])) < 0) {
69 printf("error creating the session : %s\n", lttng_strerror(ret
));
74 printf("Creating session handle: ");
75 if ((handle
= lttng_create_handle(session_name
, &dom
)) == NULL
) {
76 printf("error creating handle: %s\n", lttng_strerror(ret
));
81 printf("Enabling '*' UST events: ");
82 if ((ret
= lttng_enable_event(handle
, &event
, channel_name
)) < 0) {
83 printf("error enabling event: %s\n", lttng_strerror(ret
));
88 printf("Enabling 'abc*' UST events: ");
89 if ((ret
= lttng_enable_event(handle
, &ev2
, channel_name2
)) < 0) {
90 printf("error enabling event: %s\n", lttng_strerror(ret
));
95 printf("Start tracing: ");
96 if ((ret
= lttng_start_tracing(session_name
)) < 0) {
97 printf("error starting tracing: %s\n", lttng_strerror(ret
));
104 printf("Stop tracing: ");
105 if ((ret
= lttng_stop_tracing(session_name
)) < 0) {
106 printf("error stopping tracing: %s\n", lttng_strerror(ret
));
111 printf("Destroy tracing session: ");
112 if ((ret
= lttng_destroy_session(session_name
)) < 0) {
113 printf("error destroying session: %s\n", lttng_strerror(ret
));
120 assert(handle
!= NULL
);
127 lttng_destroy_session(session_name
);
128 lttng_destroy_handle(handle
);