Commit f55c3fce authored by sewardj's avatar sewardj
Browse files

[project @ 2001-02-14 11:03:59 by sewardj]

Show error messages generated from failed .so/.DLL load attempts.
parent 801c4d28
-----------------------------------------------------------------------------
-- $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
......
......@@ -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}
Supports Markdown
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