]> sourceware.org Git - systemtap.git/commitdiff
PR14180: Doing the tapset shuffle!
authorJosh Stone <jistone@redhat.com>
Thu, 2 Aug 2012 02:26:01 +0000 (19:26 -0700)
committerJosh Stone <jistone@redhat.com>
Thu, 2 Aug 2012 02:26:01 +0000 (19:26 -0700)
Many tapsets are kernel-specific, with no applicability at all
from userspace.  These have all been moved to tapset/linux/.

Some tapsets could be widely applicable, but are implemented with
kernel-specific APIs.  These have been moved to tapset/linux/, and
reimplemented in tapset/dyninst/ too.

Some tapsets are generic utility functions, that don't care at
all where they're run from.  These have been left in place.

68 files changed:
tapset/context.stp
tapset/dyninst/context-envvar.stp [new file with mode: 0644]
tapset/dyninst/context.stp [new file with mode: 0644]
tapset/dyninst/ctime.stp [new file with mode: 0644]
tapset/dyninst/endian.stp [new file with mode: 0644]
tapset/dyninst/guru-delay.stp [new file with mode: 0644]
tapset/dyninst/inet.stp [new file with mode: 0644]
tapset/dyninst/timestamp_gtod.stp [new file with mode: 0644]
tapset/linux/atomic.stp [moved from tapset/atomic.stp with 100% similarity]
tapset/linux/context-caller.stp [moved from tapset/context-caller.stp with 100% similarity]
tapset/linux/context-envvar.stp [moved from tapset/context-envvar.stp with 100% similarity]
tapset/linux/context-symbols.stp [moved from tapset/context-symbols.stp with 100% similarity]
tapset/linux/context-unwind.stp [moved from tapset/context-unwind.stp with 100% similarity]
tapset/linux/context.stp [new file with mode: 0644]
tapset/linux/conversions-guru.stp [moved from tapset/conversions-guru.stp with 100% similarity]
tapset/linux/conversions.stp [moved from tapset/conversions.stp with 100% similarity]
tapset/linux/ctime.stp [moved from tapset/ctime.stp with 100% similarity]
tapset/linux/dentry.stp [moved from tapset/dentry.stp with 100% similarity]
tapset/linux/dev.stp [moved from tapset/dev.stp with 100% similarity]
tapset/linux/endian.stp [moved from tapset/endian.stp with 100% similarity]
tapset/linux/guru-delay.stp [moved from tapset/guru-delay.stp with 100% similarity]
tapset/linux/inet.stp [moved from tapset/inet.stp with 100% similarity]
tapset/linux/inet_sock.stp [moved from tapset/inet_sock.stp with 100% similarity]
tapset/linux/ioblock.stp [moved from tapset/ioblock.stp with 100% similarity]
tapset/linux/ioscheduler.stp [moved from tapset/ioscheduler.stp with 100% similarity]
tapset/linux/ip.stp [moved from tapset/ip.stp with 100% similarity]
tapset/linux/ipmib-filter-default.stp [moved from tapset/ipmib-filter-default.stp with 100% similarity]
tapset/linux/ipmib.stp [moved from tapset/ipmib.stp with 100% similarity]
tapset/linux/irq.stp [moved from tapset/irq.stp with 100% similarity]
tapset/linux/kprocess.stp [moved from tapset/kprocess.stp with 100% similarity]
tapset/linux/kretprobe.stp [moved from tapset/kretprobe.stp with 100% similarity]
tapset/linux/linuxmib-filter-default.stp [moved from tapset/linuxmib-filter-default.stp with 100% similarity]
tapset/linux/linuxmib.stp [moved from tapset/linuxmib.stp with 100% similarity]
tapset/linux/logging.stp [new file with mode: 0644]
tapset/linux/memory.stp [moved from tapset/memory.stp with 100% similarity]
tapset/linux/netfilter.stp [moved from tapset/netfilter.stp with 100% similarity]
tapset/linux/networking.stp [moved from tapset/networking.stp with 100% similarity]
tapset/linux/nfs.stp [moved from tapset/nfs.stp with 100% similarity]
tapset/linux/nfs_proc.stp [moved from tapset/nfs_proc.stp with 100% similarity]
tapset/linux/nfsd.stp [moved from tapset/nfsd.stp with 100% similarity]
tapset/linux/nfsderrno.stp [moved from tapset/nfsderrno.stp with 100% similarity]
tapset/linux/panic.stp [moved from tapset/panic.stp with 100% similarity]
tapset/linux/perf.stp [moved from tapset/perf.stp with 100% similarity]
tapset/linux/proc_mem.stp [moved from tapset/proc_mem.stp with 100% similarity]
tapset/linux/pstrace.stp [moved from tapset/pstrace.stp with 100% similarity]
tapset/linux/rpc.stp [moved from tapset/rpc.stp with 100% similarity]
tapset/linux/scheduler.stp [moved from tapset/scheduler.stp with 100% similarity]
tapset/linux/scsi.stp [moved from tapset/scsi.stp with 100% similarity]
tapset/linux/signal.stp [moved from tapset/signal.stp with 100% similarity]
tapset/linux/socket.stp [moved from tapset/socket.stp with 100% similarity]
tapset/linux/target_set.stp [moved from tapset/target_set.stp with 100% similarity]
tapset/linux/task.stp [moved from tapset/task.stp with 100% similarity]
tapset/linux/task_time.stp [moved from tapset/task_time.stp with 100% similarity]
tapset/linux/tcp.stp [moved from tapset/tcp.stp with 100% similarity]
tapset/linux/tcpmib-filter-default.stp [moved from tapset/tcpmib-filter-default.stp with 100% similarity]
tapset/linux/tcpmib.stp [moved from tapset/tcpmib.stp with 100% similarity]
tapset/linux/timestamp.stp [moved from tapset/timestamp.stp with 100% similarity]
tapset/linux/timestamp_gtod.stp [moved from tapset/timestamp_gtod.stp with 100% similarity]
tapset/linux/timestamp_monotonic.stp [moved from tapset/timestamp_monotonic.stp with 100% similarity]
tapset/linux/tty.stp [moved from tapset/tty.stp with 100% similarity]
tapset/linux/ucontext-symbols.stp [moved from tapset/ucontext-symbols.stp with 100% similarity]
tapset/linux/ucontext-unwind.stp [moved from tapset/ucontext-unwind.stp with 100% similarity]
tapset/linux/ucontext.stp [moved from tapset/ucontext.stp with 100% similarity]
tapset/linux/uconversions.stp [moved from tapset/uconversions.stp with 100% similarity]
tapset/linux/udp.stp [moved from tapset/udp.stp with 100% similarity]
tapset/linux/utrace.stp [moved from tapset/utrace.stp with 100% similarity]
tapset/linux/vfs.stp [moved from tapset/vfs.stp with 100% similarity]
tapset/logging.stp

