From aacb2ff7c229fc412a4da5313ad82bec45cd1649 Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Wed, 11 May 2016 18:26:30 +0200 Subject: [PATCH] send time in events this calls clock_gettime for each active T macro, hopefully it does not eat too much CPU can be deactivated by commenting one line in T_defs.h --- common/utils/T/T.h | 25 +++++++++++++++++++++++++ common/utils/T/T_defs.h | 3 +++ common/utils/T/tracer/textlog.c | 5 +++++ 3 files changed, 33 insertions(+) diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 6797213d31..1e1a45779b 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 97da76fe1f..faeff507e8 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 f3e6f7178c..f42a1de832 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); -- GitLab