Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 202543 Details for
Bug 353056
Add support for multiple Valgrind launch configs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Create an extension point to change the valgrind executable path
0001-Valgrind-Adding-extension-point-to-set-the-valgrind-.patch (text/plain), 30.77 KB, created by
Otavio Pontes
on 2011-08-31 13:06:26 EDT
(
hide
)
Description:
Create an extension point to change the valgrind executable path
Filename:
MIME Type:
Creator:
Otavio Pontes
Created:
2011-08-31 13:06:26 EDT
Size:
30.77 KB
patch
obsolete
>From f20221d6c5ec5d0d803aea3db08e7cb572ce5ee8 Mon Sep 17 00:00:00 2001 >From: Otavio Pontes <obusatto@br.ibm.com> >Date: Mon, 29 Aug 2011 13:24:52 -0300 >Subject: [PATCH] Valgrind: Adding extension point to set the valgrind > location path > >--- > .../plugin.xml | 1 + > .../schema/valgrindLocation.exsd | 71 ++++++++++++++++ > .../internal/valgrind/core/ValgrindCommand.java | 82 +++++++++++++++--- > .../valgrind/core/IValgrindLocation.java | 18 ++++ > .../ValgrindLaunchConfigurationDelegate.java | 32 +++++-- > .../valgrind/launch/ValgrindLaunchPlugin.java | 87 +++++--------------- > .../valgrind/launch/ValgrindOptionsTab.java | 24 +++--- > .../memcheck/tests/LocationPreferenceTest.java | 7 +- > .../valgrind/memcheck/tests/MinVersionTest.java | 49 ++++++----- > .../valgrind/tests/AbstractValgrindTest.java | 17 ++-- > .../valgrind/tests/ValgrindStubCommand.java | 3 + > .../valgrind/tests/ValgrindTestLaunchDelegate.java | 4 +- > 12 files changed, 261 insertions(+), 134 deletions(-) > create mode 100644 valgrind/org.eclipse.linuxtools.valgrind.core/schema/valgrindLocation.exsd > create mode 100644 valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/IValgrindLocation.java > >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.core/plugin.xml b/valgrind/org.eclipse.linuxtools.valgrind.core/plugin.xml >index 6c85d73..5afa700 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.core/plugin.xml >+++ b/valgrind/org.eclipse.linuxtools.valgrind.core/plugin.xml >@@ -1,6 +1,7 @@ > <?xml version="1.0" encoding="UTF-8"?> > <?eclipse version="3.4"?> > <plugin> >+ <extension-point id="valgrindLocation" name="valgrindLocation" schema="schema/valgrindLocation.exsd"/> > <extension > point="org.eclipse.ui.preferencePages"> > <page >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.core/schema/valgrindLocation.exsd b/valgrind/org.eclipse.linuxtools.valgrind.core/schema/valgrindLocation.exsd >new file mode 100644 >index 0000000..262d3ff >--- /dev/null >+++ b/valgrind/org.eclipse.linuxtools.valgrind.core/schema/valgrindLocation.exsd >@@ -0,0 +1,71 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.linuxtools.valgrind.core" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.linuxtools.valgrind.core" id="valgrindLocation" name="valgrindLocation"/> >+ </appinfo> >+ <documentation> >+ Sets the Valgrition binary location to be used by valgrind plugins >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="valgrindLocation"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="valgrindLocation"> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Location class. Must implement IValgrindLocation. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.valgrind.core.IValgrindLocation"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ <attribute name="priority" type="string" use="default" value="0"> >+ <annotation> >+ <documentation> >+ Priority for this location. If there are other plugins adding ValgrindLocations the location with higher property will be used. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+</schema> >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCommand.java b/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCommand.java >index 599b07f..5b6d0e3 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCommand.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCommand.java >@@ -17,30 +17,84 @@ import java.io.InputStream; > import org.eclipse.cdt.utils.pty.PTY; > import org.eclipse.cdt.utils.spawner.ProcessFactory; > >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+ >+import org.eclipse.debug.core.ILaunchConfiguration; >+ >+import org.eclipse.linuxtools.valgrind.core.IValgrindLocation; >+ > public class ValgrindCommand { > protected static final String WHICH_CMD = "which"; //$NON-NLS-1$ > protected static final String VALGRIND_CMD = "valgrind"; //$NON-NLS-1$ >+ protected static final String EXTENSION_POINT_PRIORITY = "priority"; //$NON-NLS-1$ >+ protected static final String EXTENSION_POINT_CLASS = "class"; //$NON-NLS-1$ >+ protected static final String EXTENSION_POINT_ID = "valgrindLocation"; //$NON-NLS-1$ > > protected Process process; > protected String[] args; >+ protected ILaunchConfiguration config; >+ >+ public ValgrindCommand (ILaunchConfiguration config) { >+ this.config = config; >+ } >+ >+ public ValgrindCommand () { >+ this(null); >+ } >+ >+ private IConfigurationElement getHighestPriority(IConfigurationElement[] elements) { >+ if (elements.length == 0) >+ return null; >+ >+ int priority = Integer.parseInt(elements[0].getAttribute(EXTENSION_POINT_PRIORITY)); >+ IConfigurationElement highest = elements[0]; >+ for (int i = 1; i < elements.length; i++) { >+ int priority2 = Integer.parseInt(elements[i].getAttribute(EXTENSION_POINT_PRIORITY)); >+ if (priority2 > priority) { >+ priority = priority2; >+ highest = elements[i]; >+ } >+ } >+ return highest; >+ } >+ >+ private String getExtensionPointLocation() { >+ IExtensionPoint ep = Platform.getExtensionRegistry(). >+ getExtensionPoint(PluginConstants.CORE_PLUGIN_ID, EXTENSION_POINT_ID); >+ if (ep == null) >+ return null; >+ >+ IConfigurationElement element = getHighestPriority(ep.getConfigurationElements()); >+ if (element == null) >+ return null; >+ >+ try { >+ return ((IValgrindLocation)element.createExecutableExtension(EXTENSION_POINT_CLASS)).getValgrindLocation(config); >+ } catch (CoreException e) { >+ return null; >+ } >+ } > > public String whichValgrind() throws IOException { >- String ret; >- >+ // Valgrind binary location set in extension point overrides every other definition >+ String valgrindExtensionPointLocation = getExtensionPointLocation(); >+ if (valgrindExtensionPointLocation != null) >+ return valgrindExtensionPointLocation; >+ > // Valgrind binary location in preferences overrides default location > String valgrindPreferedPath = ValgrindPlugin.getDefault().getPreferenceStore().getString(ValgrindPreferencePage.VALGRIND_PATH); >- if (valgrindPreferedPath.equals("")) { //$NON-NLS-1$ >- // No preference, check Valgrind exists in the user's PATH >- StringBuffer out = new StringBuffer(); >- Process p = Runtime.getRuntime().exec(WHICH_CMD + " " + VALGRIND_CMD); //$NON-NLS-1$ >- // Throws IOException if which command is unsuccessful >- readIntoBuffer(out, p); >- ret = out.toString().trim(); >- } >- else { >- ret = valgrindPreferedPath; >- } >- return ret; >+ if (!valgrindPreferedPath.equals("")) >+ return valgrindPreferedPath; >+ >+ // No preference, check Valgrind exists in the user's PATH >+ StringBuffer out = new StringBuffer(); >+ Process p = Runtime.getRuntime().exec(WHICH_CMD + " " + VALGRIND_CMD); //$NON-NLS-1$ >+ // Throws IOException if which command is unsuccessful >+ readIntoBuffer(out, p); >+ return out.toString().trim(); > } > > /** >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/IValgrindLocation.java b/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/IValgrindLocation.java >new file mode 100644 >index 0000000..ece3074 >--- /dev/null >+++ b/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/valgrind/core/IValgrindLocation.java >@@ -0,0 +1,18 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM, Inc. >+ * 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: >+ * Otavio Pontes <obusatto@br.ibm.com> - initial API >+ *******************************************************************************/ >+package org.eclipse.linuxtools.valgrind.core; >+ >+import org.eclipse.debug.core.ILaunchConfiguration; >+ >+public interface IValgrindLocation { >+ >+ public abstract String getValgrindLocation(ILaunchConfiguration configuration); >+} >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java >index 6aecae8..b95906a 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java >@@ -80,6 +80,7 @@ public class ValgrindLaunchConfigurationDelegate extends AbstractCLaunchDelegate > protected ILaunch launch; > protected IProcess process; > protected String launchStr; >+ protected IPath valgrindLocation; > protected Version valgrindVersion; // null if not used > > public void launch(ILaunchConfiguration config, String mode, >@@ -97,7 +98,7 @@ public class ValgrindLaunchConfigurationDelegate extends AbstractCLaunchDelegate > this.config = config; > this.launch = launch; > try { >- command = getValgrindCommand(); >+ command = getValgrindCommand(config); > > // remove any output from previous run > ValgrindUIPlugin.getDefault().resetView(); >@@ -105,10 +106,8 @@ public class ValgrindLaunchConfigurationDelegate extends AbstractCLaunchDelegate > getPlugin().setCurrentLaunchConfiguration(null); > getPlugin().setCurrentLaunch(null); > >- // find Valgrind binary if not already done >- IPath valgrindLocation = getPlugin().getValgrindLocation(); >- // also ensure Valgrind version is usable >- valgrindVersion = getPlugin().getValgrindVersion(); >+ findValgrindLocation(); >+ findValgrindVersion(); > > monitor.worked(1); > IPath exePath = CDebugUtils.verifyProgramPath(config); >@@ -196,6 +195,25 @@ public class ValgrindLaunchConfigurationDelegate extends AbstractCLaunchDelegate > } > } > >+ protected ValgrindCommand getValgrindCommand(ILaunchConfiguration config ) { >+ return new ValgrindCommand(config); >+ } >+ >+ private void findValgrindLocation() throws CoreException { >+ if (command == null) >+ return; >+ valgrindLocation = ValgrindLaunchPlugin.getValgrindLocation(command); >+ } >+ >+ private void findValgrindVersion() throws CoreException { >+ if (command == null) >+ return; >+ >+ if (valgrindLocation == null) >+ findValgrindLocation(); >+ valgrindVersion = ValgrindLaunchPlugin.getValgrindVersion(command, valgrindLocation); >+ } >+ > protected IValgrindMessage[] parseLogs(IPath outputPath) throws IOException, CoreException { > List<IValgrindMessage> messages = new ArrayList<IValgrindMessage>(); > >@@ -267,10 +285,6 @@ public class ValgrindLaunchConfigurationDelegate extends AbstractCLaunchDelegate > return DebugPlugin.newProcess(launch, systemProcess, renderProcessLabel(programName)); > } > >- protected ValgrindCommand getValgrindCommand() { >- return getPlugin().getValgrindCommand(); >- } >- > protected ValgrindLaunchPlugin getPlugin() { > return ValgrindLaunchPlugin.getDefault(); > } >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java >index d20576d..57ff36e 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java >@@ -42,7 +42,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.BundleContext; > import org.osgi.framework.Version; > >-public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyChangeListener { >+public class ValgrindLaunchPlugin extends AbstractUIPlugin { > > // The plug-in ID > public static final String PLUGIN_ID = PluginConstants.LAUNCH_PLUGIN_ID; >@@ -72,9 +72,6 @@ public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC > > protected HashMap<String, IConfigurationElement> toolMap; > >- private ValgrindCommand valgrindCommand; >- private IPath valgrindLocation; >- private Version valgrindVersion; > private ILaunchConfiguration config; > private ILaunch launch; > >@@ -94,9 +91,6 @@ public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC > public void start(BundleContext context) throws Exception { > super.start(context); > plugin = this; >- >- // Register as listener for changes to the property page >- ValgrindPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); > } > > /* >@@ -117,37 +111,14 @@ public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC > return plugin; > } > >- public IPath getValgrindLocation() throws CoreException { >- if (valgrindLocation == null) { >- findValgrindLocation(); >- } >- >- return valgrindLocation; >- } >- >- public void setValgrindLocation(IPath valgrindLocation) { >- this.valgrindLocation = valgrindLocation; >+ public static IPath getValgrindLocation() throws CoreException { >+ return getValgrindLocation(new ValgrindCommand()); > } >- >- public Version getValgrindVersion() throws CoreException { >- if (valgrindVersion == null) { >- findValgrindVersion(); >- } >- // check for minimum supported version >- if (valgrindVersion.compareTo(MIN_VER) < 0) { >- throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Error_min_version"), valgrindVersion.toString(), MIN_VER.toString()))); //$NON-NLS-1$ >- } >- return valgrindVersion; >- } >- >- public void setValgrindVersion(Version valgrindVersion) { >- this.valgrindVersion = valgrindVersion; >- } >- >- private void findValgrindLocation() throws CoreException { >- if (getValgrindCommand().isEnabled()) { >+ >+ public static IPath getValgrindLocation(ValgrindCommand command) throws CoreException { >+ if (command.isEnabled()) { > try { >- valgrindLocation = Path.fromOSString(getValgrindCommand().whichValgrind()); >+ return Path.fromOSString(command.whichValgrind()); > } catch (IOException e) { > IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Please_ensure_Valgrind"), e); //$NON-NLS-1$ > throw new CoreException(status); >@@ -158,14 +129,11 @@ public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC > throw new CoreException(status); > } > } >- >- private void findValgrindVersion() throws CoreException { >+ >+ public static Version getValgrindVersion(ValgrindCommand command, IPath valgrindLocation) throws CoreException { >+ Version valgrindVersion = null; > try { >- if (valgrindLocation == null) { >- findValgrindLocation(); >- } >- >- String verString = getValgrindCommand().whichVersion(valgrindLocation.toOSString()); >+ String verString = command.whichVersion(valgrindLocation.toOSString()); > verString = verString.replace(VERSION_PREFIX, ""); //$NON-NLS-1$ > if (verString.indexOf(VERSION_DELIMITER) > 0) { > verString = verString.substring(0, verString.indexOf(VERSION_DELIMITER)); >@@ -180,19 +148,19 @@ public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC > IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Couldn't_determine_version"), valgrindLocation), e); //$NON-NLS-1$ > throw new CoreException(status); > } >- } >- >- public void setValgrindCommand(ValgrindCommand command) { >- valgrindCommand = command; >- } >- >- protected ValgrindCommand getValgrindCommand() { >- if (valgrindCommand == null) { >- valgrindCommand = new ValgrindCommand(); >+ >+ // check for minimum supported version >+ if (valgrindVersion.compareTo(MIN_VER) < 0) { >+ throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Error_min_version"), valgrindVersion.toString(), MIN_VER.toString()))); //$NON-NLS-1$ > } >- return valgrindCommand; >+ return valgrindVersion; > } >- >+ >+ public static Version getValgrindVersion() throws CoreException { >+ ValgrindCommand command = new ValgrindCommand(); >+ return getValgrindVersion(command, getValgrindLocation(command)); >+ } >+ > public String[] getRegisteredToolIDs() { > Set<String> ids = getToolMap().keySet(); > return ids.toArray(new String[ids.size()]); >@@ -319,15 +287,4 @@ public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC > } > return toolMap; > } >- >- public void propertyChange(PropertyChangeEvent event) { >- String prop = event.getProperty(); >- if (prop.equals(ValgrindPreferencePage.VALGRIND_PATH) >- || prop.equals(ValgrindPreferencePage.VALGRIND_ENABLE)) { >- // Reset Valgrind location and version >- valgrindLocation = null; >- valgrindVersion = null; >- } >- } >- > } >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java >index 7f3bbb6..4558d28 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java >@@ -24,6 +24,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.linuxtools.internal.valgrind.core.LaunchConfigurationConstants; >+import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand; > import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; >@@ -93,23 +94,14 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab { > protected Exception ex; > > private Version valgrindVersion; >+ private boolean checkVersion; > > public ValgrindOptionsTab() { > this(true); > } > > public ValgrindOptionsTab(boolean checkVersion) { >- if (checkVersion) { >- try { >- valgrindVersion = getPlugin().getValgrindVersion(); >- } catch (CoreException e) { >- ex = e; >- } >- } >- else { >- // Do not check version >- valgrindVersion = null; >- } >+ this.checkVersion = checkVersion; > } > > protected SelectionListener selectListener = new SelectionAdapter() { >@@ -469,6 +461,12 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab { > launchConfigurationWorkingCopy = null; > > try { >+ if (checkVersion) { >+ ValgrindCommand command = getValgrindCommand(configuration); >+ IPath valgrindLocation = ValgrindLaunchPlugin.getValgrindLocation(command); >+ valgrindVersion = ValgrindLaunchPlugin.getValgrindVersion(command, valgrindLocation); >+ } >+ > tool = configuration.getAttribute(LaunchConfigurationConstants.ATTR_TOOL, LaunchConfigurationConstants.DEFAULT_TOOL); > int select = -1; > for (int i = 0; i < tools.length && select < 0; i++) { >@@ -510,6 +508,10 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab { > isInitializing = false; > } > >+ protected ValgrindCommand getValgrindCommand(ILaunchConfiguration configuration) { >+ return new ValgrindCommand(configuration); >+ } >+ > @Override > public boolean isValid(ILaunchConfiguration launchConfig) { > setErrorMessage(null); >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/LocationPreferenceTest.java b/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/LocationPreferenceTest.java >index 6d32fc9..5e98a2f 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/LocationPreferenceTest.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/LocationPreferenceTest.java >@@ -22,7 +22,7 @@ import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchPlugin; > > public class LocationPreferenceTest extends TestCase { > >- private ValgrindCommand command = new ValgrindCommand() { >+ private ValgrindCommand command = new ValgrindCommand(null) { > protected void readIntoBuffer(StringBuffer out, Process p) throws IOException { > // Simulate not finding Valgrind in the user's PATH > throw new IOException(); >@@ -36,9 +36,8 @@ public class LocationPreferenceTest extends TestCase { > public void testManualLocationNoPATH() throws Exception { > // Set a preference for a manual location > ValgrindPlugin.getDefault().getPreferenceStore().setValue(ValgrindPreferencePage.VALGRIND_PATH, "/path/to/valgrind"); >- >- ValgrindLaunchPlugin.getDefault().setValgrindCommand(command); >- >+ ValgrindPlugin.getDefault().getPreferenceStore().setValue(ValgrindPreferencePage.VALGRIND_ENABLE, true); >+ > ValgrindLaunchPlugin.getDefault().getValgrindLocation(); > } > } >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/MinVersionTest.java b/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/MinVersionTest.java >index 33227b7..7e35239 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/MinVersionTest.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/MinVersionTest.java >@@ -10,55 +10,52 @@ > *******************************************************************************/ > package org.eclipse.linuxtools.internal.valgrind.memcheck.tests; > >+import java.io.IOException; >+ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >-import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchPlugin; >+import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand; > import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindOptionsTab; >+import org.eclipse.linuxtools.internal.valgrind.tests.ValgrindStubCommand; >+import org.eclipse.linuxtools.internal.valgrind.tests.ValgrindTestLaunchDelegate; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Shell; >-import org.osgi.framework.Version; > > public class MinVersionTest extends AbstractMemcheckTest { >- private static final Version VER_3_2_1 = new Version(3, 2, 1); >- private Version verSave; >+ private static ValgrindTestLaunchDelegate delegate_3_2_1 = new ValgrindTestLaunchDelegate() { >+ @Override >+ protected ValgrindCommand getValgrindCommand(ILaunchConfiguration config) { >+ return new ValgrindStubCommand() { >+ @Override >+ public String whichVersion(String whichValgrind) throws IOException { >+ return "valgrind-3.2.1"; //$NON-NLS-1$ >+ } >+ }; >+ } >+ }; > > @Override > protected void setUp() throws Exception { > super.setUp(); > proj = createProjectAndBuild("basicTest"); //$NON-NLS-1$ >- >- saveVersion(); > } > >- private void saveVersion() throws CoreException { >- verSave = ValgrindLaunchPlugin.getDefault().getValgrindVersion(); >- ValgrindLaunchPlugin.getDefault().setValgrindVersion(VER_3_2_1); >- } >- > @Override > protected void tearDown() throws Exception { >- restoreVersion(); >- > deleteProject(proj); > super.tearDown(); > } > >- private void restoreVersion() { >- ValgrindLaunchPlugin.getDefault().setValgrindVersion(verSave); >- } >- > public void testLaunchBadVersion() throws Exception { > // Put this back so we can make a valid config >- restoreVersion(); > ILaunchConfiguration config = createConfiguration(proj.getProject()); > // For some reason we downgraded >- saveVersion(); > > CoreException ce = null; > try { >- doLaunch(config, "testDefaults"); //$NON-NLS-1$ >+ doLaunch(config, "testDefaults", delegate_3_2_1); //$NON-NLS-1$ > } catch (CoreException e) { > ce = e; > } >@@ -69,7 +66,17 @@ public class MinVersionTest extends AbstractMemcheckTest { > public void testTabsBadVersion() throws Exception { > Shell testShell = new Shell(Display.getDefault()); > testShell.setLayout(new GridLayout()); >- ValgrindOptionsTab tab = new ValgrindOptionsTab(); >+ ValgrindOptionsTab tab = new ValgrindOptionsTab() { >+ @Override >+ protected ValgrindCommand getValgrindCommand(ILaunchConfiguration config) { >+ return new ValgrindStubCommand() { >+ @Override >+ public String whichVersion(String whichValgrind) throws IOException { >+ return "valgrind-3.2.1"; //$NON-NLS-1$ >+ } >+ }; >+ } >+ }; > > ILaunchConfiguration config = getLaunchConfigType().newInstance(null, getLaunchManager() > .generateLaunchConfigurationName( >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java >index f81c135..d3c7184 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/AbstractValgrindTest.java >@@ -65,10 +65,6 @@ public abstract class AbstractValgrindTest extends AbstractTest { > @Override > protected void setUp() throws Exception { > launches = new ArrayList<ILaunch>(); >- >- // Substitute Valgrind command line interaction >- ValgrindLaunchPlugin.getDefault().setValgrindCommand(getValgrindCommand()); >- > super.setUp(); > } > >@@ -86,7 +82,7 @@ public abstract class AbstractValgrindTest extends AbstractTest { > return getLaunchManager().getLaunchConfigurationType(ValgrindLaunchPlugin.LAUNCH_ID); > } > >- protected ILaunch doLaunch(ILaunchConfiguration config, String testName) throws Exception { >+ protected ILaunch doLaunch(ILaunchConfiguration config, String testName, ValgrindTestLaunchDelegate delegate) throws Exception { > ILaunch launch; > IPath pathToFiles = getPathToFiles(testName); > >@@ -98,7 +94,8 @@ public abstract class AbstractValgrindTest extends AbstractTest { > wc.setAttribute(LaunchConfigurationConstants.ATTR_INTERNAL_OUTPUT_DIR, pathToFiles.toOSString()); > wc.doSave(); > >- ValgrindTestLaunchDelegate delegate = new ValgrindTestLaunchDelegate(); >+ if (delegate == null) >+ delegate = new ValgrindTestLaunchDelegate(); > launch = new Launch(config, ILaunchManager.PROFILE_MODE, null); > > DebugPlugin.getDefault().getLaunchManager().addLaunch(launch); >@@ -111,6 +108,10 @@ public abstract class AbstractValgrindTest extends AbstractTest { > return launch; > } > >+ protected ILaunch doLaunch(ILaunchConfiguration config, String testName) throws Exception { >+ return doLaunch(config, testName); >+ } >+ > protected IPath getPathToFiles(String testName) throws URISyntaxException, > IOException { > URL location = FileLocator.find(getBundle(), new Path("valgrindFiles"), null); //$NON-NLS-1$ >@@ -195,8 +196,8 @@ public abstract class AbstractValgrindTest extends AbstractTest { > return new ValgrindStubCommand(); > } > else { >- return new ValgrindCommand(); >+ return new ValgrindCommand(null); > } > } > >-} >\ No newline at end of file >+} >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindStubCommand.java b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindStubCommand.java >index 7ddc1dd..ab2fef0 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindStubCommand.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindStubCommand.java >@@ -19,6 +19,9 @@ public class ValgrindStubCommand extends ValgrindCommand { > protected static final String VERSION_FILE = ".version"; //$NON-NLS-1$ > > protected int exitcode; >+ public ValgrindStubCommand() { >+ super(null); >+ } > > @Override > public String whichValgrind() throws IOException { >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java >index b33bb03..bc6504b 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.tests/src/org/eclipse/linuxtools/internal/valgrind/tests/ValgrindTestLaunchDelegate.java >@@ -25,12 +25,12 @@ public class ValgrindTestLaunchDelegate extends ValgrindLaunchConfigurationDeleg > protected static final String ERROR_CODE_FILE = ".errorCode"; //$NON-NLS-1$ > > @Override >- protected ValgrindCommand getValgrindCommand() { >+ protected ValgrindCommand getValgrindCommand(ILaunchConfiguration config) { > if (!ValgrindTestsPlugin.RUN_VALGRIND) { > return new ValgrindStubCommand(); > } > else { >- return super.getValgrindCommand(); >+ return super.getValgrindCommand(config); > } > } > >-- >1.7.4.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 353056
:
200320
|
202543
|
204413
|
204414
|
204417
|
204527
|
204528
|
204529
|
204530
|
205314
|
205315
|
205316