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>] [day] [month] [year] [list]
Date:	Fri, 27 Apr 2012 01:33:16 -0700
From:	tip-bot for Arnaldo Carvalho de Melo <acme@...hat.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, eranian@...gle.com, paulus@...ba.org,
	acme@...hat.com, hpa@...or.com, mingo@...nel.org,
	peterz@...radead.org, efault@....de, namhyung@...il.com,
	fweisbec@...il.com, dsahern@...il.com, tglx@...utronix.de
Subject: [tip:perf/core] perf annotate browser: Align jump labels

Commit-ID:  61e04b332e9417720c331eb39c96a4ccb1aa0460
Gitweb:     http://git.kernel.org/tip/61e04b332e9417720c331eb39c96a4ccb1aa0460
Author:     Arnaldo Carvalho de Melo <acme@...hat.com>
AuthorDate: Thu, 19 Apr 2012 13:15:24 -0300
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Thu, 19 Apr 2012 13:15:24 -0300

perf annotate browser: Align jump labels

Find out at browser startup the max width and use it when rendering jump
labels on the screen.

Cc: David Ahern <dsahern@...il.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Mike Galbraith <efault@....de>
Cc: Namhyung Kim <namhyung@...il.com>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephane Eranian <eranian@...gle.com>
Link: http://lkml.kernel.org/n/tip-7dxjiwqb77wz6f5lc05e0i0x@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/ui/browsers/annotate.c |   17 +++++++++++++----
 tools/perf/util/util.c            |   10 ++++++++++
 tools/perf/util/util.h            |    2 ++
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index a1e942b..c5ab21c 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -31,6 +31,7 @@ struct annotate_browser {
 	bool		    hide_src_code;
 	bool		    use_offset;
 	bool		    searching_backwards;
+	u8		    offset_width;
 	char		    search_bf[128];
 };
 
@@ -92,10 +93,17 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
 		if (!ab->use_offset)
 			addr += ab->start;
 
-		if (bdl->jump_target || !ab->use_offset)
-			printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr);
-		else
-			printed = scnprintf(bf, sizeof(bf), "    ");
+		if (!ab->use_offset) {
+			printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ":", addr);
+		} else {
+			if (bdl->jump_target) {
+				printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ":",
+						    ab->offset_width, addr);
+			} else {
+				printed = scnprintf(bf, sizeof(bf), "%*s ",
+						    ab->offset_width, " ");
+			}
+		}
 
 		if (change_color)
 			color = ui_browser__set_color(self, HE_COLORSET_ADDR);
@@ -687,6 +695,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
 
 	annotate_browser__mark_jump_targets(&browser, size);
 
+	browser.offset_width = hex_width(size);
 	browser.b.nr_entries = browser.nr_entries;
 	browser.b.entries = &notes->src->source,
 	browser.b.width += 18; /* Percentage */
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 8109a90..d03599f 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -148,3 +148,13 @@ int readn(int fd, void *buf, size_t n)
 
 	return buf - buf_start;
 }
+
+size_t hex_width(u64 v)
+{
+	size_t n = 1;
+
+	while ((v >>= 4))
+		++n;
+
+	return n;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0f99f39..6121e24 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -265,4 +265,6 @@ bool is_power_of_2(unsigned long n)
 	return (n != 0 && ((n & (n - 1)) == 0));
 }
 
+size_t hex_width(u64 v);
+
 #endif
--
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