Enabled only in debug mode and only when run under Valgrind.
Signed-off-by: Vittorio Giovara <[email protected]>
---
Updated to use a single CONFIG_ rather than a HAVE_ and a CONFIG_.
Vittorio
configure | 9 +++++++++
libavutil/log.c | 9 +++++++++
2 files changed, 18 insertions(+)
diff --git a/configure b/configure
index c1d673c..a15692a 100755
--- a/configure
+++ b/configure
@@ -315,6 +315,8 @@ Developer options (useful when working on Libav itself):
(group) and PROB the probability associated with
NAME (default 0.5).
--random-seed=VALUE seed value for --enable/disable-random
+ --disable-backtrace-printf when debug is enabled, do not print a backtrace
+ under Valgrind when an error is logged
NOTE: Object files are built at the place where configure is launched.
EOF
@@ -1242,6 +1244,7 @@ SUBSYSTEM_LIST="
"
CONFIG_LIST="
+ backtrace_printf
$COMPONENT_LIST
$EXAMPLE_LIST
$EXTERNAL_LIBRARY_LIST
@@ -3771,6 +3774,9 @@ enabled version3 && { enabled gpl && enable gplv3 ||
enable lgplv3; }
disabled optimizations || check_cflags -fomit-frame-pointer
+enabled debug && { disabled backtrace_printf ||
+ { check_func_headers valgrind/valgrind.h VALGRIND_PRINTF_BACKTRACE &&
enable backtrace_printf; } }
+
enable_weak_pic() {
disabled pic && return
enable pic
@@ -4629,6 +4635,9 @@ if enabled ppc; then
echo "dcbzl available ${dcbzl-no}"
fi
echo "debug symbols ${debug-no}"
+if enabled debug; then
+ echo "Valgrind backtrace ${backtrace_printf-no}"
+fi
echo "optimize for size ${small-no}"
echo "optimizations ${optimizations-no}"
echo "static ${static-no}"
diff --git a/libavutil/log.c b/libavutil/log.c
index d38e40b..ee0c105 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -40,6 +40,10 @@
#include "internal.h"
#include "log.h"
+#if CONFIG_BACKTRACE_PRINTF
+#include <valgrind/valgrind.h>
+#endif
+
static int av_log_level = AV_LOG_INFO;
static int flags;
@@ -161,6 +165,11 @@ void av_log_default_callback(void *avcl, int level, const
char *fmt, va_list vl)
}
colored_fputs(av_clip(level >> 3, 0, 6), tint >> 8, line);
av_strlcpy(prev, line, sizeof line);
+
+#if CONFIG_BACKTRACE_PRINTF
+ if (level <= AV_LOG_ERROR)
+ VALGRIND_PRINTF_BACKTRACE("");
+#endif
}
static void (*av_log_callback)(void*, int, const char*, va_list) =
--
1.9.3 (Apple Git-50)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel