48 while (__sync_lock_test_and_set (em->
lock, 1))
119 for (i = 0; i < l; i++)
125 if (t->
format[i+1] ==
'%')
130 case 'd':
case 'x':
case 'u':
207 digits[0] = digits[1] = 0;
208 while (p[i] >=
'0' && p[i] <=
'9')
212 digits[
i] = p[
i] -
'0';
216 if (i >= 1 && i <= 2)
221 *number = 10 * digits[0] + digits[1];
238 if (f[0] ==
'%' && f[1] !=
'%')
252 f += f[0] ==
'+' || f[0] ==
'-' || f[0] ==
'=';
255 while ((f[0] >=
'0' && f[0] <=
'9') || f[0] ==
'.')
259 f += f[0] ==
'w' || f[0] ==
'l' || f[0] ==
'L';
264 ASSERT (*result_len > f - percent);
265 l =
clib_min (f - percent, *result_len - 1);
270 *result_len = f - fmt;
280 void * d = (
u8 *) e->
data;
289 uword n_bytes = 0, n_digits, f_bytes = 0;
291 f_bytes =
sizeof (arg_format);
295 if (a == 0 || a[0] == 0)
317 else if (n_bytes == 2)
319 else if (n_bytes == 4)
321 else if (n_bytes == 8)
328 s =
format (s, arg_format, e);
330 else if (a[0] ==
'T')
333 s =
format (s, arg_format, e);
335 else if (n_bytes == 8)
336 s =
format (s, arg_format, l);
338 s =
format (s, arg_format, i);
347 else if (n_bytes == 8)
351 s =
format (s, arg_format, x);
356 s =
format (s, arg_format, d);
358 n_bytes = strlen (d) + 1;
366 ASSERT (n_digits > 0 && n_digits <= 2);
384 u64 cpu_time_now, os_time_now_nsec;
388 #include <sys/syscall.h> 390 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
392 os_time_now_nsec = 1e9 * ts.tv_sec + ts.tv_nsec;
396 os_time_now_nsec = 0;
399 et->
cpu = cpu_time_now;
400 et->
os_nsec = os_time_now_nsec;
437 memset (em, 0,
sizeof (em[0]));
469 if (lo) *lo = i & (l - 1);
480 for (i = 0; i < n; i++)
524 void * d = (
u8 *) e->
data;
534 uword n_bytes = 0, n_digits;
561 ASSERT (n_digits > 0 && n_digits <= 2);
580 u32 string_table_offset_for_src_events;
581 u32 track_offset_for_src_tracks;
602 new_name = (
char *)
format (0,
"%s:%s%c", dst_tag, t->
name, 0);
634 e->
track += track_offset_for_src_tracks;
639 f64 dt_event, dt_os_nsec, dt_clock_nsec;
651 dt_event = dt_os_nsec;
660 &&
fabs (dt_os_nsec - dt_clock_nsec) < 100)
661 dt_event = dt_clock_nsec;
675 for (e = dst->
events + 0; e < dst->events + l; e++)
722 uword n_digits, n_bytes = 0;
733 else if (n_bytes == 2)
735 else if (n_bytes == 4)
737 else if (n_bytes == 8)
746 n_bytes = strlen ((
char *) d) + 1;
752 else if (n_bytes == 8)
799 uword n_digits, n_bytes = 0;
814 else if (n_bytes == 2)
819 else if (n_bytes == 4)
824 else if (n_bytes == 8)
838 n_bytes = strlen (t) + 1;
851 else if (n_bytes == 8)
875 int n = va_arg (*va,
int);
877 for (i = 0; i < n; i++)
892 int n = va_arg (*va,
int);
894 for (i = 0; i < n; i++)
900 vec_resize (t[i].enum_strings_vector, t[i].n_enum_strings);
910 int n = va_arg (*va,
int);
912 for (i = 0; i < n; i++)
922 int n = va_arg (*va,
int);
924 for (i = 0; i < n; i++)
char ** enum_strings_vector
always_inline uword max_pow2(uword x)
elog_time_stamp_t serialize_time
sll srl srl sll sra u16x4 i
void unserialize_check_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
elog_event_t * elog_get_events(elog_main_t *em)
static void maybe_fix_string_table_offset(elog_event_t *e, elog_event_type_t *t, u32 offset)
always_inline f64 fabs(f64 x)
void elog_time_now(elog_time_stamp_t *et)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
#define vec_serialize(m, v, f)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
word elog_track_register(elog_main_t *em, elog_track_t *t)
elog_time_stamp_t init_time
#define vec_unserialize(m, v, f)
serialize_function_t unserialize_64
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u8 * format_elog_track(u8 *s, va_list *va)
always_inline i64 elog_time_stamp_diff_cpu(elog_time_stamp_t *t1, elog_time_stamp_t *t2)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define hash_set_mem(h, key, value)
static void elog_lock(elog_main_t *em)
void serialize_elog_main(serialize_main_t *m, va_list *va)
u8 * format_elog_event(u8 *s, va_list *va)
static uword find_or_create_type(elog_main_t *em, elog_event_type_t *t)
serialize_function_t serialize_64
static void serialize_elog_time_stamp(serialize_main_t *m, va_list *va)
static void unserialize_elog_event_type(serialize_main_t *m, va_list *va)
static void new_event_type(elog_main_t *em, uword i)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
void unserialize_elog_main(serialize_main_t *m, va_list *va)
always_inline f64 elog_nsec_per_clock(elog_main_t *em)
serialize_function_t unserialize_f32
static void unserialize_elog_event(serialize_main_t *m, va_list *va)
void elog_init(elog_main_t *em, u32 n_events)
word elog_event_type_register(elog_main_t *em, elog_event_type_t *t)
always_inline void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
static void unserialize_elog_time_stamp(serialize_main_t *m, va_list *va)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static uword elog_event_range(elog_main_t *em, uword *lo)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
#define vec_end(v)
End (last data address) of vector.
uword * event_type_by_format
static int elog_cmp(void *a1, void *a2)
elog_event_type_t * event_types
static uword parse_2digit_decimal(char *p, uword *number)
static char * elog_serialize_magic
elog_event_t * event_ring
static void serialize_elog_event_type(serialize_main_t *m, va_list *va)
always_inline void * elog_event_data_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
static void unserialize_elog_track(serialize_main_t *m, va_list *va)
void clib_time_init(clib_time_t *c)
void elog_alloc(elog_main_t *em, u32 n_events)
serialize_function_t unserialize_f64
void unserialize_cstring(serialize_main_t *m, char **s)
static void elog_unlock(elog_main_t *em)
clib_error_t * serialize(serialize_main_t *m,...)
#define vec_free(V)
Free vector's memory (no header).
#define clib_memcpy(a, b, c)
static void serialize_elog_event(serialize_main_t *m, va_list *va)
always_inline void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
u32 n_total_events_disable_limit
static void serialize_elog_track(serialize_main_t *m, va_list *va)
serialize_function_t unserialize_vec_8
void serialize_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
clib_error_t * unserialize(serialize_main_t *m,...)
#define vec_append(v1, v2)
Append v2 after v1.
void elog_merge(elog_main_t *dst, u8 *dst_tag, elog_main_t *src, u8 *src_tag)
serialize_function_t serialize_f32
void serialize_cstring(serialize_main_t *m, char *s)
#define vec_elt(v, i)
Get vector value at index i.
#define hash_create_vec(elts, key_bytes, value_bytes)
serialize_function_t serialize_vec_8
u32 elog_string(elog_main_t *em, char *fmt,...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
void * elog_event_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
#define clib_mem_unaligned(pointer, type)
#define hash_get_mem(h, key)
static u8 * fixed_format(u8 *s, char *fmt, char *result, uword *result_len)
#define vec_foreach(var, vec)
Vector iterator.
elog_track_t default_track
always_inline i64 elog_time_stamp_diff_os_nsec(elog_time_stamp_t *t1, elog_time_stamp_t *t2)
#define CLIB_MEMORY_BARRIER()
#define CLIB_CACHE_LINE_BYTES
always_inline u64 clib_cpu_time_now(void)
elog_event_t * elog_peek_events(elog_main_t *em)
serialize_function_t serialize_f64
#define vec_resize_aligned(V, N, A)
Resize a vector (no header, alignment specified).