linux.core: Intern SystemCall name string
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / latency / SystemCall.java
CommitLineData
7b79ee46 1/*******************************************************************************
4eec2dc5 2 * Copyright (c) 2015, 2016 EfficiOS Inc., Alexandre Montplaisir and others
7b79ee46
FLN
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
660d4ed9 10package org.eclipse.tracecompass.internal.analysis.os.linux.core.latency;
7b79ee46 11
4eec2dc5
MK
12import java.io.IOException;
13import java.io.ObjectInputStream;
14import java.io.ObjectOutputStream;
7b79ee46 15
f1c52947 16import org.eclipse.jdt.annotation.NonNull;
7b79ee46 17import org.eclipse.tracecompass.segmentstore.core.ISegment;
7b79ee46 18
7b79ee46
FLN
19/**
20 * A linux kernel system call, represented as an {@link ISegment}.
21 *
22 * @author Alexandre Montplaisir
fb3a499b 23 * @since 2.0
7b79ee46 24 */
4eec2dc5 25public final class SystemCall implements ISegment {
7b79ee46
FLN
26
27 private static final long serialVersionUID = 1554494342105208730L;
28
7b79ee46
FLN
29 /**
30 * The subset of information that is available from the syscall entry event.
31 */
4eec2dc5 32 public static class InitialInfo {
7b79ee46 33
4eec2dc5
MK
34 private long fStartTime;
35 private String fName;
7b79ee46
FLN
36
37 /**
38 * @param startTime
39 * Start time of the system call
40 * @param name
41 * Name of the system call
7b79ee46
FLN
42 */
43 public InitialInfo(
44 long startTime,
137512b3 45 String name) {
7b79ee46 46 fStartTime = startTime;
4eec2dc5 47 fName = name.intern();
7b79ee46
FLN
48 }
49 }
50
4eec2dc5
MK
51 private long fStartTime;
52 private long fEndTime;
53 private String fName;
7b79ee46
FLN
54
55 /**
56 * @param info
57 * Initial information of the system call
58 * @param endTime
59 * End time of the system call
7b79ee46
FLN
60 */
61 public SystemCall(
62 InitialInfo info,
137512b3 63 long endTime) {
4eec2dc5
MK
64 fStartTime = info.fStartTime;
65 fName = info.fName;
7b79ee46 66 fEndTime = endTime;
7b79ee46
FLN
67 }
68
4eec2dc5
MK
69 private void writeObject(ObjectOutputStream out) throws IOException {
70 out.writeLong(fStartTime);
71 out.writeLong(fEndTime);
72 out.writeUTF(fName);
73 }
74
75 private void readObject(ObjectInputStream in) throws IOException {
76 fStartTime = in.readLong();
77 fEndTime = in.readLong();
78 fName = in.readUTF().intern();
79 }
80
7b79ee46
FLN
81 @Override
82 public long getStart() {
4eec2dc5 83 return fStartTime;
7b79ee46
FLN
84 }
85
86 @Override
87 public long getEnd() {
88 return fEndTime;
89 }
90
7b79ee46
FLN
91 /**
92 * Get the name of the system call
93 *
94 * @return Name
95 */
96 public String getName() {
4eec2dc5 97 return fName;
7b79ee46
FLN
98 }
99
7b79ee46 100 @Override
f1c52947
JCK
101 public int compareTo(@NonNull ISegment o) {
102 int ret = ISegment.super.compareTo(o);
103 if (ret != 0) {
104 return ret;
7b79ee46 105 }
f1c52947 106 return toString().compareTo(o.toString());
7b79ee46
FLN
107 }
108
109 @Override
110 public String toString() {
111 return "Start Time = " + getStart() + //$NON-NLS-1$
112 "; End Time = " + getEnd() + //$NON-NLS-1$
113 "; Duration = " + getLength() + //$NON-NLS-1$
137512b3 114 "; Name = " + getName(); //$NON-NLS-1$
7b79ee46
FLN
115 }
116}
This page took 0.041466 seconds and 5 git commands to generate.