]> sourceware.org Git - systemtap.git/commitdiff
Fixed PR14735 by adding timing ('-t') mode support for dyninst.
authorDavid Smith <dsmith@redhat.com>
Wed, 17 Oct 2012 14:52:13 +0000 (09:52 -0500)
committerDavid Smith <dsmith@redhat.com>
Wed, 17 Oct 2012 14:52:13 +0000 (09:52 -0500)
* 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.

12 files changed:
runtime/dyninst/runtime.h
tapset-been.cxx
tapset-itrace.cxx
tapset-mark.cxx
tapset-netfilter.cxx
tapset-perfmon.cxx
tapset-procfs.cxx
tapset-timers.cxx
tapset-utrace.cxx
tapsets.cxx
tapsets.h
translate.cxx

index 8733ba903c6a9896ee00c202a599964e98bb5d49..5ec5d6072c4a51161aa4eed7b6560151c92cd00e 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/ptrace.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <fcntl.h>
 #include <stddef.h>
 #include <unistd.h>
@@ -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);
index f6645fd1788b58e10b35a312b1ed136d528de07f..81642fa541f95b20eb9890b46b47497e48f38596 100644 (file)
@@ -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) << "}";
 }
 
index 6cd56f09f95a25f2e4a42e15b05ce8792a11ba75..744e4c5b7872026d2d8481fad93d3fe7ed7b82ad 100644 (file)
@@ -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) << "}";
index b1411f1849adba1ec7492fb62f8298b866dde834..e380ae58f8a1284ff94603567ae052cbdef5cf31 100644 (file)
@@ -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;
index a1996a196afacf0d1a2475131fb5e7a23d143c9e..aa4df8b8bc3d13b54c0f13ee67c6c459f11c40a7 100644 (file)
@@ -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") + ";";
index 61b73bec8818df192f03410bd5846b49610b6de2..53f74dc4faf91c41cb745845905030ebd9db3c63 100644 (file)
@@ -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) << "}";
 }
 
index 913caf15eb6ca991521cbc1efc1dba1827d613b7..7e57c8484e36aa3172daa4bb907504f45ba2b1bf 100644 (file)
@@ -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;";
index 15b84761e3cc2a47538a44f51ee596288240f038..74c6016089accaffe96739d80922aa88a1e04de3 100644 (file)
@@ -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
index 5d6ff1ba0ca1cb8aca347a76699736d4d83dc4af..ac031e048531fdde579e6bbba25b7c06b501b36f 100644 (file)
@@ -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);
index 4d86726e5fe750390e5050c2a1738d8cdf3690b2..c6977490f18b5664dcfec3a083f6c90ff2baf9f7 100644 (file)
@@ -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, &timespec_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, &timespec_atend);";
+      s.op->newline() << "_stp_timespec_sub(&timespec_atend, &timespec_atstart, &timespec_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
index de433b11e953e178a8007d7298a13de74f2bd05f..db00259db8559dc36360d228c463bd0f41a1cd30 100644 (file)
--- 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);
index 50cc64047993d36aef815cdbaf9a269ff1ed25e6..0bf50ede3015e71d1f0d66925f1fcb9b05a59da3 100644 (file)
@@ -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);";
This page took 0.058555 seconds and 5 git commands to generate.