Remove session daemon kernel list events command
authorDavid Goulet <david.goulet@polymtl.ca>
Wed, 3 Aug 2011 21:23:56 +0000 (17:23 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Wed, 3 Aug 2011 21:23:56 +0000 (17:23 -0400)
Replace this command by list tracepoints and use the domain for listing.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
liblttngctl/liblttngctl.c
liblttsessiondcomm/liblttsessiondcomm.h
ltt-sessiond/main.c

index f8e8d97497342bc41a9f920e4812d6906c671b9d..7c0546f6612dc88b76afbe0e73abff696d80e851 100644 (file)
@@ -499,22 +499,13 @@ int lttng_disable_channel(struct lttng_domain *domain, const char *name)
 int lttng_list_tracepoints(struct lttng_domain *domain,
                struct lttng_event **events)
 {
-       int ret = -1;
+       int ret;
 
        copy_lttng_domain(domain);
 
-       if (domain) {
-               switch (domain->type) {
-                       case LTTNG_DOMAIN_KERNEL:
-                               ret = ask_sessiond(LTTNG_KERNEL_LIST_EVENTS, (void **) events);
-                               break;
-                       case LTTNG_DOMAIN_UST:
-                               ret = LTTCOMM_NOT_IMPLEMENTED;
-                               break;
-                       default:
-                               ret = LTTCOMM_UNKNOWN_DOMAIN;
-                               break;
-               };
+       ret = ask_sessiond(LTTNG_LIST_TRACEPOINTS, (void **) events);
+       if (ret < 0) {
+               return ret;
        }
 
        return ret / sizeof(struct lttng_event);
index b1e006a02bbb79a47e9cea43055582dcfe4ed98d..bb965b55cba66e94baa704e8f2f4ff2184410975 100644 (file)
@@ -49,7 +49,6 @@ enum lttcomm_sessiond_command {
        LTTNG_KERNEL_ENABLE_CHANNEL,
        LTTNG_KERNEL_ENABLE_EVENT,
        LTTNG_KERNEL_ENABLE_ALL_EVENT,
-       LTTNG_KERNEL_LIST_EVENTS,
        /* Session daemon context command */
        LTTNG_CREATE_SESSION,
        LTTNG_DESTROY_SESSION,
@@ -57,6 +56,7 @@ enum lttcomm_sessiond_command {
        LTTNG_LIST_DOMAINS,
        LTTNG_LIST_EVENTS,
        LTTNG_LIST_SESSIONS,
+       LTTNG_LIST_TRACEPOINTS,
        LTTNG_START_TRACE,
        LTTNG_STOP_TRACE,
 };
index 6fa89dd1e69ee000797584410aac26bc84aa8212..0af4dcdccb7cdb2ec67b2cd423a6f77902687787 100644 (file)
@@ -1269,7 +1269,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
        switch (cmd_ctx->lsm->cmd_type) {
        case LTTNG_CREATE_SESSION:
        case LTTNG_LIST_SESSIONS:
-       case LTTNG_KERNEL_LIST_EVENTS:
+       case LTTNG_LIST_TRACEPOINTS:
                break;
        default:
                DBG("Getting session %s by name", cmd_ctx->lsm->session_name);
@@ -1300,7 +1300,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
        case LTTNG_KERNEL_ENABLE_ALL_EVENT:
        case LTTNG_KERNEL_ENABLE_CHANNEL:
        case LTTNG_KERNEL_ENABLE_EVENT:
-       case LTTNG_KERNEL_LIST_EVENTS:
+       case LTTNG_LIST_TRACEPOINTS:
                /* Kernel tracer check */
                if (kernel_tracer_fd == 0) {
                        init_kernel_tracer();
@@ -1311,7 +1311,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                }
 
                /* Need a session for kernel command */
-               if (cmd_ctx->lsm->cmd_type != LTTNG_KERNEL_LIST_EVENTS &&
+               if (cmd_ctx->lsm->cmd_type != LTTNG_LIST_TRACEPOINTS &&
                                cmd_ctx->session->kernel_session == NULL) {
 
                        ret = create_kernel_session(cmd_ctx->session);
@@ -1704,31 +1704,39 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                ret = LTTCOMM_OK;
                break;
        }
-       case LTTNG_KERNEL_LIST_EVENTS:
+       case LTTNG_LIST_TRACEPOINTS:
        {
                struct lttng_event *events;
-               ssize_t size = 0;
-
-               DBG("Listing kernel events");
-
-               size = kernel_list_events(kernel_tracer_fd, &events);
-               if (size < 0) {
-                       ret = LTTCOMM_KERN_LIST_FAIL;
-                       goto error;
+               ssize_t nb_events = 0;
+
+               switch (cmd_ctx->lsm->domain.type) {
+               case LTTNG_DOMAIN_KERNEL:
+                       DBG("Listing kernel events");
+                       nb_events = kernel_list_events(kernel_tracer_fd, &events);
+                       if (nb_events < 0) {
+                               ret = LTTCOMM_KERN_LIST_FAIL;
+                               goto error;
+                       }
+                       break;
+               default:
+                       /* TODO: Userspace listing */
+                       ret = LTTCOMM_NOT_IMPLEMENTED;
+                       break;
                }
 
                /*
                 * Setup lttng message with payload size set to the event list size in
                 * bytes and then copy list into the llm payload.
                 */
-               ret = setup_lttng_msg(cmd_ctx, sizeof(struct lttng_event) * size);
+               ret = setup_lttng_msg(cmd_ctx, sizeof(struct lttng_event) * nb_events);
                if (ret < 0) {
+                       free(events);
                        goto setup_error;
                }
 
                /* Copy event list into message payload */
                memcpy(cmd_ctx->llm->payload, events,
-                               sizeof(struct lttng_event) * size);
+                               sizeof(struct lttng_event) * nb_events);
 
                free(events);
 
This page took 0.041203 seconds and 4 git commands to generate.