Skip to content
Snippets Groups Projects
Commit e1815c6e authored by Matthew Pickering's avatar Matthew Pickering
Browse files

Fix snapshotting

We also need to find all the RequestBlock requests and add those into
the block cache, as well as the results of RequestAllBlocks.
parent 4c4cadf4
No related branches found
Tags 2_1_0
No related merge requests found
...@@ -123,9 +123,7 @@ instance DebugMonad DebugM where ...@@ -123,9 +123,7 @@ instance DebugMonad DebugM where
initBlockCacheFromReqCache :: RequestCache -> BlockCache initBlockCacheFromReqCache :: RequestCache -> BlockCache
initBlockCacheFromReqCache new_req_cache = initBlockCacheFromReqCache new_req_cache =
case lookupReq RequestAllBlocks new_req_cache of addBlocks (lookupBlocks new_req_cache) emptyBlockCache
Just bs -> addBlocks bs emptyBlockCache
Nothing -> emptyBlockCache
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
module GHC.Debug.Client.RequestCache(RequestCache module GHC.Debug.Client.RequestCache(RequestCache
, cacheReq , cacheReq
, lookupReq , lookupReq
, lookupBlocks
, emptyRequestCache , emptyRequestCache
, clearMovableRequests , clearMovableRequests
, putCache , putCache
...@@ -33,6 +34,21 @@ lookupReq req (RequestCache rc) = coerceResult <$> HM.lookup (AnyReq req) rc ...@@ -33,6 +34,21 @@ lookupReq req (RequestCache rc) = coerceResult <$> HM.lookup (AnyReq req) rc
coerceResult :: AnyResp -> resp coerceResult :: AnyResp -> resp
coerceResult (AnyResp a _) = unsafeCoerce a coerceResult (AnyResp a _) = unsafeCoerce a
lookupBlocks :: RequestCache -> [RawBlock]
lookupBlocks c@(RequestCache rc) =
let all_blocks = case lookupReq RequestAllBlocks c of
Just bs -> bs
Nothing -> []
get_block :: AnyReq -> AnyResp -> [RawBlock] -> [RawBlock]
get_block (AnyReq (RequestBlock {})) (AnyResp resp _) bs = unsafeCoerce resp : bs
get_block _ _ bs = bs
individual_blocks = HM.foldrWithKey get_block [] rc
in (all_blocks ++ individual_blocks)
emptyRequestCache :: RequestCache emptyRequestCache :: RequestCache
emptyRequestCache = RequestCache HM.empty emptyRequestCache = RequestCache HM.empty
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment