From ab2e5d232b21813cc008d345ae2703dba1c6dfce Mon Sep 17 00:00:00 2001 From: StevenCostiou Date: Tue, 11 Feb 2020 16:18:24 +0100 Subject: [PATCH 1/5] Recategorizing helpers methods in Sindarin test class --- Sindarin-Tests/SindarinDebuggerTests.class.st | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Sindarin-Tests/SindarinDebuggerTests.class.st b/Sindarin-Tests/SindarinDebuggerTests.class.st index a11083a..8f61def 100644 --- a/Sindarin-Tests/SindarinDebuggerTests.class.st +++ b/Sindarin-Tests/SindarinDebuggerTests.class.st @@ -8,21 +8,21 @@ Class { #category : #'Sindarin-Tests' } -{ #category : #tests } +{ #category : #helpers } SindarinDebuggerTests >> helperMethod1 [ | a | 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. @@ -31,145 +31,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 ] From 91b1f2acd9e79dcd27f930cd075915f28d253002 Mon Sep 17 00:00:00 2001 From: StevenCostiou Date: Tue, 11 Feb 2020 18:05:38 +0100 Subject: [PATCH 2/5] Adding API methods in Sindarin for temp access by name in the current context, accessing the pc and topStack. --- Sindarin-Tests/SindarinDebuggerTests.class.st | 20 +++++++++++++++++++ Sindarin/SindarinDebugger.class.st | 15 ++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Sindarin-Tests/SindarinDebuggerTests.class.st b/Sindarin-Tests/SindarinDebuggerTests.class.st index 8f61def..338aae1 100644 --- a/Sindarin-Tests/SindarinDebuggerTests.class.st +++ b/Sindarin-Tests/SindarinDebuggerTests.class.st @@ -558,6 +558,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 | diff --git a/Sindarin/SindarinDebugger.class.st b/Sindarin/SindarinDebugger.class.st index 9aa9516..c8ba4af 100644 --- a/Sindarin/SindarinDebugger.class.st +++ b/Sindarin/SindarinDebugger.class.st @@ -308,6 +308,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" @@ -486,3 +491,13 @@ SindarinDebugger >> temporaries [ ^ self context temporaries ] + +{ #category : #stackAccessHelpers } +SindarinDebugger >> temporaryNamed: aSymbol [ + ^self temporaries at: aSymbol +] + +{ #category : #stackAccessHelpers } +SindarinDebugger >> topStack [ + ^self context top +] From 70196f7128a8426f712beb93b668918383108183 Mon Sep 17 00:00:00 2001 From: StevenCostiou Date: Tue, 11 Feb 2020 18:05:58 +0100 Subject: [PATCH 3/5] Added API skipToPC: + test --- Sindarin-Tests/SindarinDebuggerTests.class.st | 23 +++++++++++++++++++ Sindarin/SindarinDebugger.class.st | 7 ++++++ 2 files changed, 30 insertions(+) diff --git a/Sindarin-Tests/SindarinDebuggerTests.class.st b/Sindarin-Tests/SindarinDebuggerTests.class.st index 338aae1..87dadbd 100644 --- a/Sindarin-Tests/SindarinDebuggerTests.class.st +++ b/Sindarin-Tests/SindarinDebuggerTests.class.st @@ -11,6 +11,7 @@ Class { { #category : #helpers } SindarinDebuggerTests >> helperMethod1 [ | a | + a := 1. a := 5. ^ Point x: 5 y: '3' asInteger. ] @@ -455,6 +456,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 | diff --git a/Sindarin/SindarinDebugger.class.st b/Sindarin/SindarinDebugger.class.st index c8ba4af..cf3460f 100644 --- a/Sindarin/SindarinDebugger.class.st +++ b/Sindarin/SindarinDebugger.class.st @@ -413,6 +413,13 @@ SindarinDebugger >> skipMessageNodeWith: replacementValue [ stepToFirstInterestingBytecodeIn: self debugSession interruptedProcess ] +{ #category : #stepping } +SindarinDebugger >> skipToPC: aPC [ + "Skips execution until program counter reaches aPC - 1." + + [self pc < aPC] whileTrue: [ 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." From 2b33da3c7032b7b5cc17ce012cdcc6c761710566 Mon Sep 17 00:00:00 2001 From: StevenCostiou Date: Tue, 11 Feb 2020 18:07:33 +0100 Subject: [PATCH 4/5] Added Sindarin test for PC access. --- Sindarin-Tests/SindarinDebuggerTests.class.st | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sindarin-Tests/SindarinDebuggerTests.class.st b/Sindarin-Tests/SindarinDebuggerTests.class.st index 87dadbd..fcf3524 100644 --- a/Sindarin-Tests/SindarinDebuggerTests.class.st +++ b/Sindarin-Tests/SindarinDebuggerTests.class.st @@ -400,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 | From 4429ea601cd1f7c127060e60910c40d17b39921d Mon Sep 17 00:00:00 2001 From: StevenCostiou Date: Tue, 11 Feb 2020 20:41:28 +0100 Subject: [PATCH 5/5] Refactoring skipToPC to skip until a given node instead of the pc --- Sindarin/SindarinDebugger.class.st | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Sindarin/SindarinDebugger.class.st b/Sindarin/SindarinDebugger.class.st index cf3460f..84d1111 100644 --- a/Sindarin/SindarinDebugger.class.st +++ b/Sindarin/SindarinDebugger.class.st @@ -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 } @@ -414,10 +420,18 @@ SindarinDebugger >> skipMessageNodeWith: replacementValue [ ] { #category : #stepping } -SindarinDebugger >> skipToPC: aPC [ - "Skips execution until program counter reaches aPC - 1." +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 pc < aPC] whileTrue: [ self skip ] + [ self node == aProgramNode ] whileFalse: [ self skip ]. + aProgramNode isReturn ifTrue: [ ^ self ]. + skipTargetNode ifTrue: [ self skip ] ] { #category : #stepping }