From 556b540ae4beba8dd3dd0d628e149c6b93eb4c29 Mon Sep 17 00:00:00 2001 From: Yannick Brosseau Date: Fri, 16 Mar 2012 16:17:23 -0400 Subject: [PATCH] Create a LttvEvent object This object contains a pointer to the current bt_ctf_event and to the associated TraceState Signed-off-by: Yannick Brosseau --- lttv/lttv/Makefile.am | 3 ++- lttv/lttv/event.h | 32 ++++++++++++++++++++++++++++++++ lttv/lttv/print.c | 11 ++++++----- lttv/lttv/print.h | 4 ++-- lttv/lttv/tracecontext.c | 15 +++++++++++---- lttv/modules/text/textDump.c | 4 ++-- 6 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 lttv/lttv/event.h diff --git a/lttv/lttv/Makefile.am b/lttv/lttv/Makefile.am index 30ead559..b273d475 100644 --- a/lttv/lttv/Makefile.am +++ b/lttv/lttv/Makefile.am @@ -101,7 +101,8 @@ lttvinclude_HEADERS = \ tracecontext.h\ traceset.h\ filter.h\ - print.h + print.h\ + event.h #man_MANS = lttv.1 #EXTRA_DIST = lttv.1 diff --git a/lttv/lttv/event.h b/lttv/lttv/event.h new file mode 100644 index 00000000..ce15bf60 --- /dev/null +++ b/lttv/lttv/event.h @@ -0,0 +1,32 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2012 Yannick Brosseau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ +#ifndef LTTV_EVENT_H +#define LTTV_EVENT_H + +/* Forward declaration */ +struct bt_ctf_event; +/* + Basic event container used through LTTV +*/ +typedef struct +{ + struct bt_ctf_event *bt_event; + LttvTraceState *state; +} LttvEvent; + +#endif /* LTTV_EVENT_H */ diff --git a/lttv/lttv/print.c b/lttv/lttv/print.c index 9731b3ed..e87cb3e1 100644 --- a/lttv/lttv/print.c +++ b/lttv/lttv/print.c @@ -44,6 +44,7 @@ #include #include #include +#include static inline void print_enum_events(LttEvent *e, struct marker_field *f, guint64 value, GString *s, LttvTracefileState *tfs) @@ -437,19 +438,19 @@ int getFieldsFromEvent(struct bt_ctf_event *ctf_event, GString* fields, gboolean return ret; } -void lttv_event_to_string(struct bt_ctf_event *event, GString *a_string, gboolean field_names) +void lttv_event_to_string(LttvEvent *event, GString *a_string, gboolean field_names) { GString* processInfos = g_string_new(""); GString* fields = g_string_new(""); GString* cpuId_str = g_string_new(""); - getProcessInfosFromEvent(event, processInfos); - getFieldsFromEvent(event, fields, field_names); - getCPUIdFromEvent(event, cpuId_str); + getProcessInfosFromEvent(event->bt_event, processInfos); + getFieldsFromEvent(event->bt_event, fields, field_names); + getCPUIdFromEvent(event->bt_event, cpuId_str); g_string_set_size(a_string,0); - g_string_append_printf(a_string, "%llu %s: { %s }", bt_ctf_get_timestamp(event), bt_ctf_event_name(event), cpuId_str->str); + g_string_append_printf(a_string, "%llu %s: { %s }", bt_ctf_get_timestamp(event->bt_event), bt_ctf_event_name(event->bt_event), cpuId_str->str); if (strcmp("", processInfos->str) < 0) { g_string_append_printf(a_string, ", { %s }", processInfos->str); } diff --git a/lttv/lttv/print.h b/lttv/lttv/print.h index e5da0e98..0dd838b0 100644 --- a/lttv/lttv/print.h +++ b/lttv/lttv/print.h @@ -24,7 +24,7 @@ * Use these functions to print textually event fields. */ -struct bt_ctf_event; +#include void lttv_print_field(LttEvent *e, struct marker_field *f, GString *s, gboolean field_names, LttvTracefileState *tfs); @@ -32,5 +32,5 @@ void lttv_print_field(LttEvent *e, struct marker_field *f, GString *s, void lttv_event_to_string(LttEvent *e, GString *s, gboolean mandatory_fields, gboolean field_names, LttvTracefileState *tfs); #endif -void lttv_event_to_string(struct bt_ctf_event *event, GString *a_string, gboolean field_names); +void lttv_event_to_string(LttvEvent *event, GString *a_string, gboolean field_names); diff --git a/lttv/lttv/tracecontext.c b/lttv/lttv/tracecontext.c index 0f08381a..1123bf7b 100644 --- a/lttv/lttv/tracecontext.c +++ b/lttv/lttv/tracecontext.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -678,20 +679,26 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, unsigned count = 0; - struct bt_ctf_event *event; + struct bt_ctf_event *bt_event; + LttvEvent event; + /* TODO ybrosseau 2012-03-16: Put in really in the traceset */ + LttvTraceState state; + while(TRUE) { if((count >= nb_events) && (nb_events != G_MAXULONG)) { break; } - if((event = bt_ctf_iter_read_event(self->iter)) != NULL) { + if((bt_event = bt_ctf_iter_read_event(self->iter)) != NULL) { count++; - /* TODO ybrosseau: encapsulate the event into something */ - lttv_hooks_call(self->event_hooks, event); + event.bt_event = bt_event; + event.state = &state; + + lttv_hooks_call(self->event_hooks, &event); if(bt_iter_next(bt_ctf_get_iter(self->iter)) < 0) { printf("ERROR NEXT\n"); diff --git a/lttv/modules/text/textDump.c b/lttv/modules/text/textDump.c index b294b2cd..dd5f5ee0 100644 --- a/lttv/modules/text/textDump.c +++ b/lttv/modules/text/textDump.c @@ -40,7 +40,7 @@ #include #include -#include +#include static gboolean a_noevent, @@ -310,7 +310,7 @@ static int write_event_content(void *hook_data, void *call_data) LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); - struct bt_ctf_event *event = (struct bt_ctf_event *)call_data; + LttvEvent *event = (struct bt_ctf_event *)call_data; #ifdef BABEL_CLEANUP LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; -- 2.34.1