From d4954f5d8f09d3925fa163bcdbe75c0ae2f12738 Mon Sep 17 00:00:00 2001 From: adri09070 Date: Tue, 5 Jul 2022 15:13:18 +0200 Subject: [PATCH 1/4] Fixing skip so that it increments the pc by the number of bytes in the next bytecode --- Sindarin-Tests/SindarinDebuggerTest.class.st | 19 +++++++++++++++++++ ...RBBlockDefinitionSearchingVisitor.class.st | 8 -------- Sindarin/SindarinDebugger.class.st | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Sindarin-Tests/SindarinDebuggerTest.class.st b/Sindarin-Tests/SindarinDebuggerTest.class.st index 6a5d9d8..94a23d4 100644 --- a/Sindarin-Tests/SindarinDebuggerTest.class.st +++ b/Sindarin-Tests/SindarinDebuggerTest.class.st @@ -587,6 +587,25 @@ SindarinDebuggerTest >> testSkipSkipsMessagesByPuttingReceiverOnStack [ self assert: a equals: 1 ] +{ #category : #tests } +SindarinDebuggerTest >> testSkipSkipsSuperSendBytecodesCorrectly [ + + | a scdbg oldValueOfA negatedContext | + a := ScaledDecimal newFromNumber: 3 scale: 2. + scdbg := SindarinDebugger debug: [ a := a negated ]. + oldValueOfA := a. + + scdbg + step; + stepOver; + skip. + negatedContext := scdbg context. + scdbg stepUntil: [ scdbg context == negatedContext ]. + scdbg stepOver. + + self assert: a equals: oldValueOfA +] + { #category : #'tests - skipping' } SindarinDebuggerTest >> testSkipThroughNode [ | dbg realExecPC realValueOfA targetExecNode realExecTopStack nodeAfterSkipThrough | diff --git a/Sindarin/RBBlockDefinitionSearchingVisitor.class.st b/Sindarin/RBBlockDefinitionSearchingVisitor.class.st index 3747182..f3df629 100644 --- a/Sindarin/RBBlockDefinitionSearchingVisitor.class.st +++ b/Sindarin/RBBlockDefinitionSearchingVisitor.class.st @@ -8,14 +8,6 @@ Class { #category : #Sindarin } -{ #category : #'instance creation' } -RBBlockDefinitionSearchingVisitor class >> newToSearch: aBlockNode [ - - ^ self new - blockToSearch: aBlockNode; - yourself -] - { #category : #accessing } RBBlockDefinitionSearchingVisitor >> blockToSearch: aBlockNode [ diff --git a/Sindarin/SindarinDebugger.class.st b/Sindarin/SindarinDebugger.class.st index 65d3e1c..4f4f5bb 100644 --- a/Sindarin/SindarinDebugger.class.st +++ b/Sindarin/SindarinDebugger.class.st @@ -563,7 +563,7 @@ SindarinDebugger >> skipMessageNode [ self node arguments do: [ :arg | self context pop ]. "Pop the arguments of the message send from the context's value stack" "Increase the pc to go over the message send" - self context pc: self context pc + 1. + self context pc: self context pc + self nextBytecode bytes size. "Execute bytecodes the debugger usually executes without stopping the execution (for example popping the return value of the just executed message send if it is not used afterwards)" self debugSession stepToFirstInterestingBytecodeIn: self debugSession interruptedProcess @@ -578,7 +578,7 @@ SindarinDebugger >> skipMessageNodeWith: replacementValue [ "Push the replacement value on the context's value stack, to simulate that the message send happened and returned nil" self context push: replacementValue. "Increase the pc to go over the message send" - self context pc: self context pc + 1. + self context pc: self context pc + self nextBytecode bytes size. "Execute bytecodes the debugger usually executes without stopping the execution (for example popping the return value of the just executed message send if it is not used afterwards)" self debugSession stepToFirstInterestingBytecodeIn: self debugSession interruptedProcess From 502e2bccdc73b48193179ec990854ec43b4cb9a7 Mon Sep 17 00:00:00 2001 From: adri09070 Date: Tue, 5 Jul 2022 15:44:26 +0200 Subject: [PATCH 2/4] adding a method I forgot to commit --- Sindarin/SindarinDebugger.class.st | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sindarin/SindarinDebugger.class.st b/Sindarin/SindarinDebugger.class.st index 4f4f5bb..b6b9f0d 100644 --- a/Sindarin/SindarinDebugger.class.st +++ b/Sindarin/SindarinDebugger.class.st @@ -363,6 +363,13 @@ SindarinDebugger >> method [ ^ self context method ] +{ #category : #'accessing - bytes' } +SindarinDebugger >> nextBytecode [ + + ^ self currentBytecode detect: [ :each | + each offset = self context pc ] +] + { #category : #astAndAstMapping } SindarinDebugger >> node [ "Returns the AST node about to be executed by the top context of the execution" From 4148bad72455088330e4b7adef5f2a20c122cc2e Mon Sep 17 00:00:00 2001 From: adri09070 Date: Fri, 8 Jul 2022 15:37:25 +0200 Subject: [PATCH 3/4] calling skipMessage in skip + fixing test + reverting the suppression of a method in RBBlockDefinitionSearchingVisitor class --- Sindarin-Tests/SindarinDebuggerTest.class.st | 2 +- Sindarin/RBBlockDefinitionSearchingVisitor.class.st | 8 ++++++++ Sindarin/SindarinDebugger.class.st | 6 ++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sindarin-Tests/SindarinDebuggerTest.class.st b/Sindarin-Tests/SindarinDebuggerTest.class.st index 94a23d4..0e16b01 100644 --- a/Sindarin-Tests/SindarinDebuggerTest.class.st +++ b/Sindarin-Tests/SindarinDebuggerTest.class.st @@ -928,5 +928,5 @@ SindarinDebuggerTest >> testskipUpToNodeSkipTargetNode [ returnNode := (self class >> #helperMethod1) ast statements last. dbg step; skipThroughNode: returnNode. self assert: dbg node equals: returnNode. - self assert: dbg topStack equals: nil + self assert: dbg topStack equals: Point ] diff --git a/Sindarin/RBBlockDefinitionSearchingVisitor.class.st b/Sindarin/RBBlockDefinitionSearchingVisitor.class.st index f3df629..3747182 100644 --- a/Sindarin/RBBlockDefinitionSearchingVisitor.class.st +++ b/Sindarin/RBBlockDefinitionSearchingVisitor.class.st @@ -8,6 +8,14 @@ Class { #category : #Sindarin } +{ #category : #'instance creation' } +RBBlockDefinitionSearchingVisitor class >> newToSearch: aBlockNode [ + + ^ self new + blockToSearch: aBlockNode; + yourself +] + { #category : #accessing } RBBlockDefinitionSearchingVisitor >> blockToSearch: aBlockNode [ diff --git a/Sindarin/SindarinDebugger.class.st b/Sindarin/SindarinDebugger.class.st index b6b9f0d..1c9104b 100644 --- a/Sindarin/SindarinDebugger.class.st +++ b/Sindarin/SindarinDebugger.class.st @@ -534,9 +534,11 @@ SindarinDebugger >> sindarinSession: aSindarinDebugSession [ { #category : #'stepping - skip' } SindarinDebugger >> skip [ + "If it is a message send or assignment, skips the execution of the current instruction, and puts nil on the execution stack." - self node isAssignment - ifTrue: [ ^ self skipAssignmentNodeCompletely ]. + + self node isAssignment ifTrue: [ ^ self skipAssignmentNodeCompletely ]. + self node isMessage ifTrue: [ ^ self skipMessageNode ]. self skipWith: nil ] From 4f274c8fc5c53717667d9d4ecb4e8d146985c975 Mon Sep 17 00:00:00 2001 From: adri09070 Date: Tue, 19 Jul 2022 15:17:14 +0200 Subject: [PATCH 4/4] categorizing method --- Sindarin-Tests/SindarinDebuggerTest.class.st | 57 ++++++++++---------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/Sindarin-Tests/SindarinDebuggerTest.class.st b/Sindarin-Tests/SindarinDebuggerTest.class.st index 0efb631..d38a5f0 100644 --- a/Sindarin-Tests/SindarinDebuggerTest.class.st +++ b/Sindarin-Tests/SindarinDebuggerTest.class.st @@ -568,6 +568,35 @@ SindarinDebuggerTest >> testSkip [ self assert: p equals: Point ] +{ #category : #'tests - skipping' } +SindarinDebuggerTest >> testSkipAssignmentWithStoreIntoBytecodePushesReplacementValueButNotWithPopIntoBytecode [ + + | a b dbg aFormerValue bFormerValue | + dbg := SindarinDebugger debug: [ + b := 1. + [ + a := 2. + a := b := 3 + 4 ] value. + ^ 42 ]. + dbg step. + dbg step. + dbg stepThrough. "we enter the block" + + dbg skip. "we skip the assignment a:= 2" + self assert: dbg topStack equals: 4. + self assert: a equals: nil. + + bFormerValue := b. + dbg step. dbg skip. "we skip the assignment b := 3 + 4" + self assert: dbg topStack equals: bFormerValue. + self assert: b equals: bFormerValue. + + aFormerValue := a. + dbg skip. "we skip the assignment a:= (b := 3 + 4)" + self assert: dbg topStack equals: aFormerValue. + self assert: a equals: aFormerValue +] + { #category : #tests } SindarinDebuggerTest >> testSkipSkipsMessagesByPuttingReceiverOnStack [ @@ -602,34 +631,6 @@ SindarinDebuggerTest >> testSkipSkipsSuperSendBytecodesCorrectly [ self assert: a equals: oldValueOfA ] -SindarinDebuggerTest >> testSkipAssignmentWithStoreIntoBytecodePushesReplacementValueButNotWithPopIntoBytecode [ - - | a b dbg aFormerValue bFormerValue | - dbg := SindarinDebugger debug: [ - b := 1. - [ - a := 2. - a := b := 3 + 4 ] value. - ^ 42 ]. - dbg step. - dbg step. - dbg stepThrough. "we enter the block" - - dbg skip. "we skip the assignment a:= 2" - self assert: dbg topStack equals: 4. - self assert: a equals: nil. - - bFormerValue := b. - dbg step. dbg skip. "we skip the assignment b := 3 + 4" - self assert: dbg topStack equals: bFormerValue. - self assert: b equals: bFormerValue. - - aFormerValue := a. - dbg skip. "we skip the assignment a:= (b := 3 + 4)" - self assert: dbg topStack equals: aFormerValue. - self assert: a equals: aFormerValue -] - { #category : #'tests - skipping' } SindarinDebuggerTest >> testSkipThroughNode [ | dbg realExecPC realValueOfA targetExecNode realExecTopStack nodeAfterSkipThrough |