X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=61396eb461958b179f5975f1e19f3739da13bac9;hb=93ec662e687dc15a3601704a1e0c96c51ad228c9;hp=6c10c910d8207be651e41e7c720be9a679e1972c;hpb=5ba3702f9f88e499d9b440a9cd88b5efa3931ab2;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 6c10c910d..61396eb46 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1694,10 +1694,15 @@ int lttng_list_channels(struct lttng_handle *handle, struct lttng_channel **channels) { int ret; + size_t channel_count, i; + const size_t channel_size = sizeof(struct lttng_channel) + + sizeof(struct lttcomm_channel_extended); struct lttcomm_session_msg lsm; + void *extended_at; if (handle == NULL) { - return -LTTNG_ERR_INVALID; + ret = -LTTNG_ERR_INVALID; + goto end; } memset(&lsm, 0, sizeof(lsm)); @@ -1709,10 +1714,30 @@ int lttng_list_channels(struct lttng_handle *handle, ret = lttng_ctl_ask_sessiond(&lsm, (void**) channels); if (ret < 0) { - return ret; + goto end; + } + + if (ret % channel_size) { + ret = -LTTNG_ERR_UNK; + free(*channels); + *channels = NULL; + goto end; + } + channel_count = (size_t) ret / channel_size; + + /* Set extended info pointers */ + extended_at = ((void *) *channels) + + channel_count * sizeof(struct lttng_channel); + for (i = 0; i < channel_count; i++) { + struct lttng_channel *chan = &(*channels)[i]; + + chan->attr.extended.ptr = extended_at; + extended_at += sizeof(struct lttcomm_channel_extended); } - return ret / sizeof(struct lttng_channel); + ret = (int) channel_count; +end: + return ret; } /* @@ -1784,13 +1809,13 @@ error: return ret; } -int lttng_event_get_filter_string(struct lttng_event *event, - const char **filter_string) +int lttng_event_get_filter_expression(struct lttng_event *event, + const char **filter_expression) { int ret = 0; struct lttcomm_event_extended_header *ext_header; - if (!event || !filter_string) { + if (!event || !filter_expression) { ret = -LTTNG_ERR_INVALID; goto end; } @@ -1802,15 +1827,15 @@ int lttng_event_get_filter_string(struct lttng_event *event, * This can happen since the lttng_event structure is * used for other tasks where this pointer is never set. */ - *filter_string = NULL; + *filter_expression = NULL; goto end; } if (ext_header->filter_len) { - *filter_string = ((const char *) (ext_header)) + - sizeof(*ext_header); + *filter_expression = ((const char *) (ext_header)) + + sizeof(*ext_header); } else { - *filter_string = NULL; + *filter_expression = NULL; } end: @@ -2349,6 +2374,36 @@ int lttng_list_tracker_pids(struct lttng_handle *handle, return 0; } +/* + * Regenerate the metadata for a session. + * Return 0 on success, a negative error code on error. + */ +int lttng_metadata_regenerate(const char *session_name) +{ + int ret; + struct lttcomm_session_msg lsm; + + if (!session_name) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + + memset(&lsm, 0, sizeof(lsm)); + lsm.cmd_type = LTTNG_METADATA_REGENERATE; + + lttng_ctl_copy_string(lsm.session.name, session_name, + sizeof(lsm.session.name)); + + ret = lttng_ctl_ask_sessiond(&lsm, NULL); + if (ret < 0) { + goto end; + } + + ret = 0; +end: + return ret; +} + /* * lib constructor. */