From: Mathieu Desnoyers Date: Sun, 20 Mar 2016 18:54:18 +0000 (-0400) Subject: Fix: convey enum value signedness into metadata X-Git-Tag: v2.8.0~175 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=76e8b16e121a18e0d539265db386defa65b1a6f9;p=lttng-tools.git Fix: convey enum value signedness into metadata Currently, passing an enum range of: ctf_enum_range("blah", 0, UINT_MAX) in LTTng-UST will print a range of 0 ... -1 in the generated CTF metadata, which does not reflect signedness of the values. Also, struct ustctl_enum_entry is missing a LTTNG_PACKED attribute, which is against our protocol rules. This change needs to be pushed in locked-step into lttng-tools and lttng-ust, since it breaks the protocol between the two when UST uses the new enumeration type (introduced in 2.8.0-rc1). Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.h b/src/bin/lttng-sessiond/lttng-ust-ctl.h index 1ea7b938a..b8cf775e3 100644 --- a/src/bin/lttng-sessiond/lttng-ust-ctl.h +++ b/src/bin/lttng-sessiond/lttng-ust-ctl.h @@ -286,12 +286,19 @@ struct ustctl_float_type { char padding[USTCTL_UST_FLOAT_TYPE_PADDING]; } LTTNG_PACKED; +#define USTCTL_UST_ENUM_VALUE_PADDING 15 +struct ustctl_enum_value { + uint64_t value; + uint8_t signedness; + char padding[USTCTL_UST_ENUM_VALUE_PADDING]; +} LTTNG_PACKED; + #define USTCTL_UST_ENUM_ENTRY_PADDING 32 struct ustctl_enum_entry { - uint64_t start, end; /* start and end are inclusive */ + struct ustctl_enum_value start, end; /* start and end are inclusive */ char string[LTTNG_UST_SYM_NAME_LEN]; char padding[USTCTL_UST_ENUM_ENTRY_PADDING]; -}; +} LTTNG_PACKED; #define USTCTL_UST_BASIC_TYPE_PADDING 296 union _ustctl_basic_type { diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c index e49f23743..851fb99f4 100644 --- a/src/bin/lttng-sessiond/ust-metadata.c +++ b/src/bin/lttng-sessiond/ust-metadata.c @@ -304,14 +304,30 @@ int ust_metadata_enum_statedump(struct ust_registry_session *session, if (ret) { goto end; } - if (entry->start == entry->end) { + + if (entry->start.signedness) { ret = lttng_metadata_printf(session, - "%d,\n", - entry->start); + "%lld", (long long) entry->start.value); } else { ret = lttng_metadata_printf(session, - "%d ... %d,\n", - entry->start, entry->end); + "%llu", entry->start.value); + } + if (ret) { + goto end; + } + + if (entry->start.signedness == entry->end.signedness && + entry->start.value == entry->end.value) { + ret = lttng_metadata_printf(session, + ",\n"); + } else { + if (entry->end.signedness) { + ret = lttng_metadata_printf(session, + " ... %lld,\n", (long long) entry->end.value); + } else { + ret = lttng_metadata_printf(session, + " ... %llu,\n", entry->end.value); + } } if (ret) { goto end; diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index dea443d94..6913487d5 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -89,14 +89,23 @@ static int compare_enums(const struct ust_registry_enum *reg_enum_a, entries_a = ®_enum_a->entries[i]; entries_b = ®_enum_b->entries[i]; - if (entries_a->start != entries_b->start) { + if (entries_a->start.value != entries_b->start.value) { ret = -1; goto end; } - if (entries_a->end != entries_b->end) { + if (entries_a->end.value != entries_b->end.value) { ret = -1; goto end; } + if (entries_a->start.signedness != entries_b->start.signedness) { + ret = -1; + goto end; + } + if (entries_a->end.signedness != entries_b->end.signedness) { + ret = -1; + goto end; + } + if (strcmp(entries_a->string, entries_b->string)) { ret = -1; goto end;