1b7a09b1703e03513ee5bff223e8a4435641defd
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.ui / src / org / eclipse / tracecompass / analysis / os / linux / ui / views / controlflow / ControlFlowEntry.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2016 Ericsson, École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 * Geneviève Bastien - Move code to provide base classes for time graph view
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.analysis.os.linux.ui.views.controlflow;
15
16 import java.util.regex.Pattern;
17
18 import org.eclipse.jdt.annotation.NonNull;
19 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
20 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
21 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
22 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
23 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
24
25 /**
26 * An entry in the Control Flow view
27 */
28 public class ControlFlowEntry extends TimeGraphEntry {
29
30 private final @NonNull ITmfTrace fTrace;
31 private final int fThreadId;
32 private int fParentThreadId;
33 private final int fThreadQuark;
34
35 /**
36 * Constructor
37 *
38 * @param quark
39 * The attribute quark matching the thread
40 * @param trace
41 * The trace on which we are working
42 * @param execName
43 * The exec_name of this entry
44 * @param threadId
45 * The TID of the thread
46 * @param parentThreadId
47 * the Parent_TID of this thread
48 * @param startTime
49 * The start time of this process's lifetime
50 * @param endTime
51 * The end time of this process
52 */
53 public ControlFlowEntry(int quark, @NonNull ITmfTrace trace, String execName, int threadId, int parentThreadId, long startTime, long endTime) {
54 super(execName, startTime, endTime);
55 fTrace = trace;
56 fThreadId = threadId;
57 fParentThreadId = parentThreadId;
58 fThreadQuark = quark;
59 }
60
61 /**
62 * Get this entry's thread ID
63 *
64 * @return The TID
65 */
66 public int getThreadId() {
67 return fThreadId;
68 }
69
70 /**
71 * Get the entry's trace
72 *
73 * @return the entry's trace
74 */
75 public @NonNull ITmfTrace getTrace() {
76 return fTrace;
77 }
78
79 /**
80 * Get this thread's parent TID
81 *
82 * @return The "PTID"
83 */
84 public int getParentThreadId() {
85 return fParentThreadId;
86 }
87
88 /**
89 * Set this thread's parent TID
90 *
91 * @param ptid
92 * The "PTID"
93 * @since 1.1
94 */
95 public void setParentThreadId(int ptid) {
96 fParentThreadId = ptid;
97 }
98
99 /**
100 * Get the quark of the attribute matching this thread's TID
101 *
102 * @return The quark
103 */
104 public int getThreadQuark() {
105 return fThreadQuark;
106 }
107
108 @Override
109 public boolean matches(@NonNull Pattern pattern) {
110 if (pattern.matcher(getName()).find()) {
111 return true;
112 }
113 if (pattern.matcher(Integer.toString(fThreadId)).find()) {
114 return true;
115 }
116 if (pattern.matcher(Integer.toString(fParentThreadId)).find()) {
117 return true;
118 }
119 if (pattern.matcher(Integer.toString(fThreadQuark)).find()) {
120 return true;
121 }
122 if (pattern.matcher(Utils.formatTime(getStartTime(), TimeFormat.CALENDAR, Resolution.NANOSEC)).find()) {
123 return true;
124 }
125 return pattern.matcher(fTrace.getName()).find();
126 }
127
128 @Override
129 public String toString() {
130 return getClass().getSimpleName() + '(' + getName() + '[' + fThreadId + "])"; //$NON-NLS-1$
131 }
132 }
This page took 0.035722 seconds and 4 git commands to generate.