lttng: Add snapshot support - LTTng Tools v2.3
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / service / LTTngControlService.java
index 294124e9cab5c78d503881807e22cd7ab516599e..9d82dc9838a3c97b449638eef614e578b9763ac3 100644 (file)
@@ -9,6 +9,7 @@
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  *   Bernd Hufmann - Updated for support of LTTng Tools 2.1
+ *   Simon Delisle - Updated for support of LTTng Tools 2.2
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service;
 
@@ -27,24 +28,26 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BufferType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.logging.ControlCommandLogger;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.preferences.ControlPreferences;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandResult;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandShell;
-import org.osgi.framework.Version;
 
 /**
  * <p>
@@ -61,12 +64,12 @@ public class LTTngControlService implements ILttngControlService {
     /**
      * The command shell implementation
      */
-    protected ICommandShell fCommandShell = null;
+    private final ICommandShell fCommandShell;
 
     /**
      * The version string.
      */
-    protected Version fVersion = null;
+    private LttngVersion fVersion = null;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -85,10 +88,7 @@ public class LTTngControlService implements ILttngControlService {
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#getVersion()
-     */
+
     @Override
     public String getVersion() {
         if (fVersion == null) {
@@ -102,30 +102,28 @@ public class LTTngControlService implements ILttngControlService {
      * @param version - a version to set
      */
     public void setVersion(String version) {
-        fVersion = new Version(version);
+        fVersion = new LttngVersion(version);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#isVersionSupported(java.lang.String)
-     */
     @Override
     public boolean isVersionSupported(String version) {
-        Version tmp = new Version(version);
+        LttngVersion tmp = new LttngVersion(version);
         return (fVersion != null && fVersion.compareTo(tmp) >= 0) ? true : false;
     }
 
+    /**
+     * Returns the command shell implementation.
+     *
+     * @return the command shell implementation
+     */
+    protected ICommandShell getCommandShell() {
+        return fCommandShell;
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
-     * #getSessionNames(org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST);
@@ -152,13 +150,6 @@ public class LTTngControlService implements ILttngControlService {
         return retArray.toArray(new String[retArray.size()]);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
-     * #getSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST, sessionName);
@@ -185,26 +176,41 @@ public class LTTngControlService implements ILttngControlService {
                 continue;
             }
 
-            matcher = LTTngControlServiceConstants.TRACE_NETWORK_PATH_PATTERN.matcher(line);
-            if (matcher.matches()) {
-                sessionInfo.setStreamedTrace(true);
-            }
-
-            matcher = LTTngControlServiceConstants.TRACE_SESSION_PATH_PATTERN.matcher(line);
+            matcher = LTTngControlServiceConstants.TRACE_SNAPSHOT_SESSION_PATTERN.matcher(line);
             if (matcher.matches()) {
-                sessionInfo.setSessionPath(matcher.group(1).trim());
+                sessionInfo.setSessionState(matcher.group(2));
+                // real name will be set later
+                ISnapshotInfo snapshotInfo = new SnapshotInfo(""); //$NON-NLS-1$
+                sessionInfo.setSnapshotInfo(snapshotInfo);
                 index++;
                 continue;
             }
 
+            if (!sessionInfo.isSnapshotSession()) {
+                matcher = LTTngControlServiceConstants.TRACE_NETWORK_PATH_PATTERN.matcher(line);
+                if (matcher.matches()) {
+                    sessionInfo.setStreamedTrace(true);
+                }
+
+                matcher = LTTngControlServiceConstants.TRACE_SESSION_PATH_PATTERN.matcher(line);
+                if (matcher.matches()) {
+                    sessionInfo.setSessionPath(matcher.group(1).trim());
+                    index++;
+                    continue;
+                }
+            }
+
             matcher = LTTngControlServiceConstants.DOMAIN_KERNEL_PATTERN.matcher(line);
             if (matcher.matches()) {
                 // Create Domain
                 IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_KernelDomainDisplayName);
 
+                // set kernel flag
+                domainInfo.setIsKernel(true);
+
                 // in domain kernel
                 ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
-                index = parseDomain(result.getOutput(), index, channels);
+                index = parseDomain(result.getOutput(), index, channels, domainInfo);
 
                 if (channels.size() > 0) {
                     // add domain
@@ -212,9 +218,6 @@ public class LTTngControlService implements ILttngControlService {
 
                     // set channels
                     domainInfo.setChannels(channels);
-
-                    // set kernel flag
-                    domainInfo.setIsKernel(true);
                 }
                 continue;
             }
@@ -223,9 +226,12 @@ public class LTTngControlService implements ILttngControlService {
             if (matcher.matches()) {
                 IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_UstGlobalDomainDisplayName);
 
+                // set kernel flag
+                domainInfo.setIsKernel(false);
+
                 // in domain UST
                 ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
-                index = parseDomain(result.getOutput(), index, channels);
+                index = parseDomain(result.getOutput(), index, channels, domainInfo);
 
                 if (channels.size() > 0) {
                     // add domain
@@ -233,24 +239,55 @@ public class LTTngControlService implements ILttngControlService {
 
                     // set channels
                     domainInfo.setChannels(channels);
-
-                    // set kernel flag
-                    domainInfo.setIsKernel(false);
                 }
                 continue;
             }
             index++;
         }
+
+        if (sessionInfo.isSnapshotSession()) {
+            ISnapshotInfo snapshot = getSnapshotInfo(sessionName, monitor);
+            sessionInfo.setSnapshotInfo(snapshot);
+        }
+
         return sessionInfo;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
-     * #getKernelProvider(org.eclipse.core.runtime.IProgressMonitor)
-     */
+    @Override
+    public ISnapshotInfo getSnapshotInfo(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+        StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_SNAPSHOT_OUTPUT, LTTngControlServiceConstants.OPTION_SESSION, sessionName);
+        ICommandResult result = executeCommand(command.toString(), monitor);
+
+        int index = 0;
+
+        // Output:
+        // [1] snapshot-1: /home/user/lttng-traces/my-20130909-114431
+        // or
+        // [3] snapshot-3: net4://172.0.0.1/
+        ISnapshotInfo snapshotInfo = new SnapshotInfo(""); //$NON-NLS-1$
+
+        while (index < result.getOutput().length) {
+            String line = result.getOutput()[index];
+            Matcher matcher = LTTngControlServiceConstants.LIST_SNAPSHOT_OUTPUT_PATTERN.matcher(line);
+            if (matcher.matches()) {
+                snapshotInfo.setId(Integer.valueOf(matcher.group(1)));
+                snapshotInfo.setName(matcher.group(2));
+                snapshotInfo.setSnapshotPath(matcher.group(3));
+
+                Matcher matcher2 = LTTngControlServiceConstants.SNAPSHOT_NETWORK_PATH_PATTERN.matcher(snapshotInfo.getSnapshotPath());
+                if (matcher2.matches()) {
+                    snapshotInfo.setStreamedSnapshot(true);
+                }
+
+                index++;
+                break;
+            }
+            index++;
+        }
+
+        return snapshotInfo;
+    }
+
     @Override
     public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_KERNEL);
@@ -287,25 +324,11 @@ public class LTTngControlService implements ILttngControlService {
         return events;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
-     * #getUstProvider()
-     */
     @Override
     public List<IUstProviderInfo> getUstProvider() throws ExecutionException {
         return getUstProvider(new NullProgressMonitor());
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
-     * #getUstProvider(org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_UST);
@@ -314,7 +337,36 @@ public class LTTngControlService implements ILttngControlService {
             command.append(LTTngControlServiceConstants.OPTION_FIELDS);
         }
 
-        ICommandResult result = executeCommand(command.toString(), monitor);
+        ICommandResult result = executeCommand(command.toString(), monitor, false);
+        List<IUstProviderInfo> allProviders = new ArrayList<IUstProviderInfo>();
+
+        // Workaround for versions 2.0.x which causes a segmentation fault for this command
+        // if LTTng Tools is compiled without UST support.
+        if (!isVersionSupported("2.1.0") && (result.getResult() != 0)) { //$NON-NLS-1$
+            return allProviders;
+        }
+
+        if (result.getOutput() != null) {
+            // Ignore the following 2 cases:
+            // Spawning a session daemon
+            // Error: Unable to list UST events: Listing UST events failed
+            // or:
+            // Error: Unable to list UST events: Listing UST events failed
+            //
+            int index = 0;
+            while (index < result.getOutput().length) {
+                String line = result.getOutput()[index];
+                Matcher matcher = LTTngControlServiceConstants.LIST_UST_NO_UST_PROVIDER_PATTERN.matcher(line);
+                if (matcher.matches()) {
+                    return allProviders;
+                }
+                index++;
+            }
+        }
+
+        if (isError(result)) {
+            throw new ExecutionException(Messages.TraceControl_CommandError + " " + command.toString() + "\n" + formatOutput(result)); //$NON-NLS-1$ //$NON-NLS-2$
+        }
 
         // Note that field print-outs exists for version >= 2.1.0
         //
@@ -339,7 +391,6 @@ public class LTTngControlService implements ILttngControlService {
         //    field: floatfield (float)
         //    field: stringfield (string)
 
-        List<IUstProviderInfo> allProviders = new ArrayList<IUstProviderInfo>();
         IUstProviderInfo provider = null;
 
         int index = 0;
@@ -356,17 +407,12 @@ public class LTTngControlService implements ILttngControlService {
             } else {
                 index++;
             }
-
         }
         return allProviders;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
-    public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+    public ISessionInfo createSession(String sessionName, String sessionPath, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException {
 
         String newName = formatParameter(sessionName);
         String newPath = formatParameter(sessionPath);
@@ -378,6 +424,10 @@ public class LTTngControlService implements ILttngControlService {
             command.append(newPath);
         }
 
+        if (isSnapshot) {
+            command.append(LTTngControlServiceConstants.OPTION_SNAPSHOT);
+        }
+
         ICommandResult result = executeCommand(command.toString(), monitor);
 
         //Session myssession2 created.
@@ -411,28 +461,35 @@ public class LTTngControlService implements ILttngControlService {
         SessionInfo sessionInfo = new SessionInfo(name);
 
         // Verify session path
-        if ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath)))) {
+        if (!isSnapshot &&
+                ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath))))) {
             // Unexpected path
             throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
                     Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
         }
 
-        sessionInfo.setSessionPath(path);
+        if (isSnapshot) {
+            // Make it a snapshot session - content of snapshot info need to
+            // set afterwards using getSession() or getSnapshotInfo()
+            sessionInfo.setSnapshotInfo(new SnapshotInfo("")); //$NON-NLS-1$
+        } else {
+            sessionInfo.setSessionPath(path);
+        }
 
         return sessionInfo;
 
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
-    public ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, IProgressMonitor monitor) throws ExecutionException {
+    public ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException {
 
         String newName = formatParameter(sessionName);
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CREATE_SESSION, newName);
 
+        if (isSnapshot) {
+            command.append(LTTngControlServiceConstants.OPTION_SNAPSHOT);
+        }
+
         if (networkUrl != null) {
             command.append(LTTngControlServiceConstants.OPTION_NETWORK_URL);
             command.append(networkUrl);
@@ -480,20 +537,24 @@ public class LTTngControlService implements ILttngControlService {
 
         // Verify session path
         if (networkUrl != null) {
-            if (path == null) {
+            if (!isSnapshot && (path == null)) {
                 // Unexpected path
                 throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
                         Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
             }
 
-            sessionInfo.setSessionPath(path);
-
-            // Check file protocol
-            Matcher matcher = LTTngControlServiceConstants.TRACE_FILE_PROTOCOL_PATTERN.matcher(path);
-            if (matcher.matches()) {
+            if (isSnapshot) {
                 sessionInfo.setStreamedTrace(false);
+            } else {
+                sessionInfo.setSessionPath(path);
+                // Check file protocol
+                Matcher matcher = LTTngControlServiceConstants.TRACE_FILE_PROTOCOL_PATTERN.matcher(path);
+                if (matcher.matches()) {
+                    sessionInfo.setStreamedTrace(false);
+                }
             }
         }
+
         // When using controlUrl and dataUrl the full session path is not known yet
         // and will be set later on when listing the session
 
@@ -530,10 +591,6 @@ public class LTTngControlService implements ILttngControlService {
         //Session <sessionName> destroyed
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#startSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
 
@@ -546,10 +603,6 @@ public class LTTngControlService implements ILttngControlService {
         //Session <sessionName> started
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#stopSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
         String newSessionName = formatParameter(sessionName);
@@ -561,10 +614,6 @@ public class LTTngControlService implements ILttngControlService {
 
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableChannel(java.lang.String, java.util.List, boolean, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
 
@@ -602,31 +651,59 @@ public class LTTngControlService implements ILttngControlService {
             }
 //            --subbuf-size SIZE   Subbuffer size in bytes
 //                                     (default: 4096, kernel default: 262144)
-            command.append(LTTngControlServiceConstants.OPTION_SUB_BUFFER_SIZE);
-            command.append(String.valueOf(info.getSubBufferSize()));
+            if (info.getSubBufferSize() != LTTngControlServiceConstants.UNUSED_VALUE) {
+                command.append(LTTngControlServiceConstants.OPTION_SUB_BUFFER_SIZE);
+                command.append(String.valueOf(info.getSubBufferSize()));
+            }
 
 //            --num-subbuf NUM     Number of subbufers
-//                                     (default: 8, kernel default: 4)
-            command.append(LTTngControlServiceConstants.OPTION_NUM_SUB_BUFFERS);
-            command.append(String.valueOf(info.getNumberOfSubBuffers()));
+            if (info.getNumberOfSubBuffers() != LTTngControlServiceConstants.UNUSED_VALUE) {
+                command.append(LTTngControlServiceConstants.OPTION_NUM_SUB_BUFFERS);
+                command.append(String.valueOf(info.getNumberOfSubBuffers()));
+            }
 
-//            --switch-timer USEC  Switch timer interval in usec (default: 0)
-            command.append(LTTngControlServiceConstants.OPTION_SWITCH_TIMER);
-            command.append(String.valueOf(info.getSwitchTimer()));
+//            --switch-timer USEC  Switch timer interval in usec
+            if (info.getSwitchTimer() != LTTngControlServiceConstants.UNUSED_VALUE) {
+                command.append(LTTngControlServiceConstants.OPTION_SWITCH_TIMER);
+                command.append(String.valueOf(info.getSwitchTimer()));
+            }
 
-//            --read-timer USEC    Read timer interval in usec (default: 200)
-            command.append(LTTngControlServiceConstants.OPTION_READ_TIMER);
-            command.append(String.valueOf(info.getReadTimer()));
+//            --read-timer USEC    Read timer interval in usec
+            if (info.getReadTimer() != LTTngControlServiceConstants.UNUSED_VALUE) {
+                command.append(LTTngControlServiceConstants.OPTION_READ_TIMER);
+                command.append(String.valueOf(info.getReadTimer()));
+            }
+
+            if (isVersionSupported("2.2.0")) { //$NON-NLS-1$
+//                --buffers-uid  Every application sharing the same UID use the same buffers
+//                --buffers-pid Buffers are allocated per PID
+                if (!isKernel) {
+                    if (info.getBufferType() == BufferType.BUFFER_PER_PID) {
+                        command.append(LTTngControlServiceConstants.OPTION_PER_PID_BUFFERS);
+
+                    } else if (info.getBufferType() == BufferType.BUFFER_PER_UID) {
+                        command.append(LTTngControlServiceConstants.OPTION_PER_UID_BUFFERS);
+                    }
+                }
+
+//                -C SIZE   Maximum size of trace files in bytes
+                if (info.getMaxSizeTraceFiles() != LTTngControlServiceConstants.UNUSED_VALUE) {
+                    command.append(LTTngControlServiceConstants.OPTION_MAX_SIZE_TRACE_FILES);
+                    command.append(String.valueOf(info.getMaxSizeTraceFiles()));
+                }
+
+//                -W NUM   Maximum number of trace files
+                if (info.getMaxNumberTraceFiles() != LTTngControlServiceConstants.UNUSED_VALUE) {
+                    command.append(LTTngControlServiceConstants.OPTION_MAX_TRACE_FILES);
+                    command.append(String.valueOf(info.getMaxNumberTraceFiles()));
+                }
+            }
         }
 
         executeCommand(command.toString(), monitor);
 
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableChannel(java.lang.String, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
 
@@ -658,10 +735,6 @@ public class LTTngControlService implements ILttngControlService {
         executeCommand(command.toString(), monitor);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableEvents(java.lang.String, java.lang.String, java.util.List, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
 
@@ -711,10 +784,6 @@ public class LTTngControlService implements ILttngControlService {
 
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableSyscalls(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException {
 
@@ -738,10 +807,6 @@ public class LTTngControlService implements ILttngControlService {
         executeCommand(command.toString(), monitor);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableProbe(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT);
@@ -768,10 +833,6 @@ public class LTTngControlService implements ILttngControlService {
         executeCommand(command.toString(), monitor);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableLogLevel(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT);
@@ -801,12 +862,6 @@ public class LTTngControlService implements ILttngControlService {
         executeCommand(command.toString(), monitor);
     }
 
-
-
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_DISABLE_EVENT);
@@ -848,10 +903,6 @@ public class LTTngControlService implements ILttngControlService {
         executeCommand(command.toString(), monitor);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#getContexts(org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public List<String> getContextList(IProgressMonitor monitor) throws ExecutionException {
 
@@ -886,10 +937,6 @@ public class LTTngControlService implements ILttngControlService {
         return contexts;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#addContexts(java.lang.String, java.lang.String, java.lang.String, boolean, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void addContexts(String sessionName, String channelName, String eventName, boolean isKernel, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ADD_CONTEXT);
@@ -924,17 +971,9 @@ public class LTTngControlService implements ILttngControlService {
 
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#calibrate(boolean, org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void calibrate(boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
-//        String newSessionName = formatParameter(sessionName);
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CALIBRATE);
-//
-//        command.append(OPTION_SESSION);
-//        command.append(newSessionName);
 
         if (isKernel) {
             command.append(LTTngControlServiceConstants.OPTION_KERNEL);
@@ -947,9 +986,22 @@ public class LTTngControlService implements ILttngControlService {
         executeCommand(command.toString(), monitor);
     }
 
+    @Override
+    public void recordSnapshot(String sessionName, IProgressMonitor monitor)
+            throws ExecutionException {
+        StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_RECORD_SNAPSHOT);
+
+        String newSessionName = formatParameter(sessionName);
+        command.append(LTTngControlServiceConstants.OPTION_SESSION);
+        command.append(newSessionName);
+
+        executeCommand(command.toString(), monitor);
+    }
+
     // ------------------------------------------------------------------------
     // Helper methods
     // ------------------------------------------------------------------------
+
     /**
      * Checks if command result is an error result.
      *
@@ -994,7 +1046,7 @@ public class LTTngControlService implements ILttngControlService {
         ret.append(result.getResult());
         ret.append("\n"); //$NON-NLS-1$
         for (int i = 0; i < output.length; i++) {
-            ret.append(output[i] + "\n"); //$NON-NLS-1$
+            ret.append(output[i]).append("\n"); //$NON-NLS-1$
         }
         return ret.toString();
     }
@@ -1008,11 +1060,18 @@ public class LTTngControlService implements ILttngControlService {
      *            - current index in command output array
      * @param channels
      *            - list for returning channel information
+     * @param domainInfo
+     *            - The domain information
      * @return the new current index in command output array
      */
-    protected int parseDomain(String[] output, int currentIndex, List<IChannelInfo> channels) {
+    protected int parseDomain(String[] output, int currentIndex, List<IChannelInfo> channels, IDomainInfo domainInfo) {
         int index = currentIndex;
 
+        // if kernel set the buffer type to shared
+        if (domainInfo.isKernel()) {
+            domainInfo.setBufferType(BufferType.BUFFER_SHARED);
+        }
+
         // Channels:
         // -------------
         // - channnel1: [enabled]
@@ -1028,6 +1087,21 @@ public class LTTngControlService implements ILttngControlService {
         while (index < output.length) {
             String line = output[index];
 
+            if (isVersionSupported("2.2.0")) { //$NON-NLS-1$
+                Matcher bufferTypeMatcher = LTTngControlServiceConstants.BUFFER_TYPE_PATTERN.matcher(line);
+                if (bufferTypeMatcher.matches()) {
+                    String bufferTypeString = getAttributeValue(line);
+                    if (BufferType.BUFFER_PER_PID.getInName().equals(bufferTypeString)) {
+                        domainInfo.setBufferType(BufferType.BUFFER_PER_PID);
+                    } else if (BufferType.BUFFER_PER_UID.getInName().equals(bufferTypeString)) {
+                        domainInfo.setBufferType(BufferType.BUFFER_PER_UID);
+                    } else {
+                        domainInfo.setBufferType(BufferType.BUFFER_TYPE_UNKNOWN);
+                    }
+                }
+            } else {
+                domainInfo.setBufferType(BufferType.BUFFER_TYPE_UNKNOWN);
+            }
             Matcher outerMatcher = LTTngControlServiceConstants.CHANNELS_SECTION_PATTERN.matcher(line);
             Matcher noKernelChannelMatcher = LTTngControlServiceConstants.DOMAIN_NO_KERNEL_CHANNEL_PATTERN.matcher(line);
             Matcher noUstChannelMatcher = LTTngControlServiceConstants.DOMAIN_NO_UST_CHANNEL_PATTERN.matcher(line);
@@ -1045,6 +1119,9 @@ public class LTTngControlService implements ILttngControlService {
                         // get channel enablement
                         channelInfo.setState(innerMatcher.group(2));
 
+                        // set BufferType
+                        channelInfo.setBufferType(domainInfo.getBufferType());
+
                         // add channel
                         channels.add(channelInfo);
 
@@ -1210,10 +1287,6 @@ public class LTTngControlService implements ILttngControlService {
             } else {
                 index++;
             }
-//            else if (line.matches(EVENT_NONE_PATTERN)) {
-                // do nothing
-//            } else
-
         }
 
         return index;
This page took 0.031375 seconds and 5 git commands to generate.