1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.latency
;
12 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
14 import java
.io
.Serializable
;
15 import java
.util
.Comparator
;
18 import org
.eclipse
.jdt
.annotation
.Nullable
;
19 import org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
;
20 import org
.eclipse
.tracecompass
.segmentstore
.core
.ISegment
;
21 import org
.eclipse
.tracecompass
.segmentstore
.core
.SegmentComparators
;
23 import com
.google
.common
.collect
.ImmutableMap
;
24 import com
.google
.common
.collect
.Ordering
;
27 * A linux kernel system call, represented as an {@link ISegment}.
29 * @author Alexandre Montplaisir
32 public class SystemCall
implements ISegment
{
34 private static final long serialVersionUID
= 1554494342105208730L;
36 private static final Comparator
<ISegment
> COMPARATOR
= checkNotNull(Ordering
37 .from(SegmentComparators
.INTERVAL_START_COMPARATOR
)
38 .compound(SegmentComparators
.INTERVAL_END_COMPARATOR
)
39 /* Kind of lazy, but should work! */
40 .compound(Ordering
.usingToString()));
43 * The subset of information that is available from the syscall entry event.
45 public static class InitialInfo
implements Serializable
{
47 private static final long serialVersionUID
= -5009710718804983721L;
49 private final long fStartTime
;
50 private final String fName
;
51 private final Map
<String
, String
> fArgs
;
55 * Start time of the system call
57 * Name of the system call
59 * Arguments of the system call
64 Map
<String
, String
> arguments
) {
65 fStartTime
= startTime
;
67 fArgs
= NonNullUtils
.checkNotNull(ImmutableMap
.copyOf(arguments
));
71 private final InitialInfo fInfo
;
72 private final long fEndTime
;
73 private final int fRet
;
77 * Initial information of the system call
79 * End time of the system call
81 * Return value of the system call
93 public long getStart() {
94 return fInfo
.fStartTime
;
98 public long getEnd() {
103 * Get the name of the system call
107 public String
getName() {
112 * Get the arguments of the system call
114 * @return Map of the arguments
116 public Map
<String
, String
> getArguments() {
121 * Get the return value of the system call
123 * @return Return value
125 public int getReturnValue() {
130 public int compareTo(@Nullable ISegment o
) {
132 throw new IllegalArgumentException();
134 return COMPARATOR
.compare(this, o
);
138 public String
toString() {
139 return "Start Time = " + getStart() + //$NON-NLS-1$
140 "; End Time = " + getEnd() + //$NON-NLS-1$
141 "; Duration = " + getLength() + //$NON-NLS-1$
142 "; Name = " + getName() + //$NON-NLS-1$
143 "; Args = " + getArguments().toString() + //$NON-NLS-1$
144 "; Return = " + getReturnValue(); //$NON-NLS-1$