Skip to content

Commit 477ab7c

Browse files
theibhirMatthewKhouzam
authored andcommitted
callstack: add markers to nestable events
show markers for nestable events Signed-off-by: Yassine Ibhir <[email protected]>
1 parent 9af7d56 commit 477ab7c

File tree

4 files changed

+65
-39
lines changed

4 files changed

+65
-39
lines changed

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public class FlameChartDataProviderTest extends CallStackTestBase2 {
7777
private static final String CALLSTACKIEVENTS_FILE = "testfiles/traces/callstackIevents.xml";
7878

7979
public FlameChartDataProviderTest() {
80-
super( CALLSTACKIEVENTS_FILE);
80+
super(CALLSTACKIEVENTS_FILE);
8181
}
8282

8383
private FlameChartDataProvider getDataProvider() {
@@ -485,6 +485,7 @@ public void testFetchAnnotations() {
485485
assertNotNull(model);
486486
assertTrue(model.getAnnotations().containsKey(InstrumentedCallStackAnalysis.ANNOTATIONS));
487487
}
488+
488489
/**
489490
* Test fetchAnnotations with null filter returns completed with null model
490491
*/
@@ -507,25 +508,23 @@ public void testFetchAnnotationsOutputElementStyle() {
507508
FlameChartDataProvider dataProvider = getDataProvider();
508509

509510
// Get tree to find entry IDs
510-
TmfModelResponse<@NonNull TmfTreeModel<@NonNull FlameChartEntryModel>> treeResponse =
511-
dataProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), null);
511+
TmfModelResponse<@NonNull TmfTreeModel<@NonNull FlameChartEntryModel>> treeResponse = dataProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), null);
512512
TmfTreeModel<@NonNull FlameChartEntryModel> model = treeResponse.getModel();
513513

514514
if (model != null) {
515515
List<FlameChartEntryModel> entries = model.getEntries();
516516

517517
// Find a function entry that should have annotations
518518
FlameChartEntryModel functionEntry = entries.stream()
519-
.filter(e -> e.getEntryType() == EntryType.FUNCTION)
520-
.findFirst()
521-
.orElse(null);
519+
.filter(e -> e.getEntryType() == EntryType.FUNCTION)
520+
.findFirst()
521+
.orElse(null);
522522
assertNotNull(functionEntry);
523523

524-
// 15 and 18 are timestamps with instant events
524+
// Test both instant and nestable events (timestamps 15, 16, 20)
525525
Map<String, Object> fetchParams = FetchParametersUtils.selectionTimeQueryToMap(
526-
new SelectionTimeQueryFilter(15, 18, 2, Collections.singleton(functionEntry.getId())));
526+
new SelectionTimeQueryFilter(15, 20, 3, Collections.singleton(functionEntry.getId())));
527527

528-
// Fetch annotations
529528
TmfModelResponse<AnnotationModel> response = dataProvider.fetchAnnotations(fetchParams, MONITOR);
530529

531530
assertEquals(ITmfResponse.Status.COMPLETED, response.getStatus());
@@ -535,15 +534,18 @@ public void testFetchAnnotationsOutputElementStyle() {
535534
assertNotNull(annotations);
536535
assertFalse(annotations.isEmpty());
537536

538-
// Verify OutputElementStyle properties
539-
Annotation annotation = annotations.iterator().next();
540-
OutputElementStyle style = annotation.getStyle();
541-
assertNotNull(style);
537+
// Verify OutputElementStyle properties for all annotations (instant
538+
// and nestable)
539+
for (Annotation annotation : annotations) {
540+
OutputElementStyle style = annotation.getStyle();
541+
assertNotNull(style);
542+
543+
Map<String, Object> styleMap = style.getStyleValues();
544+
assertEquals("#7D3D31", styleMap.get(StyleProperties.COLOR));
545+
assertEquals(0.33f, styleMap.get(StyleProperties.HEIGHT));
546+
assertEquals(SymbolType.DIAMOND, styleMap.get(StyleProperties.SYMBOL_TYPE));
547+
}
542548

543-
Map<String, Object> styleMap = style.getStyleValues();
544-
assertEquals("#7D3D31", styleMap.get(StyleProperties.COLOR));
545-
assertEquals(0.33f, styleMap.get(StyleProperties.HEIGHT));
546-
assertEquals(SymbolType.DIAMOND, styleMap.get(StyleProperties.SYMBOL_TYPE));
547549
}
548550

549551
}
@@ -556,7 +558,7 @@ public void testAnnotationModelStructure() {
556558
FlameChartDataProvider dataProvider = getDataProvider();
557559

558560
Map<String, Object> parameters = FetchParametersUtils.selectionTimeQueryToMap(
559-
new SelectionTimeQueryFilter(0, Long.MAX_VALUE, 2,Collections.emptySet()));
561+
new SelectionTimeQueryFilter(0, Long.MAX_VALUE, 2, Collections.emptySet()));
560562
TmfModelResponse<AnnotationModel> response = dataProvider.fetchAnnotations(parameters, MONITOR);
561563
assertEquals(ITmfResponse.Status.COMPLETED, response.getStatus());
562564

@@ -568,27 +570,25 @@ public void testAnnotationModelStructure() {
568570
assertNotNull(model.getAnnotations().get(InstrumentedCallStackAnalysis.ANNOTATIONS));
569571
}
570572

