49 #ifndef included_clib_elog_h 50 #define included_clib_elog_h 109 char *enum_strings[];
296 word type_index, track_index;
324 e->
type = type_index;
325 e->
track = track_index;
436 #define __ELOG_TYPE_VAR(f) f 437 #define __ELOG_TRACK_VAR(f) f 439 #define ELOG_TYPE_DECLARE(f) static elog_event_type_t __ELOG_TYPE_VAR(f) 441 #define ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,func) \ 442 { .format = fmt, .function = func, } 444 #define ELOG_TYPE_INIT(fmt) \ 445 ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,(char *) __FUNCTION__) 447 #define ELOG_TYPE_DECLARE_HELPER(f,fmt,func) \ 448 static elog_event_type_t __ELOG_TYPE_VAR(f) = \ 449 ELOG_TYPE_INIT_FORMAT_AND_FUNCTION (fmt, func) 451 #define ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt) \ 452 ELOG_TYPE_DECLARE_HELPER (f, fmt, (char *) __FUNCTION__) 454 #define ELOG_TYPE_DECLARE_FORMAT(f,fmt) \ 455 ELOG_TYPE_DECLARE_HELPER (f, fmt, 0) 459 #define ELOG_TYPE(f,fmt) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt) 460 #define ELOG_TYPE_D(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " %d") 461 #define ELOG_TYPE_X(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " 0x%x") 462 #define ELOG_TYPE_DF(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d") 463 #define ELOG_TYPE_XF(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x") 464 #define ELOG_TYPE_FD(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d") 465 #define ELOG_TYPE_FX(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x") 467 #define ELOG_TRACK_DECLARE(f) static elog_track_t __ELOG_TRACK_VAR(f) 468 #define ELOG_TRACK(f) ELOG_TRACK_DECLARE(f) = { .name = #f, } 471 #define ELOG(em,f,data) elog ((em), &__ELOG_TYPE_VAR(f), data) 472 #define ELOG_INLINE(em,f,data) elog_inline ((em), &__ELOG_TYPE_VAR(f), data) 475 #define ELOG_TRACK_DATA(em,f,track) \ 476 elog_data ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track)) 477 #define ELOG_TRACK_DATA_INLINE(em,f,track) \ 478 elog_data_inline ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track)) 481 #define ELOG_DATA(em,f) elog_data ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track) 482 #define ELOG_DATA_INLINE(em,f) elog_data_inline ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track) static void elog_enable_disable(elog_main_t *em, int is_enabled)
Enable or disable event logging.
char ** enum_strings_vector
String table as a vector constructed when type is registered.
f64 time
Absolute time as floating point number in seconds.
elog_time_stamp_t serialize_time
static void * elog_data_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
u32 elog_string(elog_main_t *em, char *format,...)
add a string to the event-log string table
clib_error_t * serialize_open_clib_file(serialize_main_t *m, char *file)
u64 time_cycles
Absolute time stamp in CPU clock cycles.
void serialize_elog_main(serialize_main_t *m, va_list *va)
u8 * format_elog_event(u8 *s, va_list *va)
static u64 clib_cpu_time_now(void)
word elog_event_type_register(elog_main_t *em, elog_event_type_t *t)
register an event type
elog_event_t dummy_event
Dummy event to use when logger is disabled.
char * format
Format string.
void unserialize_elog_main(serialize_main_t *m, va_list *va)
u8 data[20]
20-bytes of data follows, pads to 32 bytes.
u32 n_enum_strings
Number of elements in string enum table.
static void * elog_event_data_not_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
Allocate an event to be filled in by the caller, non-inline.
#define clib_smp_atomic_add(addr, increment)
static void elog_disable_after_events(elog_main_t *em, uword n)
disable logging after specified number of ievents have been logged.
u32 type_index_plus_one
Type index plus one assigned to this type.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
uword * lock
SMP lock, non-zero means locking required.
char * format_args
Specifies how arguments to format are parsed from event data.
uword * event_type_by_format
Hash table mapping type format to type index.
static clib_error_t * elog_write_file(elog_main_t *em, char *clib_file, int flush_ring)
elog_event_type_t * event_types
Vector of event types.
void elog_init(elog_main_t *em, u32 n_events)
static void elog_inline(elog_main_t *em, elog_event_type_t *type, u32 data)
Log a single-datum event, inline version.
char * name
Track name vector.
void elog_alloc(elog_main_t *em, u32 n_events)
elog_event_t * event_ring
Vector of events (circular buffer).
f64 nsec_per_cpu_clock
Use serialize_time and init_time to give estimate for cpu clock frequency.
static void elog(elog_main_t *em, elog_event_type_t *type, u32 data)
Log a single-datum event.
word elog_track_register(elog_main_t *em, elog_track_t *t)
register an event track
clib_error_t * serialize(serialize_main_t *m,...)
static uword elog_n_events_in_buffer(elog_main_t *em)
Return number of events in the event-log buffer.
clib_error_t * unserialize_open_clib_file(serialize_main_t *m, char *file)
u32 track_index_plus_one
Set to one when track has been added to main structure.
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
void unserialize_close(serialize_main_t *m)
u64 os_nsec
OS timer in nano secs since epoch 3/30/2017, see elog_time_now()
void elog_time_now(elog_time_stamp_t *et)
void elog_merge(elog_main_t *dst, u8 *dst_tag, elog_main_t *src, u8 *src_tag, f64 align_tweak)
static void elog_reset_buffer(elog_main_t *em)
Reset the event buffer.
uword event_ring_size
Power of 2 number of elements in ring.
void serialize_close(serialize_main_t *m)
u64 cpu
CPU cycle counter.
clib_error_t * unserialize(serialize_main_t *m,...)
u16 track
Track for this event.
clib_time_t cpu_timer
Place holder for CPU clock frequency.
static uword is_pow2(uword x)
u8 * format_elog_track(u8 *s, va_list *va)
elog_event_t * events
Vector of events converted to generic form after collection.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u16 type
Event type index.
static uword elog_is_enabled(elog_main_t *em)
event logging enabled predicate
elog_track_t * tracks
Vector of tracks.
static void elog_track(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
Log a single-datum event to a specific track, non-inline version.
static void * elog_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
char * string_table
Events may refer to strings in string table.
static clib_error_t * elog_read_file(elog_main_t *em, char *clib_file)
elog_track_t default_track
Default track.
u32 n_total_events
Total number of events in buffer.
elog_event_t * elog_get_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
elog_event_t * elog_peek_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
static void elog_track_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
Log a single-datum event to a specific track.
void * elog_event_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
static void * elog_event_data_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
Allocate an event to be filled in by the caller.
static uword elog_buffer_capacity(elog_main_t *em)
Return number of events which can fit in the event buffer.
static void elog_disable_trigger(elog_main_t *em)