author | dadubrow |
Thu, 20 May 2010 13:54:19 -0500 | |
changeset 1378 | 9a387b0094c7 |
parent 94 | d74b720418db |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
package com.nokia.cdt.internal.debug.launch; |
|
18 |
||
19 |
import java.io.File; |
|
20 |
||
21 |
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; |
|
22 |
import org.eclipse.cdt.core.model.ICProject; |
|
23 |
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; |
|
24 |
import org.eclipse.cdt.debug.core.ICDebugConfiguration; |
|
25 |
import org.eclipse.cdt.debug.core.cdi.ICDISession; |
|
26 |
import org.eclipse.cdt.launch.internal.ui.LaunchMessages; |
|
27 |
import org.eclipse.cdt.ui.CUIPlugin; |
|
28 |
import org.eclipse.core.runtime.CoreException; |
|
29 |
import org.eclipse.core.runtime.IPath; |
|
30 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
31 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
32 |
import org.eclipse.core.runtime.SubProgressMonitor; |
|
33 |
import org.eclipse.debug.core.ILaunch; |
|
34 |
import org.eclipse.debug.core.ILaunchConfiguration; |
|
35 |
import org.eclipse.debug.core.ILaunchManager; |
|
36 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
37 |
import org.eclipse.swt.widgets.Display; |
|
38 |
||
39 |
import com.freescale.cdt.debug.cw.CWException; |
|
40 |
import com.freescale.cdt.debug.cw.core.cdi.Session; |
|
94
d74b720418db
Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
tzelaw
parents:
2
diff
changeset
|
41 |
import com.freescale.cdt.debug.cw.core.cdi.model.Target; |
2 | 42 |
import com.nokia.cdt.debug.cw.symbian.SettingsData; |
43 |
import com.nokia.cdt.debug.cw.symbian.SymbianPlugin; |
|
44 |
||
45 |
import cwdbg.PreferenceConstants; |
|
46 |
||
47 |
public class Trace32LaunchDelegate extends NokiaAbstractLaunchDelegate { |
|
48 |
||
49 |
public void launch(ILaunchConfiguration config, |
|
50 |
String mode, |
|
51 |
ILaunch launch, |
|
52 |
IProgressMonitor monitor) throws CoreException { |
|
53 |
||
54 |
||
55 |
// See comment at definition of the "mutex" for why this "synchronized". |
|
56 |
synchronized(Session.sessionStartStopMutex()) { |
|
57 |
||
58 |
if (monitor == null) { |
|
59 |
monitor = new NullProgressMonitor(); |
|
60 |
} |
|
61 |
||
62 |
monitor.beginTask(LaunchMessages.getString("LocalRunLaunchDelegate.Launching_Local_C_Application"), 10); //$NON-NLS-1$ |
|
63 |
// check for cancellation |
|
64 |
if (monitor.isCanceled()) |
|
65 |
return; |
|
66 |
||
67 |
try { |
|
68 |
addBeingLaunched(config); // indicating the LC is being launched |
|
69 |
||
70 |
monitor.worked(1); |
|
71 |
IPath exePath = verifyProgramPath(config); |
|
72 |
ICProject project = verifyCProject(config); |
|
73 |
IBinaryObject exeFile = verifyBinary(project, exePath); |
|
74 |
String arguments[] = getProgramArgumentsArray(config); |
|
75 |
||
76 |
// See comment for this method for more. |
|
77 |
SettingsData.setInternalPreferences(config, SettingsData.LaunchConfig_Trace32); |
|
78 |
||
79 |
// set the default source locator if required |
|
80 |
setDefaultSourceLocator(launch, config); |
|
81 |
||
82 |
if (mode.equals(ILaunchManager.DEBUG_MODE)) { |
|
83 |
// debug mode |
|
84 |
ICDebugConfiguration debugConfig = getDebugConfig(config); |
|
85 |
ICDISession dsession = null; |
|
86 |
String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, |
|
87 |
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); |
|
88 |
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) { |
|
89 |
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, |
|
90 |
new SubProgressMonitor(monitor, 8)); |
|
91 |
||
92 |
assert(dsession instanceof Session); |
|
93 |
Session cwDebugSession = (Session)dsession; |
|
94 |
||
95 |
doAdditionalSessionSetup(cwDebugSession); |
|
96 |
||
97 |
IPath[] otherExecutables = getOtherExecutables(project, exePath, config, monitor); |
|
98 |
||
99 |
{ |
|
100 |
try { |
|
101 |
monitor.worked(1); |
|
102 |
||
103 |
// if enabled in the prefs, show the console view(s) |
|
104 |
if (config.getAttribute(SettingsData.spn_Trace32Conn_LogOption, false)) { |
|
105 |
SymbianPlugin.getDefault().openT32CommLogConsole(true); |
|
106 |
} |
|
107 |
if (config.getAttribute(PreferenceConstants.J_PN_LogUnresolved, false)) { |
|
108 |
SymbianPlugin.getDefault().openSymbianRomLogConsole(true); |
|
109 |
} |
|
110 |
||
111 |
config = synchronizeWithProjectAccessPaths(project, config); |
|
112 |
||
113 |
File wd = getWorkingDirectory(config); |
|
94
d74b720418db
Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
tzelaw
parents:
2
diff
changeset
|
114 |
Target target = cwDebugSession.launchExecutable(launch, config, exeFile, otherExecutables, arguments, wd, getEnvironmentAsProperty(config), monitor, project, getTargetLabel(exeFile.getName()), true); |
d74b720418db
Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
tzelaw
parents:
2
diff
changeset
|
115 |
ATFLaunchSupport.saveDebugTargetFromLaunchDelegate(target.getCoreModelTarget()); |
2 | 116 |
|
117 |
} catch (CoreException e) { |
|
118 |
Session session = (Session)dsession; |
|
119 |
session.cleanupAfterLaunchFailure(); |
|
120 |
throw e; |
|
121 |
} catch (Exception e) { |
|
122 |
Session session = (Session)dsession; |
|
123 |
session.debuggingStopped(null); |
|
124 |
String msg = e.getLocalizedMessage(); |
|
125 |
if (msg == null) |
|
126 |
msg = "Trace32 Debug session launch error due to exception."; |
|
127 |
this.abort(msg, null, 0); |
|
128 |
} |
|
129 |
} |
|
130 |
} |
|
131 |
} |
|
132 |
else if (mode.equals(ILaunchManager.RUN_MODE)) { |
|
133 |
// Run the program. |
|
134 |
// Connect to DE, download and launch the program, close debug session. |
|
135 |
ICDebugConfiguration debugConfig = getDebugConfig(config); |
|
136 |
ICDISession dsession = null; |
|
137 |
||
138 |
// Set up communication with DE. |
|
139 |
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, |
|
140 |
new SubProgressMonitor(monitor, 8)); |
|
141 |
||
142 |
// Launch the program through the DE. |
|
143 |
Session cwDebugSession = (Session)dsession; |
|
144 |
cwDebugSession.launchExecutable( |
|
145 |
launch, |
|
146 |
config, |
|
147 |
exeFile, |
|
148 |
new IPath[0], |
|
149 |
arguments, |
|
150 |
null, |
|
151 |
getEnvironmentAsProperty(config), |
|
152 |
monitor, |
|
153 |
project, |
|
154 |
"", //$NON-NLS-1$ |
|
155 |
false /* run instead of debug */); |
|
156 |
||
157 |
// The above call would throw exception on error. So it must have succeeded |
|
158 |
// if control gets here. Show success message in a dialog. |
|
159 |
// |
|
160 |
// get the name of the executable that's launched instead of, say, the DLL name if |
|
161 |
// exeFile is a DLL. |
|
162 |
final String exeLaunched = config.getAttribute(PreferenceConstants.J_PN_RemoteProcessToLaunch, exeFile.toString()); |
|
163 |
Display display = Display.getCurrent(); |
|
164 |
if (display == null) { |
|
165 |
display = Display.getDefault(); |
|
166 |
} |
|
167 |
||
168 |
display.syncExec(new Runnable() { |
|
169 |
public void run() { |
|
170 |
MessageDialog.openInformation( |
|
171 |
CUIPlugin.getActiveWorkbenchShell(), |
|
172 |
LaunchMessages.getString("CarbideCPPLaunchDelegate.DebuggerName"), //$NON-NLS-1$ |
|
173 |
LaunchMessages.getString("TRKLaunchDelegate.runSucceed") + //$NON-NLS-1$ |
|
174 |
"\n\t\"" + exeLaunched + "\""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
175 |
} |
|
176 |
}); |
|
177 |
} |
|
178 |
} catch (CWException e) { |
|
179 |
if (! monitor.isCanceled()) // don't throw on user cancellation |
|
180 |
e.printStackTrace(); |
|
181 |
} catch (CoreException e) { |
|
182 |
if (! monitor.isCanceled()) // don't throw on user cancellation |
|
183 |
throw e; |
|
184 |
} finally { |
|
185 |
monitor.done(); |
|
186 |
removeBeingLaunched(config); |
|
187 |
} |
|
188 |
} // end of synchronized. |
|
189 |
} |
|
190 |
} |