Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
ghc-debug
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Travis Whitaker
ghc-debug
Commits
1c7ddd10
Commit
1c7ddd10
authored
6 years ago
by
Matthew Pickering
Browse files
Options
Downloads
Patches
Plain Diff
Add README
parent
161edec7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+61
-0
61 additions, 0 deletions
README.md
with
61 additions
and
0 deletions
README.md
0 → 100644
+
61
−
0
View file @
1c7ddd10
This set of libraries is progress towards implementing an way to interact
with Haskell's RTS from another Haskell program.
For example, you could use this library to
*
Implement a memory profiler, written in Haskell
*
Precisely analyse other heap properties such as retainers
# How does it work?
We call the process we want to debug the debuggee and the process which does
the debugging the debugger.
Whilst the debuggee is
running it calls the C function
`start`
which creates a unix domain socket (
`/tmp/ghc-debug`
for now). The debugger starts and connects to the socket.
Once the debugger is connected it can send requests to the debuggee to control
and inspect the RTS. The requests API is specified as follows:
```
-- | A request sent from the debugger to the debuggee parametrized on the result type.
data Request a where
-- | Request protocol version
RequestVersion :: Request Word64
-- | Pause the debuggee.
RequestPause :: Request ()
-- | Resume the debuggee.
RequestResume :: Request ()
-- | Request the debuggee's root pointers.
RequestRoots :: Request [ClosurePtr]
-- | Request a set of closures.
RequestClosures :: [ClosurePtr] -> Request [GenClosure InfoTablePtr ClosurePtr]
-- | Request a set of info tables.
RequestInfoTables :: [InfoTablePtr] -> Request [StgInfoTable]
```
So far only the version, pause and resume functions are tested (and work).
We will add some more functions to this interface, for example, a request to
call
`findPtr`
and also a way to mark objects of interest so we can retrieve their
addresses in the same manner as
`RequestRoots`
.
# How do I use it?
In short, you don't, yet.
The project needs to built with a development version of GHC from
[
this
](
https://gitlab.haskell.org/ghc/ghc/tree/wip/ghc-debug
)
branch.
Then you can use normal cabal commands to build this library.
In order to make a process debuggable it needs to call the socket initialisation
function
`start`
, see the
`test-debug`
executable for exactly how to do this.
## Testing
There are two test executables
`test-debug`
and
`debugger`
which are used to
test the library.
`test-debug`
is an interruptable program which prints out an incrementing
counter each second.
`debugger`
starts and immediately attaches to
`test-debug`
and makes some requests. So the way to test the library is to first start
`test-debug`
and then start
`debugger`
. There are lots of helpeful traces to see what's going
on with each process.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment