Implement event fields listing
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 30 May 2012 20:27:10 +0000 (16:27 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 1 Jun 2012 17:35:22 +0000 (13:35 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-abi.h
include/lttng/ust-ctl.h
include/ust-comm.h
liblttng-ust-ctl/ustctl.c
liblttng-ust/ltt-probes.c
liblttng-ust/lttng-ust-abi.c
liblttng-ust/lttng-ust-comm.c

index 898d6cfea790eb814e6353a4fd8c5297cedd336d..2651fc99747c698da04b79b784fa8c150ca2b7e9 100644 (file)
@@ -225,6 +225,9 @@ union ust_args {
                int *wait_fd;
                uint64_t *memory_map_size;
        } stream;
+       struct {
+               struct lttng_ust_field_iter entry;
+       } field_list;
 };
 
 struct lttng_ust_objd_ops {
index 10602ee73c4d3cf66433549b213c6c03ca6f2531..d6bbe6ab440162bef5889cc36d7aead54432cec2 100644 (file)
@@ -55,6 +55,19 @@ int ustctl_tracepoint_list(int sock);
 int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
                struct lttng_ust_tracepoint_iter *iter);
 
+/*
+ * ustctl_tracepoint_field_list returns a tracepoint field list handle,
+ * or negative error value.
+ */
+int ustctl_tracepoint_field_list(int sock);
+
+/*
+ * ustctl_tracepoint_field_list_get is used to iterate on the tp field
+ * list handle. End is iteration is reached when -ENOENT is returned.
+ */
+int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
+               struct lttng_ust_field_iter *iter);
+
 int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v);
 int ustctl_wait_quiescent(int sock);
 
index 7d0b6296524c0f7d6a11566aa5de9f49312a8180..9d2643df129c373176f994c4d4131fb6dd1e4036 100644 (file)
@@ -155,6 +155,11 @@ struct ustcomm_ust_reply {
        } u;
 };
 
+/*
+ * LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
+ * struct lttng_ust_field_iter field.
+ */
+
 extern int ustcomm_create_unix_sock(const char *pathname);
 extern int ustcomm_connect_unix_sock(const char *pathname);
 extern int ustcomm_accept_unix_sock(int sock);
index e4a29f99defbf4cf8b99a02b808c89e49a9cdf35..b0b5b6cc94f2997c61def90e6e30b804295abaaf 100644 (file)
@@ -486,6 +486,52 @@ int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
        return 0;
 }
 
