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

some changes for debugger

parent fc901a77
......@@ -15,13 +15,20 @@ Description: This package builds the Curry to Haskell compiler "kics".
Stability: experimental
extra-source-files:
src/lib/Curry/Module/*.hs.include
Data-Dir: src/lib/Curry/Module/
Data-Files: .curry/*.fcy
.curry/*.fint
.curry/*.efc
.curry/*.acy
.curry/*.uacy
.curry/*.cy
extra-tmp-files:
src/lib/Curry/Module/*.fcy
src/lib/Curry/Module/*.fint
src/lib/Curry/Module/*.efc
src/lib/Curry/Module/*.acy
src/lib/Curry/Module/*.uacy
src/lib/Curry/Module/*.cy
Data-Dir: src/lib/
Data-Files: Curry/Module/*.fcy
Curry/Module/*.fint
Curry/Module/*.efc
Curry/Module/*.acy
Curry/Module/*.uacy
Curry/Module/*.cy
debugOptions.hs
Executable kics
......
......@@ -59,7 +59,11 @@ runKics lbi infile outfile verb = do
let call = callProg verb lbi
datadir = takeDirectory infile
-- nomake not supported
mapM (\ format -> call cymake ["-e",'-':'-':format,"-i"++datadir,infile])
mapM (\ format -> call cymake ["--no-hidden-subdir",
"-e",
'-':'-':format,
"-i"++datadir,
infile])
["flat","extended-flat","acy","uacy","parse-only"]
call (return kics) ["-nomake","-o",outfile,infile]
......
......@@ -11,17 +11,15 @@ build-type: Custom
Synopsis: debug features for kics
Description: This package contains the debugger for the Curry to Haskell compiler "kics".
Stability: experimental
extra-tmp-files: Curry/Module/Oracle*.f*, Curry/Module/.curry
extra-tmp-files: Curry/Module/*.fcy, Curry/Module/*.fint, Curry/DebugModule
extra-source-files:
Curry/Module/*.hs.include
biosphere/src/Curry/Module/*.hs.include
prophecy/Curry/Module/*.hs.include
Data-Dir: Curry/Module/
Data-Dir: .
Data-Files:
*.fcy
*.fint
.curry/*.fcy
.curry/*.fint
Curry/Module/*.fcy
Curry/Module/*.fint
Library
hs-source-dirs: .,biosphere/src
......
......@@ -17,6 +17,9 @@ import Distribution.ModuleName (ModuleName(..))
import Curry.Files.CymakePath
import Curry.Files.KiCSPath
withLibs :: Bool
withLibs = True
kics, cymake :: IO Program
kics = mkProg getKiCS
cymake = mkProg getCymake
......@@ -38,7 +41,9 @@ main = do
{hookedPrograms=kicsProg:cymakeProg:prophecy:hookedPrograms simpleUserHooks
,confHook=myConfHook
,postConf=myPostConf
,hookedPreProcessors=[("curry",mkModule),("lcurry",mkModule),("fcy",mkOracleModule)]
,hookedPreProcessors=[("curry",mkModule),
("lcurry",mkModule),
("fcy",mkOracleModule)]
}
-- what a hack! something was forgotten in Distribution.ModuleName
......@@ -50,20 +55,32 @@ myConfHook :: (Either GenericPackageDescription PackageDescription, HookedBuildI
-> IO LocalBuildInfo
myConfHook info flags = do
lbi <- confHook simpleUserHooks info flags
libPath <- getKiCSLibDir
allFiles <- getDirectoryContents (libPath </> ".curry")
let stdlibs = map takeBaseName (filter (isSuffixOf ".fcy") allFiles)
libs = map (\ l -> modName ("Curry":"Module":["Oracle" ++ l])) stdlibs
++map (\ l -> modName ("Curry":"DebugModule":[l]))
(filter (not . (`elem` badlibs)) stdlibs)
package = localPkgDescr lbi
Just lib = library package
lib' = Just lib{exposedModules=exposedModules lib ++ libs}
let require p = requireProg flags lbi (return p)
prop <- require prophecy
stri <- require mkstrict
mapM (mkOracleLib (unflag $ configVerbosity flags) prop stri) stdlibs
return lbi{localPkgDescr=package{library=lib'}}
if not withLibs
then return lbi
else do
libPath <- getKiCSLibDir
dataPath <- getKiCSDataDir
allFiles <- getDirectoryContents libPath
let stdfiles = filter (isSuffixOf ".fcy") allFiles
goodlibs = filter (not . (`elem` badlibs) . takeBaseName) stdfiles
stdlibs = map takeBaseName stdfiles
libs = map (\ l -> modName ("Curry":"Module":["Oracle" ++ l])) stdlibs
++map (\ l -> modName ("Curry":"DebugModule":[l])) goodlibs
dbgPath = "Curry" </> "DebugModule"
createDirectoryIfMissing True dbgPath
mapM_ (\ lib -> copyFile (libPath </> lib) (dbgPath </> lib)) goodlibs
let package = localPkgDescr lbi
Just lib = library package
ex = exposedModules lib
llbi = libBuildInfo lib
hsdirs = hsSourceDirs llbi
llbi' = llbi{hsSourceDirs=dataPath:hsdirs}
lib' = Just lib{exposedModules=ex ++ libs,
libBuildInfo=llbi'}
return lbi{localPkgDescr=package{library=lib'}}
unflag = fromFlagOrDefault silent
......@@ -80,7 +97,8 @@ callProg verb lbi prog args = do
p <- prog
rawSystemProgramConf verb p (withPrograms lbi) args
myPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
myPostConf ::
Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
myPostConf args confFlags descrs lbi = do
let require = requireProg confFlags lbi
require cymake
......@@ -140,36 +158,39 @@ badlibs =
, "Random"
]
mkOracleLib :: Verbosity -> ConfiguredProgram -> ConfiguredProgram -> FilePath -> IO ()
mkOracleLib verb prop strict stdlib = do
rawSystemProgram verb prop ["-o","Curry/Module/",stdlib]
when (not (elem stdlib badlibs))
(rawSystemProgram verb strict ["-o","./",stdlib])
return ()
mkModule :: BuildInfo -> LocalBuildInfo -> PreProcessor
mkModule buildInfo lbi = PreProcessor
mkModule _ lbi = PreProcessor
{platformIndependent = True
,runPreProcessor = mkSimplePreProcessor (runKics lbi)}
runKics :: LocalBuildInfo -> FilePath -> FilePath -> Verbosity -> IO ()
runKics lbi infile outfile verb = do
let call = callProg verb lbi
datadir <- getKiCSLibDir
call cymake ["-e","--flat"
,"-i"++datadir
,"-iCurry/Module"
,"-iprophecy/Curry/Module"
,"-ibiosphere/src/Curry/Module"
,infile]
let callKics = call kics . (["-nomake",
"-userlibpath","Curry/Module:prophecy/Curry/Module",
"-o",outfile]++)
if isSuffixOf "Transform.curry" infile
then callKics ["-executable","prophecy",infile] else
if isSuffixOf "TransformationDependencies.lcurry" infile
then callKics ["-executable","mkstrict",infile]
else callKics [infile]
,runPreProcessor = mkSimplePreProcessor $ \ inf outf verb -> do
datadir <- getKiCSLibDir
runKics datadir lbi inf outf verb}
runKics :: FilePath -> LocalBuildInfo
-> FilePath -> FilePath -> Verbosity -> IO ()
runKics datadir lbi infile outfile verb
| isPrefixOf "Curry/Module" infile
= do callCymake ["-iCurry/Module","--no-hidden-subdir"]
callKics ["-userlibpath","Curry/Module"]
| isPrefixOf "prophecy" infile
= do callCymake ["-iprophecy/Curry/Module"]
callKics $ ["-userlibpath","prophecy/Curry/Module"] ++
if isSuffixOf "Transform.curry" infile
then ["-executable","prophecy"]
else []
| isPrefixOf "biosphere" infile
= do callCymake ["-iprophecy/Curry/Module","-ibiosphere/Curry/Module"]
callKics $ ["-userlibpath",
"prophecy/Curry/Module:biosphere/Curry/Module"] ++
if isSuffixOf "TransformationDependencies.lcurry" infile
then ["-executable","mkstrict"]
else []
| otherwise = error $ "runKics, unexpected infile: " ++ infile
where
call = callProg verb lbi
callCymake args =
call cymake $ args ++ ["-i"++datadir,"-e","--flat",infile]
callKics args =
call kics $ args ++ ["-nomake","-o",outfile,infile]
mkOracleModule :: BuildInfo -> LocalBuildInfo -> PreProcessor
mkOracleModule buildInfo lbi = PreProcessor
......@@ -177,10 +198,21 @@ mkOracleModule buildInfo lbi = PreProcessor
,runPreProcessor = mkSimplePreProcessor (runKicsFcy lbi)}
runKicsFcy :: LocalBuildInfo -> FilePath -> FilePath -> Verbosity -> IO ()
runKicsFcy lbi infile outfile verb = do
let call = callProg verb lbi
call kics ["-nomake","--no-interfaces","-userlibpath","Curry/Module:Curry/Module","-o",outfile,infile]
runKicsFcy lbi infile outfile verb
| isPrefixOf "Curry/Module" infile
= callKics ["-userlibpath","Curry/Module:Curry/Module"]
| isPrefixOf "Curry/Module" outfile
= do
call (return prophecy) ["-o","Curry/Module/",stdlib]
call kics ["-userlibpath","Curry/Module:Curry/Module"]
| isPrefixOf "Curry/DebugModule" infile
= call (return mkstrict) ["-o","Curry/Module/",stdlib]
rawSystemProgram verb strict ["-o","./",stdlib]
where
call = callProg verb lbi
callKics args =
call kics $ args ++ ["-nomake","--no-interfaces","-o",outfile,infile]
......@@ -34,7 +34,7 @@ type ProgAct a = Path -> [a] -> Prog -> IO a
type Done a = IORef (FM String a)
data Parameter = Parameter Bool Bool (Maybe String) String
data Parameter = Parameter Bool Bool (Maybe String) (Maybe String) String
defaults :: Parameter
defaults = Parameter False False Nothing ""
......@@ -43,28 +43,34 @@ type Getter a = Parameter -> a
type Setter a = a -> Parameter -> Parameter
quiet :: Getter Bool
quiet (Parameter x _ _ _) = x
quiet (Parameter x _ _ _ _) = x
setQuiet :: Setter Bool
setQuiet x (Parameter _ y z m) = Parameter x y z m
setQuiet x (Parameter _ y z e m) = Parameter x y z e m
force :: Getter Bool
force (Parameter _ x _ _) = x
force (Parameter _ x _ _ _) = x
setForce :: Setter Bool
setForce x (Parameter y _ z m) = Parameter y x z m
setForce x (Parameter y _ z e m) = Parameter y x z e m
output :: Getter (Maybe String)
output (Parameter _ _ x _) = x
output (Parameter _ _ x _ _) = x
setOutput :: Setter (Maybe String)
setOutput x (Parameter y z _ m) = Parameter y z x m
setOutput x (Parameter y z _ e m) = Parameter y z x e m
main :: Getter (Maybe String)
main (Parameter _ _ _ x _) = x
setMain :: Setter (Maybe String)
setMain x (Parameter y z m _ e) = Parameter y z m x e
modulename :: Getter String
modulename (Parameter _ _ _ x) = x
modulename (Parameter _ _ _ _ x) = x
setModulename :: Setter String
setModulename x (Parameter y z m _) = Parameter y z m x
setModulename x (Parameter y z m e _) = Parameter y z m e x
parseArgs :: IO Parameter
parseArgs = getArgs >>= return . parse defaults
......@@ -77,6 +83,8 @@ parseArgs = getArgs >>= return . parse defaults
| x=="--force" = parse (setForce True p) xs
| x=="-o" = case xs of
o:xs' -> parse (setOutput (Just o) p) xs'
| x=="-m" = case xs of
o:xs' -> parse (setMain (Just o) p) xs'
| null xs = setModulename x p
usage = error "usage: <-f/--force> <-q/--quiet> <-o outputdir> modulename"
......@@ -106,7 +114,7 @@ workUpDependence path done test act modu = do
process :: [String] -> Done a -> TestAct a -> ProgAct a -> ModuleName -> IO a
process path done test act modu = do
fn <- getFileInPath (flatCurryFileName modu) [""] path
fn <- getFileInPath (modu++".fcy") [""] path
imps <- fastReadImports fn >>= mapIO (workUpDependence path done test act)
let dir = dirName fn++"/"
result <- test dir modu >>=
......
......@@ -10,7 +10,7 @@ import System (getArgs)
import Directory
import Integer ( maxlist )
import List
import Maybe (isJust)
import Maybe
import Distribution (getStdLibDir)
import ReadShowTerm
......@@ -51,7 +51,7 @@ transform libdir force quiet outdir mod = make quiet mod tester (writeTrans outd
myObsolete path modu = do
ob <- obso path modu
if isJust ob || not (isPrefixOf libdir path)
if isJust ob || isJust outdir || not (isPrefixOf libdir path)
then return ob
else do
unless quiet (putStrLn (modu ++ " is a standard library"))
......
......@@ -313,7 +313,6 @@ mkTags = [(toPathList . userlibpath),(show . pm)]
getDebugOptions :: Options -> IO (Either Bool DebugOptions)
getDebugOptions opts = do
dir <- getKiCSLibDir
put' 5 opts "looking for debugger"
let dbg = "KiCS-debugger"
answer <- readProcess ghc_pkg ["list",dbg] ""
......@@ -321,6 +320,7 @@ getDebugOptions opts = do
if (not $ isInfixOf dbg answer)
then put' 5 opts "no debugger installed" >> return (Left True)
else do
dir <- getKiCSDataDir
put' 5 opts "getting debugger config"
dopts <- readProcess ghc ["-e","main",dir </> "debugOptions.hs"] ""
let (v,p,m,o) = read dopts
......@@ -358,7 +358,7 @@ getConfigs home cfgs | cfgs == cfgs = do
opts = defaultOpts
{userlibpath = let up = readSetting userlibpath splitPath 1
in punkt : up,
stdLibDir = std </> currySubdir,
stdLibDir = std,
pm = readSetting pm readPMode 2,
frontend = cymake_call,
eval = readSetting eval read 3,
......
module Curry.Files.KiCSPath (getKiCS,getKiCSLibDir,kicsVersion) where
module Curry.Files.KiCSPath
(getKiCS
,getKiCSLibDir
,getKiCSDataDir
,kicsVersion
) where
import Data.Version
import System.FilePath
......@@ -10,4 +15,8 @@ getKiCS = do
kicsDir <- getBinDir
return (kicsDir </> "kics")
getKiCSLibDir = getDataDir
\ No newline at end of file
getKiCSLibDir = do
dir <- getDataDir
return (dir </> "Curry" </> "Module")
getKiCSDataDir = getDataDir
\ No newline at end of file
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