[Mesa-dev] [PATCH] intel/eu: print bytes instead of 32 bit hex value

Sagar Ghuge sagar.ghuge at intel.com
Wed Aug 15 21:00:11 UTC 2018


INTEL_DEBUG=hex prints 32 bit hex value
and due to endianness of CPU byte order is
reversed. In order to disassemble binary
files, print each byte instead of 32 bit hex
value.

Signed-off-by: Sagar Ghuge <sagar.ghuge at intel.com>
---
 src/intel/compiler/brw_eu.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c
index 6ef0a6a577..223e561dff 100644
--- a/src/intel/compiler/brw_eu.c
+++ b/src/intel/compiler/brw_eu.c
@@ -365,9 +365,14 @@ brw_disassemble(const struct gen_device_info *devinfo,
       if (compacted) {
          brw_compact_inst *compacted = (void *)insn;
 	 if (dump_hex) {
-	    fprintf(out, "0x%08x 0x%08x                       ",
-		    ((uint32_t *)insn)[1],
-		    ((uint32_t *)insn)[0]);
+	    unsigned char * insn_ptr = ((unsigned char *)&insn[0]);
+	    for (int i = 0 ; i < 8; i = i + 4) {
+	       fprintf(out, "%02x %02x %02x %02x ",
+		       insn_ptr[i],
+		       insn_ptr[i + 1],
+		       insn_ptr[i + 2],
+		       insn_ptr[i + 3]);
+	    }
 	 }
 
 	 brw_uncompact_instruction(devinfo, &uncompacted, compacted);
@@ -375,11 +380,14 @@ brw_disassemble(const struct gen_device_info *devinfo,
 	 offset += 8;
       } else {
 	 if (dump_hex) {
-	    fprintf(out, "0x%08x 0x%08x 0x%08x 0x%08x ",
-		    ((uint32_t *)insn)[3],
-		    ((uint32_t *)insn)[2],
-		    ((uint32_t *)insn)[1],
-		    ((uint32_t *)insn)[0]);
+	    unsigned char * insn_ptr = ((unsigned char *)&insn[0]);
+	    for (int i = 0 ; i < 16; i = i + 4) {
+	       fprintf(out, "%02x %02x %02x %02x ",
+		       insn_ptr[i],
+		       insn_ptr[i + 1],
+		       insn_ptr[i + 2],
+		       insn_ptr[i + 3]);
+	    }
 	 }
 	 offset += 16;
       }
-- 
2.17.1



More information about the mesa-dev mailing list