Skip to content

Commit f07c06b

Browse files
Merge pull request #7 from dupriezt/Breaking-SinDebugSession-Inheritance-Refactoring
Breaking sin debug session inheritance refactoring
2 parents 97484dd + 4429ea6 commit f07c06b

File tree

2 files changed

+116
-26
lines changed

2 files changed

+116
-26
lines changed

Sindarin-Tests/SindarinDebuggerTests.class.st

Lines changed: 79 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ Class {
88
#category : #'Sindarin-Tests'
99
}
1010

11-
{ #category : #tests }
11+
{ #category : #helpers }
1212
SindarinDebuggerTests >> helperMethod1 [
1313
| a |
14+
a := 1.
1415
a := 5.
1516
^ Point x: 5 y: '3' asInteger.
1617
]
1718

18-
{ #category : #tests }
19+
{ #category : #helpers }
1920
SindarinDebuggerTests >> helperMethod10 [
2021
| a |
2122
a := 5.
2223
^ Point x: 5 y: '3' asInteger.
2324
]
2425

25-
{ #category : #tests }
26+
{ #category : #helpers }
2627
SindarinDebuggerTests >> helperMethod11 [
2728
| a |
2829
a := 5.
@@ -31,145 +32,145 @@ SindarinDebuggerTests >> helperMethod11 [
3132
^ 3
3233
]
3334

34-
{ #category : #tests }
35+
{ #category : #helpers }
3536
SindarinDebuggerTests >> helperMethod12 [
3637
| i |
3738
i := 5.
3839
[ i=0 ] whileFalse: [ i := i - 1 ].
3940
]
4041

41-
{ #category : #tests }
42+
{ #category : #helpers }
4243
SindarinDebuggerTests >> helperMethod13 [
4344
| a |
4445
a := 5.
4546
^ Point x: 5 y: '3' asInteger.
4647
]
4748

48-
{ #category : #tests }
49+
{ #category : #helpers }
4950
SindarinDebuggerTests >> helperMethod14 [
5051
| a |
5152
a := 5.
5253
^ Point x: 5 y: '3' asInteger.
5354
]
5455

55-
{ #category : #tests }
56+
{ #category : #helpers }
5657
SindarinDebuggerTests >> helperMethod15 [
5758
| a |
5859
a := 5.
5960
^ Point x: 5 y: '3' asInteger.
6061
]
6162

62-
{ #category : #tests }
63+
{ #category : #helpers }
6364
SindarinDebuggerTests >> helperMethod16 [
6465
^ 1+1.
6566
]
6667

67-
{ #category : #tests }
68+
{ #category : #helpers }
6869
SindarinDebuggerTests >> helperMethod17: storeContextBlock [
6970
storeContextBlock value: thisContext.
7071
Point x:5 y: 7.
7172
]
7273

73-
{ #category : #tests }
74+
{ #category : #helpers }
7475
SindarinDebuggerTests >> helperMethod18: anArg with: anotherArg [
7576
Point x: 5 y: 7.
7677
]
7778

78-
{ #category : #tests }
79+
{ #category : #helpers }
7980
SindarinDebuggerTests >> helperMethod19 [
8081
| a |
8182
a := 5.
8283
^ Point x: 5 y: '3' asInteger.
8384
]
8485

85-
{ #category : #tests }
86+
{ #category : #helpers }
8687
SindarinDebuggerTests >> helperMethod2 [
8788
| a |
8889
a := 5.
8990
^ Point x: 5 y: '3' asInteger.
9091
]
9192

92-
{ #category : #tests }
93+
{ #category : #helpers }
9394
SindarinDebuggerTests >> helperMethod20 [
9495
| a |
9596
a := 5.
9697
^ Point x: 5 y: '3' asInteger.
9798
]
9899

99-
{ #category : #tests }
100+
{ #category : #helpers }
100101
SindarinDebuggerTests >> helperMethod21 [
101102
self helperMethod22
102103
]
103104

104-
{ #category : #tests }
105+
{ #category : #helpers }
105106
SindarinDebuggerTests >> helperMethod22 [
106107
^ Point new
107108
]
108109

109-
{ #category : #tests }
110+
{ #category : #helpers }
110111
SindarinDebuggerTests >> helperMethod23 [
111112
testObjectPoint sign.
112113
testObjectPoint extent: (Point x:3 y: 4).
113114
Point new.
114115
]
115116

116-
{ #category : #tests }
117+
{ #category : #helpers }
117118
SindarinDebuggerTests >> helperMethod24 [
118119
| p |
119120
p := Point new.
120121
p sign.
121122
]
122123

123-
{ #category : #tests }
124+
{ #category : #helpers }
124125
SindarinDebuggerTests >> helperMethod3 [
125126
| a |
126127
a := 5.
127128
^ Point x: 5 y: '3' asInteger.
128129
]
129130

130-
{ #category : #tests }
131+
{ #category : #helpers }
131132
SindarinDebuggerTests >> helperMethod4 [
132133
| a |
133134
a := 5.
134135
^ Point x: 5 y: '3' asInteger.
135136
]
136137

137-
{ #category : #tests }
138+
{ #category : #helpers }
138139
SindarinDebuggerTests >> helperMethod5 [
139140
| a |
140141
a := 5.
141142
^ Point x: 5 y: '3' asInteger.
142143
]
143144

144-
{ #category : #tests }
145+
{ #category : #helpers }
145146
SindarinDebuggerTests >> helperMethod6 [
146147
| a |
147148
a := 5.
148149
^ Point x: 5 y: '3' asInteger.
149150
]
150151

151-
{ #category : #tests }
152+
{ #category : #helpers }
152153
SindarinDebuggerTests >> helperMethod7 [
153154
| a |
154155
a := 5.
155156
^ Point x: 5 y: '3' asInteger.
156157
]
157158

158-
{ #category : #tests }
159+
{ #category : #helpers }
159160
SindarinDebuggerTests >> helperMethod8 [
160161
| a |
161162
a := 5.
162163
^ Point x: 5 y: '3' asInteger.
163164
]
164165

165-
{ #category : #tests }
166+
{ #category : #helpers }
166167
SindarinDebuggerTests >> helperMethod9 [
167168
| a |
168169
a := 5.
169170
^ Point x: 5 y: '3' asInteger.
170171
]
171172

172-
{ #category : #tests }
173+
{ #category : #running }
173174
SindarinDebuggerTests >> runCaseManaged [
174175
^ self runCase
175176
]
@@ -399,6 +400,17 @@ SindarinDebuggerTests >> testOnceBreakpoint [
399400
self assert: scdbg isExecutionFinished
400401
]
401402

403+
{ #category : #tests }
404+
SindarinDebuggerTests >> testPc [
405+
| dbg |
406+
dbg := SindarinDebugger
407+
debug: [ | a p |
408+
a := 2.
409+
p := Point x: 2 y: 3 ].
410+
dbg step; step; step.
411+
self assert: dbg pc equals: dbg context pc
412+
]
413+
402414
{ #category : #tests }
403415
SindarinDebuggerTests >> testReceiver [
404416
| scdbg |
@@ -455,6 +467,28 @@ SindarinDebuggerTests >> testSkip [
455467
self assert: p equals: nil
456468
]
457469

470+
{ #category : #tests }
471+
SindarinDebuggerTests >> testSkipToPC [
472+
| dbg realExecPC realValueOfA realExecNode realExecTopStack |
473+
dbg := SindarinDebugger
474+
debug: [ self helperMethod1 ].
475+
dbg step; stepOver; stepOver.
476+
realExecPC := dbg pc.
477+
realExecNode := dbg node.
478+
realValueOfA := (dbg temporaryNamed: #a).
479+
realExecTopStack := dbg topStack.
480+
481+
dbg := SindarinDebugger
482+
debug: [ self helperMethod1 ].
483+
484+
dbg step; stepOver; skipToPC: realExecPC.
485+
self assert: dbg pc equals: realExecPC.
486+
self assert: dbg node equals: realExecNode.
487+
self assert: realValueOfA equals: 5.
488+
self assert: (dbg temporaryNamed: #a) equals: 1.
489+
self assert: dbg topStack equals: realExecTopStack
490+
]
491+
458492
{ #category : #tests }
459493
SindarinDebuggerTests >> testSkipWith [
460494
| a p scdbg |
@@ -558,6 +592,26 @@ SindarinDebuggerTests >> testTemporaries [
558592
self assert: (scdbg temporaries at: #a) equals: 5
559593
]
560594

595+
{ #category : #tests }
596+
SindarinDebuggerTests >> testTemporaryNamed [
597+
| dbg |
598+
dbg := SindarinDebugger debug: [ self helperMethod10 ].
599+
dbg step.
600+
self assert: dbg temporaries size equals: 1.
601+
self assert: (dbg temporaryNamed: #a) equals: nil.
602+
dbg step.
603+
self assert: (dbg temporaryNamed: #a) equals: 5
604+
]
605+
606+
{ #category : #tests }
607+
SindarinDebuggerTests >> testTopStack [
608+
| a dbg |
609+
a := 1.
610+
dbg := SindarinDebugger debug: [ a := 2 ].
611+
dbg step.
612+
self assert: dbg topStack equals: 2
613+
]
614+
561615
{ #category : #tests }
562616
SindarinDebuggerTests >> testWhenHitBreakpoint [
563617
| breakpoint toggle scdbg |

Sindarin/SindarinDebugger.class.st

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ SindarinDebugger >> attachTo: aDebugSession [
8585

8686
sindarinSession := aDebugSession asSindarinDebugSession.
8787
process := aDebugSession interruptedProcess.
88-
sindarinSession deactivateEventTriggering
88+
sindarinSession deactivateEventTriggering.
89+
debugStarted := true
90+
]
91+
92+
{ #category : #astAndAstMapping }
93+
SindarinDebugger >> bestNodeFor: anInterval [
94+
^self node methodNode bestNodeFor: anInterval
8995
]
9096

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

317+
{ #category : #accessing }
318+
SindarinDebugger >> pc [
319+
^ self context pc
320+
]
321+
311322
{ #category : #stepping }
312323
SindarinDebugger >> proceed [
313324
"alias of #continue"
@@ -408,6 +419,21 @@ SindarinDebugger >> skipMessageNodeWith: replacementValue [
408419
stepToFirstInterestingBytecodeIn: self debugSession interruptedProcess
409420
]
410421

422+
{ #category : #stepping }
423+
SindarinDebugger >> skipToPC: aProgramNode [
424+
"Skips execution until program counter reaches aProgramNode."
425+
[ self node == aProgramNode ] whileFalse: [ self skip ]
426+
]
427+
428+
{ #category : #stepping }
429+
SindarinDebugger >> skipToPC: aProgramNode skipToNextNode: skipTargetNode [
430+
"Skips execution until program counter reaches aProgramNode."
431+
432+
[ self node == aProgramNode ] whileFalse: [ self skip ].
433+
aProgramNode isReturn ifTrue: [ ^ self ].
434+
skipTargetNode ifTrue: [ self skip ]
435+
]
436+
411437
{ #category : #stepping }
412438
SindarinDebugger >> skipWith: replacementValue [
413439
"If it is a message-send or assignment, skips the execution of the current instruction, and puts the replacementValue on the execution stack."
@@ -486,3 +512,13 @@ SindarinDebugger >> temporaries [
486512

487513
^ self context temporaries
488514
]
515+
516+
{ #category : #stackAccessHelpers }
517+
SindarinDebugger >> temporaryNamed: aSymbol [
518+
^self temporaries at: aSymbol
519+
]
520+
521+
{ #category : #stackAccessHelpers }
522+
SindarinDebugger >> topStack [
523+
^self context top
524+
]

0 commit comments

Comments
 (0)