summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authordsmith <dsmith>2007-03-28 20:11:37 +0000
committerdsmith <dsmith>2007-03-28 20:11:37 +0000
commit90f98cc36060df795f79379e512d151d0e7c74a4 (patch)
tree937617c7cb901d5d7e75364400425d5ec7304ec6 /translate.cxx
parentdba81c1410b8905ddcdeaac0a7af7badac74b341 (diff)
downloadsystemtap-steved-90f98cc36060df795f79379e512d151d0e7c74a4.tar.gz
systemtap-steved-90f98cc36060df795f79379e512d151d0e7c74a4.tar.xz
systemtap-steved-90f98cc36060df795f79379e512d151d0e7c74a4.zip
2007-03-28 David Smith <dsmith@redhat.com>
PR 2341 (partial fix) * elaborate.h (struct derived_probe): Added needs_global_locks() member function. Unless overridden, will return true indicating that this probe needs locks around global variable references. * tapsets.cxx (struct be_derived_probe): Added override of default needs_global_locks() returning false. begin/end probes don't need locks around global variables, since they aren't run concurrently with any other probes. * translate.cxx (c_unparser::emit_common_header): Updated probe_contents logic to match the logic in emit_probe. (c_unparser::emit_probe): Added whether the probe needs global variable locks to the probe string (that helps eliminate duplicate probes). The generated C changes based on whether or not global variable locks are needed, but the pass 2 output doesn't differ between a probe that needs global variable locks and one that doesn't. If the probe doesn't need global variable locks, doesn't output them.
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/translate.cxx b/translate.cxx
index e656c5ee..b7c21032 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -845,6 +845,7 @@ c_unparser::emit_common_header ()
ostringstream oss;
oss << "c->statp = & time_" << dp->basest()->name << ";" << endl; // -t anti-dupe
dp->body->print(oss);
+ oss << "# needs_global_locks: " << dp->needs_global_locks () << endl;
if (tmp_probe_contents.count(oss.str()) == 0) // unique
{
@@ -1357,6 +1358,10 @@ c_unparser::emit_probe (derived_probe* v)
v->body->print(oss);
+ // Since the generated C changes based on whether or not the probe
+ // needs locks around global variables, this needs to be reflected
+ // in the probe string.
+ oss << "# needs_global_locks: " << v->needs_global_locks () << endl;
// If an identical probe has already been emitted, just call that
// one.
@@ -1415,8 +1420,11 @@ c_unparser::emit_probe (derived_probe* v)
// emit all read/write locks for global variables
varuse_collecting_visitor vut;
- v->body->visit (& vut);
- emit_locks (vut);
+ if (v->needs_global_locks ())
+ {
+ v->body->visit (& vut);
+ emit_locks (vut);
+ }
// initialize locals
for (unsigned j=0; j<v->locals.size(); j++)
@@ -1443,7 +1451,8 @@ c_unparser::emit_probe (derived_probe* v)
// included a print/printf/etc. routine!
o->newline(1) << "_stp_print_flush();";
- emit_unlocks (vut);
+ if (v->needs_global_locks ())
+ emit_unlocks (vut);
o->newline(-1) << "}\n";
}