Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/NewTools-Debugger-Tests/StDebuggerContextTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ StDebuggerContextTest >> setUp [
StDebuggerContextTest >> testArgumentsNodes [
|nodes|
debuggerContext context: self contextWithArgs.
nodes := debuggerContext temporaryVariablesNodes select: [ :tempNode | tempNode tempVariable isArgumentVariable ].
nodes := debuggerContext temporaryVariablesNodes select: [ :tempNode | tempNode isArgumentVariable ].
self assert: nodes size equals: 2.
self assert: nodes first key equals: 'i'.
self assert: nodes first variableTag equals: 'arg'.
self assert: nodes first rawValue equals: 4.
self assert: nodes first class equals: StInspectorTempNode.
self assert: nodes first class equals: StInspectorNewTempNode.
self assert: nodes second key equals: 'j'.
self assert: nodes second variableTag equals: 'arg'.
self assert: nodes second rawValue equals: 2.
self assert: nodes second class equals: StInspectorTempNode.
self assert: nodes second class equals: StInspectorNewTempNode.
self deny: (nodes anySatisfy: [:n| n key = 'self'])
]

{ #category : 'tests' }
StDebuggerContextTest >> testArgumentsNodesInBlock [
|nodes|
debuggerContext context: self contextWithArgsInBlock.
nodes := debuggerContext temporaryVariablesNodes select: [ :tempNode | tempNode tempVariable isArgumentVariable ].
nodes := debuggerContext temporaryVariablesNodes select: [ :tempNode | tempNode isArgumentVariable ].
self assert: nodes size equals: 2.
self assert: nodes first key equals: 'a'.
self assert: nodes first variableTag equals: 'arg'.
Expand Down Expand Up @@ -254,11 +254,11 @@ StDebuggerContextTest >> testTemporaryVariablesNodes [
self assert: nodes first key equals: 'a'.
self assert: nodes first variableTag equals: 'temp. var'.
self assert: nodes first rawValue equals: 0.
self assert: nodes first tempVariable isTempVariable.
self assert: nodes first isTempVariable.
self assert: nodes second key equals: 'b'.
self assert: nodes second variableTag equals: 'temp. var'.
self assert: nodes second rawValue equals: nil.
self assert: nodes first tempVariable isTempVariable.
self assert: nodes first isTempVariable.
self deny: (nodes anySatisfy: [:n| n key = 'self'])
]

Expand Down
4 changes: 2 additions & 2 deletions src/NewTools-Debugger-Tests/StDebuggerInspectorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ StDebuggerInspectorTest >> testUpdateLayoutForContextsWithAssertionFailure [
self
assert: assertionFailure actualObject
equals:
((session interruptedContext tempNamed: #aStringOrBlock) at: 2).
((session interruptedContext tempNamed: #aStringOrBlock) at: 1).
self
assert: assertionFailure expectedObject
equals:
((session interruptedContext tempNamed: #aStringOrBlock) at: 1)
((session interruptedContext tempNamed: #aStringOrBlock) at: 2)
]

{ #category : 'tests' }
Expand Down
24 changes: 11 additions & 13 deletions src/NewTools-Debugger-Tests/StDebuggerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ StDebuggerTest >> testContextChangedAfterStepOverAndReturn [
{ #category : 'tests - context inspector' }
StDebuggerTest >> testContextTempVarList [
| contextItems inspectorTable |

dbg := self debuggerOn: session.
inspectorTable := dbg inspector getRawInspectorPresenterOrNil attributeTable.

Expand All @@ -342,10 +342,10 @@ StDebuggerTest >> testContextTempVarList [
self assert: (contextItems at: 1) class equals: StInspectorSelfNode.

"Next nodes are temps"
self assert: (contextItems at: 2) tempVariable isTempVariable.
self assert: (contextItems at: 3) tempVariable isTempVariable.
self assert: (contextItems at: 4) tempVariable isTempVariable.
self assert: (contextItems at: 5) tempVariable isTempVariable.
self assert: (contextItems at: 2) isTempVariable.
self assert: (contextItems at: 3) isTempVariable.
self assert: (contextItems at: 4) isTempVariable.
self assert: (contextItems at: 5) isTempVariable.

"receiver"
self assert: (contextItems at: 6) rawValue identicalTo: session shortStack first receiver session.
Expand Down Expand Up @@ -413,8 +413,8 @@ StDebuggerTest >> testContextTempVarListUpdatesTempsWhenEnteringOrLeavingInlined
assert: (newContextItems at: i)
identicalTo: (contextItems at: i) ].

self assert: (newContextItems at: 9) tempVariable isTempVariable.
self assert: (newContextItems at: 9) tempVariable name equals: 'j'.
self assert: (newContextItems at: 9) isTempVariable.
self assert: (newContextItems at: 9) tempName equals: 'j'.

"We leave inlined block"
2 timesRepeat: [ dbg stepOver ].
Expand Down Expand Up @@ -458,11 +458,10 @@ StDebuggerTest >> testContextTempVarListUpdatesTempsWhenEnteringOrLeavingInlined
identicalTo: (contextItems at: i) ].

self assert:
(newContextItems at: contextItems size + 1) tempVariable
isTempVariable.
(newContextItems at: contextItems size + 1) isTempVariable.
self
assert:
(newContextItems at: contextItems size + 1) tempVariable name
(newContextItems at: contextItems size + 1) tempName
equals: 'list'.

"We leave inlined block"
Expand Down Expand Up @@ -621,7 +620,6 @@ StDebuggerTest >> testDiscardCodeChangesFor [
{ #category : 'tests - code pane' }
StDebuggerTest >> testDynamicVariableEvaluation [
|activeProcess debuggedProcess|
self skipOnPharoCITestingEnvironment.
debugger := StTestDebuggerProvider new
debuggerWithDynamicVariableSuspendedContext.
debugger initializeCode.
Expand Down Expand Up @@ -1308,11 +1306,11 @@ StDebuggerTest >> testUpdateLayoutForContextsIfAssertionFailure [
self
assert: assertionFailure actualObject
equals:
((session interruptedContext tempNamed: #aStringOrBlock) at: 2).
((session interruptedContext tempNamed: #aStringOrBlock) at: 1).
self
assert: assertionFailure expectedObject
equals:
((session interruptedContext tempNamed: #aStringOrBlock) at: 1)
((session interruptedContext tempNamed: #aStringOrBlock) at: 2)
]

{ #category : 'tests - code pane' }
Expand Down
31 changes: 17 additions & 14 deletions src/NewTools-Debugger-Tests/StTestDebuggerProvider.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,25 @@ StTestDebuggerProvider >> debuggerWithDNUContext [

{ #category : 'helpers' }
StTestDebuggerProvider >> debuggerWithDynamicVariableSuspendedContext [
|process|

| process progressSemaphore |
progressSemaphore := Semaphore new.
process := [
TestDynamicVariable value: 42 during: [
self assert:
(thisProcess psValueAt: TestDynamicVariable soleInstance index) = 42.
100 milliSeconds wait.
thisProcess suspend ] ] fork.
session := DebugSession
named: 'test session providerSessionFor:'
on: process
startedAt: process suspendedContext.
session exception:
(OupsNullException fromSignallerContext: process suspendedContext).
" self assert:
(process psValueAt: TestDynamicVariable soleInstance index) = 42."
TestDynamicVariable value: 42 during: [
self assert: (thisProcess psValueAt: TestDynamicVariable soleInstance index) = 42.
"Let's tell our owner that we are inside the block!"
progressSemaphore signal.
"And now we suspend ourselves"
thisProcess suspend ] ] fork.

"We wait until the process reaches the block.
Then we can continue"
progressSemaphore wait.

session := DebugSession named: 'test session providerSessionFor:' on: process startedAt: process suspendedContext.
session exception: (OupsNullException fromSignallerContext: process suspendedContext).
self assert: (process psValueAt: TestDynamicVariable soleInstance index) = 42.

^ self newDebugger
]

Expand Down
25 changes: 12 additions & 13 deletions src/NewTools-Debugger/StDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Class {
'programmaticallyClosed',
'stackAndCodeContainer',
'toolbarPresenter',
'previousASTScope'
'namesVisibleInPreviousScope'
],
#classVars : [
'EnableStackColoring'
Expand Down Expand Up @@ -1138,10 +1138,10 @@ StDebugger >> saveGeneratedCodeAndProceed [
{ #category : 'actions' }
StDebugger >> selectNextExecutedExpression [

| sourceNodeExecuted |
sourceNodeExecuted := self currentContext sourceNodeExecuted.
self code selectionInterval:
(sourceNodeExecuted start to: sourceNodeExecuted stop)
| interval previouslyExecutedPC |
previouslyExecutedPC := self currentContext executedPC.
interval := self currentContext method debugInfo rangeForPC: previouslyExecutedPC.
self code selectionInterval: (interval first to: interval last)
]

{ #category : 'stack' }
Expand Down Expand Up @@ -1555,8 +1555,7 @@ StDebugger >> updateInspectorFromContext: aContext [
isAssertionFailure:
self debuggerActionModel isInterruptedContextAnAssertEqualsFailure.
inspector updateWith: (self newDebuggerContextFor: aContext).
self flag: #DBG_INSPECTOR_UPDATE_BUG.
inspector getRawInspectorPresenterOrNil ifNotNil: [ :p | p update ]
self updateStep
]

{ #category : 'updating' }
Expand Down Expand Up @@ -1602,26 +1601,26 @@ StDebugger >> updateStackFromSession: aSession [
{ #category : 'updating' }
StDebugger >> updateStep [

| previousContext currentASTScope currentContext |
| previousContext currentlyVisibleNames currentContext |
previousContext := self currentContext.
self updateStackFromSession: self session.
self updateWindowTitle.
self updateExtensionsFromSession: self session.
self updateToolbar.

currentContext := self currentContext.
currentASTScope := (currentContext compiledCode sourceNodeForPC:
currentContext pc) scope.
currentlyVisibleNames := currentContext temporaryVariableNames.
self flag: #DBG_INSPECTOR_UPDATE_BUG.

inspector getRawInspectorPresenterOrNil ifNotNil: [ :p |
previousContext == currentContext ifTrue: [ "otherwise, if contexts have changed, updating the stack has already updated all nodes.""Here it is necessary to update temporary nodes if we are still in the same context but in a different scope. This is possible when leaving or entering an optimized block scope."
p
updateNodesFromScope:
(previousASTScope ifNil: [ currentASTScope ])
to: currentASTScope ].
(namesVisibleInPreviousScope ifNil: [ currentlyVisibleNames ])
to: currentlyVisibleNames ].
p update ].

previousASTScope := currentASTScope
namesVisibleInPreviousScope := currentlyVisibleNames
]

{ #category : 'toolbar' }
Expand Down
8 changes: 4 additions & 4 deletions src/NewTools-Debugger/StDebuggerContext.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ StDebuggerContext >> buildInspectorNodes [
nodes := OrderedCollection new.
tempsAndArgs := self temporaryVariablesNodes.
argsNodes := tempsAndArgs select: [ :tempNode |
tempNode tempVariable isArgumentVariable ].
tempNode isArgumentVariable ].
tempsNodes := tempsAndArgs select: [ :tempNode |
tempNode tempVariable isTempVariable ].
tempNode isTempVariable ].
nodes add: self selfNode.
nodes addAll: argsNodes.
nodes addAll: tempsNodes.
Expand Down Expand Up @@ -161,8 +161,8 @@ StDebuggerContext >> stackTopNode [
{ #category : 'nodes' }
StDebuggerContext >> temporaryVariablesNodes [

^ self context astScope allTemps collect: [ :temp |
(StInspectorTempNode hostObject: self context) tempVariable: temp ]
^ self context temporaryVariableNames collect: [ :arg1 |
(StInspectorNewTempNode hostObject: self context) tempName: arg1 ]
]

{ #category : 'nodes' }
Expand Down
15 changes: 6 additions & 9 deletions src/NewTools-Debugger/StRawInspectionPresenter.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,20 @@ StRawInspectionPresenter >> selectedPageName [
]

{ #category : '*NewTools-Debugger' }
StRawInspectionPresenter >> updateNodesFromScope: oldASTScope to: newASTScope [
StRawInspectionPresenter >> updateNodesFromScope: oldTemps to: newTemps [

| nodes newTemps oldTemps tempsToRemove tempsToAdd |
oldTemps := oldASTScope allTemps.
newTemps := newASTScope allTemps.
| nodes tempsToRemove tempsToAdd |
tempsToRemove := oldTemps difference: newTemps.
tempsToAdd := newTemps difference: oldTemps.
nodes := self attributeTable roots.

nodes removeAllSuchThat: [ :node |
node class = StInspectorTempNode and: [
tempsToRemove includes: node tempVariable ] ].
node class = StInspectorNewTempNode and: [
tempsToRemove includes: node tempName ] ].
tempsToAdd do: [ :temp |
nodes add:
((StInspectorTempNode hostObject:
((StInspectorNewTempNode hostObject:
self model inspectedObject context)
tempVariable: temp;
tempName: temp;
yourself) ].

self attributeTable roots: nodes
Expand Down
107 changes: 107 additions & 0 deletions src/NewTools-Inspector/StInspectorNewTempNode.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"
I am a variable node for representing a temporary variable stored in a Context object that has a name attached.
This includes local variables and method parameters.
"
Class {
#name : 'StInspectorNewTempNode',
#superclass : 'StInspectorNode',
#instVars : [
'debugInfo',
'tempName'
],
#category : 'NewTools-Inspector-Model',
#package : 'NewTools-Inspector',
#tag : 'Model'
}

{ #category : 'comparing' }
StInspectorNewTempNode >> = anObject [

self == anObject ifTrue: [ ^ true ].
nil.
self class = anObject class ifFalse: [ ^ false ].
^ tempName = anObject tempName and: [ hostObject = anObject hostObject ]
]

{ #category : 'accessing' }
StInspectorNewTempNode >> children [
^ #()
]

{ #category : 'accessing' }
StInspectorNewTempNode >> debugInfo [

^ debugInfo
]

{ #category : 'accessing' }
StInspectorNewTempNode >> debugInfo: anObject [

debugInfo := anObject
]

{ #category : 'accessing' }
StInspectorNewTempNode >> debugScope [

^ debugInfo debugScopeAt:
(self hostObject executedPC max: self hostObject method initialPC)
]

{ #category : 'comparing' }
StInspectorNewTempNode >> hash [

"Answer an integer value that is related to the identity of the receiver."

^ tempName hash bitXor: (hostObject hash)
]

{ #category : 'accessing' }
StInspectorNewTempNode >> hostObject: aContext [

super hostObject: aContext.
debugInfo := aContext method debugInfo.
]

{ #category : 'accessing' }
StInspectorNewTempNode >> isArgumentVariable [

^ self debugScope isArgumentNamed: tempName
]

{ #category : 'accessing' }
StInspectorNewTempNode >> isTempVariable [

^ self isArgumentVariable not
]

{ #category : 'accessing' }
StInspectorNewTempNode >> key [

^ tempName
]

{ #category : 'accessing' }
StInspectorNewTempNode >> rawValue [

^ self debugScope
readVariableNamed: tempName
fromContext: self hostObject
]

{ #category : 'accessing' }
StInspectorNewTempNode >> tempName [

^ tempName
]

{ #category : 'accessing' }
StInspectorNewTempNode >> tempName: anObject [

tempName := anObject
]

{ #category : 'accessing' }
StInspectorNewTempNode >> variableTag [

^ self isArgumentVariable ifTrue: [ 'arg' ] ifFalse: [ 'temp. var' ]
]
Loading