1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Started implementing the guts of the launcher.

This commit is contained in:
Doug Schaefer 2007-04-17 18:11:11 +00:00
parent f3a9d178e5
commit fd0881e3c0
2 changed files with 98 additions and 67 deletions

View file

@ -15,9 +15,16 @@ import java.io.File;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger; import org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MIPlugin; import org.eclipse.cdt.debug.mi.core.MIPlugin;
import org.eclipse.cdt.debug.mi.core.MISession;
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.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetNewConsole;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
@ -31,14 +38,12 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
public ICDISession createSession(ILaunch launch, File executable, public ICDISession createSession(ILaunch launch, File executable,
IProgressMonitor monitor) throws CoreException { IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub return super.createSession(launch, executable, monitor);
return null;
} }
public ICDISession createDebuggerSession(ILaunch launch, IBinaryObject exe, public ICDISession createDebuggerSession(ILaunch launch, IBinaryObject exe,
IProgressMonitor monitor) throws CoreException { IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub return super.createDebuggerSession(launch, exe, monitor);
return null;
} }
protected CommandFactory getCommandFactory(ILaunchConfiguration config) protected CommandFactory getCommandFactory(ILaunchConfiguration config)
@ -47,4 +52,48 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
return new GDBJtagCommandFactory(miVersion); return new GDBJtagCommandFactory(miVersion);
} }
protected void doStartSession(ILaunch launch, Session session, IProgressMonitor monitor) throws CoreException {
ILaunchConfiguration config = launch.getLaunchConfiguration();
ICDITarget[] targets = session.getTargets();
if (targets.length == 0 || !(targets[0] instanceof Target))
return ; // TODO should raise an exception
MISession miSession = ((Target)targets[0]).getMISession();
getMISession( session );
CommandFactory factory = miSession.getCommandFactory();
try {
MIGDBSetNewConsole newConsole = factory.createMIGDBSetNewConsole();
miSession.postCommand( newConsole );
MIInfo info = newConsole.getMIInfo();
if ( info == null ) {
throw new MIException( MIPlugin.getResourceString( "src.common.No_answer" ) ); //$NON-NLS-1$
}
}
catch( MIException e ) {
// We ignore this exception, for example
// on GNU/Linux the new-console is an error.
}
// TODO execute init script
// TODO execute load
}
protected MISession getMISession(Session session) {
ICDITarget[] targets = session.getTargets();
if (targets.length == 0 || !(targets[0] instanceof Target))
return null;
return ((Target)targets[0]).getMISession();
}
public void doRunSession(ILaunch launch, ICDISession session, IProgressMonitor monitor) {
ILaunchConfiguration config = launch.getLaunchConfiguration();
ICDITarget[] targets = session.getTargets();
if ( targets.length == 0 || !(targets[0] instanceof Target) )
return;
MISession miSession = ((Target)targets[0]).getMISession();
CommandFactory factory = miSession.getCommandFactory();
// TODO execute run script
}
} }

View file

@ -10,15 +10,24 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core; package org.eclipse.cdt.debug.gdbjtag.core;
import java.io.File;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
@ -37,69 +46,42 @@ public class GDBJtagLaunchConfigurationDelegate extends AbstractCLaunchDelegate
setDefaultSourceLocator(launch, configuration); setDefaultSourceLocator(launch, configuration);
if (mode.equals(ILaunchManager.DEBUG_MODE)) { if (mode.equals(ILaunchManager.DEBUG_MODE)) {
ICDebugConfiguration debugConfig = getDebugConfig(configuration); GDBJtagDebugger debugger = new GDBJtagDebugger();
ICDISession dsession = null; ICProject project = verifyCProject(configuration);
String debugMode = configuration IPath exePath = verifyProgramPath(configuration);
.getAttribute( File exeFile = exePath != null ? exePath.toFile() : null;
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDISession session = debugger.createSession(launch, exeFile, monitor);
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); IBinaryObject exeBinary = null;
if ( exePath != null ) {
exeBinary = verifyBinary(project, exePath);
}
boolean defaultRun = configuration.getAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, GDBJtagConstants.DEFAULT_USE_DEFAULT_RUN);
if (debugMode try {
.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) { monitor.worked(1);
// dsession = ((EmbeddedGDBCDIDebugger) debugConfig
// .createDebugger()).createDebuggerSession(this, // create the Launch targets/processes for eclipse.
// launch, exeFileInfo, new SubProgressMonitor( ICDITarget[] targets = session.getTargets();
// monitor, 8)); for( int i = 0; i < targets.length; i++ ) {
// Process process = targets[i].getProcess();
// ICDITarget[] dtargets = dsession.getTargets(); IProcess iprocess = null;
// // setFactory(dtargets); if ( process != null ) {
// try { iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()),
// getDefaultProcessMap() );
// monitor.worked(1); }
// CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
// executeGDBScript( renderProcessLabel("GDB Hardware Debugger"), iprocess, exeBinary, true, false, defaultRun);
// configuration, }
// LaunchConfigurationConstants.ATTR_DEBUGGER_COMMANDS_INIT,
// dtargets); if (!defaultRun)
// monitor.worked(2); debugger.doRunSession(launch, session, monitor);
// } catch (CoreException e) {
// queryTargetState(dtargets); try {
// session.terminate();
// // create the Launch targets/processes for eclipse. } catch (CDIException e1) {
// for (int i = 0; i < dtargets.length; i++) { // ignore
// Target target = (Target) dtargets[i]; }
// target.setConfiguration(new Configuration(target)); throw e;
// Process process = target.getProcess();
// IProcess iprocess = null;
// if (process != null) {
// iprocess = DebugPlugin.newProcess(launch,
// process, renderProcessLabel(exePath
// .toOSString()));
// }
// CDIDebugModel.newDebugTarget(launch, projectInfo,
// dtargets[i],
// renderTargetLabel(debugConfig), iprocess,
// exeFileInfo, true, true, false);
// /* FIX!!!! put up a console view for */
// // if (process != null) {
// // iprocess = DebugPlugin.newProcess(launch,
// // process,
// // renderProcessLabel(exePath.toOSString()));
// // }
// }
// executeGDBScript(
// configuration,
// LaunchConfigurationConstants.ATTR_DEBUGGER_COMMANDS_RUN,
// dtargets);
//
// } catch (CoreException e) {
// try {
// dsession.terminate();
// } catch (CDIException e1) {
// // ignore
// }
// throw e;
// }
} }
} else { } else {
cancel("TargetConfiguration not supported", cancel("TargetConfiguration not supported",