Commit e15d5d6b authored by Bernd Brassel's avatar Bernd Brassel
Browse files

integration of new debugger

parent b3f0d761
......@@ -10,10 +10,12 @@ CYMAKEBIN = $(shell which cymake)
########################################################
BIN = bin/
SRC = src/
SRC_DIR = src
SRC = $(SRC_DIR)/
DOC = doc/
LIB = $(SRC)lib/
TOOLS = $(SRC)tools/
TOOLS_DIR = $(SRC)tools
TOOLS = $(TOOLS_DIR)/
DIST = dist/
THIS = ../kics/
ORACLE = $(SRC)oracle/
......@@ -26,6 +28,8 @@ KICSSUB = $(CURRYSUB)kics/
## calls to compilers
########################################################
HC_OPTS = -i$(SRC_DIR) -i$(TOOLS_DIR)
GHCCALL = $(GHCBIN) --make -fglasgow-exts -H500m
KGHC = $(GHCCALL) -i$(LIBS)
GHC = $(GHCCALL) -i$(SRC)
......@@ -33,22 +37,25 @@ CY = $(CYMAKEBIN) -e
LIBS = $(shell $(BIN)kicslib)
KICS = $(BIN)kics -nouserlibpath -v 6 -make
SRCS = $(SRC)kics.hs $(SRC)kicsi.hs $(SRC)Generate.hs $(SRC)kicslib.hs
########################################################
## the make destinations
########################################################
all: $(SRC)InstallDir.hs $(BIN)generate $(BIN)kicslib $(BIN)kics $(BIN)kicsi libs cpns www tools
all: $(SRC)InstallDir.hs $(BIN)generate $(BIN)kicslib $(BIN)kics \
$(BIN)kicsi libs cpns www tools
.PHONY: tools
tools: $(SRC)InstallDir.hs $(BIN)makeExternalInterface $(BIN)prettyflat\
$(BIN)currytest $(BIN)prettyacy
$(BIN)generate: $(SRC)InstallDir.hs $(SRC)Generate.hs $(SRC)CurryToHaskell.hs $(SRC)PreTrans.hs
$(BIN)generate: $(SRC)Generate.hi
$(GHC) $(SRC)Generate.hs -o $(BIN)generate
$(BIN)generate $(SRC)
$(SRC)$(KICSSUB)AutoGenerated1.hs: $(BIN)generate
$(SRC)$(KICSSUB)AutoGenerated2.hs: $(BIN)generate
$(BIN)generate $(SRC)
$(SRC)InstallDir.hs: prerequisites
@echo "module InstallDir where" > $(SRC)InstallDir.hs.tmp
......@@ -75,24 +82,27 @@ ifeq (,$(findstring cymake,$(CYMAKEBIN)))
endif
$(BIN)kicslib: $(SRC)InstallDir.hs $(SRC)kicslib.hs $(SRC)Config.hs
$(BIN)kicslib: $(SRC)kicslib.hi
mkdir -p bin
$(GHC) $(SRC)kicslib -o $(BIN)kicslib
$(BIN)makeExternalInterface: $(SRC)InstallDir.hs $(BIN)kicslib
$(KGHC) $(SRC)MakeExternalInterface -o $(BIN)makeExternalInterface
$(BIN)kicsi: $(BIN)kicslib $(SRC)CurryToHaskell.hs $(SRC)kicsi.hs $(SRC)PreTrans.hs
$(SRC)MyReadline.hs:
ifeq (,$(filter readline% editline%,$(shell $(GHCBIN)-pkg list readline)))
@echo neither readline nor editline package found
cp $(SRC)NoReadline.make $(SRC)MyReadline.hs
cp $(SRC)NoReadline.make $(SRC)MyReadline.hs
else
@echo readline or editline package found
cp $(SRC)WithReadline.make $(SRC)MyReadline.hs
endif
$(BIN)kicsi: $(BIN)kicslib $(SRC)kicsi.o $(SRC)MyReadline.hs
$(KGHC) $(SRC)kicsi -o $(BIN)kicsi
$(BIN)kics: $(BIN)kicslib $(SRC)CurryToHaskell.hs $(SRC)PreTrans.hs $(SRC)kics.hs
$(BIN)kics: $(BIN)kicslib $(SRC)kics.hi
$(KGHC) $(SRC)kics -o $(BIN)kics
.PHONY: runtime
......@@ -100,8 +110,7 @@ runtime: $(SRC)InstallDir.hs
$(GHC) -fno-cse $(SRC)Curry.hs
.PHONY: libs
libs: $(BIN)kics $(SRC)$(KICSSUB)AutoGenerated1.hs $(SRC)$(KICSSUB)AutoGenerated2.hs \
runtime $(BIN)makeacy
libs: $(BIN)kics $(SRC)$(KICSSUB)AutoGenerated2.hs runtime $(BIN)makeacy
$(KICS) $(LIB)All_Libraries
cd $(LIB); ../../bin/makeacy All_Libraries
......@@ -194,3 +203,76 @@ $(BIN)makeacy: $(TOOLS)MakeAcy.curry $(BIN)kics
.PHONY:
test: $(BIN)currytest
cd examples;./doTest
depend : $(SRC)MyReadline.hs
ghc -M $(HC_OPTS) $(SRCS)
%.hi: %.o %.hs
ghc -c $(HC_OPTS) $*.hs
# DO NOT DELETE: Beginning of Haskell dependencies
src/MyReadline.o : src/MyReadline.hs
src/InstallDir.o : src/InstallDir.hs
src/KicsSubdir.o : src/KicsSubdir.hs
src/MetaProgramming/FlatCurry.o : src/MetaProgramming/FlatCurry.hs
src/MetaProgramming/FlatCurry.o : src/KicsSubdir.hi
src/MetaProgramming/FlatCurryGoodies.o : src/MetaProgramming/FlatCurryGoodies.hs
src/MetaProgramming/FlatCurryGoodies.o : src/MetaProgramming/FlatCurry.hi
src/Simplification.o : src/Simplification.hs
src/Simplification.o : src/MetaProgramming/FlatCurryGoodies.hi
src/Simplification.o : src/MetaProgramming/FlatCurryGoodies.hi
src/Simplification.o : src/MetaProgramming/FlatCurry.hi
src/PreTrans.o : src/PreTrans.hs
src/PreTrans.o : src/MetaProgramming/FlatCurryGoodies.hi
src/PreTrans.o : src/MetaProgramming/FlatCurry.hi
src/FunctionalProg.o : src/FunctionalProg.hs
src/Brace.o : src/Brace.hs
src/ShowFlatCurry.o : src/ShowFlatCurry.hs
src/ShowFlatCurry.o : src/Brace.hi
src/ShowFlatCurry.o : src/MetaProgramming/FlatCurry.hi
src/ShowFunctionalProg.o : src/ShowFunctionalProg.hs
src/ShowFunctionalProg.o : src/Brace.hi
src/ShowFunctionalProg.o : src/FunctionalProg.hi
src/Names.o : src/Names.hs
src/Names.o : src/ShowFunctionalProg.hi
src/SafeCalls.o : src/SafeCalls.hs
src/Config.o : src/Config.hs
src/Config.o : src/KicsSubdir.hi
src/Config.o : src/Names.hi
src/Config.o : src/MetaProgramming/FlatCurry.hi
src/Config.o : src/SafeCalls.hi
src/Config.o : src/InstallDir.hi
src/CurryToHaskell.o : src/CurryToHaskell.hs
src/CurryToHaskell.o : src/Names.hi
src/CurryToHaskell.o : src/Names.hi
src/CurryToHaskell.o : src/Config.hi
src/CurryToHaskell.o : src/Brace.hi
src/CurryToHaskell.o : src/SafeCalls.hi
src/CurryToHaskell.o : src/Simplification.hi
src/CurryToHaskell.o : src/PreTrans.hi
src/CurryToHaskell.o : src/ShowFunctionalProg.hi
src/CurryToHaskell.o : src/FunctionalProg.hi
src/CurryToHaskell.o : src/MetaProgramming/FlatCurryGoodies.hi
src/CurryToHaskell.o : src/MetaProgramming/FlatCurry.hi
src/kicslib.o : src/kicslib.hs
src/kicslib.o : src/Config.hi
src/Generate.o : src/Generate.hs
src/Generate.o : src/Names.hi
src/Generate.o : src/FunctionalProg.hi
src/Generate.o : src/CurryToHaskell.hi
src/Generate.o : src/Config.hi
src/Generate.o : src/SafeCalls.hi
src/kicsi.o : src/kicsi.hs
src/kicsi.o : src/MyReadline.hi
src/kicsi.o : src/Names.hi
src/kicsi.o : src/Config.hi
src/kicsi.o : src/ShowFlatCurry.hi
src/kicsi.o : src/MetaProgramming/FlatCurryGoodies.hi
src/kicsi.o : src/MetaProgramming/FlatCurry.hi
src/kicsi.o : src/SafeCalls.hi
src/kicsi.o : src/CurryToHaskell.hi
src/kics.o : src/kics.hs
src/kics.o : src/SafeCalls.hi
src/kics.o : src/CurryToHaskell.hi
src/kics.o : src/Config.hi
# DO NOT DELETE: End of Haskell dependencies
......@@ -53,6 +53,7 @@ parseOptions opts ("-i":"bf":xs) = parseOptions (opts{pm=Interactive BF}) xs
parseOptions opts ("-o":x:xs) = parseOptions (opts{target=x}) xs
parseOptions opts ("-d":xs) = parseOptions (opts{debug=True,doNotUseInterface=True}) xs
parseOptions opts ("--debug":xs) = parseOptions opts ("-d":xs)
parseOptions opts ("--debugger":d:xs) = parseOptions opts{debugger=Just d} xs
parseOptions opts [] = Right opts
parseOptions opts [x] = Right (opts{filename=x,mainModule=takeBaseName x})
parseOptions _ (x:_) = Left ("unrecognized option: "++x)
......@@ -83,6 +84,8 @@ usage problem = do
putStrLn "-i df | interactively show solutions depth first"
putStrLn "-i bf | interactively show solutions breadth first"
putStrLn "-o | name of output file"
putStrLn "-d | turn on debug mode"
putStrLn "--debugger <n> | use debug tool <n>"
error "compilation aborted"
......@@ -200,7 +203,7 @@ ghcCall opts@Opts{filename=fn} =
callnorm (ghc opts
++makeGhc (make opts)
++" -i"++show (toPathList
(concatMap (\dn -> [addKicsSubdir dn,dn])
(pathWithSubdirs
(unpath [installDir,"src"]:
unpath [installDir,"src","oracle"]:
libpath opts)))++" "
......@@ -240,7 +243,7 @@ stricthsCall opts =
mkStrictCall opts =
callnorm (installDir++"/bin/mkstrict "
++ mainModule opts++" "
++ filename opts++" "
{-++ (if make opts then "-m " else "")
++ (if force opts then "-f " else "")
++ filename opts-})
......
{-# OPTIONS -cpp #-}
{-# LANGUAGE FlexibleInstances #-}
module SafeCalls where
......
......@@ -257,7 +257,7 @@ getType expr state opts = do
genReqModule (loadedFiles state) expr
cymake (opts{filename=reqModuleName})
p <- safeIO (readFlatCurry reqModuleFile)
let (f:_) = filter ((=="expression") . snd . funcName) (progFuncs p)
let (f:_) = filter ((==mainExpr) . snd . funcName) (progFuncs p)
return (funcType f))
maybe (return ()) (putStrLn . showCurryType snd False) t
interactive state opts
......@@ -275,15 +275,19 @@ toMode _ ["or"] = OrBased
toMode _ ["ctc"] = CTC
toMode m _ = m
mainExpr = "expression"
requestExpr state opts line = do
safe $ do
let ls = loadedFiles state
mainMod = if null ls then "Prelude" else head ls
--safeSystem (verbosity opts >= 5)
-- ("rm -f request Request.fcy "++reqMod ++".o ")
requestFile <- genReqModule (loadedFiles state) line
let compileOpts = (opts{executable=True,filename=requestFile,
mainFunc="expression",
mainModule = if null ls then "Prelude" else head ls,
mainFunc=mainExpr,
mainModule = mainMod,
make=False})
startCompilation compileOpts
let call = timing state (requestCall state opts)
......@@ -303,19 +307,20 @@ requestExpr state opts line = do
filename="StrictRequest"})
safeSystem (verbosity opts >= 5)
(ghcCall opts{make=False,eval=True,
ghcOpts=ghcOpts opts++" -e expression ",
ghcOpts=ghcOpts opts++" -e "++mainExpr++" ",
filename="StrictRequest"})
else do
safeSystem (verbosity opts >= 5)
(mkStrictCall compileOpts{filename=inKicsSubdir reqModuleName,
make=True})
genDebugModule opts{mainModule=mainMod} (loadedFiles state) line
safeSystem (verbosity opts >= 5)
(ghcCall opts{make=True,ghcOpts=ghcOpts opts++" -O2 ",
filename=mkStrictName reqModuleName})
safeSystem (verbosity opts >= 5)
filename=inKicsSubdir debugModuleName})
{-safeSystem (verbosity opts >= 5)
(ghcCall opts{make=False,eval=True,
ghcOpts=ghcOpts opts++" -e expression ",
filename=mkStrictName reqModuleName})
filename=mkStrictName reqModuleName})-}
interactive state opts
......@@ -331,7 +336,7 @@ reqModuleFile = replaceExtension (inKicsSubdir reqModuleName) ".fcy"
genReqModule fs line =
safeIO (writeKicsFile (replaceExtension reqModuleName ".curry")
(imports fs++"\n\nexpression = "++ line))
(imports fs++"\n\n"++mainExpr++" = "++ line))
timing (State{time=True}) s = "time "++s
timing _ s = s
......@@ -348,12 +353,27 @@ isExtAlpha '_' = True
isExtAlpha '\'' = True
isExtAlpha c = isDigit c || isAlpha c
reqMod = modName "Request"
moduleHead = "module Request where\n"
reqMod = modName reqModuleName
imports :: [String] -> String
imports = concatMap ("\nimport "++)
------------------------------
-- triggering the debug tool
------------------------------
debugModuleName = "debug.hs"
genDebugModule Opts{debugger=Just tool,mainModule=mod} fs line = do
let modName = debugModuleName
modImports = imports $ "Debugger.DebugMonad":
("Debugger.Tools."++tool++"."++tool++"Monad"):
map mkStrictName ((reqModuleName++" as S"):fs)
modCont = modImports ++
"\n\nmain = do\n\
\ run (eval S.strict_"++mainExpr++") \""++mod++"\""
safeIO $ putStrLn modName
safeIO $ putStrLn modCont
safeIO (writeKicsFile modName modCont)
\ No newline at end of file
......@@ -8,7 +8,8 @@
module FileGoodies(separatorChar,pathSeparatorChar,suffixSeparatorChar,
isAbsolute,dirName,baseName,splitDirectoryBaseName,
stripSuffix,fileSuffix,splitBaseName,splitPath,
findFileInPath,lookupFileInPath,getFileInPath) where
findFileInPath,lookupFileInPath,getFileInPath,
replaceFileName) where
import Directory
import List(intersperse)
......@@ -106,3 +107,10 @@ getFileInPath file suffixes path = do
concat (intersperse [pathSeparatorChar] path))
return
mbfile
replaceFileName :: (String -> String) -> String -> String
replaceFileName f s = let (dir,fn) = splitDirectoryBaseName s
in case dir of
"." -> f fn
_ -> dir++separatorChar:f fn
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment