mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Bug 343861: Project should not be required to perform debugging
This commit is contained in:
parent
d5d371784d
commit
4239136a95
6 changed files with 49 additions and 47 deletions
|
@ -48,7 +48,7 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
IPath exePath = CDebugUtils.verifyProgramPath(config);
|
||||
IPath exePath = checkBinaryDetails(config);
|
||||
if (exePath != null) {
|
||||
// 1.Download binary if needed
|
||||
String remoteExePath = config.getAttribute(
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launch.remote.tabs;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.CMainTab;
|
||||
import org.eclipse.cdt.internal.launch.remote.Messages;
|
||||
import org.eclipse.cdt.launch.remote.IRemoteConnectionConfigurationConstants;
|
||||
|
@ -506,9 +507,9 @@ public class RemoteCDSFMainTab extends CMainTab {
|
|||
}
|
||||
|
||||
if (programName.length() != 0 && bUpdateRemote) {
|
||||
IProject project = getCProject().getProject();
|
||||
IPath exePath = new Path(programName);
|
||||
if (!exePath.isAbsolute()) {
|
||||
IProject project = getCProject().getProject();
|
||||
exePath = project.getFile(programName).getLocation();
|
||||
|
||||
IPath wsRoot = project.getWorkspace().getRoot().getLocation();
|
||||
|
|
|
@ -432,39 +432,40 @@ public class CMainTab extends CAbstractMainTab {
|
|||
setMessage(null);
|
||||
|
||||
if (!fDontCheckProgram) {
|
||||
String name = fProjText.getText().trim();
|
||||
if (name.length() == 0) {
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
|
||||
setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
|
||||
if (!project.isOpen()) {
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
|
||||
name = fProgText.getText().trim();
|
||||
if (name.length() == 0) {
|
||||
String programName = fProgText.getText().trim();
|
||||
if (programName.length() == 0) {
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (programName.equals(".") || programName.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
IPath exePath = new Path(name);
|
||||
if (!exePath.isAbsolute()) {
|
||||
if (!project.getFile(name).exists()) {
|
||||
IPath exePath = new Path(programName);
|
||||
if (exePath.isAbsolute()) {
|
||||
// For absolute paths, we don't need a project, we can debug the binary directly
|
||||
// as long as it exists
|
||||
if (!exePath.toFile().exists()) {
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
exePath = project.getFile(name).getLocation();
|
||||
} else {
|
||||
if (!exePath.toFile().exists()) {
|
||||
// For relative paths, we need a proper project
|
||||
String projectName = fProjText.getText().trim();
|
||||
if (projectName.length() == 0) {
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||
if (!project.exists()) {
|
||||
setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
if (!project.isOpen()) {
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
if (!project.getFile(programName).exists()) {
|
||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
@ -64,7 +63,9 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2
|
|||
private boolean fIsPostMortemTracingSession;
|
||||
|
||||
public GdbLaunchDelegate() {
|
||||
super();
|
||||
// We now fully support project-less debugging
|
||||
// See bug 343861
|
||||
this(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +119,6 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2
|
|||
monitor.subTask( LaunchMessages.getString("GdbLaunchDelegate.3") ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
IPath exePath = new Path(""); //$NON-NLS-1$
|
||||
// An attach session does not need to necessarily have an
|
||||
// executable specified. This is because:
|
||||
// - In remote multi-process attach, there will be more than one executable
|
||||
|
@ -127,13 +127,8 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2
|
|||
// the path of any executable we can attach to.
|
||||
// - In local single process, GDB has the ability to find the executable
|
||||
// automatically.
|
||||
//
|
||||
// An attach session also does not need to necessarily have a project
|
||||
// specified. This is because we can perform source lookup towards
|
||||
// code that is outside the workspace.
|
||||
// See bug 244567
|
||||
if (!attach) {
|
||||
exePath = checkBinaryDetails(config);
|
||||
checkBinaryDetails(config);
|
||||
}
|
||||
|
||||
monitor.worked( 1 );
|
||||
|
|
|
@ -138,16 +138,19 @@ public class LaunchUtils {
|
|||
* @return An object representing the binary file.
|
||||
*/
|
||||
public static IBinaryObject verifyBinary(ILaunchConfiguration configuration, IPath exePath) throws CoreException {
|
||||
ICConfigExtensionReference[] parserRefs = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(getCProject(configuration).getProject());
|
||||
for (ICConfigExtensionReference parserRef : parserRefs) {
|
||||
try {
|
||||
IBinaryParser parser = CoreModelUtil.getBinaryParser(parserRef);
|
||||
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||
if (exe != null) {
|
||||
return exe;
|
||||
ICProject cproject = getCProject(configuration);
|
||||
if (cproject != null) {
|
||||
ICConfigExtensionReference[] parserRefs = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(cproject.getProject());
|
||||
for (ICConfigExtensionReference parserRef : parserRefs) {
|
||||
try {
|
||||
IBinaryParser parser = CoreModelUtil.getBinaryParser(parserRef);
|
||||
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||
if (exe != null) {
|
||||
return exe;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
} catch (IOException e) {
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2011 QNX Software Systems 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
|
||||
|
@ -10,14 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.tests.dsf.gdb.launching;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
|
||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
|
||||
/**
|
||||
|
@ -55,7 +53,11 @@ public class TestLaunchDelegate extends GdbLaunchDelegate
|
|||
|
||||
@Override
|
||||
protected IPath checkBinaryDetails(ILaunchConfiguration config) throws CoreException {
|
||||
return new Path(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""));
|
||||
// Now that GdbLaunchDelegate supports project-less debugging, we don't need to
|
||||
// override this method. In fact, we should not override it so that we test
|
||||
// that project-less debugging keeps on working.
|
||||
// See bug 343861
|
||||
return super.checkBinaryDetails(config);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue