V4: fix address printing on 64bit platforms
authorErik Verbruggen <erik.verbruggen@digia.com>
Thu, 6 Mar 2014 11:37:06 +0000 (12:37 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 7 Mar 2014 11:20:24 +0000 (12:20 +0100)
The addresses were truncated to 32bits, which is a problem on win64,
because JITted code ended up outside that range.

Change-Id: I0d8b92486714340dffe4b4c2de29cf11a929a149
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/3rdparty/masm/assembler/LinkBuffer.cpp
src/3rdparty/masm/disassembler/UDis86Disassembler.cpp
src/qml/jit/qv4isel_masm.cpp

index bf4f2f5..432a7ee 100644 (file)
@@ -52,7 +52,13 @@ LinkBuffer::CodeRef LinkBuffer::finalizeCodeWithDisassembly(const char* format,
     va_end(argList);
     dataLogF(":\n");
     
-    dataLogF("    Code at [%p, %p):\n", result.code().executableAddress(), static_cast<char*>(result.code().executableAddress()) + result.size());
+    dataLogF(
+#if OS(WINDOWS)
+                "    Code at [0x%p, 0x%p):\n",
+#else
+                "    Code at [%p, %p):\n",
+#endif
+                result.code().executableAddress(), static_cast<char*>(result.code().executableAddress()) + result.size());
     disassemble(result.code(), m_size, "    ", WTF::dataFile());
     
     return result;
index 63c235b..3d9d8cb 100644 (file)
@@ -49,7 +49,13 @@ bool tryToDisassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const c
     uint64_t currentPC = disassembler.pc;
     while (ud_disassemble(&disassembler)) {
         char pcString[20];
-        snprintf(pcString, sizeof(pcString), "0x%lx", static_cast<unsigned long>(currentPC));
+        snprintf(pcString, sizeof(pcString),
+#if OS(WINDOWS)
+                 "0x%p",
+#else
+                 "%p",
+#endif
+                 currentPC);
         out.printf("%s%16s: %s\n", prefix, pcString, ud_insn_asm(&disassembler));
         currentPC = disassembler.pc;
     }
index fd2db58..d09ac4d 100644 (file)
@@ -119,6 +119,7 @@ static void printDisassembledOutputWithCalls(QByteArray processedOutput, const Q
         processedOutput = processedOutput.replace(ptrString, it.value());
     }
     fprintf(stderr, "%s\n", processedOutput.constData());
+    fflush(stderr);
 }
 
 JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize)