diff --git a/src/DebugInfo-Tests/DebugInfoTest.class.st b/src/DebugInfo-Tests/DebugInfoTest.class.st index 2772e4aca83..9f6d113bc56 100644 --- a/src/DebugInfo-Tests/DebugInfoTest.class.st +++ b/src/DebugInfo-Tests/DebugInfoTest.class.st @@ -825,6 +825,24 @@ DebugInfoTest >> testReadLocalMethodTemporaryVariable [ equals: contextWithArguments ] +{ #category : 'tests - read variables' } +DebugInfoTest >> testReadLocalMethodTemporaryVariableFromDeadContext [ + + | debugInfo contextWithArguments | + contextWithArguments := thisContext copy + pc: nil; + yourself. + self assert: contextWithArguments isDead. + debugInfo := self newDebugInfoFor: contextWithArguments method. + + self + shouldnt: [ + debugInfo + readVariableNamed: #contextWithArguments + fromContext: contextWithArguments ] + raise: MessageNotUnderstood +] + { #category : 'tests - read variables' } DebugInfoTest >> testReadLocalOptimizedBlockArgumentVariable [ diff --git a/src/DebugInfo/OnlineSourceDebugInfo.class.st b/src/DebugInfo/OnlineSourceDebugInfo.class.st index 1eb93e5eb38..b0d400fcb0b 100644 --- a/src/DebugInfo/OnlineSourceDebugInfo.class.st +++ b/src/DebugInfo/OnlineSourceDebugInfo.class.st @@ -250,7 +250,11 @@ OnlineSourceDebugInfo >> rangeForPC: aPC [ { #category : 'api' } OnlineSourceDebugInfo >> readVariableNamed: aName fromContext: aContext [ - ^ (self debugScopeAt: aContext pc) readVariableNamed: aName fromContext: aContext + | currentPC | + "If the context is dead (pc = nil) then we really cannot know how to interpret the temp slots, as it could have been killed in any state. + For backwards compatibility, assume that the dead context has all the temps available at the beginning of the method -- i.e., at its initial PC" + currentPC := aContext pc ifNil: [ compiledCode initialPC ]. + ^ (self debugScopeAt: currentPC) readVariableNamed: aName fromContext: aContext ] { #category : 'api' }