Preliminary work for full UST support
[lttng-tools.git] / ltt-sessiond / event.c
index e8f54504cd1c7081e0b8fcce8fa5cec8a1075e70..1f90c1c73069d97c520d2c8670ef12fe7dd68c64 100644 (file)
  * Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#include <errno.h>
 #include <urcu/list.h>
+#include <string.h>
 
 #include <lttng/lttng.h>
 #include <lttng-sessiond-comm.h>
 #include <lttngerr.h>
 
+#ifdef CONFIG_LTTNG_TOOLS_HAVE_UST
+#include <ust/lttng-ust-ctl.h>
+#else
+#include "lttng-ust-ctl.h"
+#endif
+
 #include "channel.h"
 #include "event.h"
+#include "hashtable.h"
 #include "kernel-ctl.h"
 
 /*
@@ -127,7 +136,11 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession,
        if (kevent == NULL) {
                ret = kernel_create_event(event, kchan);
                if (ret < 0) {
-                       ret = LTTCOMM_KERN_ENABLE_FAIL;
+                       if (ret == -EEXIST) {
+                               ret = LTTCOMM_KERN_EVENT_EXIST;
+                       } else {
+                               ret = LTTCOMM_KERN_ENABLE_FAIL;
+                       }
                        goto end;
                }
        } else if (kevent->enabled == 0) {
@@ -224,3 +237,60 @@ int event_kernel_enable_all(struct ltt_kernel_session *ksession,
 end:
        return ret;
 }
+
+/*
+ * Enable UST tracepoint event for a channel from a UST session.
+ */
+#ifdef DISABLE
+int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
+{
+       int ret;
+       struct lttng_ust_event ltt_uevent;
+       struct object_data *obj_event;
+
+       strncpy(ltt_uevent.name, uevent->attr.name, sizeof(ltt_uevent.name));
+       ltt_uevent.name[sizeof(ltt_uevent.name) - 1] = '\0';
+       /* TODO: adjust to other instrumentation types */
+       ltt_uevent.instrumentation = LTTNG_UST_TRACEPOINT;
+
+       ret = ustctl_create_event(app->key.sock, &ltt_uevent,
+                       uchan->obj, &obj_event);
+       if (ret < 0) {
+               DBG("Error ustctl create event %s for app pid: %d, sock: %d ret %d",
+                               uevent->attr.name, app->key.pid, app->key.sock, ret);
+               goto next;
+       }
+
+       uevent->obj = obj_event;
+       uevent->handle = obj_event->handle;
+       uevent->enabled = 1;
+       ret = LTTCOMM_OK;
+end:
+       return ret;
+}
+#endif
+
+#ifdef DISABLE
+int event_ust_disable_tracepoint(struct ltt_ust_session *ustsession,
+               struct ltt_ust_channel *ustchan, char *event_name)
+{
+       int ret;
+       struct ltt_ust_event *ustevent;
+
+       ustevent = trace_ust_find_event_by_name(ustchan->events, event_name);
+       if (ustevent == NULL) {
+               ret = LTTCOMM_NO_EVENT;
+               goto end;
+       }
+       //ret = ustctl_disable(ustsession->sock, ustevent->obj);
+       if (ret < 0) {
+               ret = LTTCOMM_UST_ENABLE_FAIL;
+               goto end;
+       }
+       ustevent->enabled = 0;
+       ret = LTTCOMM_OK;
+end:
+       return ret;
+}
+#endif
This page took 0.023826 seconds and 4 git commands to generate.