diff options
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | elaborate.h | 3 | ||||
-rw-r--r-- | tapsets.cxx | 4 | ||||
-rw-r--r-- | translate.cxx | 15 |
4 files changed, 39 insertions, 3 deletions
@@ -1,3 +1,23 @@ +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. + 2007-03-26 Frank Ch. Eigler <fche@elastic.org> * configure.ac: Bumped version to 0.5.14. diff --git a/elaborate.h b/elaborate.h index 8c3a6869..9ad3c038 100644 --- a/elaborate.h +++ b/elaborate.h @@ -125,6 +125,9 @@ public: static void emit_common_header (translator_output* o); // from c_unparser::emit_common_header // XXX: probably can move this stuff to a probe_group::emit_module_decls + + virtual bool needs_global_locks () { return true; } + // by default, probes need locks around global variables }; // ------------------------------------------------------------------------ diff --git a/tapsets.cxx b/tapsets.cxx index d05b548a..463cbf68 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -85,6 +85,10 @@ struct be_derived_probe: public derived_probe static inline bool comp(be_derived_probe const *a, be_derived_probe const *b) { return a->priority < b->priority; } + + bool needs_global_locks () { return false; } + // begin/end probes don't need locks around global variables, since + // they aren't run concurrently with any other probes }; 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"; } |