add usertrace support
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 01:25:38 +0000 (01:25 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 01:25:38 +0000 (01:25 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1623 04897980-b3bd-0310-b5e0-8ef037075253

13 files changed:
ltt/branches/poly/ltt/facility.c
ltt/branches/poly/ltt/ltt-private.h
ltt/branches/poly/ltt/trace.h
ltt/branches/poly/ltt/tracefile.c
ltt/branches/poly/lttv/lttv/batchtest.c
ltt/branches/poly/lttv/lttv/filter.c
ltt/branches/poly/lttv/lttv/print.c
ltt/branches/poly/lttv/lttv/state.c
ltt/branches/poly/lttv/lttv/state.h
ltt/branches/poly/lttv/lttv/stats.c
ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c
ltt/branches/poly/lttv/modules/gui/detailedevents/events.c
ltt/branches/poly/lttv/modules/text/textDump.c

index 9a302d2a1c6c0bbe739c7e2ca40922cd288e67f6..0440efb4e05ee721a15d86f79cee8ee4cfacf3e0 100644 (file)
@@ -281,7 +281,11 @@ void construct_fields(LttFacility *fac,
   type_descriptor_t *td;
   LttType *type;
 
-  field->name = g_quark_from_string(fld->name);
+       if(fld->name)
+         field->name = g_quark_from_string(fld->name);
+       else
+               fld->name = 0;
+
   if(fld->description) {
     len = strlen(fld->description);
     field->description = g_new(gchar, len+1);
index 98e5b342b879698f0d0b0c1a7ff5464f78690aaa..eceadc437c36f12879912ccb0fb109c889839add 100644 (file)
@@ -347,6 +347,9 @@ struct _LttTracefile{
   GQuark long_name;                  //tracefile complete filename
   GQuark name;                       //tracefile name
   guint cpu_num;                     //cpu number of the tracefile
+       guint   tid;                                                                                             //Usertrace tid, else 0
+       guint pgid;                                                                                              //Usertrace pgid, else 0
+       guint64 creation;                                                                        //Usertrace creation, else 0
   LttTrace * trace;                  //trace containing the tracefile
   int fd;                            //file descriptor 
   off_t file_size;                   //file size
index cd6bf7b7183a24ce1d05f716730ccb21e21d4438..0b63c9378aa6193eb966c44a1db97beb8818bf38 100644 (file)
@@ -86,7 +86,13 @@ GQuark ltt_tracefile_long_name(const LttTracefile *tf);
 
 /* get the cpu number of the tracefile */
 
-guint ltt_tracefile_num(LttTracefile *tf);
+guint ltt_tracefile_cpu(LttTracefile *tf);
+
+/* For usertrace */
+guint ltt_tracefile_tid(LttTracefile *tf);
+guint ltt_tracefile_pgid(LttTracefile *tf);
+guint64 ltt_tracefile_creation(LttTracefile *tf);
+
 
 LttTrace *ltt_tracefile_get_trace(LttTracefile *tf);
 
@@ -183,4 +189,6 @@ gint64 ltt_get_int(gboolean reverse_byte_order, gint size, void *data);
 
 guint64 ltt_get_uint(gboolean reverse_byte_order, gint size, void *data);
 
+LttTime ltt_interpolate_time_from_tsc(LttTracefile *tf, guint64 tsc);
+
 #endif // TRACE_H
index a1e19a7fae56871a6d0889a6101c35ce8f760780..00e3444400e56ca1262e139f59ffe5394a8f6dcc 100644 (file)
@@ -642,9 +642,12 @@ void get_absolute_pathname(const gchar *pathname, gchar * abs_pathname)
  * The left side is the name, the right side is the number.
  */
 
-int get_tracefile_name_number(const gchar *raw_name,
+int get_tracefile_name_number(gchar *raw_name,
                               GQuark *name,
-                              guint *num)
+                              guint *num,
+                                                                                                                       guint *tid,
+                                                                                                                       guint *pgid,
+                                                                                                                       guint64 *creation)
 {
   guint raw_name_len = strlen(raw_name);
   gchar char_name[PATH_MAX];
@@ -652,27 +655,84 @@ int get_tracefile_name_number(const gchar *raw_name,
   int underscore_pos;
   long int cpu_num;
   gchar *endptr;
+       gchar *tmpptr;
 
   for(i=raw_name_len-1;i>=0;i--) {
     if(raw_name[i] == '_') break;
   }
-  if(i==0)  /* Either not found or name length is 0 */
-    return -1;
-  underscore_pos = i;
+  if(i==-1) { /* Either not found or name length is 0 */
+               /* This is a userspace tracefile */
+               strncpy(char_name, raw_name, raw_name_len);
+               *name = g_quark_from_string(char_name);
+               *num = 0;       /* unknown cpu */
+               for(i=0;i<raw_name_len;i++) {
+                       if(raw_name[i] == '/') {
+                               break;
+                       }
+               }
+               i++;
+               for(;i<raw_name_len;i++) {
+                       if(raw_name[i] == '/') {
+                               break;
+                       }
+               }
+               i++;
+               for(;i<raw_name_len;i++) {
+                       if(raw_name[i] == '-') {
+                               break;
+                       }
+               }
+               if(i == raw_name_len) return -1;
+               i++;
+               tmpptr = &raw_name[i];
+               for(;i<raw_name_len;i++) {
+                       if(raw_name[i] == '.') {
+                               raw_name[i] = ' ';
+                               break;
+                       }
+               }
+               *tid = strtoul(tmpptr, &endptr, 10);
+               if(endptr == tmpptr)
+                       return -1; /* No digit */
+               if(*tid == ULONG_MAX)
+                       return -1; /* underflow / overflow */
+               i++;
+               tmpptr = &raw_name[i];
+               for(;i<raw_name_len;i++) {
+                       if(raw_name[i] == '.') {
+                               raw_name[i] = ' ';
+                               break;
+                       }
+               }
+               *pgid = strtoul(tmpptr, &endptr, 10);
+               if(endptr == tmpptr)
+                       return -1; /* No digit */
+               if(*pgid == ULONG_MAX)
+                       return -1; /* underflow / overflow */
+               i++;
+               tmpptr = &raw_name[i];
+               *creation = strtoull(tmpptr, &endptr, 10);
+               if(endptr == tmpptr)
+                       return -1; /* No digit */
+               if(*creation == G_MAXUINT64)
+                       return -1; /* underflow / overflow */
+       } else {
+               underscore_pos = i;
 
-  cpu_num = strtol(raw_name+underscore_pos+1, &endptr, 10);
+               cpu_num = strtol(raw_name+underscore_pos+1, &endptr, 10);
 
-  if(endptr == raw_name+underscore_pos+1)
-    return -1; /* No digit */
-  if(cpu_num == LONG_MIN || cpu_num == LONG_MAX)
-    return -1; /* underflow / overflow */
-  
-  strncpy(char_name, raw_name, underscore_pos);
-  
-  char_name[underscore_pos] = '\0';
+               if(endptr == raw_name+underscore_pos+1)
+                       return -1; /* No digit */
+               if(cpu_num == LONG_MIN || cpu_num == LONG_MAX)
+                       return -1; /* underflow / overflow */
+               
+               strncpy(char_name, raw_name, underscore_pos);
+               char_name[underscore_pos] = '\0';
+
+               *name = g_quark_from_string(char_name);
+               *num = cpu_num;
+       }
   
-  *name = g_quark_from_string(char_name);
-  *num = cpu_num;
   
   return 0;
 }
@@ -796,10 +856,12 @@ static int open_tracefiles(LttTrace *trace, gchar *root_path,
                        if(ret < 0) continue;
                } else if(S_ISREG(stat_buf.st_mode)) {
                        GQuark name;
-      guint num;
+      guint num, tid, pgid;
+                       guint64 creation;
       GArray *group;
-      
-      if(get_tracefile_name_number(rel_path, &name, &num))
+      num = tid = pgid = 0;
+                       creation = 0;
+      if(get_tracefile_name_number(rel_path, &name, &num, &tid, &pgid, &creation))
         continue; /* invalid name */
       
                        g_debug("Opening file.\n");
@@ -815,6 +877,9 @@ static int open_tracefiles(LttTrace *trace, gchar *root_path,
       tmp_tf.cpu_online = 1;
       tmp_tf.cpu_num = num;
       tmp_tf.name = name;
+                       tmp_tf.tid = tid;
+                       tmp_tf.pgid = pgid;
+                       tmp_tf.creation = creation;
 
       group = g_datalist_id_get_data(&trace->tracefiles, name);
       if(group == NULL) {
@@ -1427,11 +1492,25 @@ GQuark ltt_tracefile_long_name(const LttTracefile *tf)
 
 
 
-guint ltt_tracefile_num(LttTracefile *tf)
+guint ltt_tracefile_cpu(LttTracefile *tf)
 {
   return tf->cpu_num;
 }
 
+guint ltt_tracefile_tid(LttTracefile *tf)
+{
+  return tf->tid;
+}
+
+guint ltt_tracefile_pgid(LttTracefile *tf)
+{
+  return tf->pgid;
+}
+
+guint64 ltt_tracefile_creation(LttTracefile *tf)
+{
+  return tf->creation;
+}
 /*****************************************************************************
  * Get the number of blocks in the tracefile 
  ****************************************************************************/
@@ -1599,23 +1678,32 @@ fail:
   return 1;
 }
 
-/* Calculate the real event time based on the buffer boundaries */
-LttTime ltt_interpolate_time(LttTracefile *tf, LttEvent *event)
+LttTime ltt_interpolate_time_from_tsc(LttTracefile *tf, guint64 tsc)
 {
   LttTime time;
-
-//  time = ltt_time_from_uint64(
-//      cycles_2_ns(tf, (guint64)(tf->buffer.tsc - tf->buffer.begin.cycle_count)));
-  time = ltt_time_from_uint64(
-      (double)(tf->buffer.tsc - tf->trace->start_tsc) 
-                                                                                                                                       * (1000000000.0 / tf->trace->freq_scale)
-                                  / (double)tf->trace->start_freq);
-  //time = ltt_time_add(tf->buffer.begin.timestamp, time);
-  time = ltt_time_add(tf->trace->start_time_from_tsc, time);
-
+       
+       if(tsc > tf->trace->start_tsc) {
+               time = ltt_time_from_uint64(
+                               (double)(tsc - tf->trace->start_tsc) 
+                                                                                                                                               * (1000000000.0 / tf->trace->freq_scale)
+                                                                                                                                               / (double)tf->trace->start_freq);
+               time = ltt_time_add(tf->trace->start_time_from_tsc, time);
+       } else {
+               time = ltt_time_from_uint64(
+                               (double)(tf->trace->start_tsc - tsc)
+                                                                                                                                               * (1000000000.0 / tf->trace->freq_scale)
+                                                                                                                                               / (double)tf->trace->start_freq);
+               time = ltt_time_sub(tf->trace->start_time_from_tsc, time);
+       }
   return time;
 }
 
+/* Calculate the real event time based on the buffer boundaries */
+LttTime ltt_interpolate_time(LttTracefile *tf, LttEvent *event)
+{
+       return ltt_interpolate_time_from_tsc(tf, tf->buffer.tsc);
+}
+
 
 /* Get the current event of the tracefile : valid until the next read */
 LttEvent *ltt_tracefile_get_event(LttTracefile *tf)
@@ -1830,12 +1918,19 @@ static gint map_block(LttTracefile * tf, guint block_num)
                                               &header->begin.cycle_count);
   tf->buffer.begin.freq = ltt_get_uint64(LTT_GET_BO(tf),
                                          &header->begin.freq);
-  tf->buffer.begin.timestamp = ltt_time_add(
+       if(tf->buffer.begin.freq == 0)
+               tf->buffer.begin.freq = tf->trace->start_freq;
+
+  tf->buffer.begin.timestamp = ltt_interpolate_time_from_tsc(tf, 
+                                                                                                                                                                       tf->buffer.begin.cycle_count);
+#if 0
+               ltt_time_add(
                                 ltt_time_from_uint64(
                                   (double)(tf->buffer.begin.cycle_count
                                   - tf->trace->start_tsc) * 1000000.0
                                     / (double)tf->trace->start_freq),
-                                tf->trace->start_time_from_tsc);
+                                                                                                                       tf->trace->start_time_from_tsc);
+#endif //0
 #if 0
 
   tf->buffer.end.timestamp = ltt_time_add(
@@ -1851,15 +1946,21 @@ static gint map_block(LttTracefile * tf, guint block_num)
                                               &header->end.cycle_count);
   tf->buffer.end.freq = ltt_get_uint64(LTT_GET_BO(tf),
                                        &header->end.freq);
+       if(tf->buffer.end.freq == 0)
+               tf->buffer.end.freq = tf->trace->start_freq;
+       
   tf->buffer.lost_size = ltt_get_uint32(LTT_GET_BO(tf),
                                         &header->lost_size);
-  tf->buffer.end.timestamp = ltt_time_add(
+  tf->buffer.end.timestamp = ltt_interpolate_time_from_tsc(tf,
+                                                                                                                                                               tf->buffer.end.cycle_count);
+#if 0
+               ltt_time_add(
                                 ltt_time_from_uint64(
                                   (double)(tf->buffer.end.cycle_count
                                   - tf->trace->start_tsc) * 1000000.0
                                     / (double)tf->trace->start_freq),
                                 tf->trace->start_time_from_tsc);
+#endif //0
   tf->buffer.tsc =  tf->buffer.begin.cycle_count;
   tf->event.tsc = tf->buffer.tsc;
   tf->buffer.freq = tf->buffer.begin.freq;
index 1a48d6a150d7819bfecc3481c58fff2c73435908..b38a1469e79278b30a38c72443bf55d98e1e7fe1 100644 (file)
@@ -202,7 +202,7 @@ gboolean count_event(void *hook_data, void __UNUSED__ *call_data)
     g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/0x%x",
   g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile))),
   g_quark_to_string(ltt_tracefile_name(tracefile)), 
-  ltt_tracefile_num(tracefile), nb_block, offset);
+  tfs->cpu, nb_block, offset);
     g_warning("last time %lu.%lu vs current %lu.%lu",
   count_previous_time.tv_sec, count_previous_time.tv_nsec,
   time.tv_sec, time.tv_nsec);
@@ -316,7 +316,7 @@ static void compute_tracefile(LttTracefile *tracefile, void *hook_data)
   
   g_warning("test %s test", g_quark_to_string(ltt_tracefile_name(tracefile)));
   g_string_printf(filename, "%s.%s.%u.trace", a_dump_tracefiles,
-      mod_name, ltt_tracefile_num(tracefile));
+      mod_name, ltt_tracefile_cpu(tracefile));
   fp = fopen(filename->str, "w");
   if(fp == NULL) g_error("Cannot open %s", filename->str);
   g_string_free(filename, TRUE);
@@ -346,7 +346,7 @@ static void compute_tracefile(LttTracefile *tracefile, void *hook_data)
       g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/0x%x",
     g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile))),
     g_quark_to_string(ltt_tracefile_name(tracefile)), 
-    ltt_tracefile_num(tracefile), nb_block, offset);
+    ltt_tracefile_cpu(tracefile), nb_block, offset);
       g_warning("last time %lu.%lu vs current %lu.%lu",
     previous_time.tv_sec, previous_time.tv_nsec,
     time.tv_sec, time.tv_nsec);
index abdeb464bab1bdd18f4010aeafa1e722e3a75d92..567b54f0a797d7094f7e8a614e48fe2997848540 100644 (file)
@@ -1815,8 +1815,9 @@ lttv_filter_tree_parse(
 
   LttvProcessState* state;
   
-  guint cpu = ltt_tracefile_num(context->tf);
   LttvTraceState *ts = (LttvTraceState*)context->t_context;
+  LttvTracefileState *tfs = (LttvTracefileState*)context;
+  guint cpu = tfs->cpu;
   state = ts->running_process[cpu];
   
   /*
index 50c7c67473dbcb9560950892d83633b296a1f731..a6fcd2d19d0ae0ae46fdf7c3bcb778302eaeebd5 100644 (file)
@@ -161,7 +161,7 @@ void lttv_event_to_string(LttEvent *e, GString *s,
 
   LttTime time;
 
-  guint cpu = ltt_tracefile_num(tfs->parent.tf);
+  guint cpu = tfs->cpu;
   LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
   LttvProcessState *process = ts->running_process[cpu];
 
index 6c7fb339383948130069dff9ad0e9d22d4eddb03..5eb533facfcb4c068426dba11726dd0881601442 100644 (file)
@@ -259,18 +259,30 @@ init(LttvTracesetState *self, LttvTraceset *ts)
     get_max_time(tcs);
 
     nb_tracefile = tc->tracefiles->len;
-#if 0
+    tcs->processes = NULL;
+    tcs->running_process = g_new(LttvProcessState*, 
+                                 ltt_trace_get_num_cpu(tc->t));
+    restore_init_state(tcs);
     for(j = 0 ; j < nb_tracefile ; j++) {
       tfcs = 
           LTTV_TRACEFILE_STATE(g_array_index(tc->tracefiles,
                                           LttvTracefileContext*, j));
       tfcs->tracefile_name = ltt_tracefile_name(tfcs->parent.tf);
+                       tfcs->cpu = ltt_tracefile_cpu(tfcs->parent.tf);
+                       
+                       if(ltt_tracefile_tid(tfcs->parent.tf) != 0) {
+                               /* It's a Usertrace */
+                               LttvProcessState *process;
+                               LttTime timestamp = 
+                                       ltt_interpolate_time_from_tsc(tfcs->parent.tf,
+                                                       ltt_tracefile_creation(tfcs->parent.tf));
+                               process = lttv_state_find_process_or_create(
+                                                                                               tcs,
+                                                                                               0, ltt_tracefile_tid(tfcs->parent.tf),
+                                                                                               &timestamp);
+                               process->usertrace = tfcs;
+                       }
     }
