const struct lttng_kernel_type_common *elem_type;
struct field_path *field_path;
int ret;
+ bool is_string = type->elem_type->type == lttng_kernel_type_integer &&
+ (type->encoding == lttng_kernel_string_encoding_ASCII ||
+ type->encoding == lttng_kernel_string_encoding_UTF8);
field_path = field_path_resolve(field_location_ctx, type->length_name);
if (!field_path) {
goto end;
}
- /*
- * Nested compound types: Only array of integers, structures, and
- * variants are currently supported.
- */
- ret = lttng_metadata_printf(session,
- "{\n"
- " \"type\": \"dynamic-length-array\",\n"
- " \"length-field-location\": ");
- if (ret)
- goto end;
-
- ret = print_field_location(session, field_path);
- if (ret)
- goto end;
+ if (is_string) {
+ ret = lttng_metadata_printf(
+ session,
+ "{"
+ " \"type\": \"dynamic-length-string\","
+ " \"length-field-location\": ");
+ ret = print_field_location(session, field_path);
+ if (ret)
+ goto end;
- if (type->alignment != 0 && type->alignment != 1) {
+ } else {
ret = lttng_metadata_printf(session,
- ",\n\"minimum-alignment\": %u",
- type->alignment * CHAR_BIT);
+ "{\n"
+ " \"type\": \"dynamic-length-array\",\n"
+ " \"length-field-location\": ");
+
+ ret = print_field_location(session, field_path);
if (ret)
goto end;
- }
- ret = lttng_metadata_printf(session, ",\n\"element-field-class\":");
- if (ret)
- goto end;
+ if (type->alignment != 0 && type->alignment != 1) {
+ ret = lttng_metadata_printf(session,
+ ",\n\"minimum-alignment\": %u",
+ type->alignment * CHAR_BIT);
+ if (ret)
+ goto end;
+ }
- elem_type = type->elem_type;
- switch (elem_type->type) {
- case lttng_kernel_type_integer:
- case lttng_kernel_type_struct:
- case lttng_kernel_type_variant:
- ret = ctf2_metadata_write_field_class(session, elem_type, NULL);
+ ret = lttng_metadata_printf(session, ",\n\"element-field-class\":");
if (ret)
goto end;
- break;
- default:
- return -EINVAL;
+ /*
+ * Nested compound types: Only array of integers, structures, and
+ * variants are currently supported.
+ */
+ elem_type = type->elem_type;
+ switch (elem_type->type) {
+ case lttng_kernel_type_integer:
+ case lttng_kernel_type_struct:
+ case lttng_kernel_type_variant:
+ ret = ctf2_metadata_write_field_class(session, elem_type, NULL);
+ if (ret)
+ goto end;
+ break;
+
+ default:
+ return -EINVAL;
+ }
}
ret = lttng_metadata_printf(session, "}\n");