extern void lttng_set_current_session_uuid(char *uuid);
extern int lttng_ust_create_trace(pid_t pid);
extern int lttng_ust_start_trace(pid_t pid);
+extern int lttng_ust_stop_trace(pid_t pid);
#endif /* _LIBLTTNGCTL_H */
return ret;
}
+/*
+ * lttng_ust_stop_trace
+ *
+ * Request a trace stop for pid.
+ */
+int lttng_ust_stop_trace(pid_t pid)
+{
+ int ret;
+
+ lsm.pid = pid;
+ ret = ask_sessiond(UST_STOP_TRACE, NULL);
+
+ return ret;
+}
+
/*
* lttng_ust_create_trace
*
[ LTTCOMM_ERR_INDEX(LTTCOMM_FATAL) ] = "Fatal error of the session daemon",
[ LTTCOMM_ERR_INDEX(LTTCOMM_CREATE_FAIL) ] = "Create trace failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_START_FAIL) ] = "Start trace failed",
+ [ LTTCOMM_ERR_INDEX(LTTCOMM_STOP_FAIL) ] = "Stop trace failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_NO_TRACEABLE) ] = "App is not traceable",
[ LTTCOMM_ERR_INDEX(LTTCOMM_SELECT_SESS) ] = "A session MUST be selected",
[ LTTCOMM_ERR_INDEX(LTTCOMM_EXIST_SESS) ] = "Session name already exist",
LTTCOMM_CREATE_FAIL, /* Create trace fail */
LTTCOMM_SESSION_FAIL, /* Create session fail */
LTTCOMM_START_FAIL, /* Start tracing fail */
+ LTTCOMM_STOP_FAIL, /* Stop tracing fail */
LTTCOMM_LIST_FAIL, /* Listing apps fail */
LTTCOMM_NO_APPS, /* No traceable application */
LTTCOMM_NO_SESS, /* No sessions available */
return ret;
}
+/*
+ * ust_stop_trace
+ *
+ * Stop a trace. This trace, identified by the pid, must be
+ * in the current session ust_traces list.
+ */
+static int ust_stop_trace(pid_t pid)
+{
+ int sock, ret;
+ struct ltt_ust_trace *trace;
+
+ DBG("Stopping trace for pid %d", pid);
+
+ trace = find_session_ust_trace_by_pid(current_session, pid);
+ if (trace == NULL) {
+ ret = LTTCOMM_NO_TRACE;
+ goto error;
+ }
+
+ /* Connect to app using ustctl API */
+ sock = connect_app(pid);
+ if (sock < 0) {
+ ret = LTTCOMM_NO_TRACEABLE;
+ goto error;
+ }
+
+ ret = ustctl_stop_trace(sock, trace->name);
+ if (ret < 0) {
+ ret = LTTCOMM_STOP_FAIL;
+ goto error;
+ }
+
+error:
+ return ret;
+}
+
/*
* copy_common_data
*
/* No auxiliary data so only send the llm struct. */
goto end;
}
+ case UST_STOP_TRACE:
+ {
+ ret = ust_stop_trace(lsm->pid);
+
+ /* No auxiliary data so only send the llm struct. */
+ goto end;
+ }
case LTTNG_LIST_SESSIONS:
{
unsigned int session_count = get_session_count();
MSG("Trace started successfully!");
}
+ if (opt_stop_trace) {
+ DBG("Stop trace for pid %d", opt_stop_trace);
+ ret = lttng_ust_stop_trace(opt_stop_trace);
+ if (ret < 0) {
+ goto end;
+ }
+ MSG("Trace stopped successfully!");
+ }
+
return 0;
end:
extern int opt_list_traces;
extern pid_t opt_create_trace;
extern pid_t opt_start_trace;
+extern pid_t opt_stop_trace;
#endif /* _LTTNG_H */
int opt_list_traces = 0;
pid_t opt_create_trace = 0;
pid_t opt_start_trace = 0;
+pid_t opt_stop_trace = 0;
enum {
OPT_HELP = 42,
{"session", 's', POPT_ARG_STRING, &opt_session_uuid, 0, 0, 0},
{"sessiond-path", 0, POPT_ARG_STRING, &opt_sessiond_path, 0, 0, 0},
{"start", 0, POPT_ARG_INT, &opt_start_trace, 0, 0, 0},
+ {"stop", 0, POPT_ARG_INT, &opt_stop_trace, 0, 0, 0},
{"verbose", 'v', POPT_ARG_VAL, &opt_verbose, 1, 0, 0},
//{"session", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_session_name, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
fprintf(ofp, " -t, --list-traces List session's traces. Use -s to specify the session\n");
fprintf(ofp, " -C, --create-trace PID Create trace for PID\n");
fprintf(ofp, " --start PID Start trace for PID\n");
+ fprintf(ofp, " --stop PID Stop trace for PID\n");
fprintf(ofp, "\n");
fprintf(ofp, "Please see the lttng(1) man page for full documentation.\n");
fprintf(ofp, "See http://lttng.org/ust for updates, bug reports and news.\n");