Skip to content

Commit 1801704

Browse files
committed
linux: support columns in ThreadStatusDataProvider tree model
Add process ID (PID), parent PID (PPID) and thread ID (TID) columns as part of the ThreadStatusDataProvider. This will be used in the trace server. [Added] PID, PPID and TID column in the ThreadStatusDataProvider tree Signed-off-by: Bernd Hufmann <[email protected]>
1 parent 4c5e201 commit 1801704

File tree

6 files changed

+107
-15
lines changed

6 files changed

+107
-15
lines changed

analysis/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
44
Bundle-Vendor: %Bundle-Vendor
5-
Bundle-Version: 9.0.1.qualifier
5+
Bundle-Version: 9.1.0.qualifier
66
Bundle-Localization: plugin
77
Bundle-SymbolicName: org.eclipse.tracecompass.analysis.os.linux.core;singleton:=true
88
Bundle-Activator: org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/event/aspect/Messages.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@ public class Messages extends NLS {
3434
/** Label for the parent's thread ID
3535
* @since 4.2*/
3636
public static @Nullable String AspectName_Ptid;
37+
/** Description for the parent's thread ID
38+
* @since 9.1*/
39+
public static @Nullable String AspectHelpText_Ptid;
3740

3841
/**
3942
* String to identify the executable name
4043
* @since 4.1
4144
*/
4245
public static @Nullable String AspectName_ExecName;
4346

47+
/** Description for the exec name
48+
* @since 9.1*/
49+
public static @Nullable String AspectHelpText_ExecName;
50+
4451
public static @Nullable String AspectHelpText_Tid;
4552

4653
public static @Nullable String AspectName_Prio;

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/event/aspect/messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ AspectName_Prio=Prio
2222
AspectHelpText_Prio=The priority of the thread this event belongs to
2323

2424
AspectName_ExecName=Exec_Name
25+
AspectHelpText_ExecName=The Exec name of the thread
2526

2627
AspectName_Ptid=PTID
28+
AspectHelpText_Ptid=The ID of the parent thread this event belongs to

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/model/OsStrings.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ public static String tid() {
4343
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectName_Tid);
4444
}
4545

46+
/**
47+
* Description string for the thread ID
48+
*
49+
* @return The externalized description text for thread ID
50+
* @since 9.1
51+
*/
52+
public static String tidDesc() {
53+
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectHelpText_Tid);
54+
}
55+
4656
/**
4757
* Get the string for the process ID
4858
*
@@ -52,6 +62,16 @@ public static String pid() {
5262
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectName_Pid);
5363
}
5464

65+
/**
66+
* Description string for the process ID
67+
*
68+
* @return The externalized description text for process ID
69+
* @since 9.1
70+
*/
71+
public static String pidDesc() {
72+
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectHelpText_Pid);
73+
}
74+
5575
/**
5676
* Get the string for the parent's thread ID
5777
*
@@ -62,6 +82,16 @@ public static String ptid() {
6282
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectName_Ptid);
6383
}
6484

85+
/**
86+
* Description string for the parent thread ID
87+
*
88+
* @return The externalized description text for parent thread ID
89+
* @since 9.1
90+
*/
91+
public static String ptidDesc() {
92+
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectHelpText_Ptid);
93+
}
94+
6595
/**
6696
* Get the externalized string for the executable name of a thread
6797
*
@@ -72,4 +102,14 @@ public static String execName() {
72102
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectName_ExecName);
73103
}
74104

105+
/**
106+
* Description string for the executable name of a thread
107+
*
108+
* @return The externalized label for exec name description
109+
* @since 9.1
110+
*/
111+
public static String execNameDesc() {
112+
return Objects.requireNonNull(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.Messages.AspectHelpText_ExecName);
113+
}
114+
75115
}

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadEntryModel.java

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515

1616
import org.eclipse.jdt.annotation.NonNull;
1717
import org.eclipse.tracecompass.analysis.os.linux.core.model.OsStrings;
18+
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.TableColumnDescriptor;
19+
import org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor;
1820
import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel;
1921

