~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagLaunchConfigurationDelegate.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 *     QNX Software Systems - Initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.cdt.debug.gdbjtag.core;
 
12
 
 
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;
 
31
 
 
32
/**
 
33
 * @author Doug Schaefer
 
34
 * 
 
35
 */
 
36
public class GDBJtagLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
 
37
 
 
38
        protected String getPluginID() {
 
39
                return Activator.PLUGIN_ID;
 
40
        };
 
41
 
 
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);
 
47
 
 
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);
 
56
                        }
 
57
                        
 
58
                        try {
 
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() );
 
67
                                        }
 
68
                                        CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
 
69
                                                        renderProcessLabel("GDB Hardware Debugger"), iprocess, exeBinary, true, false, false);
 
70
                                }
 
71
                                
 
72
                                debugger.doRunSession(launch, session, submonitor.newChild(1));
 
73
                        } catch (CoreException e) {
 
74
                                try {
 
75
                                        session.terminate();
 
76
                                } catch (CDIException e1) {
 
77
                                        // ignore
 
78
                                }
 
79
                                throw e;
 
80
                        }
 
81
                } else {
 
82
                        cancel("TargetConfiguration not supported",
 
83
                                        ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
 
84
                }
 
85
        }
 
86
 
 
87
}