Skip to content

Commit

Permalink
perf tools: Initialize libapi debug output
Browse files Browse the repository at this point in the history
Setting libapi debug output functions to use perf functions.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
olsajiri authored and acmel committed Feb 16, 2016
1 parent bedbdd4 commit dd629cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions tools/perf/util/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <api/debug.h>

#include "cache.h"
#include "color.h"
Expand Down Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions tools/perf/util/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit dd629cc

Please sign in to comment.