Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1333511

[PATCH 4/5] perf tools: Initialize libapi debug output

From Jiri Olsa <jolsa@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 4/5] perf tools: Initialize libapi debug output
Date 2016-02-14 17:10 +0100
Message-ID <r27ph-4Un-17@gated-at.bofh.it> (permalink)
References <r27pg-4Un-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Setting libapi debug output functions
to use perf functions.

Link: http://lkml.kernel.org/n/tip-apyen6qfzzwkqjhi1tzv72ju@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 86d9c7302598..152c2e32975f 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"
@@ -192,3 +193,23 @@ int perf_debug_option(const char *str)
 	free(s);
 	return 0;
 }
+
+#define FUNC(__n, __l)					\
+static int pr_ ## __n ## _func(const char *fmt, ...)	\
+{							\
+	va_list args;					\
+	int ret;					\
+							\
+	va_start(args, fmt);				\
+	ret = _eprintf(__l, verbose, fmt, args);	\
+	va_end(args);					\
+	return ret;					\
+}
+
+FUNC(warning, 0);
+FUNC(debug, 1);
+
+void perf_debug_setup(void)
+{
+	libapi_set_print(pr_warning_func, pr_warning_func, pr_debug_func);
+}
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.4.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] perf tools: Store CPU cache details under perf data Jiri Olsa <jolsa@kernel.org> - 2016-02-14 17:10 +0100
  [PATCH 3/5] tools lib api fs: Add sysfs__read_str function Jiri Olsa <jolsa@kernel.org> - 2016-02-14 17:10 +0100
    [tip:perf/core] tools lib api fs: Add sysfs__read_str function tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-02-17 13:10 +0100
  [PATCH 5/5] perf tools: Add perf data cache feature Jiri Olsa <jolsa@kernel.org> - 2016-02-14 17:10 +0100
    [PATCHv2 5/5] perf tools: Add perf data cache feature Jiri Olsa <jolsa@redhat.com> - 2016-02-16 13:20 +0100
      Re: [PATCHv2 5/5] perf tools: Add perf data cache feature Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:30 +0100
        [PATCHv3 5/5] perf tools: Add perf data cache feature Jiri Olsa <jolsa@redhat.com> - 2016-02-16 16:10 +0100
          Re: [PATCHv3 5/5] perf tools: Add perf data cache feature Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-16 16:30 +0100
            Re: [PATCHv3 5/5] perf tools: Add perf data cache feature Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2016-02-16 16:50 +0100
          [tip:perf/core] perf tools: Add perf data cache feature tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-02-17 13:10 +0100
  [PATCH 4/5] perf tools: Initialize libapi debug output Jiri Olsa <jolsa@kernel.org> - 2016-02-14 17:10 +0100
    [tip:perf/core] perf tools: Initialize libapi debug output tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-02-17 13:10 +0100
  [PATCH 1/5] tools lib api: Add debug output support Jiri Olsa <jolsa@kernel.org> - 2016-02-14 17:10 +0100
    [tip:perf/core] tools lib api: Add debug output support tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-02-17 13:10 +0100
  [PATCH 2/5] tools lib api fs: Move filename__read_str into api/fs/fs.c Jiri Olsa <jolsa@kernel.org> - 2016-02-14 17:10 +0100
    [tip:perf/core] tools lib api fs:   Adopt filename__read_str from perf tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-02-17 13:10 +0100
  Re: [PATCH 0/5] perf tools: Store CPU cache details under perf data Ingo Molnar <mingo@kernel.org> - 2016-02-16 09:20 +0100
    Re: [PATCH 0/5] perf tools: Store CPU cache details under perf data Jiri Olsa <jolsa@redhat.com> - 2016-02-16 12:30 +0100

csiph-web