Skip to content

Commit dd629cc

Browse files
olsajiriacmel
authored andcommitted
perf tools: Initialize libapi debug output
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]>
1 parent bedbdd4 commit dd629cc

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

tools/perf/perf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,8 @@ int main(int argc, const char **argv)
613613
*/
614614
pthread__block_sigwinch();
615615

616+
perf_debug_setup();
617+
616618
while (1) {
617619
static int done_help;
618620
int was_alias = run_argv(&argc, &argv);

tools/perf/util/debug.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <string.h>
66
#include <stdarg.h>
77
#include <stdio.h>
8+
#include <api/debug.h>
89

910
#include "cache.h"
1011
#include "color.h"
@@ -187,3 +188,23 @@ int perf_debug_option(const char *str)
187188
free(s);
188189
return 0;
189190
}
191+
192+
#define DEBUG_WRAPPER(__n, __l) \
193+
static int pr_ ## __n ## _wrapper(const char *fmt, ...) \
194+
{ \
195+
va_list args; \
196+
int ret; \
197+
\
198+
va_start(args, fmt); \
199+
ret = veprintf(__l, verbose, fmt, args); \
200+
va_end(args); \
201+
return ret; \
202+
}
203+
204+
DEBUG_WRAPPER(warning, 0);
205+
DEBUG_WRAPPER(debug, 1);
206+
207+
void perf_debug_setup(void)
208+
{
209+
libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper);
210+
}

tools/perf/util/debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __attribute__(
5353
int veprintf(int level, int var, const char *fmt, va_list args);
5454

5555
int perf_debug_option(const char *str);
56+
void perf_debug_setup(void);
5657

5758
#endif /* __PERF_DEBUG_H */

0 commit comments

Comments
 (0)