Skip to contentSkip to conversation

clean hex output of ftrace

PATCH In review trem 3 participants 3 messages Oct 8, 2008 Tracing

lore
Share & tools
lore

trem

author
#0 lore raw

PATCH 1/1 clean hex output of ftrace

Fix the output of ftrace in hex mode. Without this patch, the ouput of ftrace is :

raw mode : 6474 0 141531612444 0 140 + 6402 120 S
hex mode : 000091a4 00000000 000000023f1f50c1 00000000 c8 000000b2 00009120 87 ffff00c8 00000035

There is an inversion on ouput hex(6474) is 194a

---

kernel/trace/trace.c 2008-10-08 22:30:29.000000000 +0200 renamed from kernel/trace/trace.c +0 -0
Index: linux-2.6.26/kernel/trace/trace.c
===================================================================
@@ -415,8 +415,8 @@
#endif
               byte = data[i];
-               hex[j++] = hex2asc[byte & 0x0f];
               hex[j++] = hex2asc[byte >> 4];
+               hex[j++] = hex2asc[byte & 0x0f];
       }
       hex[j++] = ' ';
#1 lore raw

kernel/trace/trace.c 2008-10-08 22:30:29.000000000 +0200 line 421

Quoted 13 lines · trem

Index: linux-2.6.26/kernel/trace/trace.c
===================================================================

kernel/trace/trace.c 2008-10-08 22:30:29.000000000 +0200 renamed from kernel/trace/trace.c +1 -1
@@ -415,8 +415,8 @@
 #endif
                byte = data[i];
 
-               hex[j++] = hex2asc[byte & 0x0f];
                hex[j++] = hex2asc[byte >> 4];
+               hex[j++] = hex2asc[byte & 0x0f];
        }
        hex[j++] = ' ';

I'm surprised Harvey Harrison hasn't changed it to pack_hex_byte and removed the static.

#2 lore raw
Quoted 3 lines · Joe Perches

I'm surprised Harvey Harrison hasn't changed it to pack_hex_byte and removed the static.

From: Harvey Harrison <[email protected]>
Subject: [PATCH] ftrace: Fix inversion of hex output and use common routines

Fix the output of ftrace in hex mode as the hi/lo nibbles are output in reverse order. Without this patch, the output of ftrace is:

raw mode : 6474 0 141531612444 0 140 + 6402 120 S
hex mode : 000091a4 00000000 000000023f1f50c1 00000000 c8 000000b2 00009120 87 ffff00c8 00000035

There is an inversion on ouput hex(6474) is 194a

[based on a patch by Philippe Reynes <[email protected]>]
---
 kernel/trace/trace.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
kernel/trace/trace.c +2 -6
index 8f3fb3d..763f763 100644
@@ -396,14 +396,12 @@ trace_seq_putmem(struct trace_seq *s, void *mem, size_t len)
 }
 
 #define HEX_CHARS 17
-static const char hex2asc[] = "0123456789abcdef";
 
 static int
 trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len)
 {
 	unsigned char hex[HEX_CHARS];
 	unsigned char *data = mem;
-	unsigned char byte;
 	int i, j;
 
 	BUG_ON(len >= HEX_CHARS);
@@ -413,10 +411,8 @@ trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len)
 #else
 	for (i = len-1, j = 0; i >= 0; i--) {
 #endif
-		byte = data[i];
-
-		hex[j++] = hex2asc[byte & 0x0f];
-		hex[j++] = hex2asc[byte >> 4];
+		hex[j++] = hex_asc_hi(data[i]);
+		hex[j++] = hex_asc_lo(data[i]);
 	}
 	hex[j++] = ' ';
 
Signature · 1 line
1.6.0.2.471.g47a76