tracing: kprobe-tracer plugin supports module_probe
RFC PATCH 9/9 tracing: kprobe-tracer plugin supports module_probe
Use register/unregister_module_*probe functions for tracing module .init/.exit functions.
Signed-off-by Masami Hiramatsu <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Ananth N Mavinakayanahalli <[email protected]>
Cc Ingo Molnar <[email protected]>
--- kernel/trace/trace_kprobe.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
kernel/trace/trace_kprobe.c +10 -5
@@ -226,6 +226,11 @@ static void free_trace_probe(struct trace_probe *tp)kfree (tp); } +static int activate_handler (void *offset,struct module *mod) +{ +return ((unsigned long )offset ==0 ) ?1 :0 ; +} +static int register_trace_probe (struct trace_probe *tp) {int ret;
@@ -234,9 +239,10 @@ static int register_trace_probe(struct trace_probe *tp)list_add_tail (&tp->list, &probe_list);if (probe_is_return (tp)) - ret =register_kretprobe (&tp->rp); + ret =register_module_kretprobe (&tp->rp, activate_handler,0 );else - ret =register_kprobe (&tp->kp); + ret =register_module_kprobe (&tp->kp, activate_handler, + (void *)(tp->kp.offset));if (ret) {pr_warning ("Probe registering error: %d\n" , ret);
@@ -249,9 +255,9 @@ static int register_trace_probe(struct trace_probe *tp)static void unregister_trace_probe (struct trace_probe *tp) {if (probe_is_return (tp)) -unregister_kretprobe (&tp->rp); +unregister_module_kretprobe (&tp->rp);else -unregister_kprobe (&tp->kp); +unregister_module_kprobe (&tp->kp);list_del (&tp->list); }
@@ -301,7 +307,6 @@ static int create_trace_probe(int argc, char **argv) }else {/* a symbol specified */ symbol = argv[1 ]; -/* TODO: support .init module functions */ tmp =strchr (symbol,'+' );if (!tmp) tmp =strchr (symbol,'-' );
Signature · 7 lines
Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: [email protected]
Steven Rostedt
maintainerQuoted 16 lines · Masami Hiramatsu
Use register/unregister_module_*probe functions for tracing module .init/.exit functions.
Signed-off-by Masami Hiramatsu <[email protected]>Cc Steven Rostedt <[email protected]>Cc Ananth N Mavinakayanahalli <[email protected]>Cc Ingo Molnar <[email protected]>--- kernel/trace/trace_kprobe.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)kernel/trace/trace_kprobe.c +0
-0
kernel/trace/trace_kprobe.c static void free_trace_probe(struct trace_probe *tp) · line 231
Quoted 6 lines
kernel/trace/trace_kprobe.c +3
-0@@ -226,6 +226,11 @@ static void free_trace_probe(struct trace_probe *tp)kfree (tp); } +static int activate_handler (void *offset,struct module *mod) +{ +return ((unsigned long )offset ==0 ) ?1 :0 ;
This is a strange way to implement:
return !offset;
-- Steve
Quoted 49 lines
kernel/trace/trace_kprobe.c +7
-5+} +static int register_trace_probe (struct trace_probe *tp) {int ret;@@ -234,9 +239,10 @@ static int register_trace_probe(struct trace_probe *tp)list_add_tail (&tp->list, &probe_list);if (probe_is_return (tp)) - ret =register_kretprobe (&tp->rp); + ret =register_module_kretprobe (&tp->rp, activate_handler,0 );else - ret =register_kprobe (&tp->kp); + ret =register_module_kprobe (&tp->kp, activate_handler, + (void *)(tp->kp.offset));if (ret) {pr_warning ("Probe registering error: %d\n" , ret);@@ -249,9 +255,9 @@ static int register_trace_probe(struct trace_probe *tp)static void unregister_trace_probe (struct trace_probe *tp) {if (probe_is_return (tp)) -unregister_kretprobe (&tp->rp); +unregister_module_kretprobe (&tp->rp);else -unregister_kprobe (&tp->kp); +unregister_module_kprobe (&tp->kp);list_del (&tp->list); }@@ -301,7 +307,6 @@ static int create_trace_probe(int argc, char **argv) }else {/* a symbol specified */ symbol = argv[1 ]; -/* TODO: support .init module functions */ tmp =strchr (symbol,'+' );if (!tmp) tmp =strchr (symbol,'-' );Signature · 7 lines
Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: [email protected]
Quoted 21 lines · Steven Rostedt
Quoted 19 lines · Masami Hiramatsu
Use register/unregister_module_*probe functions for tracing module .init/.exit functions.
Signed-off-by Masami Hiramatsu <[email protected]>Cc Steven Rostedt <[email protected]>Cc Ananth N Mavinakayanahalli <[email protected]>Cc Ingo Molnar <[email protected]>--- kernel/trace/trace_kprobe.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)kernel/trace/trace_kprobe.c +0
-0@@ -226,6 +226,11 @@ static void free_trace_probe(struct trace_probe *tp)kfree (tp); }
Quoted 7 lines
kernel/trace/trace_kprobe.c static void free_trace_probe(struct trace_probe *tp) · line 231
Quoted 3 lines
kernel/trace/trace_kprobe.c +3
-0+static int activate_handler (void *offset,struct module *mod) +{ +return ((unsigned long )offset ==0 ) ?1 :0 ;This is a strange way to implement:
return !offset;
Yes. Thanks!
Quoted 52 lines
-- Steve
Quoted 49 lines
kernel/trace/trace_kprobe.c +7
-5+} +static int register_trace_probe (struct trace_probe *tp) {int ret;@@ -234,9 +239,10 @@ static int register_trace_probe(struct trace_probe *tp)list_add_tail (&tp->list, &probe_list);if (probe_is_return (tp)) - ret =register_kretprobe (&tp->rp); + ret =register_module_kretprobe (&tp->rp, activate_handler,0 );else - ret =register_kprobe (&tp->kp); + ret =register_module_kprobe (&tp->kp, activate_handler, + (void *)(tp->kp.offset));if (ret) {pr_warning ("Probe registering error: %d\n" , ret);@@ -249,9 +255,9 @@ static int register_trace_probe(struct trace_probe *tp)static void unregister_trace_probe (struct trace_probe *tp) {if (probe_is_return (tp)) -unregister_kretprobe (&tp->rp); +unregister_module_kretprobe (&tp->rp);else -unregister_kprobe (&tp->kp); +unregister_module_kprobe (&tp->kp);list_del (&tp->list); }@@ -301,7 +307,6 @@ static int create_trace_probe(int argc, char **argv) }else {/* a symbol specified */ symbol = argv[1 ]; -/* TODO: support .init module functions */ tmp =strchr (symbol,'+' );if (!tmp) tmp =strchr (symbol,'-' );Signature · 7 lines
Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: [email protected]
Signature · 7 lines
Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: [email protected]