d89ff4e46dffe8c22f2a8f339c13e85272717d89
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / latency / SystemCall.java
1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
3 *
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 *******************************************************************************/
9
10 package org.eclipse.tracecompass.analysis.os.linux.core.latency;
11
12 import java.io.Serializable;
13 import java.util.Map;
14
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.tracecompass.common.core.NonNullUtils;
17 import org.eclipse.tracecompass.segmentstore.core.ISegment;
18
19 import com.google.common.collect.ImmutableMap;
20
21 /**
22 * A linux kernel system call, represented as an {@link ISegment}.
23 *
24 * @author Alexandre Montplaisir
25 * @since 2.0
26 */
27 public class SystemCall implements ISegment {
28
29 private static final long serialVersionUID = 1554494342105208730L;
30
31 /**
32 * The subset of information that is available from the syscall entry event.
33 */
34 public static class InitialInfo implements Serializable {
35
36 private static final long serialVersionUID = -5009710718804983721L;
37
38 private final long fStartTime;
39 private final String fName;
40 private final Map<String, String> fArgs;
41
42 /**
43 * @param startTime
44 * Start time of the system call
45 * @param name
46 * Name of the system call
47 * @param arguments
48 * Arguments of the system call
49 */
50 public InitialInfo(
51 long startTime,
52 String name,
53 Map<String, String> arguments) {
54 fStartTime = startTime;
55 fName = name;
56 fArgs = NonNullUtils.checkNotNull(ImmutableMap.copyOf(arguments));
57 }
58 }
59
60 private final InitialInfo fInfo;
61 private final long fEndTime;
62 private final int fRet;
63
64 /**
65 * @param info
66 * Initial information of the system call
67 * @param endTime
68 * End time of the system call
69 * @param ret
70 * Return value of the system call
71 */
72 public SystemCall(
73 InitialInfo info,
74 long endTime,
75 int ret) {
76 fInfo = info;
77 fEndTime = endTime;
78 fRet = ret;
79 }
80
81 @Override
82 public long getStart() {
83 return fInfo.fStartTime;
84 }
85
86 @Override
87 public long getEnd() {
88 return fEndTime;
89 }
90
91 /**
92 * Get the name of the system call
93 *
94 * @return Name
95 */
96 public String getName() {
97 return fInfo.fName;
98 }
99
100 /**
101 * Get the arguments of the system call
102 *
103 * @return Map of the arguments
104 */
105 public Map<String, String> getArguments() {
106 return fInfo.fArgs;
107 }
108
109 /**
110 * Get the return value of the system call
111 *
112 * @return Return value
113 */
114 public int getReturnValue() {
115 return fRet;
116 }
117
118 @Override
119 public int compareTo(@NonNull ISegment o) {
120 int ret = ISegment.super.compareTo(o);
121 if (ret != 0) {
122 return ret;
123 }
124 return toString().compareTo(o.toString());
125 }
126
127 @Override
128 public String toString() {
129 return "Start Time = " + getStart() + //$NON-NLS-1$
130 "; End Time = " + getEnd() + //$NON-NLS-1$
131 "; Duration = " + getLength() + //$NON-NLS-1$
132 "; Name = " + getName() + //$NON-NLS-1$
133 "; Args = " + getArguments().toString() + //$NON-NLS-1$
134 "; Return = " + getReturnValue(); //$NON-NLS-1$
135 }
136 }
This page took 0.034681 seconds and 5 git commands to generate.