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
51 changes: 35 additions & 16 deletions Sindarin-Tests/SindarinDebuggerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -568,22 +568,7 @@ SindarinDebuggerTest >> testSkip [
self assert: p equals: Point
]

{ #category : #tests }
SindarinDebuggerTest >> testSkipSkipsMessagesByPuttingReceiverOnStack [

| a scdbg |
a := 1.
scdbg := SindarinDebugger
debug: [ a := a + 2 ].
self assert: a equals: 1.

scdbg skip.
scdbg step.

self assert: a equals: 1
]

{ #category : #tests }
{ #category : #'tests - skipping' }
SindarinDebuggerTest >> testSkipAssignmentWithStoreIntoBytecodePushesReplacementValueButNotWithPopIntoBytecode [

| a b dbg aFormerValue bFormerValue |
Expand Down Expand Up @@ -612,6 +597,40 @@ SindarinDebuggerTest >> testSkipAssignmentWithStoreIntoBytecodePushesReplacement
self assert: a equals: aFormerValue
]

{ #category : #tests }
SindarinDebuggerTest >> testSkipSkipsMessagesByPuttingReceiverOnStack [

| a scdbg |
a := 1.
scdbg := SindarinDebugger
debug: [ a := a + 2 ].
self assert: a equals: 1.

scdbg skip.
scdbg step.

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 |
Expand Down
11 changes: 9 additions & 2 deletions Sindarin/SindarinDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,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"
Expand Down Expand Up @@ -572,7 +579,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
Expand All @@ -587,7 +594,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
Expand Down