add lttv kprobe support
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 29 Jan 2009 23:19:29 +0000 (23:19 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 29 Jan 2009 23:19:29 +0000 (23:19 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@3300 04897980-b3bd-0310-b5e0-8ef037075253

trunk/lttv/configure.in
trunk/lttv/lttv/lttv/print.c
trunk/lttv/lttv/lttv/state.c
trunk/lttv/lttv/lttv/state.h

index eb251dda06e5a5a84d98546aa46c6702f9a6f43d..5cfd51e331b77250eeab6bcebb1803ba1c66a9a1 100644 (file)
@@ -23,7 +23,7 @@
 AC_PREREQ(2.57)
 AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
 #AC_WITH_LTDL  # not needed ?
-AM_INIT_AUTOMAKE(lttv,0.12.8-27012009)
+AM_INIT_AUTOMAKE(lttv,0.12.9-29012009)
 AM_CONFIG_HEADER(config.h)
 AM_PROG_LIBTOOL
 
index 95c09ead0d26da6ec079a018fce736a637eca674..68661d7cac106cf742a7f2dbcdb57dc0ef5f9108 100644 (file)
@@ -62,14 +62,13 @@ static inline void print_enum_events(LttEvent *e, struct marker_field *f,
                && f->name == LTT_FIELD_SOFT_IRQ_ID) {
       g_string_append_printf(s, " [%s]",
         g_quark_to_string(ts->soft_irq_names[value]));
+    } else if (info->name == LTT_EVENT_KPROBE
+               && f->name == LTT_FIELD_IP) {
+      GQuark symbol = g_hash_table_lookup(ts->kprobe_hash,
+                                          (gconstpointer)value);
+      if (symbol)
+        g_string_append_printf(s, " [%s]", g_quark_to_string(symbol));
     }
-/* TODO : implement hash table.
-      else if (info->name == LTT_EVENT_KPROBE
-               && f->name = LTT_FIELD_IP) {
-      g_string_append_printf(s, " [%s]",
-        g_quark_to_string(ts->kprobe_symbols[value]));
-    }
-*/
   }
 }
 
index 3574868ad254fb3cba1c3379c882caa0e3c1162b..a3c6c9f14e2f6b011654d4a43676651322ba6299 100644 (file)
@@ -59,6 +59,7 @@ GQuark
     LTT_CHANNEL_SYSCALL_STATE,
     LTT_CHANNEL_TASK_STATE,
     LTT_CHANNEL_VM_STATE,
+    LTT_CHANNEL_KPROBE_STATE,
     LTT_CHANNEL_FS,
     LTT_CHANNEL_KERNEL,
     LTT_CHANNEL_MM,
@@ -97,7 +98,8 @@ GQuark
     LTT_EVENT_LIST_INTERRUPT,
     LTT_EVENT_SYS_CALL_TABLE,
     LTT_EVENT_SOFTIRQ_VEC,
-    LTT_EVENT_KPROBE_TABLE;
+    LTT_EVENT_KPROBE_TABLE,
+    LTT_EVENT_KPROBE;
 
 /* Fields Quarks */
 
@@ -324,6 +326,12 @@ static void expand_syscall_table(LttvTraceState *ts, int id)
   ts->nb_syscalls = new_nb;
 }
 
+static void expand_kprobe_table(LttvTraceState *ts, guint64 ip, char *symbol)
+{
+  g_hash_table_insert(ts->kprobe_hash, (gpointer)ip,
+    (gpointer)(glong)g_quark_from_string(symbol));
+}
+
 static void expand_trap_table(LttvTraceState *ts, int id)
 {
   guint new_nb = check_expand(ts->nb_traps, id);
@@ -1867,6 +1875,7 @@ typedef struct _LttvNameTables {
   guint nb_irqs;
   GQuark *soft_irq_names;
   guint nb_softirqs;
+  GHashTable *kprobe_hash;
 } LttvNameTables;
 
 
@@ -1996,6 +2005,8 @@ create_name_tables(LttvTraceState *tcs)
   g_array_free(hooks, TRUE);
 
   g_string_free(fe_name, TRUE);
+
+  name_tables->kprobe_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
 }
 
 
@@ -2019,6 +2030,7 @@ get_name_tables(LttvTraceState *tcs)
   tcs->soft_irq_names = name_tables->soft_irq_names;
   tcs->nb_irqs = name_tables->nb_irqs;
   tcs->nb_soft_irqs = name_tables->nb_softirqs;
+  tcs->kprobe_hash = name_tables->kprobe_hash;
 }
 
 
@@ -2040,6 +2052,7 @@ free_name_tables(LttvTraceState *tcs)
   if(name_tables->irq_names) g_free(name_tables->irq_names);
   if(name_tables->soft_irq_names) g_free(name_tables->soft_irq_names);
   if(name_tables) g_free(name_tables);
+  if(name_tables) g_hash_table_destroy(name_tables->kprobe_hash);
 } 
 
 #ifdef HASH_TABLE_DEBUG
@@ -2787,6 +2800,23 @@ static gboolean dump_syscall(void *hook_data, void *call_data)
   return FALSE;
 }
 
+static gboolean dump_kprobe(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);
+  LttvTraceHook *th = (LttvTraceHook *)hook_data;
+  guint64 ip;
+  char *symbol;
+
+  ip = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
+  symbol = ltt_event_get_string(e, lttv_trace_get_hook_field(th, 1));
+
+  expand_kprobe_table(ts, ip, symbol);
+
+  return FALSE;
+}
+
 static gboolean dump_softirq(void *hook_data, void *call_data)
 {
   LttvTracefileState *s = (LttvTracefileState *)call_data;
@@ -3399,7 +3429,7 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
     /* Find the eventtype id for the following events and register the
        associated by id hooks. */
 
-    hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 19);
+    hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 20);
     //hooks = g_array_set_size(hooks, 19); // Max possible number of hooks.
     //hn = 0;
 
@@ -3576,6 +3606,12 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
         FIELD_ARRAY(LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL),
         dump_syscall, NULL, &hooks);
 
+    lttv_trace_find_hook(ts->parent.t,
+        LTT_CHANNEL_KPROBE_STATE,
+        LTT_EVENT_KPROBE_TABLE,
+        FIELD_ARRAY(LTT_FIELD_IP, LTT_FIELD_SYMBOL),
+        dump_kprobe, NULL, &hooks);
+
     lttv_trace_find_hook(ts->parent.t,
         LTT_CHANNEL_SOFTIRQ_STATE,
         LTT_EVENT_SOFTIRQ_VEC,
@@ -4250,6 +4286,7 @@ static void module_init()
   LTT_CHANNEL_SYSCALL_STATE     = g_quark_from_string("syscall_state");
   LTT_CHANNEL_TASK_STATE     = g_quark_from_string("task_state");
   LTT_CHANNEL_VM_STATE     = g_quark_from_string("vm_state");
+  LTT_CHANNEL_KPROBE_STATE     = g_quark_from_string("kprobe_state");
   LTT_CHANNEL_FS     = g_quark_from_string("fs");
   LTT_CHANNEL_KERNEL     = g_quark_from_string("kernel");
   LTT_CHANNEL_MM     = g_quark_from_string("mm");
@@ -4286,6 +4323,7 @@ static void module_init()
   LTT_EVENT_SYS_CALL_TABLE = g_quark_from_string("sys_call_table");
   LTT_EVENT_SOFTIRQ_VEC = g_quark_from_string("softirq_vec");
   LTT_EVENT_KPROBE_TABLE = g_quark_from_string("kprobe_table");
+  LTT_EVENT_KPROBE = g_quark_from_string("kprobe");
 
   LTT_FIELD_SYSCALL_ID    = g_quark_from_string("syscall_id");
   LTT_FIELD_TRAP_ID       = g_quark_from_string("trap_id");
index 9f4fdd061ef36b25abbf944ed7a6aebf3a0095dc..d3d28ec4af8eeaf7034ca4182272b176ad3704da 100644 (file)
@@ -66,6 +66,7 @@ extern GQuark
     LTT_CHANNEL_SYSCALL_STATE,
     LTT_CHANNEL_TASK_STATE,
     LTT_CHANNEL_VM_STATE,
+    LTT_CHANNEL_KPROBE_STATE,
     LTT_CHANNEL_FS,
     LTT_CHANNEL_KERNEL,
     LTT_CHANNEL_MM,
@@ -104,7 +105,8 @@ extern GQuark
     LTT_EVENT_LIST_INTERRUPT,
     LTT_EVENT_SYS_CALL_TABLE,
     LTT_EVENT_SOFTIRQ_VEC,
-    LTT_EVENT_KPROBE_TABLE;
+    LTT_EVENT_KPROBE_TABLE,
+    LTT_EVENT_KPROBE;
 
 /* Fields Quarks */
 
@@ -372,6 +374,7 @@ struct _LttvTraceState {
   GQuark *irq_names;
   GQuark *soft_irq_names;
   LttTime *max_time_state_recomputed_in_seek;
+  GHashTable *kprobe_hash;
 
   /* Array of per cpu running process */
   LttvProcessState **running_process;
This page took 0.028869 seconds and 4 git commands to generate.