1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 17:55:39 +02:00

Pass ILaunch instead of ILaunchConfiguration.

Added "getGDBPath" method.
This commit is contained in:
Mikhail Khodjaiants 2006-03-23 21:34:03 +00:00
parent 6f5a1ad81c
commit 7a09933b77
5 changed files with 35 additions and 17 deletions

View file

@ -1,3 +1,11 @@
2006-03-23 Mikhail Khodjaiants
Pass ILaunch instead of ILaunchConfiguration.
Added "getGDBPath" method.
* AbstractGDBCDIDebugger.java
* CygwinGDBCDIDebugger2.java
* GDBCDIDebugger2.java
* GDBServerCDIDebugger2.java
2006-03-23 Mikhail Khodjaiants
Added default attribute value for ATTR_DEBUG_NAME.
* IMILaunchConfigurationConstants.java

View file

@ -24,11 +24,13 @@ import org.eclipse.cdt.debug.mi.core.cdi.Session;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@ -59,14 +61,13 @@ abstract public class AbstractGDBCDIDebugger implements ICDIDebugger2 {
if ( monitor.isCanceled() ) {
throw new OperationCanceledException();
}
ILaunchConfiguration config = launch.getLaunchConfiguration();
Session session = createGDBSession( config, executable, monitor );
Session session = createGDBSession( launch, executable, monitor );
if ( session != null ) {
ICDITarget[] targets = session.getTargets();
for( int i = 0; i < targets.length; i++ ) {
Process debugger = session.getSessionProcess( targets[i] );
if ( debugger != null ) {
IProcess debuggerProcess = DebugPlugin.newProcess( launch, debugger, renderDebuggerProcessLabel( config ) );
IProcess debuggerProcess = DebugPlugin.newProcess( launch, debugger, renderDebuggerProcessLabel( launch ) );
launch.addProcess( debuggerProcess );
}
try {
@ -79,7 +80,7 @@ abstract public class AbstractGDBCDIDebugger implements ICDIDebugger2 {
}
}
try {
doStartSession( launch, config, session, monitor );
doStartSession( launch, session, monitor );
}
catch( CoreException e ) {
failed = true;
@ -96,13 +97,14 @@ abstract public class AbstractGDBCDIDebugger implements ICDIDebugger2 {
return session;
}
protected Session createGDBSession( ILaunchConfiguration config, File executable, IProgressMonitor monitor ) throws CoreException {
String gdb = config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb" ); //$NON-NLS-1$
protected Session createGDBSession( ILaunch launch, File executable, IProgressMonitor monitor ) throws CoreException {
IPath gdbPath = getGDBPath( launch );
ILaunchConfiguration config = launch.getLaunchConfiguration();
CommandFactory factory = getCommandFactory( config );
String[] extraArgs = getExtraArguments( config );
boolean usePty = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, true );
try {
return MIPlugin.getDefault().createSession( getSessionType( config ), gdb, factory, executable, extraArgs, usePty, monitor );
return MIPlugin.getDefault().createSession( getSessionType( config ), gdbPath.toOSString(), factory, executable, extraArgs, usePty, monitor );
}
catch( Exception e ) {
// Catch all wrap them up and rethrow
@ -130,21 +132,26 @@ abstract public class AbstractGDBCDIDebugger implements ICDIDebugger2 {
abstract protected CommandFactory getCommandFactory( ILaunchConfiguration config ) throws CoreException;
protected void doStartSession( ILaunch launch, ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
protected void doStartSession( ILaunch launch, Session session, IProgressMonitor monitor ) throws CoreException {
}
protected String renderDebuggerProcessLabel( ILaunchConfiguration config ) {
protected String renderDebuggerProcessLabel( ILaunch launch ) {
String format = "{0} ({1})"; //$NON-NLS-1$
String timestamp = DateFormat.getInstance().format( new Date( System.currentTimeMillis() ) );
String label = MIPlugin.getResourceString( "src.AbstractGDBCDIDebugger.0" ); //$NON-NLS-1$
try {
label = config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb" ); //$NON-NLS-1$
IPath path = getGDBPath( launch );
label = path.toOSString();
}
catch( CoreException e ) {
}
return MessageFormat.format( format, new String[]{ label, timestamp } );
}
protected IPath getGDBPath( ILaunch launch ) throws CoreException {
ILaunchConfiguration config = launch.getLaunchConfiguration();
return new Path( config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT ) );
}
/**
* Throws a core exception with an error status object built from
* the lower level exception and error code.

View file

@ -33,9 +33,9 @@ public class CygwinGDBCDIDebugger2 extends GDBCDIDebugger2 {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger2#doStartSession(org.eclipse.debug.core.ILaunch, org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
* @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger2#doStartSession(org.eclipse.debug.core.ILaunch, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void doStartSession( ILaunch launch, ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
protected void doStartSession( ILaunch launch, Session session, IProgressMonitor monitor ) throws CoreException {
// For windows we need to start the inferior in a new console window
// to separate the Inferior std{in,out,err} from gdb std{in,out,err}
MISession miSession = getMISession( session );
@ -52,7 +52,7 @@ public class CygwinGDBCDIDebugger2 extends GDBCDIDebugger2 {
// We ignore this exception, for example
// on GNU/Linux the new-console is an error.
}
super.doStartSession( launch, config, session, monitor );
super.doStartSession( launch, session, monitor );
}
/* (non-Javadoc)

View file

@ -97,9 +97,10 @@ public class GDBCDIDebugger2 extends AbstractGDBCDIDebugger {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger#doStartSession(org.eclipse.debug.core.ILaunch, org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
* @see org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger#doStartSession(org.eclipse.debug.core.ILaunch, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void doStartSession( ILaunch launch, ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
protected void doStartSession( ILaunch launch, Session session, IProgressMonitor monitor ) throws CoreException {
ILaunchConfiguration config = launch.getLaunchConfiguration();
initializeLibraries( config, session );
if ( monitor.isCanceled() ) {
throw new OperationCanceledException();

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
/**
@ -29,9 +30,10 @@ import org.eclipse.debug.core.ILaunchConfiguration;
public class GDBServerCDIDebugger2 extends GDBCDIDebugger2 {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger2#doStartSession(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
* @see org.eclipse.cdt.debug.mi.core.GDBCDIDebugger2#doStartSession(org.eclipse.debug.core.ILaunch, org.eclipse.cdt.debug.mi.core.cdi.Session, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void doStartSession( ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
protected void doStartSession( ILaunch launch, Session session, IProgressMonitor monitor ) throws CoreException {
ILaunchConfiguration config = launch.getLaunchConfiguration();
initializeLibraries( config, session );
if ( monitor.isCanceled() ) {
throw new OperationCanceledException();