Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1895974pxu; Sun, 13 Dec 2020 06:54:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3kS16yBHydmG3EN1VSVrq1KU5LLOJSu/dMtBQBv7/qpK8inM4TXIGzzqGB0+8mL3On6jJ X-Received: by 2002:aa7:c3d3:: with SMTP id l19mr21340894edr.366.1607871286446; Sun, 13 Dec 2020 06:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607871286; cv=none; d=google.com; s=arc-20160816; b=LefY9RZ0GyV2arHFGnCqDcaGQkeTHWugYsHsvUXuUpIo98++7ljZ73auo3sJB4phNh RbysKSb3CiV5rkfM1NKr7tx+Nu64ZlpaDeX87UMjPoqyhlWlPzs2MgVJsbDR64dG/yi0 +OKs+XUZD1P8IXfgGp5SUoL/Q9JjZyz/BT0OE5tTYpiEwid2o9mDjQCUtcIkWl7fZ8Z7 5H1dVR/s54dwBUoVQt0LjT1deAylgcu2dFBU6JvxbNy2lFTKk+l8HcbC08wHQ7xRkfR8 hiDXkhih3JlNgqh77XQ744VItGsv1qQVP/3wfV4B9mQz0p0igz7ca7QaMVrxD4FFrM4T PIXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lfAZcOvjAdJ0+xLfATtyTAL0kiuL9BF6onzQdZDba/0=; b=Fmc0zJ0T4asjIOsjzbWwWopVRZiLcos28I2cNX2tRowDNyDTJJEnstGA/eJyhLPqPx 6Fd0r3FnTGMzxZV+QeM5DdECVbRG0MgUvpJ2+qDN6lheMnjA8S2llTg1mOxPH2ree1jF Q402+Vn29ql/CUGVElaKTJAflgfniZG9LO7TBU4GUq+tSeJgvdX99CdwtWPY2uM4/2iy LuOHncysaQmPJWVnh4t2Iqkb9Iw88JVU8tgLg2cNOwze29mqDLJBJP4pCuyOZDP+qJlx wN7KwQV06Qk8OMPEYSMKojW+HckbTfEscwKOkSqJ2+9yQMZmq2F3DkSo/0wR19i/Cnb2 oCeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 97si8512909edr.112.2020.12.13.06.54.23; Sun, 13 Dec 2020 06:54:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407382AbgLLKpF convert rfc822-to-8bit (ORCPT + 99 others); Sat, 12 Dec 2020 05:45:05 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:38009 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407360AbgLLKpE (ORCPT ); Sat, 12 Dec 2020 05:45:04 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-489-MUyigM7iPySexfQ1G61Stw-1; Sat, 12 Dec 2020 05:44:09 -0500 X-MC-Unique: MUyigM7iPySexfQ1G61Stw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6C7F800D55; Sat, 12 Dec 2020 10:44:07 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9689B60CCE; Sat, 12 Dec 2020 10:44:04 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Subject: [PATCH 1/8] perf tools: Add debug_set_file function Date: Sat, 12 Dec 2020 11:43:51 +0100 Message-Id: <20201212104358.412065-2-jolsa@kernel.org> In-Reply-To: <20201212104358.412065-1-jolsa@kernel.org> References: <20201212104358.412065-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 #include +#include #include 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