Re: [PATCH 1/8] perf tools: Add debug_set_file function

From: Arnaldo Carvalho de Melo
Date: Tue Dec 15 2020 - 10:38:04 EST


Em Sat, Dec 12, 2020 at 11:43:51AM +0100, Jiri Olsa escreveu:
> 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.

Thanks, applied.

- Arnaldo


> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> tools/perf/util/debug.c | 9 ++++++++-
> tools/perf/util/debug.h | 2 ++
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
> index 5cda5565777a..50fd6a4be4e0 100644
> --- a/tools/perf/util/debug.c
> +++ b/tools/perf/util/debug.c
> @@ -30,6 +30,12 @@ bool dump_trace = false, quiet = false;
> int debug_ordered_events;
> static int redirect_to_stderr;
> int debug_data_convert;
> +static FILE *debug_file;
> +
> +void debug_set_file(FILE *file)
> +{
> + debug_file = file;
> +}
>
> int veprintf(int level, int var, const char *fmt, va_list args)
> {
> @@ -39,7 +45,7 @@ int veprintf(int level, int var, const char *fmt, va_list args)
> if (use_browser >= 1 && !redirect_to_stderr)
> ui_helpline__vshow(fmt, args);
> else
> - ret = vfprintf(stderr, fmt, args);
> + ret = vfprintf(debug_file, fmt, args);
> }
>
> return ret;
> @@ -227,6 +233,7 @@ DEBUG_WRAPPER(debug, 1);
>
> void perf_debug_setup(void)
> {
> + debug_set_file(stderr);
> 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 f1734abd98dd..43f712295645 100644
> --- a/tools/perf/util/debug.h
> +++ b/tools/perf/util/debug.h
> @@ -5,6 +5,7 @@
>
> #include <stdarg.h>
> #include <stdbool.h>
> +#include <stdio.h>
> #include <linux/compiler.h>
>
> extern int verbose;
> @@ -62,6 +63,7 @@ int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5)
> int veprintf(int level, int var, const char *fmt, va_list args);
>
> int perf_debug_option(const char *str);
> +void debug_set_file(FILE *file);
> void perf_debug_setup(void);
> int perf_quiet_option(void);
>
> --
> 2.26.2
>

--

- Arnaldo