* Re: deref fault from alias, not from probe handler
@ 2005-10-12 21:17 Kevin Stafford
0 siblings, 0 replies; only message in thread
From: Kevin Stafford @ 2005-10-12 21:17 UTC (permalink / raw)
To: Frank Ch. Eigler; +Cc: systemtap
>> [...]
>>> 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-12 21:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12 21:17 deref fault from alias, not from probe handler Kevin Stafford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).