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 Rick,

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

You have to use special interface in an embedded C function.

> // 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;

Instead of 'idx', please use 'THIS->idx'

>         else return avenrun[idx];

Also, return values must be assigned to THIS->__retvalue,
so get_avenrun should be below;

function get_avenrun:long (idx:long) %{ /* pure */
	if (THIS->idx < 0 || THIS->idx > 2) THIS->__retvalue = 0;
	else THIS->__retvalue = avenrun[THIS->idx];
%}

Thanks,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


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