Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / controlflow / evProcessor / FlowAfterUpdateHandlers.java
index 0f7c18baf8213c4a35605f468c393cd22fb8a155..644352f29bca460704dbf50860ed0c8e7b2bd03a 100644 (file)
@@ -8,17 +8,18 @@
  * 
  * Contributors:
  *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *   Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
  *******************************************************************************/
 package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor;
 
-import org.eclipse.linuxtools.lttng.event.LttngEvent;
-import org.eclipse.linuxtools.lttng.state.StateStrings.Fields;
-import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor;
-import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
-import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.lttng.core.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.core.state.StateStrings.Fields;
+import org.eclipse.linuxtools.lttng.core.state.evProcessor.ILttngEventProcessor;
+import org.eclipse.linuxtools.lttng.core.state.model.LttngProcessState;
+import org.eclipse.linuxtools.lttng.core.state.model.LttngTraceState;
 import org.eclipse.linuxtools.lttng.ui.TraceDebug;
 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 
 /**
  * Creates instances of specific after state update handlers, per corresponding
@@ -43,6 +44,7 @@ class FlowAfterUpdateHandlers {
                AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() {
 
                        // @Override
+                       @Override
                        public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
                                
                                // get event time, cpu, trace_number, process, pid
@@ -53,11 +55,12 @@ class FlowAfterUpdateHandlers {
                                Long pid_in = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_NEXT_PID);
                                
                                if ( !(pid_in.equals(process_in.getPid())) ) {
-                                   TraceDebug.debug("pid_in != PID!  (getSchedChangeHandler)");
+                                   TraceDebug.debug("pid_in != PID!  (getSchedChangeHandler)"); //$NON-NLS-1$
                 }
                                
                                //hashed_process_data = processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num);
-                               TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(),process_in.getCreation_time() );
+                               TimeRangeEventProcess localProcess = procContainer.findProcess(pid_in, process_in.getCpu(), traceSt
+                                               .getTraceId(), process_in.getCreation_time());
                                
                                if ( localProcess == null ) {
                                        if ( (pid_in == 0) || (pid_in != process_in.getPpid()) ) {
@@ -66,7 +69,7 @@ class FlowAfterUpdateHandlers {
                                        }
                                        else {
                                                TraceDebug
-                                                               .debug("pid_in is not 0 or pid_in == PPID!  (getSchedChangeHandler)");
+                                                               .debug("pid_in is not 0 or pid_in == PPID!  (getSchedChangeHandler)"); //$NON-NLS-1$
                                        }
                                }
 
@@ -123,6 +126,7 @@ class FlowAfterUpdateHandlers {
            AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() {
 
                        // @Override
+                       @Override
                        public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {  
                            
                 Long child_pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_CHILD_PID);
@@ -137,7 +141,7 @@ class FlowAfterUpdateHandlers {
                             localProcess = addLocalProcess(process_child, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId());
                                    }
                                    else {
-                                       TraceDebug.debug("localProcess is null with child_pid not 0 or child_pid equals PPID (getProcessForkHandler)");
+                                       TraceDebug.debug("localProcess is null with child_pid not 0 or child_pid equals PPID (getProcessForkHandler)"); //$NON-NLS-1$
                                    }
                                        } else {
                                                // If we found the process, the Ppid and the Tgid might
@@ -147,7 +151,7 @@ class FlowAfterUpdateHandlers {
                                }
                            }
                            else {
-                               TraceDebug.debug("process_child is null! (getProcessForkHandler)");
+                               TraceDebug.debug("process_child is null! (getProcessForkHandler)"); //$NON-NLS-1$
                            }
                      
                                return false;
@@ -168,6 +172,7 @@ class FlowAfterUpdateHandlers {
            AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() {
 
                        // @Override
+                       @Override
                        public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
                            
                            LttngProcessState process = traceSt.getRunning_process().get(trcEvent.getCpuId());
@@ -189,12 +194,12 @@ class FlowAfterUpdateHandlers {
                                    localProcess = addLocalProcess(process, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId());
                                    }
                                    else {
-                                       TraceDebug.debug("process pid is not 0 or pid equals ppid! (getProcessExitHandler)");
+                                       TraceDebug.debug("process pid is not 0 or pid equals ppid! (getProcessExitHandler)"); //$NON-NLS-1$
                                    }
                                        }
                            }
                            else {
-                               TraceDebug.debug("process is null! (getProcessExitHandler)");
+                               TraceDebug.debug("process is null! (getProcessExitHandler)"); //$NON-NLS-1$
                            }                       
                            
                                return false;
@@ -216,6 +221,7 @@ class FlowAfterUpdateHandlers {
            AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() {
 
                        // @Override
+                       @Override
                        public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
                            
                            LttngProcessState process = traceSt.getRunning_process().get(trcEvent.getCpuId());
@@ -230,7 +236,7 @@ class FlowAfterUpdateHandlers {
                             localProcess = addLocalProcess(process, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId());
                         }
                         else {
-                            TraceDebug.debug("process pid is not 0 or pid equals ppid! (getProcessExecHandler)");
+                            TraceDebug.debug("process pid is not 0 or pid equals ppid! (getProcessExecHandler)"); //$NON-NLS-1$
                         }
                     }
                     else {
@@ -239,7 +245,7 @@ class FlowAfterUpdateHandlers {
                     }
                 }
                 else {
-                    TraceDebug.debug("process is null! (getProcessExecHandler)");
+                    TraceDebug.debug("process is null! (getProcessExecHandler)"); //$NON-NLS-1$
                 }
                 
                                return false;
@@ -260,6 +266,7 @@ class FlowAfterUpdateHandlers {
            AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() {
 
                        // @Override
+                       @Override
                        public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
                            
                            LttngProcessState process = traceSt.getRunning_process().get(trcEvent.getCpuId());
@@ -279,7 +286,7 @@ class FlowAfterUpdateHandlers {
                             localProcess = addLocalProcess(process, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId());
                         }
                         else {
-                            TraceDebug.debug("process pid is not 0 or pid equals ppid! (GetThreadBrandHandler)");
+                            TraceDebug.debug("process pid is not 0 or pid equals ppid! (GetThreadBrandHandler)"); //$NON-NLS-1$
                         }
                     }
                     else {
@@ -289,7 +296,7 @@ class FlowAfterUpdateHandlers {
                     }
                 }
                 else {
-                    TraceDebug.debug("process is null! (GetThreadBrandHandler)");
+                    TraceDebug.debug("process is null! (GetThreadBrandHandler)"); //$NON-NLS-1$
                 }
                 
                 return false;
@@ -320,6 +327,7 @@ class FlowAfterUpdateHandlers {
            AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() {
 
                        // @Override
+                       @Override
                        public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
                            
                                int first_cpu;
@@ -328,8 +336,6 @@ class FlowAfterUpdateHandlers {
                                Long pid_in = getAFieldLong(trcEvent, traceSt,
                                                Fields.LTT_FIELD_PID);
                            
-                // Lttv assume that pid_in will NEVER be null or incoherent
-                // What if ... ?    (let's add some debug)
                            if ( pid_in != null  ) {
                            if(pid_in == 0L) {
                                                first_cpu = 0;
@@ -341,7 +347,7 @@ class FlowAfterUpdateHandlers {
                            }
                            
                                        for (int cpu = first_cpu; cpu < nb_cpus; cpu++) {
-                               LttngProcessState process_in = lttv_state_find_process(traceSt, trcEvent.getCpuId(), pid_in );
+                                               LttngProcessState process_in = lttv_state_find_process(traceSt, Long.valueOf(cpu), pid_in);
                                
                                if ( process_in != null ) {
                                    TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(), process_in.getCreation_time());
@@ -352,23 +358,23 @@ class FlowAfterUpdateHandlers {
                                     localProcess = addLocalProcess(process_in, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId());
                                 }
                                 else {
-                                    TraceDebug.debug("process pid is not 0 or pid equals ppid! (getEnumProcessStateHandler)");
+                                    TraceDebug.debug("process pid is not 0 or pid equals ppid! (getEnumProcessStateHandler)"); //$NON-NLS-1$
                                 }
                                    }
-                                   else {
-                                       // If the process was found, it might be missing informations, add it here
-                                       localProcess.setName(process_in.getName());
-                                       localProcess.setPpid(process_in.getPpid());
-                                       localProcess.setTgid(process_in.getTgid());
-                                   }
+
+                                                       // If the process was found, it might be missing
+                                                       // informations, add it here
+                                                       localProcess.setName(process_in.getName());
+                                                       localProcess.setPpid(process_in.getPpid());
+                                                       localProcess.setTgid(process_in.getTgid());
                                }
                                else {
-                                   TraceDebug.debug("process_in is null! This should never happen. (getEnumProcessStateHandler)");
+                                   TraceDebug.debug("process_in is null! This should never happen. (getEnumProcessStateHandler)"); //$NON-NLS-1$
                                }
                            }
                            }
                            else {
-                               TraceDebug.debug("pid_in is null! This should never happen, really... (getEnumProcessStateHandler)");
+                               TraceDebug.debug("pid_in is null! This should never happen, really... (getEnumProcessStateHandler)"); //$NON-NLS-1$
                            }
                            
                                return false;
This page took 0.028315 seconds and 5 git commands to generate.