From: David Smith Date: Wed, 17 Oct 2012 14:52:13 +0000 (-0500) Subject: Fixed PR14735 by adding timing ('-t') mode support for dyninst. X-Git-Tag: release-2.1~350 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=f887a8c918fab5d52e6395126bfcfb2f0ebec364;p=systemtap.git Fixed PR14735 by adding timing ('-t') mode support for dyninst. * tapsets.cxx (common_probe_entryfn_prologue): Added dyninst support for timing ("-t") mode. Disable overload processing for dyninst mode. (common_probe_entryfn_epilogue): Change funcion signature. Add dyninst support for timing ("-t") mode. Disable overload processing for dyninst mode. (dwarf_derived_probe_group::emit_module_decls): Update common_probe_entryfn_epilogue() call. (uprobe_derived_probe_group::emit_module_utrace_decls): Ditto. (kprobe_derived_probe_group::emit_module_decls): Ditto. (hwbkpt_derived_probe_group::emit_module_decls): Ditto. (tracepoint_derived_probe_group::emit_module_decls): Ditto. * tapset-been.cxx (be_derived_probe_group::emit_module_decls): Ditto. * tapset-itrace.cxx (itrace_derived_probe_group::emit_module_decls): Ditto. * tapset-mark.cxx (mark_derived_probe_group::emit_module_decls): Ditto. * tapset-netfilter.cxx (netfilter_derived_probe_group::emit_module_decls): Ditto. * tapset-perfmon.cxx (perf_derived_probe_group::emit_module_decls): Ditto. * tapset-procfs.cxx (procfs_derived_probe_group::emit_module_decls): Ditto. * tapset-timers.cxx (timer_derived_probe_group::emit_module_decls): Ditto. (hrtimer_derived_probe_group::emit_module_decls): Ditto. (profile_derived_probe_group::emit_module_decls): Ditto. * tapset-utrace.cxx (utrace_derived_probe_group::emit_module_decls): Ditto. * runtime/dyninst/runtime.h: Added NSEC_PER_SEC and _stp_timespec_sub macros. Always include stat.c, as runtime/linux/runtime.h does. --- diff --git a/runtime/dyninst/runtime.h b/runtime/dyninst/runtime.h index 8733ba903..5ec5d6072 100644 --- a/runtime/dyninst/runtime.h +++ b/runtime/dyninst/runtime.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,20 @@ typedef uint64_t u64; #include "linux_types.h" +#ifndef NSEC_PER_SEC +#define NSEC_PER_SEC 1000000000L +#endif + +#define _stp_timespec_sub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \ + if ((result)->tv_nsec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_nsec += NSEC_PER_SEC; \ + } \ + } while (0) + #define simple_strtol strtol @@ -128,6 +143,7 @@ static inline void _stp_runtime_entryfn_epilogue(void) #include "sym.c" #include "perf.c" #include "addr-map.c" +#include "stat.c" #include "unwind.c" static int systemtap_module_init(void); diff --git a/tapset-been.cxx b/tapset-been.cxx index f6645fd17..81642fa54 100644 --- a/tapset-been.cxx +++ b/tapset-been.cxx @@ -142,7 +142,7 @@ be_derived_probe_group::emit_module_decls (systemtap_session& s) common_probe_entryfn_prologue (s, "stp->state", "stp->probe", "stp_probe_type_been", false); s.op->newline() << "(*stp->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, false, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, false); s.op->newline(-1) << "}"; } diff --git a/tapset-itrace.cxx b/tapset-itrace.cxx index 6cd56f09f..744e4c5b7 100644 --- a/tapset-itrace.cxx +++ b/tapset-itrace.cxx @@ -197,7 +197,7 @@ itrace_derived_probe_group::emit_module_decls (systemtap_session& s) // call probe function s.op->newline() << "(*p->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "return;"; s.op->newline(-1) << "}"; diff --git a/tapset-mark.cxx b/tapset-mark.cxx index b1411f184..e380ae58f 100644 --- a/tapset-mark.cxx +++ b/tapset-mark.cxx @@ -519,7 +519,7 @@ mark_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*smp->probe->ph) (c);"; s.op->newline() << "c->ips.kmark.mark_va_list = NULL;"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; return; diff --git a/tapset-netfilter.cxx b/tapset-netfilter.cxx index a1996a196..aa4df8b8b 100644 --- a/tapset-netfilter.cxx +++ b/tapset-netfilter.cxx @@ -314,7 +314,7 @@ netfilter_derived_probe_group::emit_module_decls (systemtap_session& s) // Invoke the probe handler s.op->newline() << "(*stp->ph) (c);"; - common_probe_entryfn_epilogue (s.op, false, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, false); if (np->context_vars.find("__nf_verdict") != np->context_vars.end()) s.op->newline() << "nf_verdict = (int) "+c_p+"." + s.up->c_localname("__nf_verdict") + ";"; diff --git a/tapset-perfmon.cxx b/tapset-perfmon.cxx index 61b73bec8..53f74dc4f 100644 --- a/tapset-perfmon.cxx +++ b/tapset-perfmon.cxx @@ -157,7 +157,7 @@ perf_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(-1) << "}"; s.op->newline() << "(*stp->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; } diff --git a/tapset-procfs.cxx b/tapset-procfs.cxx index 913caf15e..7e57c8484 100644 --- a/tapset-procfs.cxx +++ b/tapset-procfs.cxx @@ -274,7 +274,7 @@ procfs_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "spp->needs_fill = 0;"; s.op->newline() << "spp->count = strlen(spp->buffer);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "if (spp->needs_fill) {"; s.op->newline(1) << "spp->needs_fill = 0;"; @@ -332,7 +332,7 @@ procfs_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(1) << "retval = count;"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); } s.op->newline() << "return retval;"; diff --git a/tapset-timers.cxx b/tapset-timers.cxx index 15b84761e..74c601608 100644 --- a/tapset-timers.cxx +++ b/tapset-timers.cxx @@ -131,7 +131,7 @@ timer_derived_probe_group::emit_module_decls (systemtap_session& s) common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp->probe", "stp_probe_type_timer"); s.op->newline() << "(*stp->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; } @@ -279,7 +279,7 @@ hrtimer_derived_probe_group::emit_module_decls (systemtap_session& s) common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp->probe", "stp_probe_type_hrtimer"); s.op->newline() << "(*stp->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline() << "return rc;"; s.op->newline(-1) << "}"; @@ -301,7 +301,7 @@ hrtimer_derived_probe_group::emit_module_decls (systemtap_session& s) common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp->probe", "stp_probe_type_hrtimer"); s.op->newline() << "(*stp->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; } @@ -439,7 +439,7 @@ profile_derived_probe_group::emit_module_decls (systemtap_session& s) } s.op->newline() << "if (c->last_error == NULL) probe->ph (c);"; } - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline() << "#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)"; // == using_rpn of yore diff --git a/tapset-utrace.cxx b/tapset-utrace.cxx index 5d6ff1ba0..ac031e048 100644 --- a/tapset-utrace.cxx +++ b/tapset-utrace.cxx @@ -837,7 +837,7 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) // call probe function s.op->newline() << "(*p->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "return;"; s.op->newline(-1) << "}"; @@ -866,7 +866,7 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) // call probe function s.op->newline() << "(*p->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "if ((atomic_read (&session_state) != STAP_SESSION_STARTING) && (atomic_read (&session_state) != STAP_SESSION_RUNNING)) {"; s.op->indent(1); diff --git a/tapsets.cxx b/tapsets.cxx index 4d86726e5..c6977490f 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -92,15 +92,21 @@ common_probe_entryfn_prologue (systemtap_session& s, s.op->newline() << "unsigned long flags;"; s.op->newline() << "#endif"; - if (overload_processing) + s.op->newline() << "#ifdef STP_TIMING"; + s.op->newline() << "Stat stat = " << probe << "->timing;"; + s.op->newline() << "#endif"; + if (overload_processing && !s.runtime_usermode_p()) s.op->newline() << "#if defined(STP_TIMING) || defined(STP_OVERLOAD)"; else s.op->newline() << "#ifdef STP_TIMING"; - s.op->newline() << "cycles_t cycles_atstart = get_cycles ();"; - s.op->newline() << "#endif"; - s.op->newline() << "#ifdef STP_TIMING"; - s.op->newline() << "Stat stat = " << probe << "->timing;"; + if (! s.runtime_usermode_p()) + s.op->newline() << "cycles_t cycles_atstart = get_cycles ();"; + else + { + s.op->newline() << "struct timespec timespec_atstart;"; + s.op->newline() << "(void)clock_gettime(CLOCK_MONOTONIC_RAW, ×pec_atstart);"; + } s.op->newline() << "#endif"; s.op->newline() << "#if INTERRUPTIBLE"; @@ -198,39 +204,51 @@ common_probe_entryfn_prologue (systemtap_session& s, void -common_probe_entryfn_epilogue (translator_output* o, - bool overload_processing, - bool suppress_handler_errors) +common_probe_entryfn_epilogue (systemtap_session& s, + bool overload_processing) { - if (overload_processing) - o->newline() << "#if defined(STP_TIMING) || defined(STP_OVERLOAD)"; + if (overload_processing && !s.runtime_usermode_p()) + s.op->newline() << "#if defined(STP_TIMING) || defined(STP_OVERLOAD)"; else - o->newline() << "#ifdef STP_TIMING"; - o->newline() << "{"; - o->newline(1) << "cycles_t cycles_atend = get_cycles ();"; - // NB: we truncate cycles counts to 32 bits. Perhaps it should be - // fewer, if the hardware counter rolls over really quickly. We - // handle 32-bit wraparound here. - o->newline() << "int32_t cycles_elapsed = ((int32_t)cycles_atend > (int32_t)cycles_atstart)"; - o->newline(1) << "? ((int32_t)cycles_atend - (int32_t)cycles_atstart)"; - o->newline() << ": (~(int32_t)0) - (int32_t)cycles_atstart + (int32_t)cycles_atend + 1;"; - o->indent(-1); - - o->newline() << "#ifdef STP_TIMING"; - o->newline() << "if (likely (stat)) _stp_stat_add(stat, cycles_elapsed);"; - o->newline() << "#endif"; - - if (overload_processing) - { - o->newline() << "#ifdef STP_OVERLOAD"; - o->newline() << "{"; + s.op->newline() << "#ifdef STP_TIMING"; + s.op->newline() << "{"; + s.op->indent(1); + if (! s.runtime_usermode_p()) + { + s.op->newline() << "cycles_t cycles_atend = get_cycles ();"; + // NB: we truncate cycles counts to 32 bits. Perhaps it should be + // fewer, if the hardware counter rolls over really quickly. We + // handle 32-bit wraparound here. + s.op->newline() << "int32_t cycles_elapsed = ((int32_t)cycles_atend > (int32_t)cycles_atstart)"; + s.op->newline(1) << "? ((int32_t)cycles_atend - (int32_t)cycles_atstart)"; + s.op->newline() << ": (~(int32_t)0) - (int32_t)cycles_atstart + (int32_t)cycles_atend + 1;"; + s.op->indent(-1); + } + else + { + s.op->newline() << "struct timespec timespec_atend, timespec_elapsed;"; + s.op->newline() << "long cycles_elapsed;"; + s.op->newline() << "(void)clock_gettime(CLOCK_MONOTONIC_RAW, ×pec_atend);"; + s.op->newline() << "_stp_timespec_sub(×pec_atend, ×pec_atstart, ×pec_elapsed);"; + // 'cycles_elapsed' is really elapsed nanoseconds + s.op->newline() << "cycles_elapsed = (timespec_elapsed.tv_sec * NSEC_PER_SEC) + timespec_elapsed.tv_nsec;"; + } + + s.op->newline() << "#ifdef STP_TIMING"; + s.op->newline() << "if (likely (stat)) _stp_stat_add(stat, cycles_elapsed);"; + s.op->newline() << "#endif"; + + if (overload_processing && !s.runtime_usermode_p()) + { + s.op->newline() << "#ifdef STP_OVERLOAD"; + s.op->newline() << "{"; // If the cycle count has wrapped (cycles_atend > cycles_base), // let's go ahead and pretend the interval has been reached. // This should reset cycles_base and cycles_sum. - o->newline(1) << "cycles_t interval = (cycles_atend > c->cycles_base)"; - o->newline(1) << "? (cycles_atend - c->cycles_base)"; - o->newline() << ": (STP_OVERLOAD_INTERVAL + 1);"; - o->newline(-1) << "c->cycles_sum += cycles_elapsed;"; + s.op->newline(1) << "cycles_t interval = (cycles_atend > c->cycles_base)"; + s.op->newline(1) << "? (cycles_atend - c->cycles_base)"; + s.op->newline() << ": (STP_OVERLOAD_INTERVAL + 1);"; + s.op->newline(-1) << "c->cycles_sum += cycles_elapsed;"; // If we've spent more than STP_OVERLOAD_THRESHOLD cycles in a // probe during the last STP_OVERLOAD_INTERVAL cycles, the probe @@ -238,75 +256,75 @@ common_probe_entryfn_epilogue (translator_output* o, // NB: this is not suppressible via --suppress-runtime-errors, // because this is a system safety metric that we cannot trust // unprivileged users to override. - o->newline() << "if (interval > STP_OVERLOAD_INTERVAL) {"; - o->newline(1) << "if (c->cycles_sum > STP_OVERLOAD_THRESHOLD) {"; - o->newline(1) << "_stp_error (\"probe overhead exceeded threshold\");"; - o->newline() << "atomic_set (&session_state, STAP_SESSION_ERROR);"; - o->newline() << "atomic_inc (&error_count);"; - o->newline(-1) << "}"; - - o->newline() << "c->cycles_base = cycles_atend;"; - o->newline() << "c->cycles_sum = 0;"; - o->newline(-1) << "}"; - o->newline(-1) << "}"; - o->newline() << "#endif"; + s.op->newline() << "if (interval > STP_OVERLOAD_INTERVAL) {"; + s.op->newline(1) << "if (c->cycles_sum > STP_OVERLOAD_THRESHOLD) {"; + s.op->newline(1) << "_stp_error (\"probe overhead exceeded threshold\");"; + s.op->newline() << "atomic_set (&session_state, STAP_SESSION_ERROR);"; + s.op->newline() << "atomic_inc (&error_count);"; + s.op->newline(-1) << "}"; + + s.op->newline() << "c->cycles_base = cycles_atend;"; + s.op->newline() << "c->cycles_sum = 0;"; + s.op->newline(-1) << "}"; + s.op->newline(-1) << "}"; + s.op->newline() << "#endif"; } - o->newline(-1) << "}"; - o->newline() << "#endif"; + s.op->newline(-1) << "}"; + s.op->newline() << "#endif"; - o->newline() << "c->probe_point = 0;"; // vacated - o->newline() << "#ifdef STP_NEED_PROBE_NAME"; - o->newline() << "c->probe_name = 0;"; - o->newline() << "#endif"; - o->newline() << "c->probe_type = 0;"; + s.op->newline() << "c->probe_point = 0;"; // vacated + s.op->newline() << "#ifdef STP_NEED_PROBE_NAME"; + s.op->newline() << "c->probe_name = 0;"; + s.op->newline() << "#endif"; + s.op->newline() << "c->probe_type = 0;"; - o->newline() << "if (unlikely (c->last_error && c->last_error[0])) {"; - o->indent(1); - if (suppress_handler_errors) // PR 13306 + s.op->newline() << "if (unlikely (c->last_error && c->last_error[0])) {"; + s.op->indent(1); + if (s.suppress_handler_errors) // PR 13306 { - o->newline() << "atomic_inc (& error_count);"; + s.op->newline() << "atomic_inc (& error_count);"; } else { - o->newline() << "if (c->last_stmt != NULL)"; - o->newline(1) << "_stp_softerror (\"%s near %s\", c->last_error, c->last_stmt);"; - o->newline(-1) << "else"; - o->newline(1) << "_stp_softerror (\"%s\", c->last_error);"; - o->indent(-1); - o->newline() << "atomic_inc (& error_count);"; - o->newline() << "if (atomic_read (& error_count) > MAXERRORS) {"; - o->newline(1) << "atomic_set (& session_state, STAP_SESSION_ERROR);"; - o->newline() << "_stp_exit ();"; - o->newline(-1) << "}"; + s.op->newline() << "if (c->last_stmt != NULL)"; + s.op->newline(1) << "_stp_softerror (\"%s near %s\", c->last_error, c->last_stmt);"; + s.op->newline(-1) << "else"; + s.op->newline(1) << "_stp_softerror (\"%s\", c->last_error);"; + s.op->indent(-1); + s.op->newline() << "atomic_inc (& error_count);"; + s.op->newline() << "if (atomic_read (& error_count) > MAXERRORS) {"; + s.op->newline(1) << "atomic_set (& session_state, STAP_SESSION_ERROR);"; + s.op->newline() << "_stp_exit ();"; + s.op->newline(-1) << "}"; } - o->newline(-1) << "}"; + s.op->newline(-1) << "}"; - o->newline() << "_stp_runtime_entryfn_epilogue();"; - o->newline() << "atomic_dec (&c->busy);"; + s.op->newline() << "_stp_runtime_entryfn_epilogue();"; + s.op->newline() << "atomic_dec (&c->busy);"; - o->newline(-1) << "probe_epilogue:"; // context is free - o->indent(1); + s.op->newline(-1) << "probe_epilogue:"; // context is free + s.op->indent(1); - if (! suppress_handler_errors) // PR 13306 + if (! s.suppress_handler_errors) // PR 13306 { // Check for excessive skip counts. - o->newline() << "if (unlikely (atomic_read (& skipped_count) > MAXSKIPPED)) {"; - o->newline(1) << "if (unlikely (pseudo_atomic_cmpxchg(& session_state, STAP_SESSION_RUNNING, STAP_SESSION_ERROR) == STAP_SESSION_RUNNING))"; - o->newline() << "_stp_error (\"Skipped too many probes, check MAXSKIPPED or try again with stap -t for more details.\");"; - o->newline(-1) << "}"; + s.op->newline() << "if (unlikely (atomic_read (& skipped_count) > MAXSKIPPED)) {"; + s.op->newline(1) << "if (unlikely (pseudo_atomic_cmpxchg(& session_state, STAP_SESSION_RUNNING, STAP_SESSION_ERROR) == STAP_SESSION_RUNNING))"; + s.op->newline() << "_stp_error (\"Skipped too many probes, check MAXSKIPPED or try again with stap -t for more details.\");"; + s.op->newline(-1) << "}"; } - o->newline() << "#if INTERRUPTIBLE"; - o->newline() << "preempt_enable_no_resched ();"; - o->newline() << "#else"; - o->newline() << "local_irq_restore (flags);"; - o->newline() << "#endif"; + s.op->newline() << "#if INTERRUPTIBLE"; + s.op->newline() << "preempt_enable_no_resched ();"; + s.op->newline() << "#else"; + s.op->newline() << "local_irq_restore (flags);"; + s.op->newline() << "#endif"; - o->newline() << "#endif // STP_ALIBI"; + s.op->newline() << "#endif // STP_ALIBI"; } @@ -4845,7 +4863,7 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "SET_REG_IP(regs, kprobes_ip);"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "return 0;"; s.op->newline(-1) << "}"; @@ -4888,7 +4906,7 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "SET_REG_IP(regs, kprobes_ip);"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline() << "return 0;"; s.op->newline(-1) << "}"; @@ -7421,7 +7439,7 @@ uprobe_derived_probe_group::emit_module_utrace_decls (systemtap_session& s) s.op->newline() << "SET_REG_IP(regs, uprobes_ip);"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline() << "static void enter_uretprobe_probe (struct uretprobe_instance *inst, struct pt_regs *regs) {"; @@ -7452,7 +7470,7 @@ uprobe_derived_probe_group::emit_module_utrace_decls (systemtap_session& s) s.op->newline() << "SET_REG_IP(regs, uprobes_ip);"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline(); @@ -7597,7 +7615,7 @@ uprobe_derived_probe_group::emit_module_inode_decls (systemtap_session& s) s.op->newline() << "SET_REG_IP(regs, uprobes_ip);"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "return 0;"; s.op->newline(-1) << "}"; s.op->assert_0_indent(); @@ -7770,7 +7788,7 @@ uprobe_derived_probe_group::emit_module_dyninst_decls (systemtap_session& s) // XXX: the way that dyninst rewrites stuff is probably going to be // ... very confusing to our backtracer (at least if we stay in process) s.op->newline() << "(*sup->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "return 0;"; s.op->newline(-1) << "}"; s.op->assert_0_indent(); @@ -8146,7 +8164,7 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "SET_REG_IP(regs, kprobes_ip);"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "return 0;"; s.op->newline(-1) << "}"; @@ -8181,7 +8199,7 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "SET_REG_IP(regs, kprobes_ip);"; s.op->newline(-1) << "}"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline() << "return 0;"; s.op->newline(-1) << "}"; @@ -8780,7 +8798,7 @@ hwbkpt_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(1) << "c->kregs = regs;"; s.op->newline(-1) << "}"; s.op->newline() << "(*sdp->probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; s.op->newline() << "return 0;"; @@ -9544,7 +9562,7 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s) << " = __tracepoint_arg_" << used_args[j]->name << ";"; } s.op->newline() << "(*probe->ph) (c);"; - common_probe_entryfn_epilogue (s.op, true, s.suppress_handler_errors); + common_probe_entryfn_epilogue (s, true); s.op->newline(-1) << "}"; // define the real tracepoint callback function diff --git a/tapsets.h b/tapsets.h index de433b11e..db00259db 100644 --- a/tapsets.h +++ b/tapsets.h @@ -21,7 +21,8 @@ std::string common_probe_init (derived_probe* p); void common_probe_entryfn_prologue (systemtap_session& s, std::string statestr, std::string probe, std::string probe_type, bool overload_processing = true); -void common_probe_entryfn_epilogue (translator_output* o, bool overload_processing, bool suppress_handler_errors); +void common_probe_entryfn_epilogue (systemtap_session& s, + bool overload_processing); void register_tapset_been(systemtap_session& sess); void register_tapset_itrace(systemtap_session& sess); diff --git a/translate.cxx b/translate.cxx index 50cc64047..0bf50ede3 100644 --- a/translate.cxx +++ b/translate.cxx @@ -1114,9 +1114,6 @@ c_unparser::emit_common_header () emit_map_type_instantiations (); - if (!session->stat_decls.empty()) - o->newline() << "#include \"stat.c\"\n"; - o->newline() << "#ifdef STAP_NEED_GETTIMEOFDAY"; o->newline() << "#include \"time.c\""; // Don't we all need more? o->newline() << "#endif"; @@ -1964,7 +1961,9 @@ c_unparser::emit_module_exit () o->newline(1) << "struct stat_data *stats = _stp_stat_get (p->timing, 0);"; o->newline() << "if (stats->count) {"; o->newline(1) << "int64_t avg = _stp_div64 (NULL, stats->sum, stats->count);"; - o->newline() << "_stp_printf (\"%s, (%s), hits: %lld, cycles: %lldmin/%lldavg/%lldmax,%s\\n\","; + o->newline() << "_stp_printf (\"%s, (%s), hits: %lld, " + << (!session->runtime_usermode_p() ? "cycles" : "nsecs") + << ": %lldmin/%lldavg/%lldmax,%s\\n\","; o->newline(2) << "p->pp, p->location, (long long) stats->count,"; o->newline() << "(long long) stats->min, (long long) avg, (long long) stats->max,"; o->newline() << "p->derivation);";