aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2014-03-07 14:33:56 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-08 09:26:40 +0100
commit6c23aaf9395a2fd4b60246cc8fbf51c54c2bfb2c (patch)
tree9bf45504a5bbb34a547d947b9e5475b52b2e2d84 /src/3rdparty
parent6957e7702476dc300466f6f693782cf8661a5ba1 (diff)
V4: fix address printing for real.
The previous patch contained the wrong formatting string for 64bit platforms. Good compilers will warn on this (and fail compiling with -Werror). Fixed the issue in such a way that we now have static checking for both 32bit/64bit platforms by the compiler. Change-Id: Idf4a80d8795605c61ef812426c9984df1ceac4d4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/masm/disassembler/UDis86Disassembler.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/3rdparty/masm/disassembler/UDis86Disassembler.cpp b/src/3rdparty/masm/disassembler/UDis86Disassembler.cpp
index 3d9d8cb384..b01a234ea6 100644
--- a/src/3rdparty/masm/disassembler/UDis86Disassembler.cpp
+++ b/src/3rdparty/masm/disassembler/UDis86Disassembler.cpp
@@ -33,6 +33,20 @@
namespace JSC {
+namespace {
+template <int> struct helper;
+template <> struct helper<4> {
+ static void hex(char *str, size_t len, uint64_t pc)
+ { snprintf(str, len, "0x%x", static_cast<uint32_t>(pc)); }
+};
+template <> struct helper<8> {
+ static void hex(char *str, size_t len, uint64_t pc)
+ { snprintf(str, len, "0x%llx", pc); }
+};
+inline void print(char *str, size_t len, uint64_t pc)
+{ helper<sizeof(void*)>::hex(str, len, pc); }
+}
+
bool tryToDisassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out)
{
ud_t disassembler;
@@ -49,13 +63,7 @@ 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),
-#if OS(WINDOWS)
- "0x%p",
-#else
- "%p",
-#endif
- currentPC);
+ print(pcString, sizeof(pcString), currentPC);
out.printf("%s%16s: %s\n", prefix, pcString, ud_insn_asm(&disassembler));
currentPC = disassembler.pc;
}