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;
// 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
*/
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);
%}
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;";
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);";