Skip to content

Commit

Permalink
Merge pull request #101 from hpi-swa-lab/feature/flameGraph
Browse files Browse the repository at this point in the history
Changes layout of Printbugger to resemble a flame graph
  • Loading branch information
JoeAtHPI authored Dec 4, 2021
2 parents 2cd92f7 + b16737b commit e368016
Show file tree
Hide file tree
Showing 27 changed files with 116 additions and 139 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
private
filterableClassesInStack
^ {BlockClosure.

^ { BlockClosure.
Symbol.
DynamicVariable class.
CSProcessContextInformation.
CSMethodObject.
CSLayeredMethod.
CSPartialMethod.
TestCase.
TestResult.}
TestResult.
BPPrintbuggerTest.
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
private
filterableMessagesInStack

^ {MethodReference class: BlockClosure selector: #newProcess.
MethodReference class: BPExample selector: #traceInBackground.
MethodReference class: BlockClosure selector: #on:do:.
Expand All @@ -17,5 +17,4 @@ filterableMessagesInStack
MethodReference class: BPMethodExample selector: #runOn:.
MethodReference class: CSMethodObject selector: #run:with:in:.
MethodReference class: CSLayeredMethod selector: #valueWithReceiver:arguments:.
MethodReference class: CSPartialMethod selector: #valueWithReceiver:arguments:.
MethodReference class: BlockClosure selector: #whileFalseDo:.}
MethodReference class: CSPartialMethod selector: #valueWithReceiver:arguments:.}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
private
filteredStack
^ self filteredStackFor: self stack

^ self stack reject: [:aStackEntry | self shouldBeFiltered: aStackEntry ]


This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
"chronologicalPosition" : "jb 5/20/2021 14:50",
"chronologicalPosition:" : "jb 5/20/2021 14:50",
"containedMethodReference" : "jb 7/2/2021 14:34",
"filterableClassesInStack" : "jb 6/30/2021 00:58",
"filterableMessagesInStack" : "jb 6/24/2021 22:43",
"filteredStack" : "jb 6/30/2021 00:53",
"filteredStackFor:" : "jb 6/30/2021 00:47",
"filterableClassesInStack" : "jb 11/20/2021 02:07",
"filterableMessagesInStack" : "jb 11/20/2021 01:52",
"filteredStack" : "jb 11/19/2021 18:54",
"isStackFull" : "jb 6/30/2021 01:26",
"oneSidedStackLevelTo:" : "jb 8/1/2021 21:24",
"printOn:" : "jb 5/19/2021 20:59",
"relativeStackLevelTo:" : "jb 7/2/2021 14:36",
"shouldBeFiltered:" : "jb 6/30/2021 00:55",
"stack" : "pre 5/8/2019 18:36",
"stack:" : "jb 12/7/2020 18:55",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
colorFor: aMethodReference

^ context colorFor: aMethodReference having: self class barColorScheme
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
private
lineSubmorphsFor: aTraceValue relativeTo: aStackRelation
lineSubmorphsFor: aTraceValue calledBy: aStackOfMethodReferences

| valueMorph |
valueMorph := self newLabelValuePairMorphFor: aTraceValue.

^ {self newHaltButtonFor: aTraceValue.
self newBarMorphFor: aTraceValue
relativeTo: aStackRelation
calledBy: aStackOfMethodReferences
withHeight: (valueMorph fullBounds height + 10).
valueMorph.}

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
private - ui
newBarMorphFor: aTraceValue calledBy: aStackOfMethodReferences withHeight: aNumber


^ Morph new
name: #stackBar;
color: Color transparent;
changeTableLayout;
listDirection: #rightToLeft;
wrapCentering: #center;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
cellInset: 1@0;
addAllMorphsBack: (aStackOfMethodReferences collect: [:aStackMethod |
self newStackFrameMorphFor: aStackMethod withHeight: aNumber]);
yourself

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
private - ui
newStackFrameMorphFor: aMethodReference withHeight: aNumber

| stackMorph |
stackMorph := Morph new
color: (self colorFor: aMethodReference);
extent: (self stackDepth@aNumber);
balloonText: aMethodReference asString;
setProperty: #stackMethodReference
toValue: aMethodReference;
on: #click
send: #value
to: [ToolSet browse: aMethodReference actualClass
selector: aMethodReference selector];
yourself.

stackMorph
on: #mouseEnter
send: #value
to: [stackMorph borderStyle: (BorderStyle width: 2 color: Color black)];
on: #mouseLeave
send: #value
to: [stackMorph borderStyle: nil].

^ stackMorph

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
stackDepth
^ self fontHeight

^ self fontHeight / 1.25

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
private
stackMethodsFor: aBPExample

^ aBPExample traceValues collect: [:aTraceValue |
aTraceValue filteredStack collect: [:aStackEntry | MethodReference class: aStackEntry fourth selector: aStackEntry third]]
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
change notifications
updateLayoutToContext

self lineSubMorphs withIndexDo: [:aTraceValueLine :anIndex |
(aTraceValueLine submorphNamed: #stackBar) color: (self colorFor: (example traceValues at: anIndex) in: context)].
(aTraceValueLine submorphNamed: #stackBar) submorphsDo: [:aStackEntry |
aStackEntry color: (self colorFor: (aStackEntry valueOfProperty: #stackMethodReference))]].
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
private
visualizeLineFor: aTraceValue relativeTo: aStackRelation
visualizeLineFor: aTraceValue calledBy: aStackOfMethodReferences

^ Morph new
name: aTraceValue chronologicalPosition asString;
color: Color transparent;
Expand All @@ -9,6 +9,6 @@ visualizeLineFor: aTraceValue relativeTo: aStackRelation
cellPositioning: #center;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap;
cellInset: 3@1;
addAllMorphsBack: (self lineSubmorphsFor: aTraceValue relativeTo: aStackRelation);
yourself.
cellInset: 3@0;
addAllMorphsBack: (self lineSubmorphsFor: aTraceValue calledBy: aStackOfMethodReferences);
yourself
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
private
visualizeLinesFor: aBPExample
|stackDepthsRelativeToFirstLine|
stackDepthsRelativeToFirstLine := self stackDepthsFor: aBPExample.

| stackMethods |
stackMethods := self stackMethodsFor: aBPExample.

"Add a wrapper to have some distance between the title morph and the values"
^ Morph new
Expand All @@ -14,5 +14,5 @@ visualizeLinesFor: aBPExample
wrapCentering: #center;
cellPositioning: #topLeft;
addAllMorphsBack: (aBPExample traceValues withIndexCollect: [:aTraceValue :anIndex |
self visualizeLineFor: aTraceValue relativeTo: (stackDepthsRelativeToFirstLine at: anIndex )]);
self visualizeLineFor: aTraceValue calledBy: (stackMethods at: anIndex )]);
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"newFor:" : "jb 6/10/2021 23:33",
"newFor:withContext:" : "jb 6/10/2021 23:24" },
"instance" : {
"barWidthFor:relativeTo:" : "jb 6/25/2021 00:34",
"colorFor:" : "jb 11/20/2021 01:29",
"colorFor:in:" : "jb 6/11/2021 01:04",
"context:" : "jb 6/10/2021 23:26",
"example:" : "jb 6/10/2021 15:06",
Expand All @@ -15,19 +15,20 @@
"initialize" : "jb 6/10/2021 23:34",
"initializeProperties" : "jb 7/10/2021 16:37",
"lineSubMorphs" : "jb 7/10/2021 17:43",
"lineSubmorphsFor:relativeTo:" : "jb 7/10/2021 16:57",
"newBarMorphFor:relativeTo:withHeight:" : "jb 6/30/2021 03:10",
"lineSubmorphsFor:calledBy:" : "jb 11/19/2021 21:37",
"newBarMorphFor:calledBy:withHeight:" : "jb 11/19/2021 21:58",
"newHaltButtonFor:" : "lu 6/17/2021 13:44",
"newLabelFor:" : "jb 7/10/2021 17:13",
"newLabelMorphFor:" : "jb 7/10/2021 17:14",
"newLabelValuePairMorphFor:" : "jb 7/10/2021 17:14",
"newStackFrameMorphFor:withHeight:" : "jb 11/20/2021 01:32",
"newTitleMorphFor:" : "lu 7/20/2021 21:21",
"positionInProbeFor:and:" : "jb 6/24/2021 22:21",
"scrollBarSize" : "lu 6/9/2021 23:47",
"stackDepth" : "jb 7/10/2021 16:50",
"stackDepthsFor:" : "jb 6/30/2021 02:18",
"stackDepth" : "jb 11/19/2021 18:29",
"stackMethodsFor:" : "jb 11/19/2021 21:21",
"update:with:" : "jb 7/1/2021 23:47",
"updateLayoutToContext" : "jb 7/10/2021 17:43",
"updateLayoutToContext" : "jb 11/20/2021 01:33",
"visualize" : "jb 7/10/2021 16:41",
"visualizeLineFor:relativeTo:" : "jb 7/10/2021 16:57",
"visualizeLinesFor:" : "jb 7/10/2021 16:56" } }
"visualizeLineFor:calledBy:" : "jb 11/19/2021 21:45",
"visualizeLinesFor:" : "jb 11/19/2021 21:39" } }
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
tests
testSwimlaneDisplaysTraceValuesForOneProbe

| swimlane traceValues|
self initExample1WithMethodWithMultipleProbes.
swimlane := printbugger canvasMorph firstSubmorph.
self assert: (swimlane isKindOf: BPSwimlane).
self assert: 6 equals: (swimlane lineSubMorphs size).
traceValues := swimlane allMorphs select: [:aSubmorph | aSubmorph isKindOf: StringMorph] thenCollect: [:aStringMorph | aStringMorph contents].
traceValues := swimlane allMorphs select: [:aSubmorph |
aSubmorph isKindOf: StringMorph] thenCollect: [:aStringMorph | aStringMorph contents].
self assert: (traceValues includesAllOf: {'1'. '2'. '2'. '4'. '3'. '6'.}).

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
tests
testSwimlaneDisplaysTraceValuesForTwoProbesChronologicallySorted

|swimlane traceValues traceIndexes|
self initExample1WithMethodWithMultipleProbes.
swimlane := BPSwimlane newFor: example1.
traceValues := swimlane allMorphs select: [:aSubmorph | aSubmorph isKindOf: StringMorph] thenCollect: [:aStringMorph | aStringMorph contents].
traceValues := swimlane allMorphs select: [:aSubmorph |
aSubmorph isKindOf: StringMorph] thenCollect: [:aStringMorph | aStringMorph contents].
self assert: (traceValues includesAllOf: {'1'. '2'. '2'. '4'. '3'. '6'.}).
traceIndexes := {'1'. '2'. '2'. '4'. '3'. '6'.} collect: [:aTraceString | traceValues indexOf: aTraceString].
self assert: traceIndexes isSorted.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
tests
testTwoTraceValuesInDifferentMethodsGetDifferentColorsInMultipleSwimlanes

|swimlane1 swimlane2 colors1 colors2|
self initExample1WithMethodWithMultipleProbes.
self initExample2WithSingleProbe.

swimlane1 := printbugger canvasMorph firstSubmorph.
swimlane2 := printbugger canvasMorph submorphs second.
colors1 := (swimlane1 allMorphs select: [:aSubmorph | aSubmorph knownName = 'stackBar'] thenCollect: [:aBarMorph | aBarMorph color]) asSet.
colors2 := (swimlane2 allMorphs select: [:aSubmorph | aSubmorph knownName = 'stackBar'] thenCollect: [:aBarMorph | aBarMorph color]) asSet.
colors1 := (swimlane1 allMorphs select: [:aSubmorph |
aSubmorph knownName = 'stackBar'] thenCollect: [:aBarMorph | aBarMorph firstSubmorph color]) asSet.
colors2 := (swimlane2 allMorphs select: [:aSubmorph |
aSubmorph knownName = 'stackBar'] thenCollect: [:aBarMorph | aBarMorph firstSubmorph color]) asSet.

self assert: colors1 size equals: colors2 size.
self assert: colors1 ~= colors2.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
tests
testTwoTraceValuesInDifferentMethodsGetDifferentColorsInSameSwimlane

|swimlane colors|
self initExample1WithMethodWithExampleCallingOnlyProbedMethod.

swimlane := printbugger canvasMorph firstSubmorph.
colors := (swimlane allMorphs select: [:aSubmorph | aSubmorph knownName = 'stackBar'] thenCollect: [:aBarMorph | aBarMorph color]) asSet.
colors := (swimlane allMorphs select: [:aSubmorph |
aSubmorph knownName = 'stackBar'] thenCollect: [:aBarMorph | aBarMorph firstSubmorph color]) asSet.

self assert: 2 equals: colors size.
Loading

0 comments on commit e368016

Please sign in to comment.