mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] perf annotate: Parse --asm-raw output properly
@ 2012-11-09  1:10 Namhyung Kim
  2012-11-09  1:10 ` [PATCH 2/3] perf annotate: Merge same lines in summary view Namhyung Kim
  2012-11-09  1:10 ` [PATCH 3/3] perf annotate: Don't try to follow jump target on PLT symbols Namhyung Kim
  0 siblings, 2 replies; 6+ messages in thread
From: Namhyung Kim @ 2012-11-09  1:10 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim

From: Namhyung Kim <namhyung.kim@lge.com>

If --asm-raw option was given, objdump output will contain hex numbers
of the instruction before the symbolic name.  However current parser
code doesn't handle it properly.  Fix it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/annotate.c |  2 ++
 tools/perf/util/annotate.c        | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 3eff17f703f3..aec11f34d394 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -117,6 +117,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
 				    ab->addr_width, " ");
 		slsmg_write_nstring(bf, printed);
 		slsmg_write_nstring(dl->line, width - printed - 6);
+	} else if (!dl->name) {
+		slsmg_write_nstring(" ", width - 7);
 	} else {
 		u64 addr = dl->offset;
 		int color = -1;
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index b14d4df9f149..83b1078260e3 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -492,6 +492,9 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
 
 static void disasm_line__init_ins(struct disasm_line *dl)
 {
+	if (dl->name == NULL)
+		return;
+
 	dl->ins = ins__find(dl->name);
 
 	if (dl->ins == NULL)
@@ -514,6 +517,32 @@ static int disasm_line__parse(char *line, char **namep, char **rawp)
 	if (name[0] == '\0')
 		return -1;
 
+	if (symbol_conf.annotate_asm_raw) {
+		/*
+		 * If --asm-raw option was given, objdump output will contain
+		 * hex numbers of the instructions before the symbolic name.
+		 * They are separated by at least two space characters:
+		 *
+		 *   400540:     48 c7 45 f8 00 00 00    movq   $0x0,-0x8(%rbp)
+		 *   400547:     00
+		 *
+		 * It sometimes was broken to multiple lines due to a limited
+		 * width.  In this case following condition will be met:
+		 *
+		 *   dl->offset != -1 && dl->name == NULL.
+		 */
+		name = strstr(name, "  ");
+		if (name == NULL)
+			return 0;
+
+		while (isspace(name[0]))
+			++name;
+
+		if (name[0] == '\0')
+			return -1;
+
+	}
+
 	*rawp = name + 1;
 
 	while ((*rawp)[0] != '\0' && !isspace((*rawp)[0]))
-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-14  8:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09  1:10 [PATCH 1/3] perf annotate: Parse --asm-raw output properly Namhyung Kim
2012-11-09  1:10 ` [PATCH 2/3] perf annotate: Merge same lines in summary view Namhyung Kim
2012-11-09  5:47   ` [PATCH v2 " Namhyung Kim
2012-11-09  5:58     ` [PATCH v3 " Namhyung Kim
2012-11-14  7:44       ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-09  1:10 ` [PATCH 3/3] perf annotate: Don't try to follow jump target on PLT symbols Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome