static int ltt_seek_next_event(LttTracefile *tf);
static void __attribute__((constructor)) init(void);
static void ltt_update_event_size(LttTracefile *tf);
+
+/* Enable event debugging */
+static int a_event_debug = 0;
+
+void ltt_event_debug(int state)
+{
+ a_event_debug = state;
+}
+
//void precompute_offsets(LttFacility *fac, LttEventType *event);
#if 0
return 0;
}
+static void print_debug_event_header(LttEvent *ev, void *start_pos, void *end_pos)
+{
+ unsigned int offset = 0;
+ int i, j;
+
+ g_printf("Event header (tracefile %s offset %llx):\n",
+ g_quark_to_string(ev->tracefile->name),
+ ((uint64_t)ev->tracefile->buffer.index * ev->tracefile->buf_size)
+ + (long)start_pos - (long)ev->tracefile->buffer.head);
+
+ while (offset < (long)end_pos - (long)start_pos) {
+ g_printf("%8lx", (long)start_pos - (long)ev->tracefile->buffer.head + offset);
+ g_printf(" ");
+
+ for (i = 0; i < 4 ; i++) {
+ for (j = 0; j < 4; j++) {
+ if (offset + ((i * 4) + j) <
+ (long)end_pos - (long)start_pos)
+ g_printf("%02hhX",
+ ((char*)ev->tracefile->buffer.head)[ev->offset + offset + ((i * 4) + j)]);
+ else
+ g_printf(" ");
+ g_printf(" ");
+ }
+ if (i < 4)
+ g_printf(" ");
+ }
+ offset+=16;
+ g_printf("\n");
+ }
+}
+
/* same as ltt_tracefile_read, but does not seek to the next event nor call
* event specific operation. */
{
void * pos;
LttEvent *event;
+ void *pos_aligned;
event = &tf->event;
pos = tf->buffer.head + event->offset;
g_assert(tf->has_heartbeat);
pos += ltt_align((size_t)pos, sizeof(uint32_t), tf->alignment);
}
+ pos_aligned = pos;
if(tf->has_heartbeat) {
event->timestamp = ltt_get_uint32(LTT_GET_BO(tf),
} else {
/* Compact event */
}
+
+ if (a_event_debug)
+ print_debug_event_header(event, pos_aligned, pos);
+
/* Align the head */
if(!tf->compact)
pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->alignment);
}
+static void print_debug_event_data(LttEvent *ev)
+{
+ unsigned int offset = 0;
+ int i, j;
+
+ if (!max(ev->event_size, ev->data_size))
+ return;
+
+ g_printf("Event data (tracefile %s offset %llx):\n",
+ g_quark_to_string(ev->tracefile->name),
+ ((uint64_t)ev->tracefile->buffer.index * ev->tracefile->buf_size)
+ + (long)ev->data - (long)ev->tracefile->buffer.head);
+
+ while (offset < max(ev->event_size, ev->data_size)) {
+ g_printf("%8lx", (long)ev->data + offset
+ - (long)ev->tracefile->buffer.head);
+ g_printf(" ");
+
+ for (i = 0; i < 4 ; i++) {
+ for (j = 0; j < 4; j++) {
+ if (offset + ((i * 4) + j) < max(ev->event_size, ev->data_size))
+ g_printf("%02hhX", ((char*)ev->data)[offset + ((i * 4) + j)]);
+ else
+ g_printf(" ");
+ g_printf(" ");
+ }
+ if (i < 4)
+ g_printf(" ");
+ }
+
+ g_printf(" ");
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ if (offset + ((i * 4) + j) < max(ev->event_size, ev->data_size)) {
+ if (isprint(((char*)ev->data)[offset + ((i * 4) + j)]))
+ g_printf("%c", ((char*)ev->data)[offset + ((i * 4) + j)]);
+ else
+ g_printf(".");
+ } else
+ g_printf(" ");
+ }
+ }
+ offset+=16;
+ g_printf("\n");
+ }
+}
+
/* It will update the fields offsets too */
void ltt_update_event_size(LttTracefile *tf)
{
/* Event size too big to fit in the event size field */
tf->event.event_size = tf->event.data_size;
}
+
+ if (a_event_debug)
+ print_debug_event_data(&tf->event);
+
if (tf->event.data_size != tf->event.event_size) {
struct marker_info *info = marker_get_info_from_id(tf->trace,
tf->event.event_id);
static void lttv_debug(void *hook_data);
+static void lttv_event_debug(void *hook_data);
+
static void lttv_fatal(void *hook_data);
static void lttv_help(void *hook_data);
lttv_option_add("debug",'d', "print debugging messages", "none",
LTTV_OPT_NONE, NULL, lttv_debug, NULL);
+ /* use -edebug, -e conflicts with filter. Problem with option parsing when we
+ * reparse the options with different number of arguments. */
+ lttv_option_add("edebug",'e', "print event debugging", "none",
+ LTTV_OPT_NONE, NULL, lttv_event_debug, NULL);
+
a_fatal = FALSE;
lttv_option_add("fatal",'f', "make critical messages fatal",
"none",
g_info("Logging set to include DEBUG level messages");
}
+void lttv_event_debug(void *hook_data)
+{
+ ltt_event_debug(1);
+ g_info("Output event detailed debug");
+}
+
void lttv_fatal(void *hook_data)
{
g_log_set_always_fatal(G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);