]> sourceware.org Git - systemtap.git/commitdiff
tapset: separate env_var() from context.stp
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 22 Dec 2011 02:06:24 +0000 (21:06 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Thu, 22 Dec 2011 02:09:46 +0000 (21:09 -0500)
If it's left in context.stp, it will drag in tokenize.stp, which in
turns drags in an unoptimizable  %{ #define STAP_NEED_CONTEXT_TOKENIZE 1 %}
which in turns enlarges the context.

* tapset/context-envvar.stp: New file. Steal env_var() from ...
* tapset/context.stp: ... from here.

doc/SystemTap_Tapset_Reference/tapsets.tmpl
tapset/context-envvar.stp [new file with mode: 0644]
tapset/context.stp

index dd78a4eb2b9c457fe807eda74c502b8372c279bd..110512e7ce929c6f0be47069167b8645bbde55fb 100644 (file)
       and the current register values for the processor.
     </para>
 !Itapset/context.stp
+!Itapset/context-envvar.stp
 !Itapset/context-symbols.stp
 !Itapset/ucontext.stp
 !Itapset/ucontext-symbols.stp
diff --git a/tapset/context-envvar.stp b/tapset/context-envvar.stp
new file mode 100644 (file)
index 0000000..e7851d3
--- /dev/null
@@ -0,0 +1,57 @@
+// context-envvar tapset
+// Copyright (C) 2010 Pixar Inc. and/or Lars R. Damerow
+//
+// 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 env_var - Fetch environment variable from current process
+ * @name: Name of the environment variable to fetch
+ *
+ * Description: Returns the contents of the specified environment value
+ * for the current process. If the variable isn't set an empty string
+ * is returned.
+ */
+function env_var:string(name:string)
+{
+  if (name == "")
+    return ""
+
+  env_value = "";
+  mm = @cast(task_current(), "task_struct", "kernel<linux/sched.h>")->mm;
+  if (mm)
+    {
+      env_start = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->env_start;
+      env_end = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->env_end;
+      if (env_start != 0 && env_end != 0)
+        {
+          len = env_end - env_start;
+          cur = user_string2(env_start, "");
+          env_name = tokenize(cur, "=");
+          while (env_name != name && len > 0)
+            {
+              env_len = strlen(cur);
+              env_start += env_len + 1;
+              len -= env_len + 1;
+              if (len > 0)
+                {
+                  cur = user_string2(env_start, "");
+                  env_name = tokenize(cur, "=");
+                }
+              else
+                env_name = "";
+            }
+
+          if (len > 0)
+            env_value = tokenize("", "");
+        }
+    }
+  return env_value;
+}
index da464fb004ac49ff6896e1647c71ab38e386a44b..dc639628f504f8538ddc071abc9f8c894cab15b1 100644 (file)
@@ -565,48 +565,3 @@ function cmdline_str:string()
 {
   return cmdline_args(0, -1, " ");
 }
-
-/**
- * sfunction env_var - Fetch environment variable from current process
- * @name: Name of the environment variable to fetch
- *
- * Description: Returns the contents of the specified environment value
- * for the current process. If the variable isn't set an empty string
- * is returned.
- */
-function env_var:string(name:string)
-{
-  if (name == "")
-    return ""
-
-  env_value = "";
-  mm = @cast(task_current(), "task_struct", "kernel<linux/sched.h>")->mm;
-  if (mm)
-    {
-      env_start = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->env_start;
-      env_end = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->env_end;
-      if (env_start != 0 && env_end != 0)
-        {
-          len = env_end - env_start;
-          cur = user_string2(env_start, "");
-          env_name = tokenize(cur, "=");
-          while (env_name != name && len > 0)
-            {
-              env_len = strlen(cur);
-              env_start += env_len + 1;
-              len -= env_len + 1;
-              if (len > 0)
-                {
-                  cur = user_string2(env_start, "");
-                  env_name = tokenize(cur, "=");
-                }
-              else
-                env_name = "";
-            }
-
-          if (len > 0)
-            env_value = tokenize("", "");
-        }
-    }
-  return env_value;
-}
This page took 0.034493 seconds and 5 git commands to generate.