summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-03-25 03:14:00 +0100
committerLennart Poettering <lennart@poettering.net>2009-03-25 03:14:00 +0100
commitf6a6d013546025806a0449ae51dde70de8baff57 (patch)
tree242b305301aa3b812306f2944b6c4513bb1da413
parent8460fac28583f96c039f94d42f1035c266f9a45f (diff)
optionally skip initial frames in backtrace
-rw-r--r--src/pulsecore/log.c27
-rw-r--r--src/pulsecore/log.h3
2 files changed, 23 insertions, 7 deletions
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index e1b67948..750d73b7 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -59,12 +59,13 @@
#define ENV_LOG_PRINT_META "PULSE_LOG_META"
#define ENV_LOG_PRINT_LEVEL "PULSE_LOG_LEVEL"
#define ENV_LOG_BACKTRACE "PULSE_LOG_BACKTRACE"
+#define ENV_LOG_BACKTRACE_SKIP "PULSE_LOG_BACKTRACE_SKIP"
static char *ident = NULL; /* in local charset format */
static pa_log_target_t target = PA_LOG_STDERR, target_override;
static pa_bool_t target_override_set = FALSE;
static pa_log_level_t maximum_level = PA_LOG_ERROR, maximum_level_override = PA_LOG_ERROR;
-static unsigned show_backtrace = 0, show_backtrace_override = 0;
+static unsigned show_backtrace = 0, show_backtrace_override = 0, skip_backtrace = 0;
static pa_log_flags_t flags = 0, flags_override = 0;
#ifdef HAVE_SYSLOG_H
@@ -128,13 +129,17 @@ void pa_log_set_show_backtrace(unsigned nlevels) {
show_backtrace = nlevels;
}
+void pa_log_set_skip_backtrace(unsigned nlevels) {
+ skip_backtrace = nlevels;
+}
+
#ifdef HAVE_EXECINFO_H
static char* get_backtrace(unsigned show_nframes) {
void* trace[32];
int n_frames;
char **symbols, *e, *r;
- unsigned j, n;
+ unsigned j, n, s;
size_t a;
pa_assert(show_nframes > 0);
@@ -149,12 +154,13 @@ static char* get_backtrace(unsigned show_nframes) {
if (!symbols)
return NULL;
- n = PA_MIN((unsigned) n_frames, show_nframes);
+ s = skip_backtrace;
+ n = PA_MIN((unsigned) n_frames, s + show_nframes);
a = 4;
- for (j = 0; j < n; j++) {
- if (j > 0)
+ for (j = s; j < n; j++) {
+ if (j > s)
a += 2;
a += strlen(pa_path_get_filename(symbols[j]));
}
@@ -164,10 +170,10 @@ static char* get_backtrace(unsigned show_nframes) {
strcpy(r, " (");
e = r + 2;
- for (j = 0; j < n; j++) {
+ for (j = s; j < n; j++) {
const char *sym;
- if (j > 0) {
+ if (j > s) {
strcpy(e, "<<");
e += 2;
}
@@ -229,6 +235,13 @@ static void init_defaults(void) {
if (show_backtrace_override <= 0)
show_backtrace_override = 0;
}
+
+ if ((e = getenv(ENV_LOG_BACKTRACE_SKIP))) {
+ skip_backtrace = (unsigned) atoi(e);
+
+ if (skip_backtrace <= 0)
+ skip_backtrace = 0;
+ }
}
void pa_log_levelv_meta(
diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h
index 153e11e8..8628bf40 100644
--- a/src/pulsecore/log.h
+++ b/src/pulsecore/log.h
@@ -77,6 +77,9 @@ void pa_log_set_flags(pa_log_flags_t flags, pa_log_merge_t merge);
/* Enable backtrace */
void pa_log_set_show_backtrace(unsigned nlevels);
+/* Skip the first backtrace frames */
+void pa_log_set_skip_backtrace(unsigned nlevels);
+
void pa_log_level_meta(
pa_log_level_t level,
const char*file,