mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 18:55:38 +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) {
|
if (exePath != null) {
|
||||||
// 1.Download binary if needed
|
// 1.Download binary if needed
|
||||||
String remoteExePath = config.getAttribute(
|
String remoteExePath = config.getAttribute(
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.remote.tabs;
|
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.dsf.gdb.internal.ui.launching.CMainTab;
|
||||||
import org.eclipse.cdt.internal.launch.remote.Messages;
|
import org.eclipse.cdt.internal.launch.remote.Messages;
|
||||||
import org.eclipse.cdt.launch.remote.IRemoteConnectionConfigurationConstants;
|
import org.eclipse.cdt.launch.remote.IRemoteConnectionConfigurationConstants;
|
||||||
|
@ -506,9 +507,9 @@ public class RemoteCDSFMainTab extends CMainTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (programName.length() != 0 && bUpdateRemote) {
|
if (programName.length() != 0 && bUpdateRemote) {
|
||||||
IProject project = getCProject().getProject();
|
|
||||||
IPath exePath = new Path(programName);
|
IPath exePath = new Path(programName);
|
||||||
if (!exePath.isAbsolute()) {
|
if (!exePath.isAbsolute()) {
|
||||||
|
IProject project = getCProject().getProject();
|
||||||
exePath = project.getFile(programName).getLocation();
|
exePath = project.getFile(programName).getLocation();
|
||||||
|
|
||||||
IPath wsRoot = project.getWorkspace().getRoot().getLocation();
|
IPath wsRoot = project.getWorkspace().getRoot().getLocation();
|
||||||
|
|
|
@ -432,39 +432,40 @@ public class CMainTab extends CAbstractMainTab {
|
||||||
setMessage(null);
|
setMessage(null);
|
||||||
|
|
||||||
if (!fDontCheckProgram) {
|
if (!fDontCheckProgram) {
|
||||||
String name = fProjText.getText().trim();
|
String programName = fProgText.getText().trim();
|
||||||
if (name.length() == 0) {
|
if (programName.length() == 0) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
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(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;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 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$
|
setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
|
if (!project.exists()) {
|
||||||
setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
|
|
||||||
if (!project.isOpen()) {
|
if (!project.isOpen()) {
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!project.getFile(programName).exists()) {
|
||||||
name = fProgText.getText().trim();
|
|
||||||
if (name.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$
|
|
||||||
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()) {
|
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
exePath = project.getFile(name).getLocation();
|
|
||||||
} else {
|
|
||||||
if (!exePath.toFile().exists()) {
|
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
@ -64,7 +63,9 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2
|
||||||
private boolean fIsPostMortemTracingSession;
|
private boolean fIsPostMortemTracingSession;
|
||||||
|
|
||||||
public GdbLaunchDelegate() {
|
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$
|
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
|
// An attach session does not need to necessarily have an
|
||||||
// executable specified. This is because:
|
// executable specified. This is because:
|
||||||
// - In remote multi-process attach, there will be more than one executable
|
// - 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.
|
// the path of any executable we can attach to.
|
||||||
// - In local single process, GDB has the ability to find the executable
|
// - In local single process, GDB has the ability to find the executable
|
||||||
// automatically.
|
// 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) {
|
if (!attach) {
|
||||||
exePath = checkBinaryDetails(config);
|
checkBinaryDetails(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.worked( 1 );
|
monitor.worked( 1 );
|
||||||
|
|
|
@ -138,7 +138,9 @@ public class LaunchUtils {
|
||||||
* @return An object representing the binary file.
|
* @return An object representing the binary file.
|
||||||
*/
|
*/
|
||||||
public static IBinaryObject verifyBinary(ILaunchConfiguration configuration, IPath exePath) throws CoreException {
|
public static IBinaryObject verifyBinary(ILaunchConfiguration configuration, IPath exePath) throws CoreException {
|
||||||
ICConfigExtensionReference[] parserRefs = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(getCProject(configuration).getProject());
|
ICProject cproject = getCProject(configuration);
|
||||||
|
if (cproject != null) {
|
||||||
|
ICConfigExtensionReference[] parserRefs = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(cproject.getProject());
|
||||||
for (ICConfigExtensionReference parserRef : parserRefs) {
|
for (ICConfigExtensionReference parserRef : parserRefs) {
|
||||||
try {
|
try {
|
||||||
IBinaryParser parser = CoreModelUtil.getBinaryParser(parserRef);
|
IBinaryParser parser = CoreModelUtil.getBinaryParser(parserRef);
|
||||||
|
@ -150,6 +152,7 @@ public class LaunchUtils {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IBinaryParser parser = CCorePlugin.getDefault().getDefaultBinaryParser();
|
IBinaryParser parser = CCorePlugin.getDefault().getDefaultBinaryParser();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,14 +10,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.tests.dsf.gdb.launching;
|
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.concurrent.ThreadSafe;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
|
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +53,11 @@ public class TestLaunchDelegate extends GdbLaunchDelegate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IPath checkBinaryDetails(ILaunchConfiguration config) throws CoreException {
|
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