Change Process>>evaluate:onBehalfOf: to update
all non-scheduling variables, such as name and env,
to ensure that access to these variables during
debugging answers those of the debugged process.
This is a smaller, if tricker, change than that in
=============== Diff against Kernel-ul.893 ===============
Item was changed:
----- Method: Process>>evaluate:onBehalfOf: (in category 'private') -----
evaluate: aBlock onBehalfOf: aProcess
+ "Evaluate aBlock setting effectiveProcess to aProcess, and all other variables other than
+ the scheduling ones to those of aProcess. Used in the execution simulation machinery
+ to ensure that Processor activeProcess evaluates correctly when debugging."
+ | range savedVariables |
+ "range accesses everything after myList, e.g. threadId, effectiveProcess, name, island, env"
+ range := 5 to: Process instSize.
+ savedVariables := range collect: [:i| self instVarAt: i].
+ range do:
+ [:i| self instVarAt: i put: (aProcess instVarAt: i)].
- "Evaluate aBlock setting effectiveProcess to aProcess. Used
- in the execution simulation machinery to ensure that
- Processor activeProcess evaluates correctly when debugging."
- | oldEffectiveProcess |
- oldEffectiveProcess := effectiveProcess.
effectiveProcess := aProcess.
+ ^aBlock ensure:
+ ["write back any assigned-to variables."
+ range do:
+ [:i| | v |
+ (v := self instVarAt: i) ~~ (aProcess instVarAt: i) ifTrue:
+ [aProcess instVarAt: i put: v]].
+ "restore old values"
+ range with: savedVariables do:
+ [:i :var| self instVarAt: i put: var]]!
- ^aBlock ensure: [effectiveProcess := oldEffectiveProcess]!