Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
36299425 | 2 | * Copyright (c) 2012, 2016 Ericsson, École Polytechnique de Montréal |
be222f56 PT |
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 | |
4999a196 | 11 | * Geneviève Bastien - Move code to provide base classes for time graph view |
be222f56 PT |
12 | *******************************************************************************/ |
13 | ||
ace7140d | 14 | package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.controlflow; |
be222f56 | 15 | |
36299425 JCK |
16 | import java.util.regex.Pattern; |
17 | ||
72221aa4 | 18 | import org.eclipse.jdt.annotation.NonNull; |
2bdf0193 AM |
19 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; |
20 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry; | |
36299425 JCK |
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; | |
be222f56 PT |
24 | |
25 | /** | |
26 | * An entry in the Control Flow view | |
27 | */ | |
4999a196 GB |
28 | public class ControlFlowEntry extends TimeGraphEntry { |
29 | ||
72221aa4 | 30 | private final @NonNull ITmfTrace fTrace; |
be222f56 | 31 | private final int fThreadId; |
8321a699 | 32 | private int fParentThreadId; |
4999a196 | 33 | private final int fThreadQuark; |
be222f56 PT |
34 | |
35 | /** | |
36 | * Constructor | |
37 | * | |
4999a196 | 38 | * @param quark |
be222f56 PT |
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 | |
be222f56 PT |
48 | * @param startTime |
49 | * The start time of this process's lifetime | |
50 | * @param endTime | |
51 | * The end time of this process | |
52 | */ | |
72221aa4 | 53 | public ControlFlowEntry(int quark, @NonNull ITmfTrace trace, String execName, int threadId, int parentThreadId, long startTime, long endTime) { |
1d46dc38 PT |
54 | super(execName, startTime, endTime); |
55 | fTrace = trace; | |
be222f56 PT |
56 | fThreadId = threadId; |
57 | fParentThreadId = parentThreadId; | |
4999a196 | 58 | fThreadQuark = quark; |
be222f56 PT |
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 | ||
1d46dc38 | 70 | /** |
1cf25311 | 71 | * Get the entry's trace |
1d46dc38 | 72 | * |
1cf25311 | 73 | * @return the entry's trace |
1d46dc38 | 74 | */ |
72221aa4 | 75 | public @NonNull ITmfTrace getTrace() { |
1d46dc38 | 76 | return fTrace; |
4999a196 GB |
77 | } |
78 | ||
be222f56 PT |
79 | /** |
80 | * Get this thread's parent TID | |
81 | * | |
82 | * @return The "PTID" | |
83 | */ | |
84 | public int getParentThreadId() { | |
85 | return fParentThreadId; | |
86 | } | |
87 | ||
8321a699 PT |
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 | ||
be222f56 | 99 | /** |
4999a196 | 100 | * Get the quark of the attribute matching this thread's TID |
be222f56 | 101 | * |
4999a196 | 102 | * @return The quark |
be222f56 | 103 | */ |
4999a196 GB |
104 | public int getThreadQuark() { |
105 | return fThreadQuark; | |
be222f56 PT |
106 | } |
107 | ||
36299425 JCK |
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 | } | |
3553c912 | 122 | return (pattern.matcher(Utils.formatTime(getStartTime(), TimeFormat.CALENDAR, Resolution.NANOSEC)).find()); |
36299425 JCK |
123 | } |
124 | ||
b1b156f3 PT |
125 | @Override |
126 | public String toString() { | |
127 | return getClass().getSimpleName() + '(' + getName() + '[' + fThreadId + "])"; //$NON-NLS-1$ | |
128 | } | |
be222f56 | 129 | } |