state.[ch] modified to fit tracecontext mods
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 26 May 2004 20:35:02 +0000 (20:35 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 26 May 2004 20:35:02 +0000 (20:35 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@558 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/state.c
ltt/branches/poly/lttv/lttv/state.h
ltt/branches/poly/lttv/lttv/tracecontext.c

index 0624fe4b01e17ed3b9180162c15763f6bc54fa1b..3db6237aebe37fa084f3180ca6ca4b54d4b18af8 100644 (file)
@@ -448,9 +448,7 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container)
     if(*(value.v_pointer) == NULL) tfcs->parent.e = NULL;
     else {
       ep = *(value.v_pointer);
-      ltt_tracefile_seek_position(tfcs->parent.tf, ep);
-      tfcs->parent.e = ltt_tracefile_read(tfcs->parent.tf);
-      tfcs->parent.timestamp = ltt_event_time(tfcs->parent.e);
+      lttv_process_tracefile_seek_position(tfcs->parent, ep);
     }
   }
 }
@@ -772,7 +770,8 @@ lttv_state_create_process(LttvTracefileState *tfs, LttvProcessState *parent,
 
   char buffer[128];
 
-  tcs = ((LttvTraceState *)tc = tfs->parent.t_context);
+  tc = tfs->parent.t_context;
+  tcs = (LttvTraceState *)tc;
        
   process->pid = pid;
   process->last_cpu = tfs->cpu_name;
@@ -1064,7 +1063,7 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
     lttv_trace_find_hook(ts->parent.t, "core", "process_exit", NULL, NULL, 
         NULL, process_exit, &g_array_index(hooks, LttvTraceHook, 8));
 
-    /* Add these hooks to each before_event_by_id hooks list */
+    /* Add these hooks to each event_by_id hooks list */
 
     nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
         ltt_trace_per_cpu_tracefile_number(ts->parent.t);
@@ -1074,8 +1073,8 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
 
       for(k = 0 ; k < hooks->len ; k++) {
         hook = g_array_index(hooks, LttvTraceHook, k);
-        lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.after_event_by_id, 
-         hook.id), hook.h, &g_array_index(hooks, LttvTraceHook, k));
+        lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.event_by_id, 
+         hook.id), hook.h, &g_array_index(hooks, LttvTraceHook, k), LTTV_PRIO_STATE);
       }
     }
     lttv_attribute_find(self->parent.a, LTTV_STATE_HOOKS, LTTV_POINTER, &val);
@@ -1106,7 +1105,7 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self)
     lttv_attribute_find(self->parent.a, LTTV_STATE_HOOKS, LTTV_POINTER, &val);
     hooks = *(val.v_pointer);
 
-    /* Add these hooks to each before_event_by_id hooks list */
+    /* Remove these hooks from each event_by_id hooks list */
 
     nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
         ltt_trace_per_cpu_tracefile_number(ts->parent.t);
@@ -1117,7 +1116,7 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self)
       for(k = 0 ; k < hooks->len ; k++) {
         hook = g_array_index(hooks, LttvTraceHook, k);
         lttv_hooks_remove_data(
-            lttv_hooks_by_id_find(tfs->parent.after_event_by_id, 
+            lttv_hooks_by_id_find(tfs->parent.event_by_id, 
            hook.id), hook.h, &g_array_index(hooks, LttvTraceHook, k));
       }
     }
@@ -1226,10 +1225,10 @@ void lttv_state_save_add_event_hooks(LttvTracesetState *self)
 
     for(j = 0 ; j < nb_tracefile ; j++) {
       tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
-      lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.after_event_by_id, 
-         hook_start.id), hook_start.h, NULL);
-      lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.after_event_by_id, 
-         hook_end.id), hook_end.h, NULL);
+      lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.event_by_id, 
+         hook_start.id), hook_start.h, NULL, LTTV_PRIO_STATE);
+      lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.event_by_id, 
+         hook_end.id), hook_end.h, NULL, LTTV_PRIO_STATE);
     }
   }
 }
@@ -1262,9 +1261,9 @@ void lttv_state_save_remove_event_hooks(LttvTracesetState *self)
     for(j = 0 ; j < nb_tracefile ; j++) {
       tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
       lttv_hooks_remove_data(lttv_hooks_by_id_find(
-          tfs->parent.after_event_by_id, hook_start.id), hook_start.h, NULL);
+          tfs->parent.event_by_id, hook_start.id), hook_start.h, NULL);
       lttv_hooks_remove_data(lttv_hooks_by_id_find(
-          tfs->parent.after_event_by_id, hook_end.id), hook_end.h, NULL);
+          tfs->parent.event_by_id, hook_end.id), hook_end.h, NULL);
     }
   }
 }
