]> sourceware.org Git - systemtap.git/commitdiff
Only add probe_name to the common probe context when really needed.
authorMark Wielaard <mjw@redhat.com>
Mon, 1 Aug 2011 10:39:36 +0000 (12:39 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 1 Aug 2011 10:39:36 +0000 (12:39 +0200)
Guard probe_name with STP_NEED_PROBE_NAME. It is only needed when we include
the pn() tapset function. All this needed was moving the STP_NEED_PROBE_NAME
define from the tapset function to a top-level embedded C block (which are
included early, unlike the tapset functions themselves).

Also document common_probe_context.h busy, probe_point and probe_name fields.

runtime/common_probe_context.h
tapset/pn.stp
tapsets.cxx

index 366cb59fa72b23141183a13605ac046978d27cd9..715120166573591f861b61fafb6e2274329a31b1 100644 (file)
@@ -2,9 +2,27 @@
    Defines all common fields and probe flags for struct context.
    Available to C-based probe handlers as fields of the CONTEXT ptr.  */
 
+/* Used to indicate whether a probe context is in use.
+   Tested in the code entering the probe setup by common_probe_entry_prologue
+   and cleared by the common_probe_entry_epilogue code. When an early error
+   forces a goto probe_epilogue then needs an explicitly atomic_dec() first.
+   All context busy flags are tested on module unload to prevent unloading
+   while some probe is still running.  */
 atomic_t busy;
+
+/* The fully-resolved probe point associated with a currently running probe
+   handler, including alias and wild-card expansion effects.
+   aka stap_probe->pp.  Setup by common_probe_entryfn_prologue.
+   Used in warning/error messages and accessible by pp() tapset function.  */
 const char *probe_point;
-const char *probe_name; /* as per 'stap -l' */
+
+/* The script-level probe point associated with a currently running probe
+   handler, including  wild-card expansion effects as per 'stap -l'.
+   Guarded by STP_NEED_PROBE_NAME as setup in pn() tapset function.  */
+#ifdef STP_NEED_PROBE_NAME
+const char *probe_name;
+#endif
+
 int actionremaining;
 int nesting;
 string_t error_buffer;
index f04c1c5a29919eefbda319e1af0f79e17a66b4b0..dc3c3379d6f7435fad131d4c798dd6cdb845fe4e 100644 (file)
@@ -1,11 +1,15 @@
 // probe-name tapset
-// Copyright (C) 2010 Red Hat Inc.
+// Copyright (C) 2010, 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.
-
+%{
+#ifndef STP_NEED_PROBE_NAME
+#define STP_NEED_PROBE_NAME 1
+#endif
+%}
 
 /**
  * sfunction pn - Returns the active probe name
@@ -16,9 +20,6 @@
  */
 function pn:string ()
 %{ /* pure */ /* unprivileged */
-#ifndef STP_NEED_PROBE_NAME
-#define STP_NEED_PROBE_NAME 1
-#endif
        const char* name = CONTEXT->probe_name ?: CONTEXT->probe_point;
        strlcpy (THIS->__retvalue, name, MAXSTRINGLEN);
 %}
index 75b94ae39d9921599ca06e6cb4ec0a2c7d292ec7..7e9fbbf4abeee8fbaf9948c71fc6faf32b5d50af 100644 (file)
@@ -155,8 +155,6 @@ common_probe_entryfn_prologue (translator_output* o, string statestr,
   o->newline() << "c->probe_point = " << probe << "->pp;";
   o->newline() << "#ifdef STP_NEED_PROBE_NAME";
   o->newline() << "c->probe_name = " << probe << "->pn;";
-  o->newline() << "#else";
-  o->newline() << "c->probe_name = 0;";
   o->newline() << "#endif";
   // reset unwound address cache
   o->newline() << "c->pi = 0;";
@@ -242,7 +240,9 @@ common_probe_entryfn_epilogue (translator_output* o,
   o->newline() << "#endif";
 
   o->newline() << "c->probe_point = 0;"; // vacated
+  o->newline() << "#ifdef STP_NEED_PROBE_NAME";
   o->newline() << "c->probe_name = 0;";
+  o->newline() << "#endif";
   o->newline() << "if (unlikely (c->last_error && c->last_error[0])) {";
   o->newline(1) << "if (c->last_stmt != NULL)";
   o->newline(1) << "_stp_softerror (\"%s near %s\", c->last_error, c->last_stmt);";
This page took 0.050575 seconds and 5 git commands to generate.