diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index ae63e7d205b..b26951d3878 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,11 @@ +2004-06-08 Alain Magloire + + Fix for PR 65077 + + * mi/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java + * mi/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentCD.jav + * src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java + 2004-06-02 Mikhail Khodjaiants Moved externalized strings to the right property file. diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java index 2ca72c38e47..43c933885e4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java @@ -16,4 +16,10 @@ public class CygwinCommandFactory extends CommandFactory { return new CygwinMIEnvironmentDirectory(pathdirs); } + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.core.command.CommandFactory#createMIEnvironmentCD(java.lang.String) + */ + public MIEnvironmentCD createMIEnvironmentCD(String pathdir) { + return new CygwinMIEnvironmentCD(pathdir); + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentCD.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentCD.java new file mode 100644 index 00000000000..1da55a91cd7 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentCD.java @@ -0,0 +1,78 @@ +/********************************************************************** + * Copyright (c) 2002,2003,2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ + +package org.eclipse.cdt.debug.mi.core.command; + +import java.io.ByteArrayOutputStream; + +import org.eclipse.cdt.core.CommandLauncher; +import org.eclipse.core.runtime.Path; + +/** + * CygwinMIEnvironmentCD + */ +public class CygwinMIEnvironmentCD extends MIEnvironmentCD { + + /** + * @param path + */ + public CygwinMIEnvironmentCD(String path) { + super(path); + + // Use the cygpath utility to convert the path + CommandLauncher launcher = new CommandLauncher(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + ByteArrayOutputStream err = new ByteArrayOutputStream(); + + String newPath = null; + launcher.execute( + new Path("cygpath"), //$NON-NLS-1$ + new String[] { "-u", path }, //$NON-NLS-1$ + new String[0], + new Path(".")); //$NON-NLS-1$ + if (launcher.waitAndRead(output, err) == CommandLauncher.OK) { + newPath = output.toString().trim(); + if (newPath != null && newPath.length() > 0) { + path = newPath; + } + } + + setParameters(new String[]{newPath}); + + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.core.command.MICommand#parametersToString() + */ + protected String parametersToString() { + if (parameters != null && parameters.length == 1) { + StringBuffer sb = new StringBuffer(); + // We need to escape the double quotes and the backslash. + String param = parameters[0]; + for (int j = 0; j < param.length(); j++) { + char c = param.charAt(j); + if (c == '"' || c == '\\') { + sb.append('\\'); + } + sb.append(c); + } + + // If the string contains spaces instead of escaping + // surround the parameter with double quotes. + if (containsWhitespace(param)) { + sb.insert(0, '"'); + sb.append('"'); + } + return sb.toString().trim(); + } + return super.parametersToString(); + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java index 582ebe863c8..7507658e168 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java @@ -86,7 +86,6 @@ public class CygwinGDBDebugger extends GDBDebugger { // We ignore this exception, for example // on GNU/Linux the new-console is an error. } - initializeLibraries(config, session); return session; } catch (CDIException e) { failed = true;