Create a LttvEvent object
authorYannick Brosseau <yannick.brosseau@gmail.com>
Fri, 16 Mar 2012 20:17:23 +0000 (16:17 -0400)
committerYannick Brosseau <yannick.brosseau@gmail.com>
Mon, 11 Jun 2012 21:34:33 +0000 (17:34 -0400)
This object contains a pointer to the current bt_ctf_event
and to the associated TraceState

Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
lttv/lttv/Makefile.am
lttv/lttv/event.h [new file with mode: 0644]
lttv/lttv/print.c
lttv/lttv/print.h
lttv/lttv/tracecontext.c
lttv/modules/text/textDump.c

index 30ead55937688ae05386c73b58d72cb8d90b2a95..b273d47574cd3cd015a04c3469835223d4c31e4f 100644 (file)
@@ -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 (file)
index 0000000..ce15bf6
--- /dev/null
@@ -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 */
index 9731b3ed37f505fe2fb6bcb47b2dd24260f720b6..e87cb3e150e6ddc32a8d77ea786af9765e8c906c 100644 (file)
@@ -44,6 +44,7 @@
 #include <babeltrace/ctf/events.h>
 #include <string.h>
 #include <inttypes.h>
+#include <lttv/event.h>
 
 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);
        }
index e5da0e989a45b448590d8e7c47328fea92962a39..0dd838b07d05e1b19ddde04282884094dc80cfa4 100644 (file)
@@ -24,7 +24,7 @@
  * Use these functions to print textually event fields. 
  */
 
-struct bt_ctf_event;
+#include <lttv/event.h>
 
 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);
 
index 0f08381a9864576f1f3218522760f83bb0e01c60..1123bf7b40710ebeb4c123434ed098c12948dfad 100644 (file)
@@ -28,6 +28,7 @@
 #include <lttv/filter.h>
 #include <errno.h>
 #include <ltt/time.h>
+#include <lttv/event.h>
 
 #include <babeltrace/context.h>
 #include <babeltrace/iterator.h>
@@ -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");
index b294b2cd87441286aecdc03410901d6530f5af58..dd5f5ee07f2b36254614c819e1e6e8d3c69a7318 100644 (file)
@@ -40,7 +40,7 @@
 #include <stdio.h>
 #include <inttypes.h>
 
-#include <babeltrace/ctf/events.h>
+#include <lttv/event.h>
 
 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;
 
This page took 0.027002 seconds and 4 git commands to generate.