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: Capturing load average from within systemtap script...


Hi... 

I'm still having troubles - this time with embedded C code to access
avenrun.   After modifying the code (pardon the mess): 

global timer_count
global x1
global x2
global x3

// avenrun declared as extern long int avenrun[3] in sched.h
%{
#include <linux/timer.h>
%}
function get_avenrun:long (idx:long) %{ /* pure */
    if (idx < 0 || idx > 2) return 0;
        else return avenrun[idx];
%}


%{
#include <linux/sysrq.h>
%}
// on RHEL4 and RHEL5, handle_sysrq has 3 params
function rab_show_mem:long (arg:long)
%{
        handle_sysrq('m', NULL, NULL);
        handle_sysrq('t', NULL, NULL);
%}

probe timer.ms(3000) {
    if (timer_count < 5) {
        printf("timer %d %d\n", rab_show_mem(0),timer_count++)
        x1 = get_avenrun(0)
        x2 = get_avenrun(1)
        x3 = get_avenrun(2)
        printf("x1 %d\n", x1)
        count++
    }
    else
            exit()
}

I now get errors during compilation of the generated C module. Here
are some extracts.  The messages make me think that the generated
function get_avenrun() is not getting 'idx' as a parameter properly.
Oddly, if I remove the actual call to get_avenrun() in the timer
probe, then I get no errors.  Does the code even get generated in 
that case? 

output below... 

 sudo stap -g loadavg_trigger.stp -vv
SystemTap translator/driver (version 0.5.14/0.128 built 2007-07-03)
Copyright (C) 2005-2007 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
Created temporary directory "/tmp/stapxmUWfQ"
Searched '/usr/share/systemtap/tapset/x86_64/*.stp', found 1
Searched '/usr/share/systemtap/tapset/*.stp', found 35
Searched '/usr/share/systemtap/tapset/LKET/*.stp', found 19
Pass 1: parsed user script and 55 library script(s) in
250usr/10sys/269real ms.
Pass 2: analyzed script: 1 probe(s), 3 function(s), 2 embed(s), 2
global(s) in 10usr/0sys/6real ms.
probe_1496 locks x1[rw] timer_count[rw] 
Pass 3: translated to C into
"/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c" in
0usr/0sys/1real ms.
Running make -C "/lib/modules/2.6.18-53.1.6.el5/build"
M="/tmp/stapxmUWfQ" modules V=1
make: Entering directory `/usr/src/kernels/2.6.18-53.1.6.el5-x86_64'
test -e include/linux/autoconf.h -a -e include/config/auto.conf || (
\
        echo;
\
        echo "  ERROR: Kernel configuration is invalid.";
\
        echo "         include/linux/autoconf.h or
include/config/auto.conf are missing.";      \
        echo "         Run 'make oldconfig && make prepare' on kernel
src to fix it.";  \
        echo;
\
        /bin/false)
mkdir -p /tmp/stapxmUWfQ/.tmp_versions
rm -f /tmp/stapxmUWfQ/.tmp_versions/*
make -f scripts/Makefile.build obj=/tmp/stapxmUWfQ
+ gcc -D__KERNEL__ -Iinclude -include include/linux/autoconf.h
-ffunction-sections -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -Wstrict-prototypes -Wundef
-Werror-implicit-function-declaration -Os -mtune=generic -m64
-mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks
-Wno-sign-compare -fno-asynchronous-unwind-tables -funit-at-a-time
-mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fomit-frame-pointer -g
-fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign
'-DKBUILD_BASENAME="stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811"' -Werror
-S -o /dev/null -xc /usr/share/systemtap/runtime/autoconf-hrtimer-rel.c
+ echo ' -DSTAPCONF_HRTIMER_REL'
+ gcc -D__KERNEL__ -Iinclude -include include/linux/autoconf.h
-ffunction-sections -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -Wstrict-prototypes -Wundef
-Werror-implicit-function-declaration -Os -mtune=generic -m64
-mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks
-Wno-sign-compare -fno-asynchronous-unwind-tables -funit-at-a-time
-mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fomit-frame-pointer -g
-fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign
'-DKBUILD_BASENAME="stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811"' -Werror
-S -o /dev/null
-xc /usr/share/systemtap/runtime/autoconf-inode-private.c
+ echo ' -DSTAPCONF_INODE_PRIVATE'
  gcc
-Wp,-MD,/tmp/stapxmUWfQ/.stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.o.d
-nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include
-D__KERNEL__ -Iinclude  -include include/linux/autoconf.h  -Wall -Wundef
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-Wstrict-prototypes -Wundef -Werror-implicit-function-declaration -Os
-mtune=generic -m64 -mno-red-zone -mcmodel=kernel -pipe
-fno-reorder-blocks -Wno-sign-compare -fno-asynchronous-unwind-tables
-funit-at-a-time -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
-fomit-frame-pointer -g  -fno-stack-protector
-Wdeclaration-after-statement -Wno-pointer-sign -freorder-blocks
-Wno-unused -Werror -I"/usr/share/systemtap/runtime"
-DSTAPCONF_HRTIMER_REL  -DSTAPCONF_INODE_PRIVATE -DMODULE
-D"KBUILD_STR(s)=#s"
-D"KBUILD_BASENAME=KBUILD_STR(stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811)"  -D"KBUILD_MODNAME=KBUILD_STR(stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811)" -c -o /tmp/stapxmUWfQ/.tmp_stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.o /tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c
/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c: In function
'function_get_avenrun':
/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c:160: error:
'idx' undeclared (first use in this function)
/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c:160: error:
(Each undeclared identifier is reported only once
/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c:160: error:
for each function it appears in.)
cc1: warnings being treated as errors
/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c:160:
warning: 'return' with a value, in function returning void
/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.c:161:
warning: 'return' with a value, in function returning void
make[1]: ***
[/tmp/stapxmUWfQ/stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.o] Error 1
make: *** [_module_/tmp/stapxmUWfQ] Error 2
make: Leaving directory `/usr/src/kernels/2.6.18-53.1.6.el5-x86_64'
Pass 4: compiled C into "stap_274d6781d1ee6f411bfb49cf4ea2d5c7_811.ko"
in 490usr/140sys/639real ms.
Pass 4: compilation failed.  Try again with more '-v' (verbose) options.
Running rm -rf /tmp/stapxmUWfQ


-- 
+----------------------------------------------------------------------+
| Rick Beldin                    |  Hewlett-Packard Company            |
| email: Rick.Beldin@hp.com      |  Global Solutions Engineering       |
| WTEC Linux, RHCE               |  5555 Windward Parkway West         |
|                                |  Alpharetta, GA 30004               |
+----------------------------------------------------------------------+


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