From 5a90d39d40a4360db4715408190aee558dbc3813 Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 31 Aug 2005 18:24:26 +0000 Subject: [PATCH] 2005-08-31 Martin Hunt * sym.c (_stp_kallsyms_lookup): Moved to runtime.h. * stack.c (_stp_kta): Moved to runtime.h. * runtime.h (init_module): Initialize _stp_kallsyms_lookup and _stp_kta. * probes.c (_stp_lookup_name): Replaced by kallsyms_lookup_name(). --- runtime/ChangeLog | 5 +++++ runtime/probes.c | 13 +++---------- runtime/runtime.h | 8 ++++++++ runtime/stack.c | 2 -- runtime/sym.c | 11 ----------- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index aeb21685e..b8d8087d6 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,5 +1,10 @@ 2005-08-31 Martin Hunt + * sym.c (_stp_kallsyms_lookup): Moved to runtime.h. + * stack.c (_stp_kta): Moved to runtime.h. + * runtime.h (init_module): Initialize _stp_kallsyms_lookup + and _stp_kta. + * probes.c (_stp_lookup_name): Replaced by kallsyms_lookup_name(). * list.c (_stp_copy_argv_from_user): ifdef this function NEED_STRING_VALS. diff --git a/runtime/probes.c b/runtime/probes.c index bb4109158..139d53aa2 100644 --- a/runtime/probes.c +++ b/runtime/probes.c @@ -5,13 +5,6 @@ * @brief Functions to assist loading and unloading groups of probes. */ -/** Lookup name. - * This simply calls the kernel function kallsyms_lookup_name(). - * That function is not exported, so this workaround is required. - * See the kernel source, kernel/kallsyms.c for more information. - */ -static unsigned long (*_stp_lookup_name)(char *name)=(void *)KALLSYMS_LOOKUP_NAME; - /** Unregister a group of jprobes. * @param probes Pointer to an array of struct jprobe. * @param num_probes Number of probes in the array. @@ -37,7 +30,7 @@ int _stp_register_jprobes (struct jprobe *probes, int num_probes) unsigned long addr; for (i = 0; i < num_probes; i++) { - addr =_stp_lookup_name((char *)probes[i].kp.addr); + addr =kallsyms_lookup_name((char *)probes[i].kp.addr); if (addr == 0) { _stp_warn("function %s not found!\n", (char *)probes[i].kp.addr); ret = -1; /* FIXME */ @@ -95,7 +88,7 @@ int _stp_register_kprobes (struct kprobe *probes, int num_probes) unsigned long addr; for (i = 0; i < num_probes; i++) { - addr =_stp_lookup_name((char *)probes[i].addr); + addr = kallsyms_lookup_name((char *)probes[i].addr); if (addr == 0) { _stp_warn("function %s not found!\n", (char *)probes[i].addr); ret = -1; @@ -126,7 +119,7 @@ int _stp_register_kretprobes (struct kretprobe *probes, int num_probes) unsigned long addr; for (i = 0; i < num_probes; i++) { - addr =_stp_lookup_name((char *)probes[i].kp.addr); + addr = kallsyms_lookup_name((char *)probes[i].kp.addr); if (addr == 0) { _stp_warn("function %s not found!\n", (char *)probes[i].kp.addr); diff --git a/runtime/runtime.h b/runtime/runtime.h index 5e77505b3..6189a92c1 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -61,11 +61,19 @@ static struct #include "arith.c" #include "copy.c" +static int (*_stp_kta)(unsigned long addr); +static const char * (*_stp_kallsyms_lookup)(unsigned long addr, + unsigned long *symbolsize, + unsigned long *offset, + char **modname, char *namebuf); + /************* Module Stuff ********************/ int probe_start(void); int init_module (void) { + _stp_kta = (int (*)(unsigned long))kallsyms_lookup_name("__kernel_text_address"); + _stp_kallsyms_lookup = (const char * (*)())kallsyms_lookup_name("kallsyms_lookup"); return _stp_transport_init(); } diff --git a/runtime/stack.c b/runtime/stack.c index 1f7073f54..ba0c9935b 100644 --- a/runtime/stack.c +++ b/runtime/stack.c @@ -20,8 +20,6 @@ #include "sym.c" #include "regs.h" -static int (*_stp_kta)(unsigned long addr)=(void *)KTA; - #if defined (__x86_64__) static void __stp_stack_sprint (String str, unsigned long *stack, int verbose, int levels) diff --git a/runtime/sym.c b/runtime/sym.c index a1c04a65d..107f6b338 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -9,17 +9,6 @@ * @{ */ -/** Lookup symbol. - * This simply calls the kernel function kallsyms_lookup(). - * That function is not exported, so this workaround is required. - * See the kernel source, kernel/kallsyms.c for more information. - */ -static const char * (*_stp_kallsyms_lookup)(unsigned long addr, - unsigned long *symbolsize, - unsigned long *offset, - char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP; - - /** Write addresses symbolically into a String * @param str String * @param address The address to lookup. -- 2.43.5