[Git][ghc/ghc][wip/supersven/libdw-test] 2 commits: Introduce test predicate for libdw

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Sat Dec 28 17:31:23 UTC 2024



Sven Tennie pushed to branch wip/supersven/libdw-test at Glasgow Haskell Compiler / GHC


Commits:
557591fd by Sven Tennie at 2024-12-28T18:30:32+01:00
Introduce test predicate for libdw

Libdw does only exist on elf-based operating systems and when it has
been configured (via autoconf.)

- - - - -
ba735a74 by Sven Tennie at 2024-12-28T18:30:41+01:00
WIP: Add test for DWARF (libdw) stacktraces

- - - - -


9 changed files:

- hadrian/src/Oracles/TestSettings.hs
- hadrian/src/Settings/Builders/RunTest.hs
- testsuite/driver/testglobals.py
- testsuite/driver/testlib.py
- testsuite/ghc-config/ghc-config.hs
- testsuite/mk/test.mk
- testsuite/tests/rts/all.T
- + testsuite/tests/rts/execution_stack.hs
- + testsuite/tests/rts/execution_stack.stdout


Changes:

=====================================
hadrian/src/Oracles/TestSettings.hs
=====================================
@@ -43,6 +43,7 @@ data TestSetting = TestHostOS
                  | TestLeadingUnderscore
                  | TestGhcPackageDb
                  | TestGhcLibDir
+                 | TestGhcRtsWithLibdw
                  deriving (Show)
 
 -- | Lookup a test setting in @ghcconfig@ file.
@@ -76,6 +77,7 @@ testSetting key = do
         TestLeadingUnderscore     -> "LeadingUnderscore"
         TestGhcPackageDb          -> "GhcGlobalPackageDb"
         TestGhcLibDir             -> "GhcLibdir"
+        TestGhcRtsWithLibdw       -> "GhcRtsWithLibdw"
 
 -- | Get the RTS ways of the test compiler
 testRTSSettings :: Action [String]


=====================================
hadrian/src/Settings/Builders/RunTest.hs
=====================================
@@ -83,7 +83,8 @@ data TestCompilerArgs = TestCompilerArgs{
  ,   libdir :: FilePath
  ,   have_llvm :: Bool
  ,   rtsLinker :: Bool
- ,   pkgConfCacheFile :: FilePath }
+ ,   pkgConfCacheFile :: FilePath
+ ,   hasLibdw :: Bool}
    deriving (Eq, Show)
 
 
@@ -110,6 +111,7 @@ inTreeCompilerArgs stg = do
     targetWithSMP       <- targetSupportsSMP
 
     cross <- flag CrossCompiling
+    hasLibdw <- flag UseLibdw
 
     let ghcStage
           | cross, Stage1 <- stg = Stage1
@@ -184,6 +186,7 @@ outOfTreeCompilerArgs = do
     libdir <- getTestSetting TestGhcLibDir
 
     rtsLinker <- getBooleanSetting TestGhcWithRtsLinker
+    hasLibdw <- getBooleanSetting TestGhcRtsWithLibdw
     return TestCompilerArgs{..}
 
 
@@ -292,6 +295,7 @@ runTestBuilderArgs = builder Testsuite ? do
             , arg "-e", arg $ asBool "config.target_has_smp=" targetWithSMP
             , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic
             , arg "-e", arg $ "config.leading_underscore=" ++ show leadingUnderscore
+            , arg "-e", arg $ "config.have_libdw=" ++ show hasLibdw
 
             , arg "-e", arg $ "config.wordsize=" ++ show wordsize
             , arg "-e", arg $ "config.os="       ++ show os


=====================================
testsuite/driver/testglobals.py
=====================================
@@ -174,6 +174,9 @@ class TestConfig:
         # Is readelf available?
         self.have_readelf = False
 
+        # Is libww (DWARF) available
+        self.have_libdw = False
+
         # Do we use a fast backend for bignum (e.g. GMP)
         self.have_fast_bignum = True
 


=====================================
testsuite/driver/testlib.py
=====================================
@@ -1067,6 +1067,9 @@ def have_gdb( ) -> bool:
 def have_readelf( ) -> bool:
     return config.have_readelf
 
+def have_libdw( ) -> bool:
+    return config.have_libdw
+
 def have_fast_bignum( ) -> bool:
     return config.have_fast_bignum
 


=====================================
testsuite/ghc-config/ghc-config.hs
=====================================
@@ -29,6 +29,7 @@ main = do
   getGhcFieldOrFail fields "GhcRTSWays" "RTS ways"
   getGhcFieldOrFail fields "GhcLibdir" "LibDir"
   getGhcFieldOrFail fields "GhcGlobalPackageDb" "Global Package DB"
+  getGhcFieldOrFail fields "GhcRtsWithLibdw" "RTS expects libdw"
   getGhcFieldOrDefault fields "TargetRTSLinkerOnlySupportsSharedLibs" "target RTS linker only supports shared libraries" "NO"
   getGhcFieldOrDefault fields "GhcDynamic" "GHC Dynamic" "NO"
   getGhcFieldOrDefault fields "GhcProfiled" "GHC Profiled" "NO"


=====================================
testsuite/mk/test.mk
=====================================
@@ -150,6 +150,12 @@ else
 RUNTEST_OPTS += -e config.have_readelf=False
 endif
 
+ifeq "$(GhcRtsWithLibdw)" "YES"
+RUNTEST_OPTS += -e "config.have_libdw=True"
+else
+RUNTEST_OPTS += -e "config.have_libdw=False"
+endif
+
 ifeq "$(BIGNUM_GMP)" ""
 RUNTEST_OPTS += -e config.have_fast_bignum=False
 else


=====================================
testsuite/tests/rts/all.T
=====================================
@@ -636,3 +636,6 @@ test('T25280', [unless(opsys('linux'),skip),req_process,js_skip], compile_and_ru
 # N.B. This will likely issue a warning on stderr but we merely care that the
 # program doesn't crash.
 test('T25560', [req_c_rts, ignore_stderr], compile_and_run, [''])
+
+# TODO: Refine the command line args. (For now, turn DWARF on - anyhow - to ensure that no missing flag causes troubles.)
+test("execution_stack", [unless(have_libdw(), skip)], compile_and_run, ['-debug -g -optc=-g3'])


=====================================
testsuite/tests/rts/execution_stack.hs
=====================================
@@ -0,0 +1,6 @@
+import Data.Maybe
+import GHC.Internal.ExecutionStack
+
+main :: IO ()
+main = do
+  putStrLn =<< (fromJust <$> showStackTrace)


=====================================
testsuite/tests/rts/execution_stack.stdout
=====================================
@@ -0,0 +1 @@
+TODO: Add some stacktrace here. Or, assert in the test itself.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae59ef7aa3d5c6dc08b9b87a9b8a700e00e39e78...ba735a74900885e47e3e97064254c3f340ae8097

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae59ef7aa3d5c6dc08b9b87a9b8a700e00e39e78...ba735a74900885e47e3e97064254c3f340ae8097
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/20241228/84e4b1bb/attachment-0001.html>


More information about the ghc-commits mailing list