From 9ee1ff6aafc917b69d1510dad5a7e100d47debc4 Mon Sep 17 00:00:00 2001 From: compudj Date: Mon, 16 Feb 2009 01:58:27 +0000 Subject: [PATCH] fix 32-bits lttv for kprobes git-svn-id: http://ltt.polymtl.ca/svn@3320 04897980-b3bd-0310-b5e0-8ef037075253 --- trunk/lttv/lttv/lttv/print.c | 7 ++++++- trunk/lttv/lttv/lttv/state.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/trunk/lttv/lttv/lttv/print.c b/trunk/lttv/lttv/lttv/print.c index 68661d7c..b303900a 100644 --- a/trunk/lttv/lttv/lttv/print.c +++ b/trunk/lttv/lttv/lttv/print.c @@ -64,8 +64,13 @@ static inline void print_enum_events(LttEvent *e, struct marker_field *f, 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, +#if (__SIZEOF_LONG__ == 4) + GQuark symbol = (GQuark)g_hash_table_lookup(ts->kprobe_hash, + (gconstpointer)&value); +#else + GQuark symbol = (GQuark)g_hash_table_lookup(ts->kprobe_hash, (gconstpointer)value); +#endif if (symbol) g_string_append_printf(s, " [%s]", g_quark_to_string(symbol)); } diff --git a/trunk/lttv/lttv/lttv/state.c b/trunk/lttv/lttv/lttv/state.c index a3c6c9f1..52c8ea6b 100644 --- a/trunk/lttv/lttv/lttv/state.c +++ b/trunk/lttv/lttv/lttv/state.c @@ -227,6 +227,23 @@ static void bdevstate_free_cb(gpointer key, gpointer value, gpointer user_data); 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); @@ -328,8 +345,14 @@ static void expand_syscall_table(LttvTraceState *ts, int id) 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) @@ -2006,7 +2029,12 @@ create_name_tables(LttvTraceState *tcs) 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 } -- 2.34.1