This is the mail archive of the systemtap@sources.redhat.com 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: Few queries on tapset interface


Prasanna S Panchamukhi <prasanna@in.ibm.com> writes:

> I am trying to write down some tapsets to trace all the system calls. 

Can you specify what you mean by "tapset" in this context?
Some end-user script program that happens to trace system calls?
Some reusable library for someone else's scripts?
Something else?

I wouldn't mind having some compact noun to describe an ordinary
end-user script or script fragment or probe program.  But to me,
"tapset" has a connotation of library-like reuse.


> struct read_trace {
> 	unsigned long entry_time;
> 	unsigned long my_count;
> 	unsigned long my_fd;	
> };
> 
> #define NUM_SYSCALL XXX;
> static struct read_trace self;
> static unsigned long read_times[NUM_SYSCALL];

This looks like C code.  Such declarations are not needed.


> probe syscall:entry("read")
> {
> 	self->entry_time = $timestamp;
> 	self->my_count = count;
> 	self->my_fd = fd;
> 	printk("my_count =0x%x,my_fd = 0x%x\n", self->my_count, self->my_fd);
> }
> 
> probe syscall:exit("read")
> {
> 	if (self->entry_time) {
> 		read_times[$syscall_name] += $timestamp - self->entry_time;
> 		self->entry_time = 0;
> 	}
> 	printk("sys_read: return value =0x%x\n",*(ri->ret_addr));
> }

This would be closer to current syntax:

global entry_time, my_count, my_fd, read_times

probe kernel.syscall("read") {
      thread->entry_time = $timestamp; # "macro" variable
      thread->my_count = $count; # function argument
      thread->my_fd = $fd; # function argument
      trace ("my_count = " . string(thread->my_count) .
             "my_fd = " . string(thread->my_fd))
}

probe kernel.syscall("read").return {
      if (thread->entry_time) {
         read_times[$syscall_name]    # variable from provider alias
            += $timestamp - thread->entry_time
      }
      trace ("syscall " . $syscall_name .
             " return value = " .
             hexstring ($retvalue));  # function pseudo-argument
}

probe end {
      for ([syscall] in read_times) {
          trace ("syscall " . syscall .
                 " total-time=" . string (read_times[syscall]))
      }
}

(The name resolution rules for $-variables need to be specified.) 


> [...]
> Are there some documents to assist in writing the tapsets?

Nothing much more detailed than the "language" section of the
architecture paper.

> How can one access the function arguments?

$-variables or a close friend will access target-space values such as
function arguments.

> Is there a built-in function to print the variable?

We'll have something like "trace()".

> Is there some other way to allocate tapset global variables?

If you mean allocating arrays, then no, you don't need to manage their
allocation at all.  Just declare them as global, and use the names in
array context.


- FChE


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