[ovs-dev] [PATCH 2/3] timeval: Coalesce backtraces with counts.
Ethan Jackson
ethan at nicira.com
Thu Oct 25 17:06:26 UTC 2012
Making stubs turned out to be cleanest. Here's an incremental.
---
lib/timeval.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/lib/timeval.c b/lib/timeval.c
index bd2a84d..b36203a 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -39,10 +39,6 @@
#include "util.h"
#include "vlog.h"
-#ifndef HAVE_EXECINFO_H
-#define HAVE_EXECINFO_H 0
-#endif
-
VLOG_DEFINE_THIS_MODULE(timeval);
/* The clock to use for measuring time intervals. This is CLOCK_MONOTONIC by
@@ -98,6 +94,22 @@ static void timespec_add(struct timespec *sum,
const struct timespec *a, const struct timespec *b);
static unixctl_cb_func backtrace_cb;
+#ifndef HAVE_EXECINFO_H
+#define HAVE_EXECINFO_H 0
+
+static int
+backtrace(void **buffer OVS_UNUSED, int size OVS_UNUSED)
+{
+ NOT_REACHED();
+}
+
+static char **
+backtrace_symbols(void *const *buffer OVS_UNUSED, int size OVS_UNUSED)
+{
+ NOT_REACHED();
+}
+#endif
+
/* Initializes the timetracking module, if not already initialized. */
static void
time_init(void)
@@ -398,15 +410,13 @@ sigalrm_handler(int sig_nr OVS_UNUSED)
wall_tick = true;
monotonic_tick = true;
-#if HAVE_EXECINFO_H
- if (CACHE_TIME) {
+ if (HAVE_EXECINFO_H && CACHE_TIME) {
struct trace *trace = &traces[trace_head];
trace->n_frames = backtrace(trace->backtrace,
ARRAY_SIZE(trace->backtrace));
trace_head = (trace_head + 1) % MAX_TRACES;
}
-#endif
}
static void
@@ -611,8 +621,7 @@ format_backtraces(struct ds *ds)
{
time_init();
-#if HAVE_EXECINFO_H
- if (CACHE_TIME) {
+ if (HAVE_EXECINFO_H && CACHE_TIME) {
struct hmap trace_map = HMAP_INITIALIZER(&trace_map);
struct trace *trace, *next;
sigset_t oldsigs;
@@ -658,7 +667,6 @@ format_backtraces(struct ds *ds)
ds_chomp(ds, '\n');
unblock_sigalrm(&oldsigs);
}
-#endif
}
/* Unixctl interface. */
--
1.7.9.5
More information about the dev
mailing list