Commits

Eliot Miranda committed 8a1e4d6

Fix temp access in the debugger when the temp is in an indirect temp vector and the indirect temp vector is copied by a block within the method. The old code looked for the most local value of the remote vector, which would then answer nil in getValueOf: due to the myDepth >= info contextDepth guard. This would cause any variables in the remote vector to have the value nil unless in the innermost block scope that copied the indirection vector. The new code uses the leastLocalValue of the indirection vector when getting the value of a temp within it.

Comments (0)

Files changed (1)

Newspeak2SqueakCompilation.ns3

 		ifTrue: [0 (* method *)] 
 		ifFalse: [1 + (depthOfContext: ctxt closure outerContext)]
 )
+getLeastLocalValueOf: varName <Symbol> ^<Object> = (
+	| info |
+	info:: leastLocalInfoFor: varName.
+	(* defensive programming, but should be unnecessary now that
+	 DebugMapper>localNames filters out variables in deeper contexts. *)
+	myDepth >= info contextDepth ifFalse:
+		[^nil].
+	^info remoteVector isNil
+		ifTrue:  [(contextAtDepth: info contextDepth) tempAt: info zeroOriginOffset + 1]
+		ifFalse: [(getValueOf: info remoteVector) ifNotNil:
+					[:rv| rv at: info zeroOriginOffset + 1]]
+)
 getValueOf: varName <Symbol> ^<Object> = (
 	| info |
 	info:: mostLocalInfoFor: varName.
 		[^nil].
 	^info remoteVector isNil
 		ifTrue:  [(contextAtDepth: info contextDepth) tempAt: info zeroOriginOffset + 1]
-		ifFalse: [(getValueOf: info remoteVector) ifNotNil:
+		ifFalse: [(getLeastLocalValueOf: info remoteVector) ifNotNil:
 					[:rv| rv at: info zeroOriginOffset + 1]]
 )
 getterAstFor: varName <Symbol> ^<SendAST> = (
 				sel: #at:;
 				args: {NumberAST new val: info zeroOriginOffset + 1})]
 )
+leastLocalInfoFor: varName <Symbol> ^<LocalVarDebugInfo> = (
+	
+	| bestInfo |
+	debugInfo localVariables do: [:info |
+		(info name = varName and: [info validPCRange includes: pc]) ifTrue: [
+			(bestInfo isNil or: [info contextDepth < bestInfo contextDepth]) ifTrue: [
+				bestInfo:: info]]].
+	bestInfo notNil ifFalse: [deny].
+	^bestInfo
+)
 localNames = (
 	| names |
 	names: OrderedCollection new.