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: deref fault from alias, not from probe handler


[...]
the two pointers being dereferenced are in user space, thus ineligible to use the $ptr->field shortcut.
[...]
So here is how I am getting around this:
/*________________CUT HERE________________*/> %{
#include <sys/times.h>
%}
probe times =
kernel.function("sys_times") {
name = "times"
buf_tms_utime = __uget_tms_m($tbuf,0)
buf_tms_stime = __uget_tms_m($tbuf,1)
buf_tms_cutime = __uget_tms_m($tbuf,2)
buf_tms_cstime = __uget_tms_m($tbuf,3)
}
probe times {
log(string(buf_tms_utime))
log(string(buf_tms_stime))
log(string(buf_tms_cutime))
log(string(buf_tms_cstime))
}
function __uget_tms_m:long(u_addr:long,member:long)
%{
struct tms t;
char *ptr = (char *)(unsigned long)THIS->u_addr;
size_t sz = sizeof(struct tms);


   if(copy_from_user(&t,ptr,sz))
      THIS->__retvalue = -EFAULT;
   switch(THIS->member) {
      case 0: THIS->__retvalue =  t.tms_utime;
         break;
      case 1: THIS->__retvalue =  t.tms_stime;
         break;
      case 2: THIS->__retvalue =  t.tms_cutime;
         break;
      case 3: THIS->__retvalue =  t.tms_cstime;
         break;
      default: THIS->__retvalue = -1;
   }
%}
/*________________CUT HERE________________*/
This script produces the following compiler
error:

In function ‘function___uget_tms_m’:
/tmp/stapmFByii/stap_9586.c:194: error: storage size of ‘t’ isn’t known
/tmp/stapmFByii/stap_9586.c:196: error: invalid application of ‘sizeof’ to
incomplete type ‘struct tms’

This is the error one would receive if they had forgotten to include the header
sys/times.h file. Although a quick verification proves otherwise:

[root@localhost]# stap -vgp3 foo.stp > tmp.c
[root@localhost]# grep sys/times.h tmp.c
#include <sys/times.h>

<sys/times.h> is a user-level header file. You probably need simply <times.h> or <linux/times.h>, whichever is the linux kernel standard way. Any ideas on this one??? Thanks in advance.

Thanks Frank. Your suggestion worked.


--
Kevin Stafford
DES 2 | MS 2M3
Beaverton - OR
Linux Technology Center
IBM Systems & Technology
Phone: 1-503-578-3039
Email: kevinrs@us.ibm.com




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