[Git][ghc/ghc][wip/ghc-debug] Introduce rts_isPaused()
Sven Tennie
gitlab at gitlab.haskell.org
Sun Jun 28 12:33:36 UTC 2020
Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC
Commits:
b237baf6 by Sven Tennie at 2020-06-28T14:33:22+02:00
Introduce rts_isPaused()
Some operations are only save when the RTS is paused. This predicate
helps to make such checks.
- - - - -
3 changed files:
- includes/RtsAPI.h
- rts/Heap.c
- rts/RtsAPI.c
Changes:
=====================================
includes/RtsAPI.h
=====================================
@@ -504,6 +504,9 @@ RtsPaused rts_pause (void);
// (i.e. myTask() must stay the same).
void rts_unpause (RtsPaused paused);
+// Tells the current state of the RTS regarding rts_pause() and rts_unpause().
+bool rts_isPaused(void);
+
// List all live threads. Must be done while RTS is paused (see rts_pause()).
typedef void (*ListThreadsCb)(void *user, StgTSO *);
void rts_listThreads(ListThreadsCb cb, void *user);
=====================================
rts/Heap.c
=====================================
@@ -247,6 +247,13 @@ static StgWord collect_pointers(StgClosure *closure, StgWord size, StgClosure *p
}
StgArrBytes *heap_view_closurePtrsAsWords(Capability *cap, StgClosure *closure) {
+ if(!rts_isPaused()){
+ errorBelch("Warning: "
+ "The RTS must be paused (see rts_pause()) to inspect it's heap!");
+
+ return NULL;
+ }
+
ASSERT(LOOKS_LIKE_CLOSURE_PTR(closure));
StgWord size = heap_view_closureSize(closure);
=====================================
rts/RtsAPI.c
=====================================
@@ -672,6 +672,12 @@ void rts_unpause (RtsPaused paused)
freeTask(paused.pausing_task);
}
+// Tells the current state of the RTS regarding rts_pause() and rts_unpause().
+bool rts_isPaused(void)
+{
+ return rts_paused;
+}
+
// Call cb for all StgTSOs. *user is a user defined payload to cb. It's not
// used by the RTS.
// rts_listThreads should only be called when the RTS is paused, i.e. rts_pause
@@ -732,6 +738,13 @@ void rts_unpause (RtsPaused paused STG_UNUSED)
"multithreaded RTS.");
}
+bool rts_isPaused(void)
+{
+ errorBelch("Warning: (Un-) Pausing the RTS is only possible for "
+ "multithreaded RTS.");
+ return false;
+}
+
void rts_listThreads(ListThreadsCb cb STG_UNUSED, void *user STG_UNUSED)
{
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b237baf64c9fa9563e700cbb765102bbe6c12b09
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b237baf64c9fa9563e700cbb765102bbe6c12b09
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/20200628/f24dfe26/attachment-0001.html>
More information about the ghc-commits
mailing list