lttng: Split UST event names in a separate interface
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 27 May 2015 20:48:23 +0000 (16:48 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 12 Aug 2015 19:20:38 +0000 (15:20 -0400)
Remove the definitions pertaining to event and field names in
UstMemoryStrings, and move them to a global interface.

These names can change from one version to the other of the
tracer, so this is the first step in abstracting away the actual
trace event names from the "concepts" the library and analysis
agree upon.

Change-Id: Ia8ccf528029cc8cd3e5de13e4e7041ad6e89eeae
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/50312
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/LttngUstEventStrings.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStrings.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java

index 0ec8f10c939ecdbcd6b486fbe86b3c4c1730ef76..1bd4ea85cfd910eff2342a160ad041c02a5a97d6 100644 (file)
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.Set;
 
-import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStrings;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.LttngUstEventStrings;
 import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
 import org.eclipse.tracecompass.lttng2.ust.core.analysis.memory.UstMemoryAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
@@ -81,12 +81,12 @@ public class UstMemoryAnalysisModuleTest {
 
         /* Events */
         Set<String> expectedEvents = ImmutableSet.of(
-                UstMemoryStrings.MALLOC,
-                UstMemoryStrings.FREE,
-                UstMemoryStrings.CALLOC,
-                UstMemoryStrings.REALLOC,
-                UstMemoryStrings.MEMALIGN,
-                UstMemoryStrings.POSIX_MEMALIGN
+                LttngUstEventStrings.MALLOC,
+                LttngUstEventStrings.FREE,
+                LttngUstEventStrings.CALLOC,
+                LttngUstEventStrings.REALLOC,
+                LttngUstEventStrings.MEMALIGN,
+                LttngUstEventStrings.POSIX_MEMALIGN
                 );
 
         assertEquals(6, eventReq.getValues().size());
diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/LttngUstEventStrings.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/LttngUstEventStrings.java
new file mode 100644 (file)
index 0000000..7658a14
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson, École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.ust.core;
+
+/**
+ * Strings related to UST traces and convenience libraries.
+ *
+ * @author Matthew Khouzam
+ * @author Geneviève Bastien
+ * @noimplement This interface only contains static definitions.
+ */
+@SuppressWarnings({ "nls", "javadoc" })
+public interface LttngUstEventStrings {
+
+    /* UST_libc event names */
+    String MALLOC = "ust_libc:malloc";
+    String CALLOC = "ust_libc:calloc";
+    String REALLOC = "ust_libc:realloc";
+    String FREE = "ust_libc:free";
+    String MEMALIGN = "ust_libc:memalign";
+    String POSIX_MEMALIGN = "ust_libc:posix_memalign";
+
+    /* Possible contexts */
+    String CONTEXT_VTID = "context._vtid";
+    String CONTEXT_PROCNAME = "context._procname";
+
+    /* Event fields */
+    String FIELD_PTR = "ptr";
+    String FIELD_NMEMB = "nmemb";
+    String FIELD_SIZE = "size";
+    String FIELD_OUTPTR = "out_ptr";
+    String FIELD_INPTR = "in_ptr";
+
+}
index 3175711a1191b0213aab2211f6fd125104097f7a..83917277229e16f6e7ae347f1b7c4edb88e68792 100644 (file)
@@ -19,6 +19,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.LttngUstEventStrings;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -64,59 +65,59 @@ public class UstMemoryStateProvider extends AbstractTmfStateProvider {
     protected void eventHandle(ITmfEvent event) {
         String name = event.getName();
         switch (name) {
-        case UstMemoryStrings.MALLOC: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+        case LttngUstEventStrings.MALLOC: {
+            Long ptr = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_PTR).getValue();
             if (ZERO.equals(ptr)) {
                 return;
             }
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            Long size = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_SIZE).getValue();
             setMem(event, ptr, size);
         }
             break;
-        case UstMemoryStrings.FREE: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+        case LttngUstEventStrings.FREE: {
+            Long ptr = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_PTR).getValue();
             if (ZERO.equals(ptr)) {
                 return;
             }
             setMem(event, ptr, ZERO);
         }
             break;
-        case UstMemoryStrings.CALLOC: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+        case LttngUstEventStrings.CALLOC: {
+            Long ptr = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_PTR).getValue();
             if (ZERO.equals(ptr)) {
                 return;
             }
-            Long nmemb = (Long) event.getContent().getField(UstMemoryStrings.FIELD_NMEMB).getValue();
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            Long nmemb = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_NMEMB).getValue();
+            Long size = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_SIZE).getValue();
             setMem(event, ptr, size * nmemb);
         }
             break;
-        case UstMemoryStrings.REALLOC: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+        case LttngUstEventStrings.REALLOC: {
+            Long ptr = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_PTR).getValue();
             if (ZERO.equals(ptr)) {
                 return;
             }
-            Long newPtr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_INPTR).getValue();
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            Long newPtr = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_INPTR).getValue();
+            Long size = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_SIZE).getValue();
             setMem(event, ptr, ZERO);
             setMem(event, newPtr, size);
         }
             break;
