Bundle-Version: 0.0.1
Bundle-Vendor: Eclipse
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.junit4;bundle-version="4.5.0",
+ org.eclipse.linuxtools.lttng;bundle-version="0.0.1",
+ org.eclipse.linuxtools.tmf;bundle-version="0.0.1"
--- /dev/null
+package org.eclipse.linuxtools.lttng;
+
+public class ActivateDebugging {
+
+ public static void activate() {
+ TraceDebug.DEBUG = true;
+ }
+
+ public static void deactivate() {
+ TraceDebug.DEBUG = false;
+ }
+}
--- /dev/null
+
+package org.eclipse.linuxtools.lttng.jni;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TraceTest.class,
+ TracefileTest.class,
+ EventTest.class,
+ MarkerTest.class,
+ MarkerFieldTest.class
+})
+
+public class AllJniTests {
+
+}
--- /dev/null
+/**
+ *
+ */
+package org.eclipse.linuxtools.lttng.jni;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+
+/**
+ * @author alvaro
+ *
+ */
+public class Combinations {
+
+ private final static String tracepath="traceset/trace_617984ev_withlost";
+ private final static String eventName = "syscall_state";
+
+ private final static Integer expect_syscall_entry = 195596;
+ private final static Integer expect_syscall_exit = 195598;
+ private final static Integer expect_core_marker_format = 177;
+ private final static Integer expect_core_marker_id = 177;
+
+ // private static final String LTT_EVENT_SYSCALL_ENTRY = "syscall_entry";
+ // private static final String LTT_EVENT_SYSCALL_EXIT = "syscall_exit";
+ // private static final String LTT_EVENT_TRAP_ENTRY = "trap_entry";
+ // private static final String LTT_EVENT_TRAP_EXIT = "trap_exit";
+ // private static final String LTT_EVENT_PAGE_FAULT_ENTRY =
+ // "page_fault_entry";
+ // private static final String LTT_EVENT_PAGE_FAULT_EXIT =
+ // "page_fault_exit";
+ // private static final String LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY =
+ // "page_fault_nosem_entry";
+ // private static final String LTT_EVENT_PAGE_FAULT_NOSEM_EXIT =
+ // "page_fault_nosem_exit";
+ // private static final String LTT_EVENT_IRQ_ENTRY = "irq_entry";
+ // private static final String LTT_EVENT_IRQ_EXIT = "irq_exit";
+ // private static final String LTT_EVENT_SOFT_IRQ_RAISE = "softirq_raise";
+ // private static final String LTT_EVENT_SOFT_IRQ_ENTRY = "softirq_entry";
+ // private static final String LTT_EVENT_SOFT_IRQ_EXIT = "softirq_exit";
+ // private static final String LTT_EVENT_SCHED_SCHEDULE = "sched_schedule";
+ // private static final String LTT_EVENT_PROCESS_FORK = "process_fork";
+ // private static final String LTT_EVENT_KTHREAD_CREATE = "kthread_create";
+ // private static final String LTT_EVENT_PROCESS_EXIT = "process_exit";
+ // private static final String LTT_EVENT_PROCESS_FREE = "process_free";
+ // private static final String LTT_EVENT_EXEC = "exec";
+ // private static final String LTT_EVENT_PROCESS_STATE = "process_state";
+ // private static final String LTT_EVENT_STATEDUMP_END = "statedump_end";
+ // private static final String LTT_EVENT_FUNCTION_ENTRY = "function_entry";
+ // private static final String LTT_EVENT_FUNCTION_EXIT = "function_exit";
+ // private static final String LTT_EVENT_THREAD_BRAND = "thread_brand";
+ // private static final String LTT_EVENT_REQUEST_ISSUE =
+ // "_blk_request_issue";
+ // private static final String LTT_EVENT_REQUEST_COMPLETE =
+ // "_blk_request_complete";
+ // private static final String LTT_EVENT_LIST_INTERRUPT = "interrupt";
+ // private static final String LTT_EVENT_SYS_CALL_TABLE = "sys_call_table";
+ // private static final String LTT_EVENT_SOFTIRQ_VEC = "softirq_vec";
+ // private static final String LTT_EVENT_KPROBE_TABLE = "kprobe_table";
+ // private static final String LTT_EVENT_KPROBE = "kprobe";
+
+ // enum EventString {
+ // syscall_entry, syscall_exit, trap_entry, trap_exit, page_fault_entry,
+ // page_fault_exit, page_fault_nosem_entry, page_fault_nosem_exit,
+ // irq_entry, irq_exit, softirq_raise, softirq_entry, softirq_exit,
+ // sched_schedule, process_fork, kthread_create, process_exit, process_free,
+ // exec, process_state, statedump_end, function_entry, function_exit,
+ // thread_brand, _blk_request_issue, blk_request_complete, interrupt,
+ // sys_call_table, softirq_vec, kprobe_table, kprobe
+ // };
+
+ enum EvStateTrans {
+ syscall_entry, syscall_exit, trap_entry, trap_exit, page_fault_entry, page_fault_exit, page_fault_nosem_entry, page_fault_nosem_exit, irq_entry, irq_exit, softirq_raise, softirq_entry, softirq_exit, sched_schedule, process_fork, kthread_create, process_exit, process_free, exec, thread_brand
+ };
+
+ private static Set<String> stateSet;
+ static {
+ stateSet = new HashSet<String>();
+ EvStateTrans[] stateArr = EvStateTrans.values();
+ for (EvStateTrans event : stateArr) {
+ stateSet.add(event.name());
+ }
+ }
+
+ private JniEvent prepareEventToTest() {
+
+ JniEvent tmpEvent = null;
+ // This trace should be valid
+ try {
+ tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ } catch (JniException e) {
+ }
+
+ return tmpEvent;
+ }
+
+ @Test
+ public void testGetSpecEventFields() {
+ JniEvent event = prepareEventToTest();
+ JniMarker dmarker = event.requestEventMarker();
+ List<JniMarkerField> markers = dmarker.getMarkerFieldsArrayList();
+
+ assertNotNull(markers);
+ System.out.println("Markers: " + markers);
+
+ }
+
+ @Test
+ public void testEventsLoop() {
+ JniTrace trace = null;
+ JniEvent event = null;
+ try {
+ trace = new JniTrace(tracepath);
+ } catch (JniException e) {
+ e.printStackTrace();
+ }
+
+ HashMap<String, Integer> eventCount = new HashMap<String, Integer>();
+ while (true) {
+ event = trace.readNextEvent();
+ if (event == null) {
+ break;
+ }
+ JniMarker dmarker = event.requestEventMarker();
+ assertNotNull(dmarker);
+
+ String name = dmarker.getName();
+
+ if (eventCount.containsKey(name)) {
+ Integer cnt = eventCount.get(name);
+ eventCount.put(name, cnt + 1);
+ } else {
+ eventCount.put(name, 1);
+ // Only print state transition states and it's format
+ if (stateSet.contains(name)) {
+ System.out.println("\nMarker name: " + name + "\nFields:");
+
+ Object[] tmpMarkerFields = dmarker.getMarkerFieldsArrayList().toArray();
+ String[] fields = new String[tmpMarkerFields.length];
+
+ for (int pos = 0; pos < tmpMarkerFields.length; pos++) {
+ fields[pos] = ((JniMarkerField) tmpMarkerFields[pos]).getField() + ":" + ((JniMarkerField) tmpMarkerFields[pos]).getFormat();
+ }
+
+ for (String field : fields) {
+ System.out.println(field + " ");
+ }
+ }
+ }
+ }
+
+ for (String state : eventCount.keySet()) {
+ System.out.println(state + " : " + eventCount.get(state));
+ }
+
+ assertEquals("syscall_entry mismatch", expect_syscall_entry, eventCount
+ .get(EvStateTrans.syscall_entry.name()));
+ assertEquals("syscall_exit mismatch", expect_syscall_exit, eventCount
+ .get(EvStateTrans.syscall_exit.name()));
+ assertEquals("core_market_format mismatch", expect_core_marker_format,
+ eventCount.get("core_marker_format"));
+ assertEquals("core_market_id mismatch", expect_core_marker_id,
+ eventCount.get("core_marker_id"));
+ }
+
+}
--- /dev/null
+
+/*
+ Functions tested here :
+ public JniEvent(JniEvent oldEvent)
+ public JniEvent(long newEventPtr, long newTracefilePtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JafException
+
+ public int readNextEvent()
+ public int seekToTime(JniTime seekTime)
+ public int seekOrFallBack(JniTime seekTime)
+
+ public JniMarker requestEventMarker()
+ public String requestEventSource()
+ public JniTime requestNextEventTime()
+
+ public ArrayList<ParsedContent> parse()
+
+ public int getEventMarkerId()
+ public JniTime getEventTime()
+ public long getEventDataSize()
+ public HashMap<Integer, JniMarker> getMarkersMap()
+ public long getTracefilePtr()
+ public long getEventPtr()
+ public int getEventState()
+ public JniTracefile getParentTracefile()
+
+ public String toString()
+ public void printEventInformation()
+*/
+
+
+package org.eclipse.linuxtools.lttng.jni;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class EventTest
+{
+ private final static String tracepath="traceset/trace_617984ev_withlost";
+ private final static String eventName="kernel0";
+
+ private final static int numberOfMarkersInTracefile = 46;
+
+ private final static int numberOfparsedFieldsFirstEvent = 1;
+ private final static int numberOfparsedFieldsSecondEvent = 3;
+
+ private final static int chosenPositionOfFieldsFirstEvent = 1;
+ private final static int chosenPositionOfFieldsSecondEvent = 0;
+ private final static int chosenPositionOfFieldsAfterSeekEvent = 0;
+
+ private final static String chosenNameOfFieldsFirstEvent = "string";
+ private final static String chosenNameOfFieldsSecondEvent = "ip";
+ private final static String chosenNameOfFieldsThirdEvent = "ret";
+
+ private final static String contentOfFieldsFirstEvent = "LTT state dump begin";
+ private final static long contentOfFieldsSecondEvent = 3222386054L;
+ private final static long contentOfFieldsThirdEvent = 3L;
+
+ private final static int numberOfByteInContent = 4;
+
+ private final static long firstEventTimestamp = 952090116049L;
+ private final static long secondEventTimestamp = 952092222957L;
+ private final static long thirdEventTimestamp = 952102730748L;
+
+ private final static long timestampToSeekTest1 = 953852206193L;
+ private final static long timestampAfterSeekTest1 = 953852212349L;
+
+ private final static long timestampToSeekLast = 960386638531L;
+
+ private final static long timestampToSeekTooFarAway = Long.MAX_VALUE;
+
+ private JniEvent prepareEventToTest() {
+
+ JniEvent tmpEvent = null;
+
+ // This trace should be valid
+ try {
+ tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ }
+ catch( JniException e) { }
+
+ return tmpEvent;
+ }
+
+
+ @Test
+ public void testEventConstructors() {
+ JniTracefile testTracefile = null;
+
+ JniEvent testEvent1 = null;
+ JniEvent testEvent2 = null;
+
+ // This trace should be valid and will be used in test
+ try {
+ testTracefile = new JniTrace(tracepath).requestTracefileByName(eventName);
+ }
+ catch( JniException e) { }
+
+
+ // Test the constructor with parameters using wrong arguments
+ // Test constructor on a wrong event pointer
+ try {
+ testEvent1 = new JniEvent( new C_Pointer(0), testTracefile.getTracefileMarkersMap(), testTracefile );
+ fail("Construction with wrong event pointer should fail!");
+ }
+ catch( JniException e) {
+ }
+
+ // Test constructor on a wrong marker HashMap
+ try {
+ testEvent1 = new JniEvent( testTracefile.getCurrentEvent().getEventPtr(), null, testTracefile );
+ fail("Construction with wrong marker hashmap should fail!");
+ }
+ catch( JniException e) {
+ }
+
+ // Test constructor on a wrong tracefile reference
+ try {
+ testEvent1 = new JniEvent( testTracefile.getCurrentEvent().getEventPtr(), testTracefile.getTracefileMarkersMap(), null );
+ fail("Construction with wrong tracefile reference should fail!");
+ }
+ catch( JniException e) {
+ }
+
+
+ // Finally, test constructor with correct information
+ try {
+ testEvent1 = new JniEvent( testTracefile.getCurrentEvent().getEventPtr(), testTracefile.getTracefileMarkersMap(), testTracefile );
+
+ }
+ catch( JniException e) {
+ fail("Construction with correct information failed!");
+ }
+
+
+ // Test copy constructor
+ try {
+ testEvent1 = new JniEvent( testTracefile.getCurrentEvent() );
+ testEvent2 = new JniEvent( testEvent1);
+ }
+ catch( Exception e) {
+ fail("Copy constructor failed!");
+ }
+
+ assertEquals("JniEvent timestamp not same after using copy constructor", testEvent1.getEventTime().getTime() , testEvent2.getEventTime().getTime() );
+
+ }
+
+ @Test
+ public void testPrintAndToString() {
+
+ JniEvent testEvent = prepareEventToTest();
+
+ // Test printEventInformation
+ try {
+ testEvent.printEventInformation();
+ }
+ catch( Exception e) {
+ fail("printEventInformation failed!");
+ }
+
+ // Test ToString()
+ assertNotSame("toString returned empty data","",testEvent.toString() );
+
+ }
+
+ @Test
+ public void testEventDisplacement() {
+
+ int readValue = -1;
+ int seekValue = -1;
+ JniEvent testEvent = prepareEventToTest();
+
+ // Test #1 readNextEvent()
+ readValue = testEvent.readNextEvent();
+ assertSame("readNextEvent() returned error (test #1)",0,readValue);
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",secondEventTimestamp,testEvent.getEventTime().getTime() );
+
+ // Test #2 readNextEvent()
+ readValue = testEvent.readNextEvent();
+ assertSame("readNextEvent() returned error (test #1)",0,readValue);
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",thirdEventTimestamp,testEvent.getEventTime().getTime() );
+
+
+ // Test #1 of seekToTime()
+ seekValue = testEvent.seekToTime(new JniTime(timestampToSeekTest1) );
+ assertSame("seekToTime() returned error (test #1)",0,seekValue);
+ // Read SHOULD NOT be performed after a seek!
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",timestampToSeekTest1,testEvent.getEventTime().getTime() );
+
+ readValue = testEvent.readNextEvent();
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",timestampAfterSeekTest1,testEvent.getEventTime().getTime() );
+
+
+ // Test #2 of seekToTime()
+ seekValue = testEvent.seekToTime(new JniTime(timestampToSeekLast) );
+ assertSame("seekToTime() returned error (test #2)",0,seekValue);
+ // Read SHOULD NOT be performed after a seek!
+ assertEquals("readNextEvent() event timestamp is incoherent (test #2)",timestampToSeekLast,testEvent.getEventTime().getTime() );
+
+ // Read AFTER the last event should bring an error
+ readValue = testEvent.readNextEvent();
+ assertNotSame("readNextEvent() AFTER last event should return error (test #2)",0,readValue);
+
+
+ // Test to see if we can seek back
+ seekValue = testEvent.seekToTime(new JniTime(firstEventTimestamp) );
+ assertSame("seekToTime() returned error (test seek back)",0,seekValue);
+ // Read SHOULD NOT be performed after a seek!
+ assertEquals("readNextEvent() event timestamp is incoherent (test seek back)",firstEventTimestamp,testEvent.getEventTime().getTime() );
+
+
+ // Test #1 of seekOrFallBack() (seek within range)
+ seekValue = testEvent.seekOrFallBack(new JniTime(timestampToSeekTest1) );
+ assertSame("seekToTime() returned error (test #1)",0,seekValue);
+ // Read SHOULD NOT be performed after a seek!
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",timestampToSeekTest1,testEvent.getEventTime().getTime() );
+
+ // Test #2 of seekOrFallBack() (seek out of range, should fall back)
+ seekValue = testEvent.seekOrFallBack(new JniTime(timestampToSeekTooFarAway) );
+ assertNotSame("seekOrFallBack() should return an error (test #2)",0,seekValue);
+ // The read should return the "last" value as we seek back
+ assertEquals("readNextEvent() event timestamp is incoherent (test #2)",timestampToSeekTest1,testEvent.getEventTime().getTime() );
+ }
+
+ @Test
+ public void testGetSet() {
+
+ JniEvent testEvent = prepareEventToTest();
+
+ // Test that all Get/Set return data
+ assertNotSame("getEventMarkerId is 0",0,testEvent.getEventMarkerId() );
+
+ // JniTime should never be null
+ assertNotNull("getEventTime returned null", testEvent.getEventTime() );
+
+ assertNotSame("getEventDataSize is 0",0,testEvent.getEventDataSize() );
+
+ // Test that the marker map is not null
+ assertNotSame("getMarkersMap is null",null,testEvent.getMarkersMap() );
+ // Also check that the map contain some data
+ assertSame("getMarkersMap returned an unexpected number of markers",numberOfMarkersInTracefile,testEvent.getMarkersMap().size() );
+
+ assertNotSame("getTracefilePtr is 0",0,testEvent.getTracefilePtr() );
+ assertNotSame("getEventPtr is 0",0,testEvent.getEventPtr() );
+ // State 0 (EOK) means the event is in a sane state
+ assertSame("getEventState is not EOK",0,testEvent.getEventState() );
+
+ // ParentTracefile should never be null
+ assertNotNull("getParentTracefile returned null", testEvent.getParentTracefile() );
+ }
+
+ @Test
+ public void testRequestFunctions() {
+
+ JniEvent testEvent = prepareEventToTest();
+
+ // Test requestEventMarker(). Should return an unique marker
+ assertNotNull("requestEventMarker returned null",testEvent.requestEventMarker() );
+
+ // Test requestEventSource()
+ assertNotSame("requestEventSource is empty","",testEvent.requestEventSource() );
+
+ // Test requestEventContent()
+ assertNotNull("requestEventContent returned null",testEvent.requestEventContent() );
+
+ // Also check that the byte array contain some data
+ assertSame("requestEventContent returned an unexpected number of markers",numberOfByteInContent,testEvent.requestEventContent().length );
+
+ }
+
+ @Test
+ public void testParseAllFieldsFunctions() {
+
+ JniEvent testEvent = prepareEventToTest();
+
+ // Test parse()
+ assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
+ // Parse shouldn't be empty
+ assertSame("parseAllFields returned an unexpected number of parsed fields",numberOfparsedFieldsFirstEvent,testEvent.parseAllFields().size() );
+
+ // MORE PARSING TESTS
+ // We will perform several more unit tests about parsing as it is very important
+ // All those below use the same call as in the displacement test
+ // Test #1 readNextEvent()
+ testEvent.readNextEvent();
+ assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
+ assertSame("parseAllFields returned an unexpected number of parsed fields",numberOfparsedFieldsSecondEvent,testEvent.parseAllFields().size() );
+ // Test #2 readNextEvent()
+ testEvent.readNextEvent();
+ assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
+
+ // Test #1 of seekToTime()
+ testEvent.seekToTime(new JniTime(timestampToSeekTest1) );
+ // Read need to be perform after a seek!
+ testEvent.readNextEvent();
+ assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
+ testEvent.readNextEvent();
+ assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
+
+ // Test #2 of seekToTime()
+ testEvent.seekToTime(new JniTime(timestampToSeekLast) );
+ // Read need to be perform after a seek!
+ testEvent.readNextEvent();
+ assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
+
+ // Test to see if we can seek back
+ testEvent.seekToTime(new JniTime(firstEventTimestamp) );
+ // Read need to be perform after a seek!
+ testEvent.readNextEvent();
+ assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
+ }
+
+ @Test
+ public void testParseFieldByIdFunctions() {
+ JniEvent testEvent = prepareEventToTest();
+
+ // Test parse()
+ assertNotNull("parseFieldById returned null",testEvent.parseFieldById(0) );
+
+ testEvent.readNextEvent();
+ assertNotNull("parseFieldById returned null",testEvent.parseFieldById(chosenPositionOfFieldsFirstEvent) );
+ assertEquals("Content return by parseFieldById is invalid",contentOfFieldsFirstEvent, testEvent.parseFieldById(chosenPositionOfFieldsFirstEvent) );
+ assertEquals("Content return by parseFieldByName is invalid",contentOfFieldsFirstEvent, testEvent.parseFieldByName(chosenNameOfFieldsFirstEvent) );
+
+ // MORE PARSING TESTS
+ // We will perform several more unit tests about parsing as it is very important
+ // All those below use the same call as in the displacement test
+ // Test #1 readNextEvent()
+ testEvent.readNextEvent();
+ assertNotNull("parseFieldById returned null",testEvent.parseFieldById(chosenPositionOfFieldsSecondEvent) );
+ assertEquals("Content return by parseFieldById is invalid",contentOfFieldsSecondEvent, testEvent.parseFieldById(chosenPositionOfFieldsSecondEvent) );
+ assertEquals("Content return by parseFieldByName is invalid",contentOfFieldsSecondEvent, testEvent.parseFieldByName(chosenNameOfFieldsSecondEvent) );
+
+
+ // Test #1 of seekToTime()
+ testEvent.seekToTime(new JniTime(timestampToSeekTest1) );
+ // Read need to be perform after a seek!
+ testEvent.readNextEvent();
+ assertNotNull("parseFieldById returned null",testEvent.parseFieldById(chosenPositionOfFieldsAfterSeekEvent) );
+ assertEquals("Content return by parseFieldById is invalid",contentOfFieldsThirdEvent, testEvent.parseFieldById(chosenPositionOfFieldsAfterSeekEvent) );
+ assertEquals("Content return by parseFieldByName is invalid",contentOfFieldsThirdEvent, testEvent.parseFieldByName(chosenNameOfFieldsThirdEvent) );
+
+ // Test to see if we can seek back
+ testEvent.seekToTime(new JniTime(firstEventTimestamp) );
+ // Read need to be perform after a seek!
+ testEvent.readNextEvent();
+ assertNotNull("parseFieldById returned null",testEvent.parseFieldById(chosenPositionOfFieldsFirstEvent) );
+ assertEquals("Content return by parseFieldById is invalid",contentOfFieldsFirstEvent, testEvent.parseFieldById(chosenPositionOfFieldsFirstEvent) );
+ assertEquals("Content return by parseFieldByName is invalid",contentOfFieldsFirstEvent, testEvent.parseFieldByName(chosenNameOfFieldsFirstEvent) );
+ }
+}
--- /dev/null
+
+package org.eclipse.linuxtools.lttng.jni;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/*
+ Functions tested here :
+ public JniMarkerField(JniMarkerField oldMarkerField)
+ public JniMarkerField(long newMarkerPtr) throws JniException
+
+ public String getField()
+ public String getFormat()
+
+ public String toString()
+ public void printMarkerFieldInformation()
+*/
+
+public class MarkerFieldTest
+{
+ private final static String tracepath="traceset/trace_617984ev_withlost";
+ private final static String eventName="kernel0";
+
+ private JniMarkerField prepareMarkerFieldToTest() {
+
+ JniEvent tmpEvent = null;
+ JniMarkerField tmpMarkerField = null;
+
+ // This trace should be valid
+ // We will read the first 2 event to have something interesting to test on
+ try {
+ tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ tmpEvent.readNextEvent();
+ tmpEvent.readNextEvent();
+
+ // Use the first field
+ tmpMarkerField = tmpEvent.requestEventMarker().getMarkerFieldsArrayList().get(0);
+ }
+ catch( JniException e) { }
+
+ return tmpMarkerField;
+ }
+
+
+ @Test
+ public void testEventConstructors() {
+
+ JniMarker tmpMarker = null;
+
+ JniMarkerField tmpMarkerField1 = null;
+ JniMarkerField tmpMarkerField2 = null;
+
+ // This event should be valid and will be used in test
+ try {
+ tmpMarker = new JniTrace(tracepath).requestEventByName(eventName).requestEventMarker();
+ }
+ catch( JniException e) { }
+
+ // Test constructor with pointer on a wrong pointer
+ try {
+ tmpMarkerField1 = new JniMarkerField( new C_Pointer(0) );
+ fail("Construction with wrong pointer should fail!");
+ }
+ catch( JniException e) {
+ }
+
+ // Test constructor with pointer on a correct pointer
+ try {
+ tmpMarkerField1 = new JniMarkerField( tmpMarker.getMarkerFieldsArrayList().get(0).getMarkerFieldPtr() );
+ }
+ catch( JniException e) {
+ fail("Construction with correct pointer failed!");
+ }
+
+
+ // Test copy constructor
+ try {
+ tmpMarkerField1 = new JniMarkerField( tmpMarker.getMarkerFieldsArrayList().get(0) );
+ tmpMarkerField2 = new JniMarkerField( tmpMarkerField1);
+ }
+ catch( Exception e) {
+ fail("Copy constructor failed!");
+ }
+
+ assertSame("JniMarker name not same after using copy constructor", tmpMarkerField1.getField() , tmpMarkerField2.getField());
+
+ }
+
+ @Test
+ public void testGetSet() {
+
+ JniMarkerField testMarkerField = prepareMarkerFieldToTest();
+
+ // Test that all Get/Set return data
+ assertNotSame("getName is empty","",testMarkerField.getField() );
+ assertNotSame("getFormat is empty","",testMarkerField.getFormat() );
+ assertNotSame("getMarkerFieldPtr is 0",0,testMarkerField.getMarkerFieldPtr() );
+ }
+
+ @Test
+ public void testPrintAndToString() {
+
+ JniMarkerField testMarkerField = prepareMarkerFieldToTest();
+
+ // Test printMarkerInformation
+ try {
+ testMarkerField.printMarkerFieldInformation();
+ }
+ catch( Exception e) {
+ fail("printMarkerFieldInformation failed!");
+ }
+
+ // Test ToString()
+ assertNotSame("toString returned empty data","",testMarkerField.toString() );
+ }
+}
--- /dev/null
+
+package org.eclipse.linuxtools.lttng.jni;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/*
+ Functions tested here :
+ public JniMarker(JniMarker oldMarker)
+ public JniMarker(long newMarkerPtr) throws JniException
+
+ public String[] requestMarkerFieldToString()
+
+ public String getName()
+ public String getFormatOverview()
+ public ArrayList<JniMarkerField> getMarkerFieldArrayList()
+
+ public String toString()
+ public void printMarkerInformation()
+*/
+
+public class MarkerTest
+{
+ private final static String tracepath="traceset/trace_617984ev_withlost";
+ private final static String eventName="kernel0";
+
+ private final static int numberOfMarkersFieldInMarker = 3;
+
+ private JniMarker prepareMarkerToTest() {
+
+ JniEvent tmpEvent = null;
+ JniMarker tmpMarker = null;
+
+ // This trace should be valid
+ // We will read the second event to have something interesting to test on
+ try {
+ tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ tmpEvent.readNextEvent();
+
+ tmpMarker = tmpEvent.requestEventMarker();
+ }
+ catch( JniException e) { }
+
+ return tmpMarker;
+ }
+
+
+ @Test
+ public void testEventConstructors() {
+
+ JniEvent tmpEvent = null;
+
+ JniMarker testMarker1 = null;
+ JniMarker testMarker2 = null;
+
+ // This event should be valid and will be used in test
+ try {
+ tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ }
+ catch( JniException e) { }
+
+ // Test constructor with pointer on a wrong pointer
+ try {
+ testMarker1 = new JniMarker( new C_Pointer(0) );
+ fail("Construction with wrong pointer should fail!");
+ }
+ catch( JniException e) {
+ }
+
+ // Test constructor with pointer on a correct pointer
+ try {
+ testMarker1 = new JniMarker( tmpEvent.requestEventMarker().getMarkerPtr() );
+ }
+ catch( JniException e) {
+ fail("Construction with correct pointer failed!");
+ }
+
+
+ // Test copy constructor
+ try {
+ testMarker1 = new JniMarker( tmpEvent.requestEventMarker().getMarkerPtr() );
+ testMarker2 = new JniMarker( testMarker1);
+ }
+ catch( JniException e) {
+ fail("Copy constructor failed!");
+ }
+
+ assertSame("JniMarker name not same after using copy constructor", testMarker1.getName() , testMarker2.getName());
+
+ }
+
+ @Test
+ public void testGetSet() {
+
+ JniMarker testMarker = prepareMarkerToTest();
+
+ // Test that all Get/Set return data
+ assertNotSame("getName is empty","",testMarker.getName() );
+ assertNotSame("getFormat is empty","",testMarker.getFormatOverview() );
+
+ assertNotSame("getMarkerFieldArrayList is null",null,testMarker.getMarkerFieldsArrayList() );
+ // Also check that the map contain a certains number of data
+ assertSame("getMarkerFieldArrayList returned an unexpected number of markers",numberOfMarkersFieldInMarker,testMarker.getMarkerFieldsArrayList().size() );
+
+ assertNotSame("getMarkerPtr is 0",0,testMarker.getMarkerPtr() );
+ }
+
+ @Test
+ public void testPrintAndToString() {
+
+ JniMarker testMarker = prepareMarkerToTest();
+
+ // Test printMarkerInformation
+ try {
+ testMarker.printMarkerInformation();
+ }
+ catch( Exception e) {
+ fail("printMarkerInformation failed!");
+ }
+
+ // Test ToString()
+ assertNotSame("toString returned empty data","",testMarker.toString() );
+
+ }
+}
--- /dev/null
+
+package org.eclipse.linuxtools.lttng.jni;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+/*
+ Functions tested here :
+ public JniTrace()
+ public JniTrace(JniTrace oldTrace)
+ public JniTrace(String newpath) throws JafException
+ public JniTrace(long newPtr) throws JafException
+
+ public void openTrace(String newPath) throws JafException
+ public void openTrace() throws JafException
+ public void closeTrace( ) throws JafException
+
+ public JniEvent readNextEvent()
+ public JniEvent findNextEvent()
+ public JniEvent seekAndRead(JniTime seekTime)
+ public void seekToTime(JniTime seekTime)
+
+ public JniTracefile requestTracefileByName(String tracefileName)
+ public JniEvent requestEventByName(String tracefileName)
+ public ArrayList<Location> requestTraceLocation()
+
+ public String getTracepath()
+ public int getCpuNumber()
+ public long getArchType()
+ public long getArchVariant()
+ public short getArchSize()
+ public short getLttMajorVersion()
+ public short getLttMinorVersion()
+ public short getFlightRecorder()
+ public long getFreqScale()
+ public long getStartFreq()
+ public long getStartTimestampCurrentCounter()
+ public long getStartMonotonic()
+ public JniTime getStartTime()
+ public JniTime getStartTimeFromTimestampCurrentCounter()
+ public HashMap<String, JniTracefile> getTracefilesMap()
+ public long getTracePtr()
+
+ public void printAllTracefilesInformation()
+ public void printTraceInformation()
+
+ public String toString()
+ */
+
+
+public class TraceTest
+{
+ private final static String tracepath1="traceset/trace_617984ev_withlost";
+ private final static String tracepath2="traceset/trace_211064ev_nolost";
+ private final static String wrongTracePath="/somewhere/that/does/not/exist";
+
+ private final static String correctTracefileName="kernel0";
+ private final static String wrongTracefileName="somethingThatDoesNotExists";
+
+ private final static int numberOfTracefilesInTrace = 17;
+
+ private final static long firstEventTimestamp = 952090116049L;
+ private final static String secondEventName = "kernel";
+
+ private final static long timestampToSeekTest1 = 953852206193L;
+ private final static String eventNameAfterSeekTest1 = "kernel";
+ private final static String nextEventNameAfterSeekTest1 = "fs";
+
+ private final static long timestampToSeekTest2 = 953852210706L;
+ private final static String eventNameAfterSeekTest2 = "fs";
+ private final static String nextEventNameAfterSeekTest2 = "kernel";
+
+ private final static long timestampToSeekLast = 960386638531L;
+ private final static String eventNameAfterSeekLast = "kernel";
+
+
+ private JniTrace prepareTraceToTest() {
+ JniTrace tmpTrace = null;
+
+ // This trace should be valid
+ try {
+ tmpTrace = new JniTrace(tracepath1);
+ }
+ catch( JniException e) { }
+
+ return tmpTrace;
+ }
+
+ @Test
+ public void testTraceConstructors() {
+ JniTrace testTrace1 = null;
+ @SuppressWarnings("unused")
+ JniTrace testTrace2 = null;
+
+ // Test constructor with argument on a wrong tracepath
+ try {
+ System.out.println("TEST1");
+
+ testTrace1 = new JniTrace(wrongTracePath);
+ fail("Construction with wrong tracepath should fail!");
+ }
+ catch( JniException e) {
+ }
+
+ // Test constructor with argument on a correct tracepath
+ try {
+ System.out.println("TEST2");
+
+ testTrace1 = new JniTrace(tracepath1);
+ }
+ catch( JniException e) {
+ fail("Construction with correct tracepath failed!");
+ }
+
+ // Test copy constructor that take a pointer with a good pointer
+ try {
+ System.out.println("TEST3");
+
+ testTrace1 = new JniTrace( new C_Pointer(0) );
+ fail("Construction with wrong pointer should fail!");
+ }
+ catch( JniException e) {
+ }
+
+ // Test copy constructor that take a pointer with a good pointer
+ try {
+ System.out.println("TEST4");
+
+ testTrace1 = new JniTrace(tracepath1); // This trace should be valid
+ testTrace2 = new JniTrace( testTrace1.getTracePtr() );
+ }
+ catch( JniException e) {
+ fail("Construction with correct pointer failed!");
+ }
+
+ }
+
+ @Test
+ public void testTraceOpenClose() {
+
+ JniTrace testTrace = prepareTraceToTest(); // This trace should be valid
+
+ // test the constructor with arguments passing a wrong tracepath
+ try {
+ testTrace.openTrace(wrongTracePath);
+ fail("Open with wrong tracepath should fail!");
+ }
+ catch( JniException e) { }
+
+ // Test open with a correct tracepath
+ try {
+ testTrace.openTrace(tracepath1);
+ assertNotSame("getTracepath is empty after open","",testTrace.getTracepath() );
+ }
+ catch( JniException e) {
+ fail("Open with a correct tracepath failed!");
+ }
+
+ // Test to open a trace already opened
+ try {
+ testTrace.openTrace(tracepath1);
+ testTrace.openTrace(tracepath2);
+ assertNotSame("getTracepath is empty after open","",testTrace.getTracepath() );
+ }
+ catch( JniException e) {
+ fail("Reopen of a trace failed!");
+ }
+
+
+ // Test to open a trace already opened, but with a wrong tracepath
+ try {
+ testTrace.openTrace(tracepath1);
+ testTrace.openTrace(wrongTracePath);
+ fail("Reopen with wrong tracepath should fail!");
+ }
+ catch( JniException e) {
+ }
+ }
+
+ @Test
+ public void testGetSet() {
+
+ JniTrace testTrace = prepareTraceToTest();
+
+ // Test that all Get/Set return data
+ assertNotSame("getTracepath is empty","",testTrace.getTracepath() );
+ assertNotSame("getCpuNumber is 0",0,testTrace.getCpuNumber() );
+ assertNotSame("getArchType is 0",0,testTrace.getArchType() );
+ assertNotSame("getArchVariant is 0",0,testTrace.getArchVariant() );
+ assertNotSame("getArchSize is 0",0,testTrace.getArchSize() );
+ assertNotSame("getLttMajorVersion is 0",0,testTrace.getLttMajorVersion() );
+ assertNotSame("getLttMinorVersion is 0",0,testTrace.getLttMinorVersion() );
+ assertNotSame("getFlightRecorder is 0",0,testTrace.getFlightRecorder() );
+ assertNotSame("getFreqScale is 0",0,testTrace.getFreqScale() );
+ assertNotSame("getStartFreq is 0",0,testTrace.getStartFreq() );
+ assertNotSame("getStartTimestampCurrentCounter is 0",0,testTrace.getStartTimestampCurrentCounter());
+ assertNotSame("getStartMonotonic is 0",0,testTrace.getStartMonotonic() );
+ assertNotSame("getStartTime is null",null,testTrace.getStartTime() );
+ assertNotSame("getStartTimeFromTimestampCurrentCounter is null",null,testTrace.getStartTimeFromTimestampCurrentCounter() );
+ assertNotSame("getTracefilesMap is null",null,testTrace.getTracefilesMap() );
+ // Also check that the map contain some tracefiles
+ assertSame("getTracefilesMap returned an unexpected number of tracefiles",numberOfTracefilesInTrace,testTrace.getTracefilesMap().size() );
+ assertNotSame("getTracePtr is 0",0,testTrace.getTracePtr() );
+
+
+ }
+
+ @Test
+ public void testPrintAndToString() {
+
+ JniTrace testTrace = prepareTraceToTest();
+
+ // Test printTraceInformation
+ try {
+ testTrace.printTraceInformation();
+ }
+ catch( Exception e) {
+ fail("printTraceInformation failed!");
+ }
+
+ // Test ToString()
+ assertNotSame("toString returned empty data","",testTrace.toString() );
+ }
+
+ @Test
+ public void testRequestFunctions() {
+
+ JniTrace testTrace = prepareTraceToTest();
+
+ // Test requestTracefileByName()
+ assertNotSame("requestTracefileByName returned null",null,testTrace.requestTracefileByName(correctTracefileName) );
+ assertSame("requestTracefileByName returned content on non existent name",null,testTrace.requestTracefileByName(wrongTracefileName) );
+
+ // Test requestEventByName()
+ assertNotSame("requestEventByName returned null",null,testTrace.requestEventByName(correctTracefileName) );
+ assertSame("requestEventByName returned content on non existent name",null,testTrace.requestEventByName(wrongTracefileName) );
+ }
+
+ @Test
+ public void testEventDisplacement() {
+
+ JniEvent testEvent = null;
+ JniTrace testTrace = prepareTraceToTest();
+
+ // Test readNextEvent()
+ testEvent = testTrace.readNextEvent();
+ assertNotSame("readNextEvent() returned null",null,testEvent);
+ assertEquals("readNextEvent() timestamp is incoherent",firstEventTimestamp,testEvent.getEventTime().getTime() );
+
+ // Test findNextEvent()
+ testEvent = testTrace.findNextEvent();
+ assertNotSame("findNextEvent() returned null",null,testEvent);
+ assertEquals("findNextEvent() name is incoherent",secondEventName,testEvent.getParentTracefile().getTracefileName() );
+
+ // Test readNextEvent()
+ testEvent = testTrace.readNextEvent();
+ assertNotSame("readNextEvent() returned null",null,testEvent);
+ assertEquals("readNextEvent() timestamp is incoherent",secondEventName,testEvent.getParentTracefile().getTracefileName() );
+
+ // Tests below are for seekAndRead()
+ // After, we will perform the same operation for seekTime
+ //
+ // Test #1 of seekAndRead()
+ testEvent = testTrace.seekAndRead(new JniTime(timestampToSeekTest1) );
+ assertNotSame("seekAndRead(time) returned null (test #1)",null,testEvent);
+ assertEquals("seekAndRead(time) timestamp is incoherent (test #1)",timestampToSeekTest1,testEvent.getEventTime().getTime());
+ assertEquals("event name after seekAndRead(time) is incoherent (test #1)",eventNameAfterSeekTest1,testEvent.getParentTracefile().getTracefileName());
+ // Test that the next event after seek in the one we expect
+ testEvent = testTrace.readNextEvent();
+ assertEquals("readNextEvent() name after seekAndRead(time) is incoherent (test #1)",nextEventNameAfterSeekTest1,testEvent.getParentTracefile().getTracefileName());
+
+ // Test #2 of seekAndRead()
+ testEvent = testTrace.seekAndRead(new JniTime(timestampToSeekTest2) );
+ assertNotSame("seekAndRead(time) returned null (test #2)",null,testEvent);
+ assertEquals("seekAndRead(time) timestamp is incoherent (test #2)",timestampToSeekTest2,testEvent.getEventTime().getTime());
+ assertEquals("event name after seekAndRead(time) is incoherent (test #2)",eventNameAfterSeekTest2,testEvent.getParentTracefile().getTracefileName());
+ // Test that the next event after seek in the one we expect
+ testEvent = testTrace.readNextEvent();
+ assertEquals("readNextEvent() name after seekAndRead(time) is incoherent (test #2)",nextEventNameAfterSeekTest2,testEvent.getParentTracefile().getTracefileName());
+
+
+ // Seek to the LAST event of the trace
+ testEvent = testTrace.seekAndRead(new JniTime(timestampToSeekLast) );
+ assertNotSame("seekAndRead(time) returned null ",null,testEvent);
+ assertEquals("seekAndRead(time) timestamp is incoherent ",timestampToSeekLast,testEvent.getEventTime().getTime());
+ assertEquals("event name after seekTime(time) is incoherent ",eventNameAfterSeekLast,testEvent.getParentTracefile().getTracefileName());
+ // Test that the next event is NULL (end of the trace)
+ testEvent = testTrace.readNextEvent();
+ assertSame("seekAndRead(time) returned null ",null,testEvent);
+
+
+ // Make sure we can seek back
+ testEvent = testTrace.seekAndRead(new JniTime(firstEventTimestamp) );
+ assertNotSame("seekAndRead(time) to seek back returned null",null,testEvent);
+ assertEquals("seekAndRead(time) timestamp after seek back is incoherent",firstEventTimestamp,testEvent.getEventTime().getTime());
+
+
+
+ // Tests below are for seekToTime()
+ // These are the same test as seekAndRead() for a readNextEvent() should be performed after seek
+ //
+ // Test #1 of seekToTime()
+ testTrace.seekToTime(new JniTime(timestampToSeekTest1) );
+ testEvent = testTrace.readNextEvent();
+ assertNotSame("seekToTime(time) returned null (test #1)",null,testEvent);
+ assertEquals("seekToTime(time) timestamp is incoherent (test #1)",timestampToSeekTest1,testEvent.getEventTime().getTime());
+ assertEquals("event name after seekTime(time) is incoherent (test #1)",eventNameAfterSeekTest1,testEvent.getParentTracefile().getTracefileName());
+ // Test that the next event after seek in the one we expect
+ testEvent = testTrace.readNextEvent();
+ assertEquals("readNextEvent() name after seekToTime(time) is incoherent (test #1)",nextEventNameAfterSeekTest1,testEvent.getParentTracefile().getTracefileName());
+
+ // Test #2 of seekToTime()
+ testTrace.seekToTime(new JniTime(timestampToSeekTest2) );
+ testEvent = testTrace.readNextEvent();
+ assertNotSame("seekToTime(time) returned null (test #2)",null,testEvent);
+ assertEquals("seekToTime(time) timestamp is incoherent (test #2)",timestampToSeekTest2,testEvent.getEventTime().getTime());
+ assertEquals("event name after seekTime(time) is incoherent (test #2)",eventNameAfterSeekTest2,testEvent.getParentTracefile().getTracefileName());
+ // Test that the next event after seek in the one we expect
+ testEvent = testTrace.readNextEvent();
+ assertEquals("readNextEvent() name after seekToTime(time) is incoherent (test #2)",nextEventNameAfterSeekTest2,testEvent.getParentTracefile().getTracefileName());
+
+
+ // Seek to the LAST event of the trace
+ testTrace.seekToTime(new JniTime(timestampToSeekLast) );
+ testEvent = testTrace.readNextEvent();
+ assertNotSame("seekToTime(time) returned null ",null,testEvent);
+ assertEquals("seekToTime(time) timestamp is incoherent ",timestampToSeekLast,testEvent.getEventTime().getTime());
+ assertEquals("event name after seekTime(time) is incoherent ",eventNameAfterSeekLast,testEvent.getParentTracefile().getTracefileName());
+ // Test that the next event is NULL (end of the trace)
+ testEvent = testTrace.readNextEvent();
+ assertSame("seekToTime(time) returned null ",null,testEvent);
+
+
+ // Make sure we can seek back
+ testTrace.seekToTime(new JniTime(firstEventTimestamp) );
+ testEvent = testTrace.readNextEvent();
+ assertNotSame("seekToTime(time) to seek back returned null",null,testEvent);
+ assertEquals("seekToTime(time) timestamp after seek back is incoherent",firstEventTimestamp,testEvent.getEventTime().getTime());
+ }
+}
--- /dev/null
+
+package org.eclipse.linuxtools.lttng.jni;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/*
+ Functions tested here :
+ public JniTracefile(JniTracefile oldTracefile)
+ public JniTracefile(long newPtr) throws JniException
+
+ public int readNextEvent()
+ public int seekToTime(JniTime seekTime)
+
+ public Location requestTracefileLocation()
+
+ public boolean getIsCpuOnline()
+ public String getTracefilePath()
+ public String getTracefileName()
+ public long getCpuNumber()
+ public long getTid()
+ public long getPgid()
+ public long getCreation()
+ public long getTracePtr()
+ public long getMarkerDataPtr()
+ public int getCFileDescriptor()
+ public long getFileSize()
+ public long getBlocksNumber()
+ public boolean getIsBytesOrderReversed()
+ public boolean getIsFloatWordOrdered()
+ public long getAlignement()
+ public long getBufferHeaderSize()
+ public int getBitsOfCurrentTimestampCounter()
+ public int getBitsOfEvent()
+ public long getCurrentTimestampCounterMask()
+ public long getCurrentTimestampCounterMaskNextBit()
+ public long getEventsLost()
+ public long getSubBufferCorrupt()
+ public JniEvent getCurrentEvent()
+ public long getBufferPtr()
+ public long getBufferSize()
+ public HashMap<Integer, JniMarker> getTracefileMarkersMap()
+ public JniTrace getParentTrace()
+ public long getTracefilePtr()
+
+ public String toString()
+ public void printTracefileInformation()
+*/
+
+public class TracefileTest
+{
+ private final static String tracepath1="traceset/trace_617984ev_withlost";
+ private final static String tracefileName1="kernel0";
+
+ private final static int numberOfMarkersInTracefile = 46;
+
+ private final static long firstEventTimestamp = 952090116049L;
+ private final static long secondEventTimestamp = 952092222957L;
+ private final static long thirdEventTimestamp = 952102730748L;
+
+ private final static long timestampToSeekTest1 = 953852206193L;
+ private final static long timestampAfterSeekTest1 = 953852212349L;
+
+ private final static long timestampToSeekLast = 960386638531L;
+
+
+ private JniTracefile prepareTracefileToTest() {
+
+ JniTracefile tmpTracefile = null;
+
+ // This trace should be valid
+ try {
+ tmpTracefile = new JniTrace(tracepath1).requestTracefileByName(tracefileName1);
+
+ }
+ catch( JniException e) { }
+
+ return tmpTracefile;
+ }
+
+
+ @Test
+ public void testTracefileConstructors() {
+ JniTrace testTrace = null;
+ JniTracefile testTracefile1 = null;
+ JniTracefile testTracefile2 = null;
+
+ // This trace should be valid and will be used in test
+ try {
+ testTrace = new JniTrace(tracepath1);
+ }
+ catch( JniException e) { }
+
+
+ // Test constructor with pointer on a wrong pointer
+ try {
+ testTracefile1 = new JniTracefile( new C_Pointer(0), testTrace );
+ fail("Construction with wrong pointer should fail!");
+ }
+ catch( JniException e) {
+ }
+
+ // Test constructor with pointer on a correct pointer
+ try {
+ testTracefile1 = new JniTracefile( testTrace.requestEventByName(tracefileName1).getTracefilePtr(), testTrace );
+ }
+ catch( JniException e) {
+ fail("Construction with correct pointer failed!");
+ }
+
+
+ // Test copy constructor
+ try {
+ testTracefile1 = new JniTracefile( testTrace.requestEventByName(tracefileName1).getTracefilePtr(), testTrace );
+ testTracefile2 = new JniTracefile( testTracefile1);
+ }
+ catch( JniException e) {
+ fail("Copy constructor failed!");
+ }
+
+ assertSame("JniTracefile name not same after using copy constructor", testTracefile1.getTracefileName() , testTracefile2.getTracefileName());
+
+ }
+
+ @Test
+ public void testGetSet() {
+
+ JniTracefile testTracefile = prepareTracefileToTest();
+
+ // Test that all Get/Set return data
+ //boolean getIsCpuOnline will always be sane...
+ assertNotSame("getTracefilePath is empty","",testTracefile.getTracefilePath() );
+ assertNotSame("getTracefileName is empty","",testTracefile.getTracefileName() );
+ assertNotSame("getCpuNumber is 0",0,testTracefile.getCpuNumber() );
+ assertNotSame("getTid is 0",0,testTracefile.getTid() );
+ assertNotSame("getPgid is 0",0,testTracefile.getPgid() );
+ assertNotSame("getCreation is 0",0,testTracefile.getCreation() );
+ assertNotSame("getTracePtr is 0",0,testTracefile.getTracePtr() );
+ assertNotSame("getMarkerDataPtr is 0",0,testTracefile.getMarkerDataPtr() );
+ assertNotSame("getCFileDescriptor is 0",0,testTracefile.getCFileDescriptor() );
+ assertNotSame("getFileSize is 0",0,testTracefile.getFileSize() );
+ assertNotSame("getBlocksNumber is 0",0,testTracefile.getBlocksNumber() );
+ //boolean getIsBytesOrderReversed will always be sane...
+ //boolean getIsFloatWordOrdered will always be sane...
+ assertNotSame("getAlignement is 0",0,testTracefile.getAlignement() );
+ assertNotSame("getBufferHeaderSize is 0",0,testTracefile.getBufferHeaderSize() );
+ assertNotSame("getBitsOfCurrentTimestampCounter is 0",0,testTracefile.getBitsOfCurrentTimestampCounter() );
+ assertNotSame("getBitsOfEvent is 0",0,testTracefile.getBitsOfEvent() );
+ assertNotSame("getCurrentTimestampCounterMask is 0",0,testTracefile.getCurrentTimestampCounterMask() );
+ assertNotSame("getCurrentTimestampCounterMaskNextBit is 0",0,testTracefile.getCurrentTimestampCounterMaskNextBit() );
+ assertNotSame("getEventsLost is 0",0,testTracefile.getEventsLost() );
+ assertNotSame("getSubBufferCorrupt is 0",0,testTracefile.getSubBufferCorrupt() );
+ // There should be at least 1 event, so it shouldn't be null
+ assertNotNull("getCurrentEvent returned null", testTracefile.getCurrentEvent() );
+
+ assertNotSame("getBufferPtr is 0",0,testTracefile.getBufferPtr() );
+ assertNotSame("getBufferSize is 0",0,testTracefile.getBufferSize() );
+
+ assertNotSame("getTracefileMarkersMap is null",null,testTracefile.getTracefileMarkersMap() );
+ // Also check that the map contain a certains number of data
+ assertSame("getTracefileMarkersMap returned an unexpected number of markers",numberOfMarkersInTracefile,testTracefile.getTracefileMarkersMap().size() );
+
+ assertNotSame("getParentTrace is null",null,testTracefile.getParentTrace() );
+
+ assertNotSame("getTracefilePtr is 0",0,testTracefile.getTracefilePtr() );
+
+ }
+
+ @Test
+ public void testPrintAndToString() {
+
+ JniTracefile testTracefile = prepareTracefileToTest();
+
+ // Test printTraceInformation
+ try {
+ testTracefile.printTracefileInformation();
+ }
+ catch( Exception e) {
+ fail("printTraceInformation failed!");
+ }
+
+ // Test ToString()
+ assertNotSame("toString returned empty data","",testTracefile.toString() );
+
+ }
+
+ @Test
+ public void testEventDisplacement() {
+
+ int readValue = -1;
+ int seekValue = -1;
+ JniTracefile testTracefile = prepareTracefileToTest();
+
+ // Test #1 readNextEvent()
+ readValue = testTracefile.readNextEvent();
+ assertSame("readNextEvent() returned error (test #1)",0,readValue);
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",secondEventTimestamp,testTracefile.getCurrentEvent().getEventTime().getTime() );
+
+ // Test #2 readNextEvent()
+ readValue = testTracefile.readNextEvent();
+ assertSame("readNextEvent() returned error (test #1)",0,readValue);
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",thirdEventTimestamp,testTracefile.getCurrentEvent().getEventTime().getTime() );
+
+
+ // Test #1 of seekToTime()
+ seekValue = testTracefile.seekToTime(new JniTime(timestampToSeekTest1) );
+ assertSame("seekToTime() returned error (test #1)",0,seekValue);
+ // Read SHOULD NOT be performed after a seek!
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",timestampToSeekTest1,testTracefile.getCurrentEvent().getEventTime().getTime() );
+
+ readValue = testTracefile.readNextEvent();
+ assertEquals("readNextEvent() event timestamp is incoherent (test #1)",timestampAfterSeekTest1,testTracefile.getCurrentEvent().getEventTime().getTime() );
+
+
+ // Test #2 of seekToTime()
+ seekValue = testTracefile.seekToTime(new JniTime(timestampToSeekLast) );
+ assertSame("seekToTime() returned error (test #2)",0,seekValue);
+ // Read SHOULD NOT be performed after a seek!
+ assertEquals("readNextEvent() event timestamp is incoherent (test #2)",timestampToSeekLast,testTracefile.getCurrentEvent().getEventTime().getTime() );
+
+ // Read AFTER the last event should bring an error
+ readValue = testTracefile.readNextEvent();
+ assertNotSame("readNextEvent() AFTER last event should return error (test #2)",0,readValue);
+
+
+ // Test to see if we can seek back
+ seekValue = testTracefile.seekToTime(new JniTime(firstEventTimestamp) );
+ assertSame("seekToTime() returned error (test seek back)",0,seekValue);
+ // Read SHOULD NOT be performed after a seek!
+ assertEquals("readNextEvent() event timestamp is incoherent (test seek back)",firstEventTimestamp,testTracefile.getCurrentEvent().getEventTime().getTime() );
+
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.state;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.lttng.state.model.StateModelFactory;
+
+/**
+ * @author alvaro
+ *
+ */
+public class StateManagerFactoryTestSupport {
+ // ========================================================================
+ // Data
+ // =======================================================================
+
+ private static final Map<String, StateManager> instanceBook = new HashMap<String, StateManager>();
+
+ // ========================================================================
+ // Methods
+ // =======================================================================
+
+ /**
+ * Provide a stateManager instance per trace
+ *
+ * @return
+ */
+ public static StateManager getManager(String traceUniqueId) {
+ if (traceUniqueId == null) {
+ return null;
+ }
+
+ if (instanceBook.containsKey(traceUniqueId)) {
+ return instanceBook.get(traceUniqueId);
+ }
+
+ LttngTraceState traceModel = StateModelFactory.getStateEntryInstance();
+ StateStacksHandlerTestSupport stateInputHandler = new StateStacksHandlerTestSupport(traceModel);
+ StateManager manager = new StateManager(stateInputHandler);
+
+ instanceBook.put(traceUniqueId, manager);
+ return manager;
+ }
+
+ /**
+ * Remove previously registered managers
+ * @param traceUniqueId
+ */
+ public static void removeManager(String traceUniqueId) {
+ if (traceUniqueId != null && instanceBook.containsKey(traceUniqueId)) {
+ instanceBook.remove(traceUniqueId);
+ }
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng.state;
+
+import org.eclipse.linuxtools.lttng.TraceDebug;
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
+import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
+import org.eclipse.linuxtools.lttng.state.evProcessor.state.StateUpdateFactory;
+import org.eclipse.linuxtools.lttng.state.handlers.after.StateAfterUpdateFactory;
+import org.eclipse.linuxtools.lttng.state.handlers.before.StateBeforeUpdateFactory;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfEventField;
+
+/**
+ * @author Alvaro
+ *
+ */
+public class StateStacksHandlerTestSupport extends StateStacksHandler {
+
+ // ========================================================================
+ // Table data
+ // =======================================================================
+
+ // private static final Long LTTNG_STATE_SAVE_INTERVAL = 50000L;
+ // private JniTrace trace = null;
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+ StateStacksHandlerTestSupport(LttngTraceState model) {
+ // It's assumed to have one instance of this class per "TraceSet"
+ super(model);
+ }
+
+ // ========================================================================
+ // Methods
+ // =======================================================================
+
+ @Override
+ void processEvent(TmfEvent tmfEvent) /* throws LttngStateException */{
+ if (tmfEvent == null) {
+ return;
+ }
+
+ if (!(tmfEvent instanceof LttngEvent)) {
+ TraceDebug.debug("The event received is not an instance of LttngEvent and can not be processed");
+ }
+
+ LttngEvent trcEvent = (LttngEvent) tmfEvent;
+ TmfEventField[] fields = trcEvent.getContent().getFields();
+
+ if (fields != null) {
+ String inChannel = trcEvent.getChannelName();
+ String inEventName = trcEvent.getMarkerName();
+ // TraceDebug.debug("Event: " + inEventName);
+
+ // Check if the received event is a transition state event
+ Events eventStruct = StateStrings.getInstance()
+ .getStateTransEventMap().get(inEventName);
+ if (eventStruct != null) {
+ String expectedChannel = eventStruct.getParent().getInName();
+ // check that received channel is the expected channel in the
+ // structure
+ if (inChannel.equals(expectedChannel)) {
+ IEventProcessing handlerBefore = StateBeforeUpdateFactory.getInstance()
+ .getEventNametoProcessor(inEventName);
+
+ IEventProcessing handler = StateUpdateFactory.getInstance()
+ .getStateUpdaterProcessor(inEventName);
+
+ IEventProcessing handlerAfter = StateAfterUpdateFactory.getInstance()
+ .getEventNametoProcessor(inEventName);
+
+
+ //Establish test reference calling the before handler
+ if(handlerBefore != null) {
+ handlerBefore.process(trcEvent, traceStateModel);
+ }
+
+ //Execute the actual test action
+ if (handler != null) {
+ // process State Update
+ handler.process(trcEvent, traceStateModel);
+ } else {
+ if (TraceDebug.isDEBUG()) {
+ eventsNotHandled.add(inEventName);
+ }
+ }
+
+ //After processing verify the effects over the base state.
+ if(handlerAfter != null) {
+ handlerAfter.process(trcEvent, traceStateModel);
+ }
+
+ } else {
+ StringBuilder sb = new StringBuilder(
+ "Unexpected channel received for: " + inEventName
+ + ", channel rec: " + inChannel
+ + " chanel expected: " + expectedChannel);
+ TraceDebug.debug(sb.toString());
+ }
+ }
+ }
+ }
+
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.state;
+
+import java.util.Set;
+
+import org.eclipse.linuxtools.lttng.ActivateDebugging;
+import org.eclipse.linuxtools.lttng.TraceDebug;
+import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
+import org.eclipse.linuxtools.tmf.trace.TmfExperiment;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author alvaro
+ *
+ */
+public class TestStateManager {
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ActivateDebugging.activate();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetTraceSelection() {
+ String logName = "traceset/trace1";
+
+ LTTngTrace testStream = null;
+ try {
+ testStream = new LTTngTrace(logName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (testStream != null) {
+ LTTngTrace[] streamList = new LTTngTrace[1];
+ streamList[0] = testStream;
+ TmfExperiment newExp = new TmfExperiment(logName, streamList);
+
+ //Get the Test StateManager
+ StateManager manager = StateManagerFactoryTestSupport.getManager(newExp.getExperimentId());
+ //Start execution.
+ manager.setTraceSelection(newExp);
+
+ //Print events not handled.
+ Set<String> notHandledEvents = manager.getEventsNotHandled();
+ StringBuilder sb = new StringBuilder();
+ for (String event : notHandledEvents) {
+ sb.append("\n" + event);
+ }
+ TraceDebug.debug("Events not Handled: " + sb.toString());
+ }
+ }
+}
--- /dev/null
+package org.eclipse.linuxtools.lttng.state.handlers;
+
+import org.eclipse.linuxtools.lttng.TraceDebug;
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngEventField;
+import org.eclipse.linuxtools.lttng.state.StateStrings.Fields;
+import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
+import org.eclipse.linuxtools.lttng.state.model.LttngExecutionState;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.tmf.event.TmfEventField;
+
+public abstract class AbsStateUpdate implements IEventProcessing {
+
+ // ========================================================================
+ // Data
+ // =======================================================================
+ protected static LttngExecutionState exState = null;
+ protected static Long pid = null;
+
+ // ========================================================================
+ // push and pop from stack
+ // =======================================================================
+
+// protected static final Long ANY_CPU = 0L;
+
+
+// protected void push_state(Long cpu, StateStrings.ExecutionMode execMode,
+// String submode, TmfTimestamp eventTime, LttngTraceState traceSt) {
+//
+// LttngProcessState process = traceSt.getRunning_process().get(cpu);
+// LttngExecutionState exe_state = new LttngExecutionState();
+// exe_state.setExec_mode(execMode);
+// exe_state.setExec_submode(submode);
+// exe_state.setEntry_Time(eventTime);
+// exe_state.setChage_Time(eventTime);
+// exe_state.setCum_cpu_time(0L);
+// exe_state.setProc_status(process.getState().getProc_status());
+// process.setState(exe_state);
+//
+// Stack<LttngExecutionState> exe_state_stack = process
+// .getExecution_stack();
+// exe_state_stack.push(exe_state);
+// }
+//
+// protected void pop_state(Long cpu, StateStrings.ExecutionMode execMode,
+// LttngTraceState traceSt, TmfTimestamp eventTime) {
+//
+// LttngProcessState process = traceSt.getRunning_process().get(cpu);
+//
+// if (!process.getState().getExec_mode().equals(execMode)) {
+// // Different execution mode
+// TraceDebug.debug("Different Execution Mode type \n\tTime:"
+// + eventTime.toString() + "\n\tprocess state has: \n\t"
+// + process.getState().getExec_mode().toString()
+// + "\n\twhen pop_int is:\n\t" + execMode.toString());
+// return;
+// }
+//
+// Stack<LttngExecutionState> exe_state_stack = process
+// .getExecution_stack();
+//
+// if (exe_state_stack.size() <= 1) {
+// TraceDebug
+// .debug("Removing last item from execution stack is not allowed");
+// }
+//
+// exe_state_stack.pop();
+// process.setState(exe_state_stack.peek());
+// process.getState().setChage_Time(eventTime);
+// }
+//
+// protected void irq_push_mode(LttngIRQState irqst, IRQMode state) {
+// irqst.getMode_stack().push(state);
+// }
+//
+// protected void irq_set_base_mode(LttngIRQState irqst, IRQMode state) {
+// Stack<IRQMode> irqModeStack = irqst.getMode_stack();
+// irqModeStack.clear();
+// irqModeStack.push(state);
+// }
+//
+// protected void irq_pop_mode(LttngIRQState irqst) {
+// Stack<IRQMode> irq_stack = irqst.getMode_stack();
+// if (irq_stack.size() <= 1)
+// irq_set_base_mode(irqst, IRQMode.LTTV_IRQ_UNKNOWN);
+// else
+// irq_stack.pop();
+// }
+//
+// protected void cpu_push_mode(LTTngCPUState cpust, StateStrings.CpuMode state) {
+// // The initialization (init) creates a LttngCPUState instance per
+// // available cpu in the system
+// Stack<CpuMode> cpuStack = cpust.getMode_stack();
+// cpuStack.push(state);
+// }
+//
+// protected void cpu_pop_mode(LTTngCPUState cpust) {
+// if (cpust.getMode_stack().size() <= 1)
+// cpu_set_base_mode(cpust, StateStrings.CpuMode.LTTV_CPU_UNKNOWN);
+// else
+// cpust.getMode_stack().pop();
+// }
+//
+// /* clears the stack and sets the state passed as argument */
+// protected void cpu_set_base_mode(LTTngCPUState cpust,
+// StateStrings.CpuMode state) {
+// Stack<CpuMode> cpuStack = cpust.getMode_stack();
+// cpuStack.clear();
+// cpuStack.push(state);
+// }
+//
+// protected void bdev_pop_mode(LttngBdevState bdevst) {
+// Stack<BdevMode> bdevModeStack = bdevst.getMode_stack();
+// if (bdevModeStack.size() <= 1) {
+// bdev_set_base_mode(bdevModeStack, BdevMode.LTTV_BDEV_UNKNOWN);
+// } else {
+// bdevModeStack.pop();
+// }
+//
+// }
+//
+// protected void bdev_set_base_mode(Stack<BdevMode> bdevModeStack,
+// BdevMode state) {
+// bdevModeStack.clear();
+// bdevModeStack.push(state);
+// }
+//
+// /**
+// * Push a new received function pointer to the user_stack
+// *
+// * @param traceSt
+// * @param funcptr
+// * @param cpu
+// */
+// protected void push_function(LttngTraceState traceSt, Long funcptr, Long cpu) {
+// // Get the related process
+// LttngProcessState process = traceSt.getRunning_process().get(cpu);
+//
+// // get the user_stack
+// Stack<Long> user_stack = process.getUser_stack();
+//
+// // update stack
+// user_stack.push(funcptr);
+//
+// // update the pointer to the current function on the corresponding
+// // process
+// process.setCurrent_function(funcptr);
+// }
+//
+// protected void pop_function(LttngTraceState traceSt, LttngEvent trcEvent,
+// Long funcptr) {
+// Long cpu = trcEvent.getCpuId();
+// // LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
+// // LttvProcessState *process = ts->running_process[cpu];
+// LttngProcessState process = traceSt.getRunning_process().get(cpu);
+// Long curr_function = process.getCurrent_function();
+// if (curr_function != null && curr_function != funcptr) {
+// TraceDebug.debug("Different functions: " + funcptr + " current: "
+// + curr_function + " time stamp: "
+// + trcEvent.getTimestamp().toString());
+//
+// // g_info("Different functions (%lu.%09lu): ignore it\n",
+// // tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
+// // g_info("process state has %" PRIu64 " when pop_function is %"
+// // PRIu64
+// // "\n",
+// // process->current_function, funcptr);
+// // g_info("{ %u, %u, %s, %s, %s }\n",
+// // process->pid,
+// // process->ppid,
+// // g_quark_to_string(process->name),
+// // g_quark_to_string(process->brand),
+// // g_quark_to_string(process->state->s));
+// return;
+// }
+//
+// Stack<Long> user_stack = process.getUser_stack();
+// if (user_stack.size() == 0) {
+// TraceDebug
+// .debug("Trying to pop last function in stack. Ignored. Time Stamp: "
+// + trcEvent.getTimestamp());
+// return;
+// }
+// user_stack.pop();
+// process.setCurrent_function(user_stack.peek());
+// }
+//
+// // ========================================================================
+// // General methods
+// // =======================================================================
+// /**
+// * protected method used when only one Field is expected with Type "Long" if
+// * the number of fields is greater, the first field is returned and a
+// * tracing message is sent Null is returned if the value could not be
+// * extracted.
+// *
+// * @param trcEvent
+// * @param traceSt
+// * @param expectedNumFields
+// * @return
+// */
+// protected Long getDField(LttngEvent trcEvent, LttngTraceState traceSt,
+// Fields expectedField) {
+// Long fieldVal = null;
+// TmfEventField[] fields = trcEvent.getContent().getFields();
+// String[] fieldLabels = trcEvent.getContent().getFormat().getLabels();
+//
+// // Only one field expected
+// if (fields.length != 1 || fieldLabels.length != 1) {
+// StringBuilder sb = new StringBuilder(
+// "Unexpected number of fields received: " + fields.length
+// + " for Event: " + trcEvent.getMarkerName() + "\n\t\tFields: ");
+//
+// for (TmfEventField field : fields) {
+// sb.append(((LttngEventField)field).getName() + " ");
+// }
+//
+// TraceDebug.debug(sb.toString());
+// if (fields.length == 0) {
+// return null;
+// }
+// }
+//
+// LttngEventField field = (LttngEventField) fields[0];
+// String fieldname = field.getName();
+// String expectedFieldName = expectedField.getInName();
+// if (fieldname.equals(expectedFieldName)) {
+// Object fieldObj = field.getValue();
+// if (fieldObj instanceof Long) {
+// // Expected value found
+// fieldVal = (Long) field.getValue();
+// } else {
+// if (TraceDebug.isDEBUG()) {
+// TraceDebug
+// .debug("Unexpected field Type. Expected: Long, Received: "
+// + fieldObj.getClass().getSimpleName());
+// }
+// return null;
+// }
+// } else {
+// TraceDebug.debug("Unexpected field received: " + fieldname
+// + " Expected: " + expectedFieldName);
+// return null;
+// }
+//
+// return fieldVal;
+// }
+//
+ /**
+ * protected method used when a Field is requested among several available
+ * fields and the expected type is Long
+ *
+ * @param trcEvent
+ * @param traceSt
+ * @param expectedNumFields
+ * @return
+ */
+ protected Long getAFieldLong(LttngEvent trcEvent, LttngTraceState traceSt,
+ Fields expectedField) {
+ Long fieldVal = null;
+ TmfEventField[] fields = trcEvent.getContent().getFields();
+
+ // At least one field expected
+ if (fields.length == 0) {
+ TraceDebug.debug("Unexpected number of fields received: "
+ + fields.length);
+ return null;
+ }
+
+ LttngEventField field;
+ String fieldname;
+ String expectedFieldName = expectedField.getInName();
+ for (int i = 0; i < fields.length; i++) {
+ field = (LttngEventField) fields[i];
+ fieldname = field.getName();
+ if (fieldname.equals(expectedFieldName)) {
+ Object fieldObj = field.getValue();
+ if (fieldObj instanceof Long) {
+ // Expected value found
+ fieldVal = (Long) field.getValue();
+ // if (expectedField == Fields.LTT_FIELD_TYPE) {
+ // TraceDebug.debug("Field Type value is: " + fieldVal);
+ // }
+ break;
+ } else {
+ if (TraceDebug.isDEBUG()) {
+ TraceDebug
+ .debug("Unexpected field Type. Expected: Long, Received: "
+ + fieldObj.getClass().getSimpleName());
+ }
+ return null;
+ }
+ }
+ }
+
+ if (fieldVal == null) {
+ if (TraceDebug.isDEBUG()) {
+ sendNoFieldFoundMsg(fields, expectedFieldName);
+ }
+ }
+ return fieldVal;
+ }
+
+ /**
+ * protected method used when a Field is requested among several available
+ * fields and the expected type is String
+ *
+ * @param trcEvent
+ * @param traceSt
+ * @param expectedNumFields
+ * @return
+ */
+ protected String getAFieldString(LttngEvent trcEvent,
+ LttngTraceState traceSt, Fields expectedField) {
+ String fieldVal = null;
+ TmfEventField[] fields = trcEvent.getContent().getFields();
+
+ // Only one field expected
+ if (fields.length == 0) {
+ TraceDebug.debug("Unexpected number of fields received: "
+ + fields.length);
+ return null;
+ }
+
+ LttngEventField field;
+ String fieldname;
+ String expectedFieldName = expectedField.getInName();
+ for (int i = 0; i < fields.length; i++) {
+ field = (LttngEventField) fields[i];
+ fieldname = field.getName();
+ if (fieldname.equals(expectedFieldName)) {
+ Object fieldObj = field.getValue();
+ if (fieldObj instanceof String) {
+ // Expected value found
+ fieldVal = (String) field.getValue();
+ break;
+ } else {
+ if (TraceDebug.isDEBUG()) {
+ TraceDebug
+ .debug("Unexpected field Type. Expected: String, Received: "
+ + fieldObj.getClass().getSimpleName());
+ }
+ return null;
+ }
+ }
+ }
+
+ if (fieldVal == null) {
+ if (TraceDebug.isDEBUG()) {
+ sendNoFieldFoundMsg(fields, expectedFieldName);
+ }
+ }
+ return fieldVal;
+ }
+
+ protected void sendNoFieldFoundMsg(TmfEventField[] fields,
+ String expectedFieldName) {
+ LttngEventField field;
+ StringBuilder sb = new StringBuilder("Field not found, requested: "
+ + expectedFieldName);
+ sb.append(" number of fields: " + fields.length + "Fields: ");
+ for (int i = 0; i < fields.length; i++) {
+ field = (LttngEventField) fields[i];
+ sb.append(field.getName() + " ");
+ }
+
+ TraceDebug.debug(sb.toString(), 5);
+ }
+
+// // Adaption from MKDEV macro
+// protected Long mkdev(Long major, Long minor) {
+// Long result = null;
+// if (major != null && minor != null) {
+// result = (major << 20) | minor;
+// }
+// return result;
+// }
+//
+// /*
+// * FIXME : this function should be called when we receive an event telling
+// * that release_task has been called in the kernel. In happens generally
+// * when the parent waits for its child terminaison, but may also happen in
+// * special cases in the child's exit : when the parent ignores its children
+// * SIGCCHLD or has the flag SA_NOCLDWAIT. It can also happen when the child
+// * is part of a killed thread group, but isn't the leader.
+// */
+// protected boolean exit_process(LttngTraceState ts, LttngProcessState process) {
+// /*
+// * Wait for both schedule with exit dead and process free to happen.
+// * They can happen in any order.
+// */
+// process.incrementFree_events();
+// if (process.getFree_events() < 2) {
+// return false;
+// }
+//
+// process.getExecution_stack().clear();
+// process.getUser_stack().clear();
+// ts.getProcesses().remove(process);
+//
+// return true;
+// }
+//
+// // LttvProcessState *
+// // lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent,
+// // guint cpu, guint pid, guint tgid, GQuark name, const LttTime *timestamp)
+// // {
+// // LttvProcessState *process = g_new(LttvProcessState, 1);
+// //
+// // LttvExecutionState *es;
+// //
+// // char buffer[128];
+// //
+// // process->pid = pid;
+// // process->tgid = tgid;
+// // process->cpu = cpu;
+// // process->name = name;
+// // process->brand = LTTV_STATE_UNBRANDED;
+// // //process->last_cpu = tfs->cpu_name;
+// // //process->last_cpu_index =
+// // ltt_tracefile_num(((LttvTracefileContext*)tfs)->tf);
+// // process->type = LTTV_STATE_USER_THREAD;
+// // process->usertrace = ltt_state_usertrace_find(tcs, pid, timestamp);
+// // process->current_function = 0; //function 0x0 by default.
+// //
+// // g_info("Process %u, core %p", process->pid, process);
+// // g_hash_table_insert(tcs->processes, process, process);
+// //
+// // if(parent) {
+// // process->ppid = parent->pid;
+// // process->creation_time = *timestamp;
+// // }
+// //
+// // /* No parent. This process exists but we are missing all information
+// // about
+// // its creation. The birth time is set to zero but we remember the time of
+// // insertion */
+// //
+// // else {
+// // process->ppid = 0;
+// // process->creation_time = ltt_time_zero;
+// // }
+// //
+// // process->insertion_time = *timestamp;
+// // sprintf(buffer,"%d-%lu.%lu",pid, process->creation_time.tv_sec,
+// // process->creation_time.tv_nsec);
+// // process->pid_time = g_quark_from_string(buffer);
+// // process->cpu = cpu;
+// // process->free_events = 0;
+// // //process->last_cpu = tfs->cpu_name;
+// // //process->last_cpu_index =
+// // ltt_tracefile_num(((LttvTracefileContext*)tfs)->tf);
+// // process->execution_stack = g_array_sized_new(FALSE, FALSE,
+// // sizeof(LttvExecutionState), PREALLOCATED_EXECUTION_STACK);
+// // process->execution_stack = g_array_set_size(process->execution_stack, 2);
+// // es = process->state = &g_array_index(process->execution_stack,
+// // LttvExecutionState, 0);
+// // es->t = LTTV_STATE_USER_MODE;
+// // es->n = LTTV_STATE_SUBMODE_NONE;
+// // es->entry = *timestamp;
+// // //g_assert(timestamp->tv_sec != 0);
+// // es->change = *timestamp;
+// // es->cum_cpu_time = ltt_time_zero;
+// // es->s = LTTV_STATE_RUN;
+// //
+// // es = process->state = &g_array_index(process->execution_stack,
+// // LttvExecutionState, 1);
+// // es->t = LTTV_STATE_SYSCALL;
+// // es->n = LTTV_STATE_SUBMODE_NONE;
+// // es->entry = *timestamp;
+// // //g_assert(timestamp->tv_sec != 0);
+// // es->change = *timestamp;
+// // es->cum_cpu_time = ltt_time_zero;
+// // es->s = LTTV_STATE_WAIT_FORK;
+// //
+// // /* Allocate an empty function call stack. If it's empty, use 0x0. */
+// // process->user_stack = g_array_sized_new(FALSE, FALSE,
+// // sizeof(guint64), 0);
+// //
+// // return process;
+// // }
+//
+// /**
+// * Find the process matching the given pid and cpu
+// *
+// * If cpu is 0, the cpu value is not matched and the selection is based on
+// * pid value only
+// *
+// * @param ts
+// * @param cpu
+// * @param pid
+// * @return
+// */
+// protected LttngProcessState lttv_state_find_process(LttngTraceState ts,
+// Long cpu, Long pid) {
+// // Define the return value
+// LttngProcessState process = null;
+//
+// // Obtain the list of available processes
+// List<LttngProcessState> processList = ts.getProcesses();
+//
+// // find the process matching pid and cpu,
+// // TODO: This may need to be improved since the pid may be re-used and
+// // the creation time may need to be considered
+// for (LttngProcessState dprocess : processList) {
+// if (dprocess.getPid() == pid) {
+// if (dprocess.getCpu() == cpu || cpu == 0) {
+// return process;
+// }
+// }
+// }
+//
+// return process;
+// }
+//
+// /**
+// * @param ts
+// * @param cpu
+// * @param pid
+// * @param timestamp
+// * , Used when a new process is needed
+// * @return
+// */
+// protected LttngProcessState lttv_state_find_process_or_create(
+// LttngTraceState ts, Long cpu, Long pid, final TmfTimestamp timestamp) {
+//
+// LttngProcessState process = lttv_state_find_process(ts, cpu, pid);
+// /* Put ltt_time_zero creation time for unexisting processes */
+// if (process == null) {
+// process = create_process(ts, cpu, pid, 0L, timestamp);
+// }
+// return process;
+// }
+//
+// /**
+// * @param traceSt
+// * @param cpu
+// * @param pid
+// * @param tgid
+// * @param timestamp
+// * @return
+// */
+// protected LttngProcessState create_process(LttngTraceState traceSt,
+// Long cpu, Long pid, Long tgid, final TmfTimestamp timestamp) {
+// LttngProcessState process = create_process(traceSt, cpu, pid, tgid,
+// ProcessStatus.LTTV_STATE_UNNAMED.getInName(), timestamp);
+// return process;
+// }
+//
+// /**
+// * @param traceSt
+// * @param cpu
+// * @param pid
+// * @param tgid
+// * @param name
+// * @param timestamp
+// * @return
+// */
+// protected LttngProcessState create_process(LttngTraceState traceSt,
+// Long cpu, Long pid, Long tgid, String name,
+// final TmfTimestamp timestamp) {
+// LttngProcessState process;
+// process = new LttngProcessState(cpu, pid, tgid, name, timestamp);
+// traceSt.getProcesses().add(process);
+// return process;
+// }
+
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng.state.handlers.after;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.linuxtools.lttng.state.StateStrings;
+import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
+
+/**
+ * Builds a Map from string event name to a processing handler object, the
+ * processors implement the same interface to facilitate transparent methods
+ * call,
+ *
+ * The map key STring is the entry point of the raw events, using a hash speeds
+ * up the resolution of the appropriate processor
+ *
+ * @author alvaro
+ *
+ */
+public class StateAfterUpdateFactory {
+ // ========================================================================
+ // Data
+ // =======================================================================
+ private final Map<String, IEventProcessing> eventNametoProcessor = new HashMap<String, IEventProcessing>();
+ private static StateAfterUpdateFactory instance = null;
+ private StateAfterUpdateHandlers instantiateHandler = new StateAfterUpdateHandlers();
+
+ // ========================================================================
+ // Constructors
+ // =======================================================================
+ private StateAfterUpdateFactory() {
+ //create one instance of each individual event handler and add the instance to the map
+ eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_ENTRY
+ .getInName(), instantiateHandler.getSyscallEntryHandler());
+
+ eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_EXIT
+ .getInName(), instantiateHandler.getsySyscallExitHandler());
+
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
+// .getInName(), instantiateHandler.getTrapEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT
+// .getInName(), instantiateHandler.getTrapExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY
+// .getInName(), instantiateHandler.getTrapEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT
+// .getInName(), instantiateHandler.getTrapExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
+// .getInName(), instantiateHandler.getTrapEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
+// .getInName(), instantiateHandler.getTrapExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
+// .getInName(), instantiateHandler.getIrqEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT
+// .getInName(), instantiateHandler.getIrqExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE
+// .getInName(), instantiateHandler.getSoftIrqRaiseHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY
+// .getInName(), instantiateHandler.getSoftIrqEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT
+// .getInName(), instantiateHandler.getSoftIrqExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_LIST_INTERRUPT
+// .getInName(), instantiateHandler.getEnumInterruptHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_ISSUE
+// .getInName(), instantiateHandler.getBdevRequestIssueHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE
+// .getInName(), instantiateHandler.getBdevRequestCompleteHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_ENTRY
+// .getInName(), instantiateHandler.getFunctionEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_EXIT
+// .getInName(), instantiateHandler.getFunctionExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYS_CALL_TABLE
+// .getInName(), instantiateHandler.getDumpSyscallHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KPROBE_TABLE
+// .getInName(), instantiateHandler.getDumpKprobeHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFTIRQ_VEC
+// .getInName(), instantiateHandler.getDumpSoftIrqHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE
+// .getInName(), instantiateHandler.getSchedChangeHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FORK
+// .getInName(), instantiateHandler.getProcessForkHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KTHREAD_CREATE
+// .getInName(), instantiateHandler.getProcessKernelThreadHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_EXIT
+// .getInName(), instantiateHandler.getProcessExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FREE
+// .getInName(), instantiateHandler.getProcessFreeHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_EXEC
+// .getInName(), instantiateHandler.getProcessExecHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_THREAD_BRAND
+// .getInName(), instantiateHandler.GetThreadBrandHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_STATEDUMP_END
+// .getInName(), instantiateHandler.getStateDumpEndHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_STATE
+// .getInName(), instantiateHandler.getEnumProcessStateHandler());
+
+
+ }
+
+ // ========================================================================
+ // Public methods
+ // =======================================================================
+ /**
+ * The event processors are common to all traces an multiple instances will
+ * use more memory unnecessarily
+ *
+ * @return
+ */
+ public static StateAfterUpdateFactory getInstance() {
+ if (instance == null) {
+ instance = new StateAfterUpdateFactory();
+ }
+ return instance;
+ }
+
+ /**
+ *
+ * @return The Event Handler corresponding to the type of event
+ */
+ public IEventProcessing getEventNametoProcessor(String eventType) {
+ return eventNametoProcessor.get(eventType);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng.state.handlers.after;
+
+
+
+import org.eclipse.linuxtools.lttng.TraceDebug;
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
+import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode;
+import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
+import org.eclipse.linuxtools.lttng.state.handlers.AbsStateUpdate;
+import org.eclipse.linuxtools.lttng.state.model.LttngExecutionState;
+import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+
+/**
+ * Process the system call entry event
+ *
+ * @author alvaro
+ *
+ */
+class StateAfterUpdateHandlers {
+
+ final IEventProcessing getSyscallEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SYSCALL_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // TraceDebug.debug("After event called");
+
+ Long cpu = trcEvent.getCpuId();
+
+ // No syscall_entry update for initialization process
+ LttngProcessState process = traceSt.getRunning_process().get(
+ cpu);
+
+ if (pid != process.getPid()) {
+ TraceDebug
+ .debug("pid values don't match from before and after verification check");
+ }
+
+ if (process.getPid() == 0L) {
+ return true;
+ }
+
+ // Make sure the top of the stack and the state of the stack are
+ // set to the
+ // same object.
+ LttngExecutionState stackState = process.peekFromExecutionStack();
+ if (stackState != process.getState()) {
+ TraceDebug
+ .debug("The top of the stack does not match to the process state");
+ }
+
+ if (stackState.getExec_mode().getInName() != ExecutionMode.LTTV_STATE_SYSCALL
+ .getInName()) {
+ TraceDebug.debug("Unexpected ExecutionMode: "
+ + stackState.getExec_mode().getInName()
+ + " Expected: "
+ + ExecutionMode.LTTV_STATE_SYSCALL.getInName());
+ }
+
+ if (stackState.getEntry_LttTime() != trcEvent.getTimestamp()) {
+ TraceDebug.debug("Unexpected Entry time: "
+ + trcEvent.getTimestamp() + " Expected: "
+ + stackState.getEntry_LttTime());
+ }
+
+ return false;
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ final IEventProcessing getsySyscallExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SYSCALL_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+
+ // TraceDebug.debug("Syscall Exit After event called");
+ Long cpu = trcEvent.getCpuId();
+ LttngProcessState process = traceSt.getRunning_process().get(
+ cpu);
+
+ /* There can be no system call from PID 0 : unknown state */
+ if (process.getPid() == 0L) {
+ if (pid != 0L) {
+ TraceDebug
+ .debug("Unexpected pid from before and after verfication methods, before pid: "
+ + pid
+ + " after pid: "
+ + process.getPid_time());
+ }
+ return true;
+ }
+
+ //
+ // pop_state(cpu, StateStrings.ExecutionMode.LTTV_STATE_SYSCALL,
+ // traceSt, trcEvent.getTimestamp());
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Update stacks related to the parsing of an LttngEvent
+ *
+ * @return
+ */
+ final IEventProcessing getTrapEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_TRAP_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // Long trap = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_TRAP_ID);
+ // if (trap == null) {
+ // return true;
+ // }
+ //
+ // String submode = traceSt.getSyscall_names()
+ // .get(trap);
+ //
+ // if (submode == null) {
+ // submode = ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN
+ // .getInName();
+ // }
+ //
+ // /* update process state */
+ // push_state(cpu, StateStrings.ExecutionMode.LTTV_STATE_TRAP,
+ // submode, trcEvent.getTimestamp(), traceSt);
+ //
+ // /* update cpu status */
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // cpu_push_mode(cpust, StateStrings.CpuMode.LTTV_CPU_TRAP);
+ // cpust.setLast_trap(trap); /* update trap status */
+ //
+ // // update Trap State
+ // LttngTrapState trap_state = traceSt.getTrap_states().get(
+ // trap);
+ // trap_state.incrementRunning();
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getTrapExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_TRAP_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // Long trap = cpust.getLast_trap();
+ //
+ // pop_state(cpu, ExecutionMode.LTTV_STATE_TRAP, traceSt,
+ // trcEvent
+ // .getTimestamp());
+ //
+ // /* update cpu status */
+ // cpu_pop_mode(cpust);
+ //
+ // /* update trap status */
+ // if (trap != -1L) {
+ // traceSt.getTrap_states().get(trap).decrementRunning();
+ // }
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getIrqEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_IRQ_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // Long irq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_IRQ_ID);
+ // if (irq == null) {
+ // return true;
+ // }
+ //
+ // String submode;
+ // submode = traceSt.getIrq_names().get(irq);
+ //
+ // if (submode == null) {
+ // submode =
+ // ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN.getInName();
+ // }
+ //
+ // /*
+ // * Do something with the info about being in user or system
+ // mode
+ // * when int?
+ // */
+ // push_state(cpu, ExecutionMode.LTTV_STATE_IRQ, submode,
+ // trcEvent
+ // .getTimestamp(), traceSt);
+ //
+ // /* update cpu state */
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // cpu_push_mode(cpust, CpuMode.LTTV_CPU_IRQ); /* mode stack */
+ // cpust.setLast_irq(irq); /* last irq */
+ //
+ // /* udpate irq state */
+ // irq_push_mode(traceSt.getIrq_states().get(irq),
+ // IRQMode.LTTV_IRQ_BUSY);
+ return false;
+
+ }
+
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getSoftIrqExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFT_IRQ_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // Long softirq = cpust.getLast_soft_irq();
+ // pop_state(cpu, ExecutionMode.LTTV_STATE_SOFT_IRQ, traceSt,
+ // trcEvent.getTimestamp());
+ //
+ // /* update softirq status */
+ // if (softirq != -1) {
+ // LttngSoftIRQState softIrqstate = traceSt
+ // .getSoft_irq_states().get(softirq);
+ // softIrqstate.decrementRunning();
+ // }
+ //
+ // /* update cpu status */
+ // cpu_pop_mode(cpust);
+
+ return false;
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getIrqExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_IRQ_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // /* update process state */
+ // pop_state(cpu, ExecutionMode.LTTV_STATE_IRQ, traceSt,
+ // trcEvent
+ // .getTimestamp());
+ //
+ // /* update cpu status */
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // cpu_pop_mode(cpust);
+ //
+ // /* update irq status */
+ // Long last_irq = cpust.getLast_irq();
+ // if (last_irq != -1L) {
+ // LttngIRQState irq_state = traceSt.getIrq_states().get(
+ // last_irq);
+ // irq_pop_mode(irq_state);
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getSoftIrqRaiseHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFT_IRQ_RAISE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Long cpu = trcEvent.getCpuId();
+ //
+ // // get event field
+ // Long softirq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SOFT_IRQ_ID);
+ //
+ // if (softirq == null) {
+ // return true;
+ // }
+ //
+ // // String submode;
+ // // String[] softIrqNames = traceSt.getSoft_irq_names();
+ // // if (softirq < softIrqNames.length) {
+ // // submode = softIrqNames[softirq];
+ // // } else {
+ // // submode = "softirq " + softirq;
+ // // }
+ //
+ // /* update softirq status */
+ // /* a soft irq raises are not cumulative */
+ // LttngSoftIRQState irqState =
+ // traceSt.getSoft_irq_states().get(
+ // softirq);
+ // if (irqState != null) {
+ // irqState.setPending(1L);
+ // } else {
+ // TraceDebug
+ // .debug("unexpected soft irq id value: " + softirq);
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getSoftIrqEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFT_IRQ_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // obtrain cpu
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // // get event field
+ // Long softirq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SOFT_IRQ_ID);
+ //
+ // if (softirq == null) {
+ // return true;
+ // }
+ //
+ // // obtain submode
+ // Map<Long, String> softIrqNames = traceSt.getSoft_irq_names();
+ // String submode = softIrqNames.get(softirq);
+ // if (submode == null) {
+ // submode = "softirq " + softirq;
+ // softIrqNames.put(softirq, submode);
+ // }
+ //
+ // /* update softirq status */
+ // LttngSoftIRQState irqState =
+ // traceSt.getSoft_irq_states().get(
+ // softirq);
+ // if (irqState != null) {
+ // irqState.decrementPending();
+ // irqState.incrementRunning();
+ // } else {
+ // TraceDebug
+ // .debug("unexpected soft irq id value: " + softirq);
+ // }
+ //
+ // /* update cpu state */
+ // LTTngCPUState cpu_state = traceSt.getCpu_states().get(cpu);
+ // cpu_state.setLast_soft_irq(softirq);
+ // cpu_push_mode(cpu_state, CpuMode.LTTV_CPU_SOFT_IRQ);
+ //
+ // /* update process execution mode state stack */
+ // push_state(cpu, ExecutionMode.LTTV_STATE_SOFT_IRQ, submode,
+ // trcEvent.getTimestamp(), traceSt);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Method to handle the event: LTT_EVENT_LIST_INTERRRUPT
+ *
+ * @return
+ */
+ final IEventProcessing getEnumInterruptHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_LIST_INTERRUPT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // String action = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_ACTION);
+ // Long irq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_IRQ_ID);
+ //
+ // Map<Long, String> irq_names = traceSt.getIrq_names();
+ //
+ // irq_names.put(irq, action);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Handle the event LTT_EVENT_REQUEST_ISSUE
+ *
+ * @return
+ */
+ final IEventProcessing getBdevRequestIssueHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_REQUEST_ISSUE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Get Fields
+ // Long major = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MAJOR);
+ // Long minor = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MINOR);
+ // Long operation = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_OPERATION);
+ //
+ // // calculate bdevcode
+ // Long devcode = mkdev(major, minor);
+ //
+ // if (devcode == null) {
+ // TraceDebug
+ // .debug("incorrect calcualtion of bdevcode input( major: "
+ // + major
+ // + " minor: "
+ // + minor
+ // + " operation: " + operation);
+ // return true;
+ // }
+ //
+ // Map<Long, LttngBdevState> bdev_states = traceSt
+ // .getBdev_states();
+ // // Get the instance
+ // LttngBdevState bdevState = bdev_states.get(devcode);
+ // if (bdevState == null) {
+ // bdevState = new LttngBdevState();
+ // }
+ //
+ // // update the mode in the stack
+ // if (operation == 0L) {
+ // bdevState.getMode_stack().push(
+ // BdevMode.LTTV_BDEV_BUSY_READING);
+ // } else {
+ // bdevState.getMode_stack().push(
+ // BdevMode.LTTV_BDEV_BUSY_WRITING);
+ // }
+ //
+ // // make sure it is included in the set
+ // bdev_states.put(devcode, bdevState);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handling event: LTT_EVENT_REQUEST_COMPLETE
+ * </p>
+ * <p>
+ * FIELDS(LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getBdevRequestCompleteHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_REQUEST_COMPLETE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Get Fields
+ // Long major = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MAJOR);
+ // Long minor = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MINOR);
+ // Long operation = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_OPERATION);
+ //
+ // // calculate bdevcode
+ // Long devcode = mkdev(major, minor);
+ //
+ // if (devcode == null) {
+ // TraceDebug
+ // .debug("incorrect calcualtion of bdevcode input( major: "
+ // + major
+ // + " minor: "
+ // + minor
+ // + " operation: " + operation);
+ // return true;
+ // }
+ //
+ // Map<Long, LttngBdevState> bdev_states = traceSt
+ // .getBdev_states();
+ // // Get the instance
+ // LttngBdevState bdevState = bdev_states.get(devcode);
+ // if (bdevState == null) {
+ // bdevState = new LttngBdevState();
+ // }
+ //
+ // /* update block device */
+ // bdev_pop_mode(bdevState);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles event: LTT_EVENT_FUNCTION_ENTRY
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getFunctionEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_FUNCTION_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // Long cpu = trcEvent.getCpuId();
+ // Long funcptr = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_THIS_FN);
+ //
+ // push_function(traceSt, funcptr, cpu);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getFunctionExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_FUNCTION_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long funcptr = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_THIS_FN);
+ //
+ // pop_function(traceSt, trcEvent, funcptr);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * process event: LTT_EVENT_SYS_CALL_TABLE
+ * </p>
+ * <p>
+ * fields: LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getDumpSyscallHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SYS_CALL_TABLE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // // obtain the syscall id
+ // Long id = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_ID);
+ //
+ // // Long address = getAFieldLong(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_ADDRESS);
+ //
+ // // Obtain the symbol
+ // String symbol = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SYMBOL);
+ //
+ // // fill the symbol to the sycall_names collection
+ // traceSt.getSyscall_names().put(id, symbol);
+
+ return false;
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles event: LTT_EVENT_KPROBE_TABLE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_IP, LTT_FIELD_SYMBOL
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getDumpKprobeHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_KPROBE_TABLE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long ip = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_IP);
+ // String symbol = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SYMBOL);
+ //
+ // traceSt.getKprobe_table().put(ip, symbol);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_SOFTIRQ_VEC
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getDumpSoftIrqHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFTIRQ_VEC;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Get id
+ // Long id = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_ID);
+ //
+ // // Address not needed
+ // // Long address = ltt_event_get_long_unsigned(e,
+ // // lttv_trace_get_hook_field(th,
+ // // 1));
+ //
+ // // Get symbol
+ // String symbol = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SYMBOL);
+ //
+ // // Register the soft irq name
+ // traceSt.getSoft_irq_names().put(id, symbol);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_SCHED_SCHEDULE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getSchedChangeHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SCHED_SCHEDULE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // TmfTimestamp eventTime = trcEvent.getTimestamp();
+ //
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ //
+ // Long pid_out = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PREV_PID);
+ // Long pid_in = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_NEXT_PID);
+ // Long state_out = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PREV_STATE);
+ //
+ // if (process != null) {
+ //
+ // /*
+ // * We could not know but it was not the idle process
+ // * executing. This should only happen at the beginning,
+ // * before the first schedule event, and when the initial
+ // * information (current process for each CPU) is missing. It
+ // * is not obvious how we could, after the fact, compensate
+ // * the wrongly attributed statistics.
+ // */
+ //
+ // // This test only makes sense once the state is known and if
+ // // there
+ // // is no
+ // // missing events. We need to silently ignore schedchange
+ // // coming
+ // // after a
+ // // process_free, or it causes glitches. (FIXME)
+ // // if(unlikely(process->pid != pid_out)) {
+ // // g_assert(process->pid == 0);
+ // // }
+ // if (process.getPid() == 0
+ // && process.getState().getExec_mode() ==
+ // ExecutionMode.LTTV_STATE_MODE_UNKNOWN) {
+ // if (pid_out == 0) {
+ // /*
+ // * Scheduling out of pid 0 at beginning of the trace
+ // * : we know for sure it is in syscall mode at this
+ // * point.
+ // */
+ // int stackSize = process.getExecution_stack().size();
+ // if (stackSize != 1) {
+ // TraceDebug
+ // .debug("unpexpected process execution stack size, expected 1, received: ");
+ // }
+ //
+ // process.getState().setExec_mode(
+ // ExecutionMode.LTTV_STATE_SYSCALL);
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_WAIT);
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // process.getState().setEntry_Time(
+ // trcEvent.getTimestamp());
+ // }
+ // } else {
+ // if (process.getState().getProc_status() ==
+ // ProcessStatus.LTTV_STATE_EXIT) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_ZOMBIE);
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // } else {
+ // if (state_out == 0L) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_WAIT_CPU);
+ // } else {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_WAIT);
+ // }
+ //
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // }
+ //
+ // if (state_out == 32L || state_out == 64L) { /*
+ // * EXIT_DEAD
+ // * ||
+ // * TASK_DEAD
+ // */
+ // /* see sched.h for states */
+ // if (!exit_process(traceSt, process)) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_DEAD);
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // }
+ // }
+ // }
+ // }
+ // process = lttv_state_find_process_or_create(traceSt, cpu,
+ // pid_in, eventTime);
+ //
+ // traceSt.getRunning_process().put(cpu, process);
+ //
+ // process.getState().setProc_status(ProcessStatus.LTTV_STATE_RUN);
+ // process.getState().setChage_Time(eventTime);
+ // process.setCpu(cpu);
+ // // process->state->s = LTTV_STATE_RUN;
+ // // if(process->usertrace)
+ // // process->usertrace->cpu = cpu;
+ // // process->last_cpu_index =
+ // // ltt_tracefile_num(((LttvTracefileContext*)s)->tf);
+ //
+ // // process->state->change = s->parent.timestamp;
+ //
+ // LTTngCPUState cpu_state = traceSt.getCpu_states().get(cpu);
+ // /* update cpu status */
+ // if (pid_in == 0) {
+ //
+ // /* going to idle task */
+ // cpu_set_base_mode(cpu_state, CpuMode.LTTV_CPU_IDLE);
+ // } else {
+ // /*
+ // * scheduling a real task. we must be careful here: if we
+ // * just schedule()'ed to a process that is in a trap, we
+ // * must put the cpu in trap mode
+ // */
+ // cpu_set_base_mode(cpu_state, CpuMode.LTTV_CPU_BUSY);
+ // if (process.getState().getExec_mode() ==
+ // ExecutionMode.LTTV_STATE_TRAP) {
+ // cpu_push_mode(cpu_state, CpuMode.LTTV_CPU_TRAP);
+ // }
+ // }
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_FORK
+ * </p>
+ * <p>
+ * Fields: FIELD_ARRAY(LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID,
+ * LTT_FIELD_CHILD_TGID)
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessForkHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_FORK;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ // TmfTimestamp timeStamp = trcEvent.getTimestamp();
+ //
+ // // /* Parent PID */
+ // // Long parent_pid = getAFieldLong(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_PARENT_PID);
+ //
+ // /* Child PID */
+ // /* In the Linux Kernel, there is one PID per thread. */
+ // Long child_pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_CHILD_PID);
+ //
+ // /* Child TGID */
+ // /* tgid in the Linux kernel is the "real" POSIX PID. */
+ // Long child_tgid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_CHILD_TGID);
+ // if (child_tgid == null) {
+ // child_tgid = 0L;
+ // }
+ //
+ // /*
+ // * Mathieu : it seems like the process might have been
+ // scheduled
+ // * in before the fork, and, in a rare case, might be the
+ // current
+ // * process. This might happen in a SMP case where we don't
+ // have
+ // * enough precision on the clocks.
+ // *
+ // * Test reenabled after precision fixes on time. (Mathieu)
+ // */
+ // // #if 0
+ // // zombie_process = lttv_state_find_process(ts, ANY_CPU,
+ // // child_pid);
+ // //
+ // // if(unlikely(zombie_process != NULL)) {
+ // // /* Reutilisation of PID. Only now we are sure that the old
+ // // PID
+ // // * has been released. FIXME : should know when release_task
+ // // happens
+ // // instead.
+ // // */
+ // // guint num_cpus = ltt_trace_get_num_cpu(ts->parent.t);
+ // // guint i;
+ // // for(i=0; i< num_cpus; i++) {
+ // // g_assert(zombie_process != ts->running_process[i]);
+ // // }
+ // //
+ // // exit_process(s, zombie_process);
+ // // }
+ // // #endif //0
+ //
+ // if (process.getPid() == child_pid) {
+ // TraceDebug
+ // .debug("Unexpected, process pid equal to child pid: "
+ // + child_pid
+ // + " Event Time: "
+ // + trcEvent.getTimestamp());
+ // }
+ //
+ // // g_assert(process->pid != child_pid);
+ // // FIXME : Add this test in the "known state" section
+ // // g_assert(process->pid == parent_pid);
+ // LttngProcessState child_process = lttv_state_find_process(
+ // traceSt, ANY_CPU, child_pid);
+ // if (child_process == null) {
+ // child_process = create_process(traceSt, cpu, child_pid,
+ // child_tgid, timeStamp);
+ // } else {
+ // /*
+ // * The process has already been created : due to time
+ // * imprecision between multiple CPUs : it has been scheduled
+ // * in before creation. Note that we shouldn't have this kind
+ // * of imprecision.
+ // *
+ // * Simply put a correct parent.
+ // */
+ // StringBuilder sb = new StringBuilder("Process " + child_pid);
+ // sb.append(" has been created at ["
+ // + child_process.getCration_time() + "] ");
+ // sb.append("and inserted at ["
+ // + child_process.getInsertion_time() + "] ");
+ // sb.append("before \nfork on cpu " + cpu + " Event time: ["
+ // + trcEvent + "]\n.");
+ // sb
+ // .append("Probably an unsynchronized TSD problem on the traced machine.");
+ // TraceDebug.debug(sb.toString());
+ //
+ // // g_assert(0); /* This is a problematic case : the process
+ // // has
+ // // beencreated
+ // // before the fork event */
+ // child_process.setPpid(process.getPid());
+ // child_process.setTgid(child_tgid);
+ // }
+ //
+ // if (!child_process.getName().equals(
+ // ProcessStatus.LTTV_STATE_UNNAMED.getInName())) {
+ // TraceDebug.debug("Unexpected child process status: "
+ // + child_process.getName());
+ // }
+ //
+ // child_process.setName(process.getName());
+ // child_process.setBrand(process.getBrand());
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_KTHREAD_CREATE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_PID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessKernelThreadHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_KTHREAD_CREATE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // /*
+ // * We stamp a newly created process as kernel_thread. The
+ // thread
+ // * should not be running yet.
+ // */
+ //
+ // LttngExecutionState exState;
+ // Long pid;
+ // LttngProcessState process;
+ //
+ // /* PID */
+ // pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID);
+ // // s->parent.target_pid = pid;
+ //
+ // process = lttv_state_find_process_or_create(traceSt, ANY_CPU,
+ // pid, new TmfTimestamp());
+ //
+ // if (!process.getState().getProc_status().equals(
+ // ProcessStatus.LTTV_STATE_DEAD)) {
+ // // Leave only the first element in the stack with execution
+ // // mode to
+ // // syscall
+ // Stack<LttngExecutionState> processExStack = process
+ // .getExecution_stack();
+ // exState = processExStack.firstElement();
+ // exState.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
+ // if (processExStack.size() > 1) {
+ // processExStack.clear();
+ // processExStack.add(exState);
+ // }
+ //
+ // // update the process state to the only one in the stack
+ // process.setState(exState);
+ // }
+ //
+ // process.setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_EXIT
+ * </p>
+ * <p>
+ * LTT_FIELD_PID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long pid;
+ // LttngProcessState process;
+ //
+ // pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PID);
+ // // s->parent.target_pid = pid;
+ //
+ // // FIXME : Add this test in the "known state" section
+ // // g_assert(process->pid == pid);
+ //
+ // process = lttv_state_find_process(traceSt, ANY_CPU, pid);
+ // if (process != null) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_EXIT);
+ // }
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_FREE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_PID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessFreeHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_FREE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long release_pid;
+ // LttngProcessState process;
+ //
+ // /* PID of the process to release */
+ // release_pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PID);
+ // // s->parent.target_pid = release_pid;
+ //
+ // if (release_pid == 0) {
+ // TraceDebug.debug("Unexpected release_pid: 0, Event time: "
+ // + trcEvent.getTimestamp());
+ // }
+ //
+ // process = lttv_state_find_process(traceSt, ANY_CPU,
+ // release_pid);
+ // if (process != null) {
+ // exit_process(traceSt, process);
+ // }
+
+ return false;
+ // DISABLED
+ // if(process != null) {
+ /*
+ * release_task is happening at kernel level : we can now safely
+ * release the data structure of the process
+ */
+ // This test is fun, though, as it may happen that
+ // at time t : CPU 0 : process_free
+ // at time t+150ns : CPU 1 : schedule out
+ // Clearly due to time imprecision, we disable it. (Mathieu)
+ // If this weird case happen, we have no choice but to put the
+ // Currently running process on the cpu to 0.
+ // I re-enable it following time precision fixes. (Mathieu)
+ // Well, in the case where an process is freed by a process on
+ // another
+ // CPU
+ // and still scheduled, it happens that this is the schedchange
+ // that
+ // will
+ // drop the last reference count. Do not free it here!
+
+ // int num_cpus = ltt_trace_get_num_cpu(ts->parent.t);
+ // guint i;
+ // for(i=0; i< num_cpus; i++) {
+ // //g_assert(process != ts->running_process[i]);
+ // if(process == ts->running_process[i]) {
+ // //ts->running_process[i] = lttv_state_find_process(ts, i, 0);
+ // break;
+ // }
+ // }
+ // if(i == num_cpus) /* process is not scheduled */
+ // exit_process(s, process);
+ // }
+ //
+ // return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_EXEC
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_FILENAME
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessExecHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_EXEC;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ //
+ // // #if 0//how to use a sequence that must be transformed in a
+ // // string
+ // // /* PID of the process to release */
+ // // guint64 name_len = ltt_event_field_element_number(e,
+ // // lttv_trace_get_hook_field(th, 0));
+ // // //name = ltt_event_get_string(e,
+ // // lttv_trace_get_hook_field(th, 0));
+ // // LttField *child = ltt_event_field_element_select(e,
+ // // lttv_trace_get_hook_field(th, 0), 0);
+ // // gchar *name_begin =
+ // // (gchar*)(ltt_event_data(e)+ltt_event_field_offset(e,
+ // child));
+ // // gchar *null_term_name = g_new(gchar, name_len+1);
+ // // memcpy(null_term_name, name_begin, name_len);
+ // // null_term_name[name_len] = '\0';
+ // // process->name = g_quark_from_string(null_term_name);
+ // // #endif //0
+ //
+ // process.setName(getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_FILENAME));
+ // process.setBrand(StateStrings.LTTV_STATE_UNBRANDED);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * LTT_EVENT_THREAD_BRAND
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_NAME
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing GetThreadBrandHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_THREAD_BRAND;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // String name;
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ //
+ // name = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_NAME);
+ // process.setBrand(name);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * @return
+ */
+ final IEventProcessing getStateDumpEndHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_STATEDUMP_END;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // /* For all processes */
+ // /*
+ // * if kernel thread, if stack[0] is unknown, set to syscall
+ // * mode, wait
+ // */
+ // /* else, if stack[0] is unknown, set to user mode, running */
+ // List<LttngProcessState> processes = traceSt.getProcesses();
+ // TmfTimestamp time = trcEvent.getTimestamp();
+ //
+ // for (LttngProcessState process : processes) {
+ // fix_process(process, time);
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Private method used to establish the first execution state in the stack
+ * for a given process
+ *
+ * @param process
+ * @param timestamp
+ */
+ // private void fix_process(LttngProcessState process,
+ // TmfTimestamp timestamp) {
+ //
+ // LttngExecutionState es;
+ // Stack<LttngExecutionState> procStack = process
+ // .getExecution_stack();
+ //
+ // if (process.getType() == ProcessType.LTTV_STATE_KERNEL_THREAD) {
+ // es = procStack.firstElement();
+ //
+ // if (es.getExec_mode() == ExecutionMode.LTTV_STATE_MODE_UNKNOWN) {
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
+ // .getInName());
+ // es.setEntry_Time(timestamp);
+ // es.setChage_Time(timestamp);
+ // es.setCum_cpu_time(0L);
+ // if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
+ // es.setProc_status(ProcessStatus.LTTV_STATE_WAIT);
+ // }
+ // }
+ // } else {
+ // es = procStack.firstElement();
+ // if (es.getExec_mode() == ExecutionMode.LTTV_STATE_MODE_UNKNOWN) {
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_USER_MODE);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
+ // .getInName());
+ // es.setEntry_Time(timestamp);
+ // es.setChage_Time(timestamp);
+ // es.setCum_cpu_time(0L);
+ // if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
+ // es.setProc_status(ProcessStatus.LTTV_STATE_RUN);
+ // }
+ //
+ // if (procStack.size() == 1) {
+ // /*
+ // * Still in bottom unknown mode, means never did a
+ // * system call May be either in user mode, syscall
+ // * mode, running or waiting.
+ // */
+ // /*
+ // * FIXME : we may be tagging syscall mode when being
+ // * user mode
+ // */
+ // // Get a new execution State
+ // es = new LttngExecutionState();
+ //
+ // // initialize values
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
+ // .getInName());
+ // es.setEntry_Time(timestamp);
+ // es.setChage_Time(timestamp);
+ // es.setCum_cpu_time(0L);
+ // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED);
+ //
+ // // Push the new state to the stack
+ // procStack.push(es);
+ // }
+ // }
+ // }
+ // }
+ // };
+ // return handler;
+ // }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_STATE
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
+ * LTT_FIELD_TYPE, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, LTT_FIELD_STATUS,
+ * LTT_FIELD_TGID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getEnumProcessStateHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_STATE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long parent_pid;
+ // Long pid;
+ // Long tgid;
+ // String command;
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ // LttngProcessState parent_process;
+ // String type;
+ // // String mode, submode, status;
+ // LttngExecutionState es;
+ //
+ // /* PID */
+ // pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID);
+ //
+ // /* Parent PID */
+ // parent_pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PARENT_PID);
+ //
+ // /* Command name */
+ // command = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_NAME);
+ //
+ // /* TODO: type field, Values need to be verified */
+ // /* type */
+ // Long typeVal = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_TYPE);
+ // if (typeVal == 0L) {
+ // type = ProcessType.LTTV_STATE_KERNEL_THREAD.getInName();
+ // } else {
+ // type = ProcessType.LTTV_STATE_USER_THREAD.getInName();
+ // }
+ //
+ // // FIXME: type is rarely used, enum must match possible
+ // types.
+ //
+ // // /* mode */
+ // // mode = getAFieldString(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_MODE);
+ // //
+ // // /* submode */
+ // // submode = getAFieldString(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_SUBMODE);
+ // //
+ // // /* status */
+ // // status = getAFieldString(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_STATUS);
+ //
+ // /* TGID */
+ // tgid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_TGID);
+ // if (tgid == null) {
+ // tgid = 0L;
+ // }
+ //
+ // if (pid == 0) {
+ // for (Long acpu : traceSt.getCpu_states().keySet()) {
+ // process = lttv_state_find_process(traceSt, acpu, pid);
+ // if (process != null) {
+ // process.setPpid(parent_pid);
+ // process.setTgid(tgid);
+ // process.setName(command);
+ // process
+ // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+ // } else {
+ // StringBuilder sb = new StringBuilder(
+ // "Unexpected, null process read from the TraceState list of processes, event time: "
+ // + trcEvent.getTimestamp());
+ // TraceDebug.debug(sb.toString());
+ // }
+ // }
+ // } else {
+ // /*
+ // * The process might exist if a process was forked while
+ // * performing the state dump.
+ // */
+ // process = lttv_state_find_process(traceSt, ANY_CPU, pid);
+ // if (process == null) {
+ // parent_process = lttv_state_find_process(traceSt,
+ // ANY_CPU, parent_pid);
+ // process = create_process(traceSt, cpu, pid, tgid,
+ // command, trcEvent.getTimestamp());
+ // if (parent_process != null) {
+ // process.setPpid(parent_process.getPid());
+ // }
+ //
+ // /* Keep the stack bottom : a running user mode */
+ // /*
+ // * Disabled because of inconsistencies in the current
+ // * statedump states.
+ // */
+ // if (type.equals(ProcessType.LTTV_STATE_KERNEL_THREAD
+ // .getInName())) {
+ // /*
+ // * FIXME Kernel thread : can be in syscall or
+ // * interrupt or trap.
+ // */
+ // /*
+ // * Will cause expected trap when in fact being
+ // * syscall (even after end of statedump event) Will
+ // * cause expected interrupt when being syscall.
+ // * (only before end of statedump event)
+ // */
+ // process
+ // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+ //
+ // // #if 0
+ // // es->t = LTTV_STATE_SYSCALL;
+ // // es->s = status;
+ // // es->n = submode;
+ // // #endif //0
+ // } else {
+ // /*
+ // * User space process : bottom : user mode either
+ // * currently running or scheduled out. can be
+ // * scheduled out because interrupted in (user mode
+ // * or in syscall) or because of an explicit call to
+ // * the scheduler in syscall. Note that the scheduler
+ // * call comes after the irq_exit, so never in
+ // * interrupt context.
+ // */
+ // // temp workaround : set size to 1 : only have user
+ // // mode
+ // // bottom of stack.
+ // // will cause g_info message of expected syscall
+ // // mode when
+ // // in fact being
+ // // in user mode. Can also cause expected trap when
+ // // in fact
+ // // being user
+ // // mode in the event of a page fault reenabling
+ // // interrupts
+ // // in the handler.
+ // // Expected syscall and trap can also happen after
+ // // the end
+ // // of statedump
+ // // This will cause a
+ // // "popping last state on stack, ignoring it."
+ //
+ // // process->execution_stack =
+ // // g_array_set_size(process->execution_stack, 1);
+ // // es = process->state =
+ // // &g_array_index(process->execution_stack,
+ // // LttvExecutionState, 0);
+ // // a new process must have only one state in the
+ // // stack and
+ // // be the same as the current state
+ // // es = process.getState();
+ // // es.setExec_mode(ExecutionMode.LTTV_STATE_MODE_UNKNOWN);
+ // // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED);
+ // // es
+ // //
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN
+ // // .getInName());
+ //
+ // // #if 0
+ // // es->t = LTTV_STATE_USER_MODE;
+ // // es->s = status;
+ // // es->n = submode;
+ // // #endif //0
+ // }
+ // // TODO: clean up comments above: Moved repeated code
+ // // from both
+ // // if / else blocks above,
+ // // comments left temporarily for easier visualization
+ // // and
+ // // comparision with c code
+ // es = process.getState();
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_MODE_UNKNOWN);
+ // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN
+ // .getInName());
+ // // #if 0
+ // // /* UNKNOWN STATE */
+ // // {
+ // // es = process->state =
+ // // &g_array_index(process->execution_stack,
+ // // LttvExecutionState, 1);
+ // // es->t = LTTV_STATE_MODE_UNKNOWN;
+ // // es->s = LTTV_STATE_UNNAMED;
+ // // es->n = LTTV_STATE_SUBMODE_UNKNOWN;
+ // // }
+ // // #endif //0
+ // } else {
+ // /*
+ // * The process has already been created : Probably was
+ // * forked while dumping the process state or was simply
+ // * scheduled in prior to get the state dump event.
+ // */
+ // process.setPpid(parent_pid);
+ // process.setTgid(tgid);
+ // process.setName(command);
+ // if (type.equals(ProcessType.LTTV_STATE_KERNEL_THREAD
+ // .getInName())) {
+ // process
+ // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+ // } else {
+ // process.setType(ProcessType.LTTV_STATE_USER_THREAD);
+ // }
+ //
+ // // es =
+ // // &g_array_index(process->execution_stack,
+ // // LttvExecutionState,
+ // // 0);
+ // // #if 0
+ // // if(es->t == LTTV_STATE_MODE_UNKNOWN) {
+ // // if(type == LTTV_STATE_KERNEL_THREAD)
+ // // es->t = LTTV_STATE_SYSCALL;
+ // // else
+ // // es->t = LTTV_STATE_USER_MODE;
+ // // }
+ // // #endif //0
+ // /*
+ // * Don't mess around with the stack, it will eventually
+ // * become ok after the end of state dump.
+ // */
+ // }
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng.state.handlers.before;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.linuxtools.lttng.state.StateStrings;
+import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
+
+/**
+ * Builds a Map from string event name to a processing handler object, the
+ * processors implement the same interface to facilitate transparent methods
+ * call,
+ *
+ * The map key STring is the entry point of the raw events, using a hash speeds
+ * up the resolution of the appropriate processor
+ *
+ * @author alvaro
+ *
+ */
+public class StateBeforeUpdateFactory {
+ // ========================================================================
+ // Data
+ // =======================================================================
+ private final Map<String, IEventProcessing> eventNametoProcessor = new HashMap<String, IEventProcessing>();
+ private static StateBeforeUpdateFactory instance = null;
+ private StateBeforeUpdateHandlers instantiateHandler = new StateBeforeUpdateHandlers();
+
+ // ========================================================================
+ // Constructors
+ // =======================================================================
+ private StateBeforeUpdateFactory() {
+ //create one instance of each individual event handler and add the instance to the map
+ eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_ENTRY
+ .getInName(), instantiateHandler.getSyscallEntryHandler());
+
+ eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_EXIT
+ .getInName(), instantiateHandler.getsySyscallExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
+// .getInName(), instantiateHandler.getTrapEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT
+// .getInName(), instantiateHandler.getTrapExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY
+// .getInName(), instantiateHandler.getTrapEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT
+// .getInName(), instantiateHandler.getTrapExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
+// .getInName(), instantiateHandler.getTrapEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
+// .getInName(), instantiateHandler.getTrapExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
+// .getInName(), instantiateHandler.getIrqEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT
+// .getInName(), instantiateHandler.getIrqExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE
+// .getInName(), instantiateHandler.getSoftIrqRaiseHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY
+// .getInName(), instantiateHandler.getSoftIrqEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT
+// .getInName(), instantiateHandler.getSoftIrqExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_LIST_INTERRUPT
+// .getInName(), instantiateHandler.getEnumInterruptHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_ISSUE
+// .getInName(), instantiateHandler.getBdevRequestIssueHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE
+// .getInName(), instantiateHandler.getBdevRequestCompleteHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_ENTRY
+// .getInName(), instantiateHandler.getFunctionEntryHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_EXIT
+// .getInName(), instantiateHandler.getFunctionExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYS_CALL_TABLE
+// .getInName(), instantiateHandler.getDumpSyscallHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KPROBE_TABLE
+// .getInName(), instantiateHandler.getDumpKprobeHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFTIRQ_VEC
+// .getInName(), instantiateHandler.getDumpSoftIrqHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE
+// .getInName(), instantiateHandler.getSchedChangeHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FORK
+// .getInName(), instantiateHandler.getProcessForkHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KTHREAD_CREATE
+// .getInName(), instantiateHandler.getProcessKernelThreadHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_EXIT
+// .getInName(), instantiateHandler.getProcessExitHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FREE
+// .getInName(), instantiateHandler.getProcessFreeHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_EXEC
+// .getInName(), instantiateHandler.getProcessExecHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_THREAD_BRAND
+// .getInName(), instantiateHandler.GetThreadBrandHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_STATEDUMP_END
+// .getInName(), instantiateHandler.getStateDumpEndHandler());
+//
+// eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_STATE
+// .getInName(), instantiateHandler.getEnumProcessStateHandler());
+
+
+ }
+
+ // ========================================================================
+ // Public methods
+ // =======================================================================
+ /**
+ * The event processors are common to all traces an multiple instances will
+ * use more memory unnecessarily
+ *
+ * @return
+ */
+ public static StateBeforeUpdateFactory getInstance() {
+ if (instance == null) {
+ instance = new StateBeforeUpdateFactory();
+ }
+ return instance;
+ }
+
+ /**
+ *
+ * @return The Event Handler corresponding to the type of event
+ */
+ public IEventProcessing getEventNametoProcessor(String eventType) {
+ return eventNametoProcessor.get(eventType);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng.state.handlers.before;
+
+import org.eclipse.linuxtools.lttng.TraceDebug;
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
+import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode;
+import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionSubMode;
+import org.eclipse.linuxtools.lttng.state.StateStrings.Fields;
+import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
+import org.eclipse.linuxtools.lttng.state.handlers.AbsStateUpdate;
+import org.eclipse.linuxtools.lttng.state.model.LttngExecutionState;
+import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+
+/**
+ * Process the system call entry event
+ *
+ * @author alvaro
+ *
+ */
+class StateBeforeUpdateHandlers {
+
+ final IEventProcessing getSyscallEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SYSCALL_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // TraceDebug.debug("Before event called");
+ //
+ Long cpu = trcEvent.getCpuId();
+
+ // No syscall_entry update for initialization process
+ LttngProcessState process = traceSt.getRunning_process().get(
+ cpu);
+
+ pid = process.getPid();
+ if (pid == 0L) {
+ return true;
+ }
+
+ // Get the expected event field
+ Long syscall = getAFieldLong(trcEvent, traceSt,
+ Fields.LTT_FIELD_SYSCALL_ID);
+ if (syscall == null) {
+ TraceDebug.debug("Syscall Field not found in Event: "
+ + trcEvent.getMarkerName());
+ return true;
+ }
+
+ String submode = traceSt.getSyscall_names().get(syscall);
+
+ if (submode == null) {
+ TraceDebug.debug("Submode not found in Event");
+ submode = ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN
+ .getInName();
+ }
+
+ exState = new LttngExecutionState();
+ exState.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
+ exState.setExec_submode(submode);
+ exState.setEntry_Time(trcEvent.getTimestamp());
+ exState.setChange_Time(trcEvent.getTimestamp());
+ exState.setCum_cpu_time(0L);
+
+ return false;
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ final IEventProcessing getsySyscallExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SYSCALL_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+
+ Long cpu = trcEvent.getCpuId();
+ LttngProcessState process = traceSt.getRunning_process().get(
+ cpu);
+
+ /* There can be no system call from PID 0 : unknown state */
+ pid = process.getPid();
+ if (pid == 0L) {
+ return true;
+ }
+
+ // pop_state(cpu, StateStrings.ExecutionMode.LTTV_STATE_SYSCALL,
+ // traceSt, trcEvent.getTimestamp());
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Update stacks related to the parsing of an LttngEvent
+ *
+ * @return
+ */
+ final IEventProcessing getTrapEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_TRAP_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // Long trap = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_TRAP_ID);
+ // if (trap == null) {
+ // return true;
+ // }
+ //
+ // String submode = traceSt.getSyscall_names()
+ // .get(trap);
+ //
+ // if (submode == null) {
+ // submode = ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN
+ // .getInName();
+ // }
+ //
+ // /* update process state */
+ // push_state(cpu, StateStrings.ExecutionMode.LTTV_STATE_TRAP,
+ // submode, trcEvent.getTimestamp(), traceSt);
+ //
+ // /* update cpu status */
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // cpu_push_mode(cpust, StateStrings.CpuMode.LTTV_CPU_TRAP);
+ // cpust.setLast_trap(trap); /* update trap status */
+ //
+ // // update Trap State
+ // LttngTrapState trap_state = traceSt.getTrap_states().get(
+ // trap);
+ // trap_state.incrementRunning();
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getTrapExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_TRAP_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // Long trap = cpust.getLast_trap();
+ //
+ // pop_state(cpu, ExecutionMode.LTTV_STATE_TRAP, traceSt,
+ // trcEvent
+ // .getTimestamp());
+ //
+ // /* update cpu status */
+ // cpu_pop_mode(cpust);
+ //
+ // /* update trap status */
+ // if (trap != -1L) {
+ // traceSt.getTrap_states().get(trap).decrementRunning();
+ // }
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getIrqEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_IRQ_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // Long irq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_IRQ_ID);
+ // if (irq == null) {
+ // return true;
+ // }
+ //
+ // String submode;
+ // submode = traceSt.getIrq_names().get(irq);
+ //
+ // if (submode == null) {
+ // submode =
+ // ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN.getInName();
+ // }
+ //
+ // /*
+ // * Do something with the info about being in user or system
+ // mode
+ // * when int?
+ // */
+ // push_state(cpu, ExecutionMode.LTTV_STATE_IRQ, submode,
+ // trcEvent
+ // .getTimestamp(), traceSt);
+ //
+ // /* update cpu state */
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // cpu_push_mode(cpust, CpuMode.LTTV_CPU_IRQ); /* mode stack */
+ // cpust.setLast_irq(irq); /* last irq */
+ //
+ // /* udpate irq state */
+ // irq_push_mode(traceSt.getIrq_states().get(irq),
+ // IRQMode.LTTV_IRQ_BUSY);
+ return false;
+
+ }
+
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getSoftIrqExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFT_IRQ_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // Long softirq = cpust.getLast_soft_irq();
+ // pop_state(cpu, ExecutionMode.LTTV_STATE_SOFT_IRQ, traceSt,
+ // trcEvent.getTimestamp());
+ //
+ // /* update softirq status */
+ // if (softirq != -1) {
+ // LttngSoftIRQState softIrqstate = traceSt
+ // .getSoft_irq_states().get(softirq);
+ // softIrqstate.decrementRunning();
+ // }
+ //
+ // /* update cpu status */
+ // cpu_pop_mode(cpust);
+
+ return false;
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getIrqExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_IRQ_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // /* update process state */
+ // pop_state(cpu, ExecutionMode.LTTV_STATE_IRQ, traceSt,
+ // trcEvent
+ // .getTimestamp());
+ //
+ // /* update cpu status */
+ // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu);
+ // cpu_pop_mode(cpust);
+ //
+ // /* update irq status */
+ // Long last_irq = cpust.getLast_irq();
+ // if (last_irq != -1L) {
+ // LttngIRQState irq_state = traceSt.getIrq_states().get(
+ // last_irq);
+ // irq_pop_mode(irq_state);
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getSoftIrqRaiseHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFT_IRQ_RAISE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Long cpu = trcEvent.getCpuId();
+ //
+ // // get event field
+ // Long softirq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SOFT_IRQ_ID);
+ //
+ // if (softirq == null) {
+ // return true;
+ // }
+ //
+ // // String submode;
+ // // String[] softIrqNames = traceSt.getSoft_irq_names();
+ // // if (softirq < softIrqNames.length) {
+ // // submode = softIrqNames[softirq];
+ // // } else {
+ // // submode = "softirq " + softirq;
+ // // }
+ //
+ // /* update softirq status */
+ // /* a soft irq raises are not cumulative */
+ // LttngSoftIRQState irqState =
+ // traceSt.getSoft_irq_states().get(
+ // softirq);
+ // if (irqState != null) {
+ // irqState.setPending(1L);
+ // } else {
+ // TraceDebug
+ // .debug("unexpected soft irq id value: " + softirq);
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getSoftIrqEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFT_IRQ_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // obtrain cpu
+ // Long cpu = trcEvent.getCpuId();
+ //
+ // // get event field
+ // Long softirq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SOFT_IRQ_ID);
+ //
+ // if (softirq == null) {
+ // return true;
+ // }
+ //
+ // // obtain submode
+ // Map<Long, String> softIrqNames = traceSt.getSoft_irq_names();
+ // String submode = softIrqNames.get(softirq);
+ // if (submode == null) {
+ // submode = "softirq " + softirq;
+ // softIrqNames.put(softirq, submode);
+ // }
+ //
+ // /* update softirq status */
+ // LttngSoftIRQState irqState =
+ // traceSt.getSoft_irq_states().get(
+ // softirq);
+ // if (irqState != null) {
+ // irqState.decrementPending();
+ // irqState.incrementRunning();
+ // } else {
+ // TraceDebug
+ // .debug("unexpected soft irq id value: " + softirq);
+ // }
+ //
+ // /* update cpu state */
+ // LTTngCPUState cpu_state = traceSt.getCpu_states().get(cpu);
+ // cpu_state.setLast_soft_irq(softirq);
+ // cpu_push_mode(cpu_state, CpuMode.LTTV_CPU_SOFT_IRQ);
+ //
+ // /* update process execution mode state stack */
+ // push_state(cpu, ExecutionMode.LTTV_STATE_SOFT_IRQ, submode,
+ // trcEvent.getTimestamp(), traceSt);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Method to handle the event: LTT_EVENT_LIST_INTERRRUPT
+ *
+ * @return
+ */
+ final IEventProcessing getEnumInterruptHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_LIST_INTERRUPT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // String action = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_ACTION);
+ // Long irq = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_IRQ_ID);
+ //
+ // Map<Long, String> irq_names = traceSt.getIrq_names();
+ //
+ // irq_names.put(irq, action);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Handle the event LTT_EVENT_REQUEST_ISSUE
+ *
+ * @return
+ */
+ final IEventProcessing getBdevRequestIssueHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_REQUEST_ISSUE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Get Fields
+ // Long major = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MAJOR);
+ // Long minor = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MINOR);
+ // Long operation = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_OPERATION);
+ //
+ // // calculate bdevcode
+ // Long devcode = mkdev(major, minor);
+ //
+ // if (devcode == null) {
+ // TraceDebug
+ // .debug("incorrect calcualtion of bdevcode input( major: "
+ // + major
+ // + " minor: "
+ // + minor
+ // + " operation: " + operation);
+ // return true;
+ // }
+ //
+ // Map<Long, LttngBdevState> bdev_states = traceSt
+ // .getBdev_states();
+ // // Get the instance
+ // LttngBdevState bdevState = bdev_states.get(devcode);
+ // if (bdevState == null) {
+ // bdevState = new LttngBdevState();
+ // }
+ //
+ // // update the mode in the stack
+ // if (operation == 0L) {
+ // bdevState.getMode_stack().push(
+ // BdevMode.LTTV_BDEV_BUSY_READING);
+ // } else {
+ // bdevState.getMode_stack().push(
+ // BdevMode.LTTV_BDEV_BUSY_WRITING);
+ // }
+ //
+ // // make sure it is included in the set
+ // bdev_states.put(devcode, bdevState);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handling event: LTT_EVENT_REQUEST_COMPLETE
+ * </p>
+ * <p>
+ * FIELDS(LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getBdevRequestCompleteHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_REQUEST_COMPLETE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Get Fields
+ // Long major = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MAJOR);
+ // Long minor = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_MINOR);
+ // Long operation = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_OPERATION);
+ //
+ // // calculate bdevcode
+ // Long devcode = mkdev(major, minor);
+ //
+ // if (devcode == null) {
+ // TraceDebug
+ // .debug("incorrect calcualtion of bdevcode input( major: "
+ // + major
+ // + " minor: "
+ // + minor
+ // + " operation: " + operation);
+ // return true;
+ // }
+ //
+ // Map<Long, LttngBdevState> bdev_states = traceSt
+ // .getBdev_states();
+ // // Get the instance
+ // LttngBdevState bdevState = bdev_states.get(devcode);
+ // if (bdevState == null) {
+ // bdevState = new LttngBdevState();
+ // }
+ //
+ // /* update block device */
+ // bdev_pop_mode(bdevState);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles event: LTT_EVENT_FUNCTION_ENTRY
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getFunctionEntryHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_FUNCTION_ENTRY;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // Long cpu = trcEvent.getCpuId();
+ // Long funcptr = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_THIS_FN);
+ //
+ // push_function(traceSt, funcptr, cpu);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ *
+ * @return
+ */
+ final IEventProcessing getFunctionExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_FUNCTION_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long funcptr = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_THIS_FN);
+ //
+ // pop_function(traceSt, trcEvent, funcptr);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * process event: LTT_EVENT_SYS_CALL_TABLE
+ * </p>
+ * <p>
+ * fields: LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getDumpSyscallHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SYS_CALL_TABLE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // // obtain the syscall id
+ // Long id = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_ID);
+ //
+ // // Long address = getAFieldLong(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_ADDRESS);
+ //
+ // // Obtain the symbol
+ // String symbol = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SYMBOL);
+ //
+ // // fill the symbol to the sycall_names collection
+ // traceSt.getSyscall_names().put(id, symbol);
+
+ return false;
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles event: LTT_EVENT_KPROBE_TABLE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_IP, LTT_FIELD_SYMBOL
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getDumpKprobeHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_KPROBE_TABLE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long ip = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_IP);
+ // String symbol = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SYMBOL);
+ //
+ // traceSt.getKprobe_table().put(ip, symbol);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_SOFTIRQ_VEC
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getDumpSoftIrqHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SOFTIRQ_VEC;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // // Get id
+ // Long id = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_ID);
+ //
+ // // Address not needed
+ // // Long address = ltt_event_get_long_unsigned(e,
+ // // lttv_trace_get_hook_field(th,
+ // // 1));
+ //
+ // // Get symbol
+ // String symbol = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_SYMBOL);
+ //
+ // // Register the soft irq name
+ // traceSt.getSoft_irq_names().put(id, symbol);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_SCHED_SCHEDULE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getSchedChangeHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_SCHED_SCHEDULE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // TmfTimestamp eventTime = trcEvent.getTimestamp();
+ //
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ //
+ // Long pid_out = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PREV_PID);
+ // Long pid_in = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_NEXT_PID);
+ // Long state_out = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PREV_STATE);
+ //
+ // if (process != null) {
+ //
+ // /*
+ // * We could not know but it was not the idle process
+ // * executing. This should only happen at the beginning,
+ // * before the first schedule event, and when the initial
+ // * information (current process for each CPU) is missing. It
+ // * is not obvious how we could, after the fact, compensate
+ // * the wrongly attributed statistics.
+ // */
+ //
+ // // This test only makes sense once the state is known and if
+ // // there
+ // // is no
+ // // missing events. We need to silently ignore schedchange
+ // // coming
+ // // after a
+ // // process_free, or it causes glitches. (FIXME)
+ // // if(unlikely(process->pid != pid_out)) {
+ // // g_assert(process->pid == 0);
+ // // }
+ // if (process.getPid() == 0
+ // && process.getState().getExec_mode() ==
+ // ExecutionMode.LTTV_STATE_MODE_UNKNOWN) {
+ // if (pid_out == 0) {
+ // /*
+ // * Scheduling out of pid 0 at beginning of the trace
+ // * : we know for sure it is in syscall mode at this
+ // * point.
+ // */
+ // int stackSize = process.getExecution_stack().size();
+ // if (stackSize != 1) {
+ // TraceDebug
+ // .debug("unpexpected process execution stack size, expected 1, received: ");
+ // }
+ //
+ // process.getState().setExec_mode(
+ // ExecutionMode.LTTV_STATE_SYSCALL);
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_WAIT);
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // process.getState().setEntry_Time(
+ // trcEvent.getTimestamp());
+ // }
+ // } else {
+ // if (process.getState().getProc_status() ==
+ // ProcessStatus.LTTV_STATE_EXIT) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_ZOMBIE);
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // } else {
+ // if (state_out == 0L) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_WAIT_CPU);
+ // } else {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_WAIT);
+ // }
+ //
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // }
+ //
+ // if (state_out == 32L || state_out == 64L) { /*
+ // * EXIT_DEAD
+ // * ||
+ // * TASK_DEAD
+ // */
+ // /* see sched.h for states */
+ // if (!exit_process(traceSt, process)) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_DEAD);
+ // process.getState().setChage_Time(
+ // trcEvent.getTimestamp());
+ // }
+ // }
+ // }
+ // }
+ // process = lttv_state_find_process_or_create(traceSt, cpu,
+ // pid_in, eventTime);
+ //
+ // traceSt.getRunning_process().put(cpu, process);
+ //
+ // process.getState().setProc_status(ProcessStatus.LTTV_STATE_RUN);
+ // process.getState().setChage_Time(eventTime);
+ // process.setCpu(cpu);
+ // // process->state->s = LTTV_STATE_RUN;
+ // // if(process->usertrace)
+ // // process->usertrace->cpu = cpu;
+ // // process->last_cpu_index =
+ // // ltt_tracefile_num(((LttvTracefileContext*)s)->tf);
+ //
+ // // process->state->change = s->parent.timestamp;
+ //
+ // LTTngCPUState cpu_state = traceSt.getCpu_states().get(cpu);
+ // /* update cpu status */
+ // if (pid_in == 0) {
+ //
+ // /* going to idle task */
+ // cpu_set_base_mode(cpu_state, CpuMode.LTTV_CPU_IDLE);
+ // } else {
+ // /*
+ // * scheduling a real task. we must be careful here: if we
+ // * just schedule()'ed to a process that is in a trap, we
+ // * must put the cpu in trap mode
+ // */
+ // cpu_set_base_mode(cpu_state, CpuMode.LTTV_CPU_BUSY);
+ // if (process.getState().getExec_mode() ==
+ // ExecutionMode.LTTV_STATE_TRAP) {
+ // cpu_push_mode(cpu_state, CpuMode.LTTV_CPU_TRAP);
+ // }
+ // }
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_FORK
+ * </p>
+ * <p>
+ * Fields: FIELD_ARRAY(LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID,
+ * LTT_FIELD_CHILD_TGID)
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessForkHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_FORK;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ // TmfTimestamp timeStamp = trcEvent.getTimestamp();
+ //
+ // // /* Parent PID */
+ // // Long parent_pid = getAFieldLong(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_PARENT_PID);
+ //
+ // /* Child PID */
+ // /* In the Linux Kernel, there is one PID per thread. */
+ // Long child_pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_CHILD_PID);
+ //
+ // /* Child TGID */
+ // /* tgid in the Linux kernel is the "real" POSIX PID. */
+ // Long child_tgid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_CHILD_TGID);
+ // if (child_tgid == null) {
+ // child_tgid = 0L;
+ // }
+ //
+ // /*
+ // * Mathieu : it seems like the process might have been
+ // scheduled
+ // * in before the fork, and, in a rare case, might be the
+ // current
+ // * process. This might happen in a SMP case where we don't
+ // have
+ // * enough precision on the clocks.
+ // *
+ // * Test reenabled after precision fixes on time. (Mathieu)
+ // */
+ // // #if 0
+ // // zombie_process = lttv_state_find_process(ts, ANY_CPU,
+ // // child_pid);
+ // //
+ // // if(unlikely(zombie_process != NULL)) {
+ // // /* Reutilisation of PID. Only now we are sure that the old
+ // // PID
+ // // * has been released. FIXME : should know when release_task
+ // // happens
+ // // instead.
+ // // */
+ // // guint num_cpus = ltt_trace_get_num_cpu(ts->parent.t);
+ // // guint i;
+ // // for(i=0; i< num_cpus; i++) {
+ // // g_assert(zombie_process != ts->running_process[i]);
+ // // }
+ // //
+ // // exit_process(s, zombie_process);
+ // // }
+ // // #endif //0
+ //
+ // if (process.getPid() == child_pid) {
+ // TraceDebug
+ // .debug("Unexpected, process pid equal to child pid: "
+ // + child_pid
+ // + " Event Time: "
+ // + trcEvent.getTimestamp());
+ // }
+ //
+ // // g_assert(process->pid != child_pid);
+ // // FIXME : Add this test in the "known state" section
+ // // g_assert(process->pid == parent_pid);
+ // LttngProcessState child_process = lttv_state_find_process(
+ // traceSt, ANY_CPU, child_pid);
+ // if (child_process == null) {
+ // child_process = create_process(traceSt, cpu, child_pid,
+ // child_tgid, timeStamp);
+ // } else {
+ // /*
+ // * The process has already been created : due to time
+ // * imprecision between multiple CPUs : it has been scheduled
+ // * in before creation. Note that we shouldn't have this kind
+ // * of imprecision.
+ // *
+ // * Simply put a correct parent.
+ // */
+ // StringBuilder sb = new StringBuilder("Process " + child_pid);
+ // sb.append(" has been created at ["
+ // + child_process.getCration_time() + "] ");
+ // sb.append("and inserted at ["
+ // + child_process.getInsertion_time() + "] ");
+ // sb.append("before \nfork on cpu " + cpu + " Event time: ["
+ // + trcEvent + "]\n.");
+ // sb
+ // .append("Probably an unsynchronized TSD problem on the traced machine.");
+ // TraceDebug.debug(sb.toString());
+ //
+ // // g_assert(0); /* This is a problematic case : the process
+ // // has
+ // // beencreated
+ // // before the fork event */
+ // child_process.setPpid(process.getPid());
+ // child_process.setTgid(child_tgid);
+ // }
+ //
+ // if (!child_process.getName().equals(
+ // ProcessStatus.LTTV_STATE_UNNAMED.getInName())) {
+ // TraceDebug.debug("Unexpected child process status: "
+ // + child_process.getName());
+ // }
+ //
+ // child_process.setName(process.getName());
+ // child_process.setBrand(process.getBrand());
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_KTHREAD_CREATE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_PID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessKernelThreadHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_KTHREAD_CREATE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ // /*
+ // * We stamp a newly created process as kernel_thread. The
+ // thread
+ // * should not be running yet.
+ // */
+ //
+ // LttngExecutionState exState;
+ // Long pid;
+ // LttngProcessState process;
+ //
+ // /* PID */
+ // pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID);
+ // // s->parent.target_pid = pid;
+ //
+ // process = lttv_state_find_process_or_create(traceSt, ANY_CPU,
+ // pid, new TmfTimestamp());
+ //
+ // if (!process.getState().getProc_status().equals(
+ // ProcessStatus.LTTV_STATE_DEAD)) {
+ // // Leave only the first element in the stack with execution
+ // // mode to
+ // // syscall
+ // Stack<LttngExecutionState> processExStack = process
+ // .getExecution_stack();
+ // exState = processExStack.firstElement();
+ // exState.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
+ // if (processExStack.size() > 1) {
+ // processExStack.clear();
+ // processExStack.add(exState);
+ // }
+ //
+ // // update the process state to the only one in the stack
+ // process.setState(exState);
+ // }
+ //
+ // process.setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_EXIT
+ * </p>
+ * <p>
+ * LTT_FIELD_PID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessExitHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_EXIT;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long pid;
+ // LttngProcessState process;
+ //
+ // pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PID);
+ // // s->parent.target_pid = pid;
+ //
+ // // FIXME : Add this test in the "known state" section
+ // // g_assert(process->pid == pid);
+ //
+ // process = lttv_state_find_process(traceSt, ANY_CPU, pid);
+ // if (process != null) {
+ // process.getState().setProc_status(
+ // ProcessStatus.LTTV_STATE_EXIT);
+ // }
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_FREE
+ * </p>
+ * <p>
+ * Fields: LTT_FIELD_PID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessFreeHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_FREE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long release_pid;
+ // LttngProcessState process;
+ //
+ // /* PID of the process to release */
+ // release_pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PID);
+ // // s->parent.target_pid = release_pid;
+ //
+ // if (release_pid == 0) {
+ // TraceDebug.debug("Unexpected release_pid: 0, Event time: "
+ // + trcEvent.getTimestamp());
+ // }
+ //
+ // process = lttv_state_find_process(traceSt, ANY_CPU,
+ // release_pid);
+ // if (process != null) {
+ // exit_process(traceSt, process);
+ // }
+
+ return false;
+ // DISABLED
+ // if(process != null) {
+ /*
+ * release_task is happening at kernel level : we can now safely
+ * release the data structure of the process
+ */
+ // This test is fun, though, as it may happen that
+ // at time t : CPU 0 : process_free
+ // at time t+150ns : CPU 1 : schedule out
+ // Clearly due to time imprecision, we disable it. (Mathieu)
+ // If this weird case happen, we have no choice but to put the
+ // Currently running process on the cpu to 0.
+ // I re-enable it following time precision fixes. (Mathieu)
+ // Well, in the case where an process is freed by a process on
+ // another
+ // CPU
+ // and still scheduled, it happens that this is the schedchange
+ // that
+ // will
+ // drop the last reference count. Do not free it here!
+
+ // int num_cpus = ltt_trace_get_num_cpu(ts->parent.t);
+ // guint i;
+ // for(i=0; i< num_cpus; i++) {
+ // //g_assert(process != ts->running_process[i]);
+ // if(process == ts->running_process[i]) {
+ // //ts->running_process[i] = lttv_state_find_process(ts, i, 0);
+ // break;
+ // }
+ // }
+ // if(i == num_cpus) /* process is not scheduled */
+ // exit_process(s, process);
+ // }
+ //
+ // return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_EXEC
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_FILENAME
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getProcessExecHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_EXEC;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ //
+ // // #if 0//how to use a sequence that must be transformed in a
+ // // string
+ // // /* PID of the process to release */
+ // // guint64 name_len = ltt_event_field_element_number(e,
+ // // lttv_trace_get_hook_field(th, 0));
+ // // //name = ltt_event_get_string(e,
+ // // lttv_trace_get_hook_field(th, 0));
+ // // LttField *child = ltt_event_field_element_select(e,
+ // // lttv_trace_get_hook_field(th, 0), 0);
+ // // gchar *name_begin =
+ // // (gchar*)(ltt_event_data(e)+ltt_event_field_offset(e,
+ // child));
+ // // gchar *null_term_name = g_new(gchar, name_len+1);
+ // // memcpy(null_term_name, name_begin, name_len);
+ // // null_term_name[name_len] = '\0';
+ // // process->name = g_quark_from_string(null_term_name);
+ // // #endif //0
+ //
+ // process.setName(getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_FILENAME));
+ // process.setBrand(StateStrings.LTTV_STATE_UNBRANDED);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * <p>
+ * LTT_EVENT_THREAD_BRAND
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_NAME
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing GetThreadBrandHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_THREAD_BRAND;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // String name;
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ //
+ // name = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_NAME);
+ // process.setBrand(name);
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * @return
+ */
+ final IEventProcessing getStateDumpEndHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_STATEDUMP_END;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // /* For all processes */
+ // /*
+ // * if kernel thread, if stack[0] is unknown, set to syscall
+ // * mode, wait
+ // */
+ // /* else, if stack[0] is unknown, set to user mode, running */
+ // List<LttngProcessState> processes = traceSt.getProcesses();
+ // TmfTimestamp time = trcEvent.getTimestamp();
+ //
+ // for (LttngProcessState process : processes) {
+ // fix_process(process, time);
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+ /**
+ * Private method used to establish the first execution state in the stack
+ * for a given process
+ *
+ * @param process
+ * @param timestamp
+ */
+ // private void fix_process(LttngProcessState process,
+ // TmfTimestamp timestamp) {
+ //
+ // LttngExecutionState es;
+ // Stack<LttngExecutionState> procStack = process
+ // .getExecution_stack();
+ //
+ // if (process.getType() == ProcessType.LTTV_STATE_KERNEL_THREAD) {
+ // es = procStack.firstElement();
+ //
+ // if (es.getExec_mode() == ExecutionMode.LTTV_STATE_MODE_UNKNOWN) {
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
+ // .getInName());
+ // es.setEntry_Time(timestamp);
+ // es.setChage_Time(timestamp);
+ // es.setCum_cpu_time(0L);
+ // if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
+ // es.setProc_status(ProcessStatus.LTTV_STATE_WAIT);
+ // }
+ // }
+ // } else {
+ // es = procStack.firstElement();
+ // if (es.getExec_mode() == ExecutionMode.LTTV_STATE_MODE_UNKNOWN) {
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_USER_MODE);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
+ // .getInName());
+ // es.setEntry_Time(timestamp);
+ // es.setChage_Time(timestamp);
+ // es.setCum_cpu_time(0L);
+ // if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
+ // es.setProc_status(ProcessStatus.LTTV_STATE_RUN);
+ // }
+ //
+ // if (procStack.size() == 1) {
+ // /*
+ // * Still in bottom unknown mode, means never did a
+ // * system call May be either in user mode, syscall
+ // * mode, running or waiting.
+ // */
+ // /*
+ // * FIXME : we may be tagging syscall mode when being
+ // * user mode
+ // */
+ // // Get a new execution State
+ // es = new LttngExecutionState();
+ //
+ // // initialize values
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
+ // .getInName());
+ // es.setEntry_Time(timestamp);
+ // es.setChage_Time(timestamp);
+ // es.setCum_cpu_time(0L);
+ // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED);
+ //
+ // // Push the new state to the stack
+ // procStack.push(es);
+ // }
+ // }
+ // }
+ // }
+ // };
+ // return handler;
+ // }
+
+ /**
+ * <p>
+ * Handles: LTT_EVENT_PROCESS_STATE
+ * </p>
+ * <p>
+ * FIELDS: LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
+ * LTT_FIELD_TYPE, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, LTT_FIELD_STATUS,
+ * LTT_FIELD_TGID
+ * </p>
+ *
+ * @return
+ */
+ final IEventProcessing getEnumProcessStateHandler() {
+ AbsStateUpdate handler = new AbsStateUpdate() {
+
+ private Events eventType = Events.LTT_EVENT_PROCESS_STATE;
+
+ // @Override
+ public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
+ //
+ // Long parent_pid;
+ // Long pid;
+ // Long tgid;
+ // String command;
+ // Long cpu = trcEvent.getCpuId();
+ // LttngProcessState process = traceSt.getRunning_process().get(
+ // cpu);
+ // LttngProcessState parent_process;
+ // String type;
+ // // String mode, submode, status;
+ // LttngExecutionState es;
+ //
+ // /* PID */
+ // pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID);
+ //
+ // /* Parent PID */
+ // parent_pid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_PARENT_PID);
+ //
+ // /* Command name */
+ // command = getAFieldString(trcEvent, traceSt,
+ // Fields.LTT_FIELD_NAME);
+ //
+ // /* TODO: type field, Values need to be verified */
+ // /* type */
+ // Long typeVal = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_TYPE);
+ // if (typeVal == 0L) {
+ // type = ProcessType.LTTV_STATE_KERNEL_THREAD.getInName();
+ // } else {
+ // type = ProcessType.LTTV_STATE_USER_THREAD.getInName();
+ // }
+ //
+ // // FIXME: type is rarely used, enum must match possible
+ // types.
+ //
+ // // /* mode */
+ // // mode = getAFieldString(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_MODE);
+ // //
+ // // /* submode */
+ // // submode = getAFieldString(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_SUBMODE);
+ // //
+ // // /* status */
+ // // status = getAFieldString(trcEvent, traceSt,
+ // // Fields.LTT_FIELD_STATUS);
+ //
+ // /* TGID */
+ // tgid = getAFieldLong(trcEvent, traceSt,
+ // Fields.LTT_FIELD_TGID);
+ // if (tgid == null) {
+ // tgid = 0L;
+ // }
+ //
+ // if (pid == 0) {
+ // for (Long acpu : traceSt.getCpu_states().keySet()) {
+ // process = lttv_state_find_process(traceSt, acpu, pid);
+ // if (process != null) {
+ // process.setPpid(parent_pid);
+ // process.setTgid(tgid);
+ // process.setName(command);
+ // process
+ // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+ // } else {
+ // StringBuilder sb = new StringBuilder(
+ // "Unexpected, null process read from the TraceState list of processes, event time: "
+ // + trcEvent.getTimestamp());
+ // TraceDebug.debug(sb.toString());
+ // }
+ // }
+ // } else {
+ // /*
+ // * The process might exist if a process was forked while
+ // * performing the state dump.
+ // */
+ // process = lttv_state_find_process(traceSt, ANY_CPU, pid);
+ // if (process == null) {
+ // parent_process = lttv_state_find_process(traceSt,
+ // ANY_CPU, parent_pid);
+ // process = create_process(traceSt, cpu, pid, tgid,
+ // command, trcEvent.getTimestamp());
+ // if (parent_process != null) {
+ // process.setPpid(parent_process.getPid());
+ // }
+ //
+ // /* Keep the stack bottom : a running user mode */
+ // /*
+ // * Disabled because of inconsistencies in the current
+ // * statedump states.
+ // */
+ // if (type.equals(ProcessType.LTTV_STATE_KERNEL_THREAD
+ // .getInName())) {
+ // /*
+ // * FIXME Kernel thread : can be in syscall or
+ // * interrupt or trap.
+ // */
+ // /*
+ // * Will cause expected trap when in fact being
+ // * syscall (even after end of statedump event) Will
+ // * cause expected interrupt when being syscall.
+ // * (only before end of statedump event)
+ // */
+ // process
+ // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+ //
+ // // #if 0
+ // // es->t = LTTV_STATE_SYSCALL;
+ // // es->s = status;
+ // // es->n = submode;
+ // // #endif //0
+ // } else {
+ // /*
+ // * User space process : bottom : user mode either
+ // * currently running or scheduled out. can be
+ // * scheduled out because interrupted in (user mode
+ // * or in syscall) or because of an explicit call to
+ // * the scheduler in syscall. Note that the scheduler
+ // * call comes after the irq_exit, so never in
+ // * interrupt context.
+ // */
+ // // temp workaround : set size to 1 : only have user
+ // // mode
+ // // bottom of stack.
+ // // will cause g_info message of expected syscall
+ // // mode when
+ // // in fact being
+ // // in user mode. Can also cause expected trap when
+ // // in fact
+ // // being user
+ // // mode in the event of a page fault reenabling
+ // // interrupts
+ // // in the handler.
+ // // Expected syscall and trap can also happen after
+ // // the end
+ // // of statedump
+ // // This will cause a
+ // // "popping last state on stack, ignoring it."
+ //
+ // // process->execution_stack =
+ // // g_array_set_size(process->execution_stack, 1);
+ // // es = process->state =
+ // // &g_array_index(process->execution_stack,
+ // // LttvExecutionState, 0);
+ // // a new process must have only one state in the
+ // // stack and
+ // // be the same as the current state
+ // // es = process.getState();
+ // // es.setExec_mode(ExecutionMode.LTTV_STATE_MODE_UNKNOWN);
+ // // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED);
+ // // es
+ // //
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN
+ // // .getInName());
+ //
+ // // #if 0
+ // // es->t = LTTV_STATE_USER_MODE;
+ // // es->s = status;
+ // // es->n = submode;
+ // // #endif //0
+ // }
+ // // TODO: clean up comments above: Moved repeated code
+ // // from both
+ // // if / else blocks above,
+ // // comments left temporarily for easier visualization
+ // // and
+ // // comparision with c code
+ // es = process.getState();
+ // es.setExec_mode(ExecutionMode.LTTV_STATE_MODE_UNKNOWN);
+ // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED);
+ // es
+ // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN
+ // .getInName());
+ // // #if 0
+ // // /* UNKNOWN STATE */
+ // // {
+ // // es = process->state =
+ // // &g_array_index(process->execution_stack,
+ // // LttvExecutionState, 1);
+ // // es->t = LTTV_STATE_MODE_UNKNOWN;
+ // // es->s = LTTV_STATE_UNNAMED;
+ // // es->n = LTTV_STATE_SUBMODE_UNKNOWN;
+ // // }
+ // // #endif //0
+ // } else {
+ // /*
+ // * The process has already been created : Probably was
+ // * forked while dumping the process state or was simply
+ // * scheduled in prior to get the state dump event.
+ // */
+ // process.setPpid(parent_pid);
+ // process.setTgid(tgid);
+ // process.setName(command);
+ // if (type.equals(ProcessType.LTTV_STATE_KERNEL_THREAD
+ // .getInName())) {
+ // process
+ // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD);
+ // } else {
+ // process.setType(ProcessType.LTTV_STATE_USER_THREAD);
+ // }
+ //
+ // // es =
+ // // &g_array_index(process->execution_stack,
+ // // LttvExecutionState,
+ // // 0);
+ // // #if 0
+ // // if(es->t == LTTV_STATE_MODE_UNKNOWN) {
+ // // if(type == LTTV_STATE_KERNEL_THREAD)
+ // // es->t = LTTV_STATE_SYSCALL;
+ // // else
+ // // es->t = LTTV_STATE_USER_MODE;
+ // // }
+ // // #endif //0
+ // /*
+ // * Don't mess around with the stack, it will eventually
+ // * become ok after the end of state dump.
+ // */
+ // }
+ // }
+
+ return false;
+
+ }
+
+ // @Override
+ public Events getEventHandleType() {
+ return eventType;
+ }
+ };
+ return handler;
+ }
+
+}
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.linuxtools.lttng,
org.eclipse.linuxtools.lttng.event,
+ org.eclipse.linuxtools.lttng.jni,
org.eclipse.linuxtools.lttng.state,
org.eclipse.linuxtools.lttng.state.evProcessor,
+ org.eclipse.linuxtools.lttng.state.evProcessor.state,
org.eclipse.linuxtools.lttng.state.experiment,
org.eclipse.linuxtools.lttng.state.model,
org.eclipse.linuxtools.lttng.trace
try {
//testTrace = new JniTrace("/home/william/trace1");
- testTrace = new JniTrace("/home/william/trace5");
+ testTrace = new JniTrace("/home/francois/workspace/LTTng/org.eclipse.linuxtools.lttng.tests/traceset/trace_617984ev_withlost");
//testTrace = new JniTrace("/home/william/trace1_numcpu");
}
catch (JniException e) {