Useful to understand where and in what execution state a certain message is generated. It is enabled only when optimizations are disabled, since function names are not print otherwise. It is possible to disable this feature entirely or choose the log level between error and warning.
Signed-off-by: Vittorio Giovara <[email protected]> --- Updated to include all comments received on list and or irc. Vittorio configure | 19 ++++++++++++++++++- libavutil/log.c | 9 +++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 0e182b4..078eca5 100755 --- a/configure +++ b/configure @@ -269,6 +269,9 @@ Advanced options (experts only): (faster, but may crash) --enable-memalign-hack emulate memalign, interferes with memory debuggers --enable-sram allow use of on-chip SRAM + --disable-valgrind-backtrace do not print a backtrace under Valgrind + --backtrace-loglevel=LEVEL set log level when printing a log backtrace under + Valgrind [error] (error/warning/none) Optimization options (experts only): --disable-asm disable all assembly optimizations @@ -1616,6 +1619,7 @@ CMDLINE_SELECT=" $HAVE_LIST_CMDLINE $THREADS_LIST asm + valgrind_backtrace cross_compile debug extra_warnings @@ -1641,6 +1645,7 @@ CMDLINE_SET=" ar arch as + backtrace_loglevel build_suffix cc cpu @@ -2215,7 +2220,7 @@ pod2man_deps="doc" texi2html_deps="doc" # default parameters - +backtrace_loglevel="error" logfile="config.log" # installation paths @@ -3774,6 +3779,9 @@ die_license_disabled version3 libvo_amrwbenc enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; } disabled optimizations || check_cflags -fomit-frame-pointer +disabled optimizations || + { check_func_headers valgrind/valgrind.h VALGRIND_PRINTF_BACKTRACE && + enable_weak valgrind_backtrace; } enable_weak_pic() { disabled pic && return @@ -4819,6 +4827,15 @@ EOF test -n "$malloc_prefix" && echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH +if enabled valgrind_backtrace; then + case $backtrace_loglevel in + "error") backtrace_loglevel=AV_LOG_ERROR ;; + "warning") backtrace_loglevel=AV_LOG_WARNING;; + *) backtrace_loglevel=AV_LOG_QUIET ;; + esac + echo "#define BACKTRACE_LOGLEVEL $backtrace_loglevel" >>$TMPH +fi + if enabled yasm; then append config_files $TMPASM printf '' >$TMPASM diff --git a/libavutil/log.c b/libavutil/log.c index d38e40b..a92d0d0 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -40,6 +40,10 @@ #include "internal.h" #include "log.h" +#ifdef BACKTRACE_LOGLEVEL +#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); + +#ifdef BACKTRACE_LOGLEVEL + if (level <= BACKTRACE_LOGLEVEL) + 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
