os.linux: Create PPID and SYSTEM_CALL attributes on demand
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / kernel / KernelStateProvider.java
index 93e8e6478f3b16101b9033a6f384488081fa9e54..4d2d1a192becf7766b18ecb3d9f3f15fcab16d1a 100644 (file)
@@ -17,6 +17,9 @@ import java.util.Map;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.IPIEntryHandler;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.IPIExitHandler;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.IrqEntryHandler;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.IrqExitHandler;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.KernelEventHandler;
@@ -43,10 +46,8 @@ import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import com.google.common.collect.ImmutableMap;
 
 /**
- * This is the state change input plugin for TMF's state system which handles
- * the LTTng 2.0 kernel traces in CTF format.
- *
- * It uses the reference handler defined in CTFKernelHandler.java.
+ * This is the state change input plugin for the state system which handles the
+ * kernel traces.
  *
  * @author Alexandre Montplaisir
  */
@@ -60,7 +61,7 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
      * Version number of this state provider. Please bump this if you modify the
      * contents of the generated state history in some way.
      */
-    private static final int VERSION = 10;
+    private static final int VERSION = 21;
 
     // ------------------------------------------------------------------------
     // Fields
@@ -111,6 +112,12 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
         builder.put(layout.eventSchedProcessFork(), new ProcessForkHandler(layout));
         builder.put(layout.eventSchedProcessExit(), new ProcessExitHandler(layout));
         builder.put(layout.eventSchedProcessFree(), new ProcessFreeHandler(layout));
+        for( String s : layout.getIPIIrqVectorsEntries()) {
+            builder.put(s, new IPIEntryHandler(layout));
+        }
+        for( String s : layout.getIPIIrqVectorsExits()) {
+            builder.put(s, new IPIExitHandler(layout));
+        }
 
         final String eventStatedumpProcessState = layout.eventStatedumpProcessState();
         if (eventStatedumpProcessState != null) {
@@ -121,7 +128,7 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
             builder.put(eventSchedWakeup, new SchedWakeupHandler(layout));
         }
 
-        return NonNullUtils.checkNotNull(builder.build());
+        return builder.build();
     }
 
     // ------------------------------------------------------------------------
@@ -133,12 +140,6 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
         return VERSION;
     }
 
-    @Override
-    public void assignTargetStateSystem(ITmfStateSystemBuilder ssb) {
-        /* We can only set up the locations once the state system is assigned */
-        super.assignTargetStateSystem(ssb);
-    }
-
     @Override
     public KernelStateProvider getNewInstance() {
         return new KernelStateProvider(this.getTrace(), fLayout);
@@ -160,10 +161,9 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
              */
             KernelEventHandler handler = fEventNames.get(eventName);
             if (handler == null) {
-                if (eventName.startsWith(fLayout.eventSyscallExitPrefix())) {
+                if (isSyscallExit(eventName)) {
                     handler = fSysExitHandler;
-                } else if (eventName.startsWith(fLayout.eventSyscallEntryPrefix())
-                        || eventName.startsWith(fLayout.eventCompatSyscallEntryPrefix())) {
+                } else if (isSyscallEntry(eventName)) {
                     handler = fSysEntryHandler;
                 }
             }
@@ -176,24 +176,33 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
              * This would indicate a problem with the logic of the manager here,
              * so it shouldn't happen.
              */
-            ae.printStackTrace();
+            Activator.getDefault().logError("Attribute not found: " + ae.getMessage(), ae); //$NON-NLS-1$
 
         } catch (TimeRangeException tre) {
             /*
              * This would happen if the events in the trace aren't ordered
              * chronologically, which should never be the case ...
              */
-            System.err.println("TimeRangeExcpetion caught in the state system's event manager."); //$NON-NLS-1$
-            System.err.println("Are the events in the trace correctly ordered?"); //$NON-NLS-1$
-            tre.printStackTrace();
+            Activator.getDefault().logError("TimeRangeExcpetion caught in the state system's event manager.\n" + //$NON-NLS-1$
+                    "Are the events in the trace correctly ordered?\n" + tre.getMessage(), tre); //$NON-NLS-1$
 
         } catch (StateValueTypeException sve) {
             /*
              * This would happen if we were trying to push/pop attributes not of
              * type integer. Which, once again, should never happen.
              */
-            sve.printStackTrace();
+            Activator.getDefault().logError("State value error: " + sve.getMessage(), sve); //$NON-NLS-1$
         }
     }
 
+    private boolean isSyscallEntry(String eventName) {
+        return (eventName.startsWith(fLayout.eventSyscallEntryPrefix())
+                || eventName.startsWith(fLayout.eventCompatSyscallEntryPrefix()));
+    }
+
+    private boolean isSyscallExit(String eventName) {
+        return (eventName.startsWith(fLayout.eventSyscallExitPrefix()) ||
+                eventName.startsWith(fLayout.eventCompatSyscallExitPrefix()));
+    }
+
 }
This page took 0.028917 seconds and 5 git commands to generate.