From: sewardj Date: Wed, 14 Feb 2001 11:03:59 +0000 (+0000) Subject: [project @ 2001-02-14 11:03:59 by sewardj] X-Git-Tag: Approximately_9120_patches~2633 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=f55c3fce9c692c013346da13f1eb28263d87b6ad;p=ghc-hetmet.git [project @ 2001-02-14 11:03:59 by sewardj] Show error messages generated from failed .so/.DLL load attempts. --- diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 3f4ec2a..c5159ac 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.49 2001/02/13 18:37:53 qrczak Exp $ +-- $Id: InteractiveUI.hs,v 1.50 2001/02/14 11:03:59 sewardj Exp $ -- -- GHC Interactive User Interface -- @@ -47,7 +47,8 @@ import Monad ( when ) import PrelGHC ( unsafeCoerce# ) import PrelPack ( packString ) import PrelByteArr -import Foreign ( Ptr, nullPtr ) +import Foreign ( nullPtr ) +import CString ( peekCString ) ----------------------------------------------------------------------------- @@ -686,13 +687,14 @@ linkPackages cmdline_libs pkgs else do loadObj static_ish putStr "done.\n" Right dll_unadorned - -> do dll_ok <- addDLL dll_unadorned - if dll_ok + -> do maybe_errmsg <- addDLL dll_unadorned + if maybe_errmsg == nullPtr then putStr "done.\n" - else do putStr "not found.\n" + else do str <- peekCString maybe_errmsg + putStr ("failed (" ++ str ++ ")\n") croak - croak = throwDyn (OtherError "user specified .o/.so/.DLL cannot be found.") + croak = throwDyn (OtherError "user specified .o/.so/.DLL could not be loaded.") classify a_lib = let a_libr = reverse a_lib @@ -739,11 +741,12 @@ loadClassified :: Either FilePath String -> IO () loadClassified (Left obj_absolute_filename) = do loadObj obj_absolute_filename loadClassified (Right dll_unadorned) - = do dll_ok <- addDLL dll_unadorned - if dll_ok + = do maybe_errmsg <- addDLL dll_unadorned + if maybe_errmsg == nullPtr then return () - else throwDyn (OtherError ("can't find .o or .so/.DLL for: " - ++ dll_unadorned)) + else do str <- peekCString maybe_errmsg + throwDyn (OtherError ("can't find .o or .so/.DLL for: " + ++ dll_unadorned ++ " (" ++ str ++ ")" )) locateOneObj :: [FilePath] -> String -> IO (Either FilePath String) locateOneObj [] obj diff --git a/ghc/compiler/ghci/Linker.lhs b/ghc/compiler/ghci/Linker.lhs index 533b6ac..8b0d15a 100644 --- a/ghc/compiler/ghci/Linker.lhs +++ b/ghc/compiler/ghci/Linker.lhs @@ -11,9 +11,10 @@ module Linker ( unloadObj, -- :: String -> IO () lookupSymbol, -- :: String -> IO (Maybe (Ptr a)) resolveObjs, -- :: IO () - addDLL -- :: String -> IO Bool + addDLL -- :: String -> IO (Ptr CChar) ) where +import CTypes ( CChar ) import Foreign ( Ptr, nullPtr ) import PrelByteArr import PrelPack (packString) @@ -48,8 +49,8 @@ resolveObjs = do else return () addDLL str = do - r <- c_addDLL (packString str) - return (r == 0) + maybe_errmsg <- c_addDLL (packString str) + return maybe_errmsg type PackedString = ByteArray Int @@ -69,6 +70,6 @@ foreign import "initLinker" unsafe initLinker :: IO () foreign import "addDLL" unsafe - c_addDLL :: PackedString -> IO Int + c_addDLL :: PackedString -> IO (Ptr CChar) \end{code}