-#endif //0
-    tcs->processes = NULL;
-    tcs->running_process = g_new(LttvProcessState*, 
-                                 ltt_trace_get_num_cpu(tc->t));
-    restore_init_state(tcs);
   }
 }
 
@@ -940,8 +952,8 @@ static void push_state(LttvTracefileState *tfs, LttvExecutionMode t,
 {
   LttvExecutionState *es;
   
-  guint cpu = ltt_tracefile_num(tfs->parent.tf);
   LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
+  guint cpu = tfs->cpu;
 
 #ifdef HASH_TABLE_DEBUG
   hash_table_check(ts->processes);
@@ -967,7 +979,7 @@ static void push_state(LttvTracefileState *tfs, LttvExecutionMode t,
 
 static void pop_state(LttvTracefileState *tfs, LttvExecutionMode t)
 {
-  guint cpu = ltt_tracefile_num(tfs->parent.tf);
+  guint cpu = tfs->cpu;
   LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
   LttvProcessState *process = ts->running_process[cpu];
 
@@ -1019,6 +1031,7 @@ lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent,
   //process->last_cpu = tfs->cpu_name;
   //process->last_cpu_index = ltt_tracefile_num(((LttvTracefileContext*)tfs)->tf);
        process->kernel_thread = 0;
+       process->usertrace = NULL;
 
   g_info("Process %u, core %p", process->pid, process);
   g_hash_table_insert(tcs->processes, process, process);
@@ -1249,7 +1262,7 @@ static gboolean soft_irq_exit(void *hook_data, void *call_data)
 static gboolean schedchange(void *hook_data, void *call_data)
 {
   LttvTracefileState *s = (LttvTracefileState *)call_data;
-  guint cpu = ltt_tracefile_num(s->parent.tf);
+  guint cpu = s->cpu;
   LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
   LttvProcessState *process = ts->running_process[cpu];
   LttvProcessState *old_process = ts->running_process[cpu];
@@ -1298,6 +1311,8 @@ static gboolean schedchange(void *hook_data, void *call_data)
                   &s->parent.timestamp);
   process->state->s = LTTV_STATE_RUN;
   process->cpu = cpu;
+       if(process->usertrace)
+               process->usertrace->cpu = cpu;
  // process->last_cpu_index = ltt_tracefile_num(((LttvTracefileContext*)s)->tf);
   process->state->change = s->parent.timestamp;
   return FALSE;
@@ -1311,7 +1326,7 @@ static gboolean process_fork(void *hook_data, void *call_data)
   guint parent_pid;
   guint child_pid;
   LttvProcessState *zombie_process;
-  guint cpu = ltt_tracefile_num(s->parent.tf);
+  guint cpu = s->cpu;
   LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
   LttvProcessState *process = ts->running_process[cpu];
   LttvProcessState *child_process;
@@ -1357,8 +1372,10 @@ static gboolean process_fork(void *hook_data, void *call_data)
      *
      * Simply put a correct parent.
      */
-    g_assert(0); /* This is a problematic case : the process has been created
-                    before the fork event */
+               //It can also happen when created by a usertrace. In that case, it's
+               //correct.
+    //g_assert(0); /* This is a problematic case : the process has been created
+    //                before the fork event */
     child_process->ppid = process->pid;
   }
        g_assert(child_process->name == LTTV_STATE_UNNAMED);
@@ -1374,7 +1391,7 @@ static gboolean process_kernel_thread(void *hook_data, void *call_data)
   LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
   LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data;
   guint pid;
-  guint cpu = ltt_tracefile_num(s->parent.tf);
+  guint cpu = s->cpu;
   LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
   LttvProcessState *process;
   LttvExecutionState *es;
@@ -1397,7 +1414,7 @@ static gboolean process_exit(void *hook_data, void *call_data)
   LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data;
   LttField *f;
   guint pid;
-  guint cpu = ltt_tracefile_num(s->parent.tf);
+  guint cpu = s->cpu;
   LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
   LttvProcessState *process = ts->running_process[cpu];
 
@@ -1466,7 +1483,7 @@ static gboolean process_exec(void *hook_data, void *call_data)
   LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
   LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data;
   //gchar *name;
-  guint cpu = ltt_tracefile_num(s->parent.tf);
+  guint cpu = s->cpu;
   LttvProcessState *process = ts->running_process[cpu];
 
   /* PID of the process to release */
@@ -1495,7 +1512,7 @@ static gboolean enum_process_state(void *hook_data, void *call_data)
   guint parent_pid;
   guint pid;
   gchar * command;
-  guint cpu = ltt_tracefile_num(s->parent.tf);
+  guint cpu = s->cpu;
   LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
   LttvProcessState *process = ts->running_process[cpu];
   LttvProcessState *parent_process;
@@ -1843,6 +1860,13 @@ static gboolean state_save_after_trace_hook(void *hook_data, void *call_data)
   return FALSE;
 }
 
+guint lttv_state_current_cpu(LttvTracefileState *tfs)
+{
+       return tfs->cpu;
+}
+
+
+
 #if 0
 static gboolean block_start(void *hook_data, void *call_data)
 {
index c1095d80be13403bd063850b3a9dbfd0129a22b1..3ddc018e7dfc5db4714e37e1b950e1c0e8b94637 100644 (file)
@@ -190,7 +190,6 @@ typedef struct _LttvExecutionState {
   LttvProcessStatus s;
 } LttvExecutionState;
 
-
 typedef struct _LttvProcessState {
   guint pid;
   guint ppid;
@@ -207,6 +206,7 @@ typedef struct _LttvProcessState {
                                the active or inactive runqueue)*/
        gboolean kernel_thread;         /* Is this thread a kernel_thread ? */
 //  guint  last_tracefile_index;    /* index in the trace for cpu tracefile */
+       LttvTracefileState      *usertrace;             /* Associated usertrace */
   /* opened file descriptors, address map?... */
 } LttvProcessState;
 
@@ -303,6 +303,7 @@ struct _LttvTracefileState {
 
   //LttvProcessState *process;
   GQuark tracefile_name;
+       guint cpu;      /* Current cpu of the tracefile */
 //  guint saved_position;
 };
 
index 143c14e276300b9264dacd03e7b662b05bc4adfa..f7ba2ff0585ba9418f18e802d0574713d5692aad 100644 (file)
@@ -417,7 +417,7 @@ find_event_tree(LttvTracefileStats *tfcs,
 static void update_event_tree(LttvTracefileStats *tfcs) 
 {
   LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
-  guint cpu = ltt_tracefile_num(tfcs->parent.parent.tf);
+  guint cpu = tfcs->parent.cpu;
   LttvProcessState *process = ts->running_process[cpu];
   LttvExecutionState *es = process->state;
 
@@ -431,7 +431,7 @@ static void update_event_tree(LttvTracefileStats *tfcs)
 static void mode_change(LttvTracefileStats *tfcs)
 {
   LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
-  guint cpu = ltt_tracefile_num(tfcs->parent.parent.tf);
+  guint cpu = tfcs->parent.cpu;
   LttvProcessState *process = ts->running_process[cpu];
   LttvAttributeValue cpu_time; 
 
@@ -448,7 +448,7 @@ static void mode_change(LttvTracefileStats *tfcs)
 static void mode_end(LttvTracefileStats *tfcs)
 {
   LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
-  guint cpu = ltt_tracefile_num(tfcs->parent.parent.tf);
+  guint cpu = tfcs->parent.cpu;
   LttvProcessState *process = ts->running_process[cpu];
   LttvAttributeValue elapsed_time, cpu_time; 
 
index c79b0a4bbb81529bd0142b7f57c3b0fc04635011..15739dd503826ee5f954300cd3f592b7bd44c97a 100644 (file)
@@ -363,12 +363,12 @@ int before_schedchange_hook(void *hook_data, void *call_data)
      * draw items from the beginning of the read for it. If it is not
      * present, it's a new process and it was not present : it will
      * be added after the state update.  */
-    guint cpu = ltt_tracefile_num(tfc->tf);
+    guint cpu = tfs->cpu;
     LttvProcessState *process = ts->running_process[cpu];
     /* unknown state, bad current pid */
     if(process->pid != pid_out)
       process = lttv_state_find_process(ts,
-          ltt_tracefile_num(tfc->tf), pid_out);
+          tfs->cpu, pid_out);
     
     if(process != NULL) {
       /* Well, the process_out existed : we must get it in the process hash
@@ -524,7 +524,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
      * be added after the state update.  */
     LttvProcessState *process;
     process = lttv_state_find_process(ts,
-        ltt_tracefile_num(tfc->tf), pid_in);
+        tfs->cpu, pid_in);
     
     if(process != NULL) {
       /* Well, the process existed : we must get it in the process hash
@@ -538,7 +538,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
       
       hashed_process_data = processlist_get_process_data(process_list,
               pid_in,
-              ltt_tracefile_num(tfc->tf),
+              tfs->cpu,
               &birth,
               tfc->t_context->index);
       if(hashed_process_data == NULL)
@@ -550,7 +550,7 @@ int before_schedchange_hook(void *hook_data, void *call_data)
         processlist_add(process_list,
             drawing,
             pid_in,
-            ltt_tracefile_num(tfc->tf),
+            tfs->cpu,
             process->ppid,
             &birth,
             tfc->t_context->index,
@@ -748,7 +748,7 @@ int after_schedchange_hook(void *hook_data, void *call_data)
   /* Find process pid_in in the list... */
   //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
   //process_in = tfs->process;
-  guint cpu = ltt_tracefile_num(tfc->tf);
+  guint cpu = tfs->cpu;
   process_in = ts->running_process[cpu];
   /* It should exist, because we are after the state update. */
 #ifdef EXTRA_CHECK
@@ -861,7 +861,7 @@ int before_execmode_hook(void *hook_data, void *call_data)
    */
   /* For the pid */
   //LttvProcessState *process = tfs->process;
-  guint cpu = ltt_tracefile_num(tfc->tf);
+  guint cpu = tfs->cpu;
   LttvProcessState *process = ts->running_process[cpu];
   g_assert(process != NULL);
 
@@ -1052,7 +1052,7 @@ int before_process_exit_hook(void *hook_data, void *call_data)
 
   /* Add process to process list (if not present) */
   //LttvProcessState *process = tfs->process;
-  guint cpu = ltt_tracefile_num(tfc->tf);
+  guint cpu = tfs->cpu;
   LttvProcessState *process = ts->running_process[cpu];
   guint pid = process->pid;
   LttTime birth;
@@ -1554,7 +1554,7 @@ int after_process_exit_hook(void *hook_data, void *call_data)
 
   /* Add process to process list (if not present) */
   //LttvProcessState *process = tfs->process;
-  guint cpu = ltt_tracefile_num(tfc->tf);
+  guint cpu = tfs->cpu;
   LttvProcessState *process = ts->running_process[cpu];
 
   /* It should exist, because we are after the state update. */
@@ -1648,7 +1648,7 @@ int after_fs_exec_hook(void *hook_data, void *call_data)
 
   LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
 
-  guint cpu = ltt_tracefile_num(tfc->tf);
+  guint cpu = tfs->cpu;
   LttvProcessState *process = ts->running_process[cpu];
   g_assert(process != NULL);
 
@@ -1749,7 +1749,7 @@ int after_event_enum_process_hook(void *hook_data, void *call_data)
   /* Find process pid_in in the list... */
   process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
   //process_in = tfs->process;
-  //guint cpu = ltt_tracefile_num(tfc->tf);
+  //guint cpu = tfs->cpu;
   //process_in = ts->running_process[cpu];
   /* It should exist, because we are after the state update. */
 #ifdef EXTRA_CHECK
@@ -2228,7 +2228,7 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
     for(i=0;i<tc->tracefiles->len;i++) {
       tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i);
       if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU
-          && ltt_tracefile_num(tfc->tf) == process_info->cpu)
+          && tfs->cpu == process_info->cpu)
         break;
 
     }
index 705697c66ae6556856e9332810e9d5ab94266b12..63a1bbf88e381a043f08f71b2b540c3056136649 100644 (file)
@@ -1481,6 +1481,7 @@ int event_hook(void *hook_data, void *call_data)
 {
   EventViewerData *event_viewer_data = (EventViewerData*)hook_data;
   LttvTracefileContext *tfc = (LttvTracefileContext*)call_data;
+  LttvTracefileState *tfs = (LttvTracefileState*)call_data;
   LttEvent *e = ltt_tracefile_get_event(tfc->tf);
 
   LttvFilter *filter = event_viewer_data->main_win_filter;
@@ -1493,7 +1494,7 @@ int event_hook(void *hook_data, void *call_data)
   LttEventType *event_type = ltt_event_eventtype(e);
   LttTime time = ltt_event_time(e);
 
-  guint cpu = ltt_tracefile_num(tfc->tf);
+  guint cpu = tfs->cpu;
   LttvTraceState *ts = (LttvTraceState*)tfc->t_context;
   LttvProcessState *process = ts->running_process[cpu];
   
index dbb8ec0fbcf1d09c7e21f38b4cd2d4c4631199c6..a823d948b3dfaf8ab3350a3342e308b90154241c 100644 (file)
@@ -236,7 +236,7 @@ static int write_event_content(void *hook_data, void *call_data)
 
   LttvFilter *filter;
 
-  guint cpu = ltt_tracefile_num(tfs->parent.tf);
+  guint cpu = tfs->cpu;
   LttvTraceState *ts = (LttvTraceState*)tfc->t_context;
   LttvProcessState *process = ts->running_process[cpu];
 
This page took 0.036648 seconds and 4 git commands to generate.