From 7a09933b77a5f840516cdff52fdba18694a047e0 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Thu, 23 Mar 2006 21:34:03 +0000 Subject: [PATCH] Pass ILaunch instead of ILaunchConfiguration. Added "getGDBPath" method. --- debug/org.eclipse.cdt.debug.mi.core/ChangeLog | 8 ++++++ .../debug/mi/core/AbstractGDBCDIDebugger.java | 27 ++++++++++++------- .../debug/mi/core/CygwinGDBCDIDebugger2.java | 6 ++--- .../cdt/debug/mi/core/GDBCDIDebugger2.java | 5 ++-- .../debug/mi/core/GDBServerCDIDebugger2.java | 6 +++-- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 863863203ce..776fb04e83e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -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 diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java index 871626b3ab9..382b18d9ecd 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/AbstractGDBCDIDebugger.java @@ -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. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBCDIDebugger2.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBCDIDebugger2.java index 3e192109be8..6f12cd377bd 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBCDIDebugger2.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBCDIDebugger2.java @@ -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) diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java index 1eeea2e653f..cb4b7a6c8b9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBCDIDebugger2.java @@ -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(); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java index 53aefbe748f..65f616ce534 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerCDIDebugger2.java @@ -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();