1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42: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.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.MIException;
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.MIGDBSetNewConsole;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
@ -31,14 +38,12 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
public ICDISession createSession(ILaunch launch, File executable,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
return null;
return super.createSession(launch, executable, monitor);
}
public ICDISession createDebuggerSession(ILaunch launch, IBinaryObject exe,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
return null;
return super.createDebuggerSession(launch, exe, monitor);
}
protected CommandFactory getCommandFactory(ILaunchConfiguration config)
@ -47,4 +52,48 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
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;
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.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.cdi.CDIException;
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.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
/**
* @author Doug Schaefer
@ -37,69 +46,42 @@ public class GDBJtagLaunchConfigurationDelegate extends AbstractCLaunchDelegate
setDefaultSourceLocator(launch, configuration);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
ICDebugConfiguration debugConfig = getDebugConfig(configuration);
ICDISession dsession = null;
String debugMode = configuration
.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
GDBJtagDebugger debugger = new GDBJtagDebugger();
ICProject project = verifyCProject(configuration);
IPath exePath = verifyProgramPath(configuration);
File exeFile = exePath != null ? exePath.toFile() : null;
ICDISession session = debugger.createSession(launch, exeFile, monitor);
IBinaryObject exeBinary = null;
if ( exePath != null ) {
exeBinary = verifyBinary(project, exePath);
}
boolean defaultRun = configuration.getAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, GDBJtagConstants.DEFAULT_USE_DEFAULT_RUN);
try {
monitor.worked(1);
if (debugMode
.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
// dsession = ((EmbeddedGDBCDIDebugger) debugConfig
// .createDebugger()).createDebuggerSession(this,
// launch, exeFileInfo, new SubProgressMonitor(
// monitor, 8));
//
// ICDITarget[] dtargets = dsession.getTargets();
// // setFactory(dtargets);
// try {
//
// monitor.worked(1);
//
// executeGDBScript(
// configuration,
// LaunchConfigurationConstants.ATTR_DEBUGGER_COMMANDS_INIT,
// dtargets);
// monitor.worked(2);
//
// queryTargetState(dtargets);
//
// // create the Launch targets/processes for eclipse.
// for (int i = 0; i < dtargets.length; i++) {
// Target target = (Target) dtargets[i];
// target.setConfiguration(new Configuration(target));
// 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;
// }
// create the Launch targets/processes for eclipse.
ICDITarget[] targets = session.getTargets();
for( int i = 0; i < targets.length; i++ ) {
Process process = targets[i].getProcess();
IProcess iprocess = null;
if ( process != null ) {
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()),
getDefaultProcessMap() );
}
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
renderProcessLabel("GDB Hardware Debugger"), iprocess, exeBinary, true, false, defaultRun);
}
if (!defaultRun)
debugger.doRunSession(launch, session, monitor);
} catch (CoreException e) {
try {
session.terminate();
} catch (CDIException e1) {
// ignore
}
throw e;
}
} else {
cancel("TargetConfiguration not supported",