From 39ad74cfd50e473190c5d83fd467089af6639d0f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 26 Apr 2016 18:39:38 -0400 Subject: [PATCH] Fix: endianness of integers received by filter We need to byteswap integers passed to the filter when they are tagged as being in an endianness which differs from the architecture endianness, so the integer comparisons make sense in terms of value rather than raw bytes for those fields. Signed-off-by: Mathieu Desnoyers --- include/lttng/ust-tracepoint-event.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 92edc455..e914d97e 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #define __LTTNG_UST_NULL_STRING "(null)" @@ -411,18 +412,24 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS case 2: \ { \ union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != BYTE_ORDER) \ + __tmp.v = bswap_16(__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ case 4: \ { \ union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != BYTE_ORDER) \ + __tmp.v = bswap_32(__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ case 8: \ { \ union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != BYTE_ORDER) \ + __tmp.v = bswap_64(__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ @@ -442,18 +449,24 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS case 2: \ { \ union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != BYTE_ORDER) \ + __tmp.v = bswap_16(__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ case 4: \ { \ union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != BYTE_ORDER) \ + __tmp.v = bswap_32(__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ case 8: \ { \ union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != BYTE_ORDER) \ + __tmp.v = bswap_64(__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ -- 2.34.1