Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf debug: Add debug_set_file function

Allow to set debug output file via new debug_set_file function.

It's called during perf startup in perf_debug_setup to set stderr file
as default and any perf command can set it later to different file.

It will be used in perf daemon command to get verbose output into log
file.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20201212104358.412065-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
8abceacf 7cfcd1e0

+10 -1
+8 -1
tools/perf/util/debug.c
··· 30 30 int debug_ordered_events; 31 31 static int redirect_to_stderr; 32 32 int debug_data_convert; 33 + static FILE *debug_file; 34 + 35 + void debug_set_file(FILE *file) 36 + { 37 + debug_file = file; 38 + } 33 39 34 40 int veprintf(int level, int var, const char *fmt, va_list args) 35 41 { ··· 45 39 if (use_browser >= 1 && !redirect_to_stderr) 46 40 ui_helpline__vshow(fmt, args); 47 41 else 48 - ret = vfprintf(stderr, fmt, args); 42 + ret = vfprintf(debug_file, fmt, args); 49 43 } 50 44 51 45 return ret; ··· 233 227 234 228 void perf_debug_setup(void) 235 229 { 230 + debug_set_file(stderr); 236 231 libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper); 237 232 } 238 233
+2
tools/perf/util/debug.h
··· 5 5 6 6 #include <stdarg.h> 7 7 #include <stdbool.h> 8 + #include <stdio.h> 8 9 #include <linux/compiler.h> 9 10 10 11 extern int verbose; ··· 63 62 int veprintf(int level, int var, const char *fmt, va_list args); 64 63 65 64 int perf_debug_option(const char *str); 65 + void debug_set_file(FILE *file); 66 66 void perf_debug_setup(void); 67 67 int perf_quiet_option(void); 68 68