From 7a6e4bfd8357a1e45a9bce92f1b43408389d307c Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Wed, 20 Jun 2012 15:16:41 -0400 Subject: [PATCH] Fix for bug 383146 (enable/disable of wildcarded UST events issue) --- .../testfiles/CreateTreeTest.cfg | 6 +++--- .../dialogs/EnableUstEventsComposite.java | 2 +- .../control/service/LTTngControlService.java | 18 +++++++++++------- .../service/LTTngControlServiceFactory.java | 14 +++++++++++++- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/CreateTreeTest.cfg b/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/CreateTreeTest.cfg index 53fa9e4630..09d7c904a5 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/CreateTreeTest.cfg +++ b/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/CreateTreeTest.cfg @@ -2258,7 +2258,7 @@ Channels: -lttng enable-event ust* -u -s mysession -c mychannel --tracepoint +lttng enable-event "ust*" -u -s mysession -c mychannel --tracepoint 0 @@ -2324,7 +2324,7 @@ Channels: -lttng enable-event ust* -u -s mysession --tracepoint +lttng enable-event "ust*" -u -s mysession --tracepoint 0 @@ -2391,7 +2391,7 @@ Channels: -lttng enable-event u* -u -s mysession --tracepoint +lttng enable-event "u*" -u -s mysession --tracepoint 0 diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java index 83347f1f67..8b3ff8628f 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java @@ -200,7 +200,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve */ @Override public String getWildcard() { - return "\"" + fWildcard + "\""; //$NON-NLS-1$//$NON-NLS-2$ + return fWildcard; } /* diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java index d5e3b03b63..fce82526ea 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java @@ -523,13 +523,15 @@ public class LTTngControlService implements ILttngControlService { command.append(LTTngControlServiceConstants.OPTION_ALL); } else { + StringBuffer eventNameParameter = new StringBuffer(); for (Iterator iterator = eventNames.iterator(); iterator.hasNext();) { String event = iterator.next(); - command.append(event); + eventNameParameter.append(event); if (iterator.hasNext()) { - command.append(','); + eventNameParameter.append(','); } } + command.append(formatParameter(eventNameParameter.toString())); } if (isKernel) { @@ -656,18 +658,20 @@ public class LTTngControlService implements ILttngControlService { if (eventNames == null) { command.append(LTTngControlServiceConstants.OPTION_ALL); } else { - // no events to enable + // no events to disable if (eventNames.isEmpty()) { return; } + StringBuffer eventNameParameter = new StringBuffer(); for (Iterator iterator = eventNames.iterator(); iterator.hasNext();) { String event = iterator.next(); - command.append(event); + eventNameParameter.append(event); if (iterator.hasNext()) { - command.append(','); + eventNameParameter.append(','); } } + command.append(formatParameter(eventNameParameter.toString())); } if (isKernel) { @@ -811,7 +815,7 @@ public class LTTngControlService implements ILttngControlService { * - output array * @return - the formatted output */ - protected String formatOutput(ICommandResult result) { + public static String formatOutput(ICommandResult result) { if ((result == null) || result.getOutput() == null || result.getOutput().length == 0) { return ""; //$NON-NLS-1$ } @@ -1070,7 +1074,7 @@ public class LTTngControlService implements ILttngControlService { StringBuffer newString = new StringBuffer(); newString.append(parameter); - if (parameter.contains(" ")) { //$NON-NLS-1$ + if (parameter.contains(" ") || parameter.contains("*")) { //$NON-NLS-1$ //$NON-NLS-2$ newString.insert(0, "\""); //$NON-NLS-1$ newString.append("\""); //$NON-NLS-1$ } diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java index b9def2b191..26649d563c 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java @@ -15,7 +15,9 @@ import java.util.regex.Matcher; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.NullProgressMonitor; +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; @@ -72,7 +74,17 @@ public class LTTngControlServiceFactory { */ public ILttngControlService getLttngControlService(ICommandShell shell) throws ExecutionException { // get the version - ICommandResult result = shell.executeCommand(LTTngControlServiceConstants.CONTROL_COMMAND + LTTngControlServiceConstants.COMMAND_VERSION, new NullProgressMonitor()); + String command = LTTngControlServiceConstants.CONTROL_COMMAND + LTTngControlServiceConstants.COMMAND_VERSION; + + if (ControlPreferences.getInstance().isLoggingEnabled()) { + ControlCommandLogger.log(command); + } + + ICommandResult result = shell.executeCommand(command, new NullProgressMonitor()); + + if (ControlPreferences.getInstance().isLoggingEnabled()) { + ControlCommandLogger.log(LTTngControlService.formatOutput(result)); + } if ((result != null) && (result.getResult() == 0) && (result.getOutput().length >= 1) && (!LTTngControlServiceConstants.ERROR_PATTERN.matcher(result.getOutput()[0]).matches())) { int index = 0; -- 2.34.1