From 9ebb65f407923afd540c9d1885f678b914da4da0 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 27 Sep 2010 00:45:05 +0000 Subject: [PATCH] Bug 326137: Allow DSF-GDB attach session to work without a project or binary. --- dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml | 2 +- .../launching/GdbAttachLaunchDelegate.java | 23 +++++++++++++++++++ .../dsf/gdb/launching/GdbLaunchDelegate.java | 8 +++++++ .../cdt/dsf/gdb/launching/LaunchUtils.java | 8 +++++-- 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbAttachLaunchDelegate.java diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml index 8147ff08548..c4e5a78d671 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml @@ -27,7 +27,7 @@ id="org.eclipse.cdt.dsf.gdb.launch.attachCLaunch" type="org.eclipse.cdt.launch.attachLaunchType" modes="debug" - delegate="org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate" + delegate="org.eclipse.cdt.dsf.gdb.launching.GdbAttachLaunchDelegate" name="%launchDelegate.attach.name" delegateDescription="%launchDelegate.attach.description" sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator" diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbAttachLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbAttachLaunchDelegate.java new file mode 100644 index 00000000000..d01c7f9e40d --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbAttachLaunchDelegate.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2010 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.launching; + +import org.eclipse.cdt.dsf.concurrent.ThreadSafe; + +@ThreadSafe +public class GdbAttachLaunchDelegate extends GdbLaunchDelegate +{ + public GdbAttachLaunchDelegate() { + // For an attach session, we don't require a project + // to be specified + super(false); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java index b8e2c06cc22..8cb3fd79ca2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java @@ -61,6 +61,14 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 private final static String TRACING_FIRST_VERSION = "7.1.50"; //$NON-NLS-1$ private boolean fIsPostMortemTracingSession; + public GdbLaunchDelegate() { + super(); + } + + public GdbLaunchDelegate(boolean requireCProject) { + super(requireCProject); + } + @Override public void launch( ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor ) throws CoreException { org.eclipse.cdt.launch.LaunchUtils.enableActivity("org.eclipse.cdt.debug.dsfgdbActivity", true); //$NON-NLS-1$ 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 f9e2444a6ef..e977bb175c3 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 @@ -358,9 +358,13 @@ public class LaunchUtils { public static String[] getLaunchEnvironment(ILaunchConfiguration config) throws CoreException { // Get the project String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); - if (projectName == null) + if (projectName == null) { return null; - + } + projectName = projectName.trim(); + if (projectName.length() == 0) { + return null; + } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (project == null || !project.isAccessible()) return null;