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

Add Instance Probes #162

Open
wants to merge 14 commits into
base: develop
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
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
A Smalltalk implementation of the Babylonian Programming System.

## How to install
1. Get [a recent Squeak][squeakorg]
1. Get [a recent trunk Squeak][squeakorg]
Copy link
Member

Choose a reason for hiding this comment

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

Why is trunk needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will revert this

2. Load [Metacello][metacello]
3. Finally, load Babylonian/S with the following command:

Expand All @@ -15,11 +15,6 @@ Metacello new
repository: 'github://hpi-swa-lab/babylonian-programming-smalltalk:main/packages';
load.
```
4. (Recommended) Disable the preference for notifications on saving methods with styles. This prevents that you will be asked whether you want to save style information whenever you save a method with probes.
Copy link
Member

Choose a reason for hiding this comment

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

Is this intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, i think the readme got a bit messed up when dev was merged


```Smalltalk
Preferences disable: #confirmFirstUseOfStyle.
```

## Current State

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ compileCue: aCueWithStyledSource noPattern: aBoolean ifFail: failBlock
inside the morph to re-fullfill that premise again during compilation."
| originalMethodNode bpUnstyledSource unstyledCue |
bpUnstyledSource := aCueWithStyledSource sourceStream contents asString.

unstyledCue := CompilationCue
source: bpUnstyledSource readStream
context: aCueWithStyledSource context
receiver: aCueWithStyledSource receiver
class: aCueWithStyledSource getClass
class: aCueWithStyledSource getClass
environment: aCueWithStyledSource environment
requestor: aCueWithStyledSource requestor.
originalMethodNode := super compileCue: unstyledCue noPattern: aBoolean ifFail: failBlock.

bpUnstyledSource := originalMethodNode sourceText asString.
(self methodSourceRequiresBPLayers: bpUnstyledSource) ifTrue: [
(self compileInstrumentedVersionOf: aCueWithStyledSource) ifFalse: failBlock].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
private
rewriteToSource: parseResult

^ self rewriter value: parseResult
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"instance" : {
"annotationKeywords" : "pre 11/8/2019 20:29",
"backgroundCompileInstrumentedVersionOf:basedOn:" : "pre 10/12/2020 15:36",
"compileCue:noPattern:ifFail:" : "pre 7/20/2022 16:41",
"compileCue:noPattern:ifFail:" : "joabe 10/2/2023 12:53",
"compileInstrumentedVersionOf:" : "jb 9/9/2021 17:31",
"keywords" : "pre 11/30/2022 09:33",
"methodSourceRequiresBPLayers:" : "pre 11/11/2019 15:49",
"parse:" : "pre 5/3/2021 15:01",
"rewriteToSource:" : "pre 8/17/2020 08:54",
"rewriteToSource:" : "joabe 10/2/2023 12:48",
"rewriter" : "jb 12/7/2020 18:03" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
grammar rules
AnnotatedKeywordMessageSend: aNode startTag: startTag actualMessage: message endTag: endTag

^ self rewriteNode: message withTag: startTag
^ self rewriteNode: message withTag: startTag
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
rewrite rules
bpTemporaryProbe: annotation with: originalExpressionSourceNode

^ annotation instrumentationCallFor: (self value: originalExpressionSourceNode)
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ rewriteAssignmentNode: aNode withTag: aTag
^ annotationInformation isProbe
ifFalse: [self rewriteNode: aNode withTag: aTag]
ifTrue: ["To handle assignment probes"
annotationInformation := annotationInformation asAssignmentProbe.
"The following is a hack to some degree, but a separate semantic would be overkill here"
variableNames := aNode children first "NormalStatement" children first "AssignmentOperation*" children collect: [:assignment |
assignment children first interval contents].
annotationInformation := annotationInformation asAssignmentProbe.
variableNames := (aNode children first ruleName = #AnnotatedStatement)
ifTrue: [ "Nested assignments" #()]
ifFalse: ["The following is a hack to some degree, but a separate semantic would be overkill here"
aNode children first "NormalStatement"
children first "AssignmentOperation*"
children collect: [:assignment |assignment children first interval contents]] .
annotationInformation variableNames: variableNames.
annotationInformation instrumentationCallFor: (self value: aNode)]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"AnnotatedBinaryMessageSend:startTag:actualMessage:endTag:" : "pre 3/5/2020 16:30",
"AnnotatedBlockLiteral:startTag:actualBlock:endTag:" : "pre 9/1/2022 20:34",
"AnnotatedExpression:startTag:actualExpression:endTag:" : "pre 1/24/2020 17:26",
"AnnotatedKeywordMessageSend:startTag:actualMessage:endTag:" : "pre 3/5/2020 16:30",
"AnnotatedKeywordMessageSend:startTag:actualMessage:endTag:" : "joabe 9/25/2023 19:01",
"AnnotatedMessageChain:startTag:actualMessage:endTag:" : "pre 4/29/2020 17:01",
"AnnotatedOperand:startTag:actualOperand:endTag:" : "pre 3/5/2020 17:37",
"AnnotatedStatement:startTag:actualStatement:endTag:" : "jb 12/3/2020 22:36",
Expand All @@ -27,7 +27,7 @@
"nextBlockId" : "pre 1/27/2020 09:17",
"nextProbeId" : "pre 5/10/2019 12:20",
"rewriteArgumentNode:withTag:" : "pre 7/23/2022 15:41",
"rewriteAssignmentNode:withTag:" : "pre 7/6/2020 18:10",
"rewriteAssignmentNode:withTag:" : "joabe 10/4/2023 15:31",
"rewriteCascadeNode:withTag:" : "pre 4/29/2020 17:05",
"rewriteNode:withTag:" : "pre 9/25/2020 11:20",
"value:" : "pre 9/25/2020 11:42",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"morphClass" : "jb 3/5/2022 12:54",
"otherInformation" : "pre 5/29/2019 10:59",
"otherInformation:" : "jb 12/7/2020 18:06",
"removeFromMethod:" : "jb 1/10/2022 19:20",
"removeFromMethod:" : "joabe 10/6/2023 14:28",
"startTag" : "pre 5/10/2021 09:44",
"startTagSource" : "jb 12/7/2020 18:06",
"startTagSource:" : "pre 5/29/2019 10:59",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class initialization
clear

DefaultValue := nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
default

^ DefaultValue ifNil: [DefaultValue := self new]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
actions
addProbe: aProbe

nameToProbesDict at: aProbe assignedClassName
ifPresent: [:registeredProbes | registeredProbes add: aProbe]
ifAbsent: [ | k |
k := KeyedSet keyBlock: [ :each | each variableName ].
k add: aProbe.
nameToProbesDict at: aProbe assignedClassName put: k]

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
at: aClassName

^ nameToProbesDict at: aClassName
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialize-release
initialize

super initialize.
nameToProbesDict := Dictionary new.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
nameToProbesDict

^ nameToProbesDict
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
actions
removeProbe: aProbe

nameToProbesDict at: aProbe assignedClassName
ifPresent: [:registeredProbes | registeredProbes remove: aProbe.
registeredProbes ifEmpty:
[nameToProbesDict removeKey: aProbe assignedClassName]]

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"class" : {
"clear" : "joabe 9/28/2023 12:59",
"default" : "joabe 9/28/2023 12:57" },
"instance" : {
"addProbe:" : "joabe 10/5/2023 18:01",
"at:" : "joabe 9/28/2023 15:08",
"initialize" : "joabe 9/27/2023 16:33",
"nameToProbesDict" : "joabe 9/28/2023 12:59",
"removeProbe:" : "joabe 10/5/2023 17:47" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "Babylonian-Core-Tracing",
"classinstvars" : [
],
"classvars" : [
"DefaultValue" ],
"commentStamp" : "",
"instvars" : [
"nameToProbesDict" ],
"name" : "BPClassNameToInstanceProbes",
"pools" : [
],
"super" : "DynamicVariable",
"type" : "normal" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
annotationTag

^ 'bpInstanceProbe'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
morphic
asMorph

| newMorph |
newMorph := BPInstanceVariableProbeMorph new annotation: self; yourself.
self updateTextAnchorPropertiesOf: newMorph.
^ newMorph
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
assignedClassName: aString

assignedClassName := aString
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
assignedClassName

^ assignedClassName
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ui
canBeAnnotatedTo

^ #(stringLiteral)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
initialize-release
deleteLinkedProbes

| browser |
browser := BPBrowser open.

self linkedProbes do: [:aProbe |
browser browseReference: aProbe methodReference.
browser removeAnnotations: {aProbe}].

browser currentWindow delete.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialize-release
initialize

super initialize.

linkedProbes := OrderedCollection new.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
serialization
instrumentationCallFor: actualEnclosedExpressionSource

"Currently not used as instance probes do not rewrite a class definition in which they exist"
^ '(self bpTraceVariable: [{1}] forProbe: {2} linked: \{{3}\} inContext: thisContext)'
format: {actualEnclosedExpressionSource .
self id.
((self linkedProbes gather: [:probe | probe id]) joinSeparatedBy: ' . ')}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isInstanceVariableProbe

^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
linkedProbes

^ linkedProbes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
serialization
probeTypeTag

^ 'bpInstanceProbe'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialize-release
removeFromMethod: aCompiledMethod

"do nothing"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
variableName: aString

self enclosedExpressionSource: aString
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
variableName

^ self enclosedExpressionSource
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
wantsMetaClassIndication

^ false
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"class" : {
"annotationTag" : "joabe 9/25/2023 17:30" },
"instance" : {
"asMorph" : "joabe 10/6/2023 14:43",
"assignedClassName" : "joabe 10/6/2023 14:40",
"assignedClassName:" : "joabe 10/6/2023 14:40",
"canBeAnnotatedTo" : "joabe 9/21/2023 21:08",
"deleteLinkedProbes" : "joabe 10/6/2023 14:40",
"initialize" : "joabe 10/4/2023 15:33",
"instrumentationCallFor:" : "joabe 10/7/2023 18:25",
"isInstanceVariableProbe" : "joabe 9/21/2023 21:18",
"linkedProbes" : "joabe 10/4/2023 15:33",
"probeTypeTag" : "joabe 9/25/2023 17:30",
"removeFromMethod:" : "joabe 9/27/2023 16:43",
"variableName" : "joabe 9/28/2023 14:47",
"variableName:" : "joabe 9/28/2023 14:47",
"wantsMetaClassIndication" : "joabe 9/21/2023 21:08" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"category" : "Babylonian-Core-Annotations",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"assignedClassName",
"linkedProbes" ],
"name" : "BPInstanceVariableProbe",
"pools" : [
],
"super" : "BPProbe",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isInstanceVariableProbe

^ false
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"hasExpression" : "pre 6/7/2021 16:52",
"hasLabel" : "lu 5/20/2021 15:14",
"instrumentationCallFor:" : "pre 1/10/2023 17:33",
"isInstanceVariableProbe" : "joabe 9/21/2023 21:18",
"isProbe" : "pre 7/3/2019 11:12",
"isTemporaryProbe" : "pre 9/2/2022 14:40",
"label" : "joabe 5/9/2023 17:37",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
private
allBabylonianInternalClasses
^ #('Babylonian-Core' 'Babylonian-Compiler' 'Babylonian-UI' 'Babylonian-ProbeLog')
inject: OrderedCollection new
Copy link
Member

Choose a reason for hiding this comment

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

You can use gather for this. :)

into: [:theClasses :aPackage |
theClasses, (PackageOrganizer default packageNamed: aPackage
ifPresent: [:thePackage | thePackage classes]
ifAbsent: [#()])].
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ignoredMessagesInStack" : "pre 9/27/2023 14:34",
"value:identityHash:stack:" : "pre 10/12/2020 17:57" },
"instance" : {
"allBabylonianInternalClasses" : "joabe 7/2/2023 23:54",
"asValueMorph" : "jb 5/20/2021 01:00",
"belongingAnnotation" : "lu 1/31/2022 16:59",
"belongingAnnotationId" : "lu 12/1/2021 07:32",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*Babylonian-Core
bpExtractVariableAssignmentRangesNamed: aVariableName

^ (self extractAssignmentIntervalsFrom: self parseTree named: aVariableName) flatten


Loading
Loading