Fix: sym name len (kernel)
[lttng-tools.git] / src / bin / lttng-sessiond / trace-kernel.c
index 990684be918db721a36b8265813b4d8bdcb38cb7..a5c215fae98a068f359c0bf182e307a693dc9244 100644 (file)
@@ -38,6 +38,13 @@ struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
        assert(session);
        assert(name);
 
+       /*
+        * If we receive an empty string for channel name, it means the
+        * default channel name is requested.
+        */
+       if (name[0] == '\0')
+               name = DEFAULT_CHANNEL_NAME;
+
        DBG("Trying to find channel %s", name);
 
        cds_list_for_each_entry(chan, &session->channel_list.head, list) {
@@ -77,7 +84,7 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(
  *
  * Return pointer to structure or NULL.
  */
-struct ltt_kernel_session *trace_kernel_create_session(char *path)
+struct ltt_kernel_session *trace_kernel_create_session(void)
 {
        struct ltt_kernel_session *lks = NULL;
 
@@ -109,25 +116,6 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path)
         */
        lks->tmp_consumer = NULL;
 
-       if (*path != '\0') {
-               int ret;
-
-               /* Use the default consumer output which is the tracing session path. */
-               ret = snprintf(lks->consumer->dst.trace_path, PATH_MAX,
-                               "%s" DEFAULT_KERNEL_TRACE_DIR, path);
-               if (ret < 0) {
-                       PERROR("snprintf consumer trace path");
-                       goto error;
-               }
-
-               /* Set session path */
-               ret = asprintf(&lks->trace_path, "%s" DEFAULT_KERNEL_TRACE_DIR, path);
-               if (ret < 0) {
-                       PERROR("asprintf kernel traces path");
-                       goto error;
-               }
-       }
-
        return lks;
 
 error:
@@ -158,10 +146,21 @@ struct ltt_kernel_channel *trace_kernel_create_channel(
        lkc->channel = zmalloc(sizeof(struct lttng_channel));
        if (lkc->channel == NULL) {
                PERROR("lttng_channel zmalloc");
+               free(lkc);
                goto error;
        }
        memcpy(lkc->channel, chan, sizeof(struct lttng_channel));
 
+       /*
+        * If we receive an empty string for channel name, it means the
+        * default channel name is requested.
+        */
+       if (chan->name[0] == '\0') {
+               strncpy(lkc->channel->name, DEFAULT_CHANNEL_NAME,
+                       sizeof(lkc->channel->name));
+       }
+       lkc->channel->name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+
        lkc->fd = -1;
        lkc->stream_count = 0;
        lkc->event_count = 0;
@@ -209,7 +208,6 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev)
                attr->instrumentation = LTTNG_KERNEL_KRETPROBE;
                attr->u.kretprobe.addr = ev->attr.probe.addr;
                attr->u.kretprobe.offset = ev->attr.probe.offset;
-               attr->u.kretprobe.offset = ev->attr.probe.offset;
                strncpy(attr->u.kretprobe.symbol_name,
                                ev->attr.probe.symbol_name, LTTNG_KERNEL_SYM_NAME_LEN);
                attr->u.kretprobe.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
@@ -439,6 +437,8 @@ void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata)
 
 /*
  * Cleanup kernel session structure
+ *
+ * Should *NOT* be called with RCU read-side lock held.
  */
 void trace_kernel_destroy_session(struct ltt_kernel_session *session)
 {
@@ -476,6 +476,5 @@ void trace_kernel_destroy_session(struct ltt_kernel_session *session)
        consumer_destroy_output(session->consumer);
        consumer_destroy_output(session->tmp_consumer);
 
-       free(session->trace_path);
        free(session);
 }
This page took 0.026118 seconds and 4 git commands to generate.