2022
import com.google.common.collect.HashMultimap;
23+
import com.google.common.collect.ImmutableList;
2124
import com.google.common.collect.Multimap;
2225

2326
/**
@@ -34,7 +37,7 @@ public class ThreadEntryModel extends TimeGraphEntryModel {
3437
*/
3538
public static final class Builder {
3639
private final long fId;
37-
private @NonNull List<@NonNull String> fLabels;
40+
private @NonNull String fExecName;
3841
private final long fStartTime;
3942
private long fEndTime;
4043
private final int fTid;
@@ -46,8 +49,8 @@ public static final class Builder {
4649
*
4750
* @param id
4851
* The unique ID for this Entry model for its trace
49-
* @param labels
50-
* the thread labels
52+
* @param execName
53+
* the exec name
5154
* @param start
5255
* the thread's start time
5356
* @param end
@@ -61,9 +64,9 @@ public static final class Builder {
6164
* <code>-1</code> can be used. The PID will be assumed to be
6265
* the same as the TID
6366
*/
64-
public Builder(long id, @NonNull List<@NonNull String> labels, long start, long end, int tid, int ppid, int pid) {
67+
public Builder(long id, @NonNull String execName, long start, long end, int tid, int ppid, int pid) {
6568
fId = id;
66-
fLabels = labels;
69+
fExecName = execName;
6770
fStartTime = start;
6871
fEndTime = end;
6972
fTid = tid;
@@ -113,8 +116,8 @@ public int getPpid() {
113116
* @param name
114117
* the new name
115118
*/
116-
public void setName(@NonNull List<@NonNull String> name) {
117-
fLabels = name;
119+
public void setName(@NonNull String name) {
120+
fExecName = name;
118121
}
119122

120123
/**
@@ -159,8 +162,13 @@ public void setPid(int pid) {
159162
* {@link NullPointerException} if the parent Id is not set.
160163
*/
161164
public ThreadEntryModel build(long parentId) {
162-
return new ThreadEntryModel(fId, parentId, fLabels, fStartTime, fEndTime, fTid, fPpid, fPid);
165+
@NonNull List<@NonNull String> labels = ImmutableList.of(fExecName,
166+
String.valueOf(fTid),
167+
fPid <= 0 ? String.valueOf(fTid) : String.valueOf(fPid),
168+
fPpid > 0 ? String.valueOf(fPpid) : ""); //$NON-NLS-1$
169+
return new ThreadEntryModel(fId, parentId, labels, fStartTime, fEndTime, fTid, fPpid, fPid);
163170
}
171+
164172
}
165173

166174
private final int fThreadId;
@@ -203,6 +211,32 @@ public ThreadEntryModel(long id, long parentId, @NonNull List<@NonNull String> l
203211

204212
}
205213

214+
/**
215+
* Get the column descriptors corresponding to the of labels in the ThreadEntryModel
216+
*
217+
* @return list of column descriptor
218+
*/
219+
public static @NonNull List<@NonNull ITableColumnDescriptor> getColumnDescriptors() {
220+
ImmutableList.Builder<@NonNull ITableColumnDescriptor> headers = new ImmutableList.Builder<>();
221+
TableColumnDescriptor.Builder builder = new TableColumnDescriptor.Builder();
222+
builder.setText(OsStrings.execName());
223+
builder.setTooltip(OsStrings.execNameDesc());
224+
headers.add(builder.build());
225+
builder = new TableColumnDescriptor.Builder();
226+
builder.setText(OsStrings.tid());
227+
builder.setTooltip(OsStrings.tidDesc());
228+
headers.add(builder.build());
229+
builder = new TableColumnDescriptor.Builder();
230+
builder.setText(OsStrings.pid());
231+
builder.setTooltip(OsStrings.pidDesc());
232+
headers.add(builder.build());
233+
builder = new TableColumnDescriptor.Builder();
234+
builder.setText(OsStrings.ptid());
235+
builder.setTooltip(OsStrings.ptidDesc());
236+
headers.add(builder.build());
237+
return headers.build();
238+
}
239+
206240
/**
207241
* Gets the entry thread ID
208242
*

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadStatusDataProvider.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.eclipse.tracecompass.analysis.os.linux.core.model.OsStrings;
3636
import org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus;
3737
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
38+
import org.eclipse.tracecompass.common.core.NonNullUtils;
3839
import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator;
3940
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
4041
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.StateValues;
@@ -200,7 +201,10 @@ public ThreadStatusDataProvider(@NonNull ITmfTrace trace, TmfStateSystemAnalysis
200201
@Override
201202
public @NonNull TmfModelResponse<@NonNull TmfTreeModel<@NonNull TimeGraphEntryModel>> fetchTree(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
202203
if (fLastEnd == Long.MAX_VALUE) {
203-
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), filter(Objects.requireNonNull(fTraceEntry), fTidToEntry, fetchParameters)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
204+
TmfTreeModel.Builder<@NonNull TimeGraphEntryModel> treeModelBuilder = new TmfTreeModel.Builder();
205+
treeModelBuilder.setColumnDescriptors(ThreadEntryModel.getColumnDescriptors());
206+
treeModelBuilder.setEntries(filter(Objects.requireNonNull(fTraceEntry), fTidToEntry, fetchParameters));
207+
return new TmfModelResponse<>(treeModelBuilder.build(), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
204208
}
205209

206210
fModule.waitForInitialization();
@@ -242,7 +246,8 @@ public ThreadStatusDataProvider(@NonNull ITmfTrace trace, TmfStateSystemAnalysis
242246
}
243247

244248
// update the trace Entry.
245-
TimeGraphEntryModel traceEntry = new TimeGraphEntryModel(fTraceId, -1, getTrace().getName(), ss.getStartTime(), end);
249+
List<@NonNull String> labels = ImmutableList.of(NonNullUtils.nullToEmptyString(getTrace().getName()), "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
250+
TimeGraphEntryModel traceEntry = new TimeGraphEntryModel(fTraceId, -1, labels, ss.getStartTime(), end);
246251
fTraceEntry = traceEntry;
247252

248253
for (Integer threadQuark : ss.getQuarks(Attributes.THREADS, WILDCARD)) {
@@ -276,13 +281,17 @@ public ThreadStatusDataProvider(@NonNull ITmfTrace trace, TmfStateSystemAnalysis
276281
fEntryMetadata.put(model.getId(), model.getMetadata());
277282
}
278283

284+
TmfTreeModel.Builder<@NonNull TimeGraphEntryModel> treeModelBuilder = new TmfTreeModel.Builder();
285+
treeModelBuilder.setColumnDescriptors(ThreadEntryModel.getColumnDescriptors());
286+
treeModelBuilder.setEntries(list);
287+
TmfTreeModel<@NonNull TimeGraphEntryModel> returnModel = treeModelBuilder.build();
279288
if (complete) {
280289
fBuildMap.clear();
281290
fLastEnd = Long.MAX_VALUE;
282-
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
291+
return new TmfModelResponse<>(returnModel, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
283292
}
284293

285-
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
294+
return new TmfModelResponse<>(returnModel, ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
286295
}
287296
}
288297

@@ -305,7 +314,7 @@ private void updateEntry(Integer threadQuark, Pair<Integer, Integer> entryKey,
305314

306315
if (entry == null) {
307316
long id = fAtomicLong.getAndIncrement();
308-
entry = new ThreadEntryModel.Builder(id, Collections.singletonList(execName), startTime, endTime, threadId, ppid, pid);
317+
entry = new ThreadEntryModel.Builder(id, execName, startTime, endTime, threadId, ppid, pid);
309318
fQuarkMap.put(id, threadQuark);
310319
} else {
311320
/*
@@ -314,7 +323,7 @@ private void updateEntry(Integer threadQuark, Pair<Integer, Integer> entryKey,
314323
*/
315324
entry.setEndTime(endTime);
316325
entry.setPpid(ppid);
317-
entry.setName(Collections.singletonList(execName));
326+
entry.setName(execName);
318327
}
319328
fBuildMap.put(entryKey, entry);
320329
fTidToEntry.put(threadId, entry);

0 commit comments

Comments
 (0)