#include "kernel-ctl.h"
#include "ltt-sessiond.h"
#include "shm.h"
-#include "traceable-app.h"
+#include "ust-app.h"
#include "ust-ctl.h"
#include "utils.h"
#include "ust-ctl.h"
}
DBG("Closing all UST sockets");
- clean_traceable_apps_list();
+ ust_app_clean_list();
pthread_mutex_destroy(&kconsumerd_pid_mutex);
while (1) {
if (update_poll_flag == 1) {
+ /*
+ * Reset number of fd in the poll set. Always 2 since there is the thread
+ * quit pipe and the kernel pipe.
+ */
+ events.nb_fd = 2;
+
ret = update_kernel_poll(&events);
if (ret < 0) {
goto error;
}
/* Register applicaton to the session daemon */
- ret = register_traceable_app(&ust_cmd.reg_msg,
+ ret = ust_app_register(&ust_cmd.reg_msg,
ust_cmd.sock);
if (ret < 0) {
/* Only critical ENOMEM error can be returned here */
* If the registration is not possible, we simply
* unregister the apps and continue
*/
- unregister_traceable_app(ust_cmd.sock);
+ ust_app_unregister(ust_cmd.sock);
} else {
/*
* We just need here to monitor the close of the UST
}
/* Socket closed */
- unregister_traceable_app(pollfd);
+ ust_app_unregister(pollfd);
break;
}
}
ret = mkdir_recursive(path, S_IRWXU | S_IRWXG, geteuid(), getegid());
if (ret < 0) {
+ PERROR("Cannot create debugfs path");
goto error;
}
ret = mount(type, path, type, 0, NULL);
if (ret < 0) {
- perror("mount debugfs");
+ PERROR("Cannot mount debugfs");
goto error;
}
}
ret = mount_debugfs(debugfs_path);
if (ret < 0) {
+ perror("Cannot mount debugfs");
goto error;
}
}
{
int ret;
struct ltt_ust_session *lus;
- struct ltt_traceable_app *app;
+ struct ust_app *app;
switch (domain->type) {
case LTTNG_DOMAIN_UST_PID:
- app = traceable_app_get_by_pid(domain->attr.pid);
+ app = ust_app_get_by_pid(domain->attr.pid);
if (app == NULL) {
ret = LTTCOMM_APP_NOT_FOUND;
goto error;
case LTTNG_KERNEL_SYSCALL:
events[i].type = LTTNG_EVENT_SYSCALL;
break;
+ case LTTNG_KERNEL_ALL:
+ assert(0);
+ break;
}
i++;
}
return ret;
}
+/*
+ * Copy channel from attributes and set it in the application channel list.
+ */
+static int copy_ust_channel_to_app(struct ltt_ust_session *usess,
+ struct lttng_channel *attr, struct ust_app *app)
+{
+ int ret;
+ struct ltt_ust_channel *uchan, *new_chan;
+
+ uchan = trace_ust_get_channel_by_name(attr->name, usess);
+ if (uchan == NULL) {
+ ret = LTTCOMM_FATAL;
+ goto error;
+ }
+
+ new_chan = trace_ust_create_channel(attr, usess->path);
+ if (new_chan == NULL) {
+ PERROR("malloc ltt_ust_channel");
+ ret = LTTCOMM_FATAL;
+ goto error;
+ }
+
+ ret = channel_ust_copy(new_chan, uchan);
+ if (ret < 0) {
+ ret = LTTCOMM_FATAL;
+ goto error;
+ }
+
+ /* Add channel to the ust app channel list */
+ cds_list_add(&new_chan->list, &app->channels.head);
+ app->channels.count++;
+
+error:
+ return ret;
+}
+
/*
* Command LTTNG_ENABLE_CHANNEL processed by the client thread.
*/
}
case LTTNG_DOMAIN_UST_PID:
{
- struct ltt_ust_event *uevent, *new_uevent;
+ int sock;
+ struct ltt_ust_channel *uchan;
struct ltt_ust_session *usess;
- struct ltt_ust_channel *uchan, *app_chan;
- struct ltt_traceable_app *app;
+ struct ust_app *app;
usess = trace_ust_get_session_by_pid(&session->ust_session_list,
domain->attr.pid);
goto error;
}
- app = traceable_app_get_by_pid(domain->attr.pid);
+ app = ust_app_get_by_pid(domain->attr.pid);
if (app == NULL) {
ret = LTTCOMM_APP_NOT_FOUND;
goto error;
}
+ sock = app->sock;
uchan = trace_ust_get_channel_by_name(attr->name, usess);
if (uchan == NULL) {
- ret = channel_ust_create(usess, attr, app->sock);
+ ret = channel_ust_create(usess, attr, sock);
} else {
- ret = channel_ust_enable(usess, uchan, app->sock);
+ ret = channel_ust_enable(usess, uchan, sock);
}
if (ret != LTTCOMM_OK) {
goto error;
}
- /*TODO: This should be put in an external function */
-
- /* Copy UST channel to add to the traceable app */
- uchan = trace_ust_get_channel_by_name(attr->name, usess);
- if (uchan == NULL) {
- ret = LTTCOMM_FATAL;
- goto error;
- }
-
- app_chan = trace_ust_create_channel(attr, session->path);
- if (app_chan == NULL) {
- PERROR("malloc ltt_ust_channel");
- ret = LTTCOMM_FATAL;
+ ret = copy_ust_channel_to_app(usess, attr, app);
+ if (ret != LTTCOMM_OK) {
goto error;
}
- memcpy(app_chan, uchan, sizeof(struct ltt_ust_channel));
- CDS_INIT_LIST_HEAD(&app_chan->events.head);
-
- cds_list_for_each_entry(uevent, &uchan->events.head, list) {
- new_uevent = malloc(sizeof(struct ltt_ust_event));
- if (new_uevent == NULL) {
- PERROR("malloc ltt_ust_event");
- ret = LTTCOMM_FATAL;
- goto error;
- }
-
- memcpy(new_uevent, uevent, sizeof(struct ltt_ust_event));
- cds_list_add(&new_uevent->list, &app_chan->events.head);
- app_chan->events.count++;
- }
-
- /* Add channel to traceable_app */
- cds_list_add(&app_chan->list, &app->channels.head);
- app->channels.count++;
-
DBG("UST channel %s created for app sock %d with pid %d",
attr->name, app->sock, domain->attr.pid);
break;
goto error;
}
- ret = event_kernel_disable(session->kernel_session, kchan, event_name);
+ ret = event_kernel_disable_tracepoint(session->kernel_session, kchan, event_name);
if (ret != LTTCOMM_OK) {
goto error;
}
goto error;
}
- ret = event_kernel_enable(session->kernel_session, kchan, event);
+ ret = event_kernel_enable_tracepoint(session->kernel_session, kchan, event);
if (ret != LTTCOMM_OK) {
goto error;
}
goto error;
}
- if (event_type == LTTNG_KERNEL_SYSCALL) {
- ret = event_kernel_enable_syscalls(session->kernel_session,
+ switch (event_type) {
+ case LTTNG_KERNEL_SYSCALL:
+ ret = event_kernel_enable_all_syscalls(session->kernel_session,
kchan, kernel_tracer_fd);
- } else {
+ break;
+ case LTTNG_KERNEL_TRACEPOINT:
/*
- * This call enables all LTTNG_KERNEL_TRACEPOINTS and events
- * already registered to the channel.
+ * This call enables all LTTNG_KERNEL_TRACEPOINTS and
+ * events already registered to the channel.
*/
+ ret = event_kernel_enable_all_tracepoints(session->kernel_session,
+ kchan, kernel_tracer_fd);
+ break;
+ case LTTNG_KERNEL_ALL:
+ /* Enable syscalls and tracepoints */
ret = event_kernel_enable_all(session->kernel_session,
kchan, kernel_tracer_fd);
+ break;
+ default:
+ ret = LTTCOMM_KERN_ENABLE_FAIL;
+ goto error;
}
-
if (ret != LTTCOMM_OK) {
goto error;
}
perror("write kernel poll pipe");
}
- ret = session_destroy(name);
+ ret = session_destroy(session);
return ret;
}