Add null checks for methods missing them
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core / src / org / eclipse / tracecompass / internal / lttng2 / kernel / core / analysis / vm / module / VirtualMachineStateProvider.java
index a39b71ca9b5d48c45ef44fa2d2615dd08b047c18..706f44ae87ad9c13a605f767c228b377b9edc64a 100644 (file)
@@ -210,14 +210,21 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider {
              * prev_state, string next_comm, int32 next_tid, int32 next_prio
              */
             {
-                int prevTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldPrevTid()).getValue()).intValue();
-                int nextTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldNextTid()).getValue()).intValue();
+                final IKernelAnalysisEventLayout eventLayout = fLayouts.get(event.getTrace());
+                if (eventLayout == null) {
+                    return;
+                }
+                int prevTid = ((Long) content.getField(eventLayout.fieldPrevTid()).getValue()).intValue();
+                int nextTid = ((Long) content.getField(eventLayout.fieldNextTid()).getValue()).intValue();
 
                 if (host.isGuest()) {
                     /* Get the event's CPU */
                     Object cpuObj = TmfTraceUtils.resolveEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event);
                     if (cpuObj == null) {
-                        /* We couldn't find any CPU information, ignore this event */
+                        /*
+                         * We couldn't find any CPU information, ignore this
+                         * event
+                         */
                         break;
                     }
                     Integer cpu = (Integer) cpuObj;
@@ -253,9 +260,11 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider {
 
                     /* Add the preempted flag to the status */
                     value = ss.queryOngoingState(curStatusQuark);
-                    int newVal = Math.max(VcpuStateValues.VCPU_UNKNOWN, value.unboxInt());
-                    value = TmfStateValue.newValueInt(newVal | VcpuStateValues.VCPU_PREEMPT);
-                    ss.modifyAttribute(ts, value, curStatusQuark);
+                    if ((value.unboxInt() & VcpuStateValues.VCPU_IDLE) == 0) {
+                        int newVal = Math.max(VcpuStateValues.VCPU_UNKNOWN, value.unboxInt());
+                        value = TmfStateValue.newValueInt(newVal | VcpuStateValues.VCPU_PREEMPT);
+                        ss.modifyAttribute(ts, value, curStatusQuark);
+                    }
                 }
 
                 /* Verify if the next thread corresponds to a virtual CPU */
@@ -301,9 +310,11 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider {
                     int curStatusQuark = ss.getQuarkRelativeAndAdd(getNodeVirtualMachines(), vm.getHostId(),
                             Long.toString(virtualCpu.getCpuId()), VmAttributes.STATUS);
                     value = ss.queryOngoingState(curStatusQuark);
-                    int newVal = Math.max(VcpuStateValues.VCPU_UNKNOWN, value.unboxInt());
-                    value = TmfStateValue.newValueInt(newVal | VcpuStateValues.VCPU_VMM);
-                    ss.modifyAttribute(ts, value, curStatusQuark);
+                    if ((value.unboxInt() & VcpuStateValues.VCPU_IDLE) == 0) {
+                        int newVal = Math.max(VcpuStateValues.VCPU_UNKNOWN, value.unboxInt());
+                        value = TmfStateValue.newValueInt(newVal | VcpuStateValues.VCPU_VMM);
+                        ss.modifyAttribute(ts, value, curStatusQuark);
+                    }
                 }
 
                 /*
This page took 0.059638 seconds and 5 git commands to generate.