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