From: Mathieu Desnoyers Date: Wed, 9 Nov 2011 15:25:31 +0000 (-0500) Subject: Implement ustctl_tracepoint_list/list_get X-Git-Tag: v1.9.1~117 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b115631f8ae20c4261491c20a88af496f6341e60;p=lttng-ust.git Implement ustctl_tracepoint_list/list_get Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-comm.h b/include/lttng/ust-comm.h index 556da21e..f5da9559 100644 --- a/include/lttng/ust-comm.h +++ b/include/lttng/ust-comm.h @@ -150,6 +150,7 @@ struct ustcomm_ust_reply { uint64_t memory_map_size; } stream; struct lttng_ust_tracer_version version; + char tracepoint_list_entry[LTTNG_UST_SYM_NAME_LEN]; } u; }; diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index 17105631..2bb03f65 100644 --- a/include/lttng/ust-ctl.h +++ b/include/lttng/ust-ctl.h @@ -44,7 +44,18 @@ int ustctl_disable(int sock, struct lttng_ust_object_data *object); int ustctl_start_session(int sock, int handle); int ustctl_stop_session(int sock, int handle); -int ustctl_tracepoint_list(int sock); /* not implemented yet */ +/* + * ustctl_tracepoint_list returns a tracepoint list handle, or negative + * error value. + */ +int ustctl_tracepoint_list(int sock); +/* + * ustctl_tracepoint_list_get is used to iterate on the tp list + * handle. End is iteration is reached when -ENOENT is returned. + */ +int ustctl_tracepoint_list_get(int sock, int tp_list_handle, + char iter[LTTNG_UST_SYM_NAME_LEN]); + int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v); int ustctl_wait_quiescent(int sock); diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index b4234eff..f9c5e84f 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -370,10 +370,39 @@ int ustctl_stop_session(int sock, int handle) return ustctl_disable(sock, &obj); } - int ustctl_tracepoint_list(int sock) { - return -ENOSYS; /* not implemented */ + struct ustcomm_ust_msg lum; + struct ustcomm_ust_reply lur; + int ret, tp_list_handle; + + memset(&lum, 0, sizeof(lum)); + lum.handle = LTTNG_UST_ROOT_HANDLE; + lum.cmd = LTTNG_UST_TRACEPOINT_LIST; + ret = ustcomm_send_app_cmd(sock, &lum, &lur); + if (ret) + return ret; + tp_list_handle = lur.ret_val; + DBG("received tracepoint list handle %u", tp_list_handle); + return tp_list_handle; +} + +int ustctl_tracepoint_list_get(int sock, int tp_list_handle, + char iter[LTTNG_UST_SYM_NAME_LEN]) +{ + struct ustcomm_ust_msg lum; + struct ustcomm_ust_reply lur; + int ret; + + memset(&lum, 0, sizeof(lum)); + lum.handle = tp_list_handle; + lum.cmd = LTTNG_UST_TRACEPOINT_LIST_GET; + ret = ustcomm_send_app_cmd(sock, &lum, &lur); + if (ret) + return ret; + DBG("received tracepoint list entry %s", lur.u.tracepoint_list_entry); + memcpy(iter, lur.u.tracepoint_list_entry, LTTNG_UST_SYM_NAME_LEN); + return 0; } int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v) diff --git a/liblttng-ust/lttng-ust-abi.c b/liblttng-ust/lttng-ust-abi.c index 4b8a8e71..ccdfcfad 100644 --- a/liblttng-ust/lttng-ust-abi.c +++ b/liblttng-ust/lttng-ust-abi.c @@ -523,10 +523,13 @@ static long lttng_tracepoint_list_cmd(int objd, unsigned int cmd, unsigned long arg) { struct ltt_tracepoint_list *list = objd_private(objd); + char *str = (char *) arg; switch (cmd) { case LTTNG_UST_TRACEPOINT_LIST_GET: - ltt_tracepoint_list_get(list, (char *) arg); + ltt_tracepoint_list_get(list, str); + if (str[0] == '\0') + return -ENOENT; return 0; default: return -EINVAL; diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index ad02dd9d..71bf716a 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -304,6 +304,11 @@ end: case LTTNG_UST_VERSION: lur.u.version = lum->u.version; break; + case LTTNG_UST_TRACEPOINT_LIST_GET: + memcpy(lur.u.tracepoint_list_entry, + lum->u.tracepoint_list_entry, + LTTNG_UST_SYM_NAME_LEN); + break; } ret = send_reply(sock, &lur); if (ret < 0) {