Skip to content

Commit 9a9e5c5

Browse files
committed
kernel: make status for threads work again
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
1 parent b7238a7 commit 9a9e5c5

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public static Map<Integer, List<ITmfStateInterval>> getStatusIntervalsForThreads
548548
if (ss == null) {
549549
return Objects.requireNonNull(Collections.emptyMap());
550550
}
551-
List<Long> currentTimes = times.stream().filter(time -> (time > ss.getCurrentEndTime() || time < ss.getStartTime())).sorted().collect(Collectors.toList());
551+
List<Long> currentTimes = times.stream().filter(time -> (time < ss.getCurrentEndTime() && time > ss.getStartTime())).sorted().collect(Collectors.toList());
552552
if (currentTimes.isEmpty()) {
553553
return Objects.requireNonNull(Collections.emptyMap());
554554
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public void testFetchModel() {
262262
new TimeGraphState(6, 2, null, new OutputElementStyle(LinuxStyle.WAIT_FOR_CPU.getLabel())),
263263
new TimeGraphState(8, 2, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel())),
264264
new TimeGraphState(10, 2, null, new OutputElementStyle(LinuxStyle.WAIT_FOR_CPU.getLabel())),
265-
new TimeGraphState(12, 8, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel()))), true);
265+
new TimeGraphState(12, 8, "openat", new OutputElementStyle(LinuxStyle.SYSCALL.getLabel()))), true);
266266

267267
// Get the row model for those entries with low resolution
268268
rowResponse = dataProvider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(3, 15, 2, selectedIds)), new NullProgressMonitor());
@@ -300,7 +300,7 @@ public void testFetchModel() {
300300
// Verify kernel statuses of tid 6
301301
verifyStates(rows, FlameDataProviderTestUtils.findEntryByDepthAndType(tid6Children, -1, EntryType.KERNEL), ImmutableList.of(
302302
new TimeGraphState(1, 5, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel())),
303-
new TimeGraphState(12, 8, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel()))), true);
303+
new TimeGraphState(12, 8, "openat", new OutputElementStyle(LinuxStyle.SYSCALL.getLabel()))), true);
304304

305305
// Check arrows
306306
FlameChartEntryModel tid2 = FlameDataProviderTestUtils.findEntryByNameAndType(modelEntries, "2", EntryType.LEVEL);
@@ -436,6 +436,7 @@ private static void verifyStates(List<ITimeGraphRowModel> rowModels, FlameChartE
436436
assertNotNull(rowModel);
437437
@SuppressWarnings("null")
438438
List<ITimeGraphState> states = rowModel.getStates();
439+
assertEquals(expectedStates.size(), states.size());
439440
for (int i = 0; i < states.size(); i++) {
440441
String entryName = entry.getName();
441442
if (i > expectedStates.size() - 1) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ public ITmfStateProvider getNewInstance() {
5959
@Override
6060
protected void eventHandle(ITmfEvent event) {
6161
ITmfStateSystemBuilder ssb = getStateSystemBuilder();
62-
if (ssb == null) {
62+
if (ssb == null || event.getName().equals("instant_event")) {
6363
return;
6464
}
6565
int threadQuark = ssb.getQuarkAbsoluteAndAdd(Attributes.THREADS, event.getContent().getFieldValue(String.class, "tid"));
6666
boolean isEntry = event.getName().equals(ENTRY);
6767
long timestamp = event.getTimestamp().getValue();
6868
if (isEntry) {
69-
if (event.getName().equals("op4")) {
69+
String operationName = event.getContent().getFieldValue(String.class, "op");
70+
if (operationName != null && operationName.equals("op4")) {
7071
int systemCallQuark = ssb.getQuarkRelativeAndAdd(threadQuark, Attributes.SYSTEM_CALL);
7172
ssb.modifyAttribute(timestamp, "openat", systemCallQuark);
7273
/* Put the process in system call mode */

0 commit comments

Comments
 (0)