mate.static
mate.dbg
mate.prof
+mate.log
tags
*.swp
*_stub.c
$ make tests/Fib.test
-for testing with a debug build, use
-$ DBGFLAGS='-DDBG_JIT -DDBG_BB' make tests/Fib.dbg
+for testing with a debug build, use edit Mate/Debug.hs and set
+`mateDEBUG = True' and build again. Output is in `mate.log'
-`make clean' is needed if you change $DBGFLAGS.
-for all available flags, see `debug.h'.
-
-
-for debugging with gdb, modify Mate/MethodPool.hs and make a debug build with at
-least -DDBG_JIT enabled, then use
+for debugging with gdb, modify Mate/MethodPool.hs and enable Debugging in
+Mate/Debug.hs, then use
$ make tests/Fib.gdb
and follow the instructions in the source file.
@mkdir -p $(B_STATIC)
$(GHCCALL) $(B_STATIC) -static
-%.dbg: %.class mate.dbg
- ./mate.dbg $(basename $<)
-
-%.gdb: %.class mate.dbg
- gdb -x .gdbcmds -q --args mate.dbg $(basename $<) +RTS -V0 --install-signal-handlers=no
-
-ifeq (${DBGFLAGS},)
-DEBUGFLAGS = -DDBG_JIT -DDBG_MP
-else
-DEBUGFLAGS = ${DBGFLAGS}
-endif
-mate.dbg: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o $(CLASS_FILES)
- @mkdir -p $(B_DEBUG)/{ffi,Mate,}
- gcc -Wall $(DEBUGFLAGS) -O0 -c ffi/trap.c -o $(B_DEBUG)/ffi/trap.o
- ghc --make $(DEBUGFLAGS) $(GHC_OPT) Mate.hs $(B_DEBUG)/ffi/trap.o -o $@ $(GHC_LD) -outputdir $(B_DEBUG)
+%.gdb: %.class mate
+ gdb -x .gdbcmds -q --args mate $(basename $<) +RTS -V0 --install-signal-handlers=no
clean:
- rm -rf $(BUILD) mate mate.static mate.dbg ffi/native.o \
+ rm -rf $(BUILD) mate mate.static ffi/native.o \
tests/*.class Mate/*_stub.* \
jmate/lang/*.class jmate/io/*.class java/io/*.class \
java/lang/{Integer,Character,String,System}.class \
ghc -I. -fforce-recomp -fobject-code $(PACKAGES) Mate.hs -outputdir $(B_STATIC) -e :ctags $(GHC_CPP)
hlint:
- @# hlint isn't able to evaluate CPP comments correctly *sigh*
- @cp debug.h debug_tmp.h
- @# so we remove them "by hand", for hlint
- @gcc -E -x c -fpreprocessed -dD -E debug_tmp.h | grep -v 'debug_tmp.h' > debug.h
- @# ignore error code from hlint
- -hlint Mate.hs Mate/
- @mv debug_tmp.h debug.h
+ hlint Mate.hs Mate/
scratch: mate $(wildcard jmate/lang/*.java) scratch/GCTest.java
javac $(wildcard jmate/lang/*.java)
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
-#include "debug.h"
module Main where
import System.Environment
import qualified Data.ByteString.Lazy as B
import Control.Monad
-#ifdef DEBUG
-import Text.Printf
-#endif
import JVM.ClassFile
import Java.JAR
import Mate.Types
import Mate.ClassPool
import Mate.NativeMachine
+import Mate.Debug
import Mate.GC.Boehm
executeMain :: B.ByteString -> Class Direct -> IO ()
executeMain bclspath cls = do
initGC --required on some platforms. [todo bernhard: maybe this should be moved somewhere else - maybe at a global place where vm initialization takes place
+
let methods = classMethods cls; methods :: [Method Direct]
case find (\x -> methodName x == "main") methods of
Just m -> do
rawmethod <- parseMethod cls "main" $ methodSignature m
entry <- compileBB rawmethod mi
addMethodRef entry mi [bclspath]
-#ifdef DEBUG
- printf "executing `main' now:\n"
-#endif
+ printfInfo "executing `main' now:\n"
executeFuncPtr entry
Nothing -> error "main not found"
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
-#include "debug.h"
module Mate.BasicBlocks(
BlockID,
BasicBlock,
BBEnd,
MapBB,
Method,
-#ifdef DBG_BB
printMapBB,
-#endif
parseMethod,
testCFG -- added by hs to perform benches from outside
)where
import Mate.Debug
import Mate.Utilities
-#ifdef DEBUG
-import Text.Printf
-#endif
-
-- for immediate representation to determine BBs
type Offset = (Int, Maybe BBEnd) -- (offset in bytecode, offset to jump target)
type OffIns = (Offset, Instruction)
-#ifdef DBG_BB
printMapBB :: MapBB -> IO ()
printMapBB hmap = do
- putStr "BlockIDs: "
+ printfBb "BlockIDs: "
let keys = M.keys hmap
- mapM_ (putStr . (flip (++)) ", " . show) keys
- putStrLn "\n\nBasicBlocks:"
+ mapM_ (printfBb. (flip (++)) ", " . show) keys
+ printfBb "\n\nBasicBlocks:"
printMapBB' keys hmap
where
printMapBB' :: [BlockID] -> MapBB -> IO ()
printMapBB' [] _ = return ()
printMapBB' (i:is) hmap' = case M.lookup i hmap' of
Just bb -> do
- putStrLn $ "Block " ++ (show i)
- mapM_ putStrLn (map ((++) "\t" . show) $ code bb)
- case successor bb of
- Return -> putStrLn ""
- FallThrough t1 -> putStrLn $ "Sucessor: " ++ (show t1) ++ "\n"
- OneTarget t1 -> putStrLn $ "Sucessor: " ++ (show t1) ++ "\n"
- TwoTarget t1 t2 -> putStrLn $ "Sucessor: " ++ (show t1) ++ ", " ++ (show t2) ++ "\n"
+ printfBb $ "Block " ++ (show i)
+ mapM_ printfBb (map ((++) "\t" . show) $ code bb)
+ printfBb $ case successor bb of
+ Return -> ""
+ FallThrough t1 -> "Sucessor: " ++ (show t1) ++ "\n"
+ OneTarget t1 -> "Sucessor: " ++ (show t1) ++ "\n"
+ TwoTarget t1 t2 -> "Sucessor: " ++ (show t1) ++ ", " ++ (show t2) ++ "\n"
printMapBB' is hmap
Nothing -> error $ "BlockID " ++ show i ++ " not found."
-#endif
-#if 0
-#ifdef DBG_BB
+{-
testInstance :: String -> B.ByteString -> MethodSignature -> IO ()
testInstance cf method sig = do
cls <- parseClassFile cf
hmap <- parseMethod cls method sig
printMapBB hmap
-#endif
-#ifdef DBG_BB
test_main :: IO ()
test_main = do
test_01
test_02 = testInstance "./tests/While.class" "f"
test_03 = testInstance "./tests/While.class" "g"
test_04 = testInstance "./tests/Fac.class" "fac"
-#endif
-#endif
+-}
parseMethod :: Class Direct -> B.ByteString -> MethodSignature -> IO RawMethod
let argscount = methodGetArgsCount nametype + (if isStatic then 0 else 1)
let msig = methodSignature method
- printfBb "BB: analysing \"%s\"\n" $ toString (methodname `B.append` ": " `B.append` encode msig)
-#ifdef DBG_BB
+ printfBb $ printf "BB: analysing \"%s\"\n" $ toString (methodname `B.append` ": " `B.append` encode msig)
printMapBB mapbb
-#endif
-- small example how to get information about
-- exceptions of a method
-- TODO: remove ;-)
let (Just m) = lookupMethodSig methodname sig cls
case attrByName m "Code" of
Nothing ->
- printfBb "exception: no handler for this method\n"
+ printfBb $ printf "exception: no handler for this method\n"
Just exceptionstream ->
- printfBb "exception: \"%s\"\n" (show $ codeExceptions $ decodeMethod exceptionstream)
+ printfBb $ printf "exception: \"%s\"\n" (show $ codeExceptions $ decodeMethod exceptionstream)
return $ RawMethod mapbb locals stacks argscount codelen
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
-#include "debug.h"
module Mate.ClassPool (
getClassInfo,
classLoaded,
import Data.String.Utils
import Control.Monad
-#ifdef DEBUG
-import Text.Printf
-#endif
-#ifdef DBG_CLASS
-import JVM.Dump
-#endif
+-- import JVM.Dump
import Foreign.Ptr
import Foreign.C.Types
Just cm -> return cm
Nothing -> do
cfile <- readClassFile $ toString path
-#ifdef DBG_CLASS
- dumpClass cfile
-#endif
+ -- TODO(bernhard): hDumpClass
+ -- dumpClass cfile
-- load all interfaces, which are implemented by this class
sequence_ [ loadInterface i | i <- interfaces cfile ]
superclass <- if path /= "java/lang/Object"
let wn_iftable = fromIntegral $ ptrToIntPtr iftable :: NativeWord
-- store interface-table at offset 0 in method-table
pokeElemOff (intPtrToPtr $ fromIntegral mbase) 0 wn_iftable
-#ifdef DBG_CLASS
- let strpath = toString path
- 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
+ let hexDumpMap :: Integral v => String -> M.Map B.ByteString v -> IO ()
+ hexDumpMap header mmap = do
+ let printValue :: B.ByteString -> IO ()
+ printValue key = printfCp $ printf "\t%-70s: 0x%08x\n" (toString key) val
+ where val = fromIntegral (mmap M.! key) :: NativeWord
+ printfCp $ printf "%s\n" header
+ mapM_ printValue (M.keys mmap)
+ if mateDEBUG
+ then do
+ let strpath = toString path
+ hexDumpMap ("staticmap @ " ++ strpath) staticmap
+ hexDumpMap ("fieldmap @ " ++ strpath) fieldmap
+ hexDumpMap ("methodmap @ " ++ strpath) methodmap
+ hexDumpMap ("interfacemap @ " ++ strpath) immap
+ printfCp $ printf "mbase: 0x%08x\n" mbase
+ printfCp $ printf "iftable: 0x%08x\n" wn_iftable
+ else return ()
virtual_map <- getVirtualMap
setVirtualMap $ M.insert mbase path virtual_map
case M.lookup path imap of
Just _ -> return ()
Nothing -> do
- printfCp "interface: loading \"%s\"\n" $ toString path
+ printfCp $ printf "interface: loading \"%s\"\n" $ toString path
cfile <- readClassFile $ toString path
-- load "superinterfaces" first
sequence_ [ loadInterface i | i <- interfaces cfile ]
let mi = MethodInfo "<clinit>" path (methodSignature m)
entry <- compileBB rawmethod mi
addMethodRef entry mi [path]
- printfCp "executing static initializer from %s now\n" (toString path)
+ printfCp $ printf "executing static initializer from %s now\n" (toString path)
executeFuncPtr entry
- printfCp "static initializer from %s done\n" (toString path)
+ printfCp $ printf "static initializer from %s done\n" (toString path)
Nothing -> return ()
class_map' <- getClassMap
rcf [] = error $ "readClassFile: Class \"" ++ show path ++ "\" not found."
rcf (Directory pre:xs) = do
let cf = pre ++ path ++ ".class"
- printfCp "rcf: searching @ %s for %s\n" (show pre) (show path)
+ printfCp $ printf "rcf: searching @ %s for %s\n" (show pre) (show path)
b <- doesFileExist cf
if b
then parseClassFile cf
else rcf xs
rcf (JAR p:xs) = do
- printfCp "rcf: searching %s in JAR\n" (show path)
+ printfCp $ printf "rcf: searching %s in JAR\n" (show path)
entry <- getEntry p path
case entry of
Just (LoadedJAR _ cls) -> return cls
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
-#include "debug.h"
-module Mate.Debug where
-
-{- we cannot use `PrintfType' from Text.Printf, as it isn't exported.
- - so we implement a `VarArgsFake' here.
- - http://www.haskell.org/haskellwiki/Varargs -}
-class VarArgsFake t where
- varFake :: [String] -> t
-
-instance VarArgsFake (IO a) where
- varFake _ = return undefined
-
-instance (Show a, VarArgsFake r) => VarArgsFake (a -> r) where
- varFake _ _ = varFake []
-
--- note: with -O2 GHC is able to completely optimize away such a `printfFake' call
-printfFake :: String -> (VarArgsFake t) => t
-printfFake _ = varFake []
-
-
--- see counterpart at `debug.h'
-#ifndef DBG_JIT
-printfJit :: String -> (VarArgsFake t) => t
-printfJit = printfFake
-#endif
-
-#ifndef DBG_BB
-printfBb :: String -> (VarArgsFake t) => t
-printfBb = printfFake
-#endif
-
-#ifndef DBG_MP
-printfMp :: String -> (VarArgsFake t) => t
-printfMp = printfFake
-#endif
-
-#ifndef DBG_CP
-printfCp :: String -> (VarArgsFake t) => t
-printfCp = printfFake
-#endif
-
-#ifndef DBG_STR
-printfStr :: String -> (VarArgsFake t) => t
-printfStr = printfFake
-#endif
+module Mate.Debug
+ ( printfJit
+ , printfBb
+ , printfMp
+ , printfCp
+ , printfStr
+ , printfInfo
+ , mateDEBUG
+ , printf -- TODO: delete me
+ ) where
+
+import Text.Printf
+import System.IO
+import System.IO.Unsafe
+
+
+{-# NOINLINE logHandle #-}
+-- TODO(bernhard): use MVar if threaded
+logHandle :: Handle
+logHandle = unsafePerformIO $ openFile "mate.log" WriteMode
+
+{-# INLINE mateDEBUG #-}
+mateDEBUG :: Bool
+mateDEBUG = False
+
+{-# INLINE printString #-}
+printString :: String -> String -> IO ()
+printString prefix str = if mateDEBUG
+ then hPutStr logHandle . (++) prefix $ str
+ else return ()
+
+
+printfJit, printfBb, printfMp, printfCp, printfStr, printfInfo :: String -> IO ()
+{-
+-- TODO(bernhard):
+-- http://stackoverflow.com/questions/12123082/function-composition-with-text-printf-printf
+-}
+printfJit = printString "Jit: "
+printfBb = printString "Bb: "
+printfMp = printString "Mp: "
+printfCp = printString "Cp: "
+printfStr = printString "Str: "
+printfInfo = printString "Info: "
{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE CPP #-}
-#include "debug.h"
module Mate.GarbageAlloc(
mallocClassData,
mallocStringGC,
import Mate.GC.Boehm
-#ifdef DBG_STR
-import Text.Printf
-#endif
import Mate.Debug
-- unified place for allocating Memory
mallocClassData :: Int -> IO (Ptr a)
mallocClassData size = do
- printfStr "mallocClassData: %d\n" size
+ printfStr $ printf "mallocClassData: %d\n" size
mem <- mallocBytes size
addRootGC mem (plusPtr mem size)
return mem
mallocStringGC :: Int -> IO (Ptr a)
mallocStringGC size = do
- printfStr "mallocString: %d\n" size
+ printfStr $ printf "mallocString: %d\n" size
mallocBytesGC size
foreign export ccall mallocObjectGC :: Int -> IO CPtrdiff
mallocObjectGC :: Int -> IO CPtrdiff
mallocObjectGC size = do
ptr <- mallocBytesGC size
- printfStr "mallocObject: %d\n" size
+ printfStr $ printf "mallocObject: %d\n" size
return $ fromIntegral $ ptrToIntPtr ptr
mallocObjectUnmanaged :: Int -> IO CPtrdiff
mallocObjectUnmanaged size = do
ptr <- mallocBytes size
- printfStr "mallocObjectUnmanged: %d\n" size
+ printfStr $ printf "mallocObjectUnmanged: %d\n" size
return $ fromIntegral $ ptrToIntPtr ptr
mallocStringUnmanaged :: Int -> IO (Ptr a)
mallocStringUnmanaged size = do
- printfStr "mallocStringUnamaged: %d\n" size
+ printfStr $ printf "mallocStringUnamaged: %d\n" size
mallocBytes size
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ForeignFunctionInterface #-}
-#include "debug.h"
module Mate.MethodPool where
import Data.Binary
import JVM.ClassFile
import Harpy
-#ifdef DBG_JIT
import Harpy.X86Disassembler
-#endif
-
-#ifdef DEBUG
-import Text.Printf
-#endif
import Mate.BasicBlocks
import Mate.Types
entryaddr <- case M.lookup mi' mmap of
Nothing -> do
cls <- getClassFile cm
- printfMp "getMethodEntry(from 0x%08x): no method \"%s\" found. compile it\n" w32_from (show mi')
+ printfMp $ printf "getMethodEntry(from 0x%08x): no method \"%s\" found. compile it\n" w32_from (show mi')
mm <- lookupMethodRecursive method sig [] cls
case mm of
Just (mm', clsnames, cls') -> do
parenth = replace "(" "_" $ replace ")" "_" $ toString $ encode sig
sym2 = replace ";" "_" $ replace "/" "_" parenth
symbol = sym1 ++ "__" ++ smethod ++ "__" ++ sym2
- printfMp "native-call: symbol: %s\n" symbol
+ printfMp $ printf "native-call: symbol: %s\n" symbol
nf <- loadNativeFunction symbol
setMethodMap $ M.insert mi' nf mmap
return nf
let ((entry, _, _, new_tmap), _) = right
setTrapMap $ tmap `M.union` new_tmap -- prefers elements in tmap
- printfJit "generated code of \"%s\" from \"%s\":\n" (toString $ methName methodinfo) (toString $ methClassName methodinfo)
- printfJit "\tstacksize: 0x%04x, locals: 0x%04x\n" (rawStackSize rawmethod) (rawLocals rawmethod)
-#ifdef DBG_JIT
- mapM_ (printfJit "%s\n" . showAtt) (snd right)
-#endif
- printfJit "\n\n"
+ printfJit $ printf "generated code of \"%s\" from \"%s\":\n" (toString $ methName methodinfo) (toString $ methClassName methodinfo)
+ printfJit $ printf "\tstacksize: 0x%04x, locals: 0x%04x\n" (rawStackSize rawmethod) (rawLocals rawmethod)
+ if mateDEBUG
+ then mapM_ (printfJit . printf "%s\n" . showAtt) (snd right)
+ else return ()
+ printfJit $ printf "\n\n"
-- UNCOMMENT NEXT LINES FOR GDB FUN
-- if (toString $ methName methodinfo) == "thejavamethodIwant2debug"
-- then putStrLn "press CTRL+C now for setting a breakpoint. then `c' and ENTER for continue" >> getLine
import Mate.X86CodeGen
import Mate.X86TrapHandling
import Mate.NativeSizes
-
#else
-#error "no other arch supported yet :/"
+
+-- HACK, for ghc-mod ...
+import Mate.X86CodeGen
+import Mate.X86TrapHandling
+import Mate.NativeSizes
#endif
ptrSize = 4
longSize = 8
+type NativeWord = Word32
+#else
+-- HACK, for ghc-mod ...
+ptrSize = undefined
+longSize = undefined
type NativeWord = Word32
#endif
-{-# LANGUAGE CPP #-}
module Mate.RegisterAllocation where
-
-#include "debug.h"
-
import Data.List
import Data.Maybe
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
-#include "debug.h"
module Mate.Strings (
getUniqueStringAddr
) where
import qualified Data.Map as M
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Internal as BI
-#ifdef DEBUG
-import Text.Printf
-#endif
import JVM.ClassFile
-}
-- build object layout
fsize <- getObjectSize "java/lang/String"
- printfStr "string: fsize: %d (should be 4 * 5)\n" fsize
+ printfStr $ printf "string: fsize: %d (should be 4 * 5)\n" fsize
tblptr <- mallocObjectUnmanaged $ fromIntegral fsize
let ptr = intPtrToPtr (fromIntegral tblptr) :: Ptr CPtrdiff
mtbl <- getMethodTable "java/lang/String"
BI.memset newstr 0 (fromIntegral $ strlen + 5)
arr <- newArray ((map fromIntegral $ B.unpack str) :: [Word8])
copyBytes (plusPtr newstr 4) arr strlen
- printfStr "new str ptr: (%s)@%d\n" (toString str) strlen
+ printfStr $ printf "new str ptr: (%s)@%d\n" (toString str) strlen
let newstr_length = castPtr newstr :: Ptr CPtrdiff
poke newstr_length $ fromIntegral strlen
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Mate.Utilities where
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)
where
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
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ForeignFunctionInterface #-}
-#include "debug.h"
module Mate.X86CodeGen where
import Prelude hiding (and, div)
import Mate.Utilities
import Mate.ClassPool
import Mate.Strings
-#ifdef DEBUG
-import Text.Printf
-#endif
foreign import ccall "&mallocObjectGC"
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ForeignFunctionInterface #-}
-#include "debug.h"
module Mate.X86TrapHandling (
mateHandler,
register_signal
import Mate.ClassPool
import Mate.X86CodeGen
-#ifdef DBG_JIT
-import Text.Printf
-#endif
import Mate.Debug
import Harpy.X86Disassembler
let entry = Just (intPtrToPtr (fromIntegral reip), fixme)
let cgconfig = defaultCodeGenConfig { customCodeBuffer = entry }
(_, Right right) <- runCodeGenWithConfig (withDisasm $ patcher reip) () () cgconfig
- mapM_ (printfJit "patched: %s\n" . showAtt) $ snd right
+ mapM_ (printfJit . printf "patched: %s\n" . showAtt) $ snd right
return reip
withDisasm :: CodeGen e s CPtrdiff -> CodeGen e s (CPtrdiff, [Instruction])
+++ /dev/null
-/* DBG_JIT .... see generated code and CodeGen information
- * DBG_BB ..... BasicBlock information
- * DBG_MP ..... MethodPool.hs
- * DBG_CP ..... ClassPool.hs
- * DBG_STR .... Strings.hs
- * // no printf* defined
- * DBG_TRAP ... show information @ trap.c
- * DBG_CLASS .. dump classfile
- */
-
-/* ooops defines */
-#ifdef BG_ALL
-#define DBG_ALL
-#endif
-
-#ifdef BG_JIT
-#define DBG_JIT
-#endif
-
-#ifdef BG_BB
-#define DBG_BB
-#endif
-
-#ifdef BG_MP
-#define DBG_MP
-#endif
-
-#ifdef BG_CP
-#define DBG_CP
-#endif
-
-#ifdef BG_STR
-#define DBG_STR
-#endif
-
-#ifdef BG_TRAP
-#define DBG_TRAP
-#endif
-
-#ifdef BG_CLASS
-#define DBG_CLASS
-#endif
-
-/* if one constant from above is defined, we want to import
- * libraries like Text.Printf
- * needed for gettting proper `-Wall' output on a release build */
-
-#if defined(DBG_ALL) || defined(DBG_JIT) || defined(DBG_BB) || defined(DBG_MP) || defined(DBG_CP) || defined(DBG_STR)
-#define DEBUG
-#endif
-
-#if defined(DBG_ALL)
-#define DBG_JIT
-#define DBG_BB
-#define DBG_MP
-#define DBG_CP
-#define DBG_STR
-#define DBG_TRAP
-#if 0
-#define DBG_CLASS
-#endif
-#endif
-
-/* it would be awesome if we could just write
- * > printfFake = printf
- * here, but the type can't be infered, since `PrintfType'
- * isn't visible (at least this is my explanation :/).
- * if I'm wrong, move this to `Mate/Debug.hs'
- */
-#ifdef DBG_JIT
-#define printfJit printf
-#endif
-
-#ifdef DBG_BB
-#define printfBb printf
-#endif
-
-#ifdef DBG_MP
-#define printfMp printf
-#endif
-
-#ifdef DBG_CP
-#define printfCp printf
-#endif
-
-#ifdef DBG_STR
-#define printfStr printf
-#endif
#include <stdlib.h>
#include <stddef.h>
-#include "../debug.h"
-
/* TODO(bernhard): use {u,}int* types */
#define __USE_GNU