Skip to content

Commit 58c5f6c

Browse files
committed
Better support for copying vars in debug info
1 parent b1bab7b commit 58c5f6c

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/DebugInfo-Tests/DebugInfoTest.class.st

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,27 @@ DebugInfoTest >> testReadOuterBlockCopiedTemporaryVariableFromClosure [
958958
self assert: debugInfo notNil
959959
]
960960

961+
{ #category : 'tests - read variables' }
962+
DebugInfoTest >> testReadOuterBlockCopiedTemporaryVariableFromClosureWithDeadOuter [
963+
"This test is tricky.
964+
965+
This is a variation of testReadOuterBlockCopiedTemporaryVariableFromClosure where the outer context is dead.
966+
The value was copied into the current context so, we should be able to read it!
967+
"
968+
969+
| debugInfo context |
970+
context := [ :blockArgument |
971+
| tempInBlock |
972+
tempInBlock := 42.
973+
[ "tempInBlock is candidate to be copied in the block activation"
974+
tempInBlock.
975+
976+
thisContext copy ] value ] value: 7.
977+
978+
debugInfo := self newDebugInfoFor: context method.
979+
self assert: (debugInfo readVariableNamed: #tempInBlock fromContext: context) equals: 42
980+
]
981+
961982
{ #category : 'tests - read variables' }
962983
DebugInfoTest >> testReadOuterBlockTempVectorTemporaryVariableFromClosure [
963984
"This test is tricky.

src/DebugInfo/OnlineSourceDebugInfo.class.st

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ OnlineSourceDebugInfo >> asOfflineDebugInfo [
8787

8888
scopes := Dictionary new.
8989
astScopes do: [ :astScope |
90-
| cachedScope tempDescriptions |
90+
| onlineScope cachedScope tempDescriptions |
91+
onlineScope := OnlineSourceDebugScope on: astScope.
9192
cachedScope := OfflineSourceDebugScope new.
92-
tempDescriptions := astScope allTemps collect: [ :temp |
93+
tempDescriptions := onlineScope variables collect: [ :temp |
9394
temp descriptionArrayForScope: astScope ].
9495
(astScope isBlockScope and: [ astScope isOptimized ])
9596
ifTrue: [

src/DebugInfo/OnlineSourceDebugScope.class.st

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@ OnlineSourceDebugScope >> variableNames [
6161
{ #category : 'accessing' }
6262
OnlineSourceDebugScope >> variables [
6363

64-
^ astScope allTemps
64+
"Consider copied vars first.
65+
They override variables from the scope"
66+
| vars |
67+
vars := astScope copiedVars copy.
68+
astScope allTemps do: [ :e |
69+
vars at: e name ifAbsentPut: e.
70+
].
71+
^ vars values
6572
]

0 commit comments

Comments
 (0)