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,
LTT_EVENT_REQUEST_COMPLETE,
LTT_EVENT_LIST_INTERRUPT,
LTT_EVENT_SYS_CALL_TABLE,
- LTT_EVENT_SOFTIRQ_VEC;
+ LTT_EVENT_SOFTIRQ_VEC,
+ LTT_EVENT_KPROBE_TABLE,
+ LTT_EVENT_KPROBE;
/* Fields Quarks */
LTT_FIELD_ACTION,
LTT_FIELD_ID,
LTT_FIELD_ADDRESS,
- LTT_FIELD_SYMBOL;
+ LTT_FIELD_SYMBOL,
+ LTT_FIELD_IP;
LttvExecutionMode
LTTV_STATE_MODE_UNKNOWN,
static LttvBdevState *bdevstate_copy(LttvBdevState *bds);
+#if (__SIZEOF_LONG__ == 4)
+guint guint64_hash(gconstpointer key)
+{
+ guint64 ukey = *(const guint64 *)key;
+
+ return (guint)ukey ^ (guint)(ukey >> 32);
+}
+
+gboolean guint64_equal(gconstpointer a, gconstpointer b)
+{
+ guint64 ua = *(const guint64 *)a;
+ guint64 ub = *(const guint64 *)b;
+
+ return ua == ub;
+}
+#endif
+
void lttv_state_save(LttvTraceState *self, LttvAttribute *container)
{
LTTV_TRACE_STATE_GET_CLASS(self)->state_save(self, container);
ts->nb_syscalls = new_nb;
}
+static void expand_kprobe_table(LttvTraceState *ts, guint64 ip, char *symbol)
+{
+#if (__SIZEOF_LONG__ == 4)
+ guint64 *ip_ptr = g_new(guint64, 1);
+ g_hash_table_insert(ts->kprobe_hash, ip_ptr,
+ (gpointer)(glong)g_quark_from_string(symbol));
+#else
+ g_hash_table_insert(ts->kprobe_hash, (gpointer)ip,
+ (gpointer)(glong)g_quark_from_string(symbol));
+#endif
+}
+
static void expand_trap_table(LttvTraceState *ts, int id)
{
guint new_nb = check_expand(ts->nb_traps, id);
/* reset cpu states */
if(self->cpu_states[i].mode_stack->len > 0) {
g_array_remove_range(self->cpu_states[i].mode_stack, 0, self->cpu_states[i].mode_stack->len);
- self->cpu_states[i].last_irq = -1;
+ if(self->cpu_states[i].irq_stack->len)
+ g_array_remove_range(self->cpu_states[i].irq_stack, 0, self->cpu_states[i].irq_stack->len);
self->cpu_states[i].last_soft_irq = -1;
self->cpu_states[i].last_trap = -1;
}
tcs->cpu_states = g_new(LttvCPUState, nb_cpu);
for(j = 0; j<nb_cpu; j++) {
tcs->cpu_states[j].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
- tcs->cpu_states[j].last_irq = -1;
+ tcs->cpu_states[j].irq_stack = g_array_new(FALSE, FALSE, sizeof(gint));
tcs->cpu_states[j].last_soft_irq = -1;
tcs->cpu_states[j].last_trap = -1;
g_assert(tcs->cpu_states[j].mode_stack != NULL);
retval = g_new(LttvCPUState, n);
for(i=0; i<n; i++) {
- retval[i].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
- retval[i].last_irq = states[i].last_irq;
retval[i].last_soft_irq = states[i].last_soft_irq;
retval[i].last_trap = states[i].last_trap;
+
+ retval[i].irq_stack = g_array_new(FALSE, FALSE, sizeof(gint));
+ g_array_set_size(retval[i].irq_stack, states[i].irq_stack->len);
+ for(j=0; j<states[i].irq_stack->len; j++) {
+ g_array_index(retval[i].irq_stack, gint, j) = g_array_index(states[i].irq_stack, gint, j);
+ }
+
+ retval[i].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
g_array_set_size(retval[i].mode_stack, states[i].mode_stack->len);
for(j=0; j<states[i].mode_stack->len; j++) {
g_array_index(retval[i].mode_stack, GQuark, j) = g_array_index(states[i].mode_stack, GQuark, j);
for(i=0; i<n; i++) {
g_array_free(states[i].mode_stack, TRUE);
+ g_array_free(states[i].irq_stack, TRUE);
}
g_free(states);
guint nb_irqs;
GQuark *soft_irq_names;
guint nb_softirqs;
+ GHashTable *kprobe_hash;
} LttvNameTables;
LTT_CHANNEL_KERNEL,
LTT_EVENT_TRAP_ENTRY,
FIELD_ARRAY(LTT_FIELD_TRAP_ID),
+ NULL, NULL, &hooks) ||
+ !lttv_trace_find_hook(tcs->parent.t,
+ LTT_CHANNEL_KERNEL,
+ LTT_EVENT_PAGE_FAULT_ENTRY,
+ FIELD_ARRAY(LTT_FIELD_TRAP_ID),
NULL, NULL, &hooks)) {
// th = lttv_trace_hook_get_first(&th);
g_array_free(hooks, TRUE);
g_string_free(fe_name, TRUE);
+
+#if (__SIZEOF_LONG__ == 4)
+ name_tables->kprobe_hash = g_hash_table_new_full(guint64_hash, guint64_equal,
+ g_free, NULL);
+#else
+ name_tables->kprobe_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
+#endif
}
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;
}
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
cpu_push_mode(s->cpu_state, LTTV_CPU_IRQ);
/* update irq status */
- s->cpu_state->last_irq = irq;
+ g_array_append_val(s->cpu_state->irq_stack, irq);
irq_push_mode(&ts->irq_states[irq], LTTV_IRQ_BUSY);
return FALSE;
cpu_pop_mode(s->cpu_state);
/* update irq status */
- if (s->cpu_state->last_irq != -1)
- irq_pop_mode(&ts->irq_states[s->cpu_state->last_irq]);
+ if (s->cpu_state->irq_stack->len > 0) {
+ gint last = g_array_index(s->cpu_state->irq_stack, gint, s->cpu_state->irq_stack->len-1);
+ g_array_remove_index(s->cpu_state->irq_stack, s->cpu_state->irq_stack->len-1);
+ irq_pop_mode(&ts->irq_states[last]);
+ }
return FALSE;
}
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;
/* 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;
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,
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");
LTT_EVENT_LIST_INTERRUPT = g_quark_from_string("interrupt");
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");
LTT_FIELD_ID = g_quark_from_string("id");
LTT_FIELD_ADDRESS = g_quark_from_string("address");
LTT_FIELD_SYMBOL = g_quark_from_string("symbol");
+ LTT_FIELD_IP = g_quark_from_string("ip");
LTTV_CPU_UNKNOWN = g_quark_from_string("unknown");
LTTV_CPU_IDLE = g_quark_from_string("idle");