This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re:


Eyal,

Utility stap employs the kernel debug information installed in the
system. When you load a module command insmod does not update the
kernel debug info. There are simple two ways to resolve the issue
*  Load the module, get the address of the function foo using
/proc/kallsyms, provide the address of the foo as an argument to the
STAP script.
*  Link the module statically with the kernel and update the kernel-debuginfo

Arkady

On Thu, Jul 27, 2017 at 5:47 PM, Eyal Yehuda via systemtap
<systemtap@sourceware.org> wrote:
>
>
> hello
>
> The
>  issue I am facing is of undefined symbols in system tap kernel module
> when trying to link to another kernel module with exported symbol
>
> please note environment setup:
> os:  debian 9 stretch 64bit
> kernel version:  4.9.0-3-amd64
>
>
>           I created the following simple systemtap script using guru mode
>
>           system tap script:      temp.stp
>
>
>          %{
>                  extern int foo(void);
>          %}
>
>           function call_foo:long() %{/* pure */
>                   STAP_RETVALUE = foo();
>          %}
>
>           probe syscall.open {
>                  printf("foo() : %d\n",  call_foo())
>           }
>
>
>
>
>  In addition to that I created the following simple kernel module with
> an exported symbol function to be used from inside system tap
> script
>
>          kernel module:       xxx.c
>
>          #include <linux/kernel.h>
>          #include <linux/module.h>
>          #include <linux/printk.h>
>
>          static int foo(void){
>                  pr_info("foo()\n"); return 0;
>          }
>          EXPORT_SYMBOL(foo);
>
>          static int __init xxx_init(void){
>                 pr_info("xxx_init()\n");
>            return 0;
>          }
>
>          static void __exit xxx_exit(void){
>                 pr_info("xxx_exit() \n");
>          }
>
>          module_init(xxx_init);
>          module_exit(xxx_exit);
>          MODULE_LICENSE("GPL");
>
>
>          After compiling the kernel module and insmoding it, I run the command to compile systemtap script as follow:
>          stap -gk -v temp.stp
>
>          the compilation command result with the following error:
>
>
>  Pass 1: parsed user script and 465 library scripts using
> 113912virt/46752res/6476shr/40564data kb, in 110usr/20sys/124real ms.
>
>  Pass 2: analyzed script: 2 probes, 2 functions, 99 embeds, 0 globals
> using 165912virt/100212res/7716shr/92564data kb, in 680usr/50sys/731real
>  ms.
>
>  Pass 3: translated to C into "/tmp/stapzKUZ11/stap_1837_src.c" using
> 165912virt/100404res/7908shr/92564data kb, in 10usr/10sys/9real ms.
>          WARNING: "foo" [/tmp/stapzKUZ11/stap_1837.ko] undefined!
>          Pass 4: compiled C into "stap_1837.ko" in 1410usr/120sys/1963real ms.
>          Pass 5: starting run.
>          ERROR: Couldn't insert module '/tmp/stapzKUZ11/stap_1837.ko': Invalid parameters
>          WARNING: /usr/bin/staprun exited with status: 1
>          Pass 5: run completed in 0usr/0sys/16real ms.
>          Pass 5: run failed.  [man error::pass5]
>          Tip: /usr/share/doc/systemtap/README.Debian should help you get started.
>          Keeping temporary directory "/tmp/stapzKUZ11"
>
>
>          in dmesg I can see the following lines
>
>          Jul 27 03:56:14 debian9 kernel: [ 3938.166906] stap_2230: no symbol version for foo
>          Jul 27 03:56:14 debian9 kernel: [ 3938.166908] stap_2230: Unknown symbol foo (err -22)
>
>
>          I also checked /proc/kallsyms
>
>
>          cat /proc/kallsyms | grep xxx
>          ffffffffc0584000 T foo    [xxx]
>          ffffffffc0584014 t xxx_exit    [xxx]
>          ffffffffc0585030 r __ksymtab_foo    [xxx]
>          ffffffffc058506e r __kstrtab_foo    [xxx]
>          ffffffffc0585040 r __kcrctab_foo    [xxx]
>          ffffffffc0586000 d __this_module    [xxx]
>          ffffffffc0584014 t cleanup_module    [xxx]
>
>
> Please advice
> 1.
>  what should i do in addition to solve this issue as I must create an
> interaction between systemtap script and another kernel module
> 2.
>  In case this is not feasible can u please offer another alternative to
> make systemtap script use another kernel module services ?
>
> Thanks eyal yehuda


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]