Commit | Line | Data |
---|---|---|
739b9fec AM |
1 | package org.eclipse.tracecompass.internal.analysis.os.linux.core.views.controlflow2; |
2 | ||
3 | import java.util.List; | |
4 | ||
5 | import org.eclipse.jdt.annotation.Nullable; | |
6 | import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes; | |
7 | import org.eclipse.tracecompass.internal.provisional.tmf.core.views.timegraph2.TimeGraphTreeElement; | |
8 | import org.eclipse.tracecompass.internal.provisional.tmf.core.views.timegraph2.statesystem.StateSystemTimeGraphTreeElement; | |
9 | ||
10 | public class ControlFlowTreeElement extends StateSystemTimeGraphTreeElement { | |
11 | ||
12 | private static final String UNKNOWN_THREAD_NAME = "???"; //$NON-NLS-1$ | |
13 | ||
14 | private final int fTid; | |
15 | private final String fThreadName; | |
16 | ||
17 | public ControlFlowTreeElement(String tidStr, @Nullable String threadName, | |
18 | List<TimeGraphTreeElement> children, int sourceQuark) { | |
19 | super(getElementName(tidStr, threadName), | |
20 | children, | |
21 | sourceQuark); | |
22 | ||
23 | if (tidStr.startsWith(Attributes.THREAD_0_PREFIX)) { | |
24 | fTid = 0; | |
25 | } else { | |
26 | fTid = Integer.parseInt(tidStr); | |
27 | } | |
28 | ||
29 | fThreadName = (threadName == null ? UNKNOWN_THREAD_NAME : threadName); | |
30 | } | |
31 | ||
32 | private static String getElementName(String tidStr, @Nullable String threadName) { | |
33 | String tidPart = tidStr; | |
34 | if (tidPart.startsWith(Attributes.THREAD_0_PREFIX)) { | |
35 | /* Display "0/0" instead of "0_0" */ | |
36 | tidPart = tidPart.replace('_', '/'); | |
37 | } | |
38 | ||
39 | String threadNamePart = (threadName == null ? UNKNOWN_THREAD_NAME : threadName); | |
40 | return (tidPart + " - " + threadNamePart); //$NON-NLS-1$ | |
41 | } | |
42 | ||
43 | public int getTid() { | |
44 | return fTid; | |
45 | } | |
46 | ||
47 | public String getThreadName() { | |
48 | return fThreadName; | |
49 | } | |
50 | ||
51 | } |