mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Fix for 212632: Failure to debug-attach on Windows using GDB
and 224187: NPE launching debug configuration without app name
This commit is contained in:
parent
402016a6f0
commit
f2bcb6cb77
2 changed files with 46 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 QNX Software Systems and others.
|
* Copyright (c) 2005, 2008 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
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
* Andrew Ferguson (andrew.ferguson@arm.com) - bug 123997
|
* Andrew Ferguson (andrew.ferguson@arm.com) - bug 123997
|
||||||
* Ken Ryall (Nokia) - bug 178731
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
|
* Anton Leherbauer (Wind River Systems) - bug 224187
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch;
|
package org.eclipse.cdt.launch;
|
||||||
|
|
||||||
|
@ -153,9 +154,14 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
* error code
|
* error code
|
||||||
*/
|
*/
|
||||||
protected void abort(String message, Throwable exception, int code) throws CoreException {
|
protected void abort(String message, Throwable exception, int code) throws CoreException {
|
||||||
MultiStatus status = new MultiStatus(getPluginID(), code, message, exception);
|
IStatus status;
|
||||||
status.add(new Status(IStatus.ERROR, getPluginID(), code, exception == null ? "" : exception.getLocalizedMessage(), //$NON-NLS-1$
|
if (exception != null) {
|
||||||
exception));
|
MultiStatus multiStatus = new MultiStatus(getPluginID(), code, message, exception);
|
||||||
|
multiStatus.add(new Status(IStatus.ERROR, getPluginID(), code, exception.getLocalizedMessage(), exception));
|
||||||
|
status= multiStatus;
|
||||||
|
} else {
|
||||||
|
status= new Status(IStatus.ERROR, getPluginID(), code, message, null);
|
||||||
|
}
|
||||||
throw new CoreException(status);
|
throw new CoreException(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +196,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
|
|
||||||
public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException {
|
public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException {
|
||||||
String path = getProgramName(configuration);
|
String path = getProgramName(configuration);
|
||||||
if (path == null) {
|
if (path == null || path.trim().length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Path(path);
|
return new Path(path);
|
||||||
|
@ -364,7 +370,8 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
ICProject cproject = verifyCProject(config);
|
ICProject cproject = verifyCProject(config);
|
||||||
IPath programPath = getProgramPath(config);
|
IPath programPath = getProgramPath(config);
|
||||||
if (programPath == null || programPath.isEmpty()) {
|
if (programPath == null || programPath.isEmpty()) {
|
||||||
return null;
|
abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
|
||||||
}
|
}
|
||||||
if (!programPath.isAbsolute()) {
|
if (!programPath.isAbsolute()) {
|
||||||
IFile wsProgramPath = cproject.getProject().getFile(programPath);
|
IFile wsProgramPath = cproject.getProject().getFile(programPath);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
* Copyright (c) 2004, 2008 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
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems) - bug 205108
|
* Anton Leherbauer (Wind River Systems) - bugs 205108, 212632, 224187
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.internal;
|
package org.eclipse.cdt.launch.internal;
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IProcessInfo;
|
||||||
|
import org.eclipse.cdt.core.IProcessList;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
|
@ -38,6 +41,7 @@ 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.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
@ -196,7 +200,10 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
}
|
}
|
||||||
cancel( "", -1 ); //$NON-NLS-1$
|
cancel( "", -1 ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
IPath exePath = verifyProgramPath( config );
|
IPath exePath = getProgramPath( config );
|
||||||
|
if (exePath == null) {
|
||||||
|
exePath= getProgramPathForPid(pid);
|
||||||
|
}
|
||||||
ICProject project = verifyCProject( config );
|
ICProject project = verifyCProject( config );
|
||||||
IBinaryObject exeFile = null;
|
IBinaryObject exeFile = null;
|
||||||
if ( exePath != null ) {
|
if ( exePath != null ) {
|
||||||
|
@ -232,6 +239,29 @@ public class LocalCDILaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IPath getProgramPathForPid(int pid) {
|
||||||
|
IProcessList processList= null;
|
||||||
|
try {
|
||||||
|
processList= CCorePlugin.getDefault().getProcessList();
|
||||||
|
} catch (CoreException exc) {
|
||||||
|
// ignored on purpose
|
||||||
|
}
|
||||||
|
if (processList != null) {
|
||||||
|
IProcessInfo[] pInfos= processList.getProcessList();
|
||||||
|
for (int i = 0; i < pInfos.length; i++) {
|
||||||
|
IProcessInfo processInfo = pInfos[i];
|
||||||
|
if (processInfo.getPid() == pid) {
|
||||||
|
final String name= processInfo.getName();
|
||||||
|
if (name != null) {
|
||||||
|
return new Path(name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void launchCoreDebugSession( ILaunchConfiguration config, ILaunch launch, IProgressMonitor monitor ) throws CoreException {
|
private void launchCoreDebugSession( ILaunchConfiguration config, ILaunch launch, IProgressMonitor monitor ) throws CoreException {
|
||||||
if ( monitor.isCanceled() ) {
|
if ( monitor.isCanceled() ) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue