create directories branches, tags, trunk
[lttv.git] / ltt / branches / poly / lttv / lttv / tracecontext.h
index 5b801a586e564708240403349fd79584fb8adcd3..8bee889086bd95755a4dbfca47f954e38f920999 100644 (file)
 #ifndef PROCESSTRACE_H
 #define PROCESSTRACE_H
 
+#include <string.h>
 #include <lttv/traceset.h>
 #include <lttv/attribute.h>
 #include <lttv/hook.h>
 #include <ltt/ltt.h>
+#include <ltt/marker.h>
 
 /* This is the generic part of trace processing. All events within a
    certain time interval are accessed and processing hooks are called for
@@ -77,6 +79,11 @@ typedef struct _LttvTracefileContextClass LttvTracefileContextClass;
 typedef struct _LttvTracesetContextPosition LttvTracesetContextPosition;
 typedef struct _LttvTraceContextPosition LttvTraceContextPosition;
 
+#ifndef LTTVFILTER_TYPE_DEFINED
+typedef struct _LttvFilter LttvFilter;
+#define LTTVFILTER_TYPE_DEFINED
+#endif
+
 #define LTTV_TRACESET_CONTEXT_TYPE  (lttv_traceset_context_get_type ())
 #define LTTV_TRACESET_CONTEXT(obj)  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContext))
 #define LTTV_TRACESET_CONTEXT_CLASS(vtable)  (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContextClass))
@@ -93,7 +100,9 @@ struct _LttvTracesetContext {
   LttvAttribute *ts_a;
   TimeInterval time_span;
   GTree *pqueue;
-  LttEvent *e;    /* Last event read by lttv_process_traceset_middle */
+
+  LttvTracesetContextPosition *sync_position;   /* position at which to sync the
+                                                   trace context */
 };
 
 struct _LttvTracesetContextClass {
@@ -136,9 +145,11 @@ struct _LttvTraceContext {
   guint index;                /* in ts_context->traces */
   LttTrace *t;
   LttvTrace *vt;
-  LttvTracefileContext **tracefiles;
+  //LttvTracefileContext **tracefiles;
+  GArray *tracefiles;
   LttvAttribute *a;
   LttvAttribute *t_a;
+  TimeInterval time_span;
 };
 
 struct _LttvTraceContextClass {
@@ -158,14 +169,16 @@ struct _LttvTracefileContext {
   GObject parent;
 
   LttvTraceContext *t_context;
-  gboolean control;
// gboolean control;
   guint index;                /* in ts_context->tracefiles */
   LttTracefile *tf;
-  LttEvent *e;
// LttEvent *e;
   LttvHooks *event;
   LttvHooksById *event_by_id;
   LttTime timestamp;
   LttvAttribute *a;
+  gint target_pid;          /* Target PID of the event.
+                               Updated by state.c. -1 means unset. */
 };
 
 struct _LttvTracefileContextClass {
@@ -197,7 +210,7 @@ void lttv_process_traceset_begin(LttvTracesetContext *self,
 
 guint lttv_process_traceset_middle(LttvTracesetContext *self,
                               LttTime end, 
-                              unsigned nb_events,
+                              gulong nb_events,
                               const LttvTracesetContextPosition *end_position);
 
 void lttv_process_traceset_end(LttvTracesetContext *self,
@@ -262,36 +275,122 @@ void lttv_tracefile_context_remove_hooks_by_id(LttvTracefileContext *self,
 
 typedef struct _LttvTraceHook {
   LttvHook h;
-  guint id;
-  LttField *f1;
-  LttField *f2;
-  LttField *f3;
+  guint16 id;  /* id of the marker associated with this hook */
+  GPtrArray *fields;  /* struct marker_fields pointers */
+  gpointer hook_data;
 } LttvTraceHook;
 
+/* Get the head of marker list corresponding to the given trace hook.
+ */
+struct marker_info *lttv_trace_hook_get_marker(LttTrace *t, LttvTraceHook *th);
+
+/* Remove the hooks from the array. Does not free the array itself. */
+void lttv_trace_hook_remove_all(GArray **th);
 
 /* Search in the trace for the id of the named event type within the named
    facility. Then, find the three (if non null) named fields. All that
    information is then used to fill the LttvTraceHook structure. This
    is useful to find the specific id for an event within a trace, for
    registering a hook using this structure as event data;
-   it already contains the (up to three) needed fields handles. */
-void lttv_trace_find_hook(LttTrace *t, char *facility, char *event_type,
-    char *field1, char *field2, char *field3, LttvHook h, LttvTraceHook *th);
+   it already contains the (up to three) needed fields handles.
+   Returns the modified LttvTraceHook array.
+   Prints warnings if events or markers are not found. returns 1 on error,
+   0 on success.
+   Adds the hooks to the trace_hooks array.
+ */
+
+int lttv_trace_find_hook(LttTrace *t, GQuark facility_name, GQuark event_name,
+    GQuark fields[], LttvHook h, gpointer hook_data, GArray **trace_hooks);
 
+static inline struct marker_field *
+lttv_trace_get_hook_field(LttvTraceHook *hook, unsigned int index)
+{
+       return g_ptr_array_index(hook->fields, index);
+}
+
+static inline GQuark lttv_merge_facility_event_name(GQuark fac, GQuark ev)
+{
+  char *tmp;
+  const char *sfac, *sev;
+  GQuark ret;
+
+  sfac = g_quark_to_string(fac);
+  sev = g_quark_to_string(ev);
+  tmp = g_new(char, strlen(sfac) + strlen(sev) + 3); /* 3: _ \0 \0 */
+  strcpy(tmp, sfac);
+  strcat(tmp, "_");
+  strcat(tmp, sev);
+  ret = g_quark_from_string(tmp);
+  g_free(tmp);
+  return ret;
+}
+
+LttvTracefileContext *lttv_traceset_context_get_current_tfc(
+                             LttvTracesetContext *self);
+
+
+LttvTracesetContextPosition *lttv_traceset_context_position_new(
+    const LttvTracesetContext *self);
 
 void lttv_traceset_context_position_save(const LttvTracesetContext *self,
                                     LttvTracesetContextPosition *pos);
 
 void lttv_traceset_context_position_destroy(LttvTracesetContextPosition *pos);
 
+void lttv_traceset_context_position_copy(LttvTracesetContextPosition *dest,
+                                   const LttvTracesetContextPosition *src);
+
 gint lttv_traceset_context_pos_pos_compare(
-                              const LttvTracesetContextPosition *pos1,
-                              const LttvTracesetContextPosition *pos2);
+                          const LttvTracesetContextPosition *pos1,
+                          const LttvTracesetContextPosition *pos2);
 
 gint lttv_traceset_context_ctx_pos_compare(const LttvTracesetContext *self,
-                                        const LttvTracesetContextPosition *pos);
+                                    const LttvTracesetContextPosition *pos2);
+
+LttTime lttv_traceset_context_position_get_time(
+                                      const LttvTracesetContextPosition *pos);
+
+gint compare_tracefile(gconstpointer a, gconstpointer b);
+
+
+/* Synchronisation helpers : save/restore synchronization between ltt traces and
+ * a traceset context. */
+void lttv_process_traceset_synchronize_tracefiles(LttvTracesetContext *tsc);
+
+void lttv_process_traceset_get_sync_data(LttvTracesetContext *tsc);
+
+/* Seek n events forward and backward (without filtering) : only use these where
+ * necessary : the seek backward is costy. */
+
+#define BACKWARD_SEEK_MUL 2 /* Multiplication factor of time_offset between
+                               backward seek iterations */
+
+static const LttTime seek_back_default_offset = { 1, 0 };
+
+typedef gboolean check_handler(guint count, gboolean *stop_flag, gpointer data);
+
+guint lttv_process_traceset_seek_n_forward(LttvTracesetContext *self,
+                                           guint n,
+                                          check_handler *check,
+                                          gboolean *stop_flag,
+                                          LttvFilter *filter1,
+                                          LttvFilter *filter2,
+                                          LttvFilter *filter3,
+                                          gpointer data);
+typedef void (*seek_time_fct)(LttvTracesetContext *self, LttTime start);
+
+/* If first_offset is ltt_time_zero, it will choose a default value */
+guint lttv_process_traceset_seek_n_backward(LttvTracesetContext *self,
+                                            guint n,
+                                            LttTime first_offset,
+                                            seek_time_fct,
+                                           check_handler *check,
+                                           gboolean *stop_flag,
+                                           LttvFilter *filter1,
+                                           LttvFilter *filter2,
+                                           LttvFilter *filter3,
+                                           gpointer data);
+
+#define FIELD_ARRAY(val...) ((GQuark[]){ val, 0 })
 
-gint lttv_traceset_context_pos_pos_compare(const LttvTracesetContextPosition *a,
-                                          const LttvTracesetContextPosition *b);
 #endif // PROCESSTRACE_H
This page took 0.024612 seconds and 4 git commands to generate.