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]

rethinking syscall tapset


Hien,

Sorry about the delay in the syscall tapset. I got busy trying to update
the website.

I've been thinking that the old version didn't do much useful. A bunch
of lines like "count = $count" doesn't really add anything. There are
some good utility functions in aux_syscalls.stp.  But why do we need a
syscall tapset?  Basically it is supposed to make it easier to trace and
profile system calls. So I'm trying things like:


probe syscall.open = kernel.function("sys_open") {
      name = "open"	
      filename = user_string($filename)
      flags = $flags
      mode = $mode
      mode_str = _sys_open_mode_str($mode)
      tracestr = "open ".filename." "._sys_open_flag_str(flags)."
".hexstring(mode)
}
probe syscall.open.return = kernel.function("sys_open").return {
      name = "open"
      returnp = 1
}
probe syscall.read = kernel.function("sys_read") {
      name = "read"
      fd = $fd
      buf_uaddr = $buf
      count = $count
      tracestr = "read ".string(fd)." ".string(count)
}
probe syscall.read.return = kernel.function("sys_read").return {
      name = "read"
      returnp = 1
}

--------
probe syscall.open, syscall.read,
	syscall.open.return, syscall.read.return {

	if (pid() == target()) {
		if (returnp)
			printf("%s returned %d\n", name, returnval())
		else
			log(tracestr)
	}
}

Note that I've replaced "kernel.syscall" with just "syscall".

I've created a string "tracestr" that each syscall returns with the name
and formatted arguments. I've been debating if I want to include the
name or just the args. So in my example I would do
printf("%s: %s\n", name, argstr)


I've created another variable all return probes set called "returnp".
We could get the same thing calling is_return() in context.stp, but that
is a bit slower.

What do you think?

Martin





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