1
/*******************************************************************************
2
* Copyright (c) 2007 - 2010 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.debug.gdbjtag.core;
13
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
14
import org.eclipse.cdt.core.model.ICProject;
15
import org.eclipse.cdt.debug.core.CDIDebugModel;
16
import org.eclipse.cdt.debug.core.CDebugUtils;
17
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
18
import org.eclipse.cdt.debug.core.cdi.CDIException;
19
import org.eclipse.cdt.debug.core.cdi.ICDISession;
20
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
21
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.SubMonitor;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunch;
28
import org.eclipse.debug.core.ILaunchConfiguration;
29
import org.eclipse.debug.core.ILaunchManager;
30
import org.eclipse.debug.core.model.IProcess;
33
* @author Doug Schaefer
36
public class GDBJtagLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
38
protected String getPluginID() {
39
return Activator.PLUGIN_ID;
42
public void launch(ILaunchConfiguration configuration, String mode,
43
ILaunch launch, IProgressMonitor monitor) throws CoreException {
44
SubMonitor submonitor = SubMonitor.convert(monitor, 2);
45
// set the default source locator if required
46
setDefaultSourceLocator(launch, configuration);
48
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
49
GDBJtagDebugger debugger = new GDBJtagDebugger();
50
ICProject project = CDebugUtils.verifyCProject(configuration);
51
IPath exePath = CDebugUtils.verifyProgramPath(configuration);
52
ICDISession session = debugger.createSession(launch, null, submonitor.newChild(1));
53
IBinaryObject exeBinary = null;
54
if ( exePath != null ) {
55
exeBinary = verifyBinary(project, exePath);
59
// create the Launch targets/processes for eclipse.
60
ICDITarget[] targets = session.getTargets();
61
for( int i = 0; i < targets.length; i++ ) {
62
Process process = targets[i].getProcess();
63
IProcess iprocess = null;
64
if ( process != null ) {
65
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath != null ? exePath.toOSString() : "???"),
66
getDefaultProcessMap() );
68
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
69
renderProcessLabel("GDB Hardware Debugger"), iprocess, exeBinary, true, false, false);
72
debugger.doRunSession(launch, session, submonitor.newChild(1));
73
} catch (CoreException e) {
76
} catch (CDIException e1) {
82
cancel("TargetConfiguration not supported",
83
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);