Support utf 16/32 for enum labels
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 10 Nov 2022 18:45:34 +0000 (13:45 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 10 Nov 2022 18:45:34 +0000 (13:45 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/side/trace.h
src/tracer.c

index 5fcbacc6217677b363d05cfd82a4868608196215..2c2ab0822ba0d28efe655098b2f1279ba552634d 100644 (file)
@@ -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 */
index b892872608cff0631690e1bc593c546f07da47ea..db21bab556373f61b2015fff7c1ba04d222a47d1 100644 (file)
@@ -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)
This page took 0.027538 seconds and 4 git commands to generate.