Skip to content

Commit d9c2786

Browse files
authored
Merge pull request #106 from StevenCostiou/Pharo13
Various improvements to the Sindarin API
2 parents e5e68c9 + 50b78dd commit d9c2786

10 files changed

+84
-40
lines changed

src/Sindarin-Tests/SindarinDebuggerTest.class.st

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,6 +2011,21 @@ SindarinDebuggerTest >> testStepUntil [
20112011
self assert: i equals: 12
20122012
]
20132013

2014+
{ #category : 'tests' }
2015+
SindarinDebuggerTest >> testStepUntilOverAnEnsureBlock [
2016+
| i sindarin startingContext |
2017+
i := 20.
2018+
sindarin := SindarinDebugger
2019+
debug: [[ 5 timesRepeat:[i := i + 1]] ensure: [i := 42] ].
2020+
startingContext := sindarin context.
2021+
sindarin stepUntil: [ i = 23 ].
2022+
self assert: i equals: 23.
2023+
self should: [sindarin stepUntil: [ i = 30 ]] raise: DebuggedExecutionIsFinished.
2024+
self assert: i equals: 42.
2025+
"self assert: sindarin context identicalTo: startingContext "
2026+
2027+
]
2028+
20142029
{ #category : 'tests' }
20152030
SindarinDebuggerTest >> testSteppingAnExecutionSignalingExceptions [
20162031
| scdbg |

src/Sindarin/DebuggedExecutionException.class.st

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Sindarin/DebuggedExecutionIsFinished.class.st

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
"
2+
I am raised when an execution debugged by Sindarin has finished.
3+
"
14
Class {
25
#name : 'DebuggedExecutionIsFinished',
3-
#superclass : 'DebuggedExecutionException',
6+
#superclass : 'Error',
47
#category : 'Sindarin-Exceptions',
58
#package : 'Sindarin',
69
#tag : 'Exceptions'

src/Sindarin/Object.extension.st

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
"
2+
I visit an AST to find a particular block passed as parameter.
3+
"
14
Class {
25
#name : 'RBBlockDefinitionSearchingVisitor',
36
#superclass : 'OCProgramNodeVisitor',
47
#instVars : [
58
'blockToSearch',
69
'isBlockFound'
710
],
8-
#category : 'Sindarin-Base',
11+
#category : 'Sindarin-Core',
912
#package : 'Sindarin',
10-
#tag : 'Base'
13+
#tag : 'Core'
1114
}
1215

1316
{ #category : 'instance creation' }

src/Sindarin/SindarinDebugSession.class.st

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,30 @@ SindarinDebugSession class >> newWithName: aString forProcess: aProcess [
2525
asSindarinDebugSession
2626
]
2727

28-
{ #category : 'initialization' }
29-
SindarinDebugSession >> activateEventTriggering [
30-
triggerEventOn := true.
31-
self flag: 'Why not refreshing?'.
32-
"self refreshAttachedDebugger."
33-
]
34-
3528
{ #category : 'converting' }
3629
SindarinDebugSession >> asSindarinDebugSession [
3730

3831
^ self
3932
]
4033

34+
{ #category : 'api - debug session' }
35+
SindarinDebugSession >> basicStepInto: aContext [
36+
37+
^ self debugSession stepInto: aContext
38+
]
39+
40+
{ #category : 'api - debug session' }
41+
SindarinDebugSession >> basicStepOver: aContext [
42+
43+
^ self debugSession stepOver: aContext
44+
]
45+
46+
{ #category : 'api - debug session' }
47+
SindarinDebugSession >> basicStepThrough: aContext [
48+
49+
^ self debugSession stepThrough: aContext
50+
]
51+
4152
{ #category : 'accessing' }
4253
SindarinDebugSession >> canBeTerminated [
4354

@@ -93,22 +104,25 @@ SindarinDebugSession >> resumeAndClear [
93104

94105
{ #category : 'debugging actions' }
95106
SindarinDebugSession >> stepInto: aContext [
96-
"Should not step more a process that is terminating, otherwise the image will get locked."
97-
self flag: 'Why the image gets locked? Please investigate.'.
107+
"Should not step more a process that is terminating, otherwise the image will get locked.
108+
The image freeze is due to the stepping of the ensure block in doTerminationFromYourself that unwind the terminating context to nil and executes a jump.
109+
The ensure executes the (fake) primitive 198 which actually freezes (see issue https://github.com/pharo-spec/ScriptableDebugger/issues/105), and prevents the jump to execute which in turn provokes other freezes when trying to close opened debugger on that partially ended process."
98110

99111
self debugSession interruptedProcess isTerminating
100112
ifTrue: [ SteppingATerminatingProcess signal ].
101-
^ self debugSession stepInto: aContext
113+
^ self basicStepInto: aContext
102114
]
103115

104116
{ #category : 'debugging actions' }
105117
SindarinDebugSession >> stepOver: aContext [
106-
"Should not step more a process that is terminating, otherwise the image will get locked."
107-
self flag: 'Why the image gets locked? Please investigate.'.
118+
"Should not step more a process that is terminating, otherwise the image will get locked.
119+
The image freeze is due to the stepping of the ensure block in doTerminationFromYourself that unwind the terminating context to nil and executes a jump.
120+
The ensure executes the (fake) primitive 198 which actually freezes (see issue https://github.com/pharo-spec/ScriptableDebugger/issues/105), and prevents the jump to execute which in turn provokes other freezes when trying to close opened debugger on that partially ended process."
121+
108122

109123
self debugSession interruptedProcess isTerminating
110124
ifTrue: [ SteppingATerminatingProcess signal ].
111-
^ self debugSession stepOver: aContext
125+
^ self basicStepOver: aContext
112126
]
113127

114128
{ #category : 'debugging actions' }

src/Sindarin/SindarinDebugger.class.st

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Class {
1919
#superclass : 'Object',
2020
#traits : 'TDebugger + TSindarin',
2121
#classTraits : 'TDebugger classTrait + TSindarin classTrait',
22-
#category : 'Sindarin-Base',
22+
#category : 'Sindarin-Core',
2323
#package : 'Sindarin',
24-
#tag : 'Base'
24+
#tag : 'Core'
2525
}
2626

2727
{ #category : 'stackAccessHelpers' }
@@ -86,6 +86,15 @@ SindarinDebugger >> continue [
8686
whileFalse: [ self step ]
8787
]
8888

89+
{ #category : 'stepping - steps' }
90+
SindarinDebugger >> diveUntil: aBlock [
91+
"Dives into the current context (=startingContext) until the execution returns back to the starting context's sender, or satisfies aBlock condition."
92+
93+
| sender |
94+
sender := self context sender.
95+
self stepUntil: [ self context == sender or: aBlock ]
96+
]
97+
8998
{ #category : 'accessing' }
9099
SindarinDebugger >> firstPCOfStatement: aStatementNode [
91100

@@ -599,9 +608,18 @@ SindarinDebugger >> stepToReturn [
599608

600609
{ #category : 'stepping - steps' }
601610
SindarinDebugger >> stepUntil: aBlock [
602-
"Steps the execution until aBlock evaluates to true"
603-
604-
aBlock whileFalse: [ self step ]
611+
"Steps the execution until aBlock evaluates to true.
612+
Steps over ensure: blocks (primitive 198) to avoid hanging.
613+
The hanging seems to be due to the execution of valueNoContextSwitch"
614+
615+
aBlock whileFalse: [ "Stepping into primitive 198 freezes the image, we do not know why.
616+
Stepping over the sender context fixes the freezes.
617+
There is an open issue about understanding why: https://github.com/pharo-spec/ScriptableDebugger/issues/105"
618+
self method primitive = 198
619+
ifTrue: [
620+
self isExecutionFinished ifFalse: [
621+
sindarinSession basicStepThrough: self context sender] ]
622+
ifFalse: [ self step ] ]
605623
]
606624

607625
{ #category : 'astAndAstMapping' }

src/Sindarin/SindarinSkippingReturnWarning.class.st

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"
2+
I am raised when Sindarin attempts to skip the execution of a return node, which leaves an unspecified scenario to happen: what should we return if we skip a return?
3+
"
14
Class {
25
#name : 'SindarinSkippingReturnWarning',
36
#superclass : 'Warning',

src/Sindarin/SteppingATerminatingProcess.class.st

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"
2+
I am raised when Sindarin attempts to step a terminated process.
3+
"
14
Class {
25
#name : 'SteppingATerminatingProcess',
36
#superclass : 'Error',

src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
"
2+
I am raised when an exception is signalled within a debugged process that Sindarin executes.
3+
"
14
Class {
25
#name : 'UnhandledExceptionSignalledByADebuggedExecution',
3-
#superclass : 'DebuggedExecutionException',
6+
#superclass : 'Error',
47
#instVars : [
58
'unhandledException'
69
],

0 commit comments

Comments
 (0)