571-
/**
572-
* Test annotation model structure and properties
573-
*/
574-
@SuppressWarnings("null")
575-
@Test
573+
/**
574+
* Test annotation model structure and properties
575+
*/
576+
@SuppressWarnings("null")
577+
@Test
576578
public void testFetchValidAnnotations() {
577579
FlameChartDataProvider dataProvider = getDataProvider();
578-
TmfModelResponse<@NonNull TmfTreeModel<@NonNull FlameChartEntryModel>> treeResponse =
579-
dataProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(1, Long.MAX_VALUE, 2)), MONITOR);
580-
assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
581-
582-
TmfTreeModel<@NonNull FlameChartEntryModel> m = treeResponse.getModel();
583-
// Get entry IDs from the same tree response
584-
if(m != null) {
585-
Set<Long> allEntryIds = m.getEntries().stream()
586-
.map(FlameChartEntryModel::getId)
587-
.collect(Collectors.toSet());
580+
TmfModelResponse<@NonNull TmfTreeModel<@NonNull FlameChartEntryModel>> treeResponse = dataProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(1, Long.MAX_VALUE, 2)), MONITOR);
581+
assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
588582

583+
TmfTreeModel<@NonNull FlameChartEntryModel> m = treeResponse.getModel();
584+
// Get entry IDs from the same tree response
585+
if (m != null) {
586+
Set<Long> allEntryIds = m.getEntries().stream()
587+
.map(FlameChartEntryModel::getId)
588+
.collect(Collectors.toSet());
589589

590590
Map<String, Object> parameters = FetchParametersUtils.selectionTimeQueryToMap(
591-
new SelectionTimeQueryFilter(1, Long.MAX_VALUE, 2, allEntryIds));
591+
new SelectionTimeQueryFilter(1, Long.MAX_VALUE, 2, allEntryIds));
592592

593593
TmfModelResponse<AnnotationModel> response = dataProvider.fetchAnnotations(parameters, MONITOR);
594594

@@ -599,8 +599,8 @@ public void testFetchValidAnnotations() {
599599
assertNotNull(model);
600600

601601
Map<String, Collection<Annotation>> annotations = model.getAnnotations();
602-
assertNotNull(annotations );
603-
}
602+
assertNotNull(annotations);
603+
}
604604
}
605605

606606
private static void verifyArrows(List<ITimeGraphArrow> arrows, List<ITimeGraphArrow> expectedArrows) {

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/stubs/org/eclipse/tracecompass/analysis/profiling/core/tests/stubs/CallStackProviderStub.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public class CallStackProviderStub extends CallStackStateProvider {
3838
/** Name of the function name field */
3939
public static final String FIELD_NAME = "op";
4040
private static final ITmfStateValue NO_FUNC_EXIT = TmfStateValue.newValueString("unknown");
41+
/** Nested event */
42+
public static final String NESTABLE_INSTANT = "n"; //$NON-NLS-1$
43+
/** Instant event */
44+
public static final String INSTANT = "i"; //$NON-NLS-1$
4145

4246
/**
4347
* Constructor
@@ -137,7 +141,12 @@ protected void eventHandle(ITmfEvent event) {
137141
}
138142
// Handle instant events
139143
ITmfEventField phField = event.getContent().getField("ph");
140-
if (phField != null && "i".equals(phField.getValue())) {
144+
if (phField != null && INSTANT.equals(phField.getValue())) {
145+
handleInstant(event);
146+
return;
147+
}
148+
// Handle nested events
149+
if (phField != null && NESTABLE_INSTANT.equals(phField.getValue())) {
141150
handleInstant(event);
142151
return;
143152
}

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/stubs/org/eclipse/tracecompass/analysis/profiling/core/tests/stubs2/CallStackProviderStub.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public class CallStackProviderStub extends CallStackStateProvider {
3434

3535
private static final String ENTRY = "entry";
3636
private static final String EXIT = "exit";
37-
37+
/** Nested event */
38+
public static final String NESTABLE_INSTANT = "n"; //$NON-NLS-1$
39+
/** Instant event */
40+
public static final String INSTANT = "i"; //$NON-NLS-1$
3841
/**
3942
* Constructor
4043
*
@@ -109,7 +112,12 @@ protected void eventHandle(ITmfEvent event) {
109112
}
110113
// Handle instant events
111114
ITmfEventField phField = event.getContent().getField("ph");
112-
if (phField != null && "i".equals(phField.getValue())) {
115+
if (phField != null && INSTANT.equals(phField.getValue())) {
116+
handleInstant(event);
117+
return;
118+
}
119+
// Handle nested events
120+
if (phField != null && NESTABLE_INSTANT.equals(phField.getValue())) {
113121
handleInstant(event);
114122
return;
115123
}

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/traces/callstackIevents.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@
204204
<field name="pid" type="string" value="5" />
205205
<field name="tid" type="string" value="7" />
206206
</event>
207+
<event timestamp="19" name="nestable_instant">
208+
<field name="ph" value="n" type="string" />
209+
<field name="tid" value="2" type="string" />
210+
<field name="pid" type="string" value="1" />
211+
<field name="name" value="parse_step" type="string" />
212+
<field name="id" value="0x123" type="string" />
213+
<field name="cat" value="parser" type="string" />
214+
</event>
215+
207216
<event timestamp="20" name="exit">
208217
<field name="op" type="string" value="op2" />
209218
<field name="pid" type="string" value="1" />

0 commit comments

Comments
 (0)