+int ustctl_tracepoint_field_list(int sock)
+{
+       struct ustcomm_ust_msg lum;
+       struct ustcomm_ust_reply lur;
+       int ret, tp_field_list_handle;
+
+       memset(&lum, 0, sizeof(lum));
+       lum.handle = LTTNG_UST_ROOT_HANDLE;
+       lum.cmd = LTTNG_UST_TRACEPOINT_FIELD_LIST;
+       ret = ustcomm_send_app_cmd(sock, &lum, &lur);
+       if (ret)
+               return ret;
+       tp_field_list_handle = lur.ret_val;
+       DBG("received tracepoint field list handle %u", tp_field_list_handle);
+       return tp_field_list_handle;
+}
+
+int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
+               struct lttng_ust_field_iter *iter)
+{
+       struct ustcomm_ust_msg lum;
+       struct ustcomm_ust_reply lur;
+       int ret;
+       ssize_t len;
+
+       if (!iter)
+               return -EINVAL;
+
+       memset(&lum, 0, sizeof(lum));
+       lum.handle = tp_field_list_handle;
+       lum.cmd = LTTNG_UST_TRACEPOINT_FIELD_LIST_GET;
+       ret = ustcomm_send_app_cmd(sock, &lum, &lur);
+       if (ret)
+               return ret;
+       len = ustcomm_recv_unix_sock(sock, iter, sizeof(*iter));
+       if (len != sizeof(*iter)) {
+               return -EINVAL;
+       }
+       DBG("received tracepoint field list entry event_name %s event_loglevel %d field_name %s field_type %d",
+               iter->event_name,
+               iter->loglevel,
+               iter->field_name,
+               iter->type);
+       return 0;
+}
+
 int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v)
 {
        struct ustcomm_ust_msg lum;
index 3d6b1414b97c6baf2a0615592288cb9e67bb0225..9072d37e30f0eb5f8470ec583a0d586cd8f321ac 100644 (file)
@@ -261,6 +261,36 @@ int ltt_probes_get_field_list(struct lttng_ust_field_list *list)
                                        event_field->name,
                                        LTTNG_UST_SYM_NAME_LEN);
                                list_entry->field.field_name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+                               switch (event_field->type.atype) {
+                               case atype_integer:
+                                       list_entry->field.type = LTTNG_UST_FIELD_INTEGER;
+                                       break;
+                               case atype_string:
+                                       list_entry->field.type = LTTNG_UST_FIELD_STRING;
+                                       break;
+                               case atype_array:
+                                       if (event_field->type.u.array.elem_type.atype != atype_integer
+                                               || event_field->type.u.array.elem_type.u.basic.integer.encoding == lttng_encode_none)
+                                               list_entry->field.type = LTTNG_UST_FIELD_OTHER;
+                                       else
+                                               list_entry->field.type = LTTNG_UST_FIELD_STRING;
+                                       break;
+                               case atype_sequence:
+                                       if (event_field->type.u.sequence.elem_type.atype != atype_integer
+                                               || event_field->type.u.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none)
+                                               list_entry->field.type = LTTNG_UST_FIELD_OTHER;
+                                       else
+                                               list_entry->field.type = LTTNG_UST_FIELD_STRING;
+                                       break;
+                               case atype_float:
+                                       list_entry->field.type = LTTNG_UST_FIELD_FLOAT;
+                                       break;
+                               case atype_enum:
+                                       list_entry->field.type = LTTNG_UST_FIELD_ENUM;
+                                       break;
+                               default:
+                                       list_entry->field.type = LTTNG_UST_FIELD_OTHER;
+                               }
                                if (!event_desc->loglevel) {
                                        list_entry->field.loglevel = TRACE_DEFAULT;
                                } else {
index c16a617ceb98710b28466e6dc72080d463d173cc..dac86c7843494da620c920a7c55c5b3f5c86e4e5 100644 (file)
@@ -614,8 +614,7 @@ long lttng_tracepoint_field_list_cmd(int objd, unsigned int cmd,
        unsigned long arg, union ust_args *uargs)
 {
        struct lttng_ust_field_list *list = objd_private(objd);
-       struct lttng_ust_field_iter *tp =
-               (struct lttng_ust_field_iter *) arg;
+       struct lttng_ust_field_iter *tp = &uargs->field_list.entry;
        struct lttng_ust_field_iter *iter;
 
        switch (cmd) {
index 76c8ee3da149ff49ecfe4633d7904927f1683de9..88ac59655d7208f434c9e255b702a32b31758213 100644 (file)
@@ -236,6 +236,7 @@ int handle_message(struct sock_info *sock_info,
        struct ustcomm_ust_reply lur;
        int shm_fd, wait_fd;
        union ust_args args;
+       ssize_t len;
 
        ust_lock();
 
@@ -346,6 +347,22 @@ end:
                        goto error;
                }
        }
+       /*
+        * LTTNG_UST_TRACEPOINT_FIELD_LIST_GET needs to send the field
+        * after the reply.
+        */
+       if (lur.ret_code == USTCOMM_OK) {
+               switch (lum->cmd) {
+               case LTTNG_UST_TRACEPOINT_FIELD_LIST_GET:
+                       len = ustcomm_send_unix_sock(sock,
+                               &args.field_list.entry,
+                               sizeof(args.field_list.entry));
+                       if (len != sizeof(args.field_list.entry)) {
+                               ret = -1;
+                               goto error;
+                       }
+               }
+       }
        /*
         * We still have the memory map reference, and the fds have been
         * sent to the sessiond. We can therefore close those fds. Note
This page took 0.028726 seconds and 4 git commands to generate.