diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 6797213d311818097ef7db008797c8f772687906..1e1a45779b9a131fd45384283d8d6ed279f6a80d 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -7,6 +7,10 @@ #include "T_defs.h" +#ifdef T_SEND_TIME +#include <time.h> +#endif + /* T message IDs */ #include "T_IDs.h" @@ -187,6 +191,25 @@ extern T_cache_t *T_cache; } while (0) #endif +#ifdef T_SEND_TIME + +#define T_HEADER(x) \ + do { \ + if (!__builtin_types_compatible_p(typeof(x), struct T_header *)) { \ + printf("%s:%d:%s: " \ + "bad use of T, pass a message ID as first parameter\n", \ + __FILE__, __LINE__, __FUNCTION__); \ + abort(); \ + } \ + struct timespec T_HEADER_time; \ + if (clock_gettime(CLOCK_REALTIME, &T_HEADER_time)) abort(); \ + memcpy(T_LOCAL_buf, &T_HEADER_time, sizeof(struct timespec)); \ + T_LOCAL_size += sizeof(struct timespec); \ + T_PUT_int(1, (int)(uintptr_t)(x)); \ + } while (0) + +#else /* #ifdef T_SEND_TIME */ + #define T_HEADER(x) \ do { \ if (!__builtin_types_compatible_p(typeof(x), struct T_header *)) { \ @@ -198,6 +221,8 @@ extern T_cache_t *T_cache; T_PUT_int(1, (int)(uintptr_t)(x)); \ } while (0) +#endif /* #ifdef T_SEND_TIME */ + #define T1(t) \ do { \ if (T_ACTIVE(t)) { \ diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index 97da76fe1f6f87822a730332581c2e7a0b6a5065..faeff507e8373dd1f3714ea09269b9e530e31f57 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -1,6 +1,9 @@ #ifndef _T_defs_H_ #define _T_defs_H_ +/* comment (and recompile everything) to not send time in events */ +#define T_SEND_TIME + /* maximum number of arguments for the T macro */ #define T_MAX_ARGS 16 diff --git a/common/utils/T/tracer/textlog.c b/common/utils/T/tracer/textlog.c index f3e6f7178cf9fadd0d45c8b6055e7d4017493924..f42a1de832105a9382051fa0a3fb1d8d498150e6 100644 --- a/common/utils/T/tracer/textlog.c +++ b/common/utils/T/tracer/textlog.c @@ -84,10 +84,15 @@ int fullread(int fd, void *_buf, int count) event get_event(int s, char *v, void *d) { + struct timespec t; int type; int32_t length; fullread(s, &length, 4); +#ifdef T_SEND_TIME + fullread(s, &t, sizeof(struct timespec)); + length -= sizeof(struct timespec); +#endif fullread(s, &type, sizeof(int)); length -= sizeof(int); fullread(s, v, length);