linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 06/10] perf tools: Initialize libapi debug output
Date: Tue, 16 Feb 2016 17:34:52 -0300	[thread overview]
Message-ID: <1455654896-14205-7-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1455654896-14205-1-git-send-email-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

Setting libapi debug output functions to use perf functions.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1455465826-8426-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf.c       |  2 ++
 tools/perf/util/debug.c | 21 +++++++++++++++++++++
 tools/perf/util/debug.h |  1 +
 3 files changed, 24 insertions(+)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index a929618b8eb6..144047c396f0 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -613,6 +613,8 @@ int main(int argc, const char **argv)
 	 */
 	pthread__block_sigwinch();
 
+	perf_debug_setup();
+
 	while (1) {
 		static int done_help;
 		int was_alias = run_argv(&argc, &argv);
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index d6c8d2b2cd70..ff7e86ad1b06 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <api/debug.h>
 
 #include "cache.h"
 #include "color.h"
@@ -187,3 +188,23 @@ int perf_debug_option(const char *str)
 	free(s);
 	return 0;
 }
+
+#define DEBUG_WRAPPER(__n, __l)				\
+static int pr_ ## __n ## _wrapper(const char *fmt, ...)	\
+{							\
+	va_list args;					\
+	int ret;					\
+							\
+	va_start(args, fmt);				\
+	ret = veprintf(__l, verbose, fmt, args);	\
+	va_end(args);					\
+	return ret;					\
+}
+
+DEBUG_WRAPPER(warning, 0);
+DEBUG_WRAPPER(debug, 1);
+
+void perf_debug_setup(void)
+{
+	libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper);
+}
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 8b9a088c32ab..14bafda79eda 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -53,5 +53,6 @@ int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __attribute__(
 int veprintf(int level, int var, const char *fmt, va_list args);
 
 int perf_debug_option(const char *str);
+void perf_debug_setup(void);
 
 #endif	/* __PERF_DEBUG_H */
-- 
2.5.0

  parent reply	other threads:[~2016-02-16 20:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 20:34 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 01/10] perf jvmti: Add check for java alternatives cmd in Makefile Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 02/10] tools lib api: Add debug output support Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 03/10] tools lib api fs: Adopt filename__read_str from perf Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 04/10] tools lib api fs: Add sysfs__read_str function Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 05/10] perf debug: Rename __eprintf(va_list args) to veprintf Arnaldo Carvalho de Melo
2016-02-16 20:34 ` Arnaldo Carvalho de Melo [this message]
2016-02-16 20:34 ` [PATCH 07/10] perf tools: Add perf data cache feature Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 08/10] perf stat: Abstract stat metrics printing Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 09/10] perf stat: Add support for metrics in interval mode Arnaldo Carvalho de Melo
2016-02-16 20:34 ` [PATCH 10/10] perf stat: Move noise/running printing into printout Arnaldo Carvalho de Melo
2016-02-17  7:39 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455654896-14205-7-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).