import Mate.BasicBlocks
import {-# SOURCE #-} Mate.MethodPool
import Mate.Types
+import Mate.Utilities
import Mate.Debug
import Mate.GarbageAlloc
import Mate.NativeSizes
let wn_iftable = fromIntegral $ ptrToIntPtr iftable :: NativeWord
-- store interface-table at offset 0 in method-table
pokeElemOff (intPtrToPtr $ fromIntegral mbase) 0 wn_iftable
- printfCp "staticmap: %s @ %s\n" (show staticmap) (toString path)
- printfCp "fieldmap: %s @ %s\n" (show fieldmap) (toString path)
- printfCp "methodmap: %s @ %s\n" (show methodmap) (toString path)
- printfCp "mbase: 0x%08x\n" mbase
- printfCp "interfacemethod: %s @ %s\n" (show immap) (toString path)
+ let strpath = toString path
+#ifdef DBG_CLASS
+ hexDumpMap ("staticmap @ " ++ strpath) staticmap
+ hexDumpMap ("fieldmap @ " ++ strpath) fieldmap
+ hexDumpMap ("methodmap @ " ++ strpath) methodmap
+ hexDumpMap ("interfacemap @ " ++ strpath) immap
+#endif
+ printfCp "mbase: 0x%08x\n" mbase
printfCp "iftable: 0x%08x\n" wn_iftable
virtual_map <- getVirtualMap
setVirtualMap $ M.insert mbase path virtual_map
import Mate.Types
import Mate.NativeSizes
+#ifdef DEBUG
+import Text.Printf
+#endif
buildMethodID :: Class Direct -> Word16 -> MethodInfo
buildMethodID cls idx = MethodInfo (ntName nt) rc (ntSignature nt)
lookupMethodSig :: B.ByteString -> MethodSignature -> Class Direct -> Maybe (Method Direct)
lookupMethodSig name sig cls =
find (\x -> methodName x == name && methodSignature x == sig) $ classMethods cls
+
+hexDumpMap :: Integral v => String -> M.Map B.ByteString v -> IO ()
+#ifdef DEBUG
+hexDumpMap header mmap = do
+ let printValue :: B.ByteString -> IO ()
+ printValue key = printf "\t%-70s: 0x%08x\n" (toString key) val
+ where val = fromIntegral (mmap M.! key) :: NativeWord
+ printf "%s\n" header
+ mapM_ printValue (M.keys mmap)
+#else
+hexDumpMap _ _ = return ()
+#endif