-        case UstMemoryStrings.MEMALIGN: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+        case LttngUstEventStrings.MEMALIGN: {
+            Long ptr = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_PTR).getValue();
             if (ZERO.equals(ptr)) {
                 return;
             }
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            Long size = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_SIZE).getValue();
             setMem(event, ptr, size);
         }
             break;
-        case UstMemoryStrings.POSIX_MEMALIGN: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_OUTPTR).getValue();
+        case LttngUstEventStrings.POSIX_MEMALIGN: {
+            Long ptr = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_OUTPTR).getValue();
             if (ZERO.equals(ptr)) {
                 return;
             }
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            Long size = (Long) event.getContent().getField(LttngUstEventStrings.FIELD_SIZE).getValue();
             setMem(event, ptr, size);
         }
             break;
@@ -142,7 +143,7 @@ public class UstMemoryStateProvider extends AbstractTmfStateProvider {
     }
 
     private static Long getVtid(ITmfEvent event) {
-        ITmfEventField field = event.getContent().getField(UstMemoryStrings.CONTEXT_VTID);
+        ITmfEventField field = event.getContent().getField(LttngUstEventStrings.CONTEXT_VTID);
         if (field == null) {
             return MINUS_ONE;
         }
@@ -150,7 +151,7 @@ public class UstMemoryStateProvider extends AbstractTmfStateProvider {
     }
 
     private static String getProcname(ITmfEvent event) {
-        ITmfEventField field = event.getContent().getField(UstMemoryStrings.CONTEXT_PROCNAME);
+        ITmfEventField field = event.getContent().getField(LttngUstEventStrings.CONTEXT_PROCNAME);
         if (field == null) {
             return EMPTY_STRING;
         }
index b573a3fa5ea9ca1e0aca828c8a529a9d67a0010c..c7c8c8c0994139b8af37aa23ac7977debe955871 100644 (file)
@@ -19,33 +19,16 @@ package org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory;
  * @author Matthew Khouzam
  * @author Geneviève Bastien
  */
-@SuppressWarnings({ "nls", "javadoc" })
+@SuppressWarnings("nls")
 public interface UstMemoryStrings {
 
     /** Memory state system attribute name */
-    static final String UST_MEMORY_MEMORY_ATTRIBUTE = "Memory"; //$NON-NLS-1$
-    /** Procname state system attribute name */
-    static final String UST_MEMORY_PROCNAME_ATTRIBUTE = "Procname"; //$NON-NLS-1$
-    /** Name of the attribute to store memory usage of events with no context */
-    static final String OTHERS = "Others";
-
-    /* UST_libc event names */
-    static final String MALLOC = "ust_libc:malloc";
-    static final String CALLOC = "ust_libc:calloc";
-    static final String REALLOC = "ust_libc:realloc";
-    static final String FREE = "ust_libc:free";
-    static final String MEMALIGN = "ust_libc:memalign";
-    static final String POSIX_MEMALIGN = "ust_libc:posix_memalign";
+    String UST_MEMORY_MEMORY_ATTRIBUTE = "Memory";
 
-    /* Possible contexts */
-    static final String CONTEXT_VTID = "context._vtid";
-    static final String CONTEXT_PROCNAME = "context._procname";
+    /** Procname state system attribute name */
+    String UST_MEMORY_PROCNAME_ATTRIBUTE = "Procname";
 
-    /* Event fields */
-    static final String FIELD_PTR = "ptr";
-    static final String FIELD_NMEMB = "nmemb";
-    static final String FIELD_SIZE = "size";
-    static final String FIELD_OUTPTR = "out_ptr";
-    static final String FIELD_INPTR = "in_ptr";
+    /** Name of the attribute to store memory usage of events with no context */
+    String OTHERS = "Others";
 
-}
+}
\ No newline at end of file
index 43bea1371303037c4a0792b01d762552e9bbea2a..bc79cea99fa7a50e33e2fcba0705b37c3e42cd7f 100644 (file)
@@ -18,8 +18,8 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.LttngUstEventStrings;
 import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStateProvider;
-import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStrings;
 import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
@@ -45,12 +45,12 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
     public static final @NonNull String ID = "org.eclipse.linuxtools.lttng2.ust.analysis.memory"; //$NON-NLS-1$
 
     private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of(
-            UstMemoryStrings.MALLOC,
-            UstMemoryStrings.FREE,
-            UstMemoryStrings.CALLOC,
-            UstMemoryStrings.REALLOC,
-            UstMemoryStrings.MEMALIGN,
-            UstMemoryStrings.POSIX_MEMALIGN
+            LttngUstEventStrings.MALLOC,
+            LttngUstEventStrings.FREE,
+            LttngUstEventStrings.CALLOC,
+            LttngUstEventStrings.REALLOC,
+            LttngUstEventStrings.MEMALIGN,
+            LttngUstEventStrings.POSIX_MEMALIGN
             );
 
     /** The requirements as an immutable set */
This page took 0.032691 seconds and 5 git commands to generate.