summaryrefslogtreecommitdiffstats
path: root/tapset
diff options
context:
space:
mode:
Diffstat (limited to 'tapset')
-rw-r--r--tapset/aux_syscalls.stp80
-rw-r--r--tapset/syscalls.stp22
-rw-r--r--tapset/task.stp14
-rw-r--r--tapset/tty.stp189
4 files changed, 283 insertions, 22 deletions
diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp
index 9347e46f..2f19ab16 100644
--- a/tapset/aux_syscalls.stp
+++ b/tapset/aux_syscalls.stp
@@ -1302,16 +1302,76 @@ function _sock_family_str(f) {
return sprintf("UNKNOWN VALUE: %d", f)
}
-function _sock_type_str(t) {
- if(t==1) return "SOCK_STREAM"
- if(t==2) return "SOCK_DGRAM"
- if(t==5) return "SOCK_SEQPACKET"
- if(t==3) return "SOCK_RAW"
- if(t==4) return "SOCK_RDM"
- if(t==6) return "SOCK_DCCP"
- if(t==10) return "SOCK_PACKET"
- return sprintf("UNKNOWN VALUE: %d", t)
-}
+function _sock_type_str:string(type:long)
+%{ /* pure */
+#ifdef SOCK_TYPE_MASK
+ int flags = (int)THIS->type & ~SOCK_TYPE_MASK;
+ int t = (int)THIS->type & SOCK_TYPE_MASK;
+#else
+ int t = (int)THIS->type;
+#endif
+
+ switch (t) {
+ case SOCK_STREAM:
+ strlcpy (THIS->__retvalue, "SOCK_STREAM", MAXSTRINGLEN);
+ break;
+ case SOCK_DGRAM:
+ strlcpy (THIS->__retvalue, "SOCK_DGRAM", MAXSTRINGLEN);
+ break;
+ case SOCK_RAW:
+ strlcpy (THIS->__retvalue, "SOCK_RAW", MAXSTRINGLEN);
+ break;
+ case SOCK_RDM:
+ strlcpy (THIS->__retvalue, "SOCK_RDM", MAXSTRINGLEN);
+ break;
+ case SOCK_SEQPACKET:
+ strlcpy (THIS->__retvalue, "SOCK_SEQPACKET", MAXSTRINGLEN);
+ break;
+#ifdef SOL_DCCP
+ case SOCK_DCCP:
+ strlcpy (THIS->__retvalue, "SOCK_DCCP", MAXSTRINGLEN);
+ break;
+#endif
+ case SOCK_PACKET:
+ strlcpy (THIS->__retvalue, "SOCK_PACKET", MAXSTRINGLEN);
+ break;
+ default:
+ strlcpy (THIS->__retvalue, "UNKNOWN VALUE: %d", t);
+ break;
+ }
+
+#ifdef SOCK_TYPE_MASK
+ if (flags & SOCK_CLOEXEC) {
+ strlcat (THIS->__retvalue, "|SOCK_CLOEXEC", MAXSTRINGLEN);
+ }
+ if (flags & SOCK_NONBLOCK) {
+ strlcat (THIS->__retvalue, "|SOCK_NONBLOCK", MAXSTRINGLEN);
+ }
+#endif
+%}
+
+function _sock_flags_str:string(f:long)
+%{ /* pure */
+#ifdef SOCK_TYPE_MASK
+ int flags = (int)THIS->f;
+ int len;
+
+ THIS->__retvalue[0] = '\0';
+ if (flags & SOCK_CLOEXEC) {
+ strlcat (THIS->__retvalue, "SOCK_CLOEXEC|", MAXSTRINGLEN);
+ }
+ if (flags & SOCK_NONBLOCK) {
+ strlcat (THIS->__retvalue, "SOCK_NONBLOCK|", MAXSTRINGLEN);
+ }
+ len = strlen(THIS->__retvalue);
+ if (len) {
+ THIS->__retvalue[len - 1] = '\0';
+ }
+ else {
+ strlcat (THIS->__retvalue, "0", MAXSTRINGLEN);
+ }
+#endif
+%}
function _opoll_op_str(o) {
if(o==1) return "EPOLL_CTL_ADD"
diff --git a/tapset/syscalls.stp b/tapset/syscalls.stp
index 825842a6..dde0ca9f 100644
--- a/tapset/syscalls.stp
+++ b/tapset/syscalls.stp
@@ -27,17 +27,29 @@
# accept _____________________________________________________
# long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
-# int __user *upeer_addrlen)
-probe syscall.accept = kernel.function("SyS_accept").call !,
- kernel.function("sys_accept").call ?
+# int __user *upeer_addrlen, int flags)
+probe syscall.accept = _syscall.accept4 !, _syscall.accept
{
name = "accept"
sockfd = $fd
addr_uaddr = $upeer_sockaddr
addrlen_uaddr = $upeer_addrlen
- argstr = sprintf("%d, %p, %p", $fd, $upeer_sockaddr, $upeer_addrlen)
+ argstr = sprintf("%d, %p, %p, %s", $fd, $upeer_sockaddr,
+ $upeer_addrlen, flags_str)
}
-probe syscall.accept.return = kernel.function("SyS_accept").return !,
+probe _syscall.accept4 = kernel.function("sys_accept4").call
+{
+ flags = $flags
+ flags_str = _sock_flags_str($flags)
+}
+probe _syscall.accept = kernel.function("SyS_accept").call !,
+ kernel.function("sys_accept").call ?
+{
+ flags = 0
+ flags_str = "0"
+}
+probe syscall.accept.return = kernel.function("sys_accept4").return !,
+ kernel.function("SyS_accept").return !,
kernel.function("sys_accept").return ?
{
name = "accept"
diff --git a/tapset/task.stp b/tapset/task.stp
index 3bb65413..90579d5d 100644
--- a/tapset/task.stp
+++ b/tapset/task.stp
@@ -45,21 +45,21 @@ function task_parent:long (task:long) %{ /* pure */
// EXIT_DEAD 32
function task_state:long (task:long)
{
- return @cast(task, "task_struct", "kernel")->state
+ return @cast(task, "task_struct", "kernel<linux/sched.h>")->state
}
// Return the name of the given task
function task_execname:string (task:long)
{
- return kernel_string(@cast(task, "task_struct", "kernel")->comm)
+ return kernel_string(@cast(task, "task_struct", "kernel<linux/sched.h>")->comm)
}
// Return the process id of the given task
function task_pid:long (task:long)
{
- return @cast(task, "task_struct", "kernel")->tgid
+ return @cast(task, "task_struct", "kernel<linux/sched.h>")->tgid
}
@@ -95,7 +95,7 @@ function pid2execname:string (pid:long) {
// Return the thread id of the given task
function task_tid:long (task:long)
{
- return @cast(task, "task_struct", "kernel")->pid
+ return @cast(task, "task_struct", "kernel<linux/sched.h>")->pid
}
@@ -181,11 +181,11 @@ function task_nice:long (task:long) %{ /* pure */
function task_cpu:long (task:long)
{
%( kernel_v >= "2.6.22" %?
- ti = @cast(task, "task_struct", "kernel")->stack
+ ti = @cast(task, "task_struct", "kernel<linux/sched.h>")->stack
%:
- ti = @cast(task, "task_struct", "kernel")->thread_info
+ ti = @cast(task, "task_struct", "kernel<linux/sched.h>")->thread_info
%)
- return @cast(ti, "thread_info", "kernel")->cpu
+ return @cast(ti, "thread_info", "kernel<linux/sched.h>")->cpu
}
// Return the number of open file handlers for the given task
diff --git a/tapset/tty.stp b/tapset/tty.stp
new file mode 100644
index 00000000..f6ce8ea9
--- /dev/null
+++ b/tapset/tty.stp
@@ -0,0 +1,189 @@
+// tty tapset
+// Copyright (C) 2009 IBM Corp.
+//
+// Author: Breno Leitao <leitao@linux.vnet.ibm.com>
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+/**
+ * probe tty.open - Called when a tty is opened
+ * @inode_number: the inode number
+ * @inode_state: the inode state
+ * @inode_flags: the inode flags
+ * @file_name: the file name
+ * @file_mode: the file mode
+ * @file_flags: the file flags
+ */
+probe tty.open = kernel.function("tty_open") {
+ inode_number= $inode->i_ino
+ inode_state = $inode->i_state
+ inode_flags = $inode->i_flags
+
+ file_name = d_name($filp->f_path->dentry)
+ file_mode = $filp->f_mode
+ file_flags = $filp->f_flags
+}
+
+/**
+ * probe tty.release - Called when the tty is closed
+ * @inode_number: the inode number
+ * @inode_state: the inode state
+ * @inode_flags: the inode flags
+ * @file_name: the file name
+ * @file_mode: the file mode
+ * @file_flags: the file flags
+ */
+probe tty.release = kernel.function("tty_release") {
+ inode_number= $inode->i_ino
+ inode_state = $inode->i_state
+ inode_flags = $inode->i_flags
+
+ file_name = d_name($filp->f_path->dentry)
+ file_mode = $filp->f_mode
+ file_flags = $filp->f_flags
+}
+
+/**
+ * probe tty.resize - Called when a terminal resize happens
+ * @name: the tty name
+ * @old_row: the old row value
+ * @old_col: the old col value
+ * @old_ypixel: the old ypixel
+ * @old_xpixel: the old xpixel
+ * @new_row: the new row value
+ * @new_col: the new col value
+ * @new_ypixel: the new ypixel value
+ * @new_xpixel: the new xpixel value
+*/
+probe tty.resize = kernel.function("tty_do_resize"){
+ name = kernel_string($tty->name)
+ old_row = $tty->winsize->ws_row
+ old_col = $tty->winsize->ws_col
+ old_ypixel = $tty->winsize->ws_ypixel
+ old_xpixel = $tty->winsize->ws_xpixel
+
+ new_row = $ws->ws_row
+ new_col = $ws->ws_col
+ new_ypixel = $ws->ws_ypixel
+ new_xpixel = $ws->ws_xpixel
+}
+
+/**
+ * probe tty.ioctl - called when a ioctl is request to the tty
+ * @name: the file name
+ * @cmd: the ioctl command
+ * @arg: the ioctl argument
+ */
+probe tty.ioctl = kernel.function("tty_ioctl"){
+ name = kernel_string($file->f_path->dentry->d_iname)
+
+ cmd = $cmd
+ arg = $arg
+}
+
+/**
+ * probe tty.init - Called when a tty is being initalized
+ * @driver_name: the driver name
+ * @name: the driver .dev_name name
+ * @module: the module name
+ */
+probe tty.init = kernel.function("tty_init_dev"){
+ driver_name = kernel_string($driver->driver_name)
+ name = kernel_string($driver->name)
+ module = kernel_string($driver->owner->name)
+}
+
+/**
+ * probe tty.register - Called when a tty device is registred
+ * @driver_name: the driver name
+ * @name: the driver .dev_name name
+ * @module: the module name
+ * @index: the tty index requested
+ */
+probe tty.register = kernel.function("tty_register_device"){
+ driver_name = kernel_string($driver->driver_name)
+ name = kernel_string($driver->name)
+ module = kernel_string($driver->owner->name)
+ index = $index
+}
+
+/**
+ * probe tty.unregister - Called when a tty device is being unregistered
+ * @driver_name: the driver name
+ * @name: the driver .dev_name name
+ * @module: the module name
+ * @index: the tty index requested
+ */
+probe tty.unregister = kernel.function("tty_unregister_device"){
+ driver_name = kernel_string($driver->driver_name)
+ name = kernel_string($driver->name)
+ module = kernel_string($driver->owner->name)
+ index = $index
+}
+
+/**
+ * probe tty.poll - Called when a tty device is being polled
+ * @file_name: the tty file name
+ * @wait_key: the wait queue key
+ */
+probe tty.poll = kernel.function("tty_poll"){
+ file_name = d_name($filp->f_path->dentry)
+
+ if ($wait)
+ wait_key = $wait->key
+ else
+ wait_key = 0
+}
+
+/**
+ * probe tty.receive - called when a tty receives a message
+ * @cp: the buffer that was received
+ * @fp: The flag buffer
+ * @count: The amount of characters received
+ * @driver_name: the driver name
+ * @name: the name of the module file
+ * @index: The tty Index
+ * @id: the tty id
+ */
+probe tty.receive = kernel.function("n_tty_receive_buf"){
+ cp = kernel_string($cp)
+ fp = kernel_string($fp)
+ count = $count
+
+ driver_name = kernel_string($tty->driver->driver_name)
+ name = kernel_string($tty->driver->name)
+ index = $tty->index
+ id = $tty->magic
+}
+
+/**
+ * probe tty.write - write to the tty line
+ * @buffer: the buffer that will be written
+ * @nr: The amount of characters
+ * @driver_name: the driver name
+ * @file_name: the file name lreated to the tty
+ */
+probe tty.write = kernel.function("n_tty_write"){
+ buffer = kernel_string($buf)
+ nr = $nr
+
+ file_name = d_name($file->f_path->dentry)
+ driver_name = kernel_string($tty->driver->driver_name)
+}
+
+/**
+ * probe tty.read - called when a tty line will be read
+ * @buffer: the buffer that will receive the characters
+ * @nr: The amount of characters to be read
+ * @driver_name: the driver name
+ * @file_name: the file name lreated to the tty
+ */
+probe tty.read = kernel.function("n_tty_read"){
+ buffer = kernel_string($buf)
+ nr = $nr
+ file_name = d_name($file->f_path->dentry)
+ driver_name = kernel_string($tty->driver->driver_name)
+}