From 6a4f824d3317497f00cd7065ab9905fbb86ea58f Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 6 Dec 2011 14:50:18 -0500 Subject: [PATCH] API change for lttng_start/stop_tracing prototype Now takes a session name and no lttng_handle anymore. Signed-off-by: David Goulet --- include/lttng/lttng.h | 4 ++-- liblttngctl/lttngctl.c | 18 +++++++++++------- lttng/commands/start.c | 12 +----------- lttng/commands/stop.c | 12 +----------- tests/lttng/kernel_all_events_basic.c | 4 ++-- tests/lttng/kernel_event_basic.c | 4 ++-- 6 files changed, 19 insertions(+), 35 deletions(-) diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 5654eb79f..bfe2cc5c3 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -314,12 +314,12 @@ extern int lttng_register_consumer(struct lttng_handle *handle, /* * Start tracing for *all* registered trace (kernel and user-space). */ -extern int lttng_start_tracing(struct lttng_handle *handle); +extern int lttng_start_tracing(const char *session_name); /* * Stop tracing for *all* registered trace (kernel and user-space). */ -extern int lttng_stop_tracing(struct lttng_handle *handle); +extern int lttng_stop_tracing(const char *session_name); /* * Add context to event for a specific channel. diff --git a/liblttngctl/lttngctl.c b/liblttngctl/lttngctl.c index 48e82def7..ed685966e 100644 --- a/liblttngctl/lttngctl.c +++ b/liblttngctl/lttngctl.c @@ -425,17 +425,17 @@ int lttng_register_consumer(struct lttng_handle *handle, /* * Start tracing for all trace of the session. */ -int lttng_start_tracing(struct lttng_handle *handle) +int lttng_start_tracing(const char *session_name) { struct lttcomm_session_msg lsm; - if (handle == NULL) { + if (session_name == NULL) { return -1; } lsm.cmd_type = LTTNG_START_TRACE; - copy_string(lsm.session.name, handle->session_name, - sizeof(lsm.session.name)); + + copy_string(lsm.session.name, session_name, sizeof(lsm.session.name)); return ask_sessiond(&lsm, NULL); } @@ -443,13 +443,17 @@ int lttng_start_tracing(struct lttng_handle *handle) /* * Stop tracing for all trace of the session. */ -int lttng_stop_tracing(struct lttng_handle *handle) +int lttng_stop_tracing(const char *session_name) { struct lttcomm_session_msg lsm; + if (session_name == NULL) { + return -1; + } + lsm.cmd_type = LTTNG_STOP_TRACE; - copy_string(lsm.session.name, handle->session_name, - sizeof(lsm.session.name)); + + copy_string(lsm.session.name, session_name, sizeof(lsm.session.name)); return ask_sessiond(&lsm, NULL); } diff --git a/lttng/commands/start.c b/lttng/commands/start.c index 312e94ed2..2eacc462f 100644 --- a/lttng/commands/start.c +++ b/lttng/commands/start.c @@ -35,8 +35,6 @@ enum { OPT_HELP = 1, }; -static struct lttng_handle *handle; - static struct poptOption long_options[] = { /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, @@ -77,15 +75,9 @@ static int start_tracing(void) session_name = opt_session_name; } - handle = lttng_create_handle(session_name, NULL); - if (handle == NULL) { - ret = -1; - goto error; - } - DBG("Starting tracing for session %s", session_name); - ret = lttng_start_tracing(handle); + ret = lttng_start_tracing(session_name); if (ret < 0) { goto free_name; } @@ -97,8 +89,6 @@ free_name: free(session_name); } error: - lttng_destroy_handle(handle); - return ret; } diff --git a/lttng/commands/stop.c b/lttng/commands/stop.c index b40a63881..f1299b5bc 100644 --- a/lttng/commands/stop.c +++ b/lttng/commands/stop.c @@ -35,8 +35,6 @@ enum { OPT_HELP = 1, }; -static struct lttng_handle *handle; - static struct poptOption long_options[] = { /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, @@ -75,13 +73,7 @@ static int stop_tracing(void) session_name = opt_session_name; } - handle = lttng_create_handle(session_name, NULL); - if (handle == NULL) { - ret = -1; - goto error; - } - - ret = lttng_stop_tracing(handle); + ret = lttng_stop_tracing(session_name); if (ret < 0) { goto free_name; } @@ -94,8 +86,6 @@ free_name: } error: - lttng_destroy_handle(handle); - return ret; } diff --git a/tests/lttng/kernel_all_events_basic.c b/tests/lttng/kernel_all_events_basic.c index eb46decae..fd3926d1f 100644 --- a/tests/lttng/kernel_all_events_basic.c +++ b/tests/lttng/kernel_all_events_basic.c @@ -77,7 +77,7 @@ int main(int argc, char **argv) PRINT_OK(); printf("Start tracing: "); - if ((ret = lttng_start_tracing(handle)) < 0) { + if ((ret = lttng_start_tracing("test")) < 0) { printf("error starting tracing: %s\n", lttng_strerror(ret)); goto start_fail; } @@ -86,7 +86,7 @@ int main(int argc, char **argv) sleep(2); printf("Stop tracing: "); - if ((ret = lttng_stop_tracing(handle)) < 0) { + if ((ret = lttng_stop_tracing("test")) < 0) { printf("error stopping tracing: %s\n", lttng_strerror(ret)); goto stop_fail; } diff --git a/tests/lttng/kernel_event_basic.c b/tests/lttng/kernel_event_basic.c index d45b5e4f9..b33f691fd 100644 --- a/tests/lttng/kernel_event_basic.c +++ b/tests/lttng/kernel_event_basic.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) PRINT_OK(); printf("Start tracing: "); - if ((ret = lttng_start_tracing(handle)) < 0) { + if ((ret = lttng_start_tracing(session_name)) < 0) { printf("error starting tracing: %s\n", lttng_strerror(ret)); goto start_fail; } @@ -153,7 +153,7 @@ int main(int argc, char **argv) sleep(2); printf("Stop tracing: "); - if ((ret = lttng_stop_tracing(handle)) < 0) { + if ((ret = lttng_stop_tracing(session_name)) < 0) { printf("error stopping tracing: %s\n", lttng_strerror(ret)); goto stop_fail; } -- 2.34.1