summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authorfche <fche>2005-08-01 19:39:05 +0000
committerfche <fche>2005-08-01 19:39:05 +0000
commitfe3d01fa89a373b8f930689cf2375cc04cb57b74 (patch)
tree47be3fb3f9de03b6205b05828112fc9df969dbdb /translate.cxx
parentd8067b24c81ff89a28ece9c52ba35fe6136d35f2 (diff)
downloadsystemtap-steved-fe3d01fa89a373b8f930689cf2375cc04cb57b74.tar.gz
systemtap-steved-fe3d01fa89a373b8f930689cf2375cc04cb57b74.tar.xz
systemtap-steved-fe3d01fa89a373b8f930689cf2375cc04cb57b74.zip
2005-08-01 Frank Ch. Eigler <fche@elastic.org>
* elaborate.cxx (derive_probes, semantic_pass_symbols): Improve error message specificity. * translate.cxx (emit_module_init): Compact partial registration recovery code. (emit_module_exit): Invert deregistration sequence. * testsuite/buildok/four.stp: Some module() test case.
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx37
1 files changed, 19 insertions, 18 deletions
diff --git a/translate.cxx b/translate.cxx
index 78a75d91..85dfc925 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -633,15 +633,8 @@ c_unparser::emit_module_init ()
// We need to deregister any already probes set up - this is
// essential for kprobes.
if (i > 0)
- // NB: This may be an END probe. It may refuse to run
- // if the session_state was ERRORed
- for (unsigned j=i; j>0; j--)
- {
- o->newline() << "/* deregister " << j-1 << " */";
- session->probes[j-1]->emit_deregistrations (o, j-1);
- }
- // XXX: ignore rc
- o->newline() << "goto out;";
+ o->newline() << "goto unregister_" << (i-1) << ";";
+
o->newline(-1) << "}";
}
@@ -652,10 +645,22 @@ c_unparser::emit_module_init ()
o->newline() << "if (atomic_read (&session_state) == STAP_SESSION_STARTING)";
o->newline(1) << "atomic_set (&session_state, STAP_SESSION_RUNNING);";
// XXX: else maybe set anyrc and thus return a failure from module_init?
- o->indent(-1);
+ o->newline(-1) << "goto out;";
+
+ // recovery code for partially successful registration (rc != 0)
+ o->newline();
+ for (int i=session->probes.size()-2; i >= 0; i--) // NB: -2
+ {
+ o->newline(-1) << "unregister_" << i << ":";
+ o->indent(1);
+ session->probes[i]->emit_deregistrations (o, i);
+ // NB: This may be an END probe. It will refuse to run
+ // if the session_state was ERRORed.
+ }
+ o->newline();
- o->newline() << "out:";
- o->newline() << "return rc;";
+ o->newline(-1) << "out:";
+ o->newline(1) << "return rc;";
o->newline(-1) << "}" << endl;
}
@@ -688,15 +693,11 @@ c_unparser::emit_module_exit ()
// o->newline(-1) << "if (holdon) msleep (5);";
o->newline(-1) << "} while (holdon);";
o->newline(-1);
-
// XXX: might like to have an escape hatch, in case some probe is
// genuinely stuck
- for (unsigned i=0; i<session->probes.size(); i++)
- {
- o->newline() << "/* deregister " << i << " */";
- session->probes[i]->emit_deregistrations (o, i);
- }
+ for (int i=session->probes.size()-1; i>=0; i--)
+ session->probes[i]->emit_deregistrations (o, i);
for (unsigned i=0; i<session->globals.size(); i++)
{