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
104 changes: 79 additions & 25 deletions Sindarin-Tests/SindarinDebuggerTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ Class {
#category : #'Sindarin-Tests'
}

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod1 [
| a |
a := 1.
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod10 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod11 [
| a |
a := 5.
Expand All @@ -31,145 +32,145 @@ SindarinDebuggerTests >> helperMethod11 [
^ 3
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod12 [
| i |
i := 5.
[ i=0 ] whileFalse: [ i := i - 1 ].
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod13 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod14 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod15 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod16 [
^ 1+1.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod17: storeContextBlock [
storeContextBlock value: thisContext.
Point x:5 y: 7.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod18: anArg with: anotherArg [
Point x: 5 y: 7.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod19 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod2 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod20 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod21 [
self helperMethod22
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod22 [
^ Point new
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod23 [
testObjectPoint sign.
testObjectPoint extent: (Point x:3 y: 4).
Point new.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod24 [
| p |
p := Point new.
p sign.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod3 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod4 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod5 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod6 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod7 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod8 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #helpers }
SindarinDebuggerTests >> helperMethod9 [
| a |
a := 5.
^ Point x: 5 y: '3' asInteger.
]

{ #category : #tests }
{ #category : #running }
SindarinDebuggerTests >> runCaseManaged [
^ self runCase
]
Expand Down Expand Up @@ -399,6 +400,17 @@ SindarinDebuggerTests >> testOnceBreakpoint [
self assert: scdbg isExecutionFinished
]

{ #category : #tests }
SindarinDebuggerTests >> testPc [
| dbg |
dbg := SindarinDebugger
debug: [ | a p |
a := 2.
p := Point x: 2 y: 3 ].
dbg step; step; step.
self assert: dbg pc equals: dbg context pc
]

{ #category : #tests }
SindarinDebuggerTests >> testReceiver [
| scdbg |
Expand Down Expand Up @@ -455,6 +467,28 @@ SindarinDebuggerTests >> testSkip [
self assert: p equals: nil
]

{ #category : #tests }
SindarinDebuggerTests >> testSkipToPC [
| dbg realExecPC realValueOfA realExecNode realExecTopStack |
dbg := SindarinDebugger
debug: [ self helperMethod1 ].
dbg step; stepOver; stepOver.
realExecPC := dbg pc.
realExecNode := dbg node.
realValueOfA := (dbg temporaryNamed: #a).
realExecTopStack := dbg topStack.

dbg := SindarinDebugger
debug: [ self helperMethod1 ].

dbg step; stepOver; skipToPC: realExecPC.
self assert: dbg pc equals: realExecPC.
self assert: dbg node equals: realExecNode.
self assert: realValueOfA equals: 5.
self assert: (dbg temporaryNamed: #a) equals: 1.
self assert: dbg topStack equals: realExecTopStack
]

{ #category : #tests }
SindarinDebuggerTests >> testSkipWith [
| a p scdbg |
Expand Down Expand Up @@ -558,6 +592,26 @@ SindarinDebuggerTests >> testTemporaries [
self assert: (scdbg temporaries at: #a) equals: 5
]

{ #category : #tests }
SindarinDebuggerTests >> testTemporaryNamed [
| dbg |
dbg := SindarinDebugger debug: [ self helperMethod10 ].
dbg step.
self assert: dbg temporaries size equals: 1.
self assert: (dbg temporaryNamed: #a) equals: nil.
dbg step.
self assert: (dbg temporaryNamed: #a) equals: 5
]

{ #category : #tests }
SindarinDebuggerTests >> testTopStack [
| a dbg |
a := 1.
dbg := SindarinDebugger debug: [ a := 2 ].
dbg step.
self assert: dbg topStack equals: 2
]

{ #category : #tests }
SindarinDebuggerTests >> testWhenHitBreakpoint [
| breakpoint toggle scdbg |
Expand Down
38 changes: 37 additions & 1 deletion Sindarin/SindarinDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ SindarinDebugger >> attachTo: aDebugSession [

sindarinSession := aDebugSession asSindarinDebugSession.
process := aDebugSession interruptedProcess.
sindarinSession deactivateEventTriggering
sindarinSession deactivateEventTriggering.
debugStarted := true
]

{ #category : #astAndAstMapping }
SindarinDebugger >> bestNodeFor: anInterval [
^self node methodNode bestNodeFor: anInterval
]

{ #category : #stackAccess }
Expand Down Expand Up @@ -308,6 +314,11 @@ SindarinDebugger >> openInGraphicalDebugger [
'Should be an extension of DebuggerSelector and handled by its sole instance'
]

{ #category : #accessing }
SindarinDebugger >> pc [
^ self context pc
]

{ #category : #stepping }
SindarinDebugger >> proceed [
"alias of #continue"
Expand Down Expand Up @@ -408,6 +419,21 @@ SindarinDebugger >> skipMessageNodeWith: replacementValue [
stepToFirstInterestingBytecodeIn: self debugSession interruptedProcess
]

{ #category : #stepping }
SindarinDebugger >> skipToPC: aProgramNode [
"Skips execution until program counter reaches aProgramNode."
[ self node == aProgramNode ] whileFalse: [ self skip ]
]

{ #category : #stepping }
SindarinDebugger >> skipToPC: aProgramNode skipToNextNode: skipTargetNode [
"Skips execution until program counter reaches aProgramNode."

[ self node == aProgramNode ] whileFalse: [ self skip ].
aProgramNode isReturn ifTrue: [ ^ self ].
skipTargetNode ifTrue: [ self skip ]
]

{ #category : #stepping }
SindarinDebugger >> skipWith: replacementValue [
"If it is a message-send or assignment, skips the execution of the current instruction, and puts the replacementValue on the execution stack."
Expand Down Expand Up @@ -486,3 +512,13 @@ SindarinDebugger >> temporaries [

^ self context temporaries
]

{ #category : #stackAccessHelpers }
SindarinDebugger >> temporaryNamed: aSymbol [
^self temporaries at: aSymbol
]

{ #category : #stackAccessHelpers }
SindarinDebugger >> topStack [
^self context top
]