analysis: add sorting for systemCall attributes

Adds comparators for SyscallFileAspect, SyscallRetAspect,
SyscallComponentAspect, SyscallTidAspect and SyscallNameAspect.
Each one of these comparators implements the Start Time as a secondary
sorting field.

[Changed] Added sorting for systemCall attributes

Change-Id: I2206d72fe0097bddbcf7b688e4e2c62518b43936
Signed-off-by: David Piché <dpiche.veg@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/163547
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java
index 01f90cc..2737800 100644
--- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java
+++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java
@@ -31,6 +31,7 @@
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.SyscallLookup;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
+import org.eclipse.tracecompass.segmentstore.core.SegmentComparators;
 import org.eclipse.tracecompass.segmentstore.core.SegmentStoreFactory.SegmentStoreType;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
@@ -214,7 +215,19 @@
 
         @Override
         public @Nullable Comparator<?> getComparator() {
-            return null;
+            return (ISegment segment1, ISegment segment2) -> {
+                if (segment1 == null) {
+                    return 1;
+                }
+                if (segment2 == null) {
+                    return -1;
+                }
+                if (segment1 instanceof SystemCall && segment2 instanceof SystemCall) {
+                    int res = ((SystemCall) segment1).getName().compareTo(((SystemCall) segment2).getName());
+                    return (res != 0 ? res : SegmentComparators.INTERVAL_START_COMPARATOR.thenComparing(SegmentComparators.INTERVAL_END_COMPARATOR).compare(segment1, segment2));
+                }
+                return 1;
+            };
         }
 
         @Override
@@ -245,7 +258,19 @@
 
         @Override
         public @Nullable Comparator<?> getComparator() {
-            return null;
+            return (ISegment segment1, ISegment segment2) -> {
+                if (segment1 == null) {
+                    return 1;
+                }
+                if (segment2 == null) {
+                    return -1;
+                }
+                if (segment1 instanceof SystemCall && segment2 instanceof SystemCall) {
+                    int res = Integer.compare(((SystemCall) segment1).getTid(), ((SystemCall) segment2).getTid());
+                    return (res != 0 ? res : SegmentComparators.INTERVAL_START_COMPARATOR.thenComparing(SegmentComparators.INTERVAL_END_COMPARATOR).compare(segment1, segment2));
+                }
+                return 1;
+            };
         }
 
         @Override
@@ -276,7 +301,19 @@
 
         @Override
         public @Nullable Comparator<?> getComparator() {
-            return null;
+            return (ISegment segment1, ISegment segment2) -> {
+                if (segment1 == null) {
+                    return 1;
+                }
+                if (segment2 == null) {
+                    return -1;
+                }
+                if (segment1 instanceof SystemCall && segment2 instanceof SystemCall) {
+                    int res = SyscallLookup.getInstance().getComponent(((SystemCall) segment1).getName()).compareTo(SyscallLookup.getInstance().getComponent(((SystemCall) segment2).getName()));
+                    return (res != 0 ? res : SegmentComparators.INTERVAL_START_COMPARATOR.thenComparing(SegmentComparators.INTERVAL_END_COMPARATOR).compare(segment1, segment2));
+                }
+                return 1;
+            };
         }
 
         @Override
@@ -315,7 +352,19 @@
 
         @Override
         public @Nullable Comparator<?> getComparator() {
-            return null;
+            return (ISegment segment1, ISegment segment2) -> {
+                if (segment1 == null) {
+                    return 1;
+                }
+                if (segment2 == null) {
+                    return -1;
+                }
+                if (segment1 instanceof SystemCall && segment2 instanceof SystemCall) {
+                    int res = Integer.compare(((SystemCall) segment1).getReturnValue(), ((SystemCall) segment2).getReturnValue());
+                    return (res != 0 ? res : SegmentComparators.INTERVAL_START_COMPARATOR.thenComparing(SegmentComparators.INTERVAL_END_COMPARATOR).compare(segment1, segment2));
+                }
+                return 1;
+            };
         }
 
     }
@@ -339,7 +388,19 @@
 
         @Override
         public @Nullable Comparator<?> getComparator() {
-            return null;
+            return (ISegment segment1, ISegment segment2) -> {
+                if (segment1 == null) {
+                    return 1;
+                }
+                if (segment2 == null) {
+                    return -1;
+                }
+                if (segment1 instanceof SystemCall && segment2 instanceof SystemCall) {
+                    int res = SyscallLookup.getInstance().getFile(((SystemCall) segment1).getName()).compareTo(SyscallLookup.getInstance().getFile(((SystemCall) segment2).getName()));
+                    return (res != 0 ? res : SegmentComparators.INTERVAL_START_COMPARATOR.thenComparing(SegmentComparators.INTERVAL_END_COMPARATOR).compare(segment1, segment2));
+                }
+                return 1;
+            };
         }
 
         @Override