lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1389762525-1795-1-git-send-email-namhyung@kernel.org>
Date:	Wed, 15 Jan 2014 14:08:45 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...nel.org>,
	Namhyung Kim <namhyung.kim@....com>,
	LKML <linux-kernel@...r.kernel.org>,
	Jiri Olsa <jolsa@...hat.com>, David Ahern <dsahern@...il.com>
Subject: [PATCH/RFC] perf ui/tui: Show column header in hist browser

Add a line for showing column headers like --stdio.

Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/ui/browser.c        |  4 +--
 tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index d11541d4d7d7..441470ba8d2c 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -278,8 +278,8 @@ void ui_browser__hide(struct ui_browser *browser)
 static void ui_browser__scrollbar_set(struct ui_browser *browser)
 {
 	int height = browser->height, h = 0, pct = 0,
-	    col = browser->width,
-	    row = browser->y - 1;
+	    col = browser->width, row = 0;
+
 
 	if (browser->nr_entries > 1) {
 		pct = ((browser->index * (browser->height - 1)) /
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e0ab399d431d..5b94de48f23c 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -25,6 +25,7 @@ struct hist_browser {
 	struct map_symbol   *selection;
 	int		     print_seq;
 	bool		     show_dso;
+	bool		     show_column_header;
 	float		     min_pcnt;
 	u64		     nr_pcnt_entries;
 };
@@ -312,6 +313,57 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser)
 
 static void hist_browser__update_pcnt_entries(struct hist_browser *hb);
 
+static void hist_browser__column_header(struct hist_browser *browser)
+{
+	struct perf_hpp_fmt *fmt;
+	struct sort_entry *se;
+	struct hists *hists = browser->hists;
+	bool show = browser->show_column_header;
+	unsigned int width;
+
+	pthread_mutex_lock(&ui__lock);
+
+	if (!show)
+		goto out;
+
+	ui_browser__gotorc(&browser->b, 0, 0);
+
+	perf_hpp__for_each_format(fmt) {
+		char buf[128];
+		struct perf_hpp hpp = {
+			.buf	= buf,
+			.size	= sizeof(buf),
+			.ptr	= hists_to_evsel(hists),
+		};
+
+		width = fmt->width(fmt, &hpp);
+		fmt->header(fmt, &hpp);
+
+		slsmg_printf(" %-*s", width, hpp.buf);
+	}
+
+	list_for_each_entry(se, &hist_entry__sort_list, list) {
+		if (se->elide)
+			continue;
+
+		width = strlen(se->se_header);
+		if (!hists__new_col_len(hists, se->se_width_idx, width))
+			width = hists__col_len(hists, se->se_width_idx);
+
+		slsmg_printf("  %-*s", width, se->se_header);
+	}
+
+	/*
+	 * We just called ui_browser__refresh_dimensions().
+	 * Update it to honor a new column header line.
+	 */
+	browser->b.y++;
+	browser->b.height--;
+
+out:
+	pthread_mutex_unlock(&ui__lock);
+}
+
 static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
 			     struct hist_browser_timer *hbt)
 {
@@ -331,6 +383,8 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
 			     "Press '?' for help on key bindings") < 0)
 		return -1;
 
+	hist_browser__column_header(browser);
+
 	while (1) {
 		key = ui_browser__run(&browser->b, delay_secs);
 
@@ -1198,6 +1252,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists)
 		browser->b.refresh = hist_browser__refresh;
 		browser->b.seek = ui_browser__hists_seek;
 		browser->b.use_navkeypressed = true;
+		browser->show_column_header = true;
 	}
 
 	return browser;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