Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug points api improvements #16861

Open
wants to merge 5 commits into
base: Pharo13
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ClyAddBreakPointCommand >> defaultMenuIconName [

{ #category : 'accessing' }
ClyAddBreakPointCommand >> defaultMenuItemName [
^' Add Breakpoint to: ', sourceNode displaySourceCode
^' Break on ', sourceNode displaySourceCode
]

{ #category : 'execution' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ClyAddWatchDebugPointCommand >> defaultMenuIconName [

{ #category : 'accessing' }
ClyAddWatchDebugPointCommand >> defaultMenuItemName [
^' Add Watch to: ', sourceNode displaySourceCode
^' Watch ', sourceNode displaySourceCode
]

{ #category : 'execution' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ SycOpenDebuggingPointsInMethodMenuCommand >> defaultMenuIconName [
{ #category : 'accessing' }
SycOpenDebuggingPointsInMethodMenuCommand >> defaultMenuItemName [

^ 'Debug Points'
^ 'Break'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 'Debug'

]
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ SycOpenDebuggingPointsMenuCommand >> defaultMenuIconName [
{ #category : 'accessing' }
SycOpenDebuggingPointsMenuCommand >> defaultMenuItemName [

^ 'Debug Points'
^ 'Break'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 'Debug'

]
12 changes: 6 additions & 6 deletions src/DebugPoints-Tests/DebugPointTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ DebugPointTest >> testCountBehavior [
cbh := dp getBehavior: CountBehavior.

self
assertCollection: dp sideEffectBehaviors
assertCollection: dp metaBehaviors
hasSameElements: { cbh }.
self
assertCollection: dp behaviors
Expand Down Expand Up @@ -649,7 +649,7 @@ DebugPointTest >> testOnceBehavior [
behavior := dp getBehavior: OnceBehavior.

self
assertCollection: dp sideEffectBehaviors
assertCollection: dp metaBehaviors
hasSameElements: { behavior }.
self assertCollection: dp behaviors hasSameElements: { behavior }.

Expand Down Expand Up @@ -696,7 +696,7 @@ DebugPointTest >> testOnceEvaluatesAfterConditionBehavior [
onceBehavior := dp getBehavior: OnceBehavior.

self
assertCollection: dp sideEffectBehaviors
assertCollection: dp metaBehaviors
hasSameElements: { onceBehavior }.
self
assertCollection: dp checkBehaviors
Expand Down Expand Up @@ -781,7 +781,7 @@ DebugPointTest >> testRemoveBehavior [
onceBehavior := dp getBehavior: OnceBehavior.

self
assertCollection: dp sideEffectBehaviors
assertCollection: dp metaBehaviors
hasSameElements: { onceBehavior }.
self
assertCollection: dp checkBehaviors
Expand All @@ -798,14 +798,14 @@ DebugPointTest >> testRemoveBehavior [
dp removeBehavior: ConditionBehavior.

self
assertCollection: dp sideEffectBehaviors
assertCollection: dp metaBehaviors
hasSameElements: { onceBehavior }.
self assertCollection: dp checkBehaviors hasSameElements: { }.
self assertCollection: dp behaviors hasSameElements: { onceBehavior }.

dp removeBehavior: OnceBehavior.

self assertCollection: dp sideEffectBehaviors hasSameElements: { }.
self assertCollection: dp metaBehaviors hasSameElements: { }.
self assertCollection: dp checkBehaviors hasSameElements: { }.
self assertCollection: dp behaviors hasSameElements: { }.

Expand Down
64 changes: 48 additions & 16 deletions src/DebugPoints/DebugPoint.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Class {
'name',
'enabled',
'checkBehaviors',
'sideEffectBehaviors',
'arguments',
'properties',
'target',
'link'
'link',
'metaBehaviors'
],
#classVars : [
'AllDebugPoints'
Expand Down Expand Up @@ -88,9 +88,15 @@ DebugPoint >> addCheckBehavior: aConditionBehavior [
]

{ #category : 'adding' }
DebugPoint >> addSideEffectBehavior: aSideEffectBehavior [
DebugPoint >> addMetaBehavior: aSideEffectBehavior [

sideEffectBehaviors add: aSideEffectBehavior
metaBehaviors add: aSideEffectBehavior
]

{ #category : 'default values' }
DebugPoint >> args [

^ #( context )
]

{ #category : 'accessing' }
Expand All @@ -108,7 +114,7 @@ DebugPoint >> arguments: aDictionary [
{ #category : 'accessing' }
DebugPoint >> behaviors [

^ checkBehaviors , sideEffectBehaviors
^ checkBehaviors , metaBehaviors
]

{ #category : 'actions' }
Expand All @@ -123,6 +129,12 @@ DebugPoint >> checkBehaviors [
^ checkBehaviors
]

{ #category : 'default values' }
DebugPoint >> control [

^ #before
]

{ #category : 'protocol' }
DebugPoint >> disable [

Expand Down Expand Up @@ -161,6 +173,18 @@ DebugPoint >> enabled: aBoolean [
DebugPointManager notifyDebugPointChanged: self
]

{ #category : 'accessing' }
DebugPoint >> evaluateInContext: expression [
|currentContext|
currentContext := self getArgument: #context.
^ Smalltalk compiler
source: expression;
context: currentContext;
receiver: currentContext receiver;
bindings: { (#thisContext -> currentContext) };
evaluate
]

{ #category : 'accessing' }
DebugPoint >> getArgument: aSymbol [

Expand Down Expand Up @@ -189,9 +213,10 @@ DebugPoint >> hitWithContext: aContext [
DebugPointManager notifyDebugPointHit: self inContext: aContext.
self enabled ifFalse: [ ^ false ].
self saveContext: aContext.

(self checkBehaviors allSatisfy: [ :behavior | behavior execute ])
ifFalse: [ ^ false ].
self sideEffectBehaviors do: [ :behavior | behavior execute ].
self metaBehaviors do: [ :behavior | behavior execute ].
^ true
]

Expand All @@ -201,7 +226,7 @@ DebugPoint >> initialize [
enabled := true.
checkBehaviors := SortedCollection sortUsing: [ :elem1 :elem2 |
elem1 priority >= elem2 priority ].
sideEffectBehaviors := SortedCollection sortUsing: [ :elem1 :elem2 |
metaBehaviors := SortedCollection sortUsing: [ :elem1 :elem2 |
elem1 priority >= elem2 priority ]
]

Expand Down Expand Up @@ -238,14 +263,21 @@ DebugPoint >> link: aMetaLink [
link := aMetaLink
]

{ #category : 'accessing' }
DebugPoint >> metaBehaviors [

^ metaBehaviors
]

{ #category : 'default values' }
DebugPoint >> metaLink [

^ MetaLink new
metaObject: self;
options: #( #+ optionCompileOnLinkInstallation );
selector: #hitWithContext:;
arguments: #( context )
selector: self selector;
control: self control;
arguments: self args
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -335,15 +367,15 @@ DebugPoint >> removeFromMethod: aMethod [
]

{ #category : 'removing' }
DebugPoint >> removeNode: aNode [
DebugPoint >> removeMetaBehavior: aSideEffectBehavior [

self link removeNode: aNode
metaBehaviors remove: aSideEffectBehavior
]

{ #category : 'removing' }
DebugPoint >> removeSideEffectBehavior: aSideEffectBehavior [
DebugPoint >> removeNode: aNode [

sideEffectBehaviors remove: aSideEffectBehavior
self link removeNode: aNode
]

{ #category : 'scope' }
Expand Down Expand Up @@ -371,10 +403,10 @@ DebugPoint >> scopeString [
^ self target scopeString
]

{ #category : 'accessing' }
DebugPoint >> sideEffectBehaviors [
{ #category : 'default values' }
DebugPoint >> selector [

^ sideEffectBehaviors
^ #hitWithContext:
]

{ #category : 'accessing' }
Expand Down
4 changes: 2 additions & 2 deletions src/DebugPoints/DebugPointMetaBehavior.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Class {
{ #category : 'adding' }
DebugPointMetaBehavior >> addToDebugPoint: aDebugPoint [

aDebugPoint addSideEffectBehavior: self
aDebugPoint addMetaBehavior: self
]

{ #category : 'removing' }
DebugPointMetaBehavior >> removeFromDebugPoint: aDebugPoint [

aDebugPoint removeSideEffectBehavior: self
aDebugPoint removeMetaBehavior: self
]
18 changes: 1 addition & 17 deletions src/DebugPoints/ScriptBehavior.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,11 @@ ScriptBehavior class >> isAbstract [
^ false
]

{ #category : 'accessing' }
ScriptBehavior >> context [
^self getArgument: #context
]

{ #category : 'accessing' }
ScriptBehavior >> evaluate: expression withContext: aContext [

^ Smalltalk compiler
source: expression;
context: aContext;
receiver: aContext receiver;
bindings: { (#thisContext -> aContext) };
evaluate
]

{ #category : 'execution' }
ScriptBehavior >> execute [

self script ifNil: [ ^ true ].
self evaluate: self script withContext: self context.
self debugPoint evaluateInContext: self script.
^ true
]

Expand Down
7 changes: 5 additions & 2 deletions src/DebugPoints/TranscriptBehavior.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ TranscriptBehavior class >> isAbstract [

{ #category : 'execution' }
TranscriptBehavior >> execute [
self text trace.
^true

(self text isNil or: [ self text isEmpty ]) ifTrue: [ ^ true ].
(self debugPoint evaluateInContext: self text) traceCr.

^ true
]

{ #category : 'cleanup' }
Expand Down
27 changes: 21 additions & 6 deletions src/DebugPoints/WatchDebugPoint.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ WatchDebugPoint >> addValue: aValue [
self history size > self limit ifTrue: [ self history removeLast ] ]
]

{ #category : 'default values' }
WatchDebugPoint >> args [

^ #( context value )
]

{ #category : 'default values' }
WatchDebugPoint >> control [

^ #after
]

{ #category : 'accessing' }
WatchDebugPoint >> history [

Expand Down Expand Up @@ -59,12 +71,9 @@ WatchDebugPoint >> limit: anInteger [
{ #category : 'default values' }
WatchDebugPoint >> metaLink [

^ MetaLink new
metaObject: self;
selector: #hitWithContext:value:;
arguments: #( context value );
control: #after;
option: #( #+ optionWeakAfter #+ optionCompileOnLinkInstallation )
^ super metaLink
option: #( #+ optionWeakAfter #+ optionCompileOnLinkInstallation );
yourself
]

{ #category : 'accessing' }
Expand All @@ -73,6 +82,12 @@ WatchDebugPoint >> name [
^ name ifNil: [ #WatchPoint ]
]

{ #category : 'default values' }
WatchDebugPoint >> selector [

^ #hitWithContext:value:
]

{ #category : 'accessing' }
WatchDebugPoint >> type [

Expand Down