From 624446b2c348b895417f9564d946b2fad0c55816 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 30 Jan 2015 14:03:21 -0500 Subject: [PATCH] Bug 458499 - Unable to debug when GDB command contains additional arguments Change-Id: I0cfb07dd04d28062a653f76dbd23510d712e4c71 Signed-off-by: Marc Khouzam --- .../cdt/dsf/gdb/launching/LaunchUtils.java | 10 +++++--- .../cdt/dsf/gdb/service/GDBBackend.java | 23 +++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java index 9145957ecb4..a57d392adba 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 Ericsson and others. + * Copyright (c) 2010, 2015 Ericsson and others. * 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 @@ -46,6 +46,7 @@ import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.service.SessionType; +import org.eclipse.cdt.utils.CommandLineUtil; import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -299,8 +300,11 @@ public class LaunchUtils { * A timeout is scheduled which will kill the process if it takes too long. */ public static String getGDBVersion(final ILaunchConfiguration configuration) throws CoreException { - String cmd = getGDBPath(configuration).toOSString(); - String[] args = new String[] { cmd, "--version" }; //$NON-NLS-1$ + String cmd = getGDBPath(configuration).toOSString() + " --version"; //$NON-NLS-1$ + + // Parse cmd to properly handle spaces and such things (bug 458499) + String[] args = CommandLineUtil.argumentsToArray(cmd); + Process process = null; Job timeoutJob = null; try { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java index e0bfe4e5b50..f72a792d32b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Wind River Systems, Nokia and others. + * Copyright (c) 2006, 2015 Wind River Systems, Nokia and others. * 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 @@ -47,6 +47,7 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; import org.eclipse.cdt.dsf.service.AbstractDsfService; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.utils.CommandLineUtil; import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.cdt.utils.spawner.Spawner; import org.eclipse.core.resources.IContainer; @@ -203,14 +204,18 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend, IMIBa // The goal here is to keep options to an absolute minimum. // All configuration should be done in the final launch sequence // to allow for more flexibility. - return new String[] { getGDBPath().toOSString(), // This could contain spaces - "--interpreter", //$NON-NLS-1$ - // We currently work with MI version 2. Don't use just 'mi' because it - // points to the latest MI version, while we want mi2 specifically. - "mi2", //$NON-NLS-1$ - // Don't read the gdbinit file here. It is read explicitly in - // the LaunchSequence to make it easier to customize. - "--nx" }; //$NON-NLS-1$ + + String cmd = getGDBPath().toOSString() + + " --interpreter" + //$NON-NLS-1$ + // We currently work with MI version 2. Don't use just 'mi' because it + // points to the latest MI version, while we want mi2 specifically. + " mi2" + //$NON-NLS-1$ + // Don't read the gdbinit file here. It is read explicitly in + // the LaunchSequence to make it easier to customize. + " --nx"; //$NON-NLS-1$ + + // Parse to properly handle spaces and such things (bug 458499) + return CommandLineUtil.argumentsToArray(cmd); } @Override