[Git][ghc/ghc][wip/ghc-debug] 35 commits: testsuite: Drop --io-manager flag from testsuite configuration

Sven Tennie gitlab at gitlab.haskell.org
Tue Aug 18 07:22:32 UTC 2020



Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC


Commits:
9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00
testsuite: Drop --io-manager flag from testsuite configuration

This is no longer necessary as there are now dedicated testsuite ways
which run tests with WinIO.

- - - - -
55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00
llvm-targets: Add i686 targets

Addresses #18422.

- - - - -
4ac72b66 by Matthew Pickering at 2020-08-17T08:32:48+02:00
rts: Implement ghc-debug API (#18405)

There are four components to this patch which make it possible to
implement `ghc-debug`.

1. Add four new functions to the RtsAPI.
  * rts_pause and rts_unpause allow an external process to completely
  pause and unpause the RTS.
  * rts_listThreads and rts_listMiscRoots are used to find the current
  roots of the garbage collector.

These changes also mean that `Task.h` is exposed to the user.

2. Generalise the `ghc-heap` API so that raw `Word`s can be returned
rather than actual objects. This is necessary when trying to decode
closures on an external process because the pointers in such closures
are correct for the internal rather than external process. If you used
the previous API then you would get a segfault as the garbage collector
would try to traverse into these nonsensical branches.

```
-- before
getClosureData :: a -> IO Closure
-- after
getClosureDataX :: (forall c . c -> IO (Ptr StgInfoTable, [Word], [b]))
	                      -> a -> IO (GenClosure b)
```

For the normal case `b` is instantiated to `Box`, which contains a
pointer to a heap object.

```
data Box = Box a

-- GenClosure Box
```

For `ghc-debug` we instead just take the word of the address as we have
to explicitly interpret it on the external process.

```
GenClosure Word
```

3. Support for decoding `TSO` and `STACK` closures is partially
implemented. There is still quite a bit of work to do to finish both but
these at least allow us to make some more progress.

4. findPtr is generalised to take a callback argument. This means that
its result can be communicated to the debugger rather than just printing
out the result. The debugger has a function which invokes `findPtr` and
passes a callback which sends the result over a socket.

Co-authored-by: Ben Gamari <ben at smart-cactus.org>

- - - - -
91057d88 by Sven Tennie at 2020-08-17T08:32:48+02:00
Decode more StgTSO and StgStack fields (#18405)

Use hsc2hs to get an understandable and stable mapping from the C
structs to Haskell.

It's important to keep StgTSO and StgStack decoding downwards
compatible. This is especially needed for hadrian/ghci.

- - - - -
fae266ce by Sven Tennie at 2020-08-17T08:32:48+02:00
Add test for StgTSO decoding (#18405)

This makes sure ghc-heap decodes StgTSO and StgStack correctly.

To assert - otherwise dynamic - properties, a new, non-running TSO is
created in create_tso() (create_tso.c).

size is renamed to stack_size to use a dedicated type.

size was already defined as a HalfWord in GenClosure, which is
only equivalent to Word32 on 64bit architectures.

- - - - -
03bd6416 by Sven Tennie at 2020-08-17T08:32:48+02:00
Add documentation to ghc-debug functions (#18405)

- - - - -
5a96f25d by Sven Tennie at 2020-08-17T08:32:48+02:00
Adjust type of getClosureX to type of getClosureDataX (#18405)

After a rebase the compiler complained:

libraries/ghc-heap/GHC/Exts/Heap.hs:89:23: error:
    • Couldn't match type: a -> IO (Ptr StgInfoTable, [Word], [b])
                     with: forall c. c -> IO (Ptr StgInfoTable, [Word], [b])
      Expected: (forall c. c -> IO (Ptr StgInfoTable, [Word], [b]))
                -> a -> IO (GenClosure b)
        Actual: (a -> IO (Ptr StgInfoTable, [Word], [b]))
                -> a -> IO (GenClosure b)
    • In the expression: getClosureX
      In an equation for ‘getClosureDataX’: getClosureDataX = getClosureX
      In the instance declaration for ‘HasHeapRep a’
    • Relevant bindings include
        getClosureDataX :: (forall c.
                            c -> IO (Ptr StgInfoTable, [Word], [b]))
                           -> a -> IO (GenClosure b)
          (bound at libraries/ghc-heap/GHC/Exts/Heap.hs:89:5)
   |
89 |     getClosureDataX = getClosureX
   |                       ^^^^^^^^^^^
)

- - - - -
93f49862 by Sven Tennie at 2020-08-17T08:32:48+02:00
Add test for rts_pause and rts_unpause (#18405)

- - - - -
9368ddfe by Sven Tennie at 2020-08-17T08:32:48+02:00
Add test list_threads_and_misc_roots (#18405)

It uses rts_listThreads() and rts_listMiscRoots().

- - - - -
c4a4efdd by Sven Tennie at 2020-08-17T08:32:48+02:00
Introduce rts_isPaused() (#18405)

Some operations are only save when the RTS is paused. This predicate
helps to make such checks.

- - - - -
1f0ae63b by Sven Tennie at 2020-08-17T08:32:48+02:00
Decode CostCentreStacks, CostCentres and InfoTables (#18405)

- - - - -
8059d205 by Sven Tennie at 2020-08-17T08:32:48+02:00
Use cache and loop breakers for CostCentre, CostCentreStack and IndexTable decoding (#18405)

- - - - -
aa1d6ac3 by Sven Tennie at 2020-08-17T08:32:48+02:00
Cleanup

- - - - -
9083b878 by Sven Tennie at 2020-08-17T08:32:48+02:00
Query caches once, not twice

- - - - -
2d5ce49a by Sven Tennie at 2020-08-17T08:32:48+02:00
Fix Haddock for EndTSOQueue

- - - - -
1a303bbb by Sven Tennie at 2020-08-17T08:32:48+02:00
Run prof_info test only in prof_ways (#18405)

That's the required way for collecting PROFILING data (e.g.
CostCentres).

- - - - -
044af0f5 by Sven Tennie at 2020-08-17T08:32:48+02:00
Skip WIP test

(Red on CI)

- - - - -
88b56eae by Sven Tennie at 2020-08-17T08:32:48+02:00
Add missing module to ghc-heap.cabal

- - - - -
0f6c75f4 by Sven Tennie at 2020-08-17T08:32:48+02:00
Rearrange #ifdef with GHC version

This prevents some "unused" warnings.

- - - - -
8144ad9e by Sven Tennie at 2020-08-17T08:32:48+02:00
Fix cpp redefinition warnings

With --Werror this made the build fail.

- - - - -
6cc475af by Sven Tennie at 2020-08-17T08:32:48+02:00
Add dummy import for PeekProfInfo_ProfilingEnabled for non-profiled builds

This circumvents #15197. Otherwise PeekProfInfo_ProfilingEnabled
wouldn't be available for make-based builds.

- - - - -
248afdea by Sven Tennie at 2020-08-17T08:32:48+02:00
Add assertions to prof_info test (#18405)

- - - - -
75d9d2c5 by Sven Tennie at 2020-08-17T08:32:48+02:00
Fix types in tests

Use `Ptr ()` instead of `Word` to communicate that addresses/pointers
are meant.

- - - - -
3eed7e51 by Sven Tennie at 2020-08-17T08:32:48+02:00
Cleanup

- - - - -
ffa9b577 by Sven Tennie at 2020-08-17T08:32:48+02:00
Introduce LiftedClosure

This is a representation for closures that do not have a represantation
in the Haskell language. I.e. things like TSOs.

- - - - -
0960d594 by Sven Tennie at 2020-08-17T08:32:48+02:00
Fix prof_info test

Line number of self defined cost centre changed.

- - - - -
f0fe17f2 by Sven Tennie at 2020-08-17T08:32:48+02:00
Expect stack_marking starting from GHC 8.10

This field was introduced with GHC 8.10.

- - - - -
9aac043f by Sven Tennie at 2020-08-17T08:32:48+02:00
Add WhatNext, WhyBlocked and TsoFlags

Additionally extract TestUtils with common test functions.

- - - - -
941a9990 by Sven Tennie at 2020-08-17T08:32:48+02:00
Parse TSO flags

- - - - -
36b4f8a3 by Sven Tennie at 2020-08-17T08:32:48+02:00
Cache only CostCentres during ProfInfo decoding

Looks like caches for CostCentreStacks and IndexTables are not needed.

- - - - -
705912c7 by Sven Tennie at 2020-08-17T08:32:48+02:00
Fix warning

- - - - -
4df1a44d by Sven Tennie at 2020-08-17T08:32:48+02:00
END_TSO_QUEUE is not a closure type on it's own

Indeed it's a CONSTR_NOCAF.

- - - - -
3a468673 by Sven Tennie at 2020-08-17T08:32:48+02:00
Delete unused function

- - - - -
a0bd62e4 by Sven Tennie at 2020-08-17T08:32:48+02:00
Rename boundTaskExiting and getTask (#18405)

Both are directly related to myTask, which the new names now reflect.

- - - - -
26f2302e by Sven Tennie at 2020-08-18T09:21:07+02:00
Mark unsafe accesses (#18405)

StgTSO and StgStack are very dynamic by nature. Accesses to outdated
pointers lead to segmentation faults or absolutely wrong results.

So, make sure (by naming) that the users nows about these facts.

- - - - -


30 changed files:

- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Runtime/Interpreter.hs
- includes/Rts.h
- includes/RtsAPI.h
- + includes/rts/Task.h
- includes/rts/storage/Heap.h
- libraries/ghc-heap/GHC/Exts/Heap.hs
- libraries/ghc-heap/GHC/Exts/Heap/ClosureTypes.hs
- libraries/ghc-heap/GHC/Exts/Heap/Closures.hs
- + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hsc
- + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc
- + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc
- + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs
- + libraries/ghc-heap/GHC/Exts/Heap/Ptr/Utils.hs
- libraries/ghc-heap/ghc-heap.cabal.in
- + libraries/ghc-heap/tests/TestUtils.hs
- libraries/ghc-heap/tests/all.T
- + libraries/ghc-heap/tests/create_tso.c
- + libraries/ghc-heap/tests/create_tso.h
- + libraries/ghc-heap/tests/list_threads_and_misc_roots.hs
- + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.c
- + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.h
- + libraries/ghc-heap/tests/parse_tso_flags.hs
- + libraries/ghc-heap/tests/prof_info.hs
- + libraries/ghc-heap/tests/tso_and_stack_closures.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Run.hs
- llvm-targets
- rts/Heap.c
- rts/Printer.c


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78c049b6d52d6d01a6e9184c609a65c1041b8c3b...26f2302e80c4d92f344997b120af5dba0c2fa4f9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78c049b6d52d6d01a6e9184c609a65c1041b8c3b...26f2302e80c4d92f344997b120af5dba0c2fa4f9
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/20200818/9269666c/attachment-0001.html>


More information about the ghc-commits mailing list