[PATCH 6/7] perf debug: fix hex dump partial final line

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Arnaldo Carvalho de Melo
Date: Thursday, June 17, 2010 - 1:40 pm

From: Andy Isaacson <adi@hexapodia.org>

The loop counter math in trace_event was much more complicated than
necessary, resulting in incorrectly decoding the human-readable
portion of the partial last line of hexdump in "perf trace -D" output:

.  0020:  00 00 00 00 00 00 00 00 2f 73 62 69 6e 2f 69 6e  ......../sbin/i
.  0030:  69 74 00 00 00 00 00 00                          /sbin/i

With this fixed (and simpler!) code, we get the correct output:

.  0020:  00 00 00 00 00 00 00 00 2f 73 62 69 6e 2f 69 6e  ......../sbin/in
.  0030:  69 74 00 00 00 00 00 00                          it......

Cc: Ingo Molnar <mingo@elte.hu>
LPU-Reference: <20100612024404.GA24469@hexapodia.org>
Signed-off-by: Andy Isaacson <adi@hexapodia.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/debug.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 6cddff2..318dab1 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -86,12 +86,10 @@ void trace_event(event_t *event)
 			dump_printf_color("  ", color);
 			for (j = 0; j < 15-(i & 15); j++)
 				dump_printf_color("   ", color);
-			for (j = 0; j < (i & 15); j++) {
-				if (isprint(raw_event[i-15+j]))
-					dump_printf_color("%c", color,
-							  raw_event[i-15+j]);
-				else
-					dump_printf_color(".", color);
+			for (j = i & ~15; j <= i; j++) {
+				dump_printf_color("%c", color,
+						isprint(raw_event[j]) ?
+						raw_event[j] : '.');
 			}
 			dump_printf_color("\n", color);
 		}
-- 
1.6.2.5

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PULL 0/7] perf/core improvements and fixes for 2.6.36, Arnaldo Carvalho de Melo, (Thu Jun 17, 1:39 pm)
[PATCH 3/7] perf record: Add option to avoid updating buil ..., Arnaldo Carvalho de Melo, (Thu Jun 17, 1:40 pm)
[PATCH 4/7] perf tools: .gitignore += config.make config.m ..., Arnaldo Carvalho de Melo, (Thu Jun 17, 1:40 pm)
[PATCH 5/7] perf probe: Add kernel source path option, Arnaldo Carvalho de Melo, (Thu Jun 17, 1:40 pm)
[PATCH 6/7] perf debug: fix hex dump partial final line, Arnaldo Carvalho de Melo, (Thu Jun 17, 1:40 pm)