start changes for irq resource monitoring
authorpmf <pmf@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 31 Jul 2007 19:46:13 +0000 (19:46 +0000)
committerpmf <pmf@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 31 Jul 2007 19:46:13 +0000 (19:46 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2561 04897980-b3bd-0310-b5e0-8ef037075253

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

index 71be9d506cc7b877438c9aeeeff7b17eab0d236a..4ef1e6419cabad04caf6b9fc334e911a728a1605 100644 (file)
@@ -134,6 +134,11 @@ LttvCPUMode
   LTTV_CPU_IRQ,
   LTTV_CPU_TRAP;
 
+LttvIRQMode
+  LTTV_IRQ_UNKNOWN,
+  LTTV_IRQ_IDLE,
+  LTTV_IRQ_BUSY;
+
 static GQuark
   LTTV_STATE_TRACEFILES,
   LTTV_STATE_PROCESSES,
@@ -384,6 +389,7 @@ static void
 init(LttvTracesetState *self, LttvTraceset *ts)
 {
   guint i, j, nb_trace, nb_tracefile, nb_cpu;
+  guint64 nb_irq;
 
   LttvTraceContext *tc;
 
@@ -414,9 +420,11 @@ init(LttvTracesetState *self, LttvTraceset *ts)
 
     nb_tracefile = tc->tracefiles->len;
     nb_cpu = ltt_trace_get_num_cpu(tc->t);
+    nb_irq = tcs->nb_irqs;
     tcs->processes = NULL;
     tcs->usertraces = NULL;
     tcs->running_process = g_new(LttvProcessState*, nb_cpu);
+
     /* init cpu resource stuff */
     tcs->cpu_states = g_new(LttvCPUState, nb_cpu);
     for(j = 0; j<nb_cpu; j++) {
@@ -424,6 +432,13 @@ init(LttvTracesetState *self, LttvTraceset *ts)
       g_assert(tcs->cpu_states[j].mode_stack != NULL);
     } 
 
+    /* init irq resource stuff */
+    tcs->irq_states = g_new(LttvIRQState, nb_irq);
+    for(j = 0; j<nb_irq; j++) {
+      tcs->irq_states[j].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvIRQMode));
+      g_assert(tcs->irq_states[j].mode_stack != NULL);
+    } 
+
     restore_init_state(tcs);
     for(j = 0 ; j < nb_tracefile ; j++) {
       tfcs = 
@@ -1611,6 +1626,27 @@ static void cpu_pop_mode(LttvCPUState *cpust)
     g_array_set_size(cpust->mode_stack, cpust->mode_stack->len - 1);
 }
 
+/* clears the stack and sets the state passed as argument */
+static void irq_set_base_mode(LttvIRQState *irqst, LttvIRQMode state)
+{
+  g_array_set_size(irqst->mode_stack, 1);
+  ((GQuark *)irqst->mode_stack->data)[0] = state;
+}
+
+static void irq_push_mode(LttvIRQState *irqst, LttvIRQMode state)
+{
+  g_array_set_size(irqst->mode_stack, irqst->mode_stack->len + 1);
+  ((GQuark *)irqst->mode_stack->data)[irqst->mode_stack->len - 1] = state;
+}
+
+static void irq_pop_mode(LttvIRQState *irqst)
+{
+  if(irqst->mode_stack->len == 1)
+    irq_set_base_mode(irqst, LTTV_IRQ_UNKNOWN);
+  else
+    g_array_set_size(irqst->mode_stack, irqst->mode_stack->len - 1);
+}
+
 static void push_state(LttvTracefileState *tfs, LttvExecutionMode t, 
     guint state_id)
 {
@@ -1991,6 +2027,7 @@ static gboolean trap_exit(void *hook_data, void *call_data)
 static gboolean irq_entry(void *hook_data, void *call_data)
 {
   LttvTracefileState *s = (LttvTracefileState *)call_data;
+  LttvTraceState *ts = (LttvTraceState *)s->parent.t_context;
   LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
   guint8 fac_id = ltt_event_facility_id(e);
   guint8 ev_id = ltt_event_eventtype_id(e);
@@ -2021,6 +2058,9 @@ static gboolean irq_entry(void *hook_data, void *call_data)
   /* update cpu status */
   cpu_push_mode(s->cpu_state, LTTV_CPU_IRQ);
 
+  /* update irq status */
+  irq_push_mode(&ts->irq_states[irq], LTTV_IRQ_BUSY);
+
   return FALSE;
 }
 
@@ -3574,6 +3614,10 @@ static void module_init()
   LTTV_CPU_BUSY = g_quark_from_string("busy");
   LTTV_CPU_IRQ = g_quark_from_string("irq");
   LTTV_CPU_TRAP = g_quark_from_string("trap");
+
+  LTTV_IRQ_UNKNOWN = g_quark_from_string("unknown");
+  LTTV_IRQ_IDLE = g_quark_from_string("idle");
+  LTTV_IRQ_BUSY = g_quark_from_string("busy");
 }
 
 static void module_destroy() 
index c419e43fe0e132fc5453448aa35dc5b1e227383e..eef1c7a551b4f54645c9bf421508c116ed943561 100644 (file)
@@ -206,6 +206,12 @@ extern LttvCPUMode
   LTTV_CPU_IRQ,
   LTTV_CPU_TRAP;
 
+typedef GQuark LttvIRQMode;
+extern LttvIRQMode
+  LTTV_IRQ_UNKNOWN,
+  LTTV_IRQ_IDLE,
+  LTTV_IRQ_BUSY;
+
 typedef struct _LttvExecutionState {
   LttvExecutionMode t;
   LttvExecutionSubmode n;
@@ -289,6 +295,10 @@ typedef struct _LttvCPUState {
   GArray *mode_stack;
 } LttvCPUState;
 
+typedef struct _LttvIRQState {
+  GArray *mode_stack;
+} LttvIRQState;
+
 struct _LttvTraceState {
   LttvTraceContext parent;
 
@@ -313,6 +323,7 @@ struct _LttvTraceState {
   LttvProcessState **running_process;
   gboolean has_precomputed_states;
   LttvCPUState *cpu_states; /* state of each cpu */
+  LttvIRQState *irq_states; /* state of each irq handler */
 };
 
 struct _LttvTraceStateClass {
This page took 0.029471 seconds and 4 git commands to generate.