index 9c4663a1a7cbf9dfe2086c6dc05928dd2a9440bd..d849b325ed7175095c5d71e910f064195cb248b2 100644 (file)
 //processor.
 // </tapsetdescription>
 
-/**
- * sfunction print_regs - Print a register dump
- * 
- * Description: This function prints a register dump. Does nothing if no registers are available for the probe point.
- */
-function print_regs ()
-%{
-       if ((c->probe_flags & _STP_PROBE_STATE_USER_MODE) && CONTEXT->uregs) {
-               _stp_print_regs (CONTEXT->uregs);
-       } else if (CONTEXT->kregs) {
-               _stp_print_regs (CONTEXT->kregs);
-       }
-%}
-
-/**
- * sfunction execname - Returns the execname of a target process (or group of processes)
- * 
- * Description: Returns the execname of a target process (or group of processes).
- */
-function execname:string ()
-%{ /* pure */ /* unprivileged */
-       strlcpy (STAP_RETVALUE, current->comm, MAXSTRINGLEN);
-%}
-
-/**
- * sfunction pid - Returns the ID of a target process
- * 
- * Description: This function returns the ID of a target process.
- */
-function pid:long ()
-%{ /* pure */ /* unprivileged */
-       STAP_RETVALUE = current->tgid;
-%}
-
-/**
- * sfunction tid - Returns the thread ID of a target process
- * 
- * Description: This function returns the thread ID of the target process.
- */
-function tid:long ()
-%{ /* pure */ /* unprivileged */
-       STAP_RETVALUE = current->pid;
-%}
-
-/**
- * sfunction ppid - Returns the process ID of a target process's parent process
- *
- * Description: This function return the process ID of the target proccess's parent process.
- */
-function ppid:long()
-%{ /* pure */ /* unprivileged */
-#if defined(STAPCONF_REAL_PARENT)
-       STAP_RETVALUE = current->real_parent->tgid;
-#else
-       STAP_RETVALUE = current->parent->tgid;
-#endif
-%}
-
-/**
- * sfunction pgrp - Returns the process group ID of the current process
- *
- * Description: This function returns the process group ID of the
- * current process.
- */
-function pgrp:long ()
-%{ /* pure */ /* unprivileged */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
-       struct signal_struct *ss = kread( &(current->signal) );
-       STAP_RETVALUE = kread ( &(ss->pgrp) );
-       CATCH_DEREF_FAULT();
-#else
-       STAP_RETVALUE = task_pgrp_nr_ns(current, &init_pid_ns);
-#endif
-%}
-
-/**
- * sfunction sid - Returns the session ID of the current process
- *
- * Description: The session ID of a process is the process group ID
- * of the session leader. Session ID is stored in the signal_struct
- *  since Kernel 2.6.0.
- */
-function sid:long ()
-%{ /* pure */ /* unprivileged */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
-       struct signal_struct *ss = kread( &(current->signal) );
-       STAP_RETVALUE = kread ( &(ss->session) );
-       CATCH_DEREF_FAULT();
-#else
-       STAP_RETVALUE = task_session_nr_ns(current, &init_pid_ns);
-#endif
-%}
-
-/**
- * sfunction pexecname - Returns the execname of a target process's parent process
- * 
- * Description: This function returns the execname of a target
- * process's parent procces.
- */
-function pexecname:string ()
-%{ /* pure */ /* unprivileged */
-#if defined(STAPCONF_REAL_PARENT)
-       strlcpy (STAP_RETVALUE, current->real_parent->comm, MAXSTRINGLEN);
-#else
-       strlcpy (STAP_RETVALUE, current->parent->comm, MAXSTRINGLEN);
-#endif
-%}
-
-/**
- * sfunction gid - Returns the group ID of a target process
- * 
- * Description: This function returns the group ID of a target process.
- */
-function gid:long ()
-%{ /* pure */ /* unprivileged */
-#ifdef STAPCONF_TASK_UID
-       STAP_RETVALUE = current->gid;
-#else
-       STAP_RETVALUE = current_gid();
-#endif
-%}
-
-/**
- * sfunction egid - Returns the effective gid of a target process
- * 
- * Description: This function returns the effective gid of a target process
- */
-function egid:long ()
-%{ /* pure */ /* unprivileged */
-#ifdef STAPCONF_TASK_UID
-       STAP_RETVALUE = current->egid;
-#else
-       STAP_RETVALUE = current_egid();
-#endif
-%}
-
-/**
- * sfunction uid - Returns the user ID of a target process
- * 
- * Description: This function returns the user ID of the target process.
- */
-function uid:long ()
-%{ /* pure */ /* unprivileged */
-#ifdef STAPCONF_TASK_UID
-       STAP_RETVALUE = current->uid;
-#else
-       STAP_RETVALUE = current_uid();
-#endif
-%}
-
-/**
- * sfunction euid - Return the effective uid of a target process
- *
- * Description: Returns the effective user ID of the target process.
- */
-function euid:long ()
-%{ /* pure */ /* unprivileged */
-#ifdef STAPCONF_TASK_UID
-       STAP_RETVALUE = current->euid;
-#else
-       STAP_RETVALUE = current_euid();
-#endif
-%}
-
-
-/**
- * sfunction is_myproc - Determines if the current probe point has occurred in the user's own process
- *
- * Description: This function returns 1 if the current probe
- * point has occurred in the user's own process.
- */
-function is_myproc:long ()
-%{ /* pure */ /* unprivileged */
-        STAP_RETVALUE = is_myproc();
-%}
-
-
-%( systemtap_v <= "1.4" %?
-/**
- * sfunction cpuid - Returns the current cpu number
- * 
- * Description: This function returns the current cpu number.
- * Deprecated in SystemTap 1.4 and removed in SystemTap 1.5.
- */
-function cpuid:long ()
-%{ /* pure */
-       STAP_RETVALUE = smp_processor_id();
-%}
-%)
-
-/**
- * sfunction cpu - Returns the current cpu number
- *
- * Description: This function returns the current cpu number.
- */
-function cpu:long ()
-%{ /* pure */ /* unprivileged */
-       STAP_RETVALUE = smp_processor_id();
-%}
-
 /**
  * sfunction pp - Returns the active probe point
  *
@@ -224,198 +24,6 @@ function pp:string ()
        strlcpy (STAP_RETVALUE, CONTEXT->probe_point, MAXSTRINGLEN);
 %}
 
-/**
- * sfunction registers_valid - Determines validity of register() and u_register() in current context
- *
- * Description: This function returns 1 if register() and u_register()
- * can be used in the current context, or 0 otherwise.
- * For example, registers_valid() returns 0
- * when called from a begin or end probe.
- */
-function registers_valid:long ()
-%{ /* pure */ /* unprivileged */
-       STAP_RETVALUE = ((c->probe_flags & _STP_PROBE_STATE_USER_MODE)
-                           ? (CONTEXT->uregs != NULL)
-                           : (CONTEXT->kregs != NULL));
-%}
-
-/**
- * sfunction user_mode - Determines if probe point occurs in user-mode
- *
- * Return 1 if the probe point occurred in user-mode.
- */
-function user_mode:long ()
-%{ /* pure */ /* unprivileged */
-  STAP_RETVALUE = (CONTEXT->probe_flags
-                     & _STP_PROBE_STATE_USER_MODE) ? 1 : 0;
-%}
-
-/**
- * sfunction is_return - Whether the current probe context is a return probe
- * 
- * Description: Returns 1 if the current probe context is a return probe,
- * returns 0 otherwise.
- */
-function is_return:long ()
-%{ /* pure */
-       if (CONTEXT->probe_type == _STP_PROBE_HANDLER_KRETPROBE
-           || CONTEXT->probe_type == _STP_PROBE_HANDLER_URETPROBE)
-               STAP_RETVALUE = 1;
-       else
-               STAP_RETVALUE = 0;
-%}
-
-/**
- * sfunction target - Return the process ID of the target process
- * 
- * Description: This function returns the process ID of the target
- * process.  This is useful in conjunction with the -x PID or
- * -c CMD command-line options to stap. An example of its use is
- * to create scripts that filter on a specific process.
- *
- * -x <pid>
- * target() returns the pid specified by -x
- *
- * -c <command>
- * target() returns the pid for the executed command specified by -c
- */
-function target:long ()
-%{ /* pure */ /* unprivileged */
-        STAP_RETVALUE = _stp_target;
-%}
-
-/**
- * sfunction module_name - The module name of the current script
- * 
- * Description: This function returns the name of the stap module.
- * Either generated randomly (stap_[0-9a-f]+_[0-9a-f]+)
- * or set by stap -m <module_name>.
- */
-function module_name:string ()
-%{ /* pure */ /* unprivileged */
-       strlcpy(STAP_RETVALUE, THIS_MODULE->name, MAXSTRINGLEN);
-%}
-
-/**
- * sfunction stp_pid - The process id of the stapio process
- *
- * Description: This function returns the process id of the 
- * stapio process that launched this script. There could be
- * other SystemTap scripts and stapio processes running on
- * the system.
- */
-function stp_pid:long ()
-%{ /* pure */
-        STAP_RETVALUE = _stp_pid;
-%}
-
-
-/**
- * sfunction remote_id - The index of this instance in a remote execution.
- *
- * Description: This function returns a number 0..N, which is the unique 
- * index of this particular script execution from a swarm of
- * "stap --remote A --remote B ..." runs, and is the same number
- * "stap --remote-prefix" would print.  The function returns -1 if the
- * script was not launched with "stap --remote", or if the remote 
- * staprun/stapsh are older than version 1.7.
- */
-function remote_id:long () {
-         return %{ /* pure */ /* unprivileged */ _stp_remote_id %}
-}
-
-
-/**
- * sfunction remote_uri - The name of this instance in a remote execution.
- *
- * Description: This function returns the remote host used to invoke
- * this particular script execution from a swarm of "stap --remote" runs.
- * It may not be unique among the swarm.
- * The function returns an empty string if the script was not launched with
- * "stap --remote".
- */
-function remote_uri:string () {
-         return %{ /* string */ /* pure */ /* unprivileged */ _stp_remote_uri %}
-}
-
-
-/**
- * sfunction stack_size - Return the size of the kernel stack
- * 
- * Description: This function returns the size of the kernel stack.
- */
-function stack_size:long ()
-%{ /* pure */
-        STAP_RETVALUE = THREAD_SIZE;
-%}
-
-/**
- * sfunction stack_used - Returns the amount of kernel stack used
- *
- * Description: This function determines how many bytes are
- * currently used in the kernel stack.
- */
-function stack_used:long ()
-%{ /* pure */
-       char a;
-        STAP_RETVALUE = THREAD_SIZE - ((long)&a & (THREAD_SIZE-1));
-%}
-
-/**
- * sfunction stack_unused - Returns the amount of kernel stack currently available
- *
- * Description: This function determines how many bytes are
- * currently available in the kernel stack.
- */
-function stack_unused:long ()
-%{ /* pure */
-       char a;
-        STAP_RETVALUE = (long)&a & (THREAD_SIZE-1);
-%}
-
-/**
- * sfunction addr - Address of the current probe point.
- *
- * Description: Returns the instruction pointer from the current probe's
- * register state.  Not all probe types have registers though, in which case
- * zero is returned.  The returned address is suitable for use with functions
- * like symname() and symdata().
- */
-function addr:long ()
-%{ /* pure */
-  if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE) {
-    STAP_RETVALUE = (intptr_t)(CONTEXT->uregs ? REG_IP(CONTEXT->uregs) : 0);
-  } else {
-    STAP_RETVALUE = (intptr_t)(CONTEXT->kregs ? REG_IP(CONTEXT->kregs) : 0);
-  }
-%}
-
-/**
- * sfunction uaddr - User space address of current running task
- *
- * Description: Returns the address in userspace that the current
- * task was at when the probe occurred. When the current running task
- * isn't a user space thread, or the address cannot be found, zero
- * is returned. Can be used to see where the current task is combined
- * with usymname() or usymdata(). Often the task will be in the VDSO
- * where it entered the kernel.
- */
-function uaddr:long ()
-%{ /* pure */ /* myproc-unprivileged */
-  struct pt_regs *uregs;
-
-  if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
-    uregs = CONTEXT->uregs;
-  else
-    uregs = _stp_current_pt_regs();
-
-  if (uregs)
-    STAP_RETVALUE = (int64_t) REG_IP(uregs);
-  else
-    STAP_RETVALUE = 0;
-%}
-
-
 /**
  * sfunction probe_type - The low level probe handler type of the current probe.
  *
@@ -490,81 +98,3 @@ function probe_type:string()
       break;
   }
 %}
-
-/**
- * sfunction cmdline_args - Fetch command line arguments from current process
- * @n: First argument to get (zero is the command itself)
- * @m: Last argument to get (or minus one for all arguments after n)
- * @delim: String to use to delimit arguments when more than one.
- *
- * Description: Returns arguments from the current process starting
- * with argument number n, up to argument m. If there are less than n
- * arguments, or the arguments cannot be retrieved from the current
- * process, the empty string is returned. If m is smaller than n then
- * all arguments starting from argument n are returned. Argument zero
- * is traditionally the command itself.
- */
-function cmdline_args:string(n:long, m:long, delim:string)
-{
-  args = "";
-  mm = @cast(task_current(), "task_struct", "kernel<linux/sched.h>")->mm;
-  if (mm)
-    {
-      arg_start = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->arg_start;
-      arg_end = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->arg_end;
-      if (arg_start != 0 && arg_end != 0)
-        {
-          nr = 0;
-          len = arg_end - arg_start;
-          arg = user_string2(arg_start, "");
-          while (len > 0)
-            {
-              if (nr == n)
-                args = arg;
-              else if (nr > n)
-                {
-                  if (arg == "")
-                    args .= delim . "\"\""
-                  else
-                    args .= delim . arg;
-                }
-
-              arg_len = strlen(arg);
-              arg_start += arg_len + 1;
-              len -= arg_len + 1;
-              if (len > 0 && nr != m)
-                arg = user_string2(arg_start, "");
-              else
-                arg = "";
-              nr++;
-            }
-        }
-    }
-  return args;
-}
-
-/**
- * sfunction cmdline_arg - Fetch a command line argument
- * @n: Argument to get (zero is the command itself)
- *
- * Description: Returns argument the requested argument from the
- * current process or the empty string when there are not that many
- * arguments or there is a problem retrieving the argument. Argument
- * zero is traditionally the command itself.
- */
-function cmdline_arg:string(n:long)
-{
-  return cmdline_args(n, n, "");
-}
-
-/**
- * sfunction cmdline_str - Fetch all command line arguments from current process
- *
- * Description: Returns all arguments from the current process
- * delimited by spaces. Returns the empty string when the arguments
- * cannot be retrieved.
- */
-function cmdline_str:string()
-{
-  return cmdline_args(0, -1, " ");
-}
diff --git a/tapset/dyninst/context-envvar.stp b/tapset/dyninst/context-envvar.stp
new file mode 100644 (file)
index 0000000..cb6d646
--- /dev/null
@@ -0,0 +1,24 @@
+// context-envvar tapset
+// Copyright (C) 2012 Red Hat, Inc.
+//
+// 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.
+
+// NB: functionally equivalent to linux/context-envvar.stp
+
+%{
+#include <stdlib.h>
+%}
+
+function env_var:string(name:string)
+%{ /* pure */
+    // XXX getenv may not be reentrant!
+    const char* env = getenv(STAP_ARG_name);
+    if (env)
+        strlcpy (STAP_RETVALUE, env, MAXSTRINGLEN);
+    else
+        STAP_RETVALUE[0] = '\0';
+
+%}
diff --git a/tapset/dyninst/context.stp b/tapset/dyninst/context.stp
new file mode 100644 (file)
index 0000000..757c46e
--- /dev/null
@@ -0,0 +1,108 @@
+// context tapset
+// Copyright (C) 2012 Red Hat, Inc.
+//
+// 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.
+
+// NB: functionally equivalent to linux/context.stp
+
+%{
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <unistd.h>
+%}
+
+// TODO function print_regs ()
+
+// TODO function execname:string ()
+
+function pid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = getpid();
+%}
+
+function tid:long ()
+%{ /* pure */ /* unprivileged */
+        /* NB: no glibc wrapper available */
+       STAP_RETVALUE = syscall(SYS_gettid);
+%}
+
+function ppid:long()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = getppid();
+%}
+
+function pgrp:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = getpgrp();
+%}
+
+function sid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = getsid(0);
+%}
+
+// TODO function pexecname:string ()
+
+function gid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = getgid();
+%}
+
+function egid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = getegid();
+%}
+
+function uid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = getuid();
+%}
+
+function euid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = geteuid();
+%}
+
+
+// TODO function is_myproc:long ()
+// NB: dyninst by nature is myproc-only, *except if you're root*
+
+// TODO function cpu:long ()
+
+// TODO function registers_valid:long ()
+
+function user_mode:long ()
+{
+       return 1;
+}
+
+// TODO function is_return:long ()
+
+// TODO function target:long ()
+
+// TODO function module_name:string ()
+
+// TODO function stp_pid:long ()
+
+// TODO function remote_id:long ()
+
+// TODO function remote_uri:string ()
+
+// TODO function stack_size:long ()
+
+// TODO function stack_used:long ()
+
+// TODO function stack_unused:long ()
+
+// TODO function addr:long ()
+
+// TODO function uaddr:long ()
+
+// TODO function cmdline_args:string(n:long, m:long, delim:string)
+
+// TODO function cmdline_arg:string(n:long)
+
+// TODO function cmdline_str:string()
diff --git a/tapset/dyninst/ctime.stp b/tapset/dyninst/ctime.stp
new file mode 100644 (file)
index 0000000..c754618
--- /dev/null
@@ -0,0 +1,30 @@
+/* ctime.stp - Convert seconds to human readable date string.
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ */
+
+/* NB: functionally equivalent to linux/ctime.stp
+ * This means unlike normal userspace ctime(), this version
+ * returns time in UTC, without a final newline.
+ */
+
+%{
+#include <string.h>
+#include <time.h>
+%}
+
+function ctime:string(epochsecs:long)
+%{  /* pure */
+    struct tm gmt;
+    char buf[26];
+
+    const time_t t = STAP_ARG_epochsecs;
+
+    if (gmtime_r(&t, &gmt) && asctime_r(&gmt, buf)) {
+        char* newline = strchr(buf, '\n');
+        if (newline)
+            *newline = '\0';
+        strlcpy (STAP_RETVALUE, buf, MAXSTRINGLEN);
+    } else
+        STAP_RETVALUE[0] = '\0';
+%}
diff --git a/tapset/dyninst/endian.stp b/tapset/dyninst/endian.stp
new file mode 100644 (file)
index 0000000..cc4815f
--- /dev/null
@@ -0,0 +1,29 @@
+// NB: functionally equivalent to linux/endian.stp
+
+%{
+#include <endian.h>
+%}
+
+function big_endian2:long (val:long) %{ /* pure */
+       STAP_RETVALUE = htobe16((uint16_t)STAP_ARG_val);
+%}
+
+function big_endian4:long (val:long) %{ /* pure */
+       STAP_RETVALUE = htobe32((uint32_t)STAP_ARG_val);
+%}
+
+function big_endian8:long (val:long) %{ /* pure */
+       STAP_RETVALUE = htobe64((uint64_t)STAP_ARG_val);
+%}
+
+function little_endian2:long (val:long) %{ /* pure */
+       STAP_RETVALUE = htole16((uint16_t)STAP_ARG_val);
+%}
+
+function little_endian4:long (val:long) %{ /* pure */
+       STAP_RETVALUE = htole32((uint32_t)STAP_ARG_val);
+%}
+
+function little_endian8:long (val:long) %{ /* pure */
+       STAP_RETVALUE = htole64((uint64_t)STAP_ARG_val);
+%}
diff --git a/tapset/dyninst/guru-delay.stp b/tapset/dyninst/guru-delay.stp
new file mode 100644 (file)
index 0000000..41ae733
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (C) 2012 Red Hat Inc.
+//
+// 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.
+//
+
+// NB: functionally equivalent to linux/guru-delay.stp
+
+%{
+#include <time.h>
+%}
+
+function mdelay(ms:long)
+{
+       udelay(ms * 1000);
+}
+
+function udelay(us:long)
+%{ /* guru */
+       struct timespec ts = {
+               STAP_ARG_us / 1000000,
+               STAP_ARG_us % 1000000,
+       };
+       nanosleep(&ts, NULL);
+       // XXX spin on EINTR?
+%}
diff --git a/tapset/dyninst/inet.stp b/tapset/dyninst/inet.stp
new file mode 100644 (file)
index 0000000..a674d4c
--- /dev/null
@@ -0,0 +1,40 @@
+/* Some functions from libc <arpa/inet.h> */
+
+/* NB: functionally equivalent to linux/inet.stp
+ * ... but we have the advantage of using (mostly) direct equivalents!
+ */
+
+%{
+#include <arpa/inet.h>
+#include <endian.h>
+%}
+
+function htonll:long (x:long)
+%{
+       /* pure */ STAP_RETVALUE = htobe64 ((uint64_t) STAP_ARG_x);
+%}
+
+function htonl:long (x:long)
+%{
+       /* pure */ STAP_RETVALUE = htonl ((uint32_t) STAP_ARG_x);
+%}
+
+function htons:long (x:long)
+%{
+       /* pure */ STAP_RETVALUE = htons ((uint16_t) STAP_ARG_x);
+%}
+
+function ntohll:long (x:long)
+%{
+       /* pure */ STAP_RETVALUE = be64toh ((uint64_t) STAP_ARG_x);
+%}
+
+function ntohl:long (x:long)
+%{
+       /* pure */ STAP_RETVALUE = ntohl ((uint32_t) STAP_ARG_x);
+%}
+
+function ntohs:long (x:long)
+%{
+       /* pure */ STAP_RETVALUE = ntohs ((uint16_t) STAP_ARG_x);
+%}
diff --git a/tapset/dyninst/timestamp_gtod.stp b/tapset/dyninst/timestamp_gtod.stp
new file mode 100644 (file)
index 0000000..00f4244
--- /dev/null
@@ -0,0 +1,31 @@
+// timestamp tapset -- gettimeofday variants
+// Copyright (C) 2012 Red Hat, Inc.
+//
+// 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.
+
+// NB: functionally equivalent to linux/timestamp_gtod.stp
+
+%{
+#include <sys/time.h>
+%}
+
+function gettimeofday_ns:long () {
+  return gettimeofday_us() * 1000; // XXX available resolution isn't this high!
+}
+
+function gettimeofday_us:long () %{ /* pure */ /* unprivileged */
+  struct timeval tv;
+  if (gettimeofday(&tv, NULL) == 0)
+    STAP_RETVALUE = (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec;
+%}
+
+function gettimeofday_ms:long () {
+  return gettimeofday_us() / 1000;
+}
+
+function gettimeofday_s:long () {
+  return gettimeofday_us() / 1000000;
+}
similarity index 100%
rename from tapset/atomic.stp
rename to tapset/linux/atomic.stp
diff --git a/tapset/linux/context.stp b/tapset/linux/context.stp
new file mode 100644 (file)
index 0000000..1b424d1
--- /dev/null
@@ -0,0 +1,483 @@
+// context tapset
+// Copyright (C) 2005-2011 Red Hat Inc.
+// Copyright (C) 2006 Intel Corporation.
+//
+// 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.
+// <tapsetdescription>
+// Context functions provide additional information about where an event occurred. These functions can
+//provide information such as a backtrace to where the event occurred and the current register values for the
+//processor.
+// </tapsetdescription>
+
+/**
+ * sfunction print_regs - Print a register dump
+ * 
+ * Description: This function prints a register dump. Does nothing if no registers are available for the probe point.
+ */
+function print_regs ()
+%{
+       if ((c->probe_flags & _STP_PROBE_STATE_USER_MODE) && CONTEXT->uregs) {
+               _stp_print_regs (CONTEXT->uregs);
+       } else if (CONTEXT->kregs) {
+               _stp_print_regs (CONTEXT->kregs);
+       }
+%}
+
+/**
+ * sfunction execname - Returns the execname of a target process (or group of processes)
+ * 
+ * Description: Returns the execname of a target process (or group of processes).
+ */
+function execname:string ()
+%{ /* pure */ /* unprivileged */
+       strlcpy (STAP_RETVALUE, current->comm, MAXSTRINGLEN);
+%}
+
+/**
+ * sfunction pid - Returns the ID of a target process
+ * 
+ * Description: This function returns the ID of a target process.
+ */
+function pid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = current->tgid;
+%}
+
+/**
+ * sfunction tid - Returns the thread ID of a target process
+ * 
+ * Description: This function returns the thread ID of the target process.
+ */
+function tid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = current->pid;
+%}
+
+/**
+ * sfunction ppid - Returns the process ID of a target process's parent process
+ *
+ * Description: This function return the process ID of the target proccess's parent process.
+ */
+function ppid:long()
+%{ /* pure */ /* unprivileged */
+#if defined(STAPCONF_REAL_PARENT)
+       STAP_RETVALUE = current->real_parent->tgid;
+#else
+       STAP_RETVALUE = current->parent->tgid;
+#endif
+%}
+
+/**
+ * sfunction pgrp - Returns the process group ID of the current process
+ *
+ * Description: This function returns the process group ID of the
+ * current process.
+ */
+function pgrp:long ()
+%{ /* pure */ /* unprivileged */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
+       struct signal_struct *ss = kread( &(current->signal) );
+       STAP_RETVALUE = kread ( &(ss->pgrp) );
+       CATCH_DEREF_FAULT();
+#else
+       STAP_RETVALUE = task_pgrp_nr_ns(current, &init_pid_ns);
+#endif
+%}
+
+/**
+ * sfunction sid - Returns the session ID of the current process
+ *
+ * Description: The session ID of a process is the process group ID
+ * of the session leader. Session ID is stored in the signal_struct
+ *  since Kernel 2.6.0.
+ */
+function sid:long ()
+%{ /* pure */ /* unprivileged */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
+       struct signal_struct *ss = kread( &(current->signal) );
+       STAP_RETVALUE = kread ( &(ss->session) );
+       CATCH_DEREF_FAULT();
+#else
+       STAP_RETVALUE = task_session_nr_ns(current, &init_pid_ns);
+#endif
+%}
+
+/**
+ * sfunction pexecname - Returns the execname of a target process's parent process
+ * 
+ * Description: This function returns the execname of a target
+ * process's parent procces.
+ */
+function pexecname:string ()
+%{ /* pure */ /* unprivileged */
+#if defined(STAPCONF_REAL_PARENT)
+       strlcpy (STAP_RETVALUE, current->real_parent->comm, MAXSTRINGLEN);
+#else
+       strlcpy (STAP_RETVALUE, current->parent->comm, MAXSTRINGLEN);
+#endif
+%}
+
+/**
+ * sfunction gid - Returns the group ID of a target process
+ * 
+ * Description: This function returns the group ID of a target process.
+ */
+function gid:long ()
+%{ /* pure */ /* unprivileged */
+#ifdef STAPCONF_TASK_UID
+       STAP_RETVALUE = current->gid;
+#else
+       STAP_RETVALUE = current_gid();
+#endif
+%}
+
+/**
+ * sfunction egid - Returns the effective gid of a target process
+ * 
+ * Description: This function returns the effective gid of a target process
+ */
+function egid:long ()
+%{ /* pure */ /* unprivileged */
+#ifdef STAPCONF_TASK_UID
+       STAP_RETVALUE = current->egid;
+#else
+       STAP_RETVALUE = current_egid();
+#endif
+%}
+
+/**
+ * sfunction uid - Returns the user ID of a target process
+ * 
+ * Description: This function returns the user ID of the target process.
+ */
+function uid:long ()
+%{ /* pure */ /* unprivileged */
+#ifdef STAPCONF_TASK_UID
+       STAP_RETVALUE = current->uid;
+#else
+       STAP_RETVALUE = current_uid();
+#endif
+%}
+
+/**
+ * sfunction euid - Return the effective uid of a target process
+ *
+ * Description: Returns the effective user ID of the target process.
+ */
+function euid:long ()
+%{ /* pure */ /* unprivileged */
+#ifdef STAPCONF_TASK_UID
+       STAP_RETVALUE = current->euid;
+#else
+       STAP_RETVALUE = current_euid();
+#endif
+%}
+
+
+/**
+ * sfunction is_myproc - Determines if the current probe point has occurred in the user's own process
+ *
+ * Description: This function returns 1 if the current probe
+ * point has occurred in the user's own process.
+ */
+function is_myproc:long ()
+%{ /* pure */ /* unprivileged */
+        STAP_RETVALUE = is_myproc();
+%}
+
+
+%( systemtap_v <= "1.4" %?
+/**
+ * sfunction cpuid - Returns the current cpu number
+ * 
+ * Description: This function returns the current cpu number.
+ * Deprecated in SystemTap 1.4 and removed in SystemTap 1.5.
+ */
+function cpuid:long ()
+%{ /* pure */
+       STAP_RETVALUE = smp_processor_id();
+%}
+%)
+
+/**
+ * sfunction cpu - Returns the current cpu number
+ *
+ * Description: This function returns the current cpu number.
+ */
+function cpu:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = smp_processor_id();
+%}
+
+/**
+ * sfunction registers_valid - Determines validity of register() and u_register() in current context
+ *
+ * Description: This function returns 1 if register() and u_register()
+ * can be used in the current context, or 0 otherwise.
+ * For example, registers_valid() returns 0
+ * when called from a begin or end probe.
+ */
+function registers_valid:long ()
+%{ /* pure */ /* unprivileged */
+       STAP_RETVALUE = ((c->probe_flags & _STP_PROBE_STATE_USER_MODE)
+                           ? (CONTEXT->uregs != NULL)
+                           : (CONTEXT->kregs != NULL));
+%}
+
+/**
+ * sfunction user_mode - Determines if probe point occurs in user-mode
+ *
+ * Return 1 if the probe point occurred in user-mode.
+ */
+function user_mode:long ()
+%{ /* pure */ /* unprivileged */
+  STAP_RETVALUE = (CONTEXT->probe_flags
+                     & _STP_PROBE_STATE_USER_MODE) ? 1 : 0;
+%}
+
+/**
+ * sfunction is_return - Whether the current probe context is a return probe
+ * 
+ * Description: Returns 1 if the current probe context is a return probe,
+ * returns 0 otherwise.
+ */
+function is_return:long ()
+%{ /* pure */
+       if (CONTEXT->probe_type == _STP_PROBE_HANDLER_KRETPROBE
+           || CONTEXT->probe_type == _STP_PROBE_HANDLER_URETPROBE)
+               STAP_RETVALUE = 1;
+       else
+               STAP_RETVALUE = 0;
+%}
+
+/**
+ * sfunction target - Return the process ID of the target process
+ * 
+ * Description: This function returns the process ID of the target
+ * process.  This is useful in conjunction with the -x PID or
+ * -c CMD command-line options to stap. An example of its use is
+ * to create scripts that filter on a specific process.
+ *
+ * -x <pid>
+ * target() returns the pid specified by -x
+ *
+ * -c <command>
+ * target() returns the pid for the executed command specified by -c
+ */
+function target:long ()
+%{ /* pure */ /* unprivileged */
+        STAP_RETVALUE = _stp_target;
+%}
+
+/**
+ * sfunction module_name - The module name of the current script
+ * 
+ * Description: This function returns the name of the stap module.
+ * Either generated randomly (stap_[0-9a-f]+_[0-9a-f]+)
+ * or set by stap -m <module_name>.
+ */
+function module_name:string ()
+%{ /* pure */ /* unprivileged */
+       strlcpy(STAP_RETVALUE, THIS_MODULE->name, MAXSTRINGLEN);
+%}
+
+/**
+ * sfunction stp_pid - The process id of the stapio process
+ *
+ * Description: This function returns the process id of the 
+ * stapio process that launched this script. There could be
+ * other SystemTap scripts and stapio processes running on
+ * the system.
+ */
+function stp_pid:long ()
+%{ /* pure */
+        STAP_RETVALUE = _stp_pid;
+%}
+
+
+/**
+ * sfunction remote_id - The index of this instance in a remote execution.
+ *
+ * Description: This function returns a number 0..N, which is the unique 
+ * index of this particular script execution from a swarm of
+ * "stap --remote A --remote B ..." runs, and is the same number
+ * "stap --remote-prefix" would print.  The function returns -1 if the
+ * script was not launched with "stap --remote", or if the remote 
+ * staprun/stapsh are older than version 1.7.
+ */
+function remote_id:long () {
+         return %{ /* pure */ /* unprivileged */ _stp_remote_id %}
+}
+
+
+/**
+ * sfunction remote_uri - The name of this instance in a remote execution.
+ *
+ * Description: This function returns the remote host used to invoke
+ * this particular script execution from a swarm of "stap --remote" runs.
+ * It may not be unique among the swarm.
+ * The function returns an empty string if the script was not launched with
+ * "stap --remote".
+ */
+function remote_uri:string () {
+         return %{ /* string */ /* pure */ /* unprivileged */ _stp_remote_uri %}
+}
+
+
+/**
+ * sfunction stack_size - Return the size of the kernel stack
+ * 
+ * Description: This function returns the size of the kernel stack.
+ */
+function stack_size:long ()
+%{ /* pure */
+        STAP_RETVALUE = THREAD_SIZE;
+%}
+
+/**
+ * sfunction stack_used - Returns the amount of kernel stack used
+ *
+ * Description: This function determines how many bytes are
+ * currently used in the kernel stack.
+ */
+function stack_used:long ()
+%{ /* pure */
+       char a;
+        STAP_RETVALUE = THREAD_SIZE - ((long)&a & (THREAD_SIZE-1));
+%}
+
+/**
+ * sfunction stack_unused - Returns the amount of kernel stack currently available
+ *
+ * Description: This function determines how many bytes are
+ * currently available in the kernel stack.
+ */
+function stack_unused:long ()
+%{ /* pure */
+       char a;
+        STAP_RETVALUE = (long)&a & (THREAD_SIZE-1);
+%}
+
+/**
+ * sfunction addr - Address of the current probe point.
+ *
+ * Description: Returns the instruction pointer from the current probe's
+ * register state.  Not all probe types have registers though, in which case
+ * zero is returned.  The returned address is suitable for use with functions
+ * like symname() and symdata().
+ */
+function addr:long ()
+%{ /* pure */
+  if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE) {
+    STAP_RETVALUE = (intptr_t)(CONTEXT->uregs ? REG_IP(CONTEXT->uregs) : 0);
+  } else {
+    STAP_RETVALUE = (intptr_t)(CONTEXT->kregs ? REG_IP(CONTEXT->kregs) : 0);
+  }
+%}
+
+/**
+ * sfunction uaddr - User space address of current running task
+ *
+ * Description: Returns the address in userspace that the current
+ * task was at when the probe occurred. When the current running task
+ * isn't a user space thread, or the address cannot be found, zero
+ * is returned. Can be used to see where the current task is combined
+ * with usymname() or usymdata(). Often the task will be in the VDSO
+ * where it entered the kernel.
+ */
+function uaddr:long ()
+%{ /* pure */ /* myproc-unprivileged */
+  struct pt_regs *uregs;
+
+  if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
+    uregs = CONTEXT->uregs;
+  else
+    uregs = _stp_current_pt_regs();
+
+  if (uregs)
+    STAP_RETVALUE = (int64_t) REG_IP(uregs);
+  else
+    STAP_RETVALUE = 0;
+%}
+
+
+/**
+ * sfunction cmdline_args - Fetch command line arguments from current process
+ * @n: First argument to get (zero is the command itself)
+ * @m: Last argument to get (or minus one for all arguments after n)
+ * @delim: String to use to delimit arguments when more than one.
+ *
+ * Description: Returns arguments from the current process starting
+ * with argument number n, up to argument m. If there are less than n
+ * arguments, or the arguments cannot be retrieved from the current
+ * process, the empty string is returned. If m is smaller than n then
+ * all arguments starting from argument n are returned. Argument zero
+ * is traditionally the command itself.
+ */
+function cmdline_args:string(n:long, m:long, delim:string)
+{
+  args = "";
+  mm = @cast(task_current(), "task_struct", "kernel<linux/sched.h>")->mm;
+  if (mm)
+    {
+      arg_start = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->arg_start;
+      arg_end = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->arg_end;
+      if (arg_start != 0 && arg_end != 0)
+        {
+          nr = 0;
+          len = arg_end - arg_start;
+          arg = user_string2(arg_start, "");
+          while (len > 0)
+            {
+              if (nr == n)
+                args = arg;
+              else if (nr > n)
+                {
+                  if (arg == "")
+                    args .= delim . "\"\""
+                  else
+                    args .= delim . arg;
+                }
+
+              arg_len = strlen(arg);
+              arg_start += arg_len + 1;
+              len -= arg_len + 1;
+              if (len > 0 && nr != m)
+                arg = user_string2(arg_start, "");
+              else
+                arg = "";
+              nr++;
+            }
+        }
+    }
+  return args;
+}
+
+/**
+ * sfunction cmdline_arg - Fetch a command line argument
+ * @n: Argument to get (zero is the command itself)
+ *
+ * Description: Returns argument the requested argument from the
+ * current process or the empty string when there are not that many
+ * arguments or there is a problem retrieving the argument. Argument
+ * zero is traditionally the command itself.
+ */
+function cmdline_arg:string(n:long)
+{
+  return cmdline_args(n, n, "");
+}
+
+/**
+ * sfunction cmdline_str - Fetch all command line arguments from current process
+ *
+ * Description: Returns all arguments from the current process
+ * delimited by spaces. Returns the empty string when the arguments
+ * cannot be retrieved.
+ */
+function cmdline_str:string()
+{
+  return cmdline_args(0, -1, " ");
+}
similarity index 100%
rename from tapset/ctime.stp
rename to tapset/linux/ctime.stp
similarity index 100%
rename from tapset/dentry.stp
rename to tapset/linux/dentry.stp
similarity index 100%
rename from tapset/dev.stp
rename to tapset/linux/dev.stp
similarity index 100%
rename from tapset/endian.stp
rename to tapset/linux/endian.stp
similarity index 100%
rename from tapset/inet.stp
rename to tapset/linux/inet.stp
similarity index 100%
rename from tapset/ioblock.stp
rename to tapset/linux/ioblock.stp
similarity index 100%
rename from tapset/ip.stp
rename to tapset/linux/ip.stp
similarity index 100%
rename from tapset/ipmib.stp
rename to tapset/linux/ipmib.stp
similarity index 100%
rename from tapset/irq.stp
rename to tapset/linux/irq.stp
diff --git a/tapset/linux/logging.stp b/tapset/linux/logging.stp
new file mode 100644 (file)
index 0000000..e90cd80
--- /dev/null
@@ -0,0 +1,59 @@
+// logging tapset
+// Copyright (C) 2005-2011 Red Hat Inc.
+//
+// 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.
+
+
+/**
+ * sfunction ftrace - Send a message to the ftrace ring-buffer
+ *
+ * @msg: The formatted message string
+ *
+ * Description: If the ftrace ring-buffer is configured & available,
+ * see /debugfs/tracing/trace for the message.  Otherwise, the
+ * message may be quietly dropped.  An implicit end-of-line is added.
+ */
+function ftrace (msg:string) %{
+#ifdef STAPCONF_TRACE_PRINTK
+       static char *fmt = "%s\n";
+       trace_printk (fmt, STAP_ARG_msg);
+
+       /* The "fmt" is designed to be non __builtin_constant_p(), so as
+       to defeat trace_printk -> __trace_bprintk optimization.  That's
+       because bprintk doesn't save the incoming strings, only their
+       addresses. */
+#endif
+%}
+
+
+
+/**
+ * sfunction printk - Send a message to the kernel trace buffer
+ *
+ * @level: an integer for the severity level (0=KERN_EMERG ... 7=KERN_DEBUG)
+ * @msg: The formatted message string
+ *
+ * Description: Print a line of text to the kernel dmesg/console with the
+ * given severity.  An implicit end-of-line is added.  This function may 
+ * not be safely called from all kernel probe contexts, so is restricted
+ * to guru mode only.
+ */
+function printk (level:long,msg:string) %{ /* guru */
+         printk (STAP_ARG_level == 0 ? KERN_EMERG "%s\n":
+                 STAP_ARG_level == 1 ? KERN_ALERT "%s\n":
+                 STAP_ARG_level == 2 ? KERN_CRIT "%s\n":
+                 STAP_ARG_level == 3 ? KERN_ERR "%s\n":
+                 STAP_ARG_level == 4 ? KERN_WARNING "%s\n":
+                 STAP_ARG_level == 5 ? KERN_NOTICE "%s\n":
+                 STAP_ARG_level == 6 ? KERN_INFO "%s\n":
+                 STAP_ARG_level == 7 ? KERN_DEBUG "%s\n":
+#ifdef KERN_DEFAULT
+                 KERN_DEFAULT "%s\n"
+#else
+                 KERN_INFO "%s\n"
+#endif
+                 , STAP_ARG_msg);
+%}
similarity index 100%
rename from tapset/memory.stp
rename to tapset/linux/memory.stp
similarity index 100%
rename from tapset/nfs.stp
rename to tapset/linux/nfs.stp
similarity index 100%
rename from tapset/nfsd.stp
rename to tapset/linux/nfsd.stp
similarity index 100%
rename from tapset/panic.stp
rename to tapset/linux/panic.stp
similarity index 100%
rename from tapset/perf.stp
rename to tapset/linux/perf.stp
similarity index 100%
rename from tapset/pstrace.stp
rename to tapset/linux/pstrace.stp
similarity index 100%
rename from tapset/rpc.stp
rename to tapset/linux/rpc.stp
similarity index 100%
rename from tapset/scsi.stp
rename to tapset/linux/scsi.stp
similarity index 100%
rename from tapset/signal.stp
rename to tapset/linux/signal.stp
similarity index 100%
rename from tapset/socket.stp
rename to tapset/linux/socket.stp
similarity index 100%
rename from tapset/task.stp
rename to tapset/linux/task.stp
similarity index 100%
rename from tapset/tcp.stp
rename to tapset/linux/tcp.stp
similarity index 100%
rename from tapset/tcpmib.stp
rename to tapset/linux/tcpmib.stp
similarity index 100%
rename from tapset/tty.stp
rename to tapset/linux/tty.stp
similarity index 100%
rename from tapset/udp.stp
rename to tapset/linux/udp.stp
similarity index 100%
rename from tapset/utrace.stp
rename to tapset/linux/utrace.stp
similarity index 100%
rename from tapset/vfs.stp
rename to tapset/linux/vfs.stp
index c98564fbd0cfc6e60c5fbaf194b772cad4b247a7..a4e4f2a6601be50c53c13cedf22748a462389770 100644 (file)
@@ -76,55 +76,3 @@ function error (msg:string) %{ /* unprivileged */
 function stp_print_binary(n:long, arg1:long, arg2:long, arg3:long, arg4:long) %{
        _stp_print_binary (STAP_ARG_n, STAP_ARG_arg1, STAP_ARG_arg2, STAP_ARG_arg3, STAP_ARG_arg4);
 %}
-
-
-/**
- * sfunction ftrace - Send a message to the ftrace ring-buffer
- *
- * @msg: The formatted message string
- *
- * Description: If the ftrace ring-buffer is configured & available,
- * see /debugfs/tracing/trace for the message.  Otherwise, the
- * message may be quietly dropped.  An implicit end-of-line is added.
- */
-function ftrace (msg:string) %{
-#ifdef STAPCONF_TRACE_PRINTK
-       static char *fmt = "%s\n";
-       trace_printk (fmt, STAP_ARG_msg);
-
-       /* The "fmt" is designed to be non __builtin_constant_p(), so as
-       to defeat trace_printk -> __trace_bprintk optimization.  That's
-       because bprintk doesn't save the incoming strings, only their
-       addresses. */
-#endif
-%}
-
-
-
-/**
- * sfunction printk - Send a message to the kernel trace buffer
- *
- * @level: an integer for the severity level (0=KERN_EMERG ... 7=KERN_DEBUG)
- * @msg: The formatted message string
- *
- * Description: Print a line of text to the kernel dmesg/console with the
- * given severity.  An implicit end-of-line is added.  This function may 
- * not be safely called from all kernel probe contexts, so is restricted
- * to guru mode only.
- */
-function printk (level:long,msg:string) %{ /* guru */
-         printk (STAP_ARG_level == 0 ? KERN_EMERG "%s\n":
-                 STAP_ARG_level == 1 ? KERN_ALERT "%s\n":
-                 STAP_ARG_level == 2 ? KERN_CRIT "%s\n":
-                 STAP_ARG_level == 3 ? KERN_ERR "%s\n":
-                 STAP_ARG_level == 4 ? KERN_WARNING "%s\n":
-                 STAP_ARG_level == 5 ? KERN_NOTICE "%s\n":
-                 STAP_ARG_level == 6 ? KERN_INFO "%s\n":
-                 STAP_ARG_level == 7 ? KERN_DEBUG "%s\n":
-#ifdef KERN_DEFAULT
-                 KERN_DEFAULT "%s\n"
-#else
-                 KERN_INFO "%s\n"
-#endif
-                 , STAP_ARG_msg);
-%}
This page took 0.092831 seconds and 5 git commands to generate.