[Git][ghc/ghc][wip/romes/rts-linker-direct-symbol-lookup] 3 commits: Improve debug message

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Mar 25 14:27:20 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/rts-linker-direct-symbol-lookup at Glasgow Haskell Compiler / GHC


Commits:
5c11c646 by Rodrigo Mesquita at 2024-03-25T14:27:10+00:00
Improve debug message

- - - - -
dbf4ae7e by Rodrigo Mesquita at 2024-03-25T14:27:10+00:00
WIP

- - - - -
bdc1bc89 by Rodrigo Mesquita at 2024-03-25T14:27:10+00:00
Simplify MVar operations used

- - - - -


4 changed files:

- compiler/GHC/ByteCode/Linker.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Linker/Types.hs
- compiler/GHC/Runtime/Interpreter.hs


Changes:

=====================================
compiler/GHC/ByteCode/Linker.hs
=====================================
@@ -180,7 +180,13 @@ lookupHsSymbol interp pkgs_loaded nm sym_suffix = do
         case mb_ptr of
           Just ptr -> pure (Just ptr)
           Nothing -> go dlls
-      go [] = panic "lookupHsSymbol: symbol not found in the loaded_dlls associated with this pkg_id"
+      go [] = pprPanic "GHC.ByteCode.Linker.lookupHsSymbol" $
+        text "name"
+         <+> ppr nm
+         <+> parens (text "symbol" <+> ppr sym_to_find)
+         <+> text "not found in the loaded_dlls associated with this pkg_id"
+         <+> parens (ppr pkg_id) <> text ":"
+         $$ ppr (lookupUDFM pkgs_loaded pkg_id)
 
   go loaded_dlls
 


=====================================
compiler/GHC/Linker/Loader.hs
=====================================
@@ -223,6 +223,7 @@ loadDependencies
   -> [Module]
   -> IO (LoaderState, SuccessFlag, [Linkable], PkgsLoaded) -- ^ returns the set of linkables required
 loadDependencies interp hsc_env pls span needed_mods = do
+   putStrLn "Start loading dependencies"
 --   initLoaderState (hsc_dflags hsc_env) dl
    let opts = initLinkDepsOpts hsc_env
 
@@ -240,6 +241,7 @@ loadDependencies interp hsc_env pls span needed_mods = do
                                                                   | pkg_id <- uniqDSetToList this_pkgs_needed
                                                                   , Just pkg <- [lookupUDFM all_pkgs_loaded pkg_id]
                                                                   ])
+   putStrLn "Finished loading dependencies"
    return (pls2, succ, ldAllLinkables deps, this_pkgs_loaded)
 
 


=====================================
compiler/GHC/Linker/Types.hs
=====================================
@@ -148,7 +148,7 @@ data LoadedPkgInfo
   , loaded_pkg_hs_objs     :: ![LibrarySpec]
   , loaded_pkg_non_hs_objs :: ![LibrarySpec]
   , loaded_pkg_hs_dlls     :: ![RemotePtr LoadedDLL]
-  -- ^ TODO: write Note
+    -- ^ See Note [Dynamically Loading Symbols]
   , loaded_pkg_trans_deps  :: UniqDSet UnitId
   }
 


=====================================
compiler/GHC/Runtime/Interpreter.hs
=====================================
@@ -500,12 +500,12 @@ withSymbolCache interp str determine_addr = do
       case maddr of
         Nothing -> return Nothing
         Just p -> do
-          let cache' = addToUFM cache str p
-          modifyMVar_ (interpLookupSymbolCache interp) (const (pure cache'))
+          let upd_cache cache' = addToUFM cache' str p
+          modifyMVar_ (interpLookupSymbolCache interp) (pure . upd_cache)
           return (Just p)
 
 purgeLookupSymbolCache :: Interp -> IO ()
-purgeLookupSymbolCache interp = modifyMVar_ (interpLookupSymbolCache interp) (const (pure emptyUFM))
+purgeLookupSymbolCache interp = putMVar (interpLookupSymbolCache interp) emptyUFM
 
 -- | loadDLL loads a dynamic library using the OS's native linker
 -- (i.e. dlopen() on Unix, LoadLibrary() on Windows).  It takes either



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4be79c71e5819015de9332c704f5f4d7cc7380b2...bdc1bc89f31e87ff201e9d8825202b4a7eb43727

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4be79c71e5819015de9332c704f5f4d7cc7380b2...bdc1bc89f31e87ff201e9d8825202b4a7eb43727
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240325/1f6ac45c/attachment-0001.html>


More information about the ghc-commits mailing list