From: Adam Crume Date: Wed, 25 Jun 2014 20:57:42 +0000 (-0700) Subject: lttng: Add tracing-common.h X-Git-Tag: v0.86~231^2~72 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fcf49257f0254d357c2ed7610a4a4c1f5fe2b32d;p=ceph.git lttng: Add tracing-common.h Signed-off-by: Adam Crume --- diff --git a/configure.ac b/configure.ac index c0310ebd9a7..b008d4f2314 100644 --- a/configure.ac +++ b/configure.ac @@ -808,6 +808,33 @@ if test x"$LTTNG_GEN_TP_CHECK" != "xyes"; then fi AC_SUBST([LTTNG_GEN_TP_PROG], [lttng-gen-tp]) +AC_MSG_CHECKING([if time_t is an integer]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ + struct { + unsigned int time_t_is_integer: ((time_t) 1.5 == 1) ? 1 : -1; + } x; + return 0; +]])], [ + AC_MSG_RESULT([yes]) +], [ + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([time_t is not an integer. We assume this for tracing.]) +]) + +AC_MSG_CHECKING([if time_t fits in uint64_t]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include +#include ]], [[ + struct { + unsigned int time_t_fits_in_uin64_t: (sizeof(time_t) <= sizeof(uint64_t)) ? 1 : -1; + } x; + return 0; +]])], [ + AC_MSG_RESULT([yes]) +], [ + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([time_t is larger than uint64_t. We assume it can be cast to uint64_t, for tracing.]) +]) + # Checks for typedefs, structures, and compiler characteristics. #AC_HEADER_STDBOOL diff --git a/src/tracing/Makefile.am b/src/tracing/Makefile.am index 810989686b4..a02248f63e8 100644 --- a/src/tracing/Makefile.am +++ b/src/tracing/Makefile.am @@ -12,7 +12,8 @@ libtracepoints_la_SOURCES = \ osd.c \ osd.h \ pg.h \ - pg.c + pg.c \ + tracing-common.h libtracepoints_la_LIBADD = -llttng-ust -ldl libtracepoints_la_CPPFLAGS = -DTRACEPOINT_PROBE_DYNAMIC_LINKAGE diff --git a/src/tracing/tracing-common.h b/src/tracing/tracing-common.h new file mode 100644 index 00000000000..d6c0c417e6b --- /dev/null +++ b/src/tracing/tracing-common.h @@ -0,0 +1,76 @@ +#if !defined(TRACING_COMMON_H) +#define TRACING_COMMON_H + +#define CEPH_TRACE_BUF_TRUNC_LEN 32 + +// TODO: This is GCC-specific. Replace CEPH_MAX and CEPH_MIN with standard macros, if possible. +#define CEPH_MAX(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) + +#define CEPH_MIN(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) + +// type should be an integer type +// val should have type type* +#define ceph_ctf_integerp(type, field, val) \ + ctf_integer(type, field, (val) == NULL ? 0 : (val)) \ + ctf_integer(uint8_t, field##_isnull, (val) == NULL) + +// val should have type char* +#define ceph_ctf_string(field, val) \ + ctf_string(field, (val) == NULL ? "" : (val)) \ + ctf_integer(uint8_t, field##_isnull, (val) == NULL) + +// val should have type char** +#define ceph_ctf_stringp(field, val) \ + ctf_string(field, ((val) == NULL || *(val) == NULL) ? "" : (val)) \ + ctf_integer(uint8_t, field##_isnull, (val) == NULL) \ + ctf_integer(uint8_t, field##_data_isnull, (val) == NULL || *(val) == NULL) + +// val should have type type* +// lenval should have type lentype +#define ceph_ctf_sequence(type, field, val, lentype, lenval) \ + ctf_integer_hex(void*, field, val) \ + ctf_sequence(type, field##_data, (val) == NULL ? "" : (val), lentype, (val) == NULL ? 0 : CEPH_MIN((lenval), CEPH_TRACE_BUF_TRUNC_LEN)) \ + ctf_integer(uint8_t, field##_isnull, (val) == NULL) \ + ctf_integer(lentype, field##_len, lenval) + +// val should have type type** +// lenval should have type lentype* +#define ceph_ctf_sequencep(type, field, val, lentype, lenval) \ + ctf_integer_hex(void*, field, val) \ + ctf_sequence(type, \ + field##_data, \ + ((val) == NULL || *(val) == NULL) ? "" : *(val), \ + lentype, \ + ((val) == NULL || *(val) == NULL || (lenval) == NULL) ? 0 : CEPH_MIN(*(lenval), CEPH_TRACE_BUF_TRUNC_LEN)) \ + ctf_integer(uint8_t, field##_isnull, (val) == NULL) \ + ctf_integer(uint8_t, field##_data_isnull, ((val) == NULL || *(val) == NULL)) \ + ctf_integer(lentype, field##_len, (lenval) == NULL ? 0 : *(lenval)) \ + ctf_integer(lentype, field##_len_isnull, (lenval) == NULL) + +// p should be of type struct timeval* +#define ceph_ctf_timevalp(field, p) \ + ctf_integer(long int, field##_sec, (p) == NULL ? 0 : (p)->tv_sec) \ + ctf_integer(long int, field##_usec, (p) == NULL ? 0 : (p)->tv_usec) \ + ctf_integer(uint8_t, field##_isnull, (p) == NULL) + +// val should be of type time_t +// Currently assumes that time_t is an integer and no more than 64 bits wide. +// This is verified by the configure script. +#define ceph_ctf_time_t(field, val) \ + ctf_integer(uint64_t, field, (uint64_t)(val)) + +// val should be of type time_t* +// Currently assumes that time_t is an integer and no more than 64 bits wide. +// This is verified by the configure script. +#define ceph_ctf_time_tp(field, val) \ + ctf_integer(uint64_t, field, (val) == NULL ? 0 : (uint64_t)(*val)) \ + ctf_integer(uint8_t, field##_isnull, (val) == NULL) + + +#endif /* TRACING_COMMON_H */