Now takes a session name and no lttng_handle anymore.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
/*
* 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.
/*
* 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);
}
/*
* 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);
}
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},
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;
}
free(session_name);
}
error:
- lttng_destroy_handle(handle);
-
return ret;
}
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},
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;
}
}
error:
- lttng_destroy_handle(handle);
-
return ret;
}
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;
}
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;
}
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;
}
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;
}