index 7529dc6545fa0410af4e957e8c9307391acdb0f5..06d69c0462e40a99b13a097e0c20cc7e6c119eee 100644 (file)
@@ -48,6 +48,9 @@
    contains an execution mode stack (e.g. irq within system call, called
    from user mode). */
 
+/* Priority of state hooks */
+#define LTTV_PRIO_STATE 25
+
 typedef struct _LttvTracesetState LttvTracesetState;
 typedef struct _LttvTracesetStateClass LttvTracesetStateClass;
 
index 764dffc25ca51bb4b80f4436ffae4ce8534412db..395b3ab2c2e9334c1b6e49af730553de74c29696 100644 (file)
@@ -190,7 +190,6 @@ init(LttvTracesetContext *self, LttvTraceset *ts)
   }
   lttv_process_traceset_seek_time(self, null_time);
   lttv_traceset_context_compute_time_span(self, &self->time_span);
-  self->e = NULL;
 
   self->pqueue = g_tree_new(compare_tracefile);
 }
@@ -691,17 +690,20 @@ void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start)
 
   LttEvent *event;
 
+  GTree *pqueue = self->ts_context->pqueue;
+
   nb_tracefile = ltt_trace_control_tracefile_number(self->t) +
       ltt_trace_per_cpu_tracefile_number(self->t);
 
   for(i = 0 ; i < nb_tracefile ; i++) {
     tfc = self->tracefiles[i];
     ltt_tracefile_seek_time(tfc->tf, start);
+    g_tree_remove(pqueue, tfc);
     event = ltt_tracefile_read(tfc->tf);
     tfc->e = event;
     if(event != NULL) {
       tfc->timestamp = ltt_event_time(event);
-      g_tree_insert(self->ts_context->pqueue, tfc, tfc);
+      g_tree_insert(pqueue, tfc, tfc);
     }
   }
 }
@@ -715,15 +717,6 @@ void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start)
 
   LttvTracefileContext *tfc;
 
-  /* Empty the pqueue */
-
-  while(TRUE){
-    tfc = NULL;
-    g_tree_foreach(self->pqueue, get_first, &tfc);
-    if(tfc == NULL) break;
-    g_tree_remove(self->pqueue, &(tfc->timestamp));
-  }
-
   nb_trace = lttv_traceset_number(self->ts);
   for(i = 0 ; i < nb_trace ; i++) {
     tc = self->traces[i];
@@ -732,6 +725,27 @@ void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start)
 }
 
 
+gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self, 
+                                              const LttEventPosition *pos)
+{
+  LttvTracefileContext *tfc = self;
+
+  LttEvent *event;
+
+  GTree *pqueue = self->t_context->ts_context->pqueue;
+  
+  ltt_tracefile_seek_position(tfc->tf, pos);
+  g_tree_remove(pqueue, tfc);
+  event = ltt_tracefile_read(tfc->tf);
+  tfc->e = event;
+  if(event != NULL) {
+    tfc->timestamp = ltt_event_time(event);
+    g_tree_insert(pqueue, tfc, tfc);
+  }
+
+
+}
+
 gboolean lttv_process_trace_seek_position(LttvTraceContext *self, 
                                         const LttvTraceContextPosition *pos)
 {
@@ -749,13 +763,7 @@ gboolean lttv_process_trace_seek_position(LttvTraceContext *self,
 
   for(i = 0 ; i < nb_tracefile ; i++) {
     tfc = self->tracefiles[i];
-    ltt_tracefile_seek_position(tfc->tf, pos->tf_pos[i]);
-    event = ltt_tracefile_read(tfc->tf);
-    tfc->e = event;
-    if(event != NULL) {
-      tfc->timestamp = ltt_event_time(event);
-      g_tree_insert(self->ts_context->pqueue, tfc, tfc);
-    }
+    lttv_process_tracefile_seek_position(tfc, pos->tf_pos[i]);
   }
 
   return TRUE;
@@ -778,15 +786,6 @@ gboolean lttv_process_traceset_seek_position(LttvTracesetContext *self,
   if(nb_trace != pos->nb_trace)
     return FALSE; /* Error */
 
-  /* Empty the pqueue */
-
-  while(TRUE){
-    tfc = NULL;
-    g_tree_foreach(self->pqueue, get_first, &tfc);
-    if(tfc == NULL) break;
-    g_tree_remove(self->pqueue, &(tfc->timestamp));
-  }
-
   for(i = 0 ; i < nb_trace ; i++) {
     tc = self->traces[i];
     sum_ret = sum_ret && lttv_process_trace_seek_position(tc, &pos->t_pos[i]);
This page took 0.027585 seconds and 4 git commands to generate.