From 2cec19d9d0716f8d68f1c5a87667d0387d4d252d Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Sun, 16 Aug 2009 19:24:21 +0200 Subject: perf tools: Factorize the dprintf definition We have two users of dprintf: report and annotate. Another one is coming with perf trace. Then factorize it into the debug file. While at it, rename dprintf() to dump_printf() so that it doesn't conflicts with its libc homograph. Signed-off-by: Frederic Weisbecker Cc: Frederic Weisbecker Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: Mike Galbraith LKML-Reference: <1250443461-28130-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar --- tools/perf/util/debug.c | 15 +++++++++++++++ tools/perf/util/debug.h | 2 ++ 2 files changed, 17 insertions(+) (limited to 'tools/perf/util') diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 7cb8464abe61..8318fdee4778 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -6,6 +6,7 @@ #include int verbose = 0; +int dump_trace = 0; int eprintf(const char *fmt, ...) { @@ -20,3 +21,17 @@ int eprintf(const char *fmt, ...) return ret; } + +int dump_printf(const char *fmt, ...) +{ + va_list args; + int ret = 0; + + if (dump_trace) { + va_start(args, fmt); + ret = vprintf(fmt, args); + va_end(args); + } + + return ret; +} diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 2ae9090108d3..a683bd571f1c 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -1,5 +1,7 @@ /* For debugging general purposes */ extern int verbose; +extern int dump_trace; int eprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); +int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); -- cgit v1.2.3