lttng: Always create the sub-attributes of TID nodes
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 1 May 2012 19:29:32 +0000 (15:29 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 2 May 2012 02:27:43 +0000 (22:27 -0400)
This makes the history slightly bigger, but it avoids having
to catch all sort of exceptions in the views, for the cases
where the expected sub-attributes never get populated. Now
they will simply contain a "null" value for the whole duration.

Also relaxed the test cases a bit, changed it so we won't have
to update them every time we make a single change to the state
provider.

Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/CtfKernelHandler.java

index 1957e1e5d67ca072cfaf16a66ab86c2be7f07c47..47ab2e746e0ceff4e5e69c4d21b5907512f95659 100644 (file)
@@ -365,23 +365,21 @@ public class StateSystemFullHistoryTest {
         List<Integer> list = ssb.getQuarks("*", "1577", Attributes.EXEC_NAME);
 
         assertEquals(1, list.size());
-        assertEquals(Integer.valueOf(398), list.get(0));
     }
 
     @Test
     public void testGetQuarks_middle() {
         List<Integer> list = ssb.getQuarks(Attributes.THREADS, "*", Attributes.EXEC_NAME);
 
-        assertEquals(Integer.valueOf(18), list.get(4));
-        assertEquals(Integer.valueOf(54), list.get(10));
-        assertEquals(Integer.valueOf(64), list.get(12));
+        /* Number of different kernel threads in the trace */
+        assertEquals(168, list.size());
     }
 
     @Test
     public void testGetQuarks_end() {
         List<Integer> list = ssb.getQuarks(Attributes.THREADS, "1577", "*");
 
-        assertEquals(3, list.size());
-        assertEquals(Integer.valueOf(398), list.get(1));
+        /* There should be 4 sub-attributes for each Thread node */
+        assertEquals(4, list.size());
     }
 }
index 86a590bd609e3f95bf58fe6adadbbe4aaf3d6fe2..d6072561d88b4ea805538b980bf7a26bd86a809b 100644 (file)
@@ -225,15 +225,16 @@ class CtfKernelHandler implements Runnable {
 
                 /* Update the currentThreadNodes pointer */
                 Integer newCurrentThreadNode = ss.getQuarkAbsoluteAndAdd(Attributes.THREADS, nextTid.toString());
+                initThreadNode(newCurrentThreadNode);
                 currentThreadNodes.set(eventCpu, newCurrentThreadNode);
 
                 /* Set the status of the new scheduled process */
-                quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.STATUS);
+                quark = ss.getQuarkRelative(newCurrentThreadNode, Attributes.STATUS);
                 value = TmfStateValue.newValueInt(Attributes.STATUS_RUN);
                 ss.modifyAttribute(ts, value, quark);
 
                 /* Set the exec name of the new process */
-                quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.EXEC_NAME);
+                quark = ss.getQuarkRelative(newCurrentThreadNode, Attributes.EXEC_NAME);
                 value = TmfStateValue.newValueString(nextProcessName);
                 ss.modifyAttribute(ts, value, quark);
 
@@ -264,17 +265,18 @@ class CtfKernelHandler implements Runnable {
                 Integer childTid = ((Long) content.getField(LttngStrings.CHILD_TID).getValue()).intValue();
 
                 tidNode = ss.getQuarkAbsoluteAndAdd(Attributes.THREADS, childTid.toString());
+                initThreadNode(tidNode);
 
                 /*
                  * Add the new process with its known TID, PPID, and initial
                  * Exec_name
                  */
-                quark = ss.getQuarkRelativeAndAdd(tidNode, Attributes.PPID);
+                quark = ss.getQuarkRelative(tidNode, Attributes.PPID);
                 value = TmfStateValue.newValueInt(parentTid);
                 ss.modifyAttribute(ts, value, quark);
 
                 /* Set the new process' exec_name */
-                quark = ss.getQuarkRelativeAndAdd(tidNode, Attributes.EXEC_NAME);
+                quark = ss.getQuarkRelative(tidNode, Attributes.EXEC_NAME);
                 value = TmfStateValue.newValueString(childProcessName);
                 ss.modifyAttribute(ts, value, quark);
                 break;
@@ -375,7 +377,16 @@ class CtfKernelHandler implements Runnable {
              */
             sve.printStackTrace();
         }
+    }
 
+    /**
+     * Ensure we always have some sub-attributes available for every "TID" node.
+     */
+    private void initThreadNode(int currentThreadNode) {
+        ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.PPID);
+        ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.EXEC_NAME);
+        ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.EXEC_MODE_STACK);
+        ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
     }
 
     private static HashMap<String, Integer> fillEventNames() {
This page took 0.029364 seconds and 5 git commands to generate.