From 005654f2cf1de91d8499bfe2a996cf8a3cc39869 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:12:28 +0200 Subject: [PATCH 01/12] Fixing freezes when stepping automatically into primitive 198 --- src/Sindarin/SindarinDebugger.class.st | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Sindarin/SindarinDebugger.class.st b/src/Sindarin/SindarinDebugger.class.st index 3e407a2..64124e9 100644 --- a/src/Sindarin/SindarinDebugger.class.st +++ b/src/Sindarin/SindarinDebugger.class.st @@ -601,7 +601,13 @@ SindarinDebugger >> stepToReturn [ SindarinDebugger >> stepUntil: aBlock [ "Steps the execution until aBlock evaluates to true" - aBlock whileFalse: [ self step ] + aBlock whileFalse: [ + "Stepping into primitive 198 freezes the image, we do not know why. + Stepping over the sender context fixes the freezes. + There is an open issue about understanding why: https://github.com/pharo-spec/ScriptableDebugger/issues/105" + self method primitive = 198 + ifTrue: [ sindarinSession stepOver: self context sender ] + ifFalse: [ self step ] ] ] { #category : 'astAndAstMapping' } From c6b676acf92e90896b662474e342b658ae87795e Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:13:27 +0200 Subject: [PATCH 02/12] better comment --- src/Sindarin/SindarinDebugger.class.st | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Sindarin/SindarinDebugger.class.st b/src/Sindarin/SindarinDebugger.class.st index 64124e9..3b81f2d 100644 --- a/src/Sindarin/SindarinDebugger.class.st +++ b/src/Sindarin/SindarinDebugger.class.st @@ -599,10 +599,11 @@ SindarinDebugger >> stepToReturn [ { #category : 'stepping - steps' } SindarinDebugger >> stepUntil: aBlock [ - "Steps the execution until aBlock evaluates to true" + "Steps the execution until aBlock evaluates to true. + Steps over ensure: blocks (primitive 198) to avoid hanging. + The hanging seems to be due to the execution of valueNoContextSwitch" - aBlock whileFalse: [ - "Stepping into primitive 198 freezes the image, we do not know why. + aBlock whileFalse: [ "Stepping into primitive 198 freezes the image, we do not know why. Stepping over the sender context fixes the freezes. There is an open issue about understanding why: https://github.com/pharo-spec/ScriptableDebugger/issues/105" self method primitive = 198 From fe006d82abb3b5a44d4a3bff1e3bc862bfa4393b Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:13:47 +0200 Subject: [PATCH 03/12] Added diveUntil API: stepping stops when we return from the original context --- src/Sindarin/SindarinDebugger.class.st | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Sindarin/SindarinDebugger.class.st b/src/Sindarin/SindarinDebugger.class.st index 3b81f2d..b9d884b 100644 --- a/src/Sindarin/SindarinDebugger.class.st +++ b/src/Sindarin/SindarinDebugger.class.st @@ -86,6 +86,13 @@ SindarinDebugger >> continue [ whileFalse: [ self step ] ] +{ #category : 'stepping - steps' } +SindarinDebugger >> diveUntil: aBlock [ + "Dives into the current context (=startingContext) until the execution returns back to the starting context's sender, or satisfies aBlock condition." + + self stepUntil: [ self context == self context sender or: aBlock ] +] + { #category : 'accessing' } SindarinDebugger >> firstPCOfStatement: aStatementNode [ From 94e3e66ca616051254932c684f2cc35fe19479c7 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 12:33:41 +0200 Subject: [PATCH 04/12] API methods in Sindarin Debug Session --- src/Sindarin/SindarinDebugSession.class.st | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Sindarin/SindarinDebugSession.class.st b/src/Sindarin/SindarinDebugSession.class.st index 15851d9..75f4ccf 100644 --- a/src/Sindarin/SindarinDebugSession.class.st +++ b/src/Sindarin/SindarinDebugSession.class.st @@ -38,6 +38,18 @@ SindarinDebugSession >> asSindarinDebugSession [ ^ self ] +{ #category : 'api' } +SindarinDebugSession >> basicStepInto: aContext [ + + ^ self debugSession stepInto: aContext +] + +{ #category : 'api' } +SindarinDebugSession >> basicStepOver: aContext [ + + ^ self debugSession stepOver: aContext +] + { #category : 'accessing' } SindarinDebugSession >> canBeTerminated [ From df949fada1c7eb8953c1f490d0bda8fc74428e10 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:01:57 +0200 Subject: [PATCH 05/12] Now using the debug session basic API in Sindarin Debug Session --- src/Sindarin/SindarinDebugSession.class.st | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Sindarin/SindarinDebugSession.class.st b/src/Sindarin/SindarinDebugSession.class.st index 75f4ccf..258d5b3 100644 --- a/src/Sindarin/SindarinDebugSession.class.st +++ b/src/Sindarin/SindarinDebugSession.class.st @@ -105,22 +105,25 @@ SindarinDebugSession >> resumeAndClear [ { #category : 'debugging actions' } SindarinDebugSession >> stepInto: aContext [ - "Should not step more a process that is terminating, otherwise the image will get locked." - self flag: 'Why the image gets locked? Please investigate.'. + "Should not step more a process that is terminating, otherwise the image will get locked. + 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. + 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." self debugSession interruptedProcess isTerminating ifTrue: [ SteppingATerminatingProcess signal ]. - ^ self debugSession stepInto: aContext + ^ self basicStepInto: aContext ] { #category : 'debugging actions' } SindarinDebugSession >> stepOver: aContext [ - "Should not step more a process that is terminating, otherwise the image will get locked." - self flag: 'Why the image gets locked? Please investigate.'. + "Should not step more a process that is terminating, otherwise the image will get locked. + 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. + 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." + self debugSession interruptedProcess isTerminating ifTrue: [ SteppingATerminatingProcess signal ]. - ^ self debugSession stepOver: aContext + ^ self basicStepOver: aContext ] { #category : 'debugging actions' } From 1b5a43dc6e5b0a8397da8478f4afd0300360c36f Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:02:17 +0200 Subject: [PATCH 06/12] Using the direct API to step over ensure blocks --- src/Sindarin/SindarinDebugger.class.st | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Sindarin/SindarinDebugger.class.st b/src/Sindarin/SindarinDebugger.class.st index b9d884b..4862c5a 100644 --- a/src/Sindarin/SindarinDebugger.class.st +++ b/src/Sindarin/SindarinDebugger.class.st @@ -614,7 +614,9 @@ SindarinDebugger >> stepUntil: aBlock [ Stepping over the sender context fixes the freezes. There is an open issue about understanding why: https://github.com/pharo-spec/ScriptableDebugger/issues/105" self method primitive = 198 - ifTrue: [ sindarinSession stepOver: self context sender ] + ifTrue: [ + self isExecutionFinished ifFalse: [ + sindarinSession basicStepOver: self context sender ] ] ifFalse: [ self step ] ] ] From 8d6f8daf50baa9d590837d2cabf8991a67ecd1bf Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:04:01 +0200 Subject: [PATCH 07/12] Fixing the dive until to stop stepping once we get back to the sender context --- src/Sindarin/SindarinDebugger.class.st | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Sindarin/SindarinDebugger.class.st b/src/Sindarin/SindarinDebugger.class.st index 4862c5a..08697d5 100644 --- a/src/Sindarin/SindarinDebugger.class.st +++ b/src/Sindarin/SindarinDebugger.class.st @@ -90,7 +90,9 @@ SindarinDebugger >> continue [ SindarinDebugger >> diveUntil: aBlock [ "Dives into the current context (=startingContext) until the execution returns back to the starting context's sender, or satisfies aBlock condition." - self stepUntil: [ self context == self context sender or: aBlock ] + | sender | + sender := self context sender. + self stepUntil: [ self context == sender or: aBlock ] ] { #category : 'accessing' } From a0381344532ff4590b20214133e650f7f8e9ffb6 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:10:54 +0200 Subject: [PATCH 08/12] Removing dead code --- src/Sindarin/SindarinDebugSession.class.st | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Sindarin/SindarinDebugSession.class.st b/src/Sindarin/SindarinDebugSession.class.st index 258d5b3..526e898 100644 --- a/src/Sindarin/SindarinDebugSession.class.st +++ b/src/Sindarin/SindarinDebugSession.class.st @@ -25,13 +25,6 @@ SindarinDebugSession class >> newWithName: aString forProcess: aProcess [ asSindarinDebugSession ] -{ #category : 'initialization' } -SindarinDebugSession >> activateEventTriggering [ - triggerEventOn := true. - self flag: 'Why not refreshing?'. - "self refreshAttachedDebugger." -] - { #category : 'converting' } SindarinDebugSession >> asSindarinDebugSession [ From 84ae598f4cf651e47cfbf11d137ba1e05fd029fe Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:12:43 +0200 Subject: [PATCH 09/12] Recategorizing --- src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st | 4 ++-- src/Sindarin/SindarinDebugSession.class.st | 4 ++-- src/Sindarin/SindarinDebugger.class.st | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st b/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st index 1f50da8..825df6e 100644 --- a/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st +++ b/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st @@ -5,9 +5,9 @@ Class { 'blockToSearch', 'isBlockFound' ], - #category : 'Sindarin-Base', + #category : 'Sindarin-Core', #package : 'Sindarin', - #tag : 'Base' + #tag : 'Core' } { #category : 'instance creation' } diff --git a/src/Sindarin/SindarinDebugSession.class.st b/src/Sindarin/SindarinDebugSession.class.st index 526e898..238404d 100644 --- a/src/Sindarin/SindarinDebugSession.class.st +++ b/src/Sindarin/SindarinDebugSession.class.st @@ -31,13 +31,13 @@ SindarinDebugSession >> asSindarinDebugSession [ ^ self ] -{ #category : 'api' } +{ #category : 'api - debug session' } SindarinDebugSession >> basicStepInto: aContext [ ^ self debugSession stepInto: aContext ] -{ #category : 'api' } +{ #category : 'api - debug session' } SindarinDebugSession >> basicStepOver: aContext [ ^ self debugSession stepOver: aContext diff --git a/src/Sindarin/SindarinDebugger.class.st b/src/Sindarin/SindarinDebugger.class.st index 08697d5..68ad91c 100644 --- a/src/Sindarin/SindarinDebugger.class.st +++ b/src/Sindarin/SindarinDebugger.class.st @@ -19,9 +19,9 @@ Class { #superclass : 'Object', #traits : 'TDebugger + TSindarin', #classTraits : 'TDebugger classTrait + TSindarin classTrait', - #category : 'Sindarin-Base', + #category : 'Sindarin-Core', #package : 'Sindarin', - #tag : 'Base' + #tag : 'Core' } { #category : 'stackAccessHelpers' } From 32752de6b88dc8004a340ac03a9cd533114d7ef2 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:16:44 +0200 Subject: [PATCH 10/12] Add missing class comments --- src/Sindarin/DebuggedExecutionIsFinished.class.st | 3 +++ src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st | 3 +++ src/Sindarin/SindarinSkippingReturnWarning.class.st | 3 +++ src/Sindarin/SteppingATerminatingProcess.class.st | 3 +++ .../UnhandledExceptionSignalledByADebuggedExecution.class.st | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/Sindarin/DebuggedExecutionIsFinished.class.st b/src/Sindarin/DebuggedExecutionIsFinished.class.st index b652f67..4fbd777 100644 --- a/src/Sindarin/DebuggedExecutionIsFinished.class.st +++ b/src/Sindarin/DebuggedExecutionIsFinished.class.st @@ -1,3 +1,6 @@ +" +I am raised when an execution debugged by Sindarin has finished. +" Class { #name : 'DebuggedExecutionIsFinished', #superclass : 'DebuggedExecutionException', diff --git a/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st b/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st index 825df6e..ae9ea12 100644 --- a/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st +++ b/src/Sindarin/RBBlockDefinitionSearchingVisitor.class.st @@ -1,3 +1,6 @@ +" +I visit an AST to find a particular block passed as parameter. +" Class { #name : 'RBBlockDefinitionSearchingVisitor', #superclass : 'OCProgramNodeVisitor', diff --git a/src/Sindarin/SindarinSkippingReturnWarning.class.st b/src/Sindarin/SindarinSkippingReturnWarning.class.st index 4298f5c..f29c889 100644 --- a/src/Sindarin/SindarinSkippingReturnWarning.class.st +++ b/src/Sindarin/SindarinSkippingReturnWarning.class.st @@ -1,3 +1,6 @@ +" +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? +" Class { #name : 'SindarinSkippingReturnWarning', #superclass : 'Warning', diff --git a/src/Sindarin/SteppingATerminatingProcess.class.st b/src/Sindarin/SteppingATerminatingProcess.class.st index c321cfb..f21097c 100644 --- a/src/Sindarin/SteppingATerminatingProcess.class.st +++ b/src/Sindarin/SteppingATerminatingProcess.class.st @@ -1,3 +1,6 @@ +" +I am raised when Sindarin attempts to step a terminated process. +" Class { #name : 'SteppingATerminatingProcess', #superclass : 'Error', diff --git a/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st b/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st index fc791b0..b776bda 100644 --- a/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st +++ b/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st @@ -1,3 +1,6 @@ +" +I am raised when an exception is signalled within a debugged process that Sindarin executes. +" Class { #name : 'UnhandledExceptionSignalledByADebuggedExecution', #superclass : 'DebuggedExecutionException', From bb1ca0fd192b617babc676920cc808722b19925e Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:19:26 +0200 Subject: [PATCH 11/12] Removing unused super class (dead code) with unsent method also removed from Object's extension (dead code again). --- src/Sindarin/DebuggedExecutionException.class.st | 12 ------------ src/Sindarin/DebuggedExecutionIsFinished.class.st | 2 +- src/Sindarin/Object.extension.st | 6 ------ ...edExceptionSignalledByADebuggedExecution.class.st | 2 +- 4 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 src/Sindarin/DebuggedExecutionException.class.st delete mode 100644 src/Sindarin/Object.extension.st diff --git a/src/Sindarin/DebuggedExecutionException.class.st b/src/Sindarin/DebuggedExecutionException.class.st deleted file mode 100644 index 2549680..0000000 --- a/src/Sindarin/DebuggedExecutionException.class.st +++ /dev/null @@ -1,12 +0,0 @@ -Class { - #name : 'DebuggedExecutionException', - #superclass : 'Error', - #category : 'Sindarin-Exceptions', - #package : 'Sindarin', - #tag : 'Exceptions' -} - -{ #category : 'testing' } -DebuggedExecutionException >> isExceptionSignalledForDebuggedExecution [ - ^ true -] diff --git a/src/Sindarin/DebuggedExecutionIsFinished.class.st b/src/Sindarin/DebuggedExecutionIsFinished.class.st index 4fbd777..4cccddd 100644 --- a/src/Sindarin/DebuggedExecutionIsFinished.class.st +++ b/src/Sindarin/DebuggedExecutionIsFinished.class.st @@ -3,7 +3,7 @@ I am raised when an execution debugged by Sindarin has finished. " Class { #name : 'DebuggedExecutionIsFinished', - #superclass : 'DebuggedExecutionException', + #superclass : 'Error', #category : 'Sindarin-Exceptions', #package : 'Sindarin', #tag : 'Exceptions' diff --git a/src/Sindarin/Object.extension.st b/src/Sindarin/Object.extension.st deleted file mode 100644 index d0b1b50..0000000 --- a/src/Sindarin/Object.extension.st +++ /dev/null @@ -1,6 +0,0 @@ -Extension { #name : 'Object' } - -{ #category : '*Sindarin' } -Object >> isExceptionSignalledForDebuggedExecution [ - ^ false -] diff --git a/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st b/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st index b776bda..6b1aa7a 100644 --- a/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st +++ b/src/Sindarin/UnhandledExceptionSignalledByADebuggedExecution.class.st @@ -3,7 +3,7 @@ I am raised when an exception is signalled within a debugged process that Sindar " Class { #name : 'UnhandledExceptionSignalledByADebuggedExecution', - #superclass : 'DebuggedExecutionException', + #superclass : 'Error', #instVars : [ 'unhandledException' ], From 50b78dd292970bf72e0a6a549b350ae7cc3482ab Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:20:41 +0200 Subject: [PATCH 12/12] Last changes + test while debugging with Carolina --- src/Sindarin-Tests/SindarinDebuggerTest.class.st | 15 +++++++++++++++ src/Sindarin/SindarinDebugSession.class.st | 6 ++++++ src/Sindarin/SindarinDebugger.class.st | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Sindarin-Tests/SindarinDebuggerTest.class.st b/src/Sindarin-Tests/SindarinDebuggerTest.class.st index 0774bd5..07adb04 100644 --- a/src/Sindarin-Tests/SindarinDebuggerTest.class.st +++ b/src/Sindarin-Tests/SindarinDebuggerTest.class.st @@ -2011,6 +2011,21 @@ SindarinDebuggerTest >> testStepUntil [ self assert: i equals: 12 ] +{ #category : 'tests' } +SindarinDebuggerTest >> testStepUntilOverAnEnsureBlock [ + | i sindarin startingContext | + i := 20. + sindarin := SindarinDebugger + debug: [[ 5 timesRepeat:[i := i + 1]] ensure: [i := 42] ]. + startingContext := sindarin context. + sindarin stepUntil: [ i = 23 ]. + self assert: i equals: 23. + self should: [sindarin stepUntil: [ i = 30 ]] raise: DebuggedExecutionIsFinished. + self assert: i equals: 42. + "self assert: sindarin context identicalTo: startingContext " + +] + { #category : 'tests' } SindarinDebuggerTest >> testSteppingAnExecutionSignalingExceptions [ | scdbg | diff --git a/src/Sindarin/SindarinDebugSession.class.st b/src/Sindarin/SindarinDebugSession.class.st index 238404d..8d085fd 100644 --- a/src/Sindarin/SindarinDebugSession.class.st +++ b/src/Sindarin/SindarinDebugSession.class.st @@ -43,6 +43,12 @@ SindarinDebugSession >> basicStepOver: aContext [ ^ self debugSession stepOver: aContext ] +{ #category : 'api - debug session' } +SindarinDebugSession >> basicStepThrough: aContext [ + + ^ self debugSession stepThrough: aContext +] + { #category : 'accessing' } SindarinDebugSession >> canBeTerminated [ diff --git a/src/Sindarin/SindarinDebugger.class.st b/src/Sindarin/SindarinDebugger.class.st index 68ad91c..b2751b4 100644 --- a/src/Sindarin/SindarinDebugger.class.st +++ b/src/Sindarin/SindarinDebugger.class.st @@ -618,7 +618,7 @@ SindarinDebugger >> stepUntil: aBlock [ self method primitive = 198 ifTrue: [ self isExecutionFinished ifFalse: [ - sindarinSession basicStepOver: self context sender ] ] + sindarinSession basicStepThrough: self context sender] ] ifFalse: [ self step ] ] ]