From d9582a605fc7710279b3504a7d6b37e8ee943c2a Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 20 Nov 2008 16:20:13 -0500 Subject: PR5689 part 1: per-global-variable skip tracking --- ChangeLog | 6 ++++++ translate.cxx | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d248018c..cf4f4611 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-20 Frank Ch. Eigler + + PR 5689 + * translate.cxx (emit_global, emit_global_init, emit_module_exit, + emit_locks): Track & print global.s_VAR_lock_skip_count. + 2008-11-20 Frank Ch. Eigler * main.cxx (main): Correct thinko in --vp option with <5 arg chars. diff --git a/translate.cxx b/translate.cxx index 741455e0..0d4cc266 100644 --- a/translate.cxx +++ b/translate.cxx @@ -1043,6 +1043,9 @@ c_unparser::emit_global (vardecl *v) else o->newline() << "MAP s_" << vn << ";"; o->newline() << "rwlock_t s_" << vn << "_lock;"; + o->newline() << "#ifdef STP_TIMING"; + o->newline() << "atomic_t s_" << vn << "_lock_skip_count;"; + o->newline() << "#endif" << endl; } @@ -1055,11 +1058,14 @@ c_unparser::emit_global_init (vardecl *v) { if (v->init) { - o->line() << ".s_" << vn << " = "; + o->newline() << ".s_" << vn << " = "; v->init->visit(this); o->line() << ","; } } + o->newline() << "#ifdef STP_TIMING"; + o->newline() << ".s_" << vn << "_lock_skip_count = ATOMIC_INIT(0),"; + o->newline() << "#endif"; } @@ -1332,6 +1338,18 @@ c_unparser::emit_module_exit () << "skipped probes: %d\\n\", " << "(int) atomic_read (& error_count), " << "(int) atomic_read (& skipped_count));"; + o->newline() << "#ifdef STP_TIMING"; + o->newline() << "{"; + o->newline(1) << "int ctr;"; + for (unsigned i=0; iglobals.size(); i++) + { + string vn = c_varname (session->globals[i]->name); + o->newline() << "ctr = atomic_read (& global.s_" << vn << "_lock_skip_count);"; + o->newline() << "if (ctr) _stp_warn (\"Variable `%s' lock timeouts: %d\\n\", " + << lex_cast_qstring(vn) << ", ctr);"; + } + o->newline(-1) << "}"; + o->newline () << "#endif"; o->newline() << "_stp_print_flush();"; o->newline(-1) << "}"; o->newline(-1) << "}\n"; @@ -1625,6 +1643,9 @@ c_unparser::emit_locks(const varuse_collecting_visitor& vut) o->newline(1) << "ndelay (TRYLOCKDELAY);"; o->newline(-1) << "if (unlikely (numtrylock >= MAXTRYLOCK)) {"; o->newline(1) << "atomic_inc (& skipped_count);"; + o->newline() << "#ifdef STP_TIMING"; + o->newline() << "atomic_inc (& global.s_" << c_varname (v->name) << "_lock_skip_count);"; + o->newline() << "#endif"; // The following works even if i==0. Note that using // globals[i-1]->name is wrong since that global may not have // been lockworthy by this probe. -- cgit