Fix some null warnings
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core / src / org / eclipse / tracecompass / internal / lttng2 / kernel / core / analysis / graph / handlers / TraceEventHandlerStatedump.java
1 /*******************************************************************************
2 * Copyright (c) 2015 É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
10 package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.handlers;
11
12 import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
13
14 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
15 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
16 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecGraphProvider;
17 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecGraphProvider.ProcessStatus;
18 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model.EventField;
19 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model.LttngSystemModel;
20 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model.LttngWorker;
21 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
22
23 /**
24 * Handles the LTTng statedump events necessary for the initialization of the
25 * system model
26 *
27 * @author Francis Giraldeau
28 */
29 public class TraceEventHandlerStatedump extends BaseHandler {
30
31 /**
32 * Constructor
33 *
34 * @param provider
35 * The parent graph provider
36 */
37 public TraceEventHandlerStatedump(LttngKernelExecGraphProvider provider) {
38 super(provider);
39 }
40
41 @Override
42 public void handleEvent(ITmfEvent event) {
43 IKernelAnalysisEventLayout eventLayout = getProvider().getEventLayout(event.getTrace());
44 LttngSystemModel system = getProvider().getSystem();
45 String eventName = event.getName();
46 if (!eventName.equals(eventLayout.eventStatedumpProcessState())) {
47 return;
48 }
49
50 Integer tid = EventField.getInt(event, eventLayout.fieldTid());
51 String name = EventField.getOrDefault(event, eventLayout.fieldName(), nullToEmptyString(Messages.TraceEventHandlerSched_UnknownThreadName));
52 Integer status = EventField.getInt(event, eventLayout.fieldStatus());
53
54 String host = event.getTrace().getHostId();
55 long ts = event.getTimestamp().getValue();
56
57 HostThread ht = new HostThread(host, tid);
58 LttngWorker task = system.findWorker(ht);
59 if (task == null) {
60 task = new LttngWorker(ht, name, ts);
61 system.addWorker(task);
62 } else {
63 task.setName(name);
64 }
65
66 task.setStatus(ProcessStatus.getStatus(status));
67 }
68
69 }
This page took 0.031446 seconds and 5 git commands to generate.