Commit 7f6878a3 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt

tracing/kprobe: Update symbol reference when loading module

Since the address of a module-local variable can only be
solved after the target module is loaded, the symbol
fetch-argument should be updated when loading target
module.
Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: http://lkml.kernel.org/r/20110627072703.6528.75042.stgit@fedora15Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 61424318
...@@ -343,6 +343,14 @@ DEFINE_BASIC_FETCH_FUNCS(deref) ...@@ -343,6 +343,14 @@ DEFINE_BASIC_FETCH_FUNCS(deref)
DEFINE_FETCH_deref(string) DEFINE_FETCH_deref(string)
DEFINE_FETCH_deref(string_size) DEFINE_FETCH_deref(string_size)
static __kprobes void update_deref_fetch_param(struct deref_fetch_param *data)
{
if (CHECK_FETCH_FUNCS(deref, data->orig.fn))
update_deref_fetch_param(data->orig.data);
else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn))
update_symbol_cache(data->orig.data);
}
static __kprobes void free_deref_fetch_param(struct deref_fetch_param *data) static __kprobes void free_deref_fetch_param(struct deref_fetch_param *data)
{ {
if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) if (CHECK_FETCH_FUNCS(deref, data->orig.fn))
...@@ -376,6 +384,19 @@ DEFINE_BASIC_FETCH_FUNCS(bitfield) ...@@ -376,6 +384,19 @@ DEFINE_BASIC_FETCH_FUNCS(bitfield)
#define fetch_bitfield_string NULL #define fetch_bitfield_string NULL
#define fetch_bitfield_string_size NULL #define fetch_bitfield_string_size NULL
static __kprobes void
update_bitfield_fetch_param(struct bitfield_fetch_param *data)
{
/*
* Don't check the bitfield itself, because this must be the
* last fetch function.
*/
if (CHECK_FETCH_FUNCS(deref, data->orig.fn))
update_deref_fetch_param(data->orig.data);
else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn))
update_symbol_cache(data->orig.data);
}
static __kprobes void static __kprobes void
free_bitfield_fetch_param(struct bitfield_fetch_param *data) free_bitfield_fetch_param(struct bitfield_fetch_param *data)
{ {
...@@ -389,6 +410,7 @@ free_bitfield_fetch_param(struct bitfield_fetch_param *data) ...@@ -389,6 +410,7 @@ free_bitfield_fetch_param(struct bitfield_fetch_param *data)
free_symbol_cache(data->orig.data); free_symbol_cache(data->orig.data);
kfree(data); kfree(data);
} }
/* Default (unsigned long) fetch type */ /* Default (unsigned long) fetch type */
#define __DEFAULT_FETCH_TYPE(t) u##t #define __DEFAULT_FETCH_TYPE(t) u##t
#define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t) #define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t)
...@@ -680,6 +702,16 @@ static struct trace_probe *alloc_trace_probe(const char *group, ...@@ -680,6 +702,16 @@ static struct trace_probe *alloc_trace_probe(const char *group,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
static void update_probe_arg(struct probe_arg *arg)
{
if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn))
update_bitfield_fetch_param(arg->fetch.data);
else if (CHECK_FETCH_FUNCS(deref, arg->fetch.fn))
update_deref_fetch_param(arg->fetch.data);
else if (CHECK_FETCH_FUNCS(symbol, arg->fetch.fn))
update_symbol_cache(arg->fetch.data);
}
static void free_probe_arg(struct probe_arg *arg) static void free_probe_arg(struct probe_arg *arg)
{ {
if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn)) if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn))
...@@ -749,11 +781,14 @@ static void disable_trace_probe(struct trace_probe *tp, int flag) ...@@ -749,11 +781,14 @@ static void disable_trace_probe(struct trace_probe *tp, int flag)
/* Internal register function - just handle k*probes and flags */ /* Internal register function - just handle k*probes and flags */
static int __register_trace_probe(struct trace_probe *tp) static int __register_trace_probe(struct trace_probe *tp)
{ {
int ret; int i, ret;
if (trace_probe_is_registered(tp)) if (trace_probe_is_registered(tp))
return -EINVAL; return -EINVAL;
for (i = 0; i < tp->nr_args; i++)
update_probe_arg(&tp->args[i]);
/* Set/clear disabled flag according to tp->flag */ /* Set/clear disabled flag according to tp->flag */
if (trace_probe_is_enabled(tp)) if (trace_probe_is_enabled(tp))
tp->rp.kp.flags &= ~KPROBE_FLAG_DISABLED; tp->rp.kp.flags &= ~KPROBE_FLAG_DISABLED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment