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]

Cannot access data passed in via gettimeofday


Hi all,

I am having trouble getting parameters out of what seems to be a simple 
but buggy system-tap script.  The script is included below and the test 
case (a short C program) follows.  Basically, I am trying to hi-jack 
gettimeofday and piggyback some information back by treating the struct it 
passes in as a larger buffer than struct timeval.  However, I need to 
separate regular calls to gettimeofday from the special ones where the 
special path triggers.  To do this, I though I could treat the struct as 
an incoming parameter by looking for unusual bit patterns in the struct. 
Unfortunately, I can't seem to see the data at all despite using the 
copy_from_user function to copy data from user to kernel space.  Any idea 
what's going on here?   I additionally hijack stime so i can distinguish 
in the output my special call to gettimeofday.   The sample out below 
shows that the special values 0xaaaaaaaa and 0xbbbbbbbb are not 
transmitted.   If I use settimeofday instead of gettimeofday, then this 
program seems to work.   It feels like there is some other mechanism at 
work here that I don't know about. 


---------------------------
gettimeofday 0:   sec = 4ec7ed3c  usec = 4eb6db96
---------------------------

**********************system tap script**********************

probe kernel.function("sys_stime")
{
        doTime()
}

function doTime()
%{
        _stp_printf("---------------------------\n");
%}


probe kernel.function("sys_gettimeofday")
{
        doGetTimeOfDay($tv)
}

function doGetTimeOfDay(tv:long)
%{
        struct timeval *tv = (struct timeval *) ((long)THIS->tv);
        struct timeval ltv;
        int notCopied = 0;

        notCopied = copy_from_user(&ltv, tv, sizeof(ltv));
        _stp_printf("gettimeofday %d:   sec = %x  usec = %x\n", notCopied, 
ltv.tv_sec, ltv.tv_usec);
%}


**********************test program**********************

#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>

main() {

    struct timeval tv;
    time_t t;

    stime(&t);
    tv.tv_sec = 0xaaaaaaaa;
    tv.tv_usec = 0xbbbbbbbb;
    gettimeofday(&tv, NULL);
    stime(&t);
}



Perry


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