Skip to content

Commit

Permalink
Merge branch 'develop' into error/fix-morph-resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Oct 2, 2023
2 parents de1e829 + 90e3c6f commit c18736f
Show file tree
Hide file tree
Showing 88 changed files with 361 additions and 139 deletions.
10 changes: 5 additions & 5 deletions .squot
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
OrderedDictionary {
'packages/BaselineOfBabylonianProgramming.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-Core.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-Demo.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-ExampleMining.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-ProbeLog.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-Compiler.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-Core.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-Tests.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-UI.package' : #SquotCypressCodeSerializer,
'packages/BaselineOfBabylonianProgramming.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-ProbeLog.package' : #SquotCypressCodeSerializer,
'packages/Babylonian-ExampleMining.package' : #SquotCypressCodeSerializer
'packages/Babylonian-Tests.package' : #SquotCypressCodeSerializer
}
15 changes: 10 additions & 5 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 trunk Squeak][squeakorg]
1. Get [a recent Squeak][squeakorg]
2. Load [Metacello][metacello]
3. Finally, load Babylonian/S with the following command:

Expand All @@ -15,6 +15,11 @@ 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.

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

## Current State

Expand All @@ -30,17 +35,17 @@ compilerClass
on your class' side. Otherwise, the trace will disregard that class for performance reasons.


## Babylonian Printbugger
Due to their self-contained nature, traced values of multiple annotations are not entangled, meaning developers must manually reconstruct the program flow in order to know which trace values precede or succeed others in different annotations (possibly throughout different methods). To solve this problem, one can use the Printbugger. It sets probes and assertions - independent from their origin - into a chronological context. Hence, truthfully bringing printf-like tracing with live feedback to Babylonian Programming. The Printbugger additionally offers multiple features to enhance it from typical printf-traces:
## Babylonian ProbeLog
Due to their self-contained nature, traced values of multiple annotations are not entangled, meaning developers must manually reconstruct the program flow in order to know which trace values precede or succeed others in different annotations (possibly throughout different methods). To solve this problem, one can use the ProbeLog. It sets probes and assertions - independent from their origin - into a chronological context. Hence, truthfully bringing printf-like tracing with live feedback to Babylonian Programming. The ProbeLog additionally offers multiple features to enhance it from typical printf-traces:
- Start debugging from a certain point in the trace by clicking the pause button
- Know which methods were called starting from an example to the responding trace value with the generated Flame Graph
- Navigate to a trace value's or example's origin by clicking on it
- Change an example directly from a lane's title
- Filter trace values of an annotation by clicking on the eye-icon
- Double click a trace value to highlight its originating annotation (given the responding morph is visible)
- Individualize your trace with the Printbugger's theme support
- Individualize your trace with the ProbeLog's theme support

