From: Mathieu Desnoyers Date: Thu, 10 Nov 2022 18:45:34 +0000 (-0500) Subject: Support utf 16/32 for enum labels X-Git-Url: https://git.efficios.com/?a=commitdiff_plain;h=238bedba471686bb320d08d110b3fdc05f9dfd5c;p=libside.git Support utf 16/32 for enum labels Signed-off-by: Mathieu Desnoyers --- diff --git a/include/side/trace.h b/include/side/trace.h index 5fcbacc..2c2ab08 100644 --- a/include/side/trace.h +++ b/include/side/trace.h @@ -325,7 +325,7 @@ struct side_type_float { struct side_enum_mapping { int64_t range_begin; int64_t range_end; - const char *label; + struct side_type_raw_string label; } SIDE_PACKED; struct side_enum_mappings { @@ -338,7 +338,7 @@ struct side_enum_mappings { struct side_enum_bitmap_mapping { uint64_t range_begin; uint64_t range_end; - const char *label; + struct side_type_raw_string label; } SIDE_PACKED; struct side_enum_bitmap_mappings { @@ -693,14 +693,22 @@ struct side_event_description { { \ .range_begin = _begin, \ .range_end = _end, \ - .label = _label, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ } #define side_enum_mapping_value(_label, _value) \ { \ .range_begin = _value, \ .range_end = _value, \ - .label = _label, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ } #define side_define_enum_bitmap(_identifier, _mappings, _attr) \ @@ -718,14 +726,22 @@ struct side_event_description { { \ .range_begin = _begin, \ .range_end = _end, \ - .label = _label, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ } #define side_enum_bitmap_mapping_value(_label, _value) \ { \ .range_begin = _value, \ .range_end = _value, \ - .label = _label, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ } /* Stack-copy field and type definitions */ diff --git a/src/tracer.c b/src/tracer.c index b892872..db21bab 100644 --- a/src/tracer.c +++ b/src/tracer.c @@ -465,7 +465,7 @@ void print_enum_labels(const struct side_enum_mappings *mappings, union int64_va } if (v64.s >= mapping->range_begin && v64.s <= mapping->range_end) { printf("%s", print_count++ ? ", " : ""); - printf("\"%s\"", mapping->label); + tracer_print_string(mapping->label.p, mapping->label.unit_size, mapping->label.byte_order, NULL); } } if (!print_count) @@ -594,7 +594,7 @@ void tracer_print_enum_bitmap(const struct side_type *type_desc, match: if (match) { printf("%s", print_count++ ? ", " : ""); - printf("\"%s\"", mapping->label); + tracer_print_string(mapping->label.p, mapping->label.unit_size, mapping->label.byte_order, NULL); } } if (!print_count)