From: Mathieu Desnoyers Date: Wed, 30 May 2012 20:27:10 +0000 (-0400) Subject: Implement event fields listing X-Git-Tag: v2.1.0-rc1~73 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=400033107ea279bb8a1530ddec13e1453dc4c4a3;p=lttng-ust.git Implement event fields listing Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-abi.h b/include/lttng/ust-abi.h index 898d6cfe..2651fc99 100644 --- a/include/lttng/ust-abi.h +++ b/include/lttng/ust-abi.h @@ -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 { diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index 10602ee7..d6bbe6ab 100644 --- a/include/lttng/ust-ctl.h +++ b/include/lttng/ust-ctl.h @@ -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); diff --git a/include/ust-comm.h b/include/ust-comm.h index 7d0b6296..9d2643df 100644 --- a/include/ust-comm.h +++ b/include/ust-comm.h @@ -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); diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index e4a29f99..b0b5b6cc 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -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; diff --git a/liblttng-ust/ltt-probes.c b/liblttng-ust/ltt-probes.c index 3d6b1414..9072d37e 100644 --- a/liblttng-ust/ltt-probes.c +++ b/liblttng-ust/ltt-probes.c @@ -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 { diff --git a/liblttng-ust/lttng-ust-abi.c b/liblttng-ust/lttng-ust-abi.c index c16a617c..dac86c78 100644 --- a/liblttng-ust/lttng-ust-abi.c +++ b/liblttng-ust/lttng-ust-abi.c @@ -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) { diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 76c8ee3d..88ac5965 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -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