More detailed information on the interactions and classes can be read [here](https://github.com/hpi-swa-lab/babylonian-programming-smalltalk/blob/develop/printbugger_docs.md).
More detailed information on the interactions and classes can be read [here](https://github.com/hpi-swa-lab/babylonian-programming-smalltalk/blob/develop/probelog.md).

![image](https://user-images.githubusercontent.com/33000454/158557998-b81bea53-4d6e-4fd9-b8ec-a87939c7e6c1.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ executeSynchronously
| state |
state := self prepareRunState.
self runSetUpWith: state.
[ ^ self runWithTimeoutOn: state] ensure: [self runTearDownWith: state]
[ ^ self runWithTimeoutOn: state]
ensure: [
self runTearDownWith: state.
self changed: #exampleCompleted with: self]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ tracing
runSetUpWith: aState

| result |
self setUpScript ifNotNil: [
result := Compiler evaluate: self setUpScript notifying: aState.
result isSymbol ifTrue: [
self method methodClass perform: result]]
#bpInstrumented withoutLayerDo: [
self setUpScript ifNotNil: [
result := Compiler evaluate: self setUpScript notifying: aState.
result isSymbol ifTrue: [
self method methodClass perform: result]]]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ tracing
runTearDownWith: aState

| result |
self tearDownScript ifNotNil: [
result := Compiler evaluate: self tearDownScript notifying: aState.
result isSymbol ifTrue: [
self method methodClass perform: result]]
#bpInstrumented withoutLayerDo: [
self tearDownScript ifNotNil: [
result := Compiler evaluate: self tearDownScript notifying: aState.
result isSymbol ifTrue: [
self method methodClass perform: result]]]
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ runWithTimeoutOn: initialState
complete := false.

self startWatchdog: [
semaphore waitTimeoutMSecs: self timeout.
self timeout milliSeconds wait.
"We sadly cannot simply ask self tracingIsStillRunning as the values rely
on this method's return value which is not done at this point. So uglyish complete workaround"
complete ifFalse: [self suspendTracingProcess]].

[ ^ self runOn: initialState] ensure: [
complete := true.
semaphore signal]
complete := true.
semaphore terminateProcess.]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
private
startWatchdog: watchdogBlock

| watchdog |
watchdog := watchdogBlock newProcess.
watchdog priority: Processor timingPriority-1.
watchdog resume.
watchdogBlock
forkAt: Processor timingPriority-1
named: 'watchdog for ' , self exampleName.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"exampleName" : "pre 1/11/2023 10:47",
"exampleName:" : "pre 1/11/2023 10:47",
"execute" : "pre 7/13/2023 10:44",
"executeSynchronously" : "pre 7/13/2023 10:44",
"executeSynchronously" : "pre 8/15/2023 15:45",
"expectedResult" : "pre 1/11/2023 10:47",
"expectedResult:" : "pre 1/11/2023 10:47",
"hasExpectedResult" : "joabe 9/28/2022 22:56",
Expand All @@ -36,13 +36,13 @@
"removeTrace" : "pre 1/11/2023 10:43",
"resumeTracing" : "pre 1/12/2023 09:39",
"runOn:" : "pre 1/11/2023 10:47",
"runSetUpWith:" : "pre 7/22/2022 21:17",
"runTearDownWith:" : "pre 7/22/2022 21:17",
"runWithTimeoutOn:" : "pre 11/2/2022 11:42",
"runSetUpWith:" : "pre 8/23/2023 11:07",
"runTearDownWith:" : "pre 8/23/2023 11:07",
"runWithTimeoutOn:" : "pre 8/23/2023 12:04",
"setIsActive:" : "pre 1/11/2023 10:47",
"setUpScript" : "pre 1/11/2023 10:47",
"setUpScript:" : "pre 1/11/2023 10:48",
"startWatchdog:" : "pre 11/2/2022 11:40",
"startWatchdog:" : "pre 8/23/2023 12:01",
"suspendTracingProcess" : "pre 1/12/2023 09:39",
"tearDownScript" : "pre 1/11/2023 10:48",
"tearDownScript:" : "pre 1/11/2023 10:48",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
timeout

^ timeout ifNil: [timeout := 30000]
^ timeout ifNil: [timeout := 5000]
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"setUpScript:" : "pre 1/21/2021 15:36",
"tearDownScript" : "pre 1/21/2021 15:36",
"tearDownScript:" : "pre 1/21/2021 15:36",
"timeout" : "joabe 9/27/2022 23:28",
"timeout" : "pre 8/22/2023 17:13",
"timeout:" : "joabe 9/27/2022 20:26",
"traceInformation" : "pre 1/11/2023 10:49" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
binding
hasBindingThatBeginsWith: aString

^ state keys anySatisfy: [:key | key isString and: [key beginsWith: aString]]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"instance" : {
"bindingOf:" : "pre 1/19/2023 10:19",
"hasBindingOf:" : "pre 1/19/2023 10:19",
"hasBindingThatBeginsWith:" : "pre 8/22/2023 09:46",
"initialize" : "pre 1/19/2023 10:19",
"selectFrom:to:" : "pre 7/22/2022 21:24",
"selectionInterval" : "pre 7/22/2022 21:24",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process control
releaseProcess

self assert: (self tracingProcessAndDescendants allSatisfy: [:p | p isTerminated]).
tracingProcess := nil.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"instance" : {
"isProcessSuspended" : "pre 1/12/2023 09:37",
"probes" : "jb 5/19/2021 19:35",
"releaseProcess" : "pre 8/22/2023 12:01",
"resumeProcess" : "pre 1/12/2023 13:28",
"suspendProcess" : "pre 1/12/2023 13:27",
"terminateTracingProcess" : "pre 1/12/2023 13:28",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ add: aBPExample

<bpRelevantMethod>
mutex critical: [examples add: aBPExample].
aBPExample addDependent: self.
self changed: #bpExamples.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ remove: aBPExample
mutex critical: [
examples remove: aBPExample ifAbsent: ["dont care"].
aBPExample ensureTerminatedProcess].
aBPExample removeDependent: self.
self changed: #bpExamples.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
change notifications
update: anAspect with: anObject

anAspect = #exampleIsActive ifTrue: [
^ self changed: #activeExamples].

anAspect = #newTrace ifTrue: [
^ self changed: #tracesChanged].
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"shutDown:" : "pre 5/26/2021 17:17" },
"instance" : {
"activeExamples" : "pre 5/3/2021 16:55",
"add:" : "pre 5/6/2021 18:30",
"add:" : "pre 8/23/2023 10:39",
"doSilently:" : "pre 9/2/2022 14:46",
"exampleIdentifiers" : "pre 5/3/2021 16:41",
"examples" : "pre 5/4/2021 15:20",
"examplesForMethod:" : "pre 5/4/2021 15:09",
"initialize" : "pre 5/3/2021 16:42",
"paddedTracesOfActiveExamples" : "pre 5/3/2021 16:55",
"rehash" : "pre 5/19/2021 21:36",
"remove:" : "pre 5/6/2021 16:54",
"remove:" : "pre 8/23/2023 11:02",
"removeAll:" : "jb 12/7/2020 18:52",
"removeTraces" : "jb 12/7/2020 18:52",
"runActiveExamples" : "pre 5/6/2021 18:31",
Expand All @@ -25,4 +25,5 @@
"systemChangeEvent:" : "pre 1/11/2023 13:42",
"tracesOfActiveExamples" : "pre 5/6/2021 18:31",
"update:" : "pre 9/2/2022 14:46",
"update:with:" : "pre 8/23/2023 10:42",
"updateExamplesOnEvent:" : "pre 1/11/2023 13:38" } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
accessing
argumentNames
"Caches argument names as parsing them requires accessing the source files, which is expensive."

| parts |
parts := self method methodClass formalHeaderPartsFor: self method selector.
^ (1 to: self method selector numArgs) collect: [:anIndex |
parts at: (4 * anIndex)]
(cachedArgumentNames isNil or: [cachedArgNamesKey ~~ self method]) ifTrue: [
parts := self method methodClass formalHeaderPartsFor: self method selector.
cachedArgumentNames := (1 to: self method selector numArgs) collect: [:anIndex |
parts at: (4 * anIndex)].
cachedArgNamesKey := self method].
^ cachedArgumentNames


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
method: aCompiledMethod

super method: aCompiledMethod.
"Force cache invalidation"
self argumentNames.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
accessing
newArguments

^ (argumentScripts first: self argumentNames size)
collect: [:script |
script isLiveSpecimenReference
ifTrue: [self resolveLiveSpecimen: script]
ifFalse: [Compiler evaluate: script for: self method methodClass]]
^ self newArgumentsIn: BPMethodExampleRunConfiguration new
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
accessing
newArgumentsDictionary

^ OrderedDictionary newFrom: (self argumentNames
with: (self newArguments first: self argumentNames size)
collect: [:name :value | name asSymbol -> value])
^ self newArgumentsDictionaryIn: BPMethodExampleRunConfiguration new
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
newArgumentsDictionaryIn: aMethodExampleState

^ OrderedDictionary newFrom: (self argumentNames
with: ((self newArgumentsIn: aMethodExampleState) first: self argumentNames size)
collect: [:name :value | name asSymbol -> value])
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
accessing
newArgumentsIn: aMethodExampleRunState

^ (argumentScripts first: self argumentNames size)
collect: [:script |
script isLiveSpecimenReference
ifTrue: [self resolveLiveSpecimen: script]
ifFalse: [Compiler
evaluate: script
for: self method methodClass
notifying: aMethodExampleRunState]]
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
accessing
newReceiver

| result |
^ self receiverConstructor isEmptyOrNil
ifFalse: [
self receiverConstructor isSymbol ifTrue: [
^ self method methodClass perform: self receiverConstructor].
self receiverConstructor isLiveSpecimenReference ifTrue: [
^ self resolveLiveSpecimen: self receiverConstructor].
result := Compiler evaluate: self receiverConstructor for: self method methodClass.
result isSymbol
ifTrue: [self method methodClass perform: result]
ifFalse: [result]]
ifTrue: [self method methodClass new].
^ self newReceiverIn: BPMethodExampleRunConfiguration new
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
accessing
newReceiverIn: aMethodExampleState

| result |
^ self receiverConstructor isEmptyOrNil
ifFalse: [
self receiverConstructor isSymbol ifTrue: [
^ self method methodClass perform: self receiverConstructor].
self receiverConstructor isLiveSpecimenReference ifTrue: [
^ self resolveLiveSpecimen: self receiverConstructor].
result := Compiler
evaluate: self receiverConstructor
for: self method methodClass
notifying: aMethodExampleState.
result isSymbol
ifTrue: [self method methodClass perform: result]
ifFalse: [result]]
ifTrue: [self method methodClass new].
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
tracing
prepareRunState

#bpInstrumented withoutLayerDo: [
^ BPMethodExampleRunConfiguration new
receiver: self newReceiver;
arguments: self newArgumentsDictionary;
yourself].
#bpInstrumented withoutLayerDo: [ | newState |
newState := BPMethodExampleRunConfiguration new.
^ newState].
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
tracing
runOn: aState

#bpInstrumented withoutLayerDo: [
aState receiver: (self newReceiverIn: aState).
aState arguments: (self newArgumentsDictionaryIn: aState).].

^ aState receiver
perform: self method selector
withArguments: aState arguments
Loading

0 comments on commit c18736f

Please sign in to comment.