This message generated a parse failure. Raw output follows here. Please use 'back' to navigate. From devnull@lkml.org Thu Apr 25 23:06:45 2024 >From spaans Mon Jul 25 15:32:10 2016 Envelope-to: lkml@grols.ch Delivery-date: Mon, 25 Jul 2016 15:17:28 +0200 Received: from srv.grols.ch [2a00:d10:4002:1::101] by squeeze.vs19.net with IMAP (fetchmail-6.3.21) for (single-drop); Mon, 25 Jul 2016 15:32:10 +0200 (CEST) Received: from vger.kernel.org ([209.132.180.67]) by home.grols.ch with esmtp (Exim 4.87) (envelope-from ) id 1bRfl9-0004og-Ji for lkml@grols.ch; Mon, 25 Jul 2016 15:17:28 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752282AbcGYNRZ (ORCPT ); Mon, 25 Jul 2016 09:17:25 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:32925 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752271AbcGYNRY (ORCPT ); Mon, 25 Jul 2016 09:17:24 -0400 Received: by mail-wm0-f67.google.com with SMTP id o80so16729856wme.0 for ; Mon, 25 Jul 2016 06:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=SQ5kieUjNy3Ksstg+kitu//Akhtd61kg7+zD9CtNnaQ=; b=XoQni2FjitoHPAOxnoG1E6Xza+2sV9YpHNS/54KT+sCG8tonAUdyQAWQre2rIzm/AP X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SQ5kieUjNy3Ksstg+kitu//Akhtd61kg7+zD9CtNnaQ=; b=jgwhuO3mAeHnqobBNVBwG3gBtw/XVxS/JdkjwMKSnnrsgvcfBMSDRQb X-Gm-Message-State: ALyK8tJmx7Qmq1I+N4R6hYgIkL/IKDDE56D8LJkRaZRswh2P69uhRQr806h9E4lu5dbeeQ== X-Received: by 10.28.215.81 with SMTP id o78mr41694072wmg.42.1469452642965; Mon, 25 Jul 2016 06:17:22 -0700 (PDT) Received: from yoda.ipgp.fr (IPG-216-10.ipgp.fr. [192.54.216.10]) by smtp.gmail.com with ESMTPSA id q23sm27467963wme.17.2016.07.25.06.17.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jul 2016 06:17:22 -0700 (PDT) From: Franck HOUSSEN To: linux-kernel@vger.kernel.org Cc: Franck HOUSSEN Subject: [PATCH] Add --output option to perf-top. Motivation: symmetry with other perf tools. Date: Mon, 25 Jul 2016 15:17:20 +0200 Message-Id: <1469452640-28335-1-git-send-email-fghoussen@gmail.com> X-Mailer: git-send-email 2.8.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-Id: X-Mailing-List: linux-kernel@vger.kernel.org Received-SPF: none client-ip=209.132.180.67; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org X-Spam-Score: 3.8 X-Spam-Score-Bar: +++ X-Spam-Action: no action X-Spam-Report: Action: no action Symbol: FORGED_SENDER(0.30) Symbol: R_MISSING_CHARSET(2.50) Symbol: BAYES_SPAM(0.67) Symbol: MIME_GOOD(-0.10) Symbol: FORGED_RECIPIENTS(2.00) Symbol: R_DKIM_ALLOW(-1.10) Symbol: DMARC_POLICY_ALLOW(-0.50) Message-ID: 1469452640-28335-1-g Signed-off-by: Franck HOUSSEN --- tools/perf/builtin-top.c | 10 +++++++++- tools/perf/ui/stdio/hist.c | 2 ++ tools/perf/util/top.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 2a6cc25..a81a1ef 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -260,6 +260,8 @@ static void perf_top__print_sym_table(struct perf_top *top) perf_top__header_snprintf(top, bf, sizeof(bf)); printf("%s\n", bf); + if (top && top->output_log) + fprintf(top->output_log, "\n%s\n", bf); perf_top__reset_sample_counters(top); @@ -295,7 +297,8 @@ static void perf_top__print_sym_table(struct perf_top *top) hists__output_recalc_col_len(hists, top->print_entries - printed); putchar('\n'); hists__fprintf(hists, false, top->print_entries - printed, win_width, - top->min_percent, stdout); + top->min_percent, + top->output_log ? top->output_log : stdout); } static void prompt_integer(int *target, const char *msg) @@ -1213,6 +1216,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) "Show raw trace event output (do not use print fmt or plugins)"), OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, "Show entries in a hierarchy"), + OPT_STRING('o', "output", &top.output_name, "log", + "Output to a file (tee-like way)"), OPT_END() }; const char * const top_usage[] = { @@ -1337,7 +1342,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) sigaction(SIGWINCH, &act, NULL); } + top.output_log = top.output_name ? fopen(top.output_name, "w") : NULL; status = __cmd_top(&top); + if (top.output_log) + fclose(top.output_log); out_delete_evlist: perf_evlist__delete(top.evlist); diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 560eb47..40ef246 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -511,6 +511,8 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, hist_entry__snprintf(he, &hpp); ret = fprintf(fp, "%s\n", bf); + if (fp != stdout) /* if fp is a file, print also to stdout */ + fprintf(stdout, "%s\n", bf); if (symbol_conf.use_callchain) ret += hist_entry_callchain__fprintf(he, total_period, 0, fp); diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index b2940c8..4035a58 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -4,6 +4,7 @@ #include "tool.h" #include #include +#include #include #include @@ -37,6 +38,8 @@ struct perf_top { int sym_pcnt_filter; const char *sym_filter; float min_percent; + const char *output_name; + FILE *output_log; }; #define CONSOLE_CLEAR "" -- 2.8.1