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
29 changes: 29 additions & 0 deletions Sindarin-Tests/SindarinDebuggerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,35 @@ SindarinDebuggerTest >> testSkip [
self assert: p equals: nil
]

{ #category : #tests }
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 |
Expand Down
14 changes: 12 additions & 2 deletions Sindarin/SindarinDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,20 @@ SindarinDebugger >> skip [
{ #category : #'stepping - skip' }
SindarinDebugger >> skipAssignmentNodeCompletely [

| currentBytecode |
currentBytecode := self currentBytecode detect: [ :each |
each offset = self context pc ].

"Pop the value that will be assigned"
self context pop.
"Pop the value to be assigned"

"If the assignment is a store bytecode and not a pop bytecode, we push the current value of the variable that was going to be assigned."
(#( 243 244 245 252 ) includes: currentBytecode bytes first) ifTrue: [
self context push:
(self node variable variableValueInContext: self context) ].

"Increase the pc to go over the assignment"
self context pc: (self context pc) + (self currentBytecode detect: [:each | each offset = self context pc ]) bytes size.
self context pc: self context pc + currentBytecode 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
Expand Down