linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Feng Tang <feng.tang@intel.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com,
	mingo@kernel.org, andi@firstfloor.org, peterz@infradead.org,
	namhyung@kernel.org, tglx@linutronix.de, feng.tang@intel.com,
	mingo@elte.hu
Subject: [tip:perf/core] perf hists browser: Integrate script browser into main hists browser
Date: Tue, 30 Oct 2012 05:09:47 -0700	[thread overview]
Message-ID: <tip-cdbab7c201ab38f7b8d248ebf289025381166526@git.kernel.org> (raw)
In-Reply-To: <1351569369-26732-6-git-send-email-feng.tang@intel.com>

Commit-ID:  cdbab7c201ab38f7b8d248ebf289025381166526
Gitweb:     http://git.kernel.org/tip/cdbab7c201ab38f7b8d248ebf289025381166526
Author:     Feng Tang <feng.tang@intel.com>
AuthorDate: Tue, 30 Oct 2012 11:56:06 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 29 Oct 2012 11:56:19 -0200

perf hists browser: Integrate script browser into main hists browser

Integrate the script browser into "perf report" framework, users can use
function key 'r' or the drop down menu to list all perf scripts and
select one of them, just like they did for the annotation.

Signed-off-by: Feng Tang <feng.tang@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1351569369-26732-6-git-send-email-feng.tang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index ef2f93c..fe62284 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1141,6 +1141,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	int nr_options = 0;
 	int key = -1;
 	char buf[64];
+	char script_opt[64];
 
 	if (browser == NULL)
 		return -1;
@@ -1159,6 +1160,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 		int choice = 0,
 		    annotate = -2, zoom_dso = -2, zoom_thread = -2,
 		    annotate_f = -2, annotate_t = -2, browse_map = -2;
+		int scripts_comm = -2, scripts_symbol = -2, scripts_all = -2;
 
 		nr_options = 0;
 
@@ -1211,6 +1213,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				hist_browser__reset(browser);
 			}
 			continue;
+		case 'r':
+			goto do_scripts;
 		case K_F1:
 		case 'h':
 		case '?':
@@ -1229,6 +1233,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 					"E             Expand all callchains\n"
 					"d             Zoom into current DSO\n"
 					"t             Zoom into current Thread\n"
+					"r             Run available scripts\n"
 					"P             Print histograms to perf.hist.N\n"
 					"V             Verbose (DSO names in callchains, etc)\n"
 					"/             Filter symbol by name");
@@ -1317,6 +1322,25 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 		    browser->selection->map != NULL &&
 		    asprintf(&options[nr_options], "Browse map details") > 0)
 			browse_map = nr_options++;
+
+		/* perf script support */
+		if (browser->he_selection) {
+			struct symbol *sym;
+
+			if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]",
+				browser->he_selection->thread->comm) > 0)
+				scripts_comm = nr_options++;
+
+			sym = browser->he_selection->ms.sym;
+			if (sym && sym->namelen &&
+				asprintf(&options[nr_options], "Run scripts for samples of symbol [%s]",
+						sym->name) > 0)
+				scripts_symbol = nr_options++;
+		}
+
+		if (asprintf(&options[nr_options], "Run scripts for all samples") > 0)
+			scripts_all = nr_options++;
+
 add_exit_option:
 		options[nr_options++] = (char *)"Exit";
 retry_popup_menu:
@@ -1411,6 +1435,20 @@ zoom_out_thread:
 			hists__filter_by_thread(hists);
 			hist_browser__reset(browser);
 		}
+		/* perf scripts support */
+		else if (choice == scripts_all || choice == scripts_comm ||
+				choice == scripts_symbol) {
+do_scripts:
+			memset(script_opt, 0, 64);
+
+			if (choice == scripts_comm)
+				sprintf(script_opt, " -c %s ", browser->he_selection->thread->comm);
+
+			if (choice == scripts_symbol)
+				sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name);
+
+			script_browse(script_opt);
+		}
 	}
 out_free_stack:
 	pstack__delete(fstack);

  parent reply	other threads:[~2012-10-30 12:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-30  3:56 [PATCH v5 0/8] perf tools: Add script browser and runtime data file switch Feng Tang
2012-10-30  3:56 ` [PATCH v5 1/8] perf tool: Add a global variable "const char *input_name" Feng Tang
2012-10-30 12:05   ` [tip:perf/core] perf tools: Add a global variable " const " tip-bot for Feng Tang
2012-10-30  3:56 ` [PATCH v5 2/8] perf script: Add more filter to find_scripts() Feng Tang
2012-10-30 12:06   ` [tip:perf/core] " tip-bot for Feng Tang
2012-10-30  3:56 ` [PATCH v5 3/8] perf ui/browser: Add a browser for perf script Feng Tang
2012-10-30 12:07   ` [tip:perf/core] perf scripts browser: " tip-bot for Feng Tang
2012-10-30  3:56 ` [PATCH v5 4/8] perf ui/browser: Integrate script browser into annotation browser Feng Tang
2012-10-30 12:08   ` [tip:perf/core] perf annotate browser: " tip-bot for Feng Tang
2012-10-30  3:56 ` [PATCH v5 5/8] perf ui/browser: Integrate script browser into main hists browser Feng Tang
2012-10-29 14:54   ` Arnaldo Carvalho de Melo
2012-10-30 16:05     ` Feng Tang
2012-10-30 12:09   ` tip-bot for Feng Tang [this message]
2012-10-30  3:56 ` [PATCH v5 6/8] perf header: Add is_perf_magic() func Feng Tang
2012-10-30 12:10   ` [tip:perf/core] " tip-bot for Feng Tang
2012-10-30  3:56 ` [PATCH v5 7/8] perf hists browser: Add option for runtime switching perf data file Feng Tang
2012-10-29 14:06   ` Arnaldo Carvalho de Melo
2012-10-30 16:01     ` Feng Tang
2012-10-30  3:56 ` [PATCH v5 8/8] perf report: Enable the runtime switching of " Feng Tang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-cdbab7c201ab38f7b8d248ebf289025381166526@git.kernel.org \
    --to=feng.tang@intel.com \
    --cc=acme@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).