]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Adapt -jdump to unified string.format("%x", -1) behavior.
authorMike Pall <mike>
Mon, 13 May 2013 17:39:34 +0000 (19:39 +0200)
committerMike Pall <mike>
Mon, 13 May 2013 17:39:34 +0000 (19:39 +0200)
src/jit/dis_x86.lua
src/jit/dump.lua

index c442a176b1b0fef0a8b2ab86611b1818803cbe68..49101efe8ccb17966315ded32869a5726ac3cbc5 100644 (file)
@@ -28,6 +28,8 @@ local type = type
 local sub, byte, format = string.sub, string.byte, string.format
 local match, gmatch, gsub = string.match, string.gmatch, string.gsub
 local lower, rep = string.lower, string.rep
+local bit = require("bit")
+local tohex = bit.tohex
 
 -- Map for 1st opcode byte in 32 bit mode. Ugly? Well ... read on.
 local map_opc1_32 = {
@@ -532,7 +534,7 @@ local function putpat(ctx, name, pat)
        local lo = imm % 0x1000000
        x = format("0x%02x%06x", (imm-lo) / 0x1000000, lo)
       else
-       x = format("0x%08x", imm)
+       x = "0x"..tohex(imm)
       end
     elseif p == "R" then
       local r = byte(code, pos-1, pos-1)%8
index 2a7d64e4edc636a97ddc024f955177c5c0120559..e6c9d5b6213e7645d40a003f5858c425112de057 100644 (file)
@@ -62,7 +62,7 @@ local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek
 local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap
 local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr
 local bit = require("bit")
-local band, shl, shr = bit.band, bit.lshift, bit.rshift
+local band, shl, shr, tohex = bit.band, bit.lshift, bit.rshift, bit.tohex
 local sub, gsub, format = string.sub, string.gsub, string.format
 local byte, char, rep = string.byte, string.char, string.rep
 local type, tostring = type, tostring
@@ -135,6 +135,7 @@ local function dump_mcode(tr)
   local mcode, addr, loop = tracemc(tr)
   if not mcode then return end
   if not disass then disass = require("jit.dis_"..jit.arch) end
+  if addr < 0 then addr = addr + 2^32 end
   out:write("---- TRACE ", tr, " mcode ", #mcode, "\n")
   local ctx = disass.create(mcode, addr, dumpwrite)
   ctx.hexdump = 0
@@ -609,7 +610,7 @@ local function dump_texit(tr, ex, ngpr, nfpr, ...)
       end
     else
       for i=1,ngpr do
-       out:write(format(" %08x", regs[i]))
+       out:write(" ", tohex(regs[i]))
        if i % 8 == 0 then out:write("\n") end
       end
     end