diff options
author | dsmith <dsmith> | 2006-09-08 13:05:49 +0000 |
---|---|---|
committer | dsmith <dsmith> | 2006-09-08 13:05:49 +0000 |
commit | 46b84a80a83501d9a83856c255b74100be1717b9 (patch) | |
tree | 7121d1f95e6f23e15736b5a8511c9a745eee6bdf /translate.cxx | |
parent | 4b5f3e450724431c52c100143d859846f4009329 (diff) | |
download | systemtap-steved-46b84a80a83501d9a83856c255b74100be1717b9.tar.gz systemtap-steved-46b84a80a83501d9a83856c255b74100be1717b9.tar.xz systemtap-steved-46b84a80a83501d9a83856c255b74100be1717b9.zip |
2006-09-08 David Smith <dsmith@redhat.com>
* elaborate.h (struct derived_probe): Replace emit_registrations()
function with emit_registrations_start() and
emit_registrations_end().
(struct derived_probe_group): Added emit_module_init().
(struct derived_probe_group_container): Added emit_module_init(),
emit_module_init_call(), and emit_module_exit().
* elaborate.cxx (struct alias_derived_probe): Updated
emit_regitrations calls.
* translate.cxx (emit_module_init): Instead of actually emitting
per-probe-point registrations/unregistrations, let the session's
derived_probe_group_container do it.
* tapsets.cxx (emit_probe_timing): New function that handles
probe timing code.
(be_derived_probe::emit_registrations_start): Renamed from
emit_registrations.
(be_derived_probe_group::emit_module_init): New function that
outputs probes create and destroy functions.
(dwarf_derived_probe::emit_registrations): Removed, but most code
moved to emit_registrations_start().
(dwarf_derived_probe::emit_registrations_start): Handles details
of multiple dwarf probe registrations.
(dwarf_derived_probe::emit_registrations_end): Handles cleanup
details of multiple dwarf probe registrations.
(dwarf_derived_probe_group::emit_module_init): New function that
outputs probes create and destroy functions.
(timer_derived_probe::emit_registrations_start): Renamed from
emit_registrations. Added mutiple probe handling.
(timer_derived_probe::emit_registrations_end): Handles cleanup
details of multiple probe registrations.
(timer_derived_probe_group::emit_module_init): New function that
outputs probes create and destroy functions.
(profile_derived_probe::emit_registrations_start): Renamed from
emit_registrations. Added mutiple probe handling.
(profile_derived_probe::emit_registrations_end): Handles cleanup
details of multiple probe registrations.
(profile_derived_probe_group::emit_module_init): New function that
outputs probes create and destroy functions.
(mark_derived_probe::emit_registrations_start): Renamed from
emit_registrations. Added mutiple probe handling.
(mark_derived_probe::emit_registrations_end): Handles cleanup
details of multiple probe registrations.
(mark_derived_probe_group::emit_module_init): New function that
outputs probes create and destroy functions.
(hrtimer_derived_probe::emit_registrations_start): Renamed from
emit_registrations. Added mutiple probe handling.
(hrtimer_derived_probe::emit_registrations_end): Dummy function.
(hrtimer_derived_probe_group::emit_module_init): New function that
outputs probes create and destroy functions.
(derived_probe_group_container::emit_module_init): Added function
to call all probe group's emit_module_int functions.
(derived_probe_group_container::emit_module_init_call): Added
function to handle probe group initialization cleanup.
(derived_probe_group_container::emit_module_exit): Added
function to handle probe group cleanup.
Diffstat (limited to 'translate.cxx')
-rw-r--r-- | translate.cxx | 102 |
1 files changed, 3 insertions, 99 deletions
diff --git a/translate.cxx b/translate.cxx index e10ae3c6..da90e495 100644 --- a/translate.cxx +++ b/translate.cxx @@ -988,67 +988,7 @@ c_unparser::emit_functionsig (functiondecl* v) void c_unparser::emit_module_init () { - // Emit the per-probe-point registrations into individual functions, - // to avoid forcing the compiler to work too hard at optimizing such - // a silly function. A "don't optimize this function" pragma could - // come in handy too. - - set<string> basest_names; - for (unsigned i=0; i<session->probes.size(); i++) - { - o->newline() << "static noinline int register_probe_" << i << " (void) {"; - o->indent(1); - // By default, mark the first location as the site of possible - // registration failure. This is helpful since non-dwarf - // derived_probes tend to have only a single location. - assert (session->probes[i]->locations.size() > 0); - o->newline() << "int rc = 0;"; - o->newline() << "const char *probe_point = " << - lex_cast_qstring (*session->probes[i]->locations[0]) << ";"; - session->probes[i]->emit_registrations (o); - - o->newline() << "if (unlikely (rc)) {"; - // In case it's just a lower-layer (kprobes) error that set rc - // but not session_state, do that here to prevent any other BEGIN - // probe from attempting to run. - o->newline(1) << "atomic_set (&session_state, STAP_SESSION_ERROR);"; - - o->newline() << "_stp_error (\"probe " << i << " registration failed" - << ", rc=%d, %s\\n\", rc, probe_point);"; - o->newline(-1) << "}"; - - o->newline() << "return rc;"; - o->newline(-1) << "}"; - - o->newline(); - o->newline() << "noinline void unregister_probe_" << i << " (void) {"; - o->indent(1); - session->probes[i]->emit_deregistrations (o); - - string nm = session->probes[i]->basest()->name; - if (basest_names.find(nm) == basest_names.end()) - { - basest_names.insert (nm); - o->newline() << "#ifdef STP_TIMING"; - o->newline() << "{"; - o->newline(1) << "const char *probe_point = " - << lex_cast_qstring (*session->probes[i]->basest()->locations[0]) << ";"; - o->newline() << "const char *decl_location = " - << lex_cast_qstring (session->probes[i]->basest()->tok->location) << ";"; - o->newline() << "struct stat_data *stats = _stp_stat_get (time_" << session->probes[i]->basest()->name - << ", 0);"; - o->newline() << "const char *error;"; - o->newline() << "if (stats->count) {"; - o->newline(1) << "int64_t avg = _stp_div64 (&error, stats->sum, stats->count);"; - o->newline() << "_stp_printf (\"probe %s (%s), %lld hits taking %lldmin/%lldavg/%lldmax cycles.\\n\","; - o->newline() << "probe_point, decl_location, (long long) stats->count, (long long) stats->min, (long long) avg, (long long) stats->max);"; - o->newline() << "_stp_print_flush();"; - o->newline(-1) << "}"; - o->newline(-1) << "}"; - o->newline() << "#endif"; - } - o->newline(-1) << "}"; - } + session->probes.emit_module_init (o); o->newline(); o->newline() << "int systemtap_module_init (void) {"; @@ -1097,42 +1037,7 @@ c_unparser::emit_module_init () o->newline() << "#endif"; } - for (unsigned i=0; i<session->probes.size(); i++) - { - o->newline() << "rc = register_probe_" << i << "();"; - o->newline() << "if (rc)"; - o->indent(1); - // We need to deregister any already probes set up - this is - // essential for kprobes. - if (i > 0) - o->newline() << "goto unregister_" << (i-1) << ";"; - else - o->newline() << "goto out;"; - o->indent(-1); - } - - // BEGIN probes would have all been run by now. One of them may - // have triggered a STAP_SESSION_ERROR (which would incidentally - // block later BEGIN ones). If so, let that indication stay, and - // otherwise act like probe insertion was a success. - o->newline() << "if (atomic_read (&session_state) == STAP_SESSION_STARTING)"; - o->newline(1) << "atomic_set (&session_state, STAP_SESSION_RUNNING);"; - o->newline(-1) << "goto out;"; - - // Recovery code for partially successful registration (rc != 0) - // XXX: Do we need to delay here to ensure any triggered probes have - // terminated? Probably not much, as they should all test for - // SESSION_STARTING state right at the top and return. ("begin" - // probes don't count, as they return synchronously.) - o->newline(); - for (int i=session->probes.size()-2; i >= 0; i--) // NB: -2 - { - o->newline(-1) << "unregister_" << i << ":"; - o->newline(1) << "unregister_probe_" << i << "();"; - // NB: This may be an END probe. It will refuse to run - // if the session_state was ERRORed. - } - o->newline(); + session->probes.emit_module_init_call (o); // If any registrations failed, we will need to deregister the globals, // as this is our only chance. @@ -1187,8 +1092,7 @@ c_unparser::emit_module_exit () // XXX: might like to have an escape hatch, in case some probe is // genuinely stuck somehow - for (int i=session->probes.size()-1; i>=0; i--) - o->newline() << "unregister_probe_" << i << "();"; // NB: runs "end" probes + session->probes.emit_module_exit (o); // NB: runs "end" probes for (unsigned i=0; i<session->globals.size(); i++) { |