Lines 21-26
Link Here
|
21 |
import java.util.MissingResourceException; |
21 |
import java.util.MissingResourceException; |
22 |
import java.util.ResourceBundle; |
22 |
import java.util.ResourceBundle; |
23 |
|
23 |
|
|
|
24 |
import org.eclipse.cdt.core.CCorePlugin; |
25 |
import org.eclipse.cdt.core.IAddressFactory; |
26 |
import org.eclipse.cdt.core.model.IBinary; |
27 |
import org.eclipse.cdt.core.model.ICElement; |
24 |
import org.eclipse.cdt.debug.core.cdi.ICDISession; |
28 |
import org.eclipse.cdt.debug.core.cdi.ICDISession; |
25 |
import org.eclipse.cdt.debug.mi.core.cdi.Session; |
29 |
import org.eclipse.cdt.debug.mi.core.cdi.Session; |
26 |
import org.eclipse.cdt.debug.mi.core.command.CLICommand; |
30 |
import org.eclipse.cdt.debug.mi.core.command.CLICommand; |
Lines 30-35
Link Here
|
30 |
import org.eclipse.cdt.debug.mi.core.output.MIInfo; |
34 |
import org.eclipse.cdt.debug.mi.core.output.MIInfo; |
31 |
import org.eclipse.cdt.utils.pty.PTY; |
35 |
import org.eclipse.cdt.utils.pty.PTY; |
32 |
import org.eclipse.cdt.utils.spawner.ProcessFactory; |
36 |
import org.eclipse.cdt.utils.spawner.ProcessFactory; |
|
|
37 |
import org.eclipse.core.resources.IFile; |
38 |
import org.eclipse.core.runtime.IPluginDescriptor; |
33 |
import org.eclipse.core.runtime.Plugin; |
39 |
import org.eclipse.core.runtime.Plugin; |
34 |
import org.eclipse.core.runtime.Preferences; |
40 |
import org.eclipse.core.runtime.Preferences; |
35 |
import org.osgi.framework.BundleContext; |
41 |
import org.osgi.framework.BundleContext; |
Lines 113-119
Link Here
|
113 |
* @return ICDISession |
119 |
* @return ICDISession |
114 |
* @throws MIException |
120 |
* @throws MIException |
115 |
*/ |
121 |
*/ |
116 |
public ICDISession createCSession(String gdb, File program, File cwd, String gdbinit) throws IOException, MIException { |
122 |
public ICDISession createCSession(String gdb, IFile program, File cwd, String gdbinit) throws IOException, MIException { |
117 |
PTY pty = null; |
123 |
PTY pty = null; |
118 |
boolean failed = false; |
124 |
boolean failed = false; |
119 |
|
125 |
|
Lines 156-162
Link Here
|
156 |
* @return ICDISession |
162 |
* @return ICDISession |
157 |
* @throws IOException |
163 |
* @throws IOException |
158 |
*/ |
164 |
*/ |
159 |
public ICDISession createCSession(String gdb, File program, File cwd, String gdbinit, PTY pty) throws IOException, MIException { |
165 |
public ICDISession createCSession(String gdb, IFile program, File cwd, String gdbinit, PTY pty) throws IOException, MIException { |
160 |
if (gdb == null || gdb.length() == 0) { |
166 |
if (gdb == null || gdb.length() == 0) { |
161 |
gdb = GDB; |
167 |
gdb = GDB; |
162 |
} |
168 |
} |
Lines 170-182
Link Here
|
170 |
if (program == null) { |
176 |
if (program == null) { |
171 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
177 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
172 |
} else { |
178 |
} else { |
173 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1", program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
179 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1", program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
174 |
} |
180 |
} |
175 |
} else { |
181 |
} else { |
176 |
if (program == null) { |
182 |
if (program == null) { |
177 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
183 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
178 |
} else { |
184 |
} else { |
179 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1", program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
185 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1", program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
180 |
} |
186 |
} |
181 |
} |
187 |
} |
182 |
|
188 |
|
Lines 206-212
Link Here
|
206 |
// If an exception is thrown that means ok |
212 |
// If an exception is thrown that means ok |
207 |
// we did not attach to any target. |
213 |
// we did not attach to any target. |
208 |
} |
214 |
} |
209 |
return new Session(session, false); |
215 |
return new Session(session, getAddressFactory(program), false); |
210 |
} |
216 |
} |
211 |
|
217 |
|
212 |
/** |
218 |
/** |
Lines 216-222
Link Here
|
216 |
* @return ICDISession |
222 |
* @return ICDISession |
217 |
* @throws IOException |
223 |
* @throws IOException |
218 |
*/ |
224 |
*/ |
219 |
public ICDISession createCSession(String gdb, File program, File core, File cwd, String gdbinit) throws IOException, MIException { |
225 |
public ICDISession createCSession(String gdb, IFile program, File core, File cwd, String gdbinit) throws IOException, MIException { |
220 |
if (gdb == null || gdb.length() == 0) { |
226 |
if (gdb == null || gdb.length() == 0) { |
221 |
gdb = GDB; |
227 |
gdb = GDB; |
222 |
} |
228 |
} |
Lines 229-235
Link Here
|
229 |
if (program == null) { |
235 |
if (program == null) { |
230 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
236 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
231 |
} else { |
237 |
} else { |
232 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath(), program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
238 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath(), program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
233 |
} |
239 |
} |
234 |
Process pgdb = getGDBProcess(args); |
240 |
Process pgdb = getGDBProcess(args); |
235 |
MISession session; |
241 |
MISession session; |
Lines 239-245
Link Here
|
239 |
pgdb.destroy(); |
245 |
pgdb.destroy(); |
240 |
throw e; |
246 |
throw e; |
241 |
} |
247 |
} |
242 |
return new Session(session); |
248 |
return new Session(session, getAddressFactory(program)); |
243 |
} |
249 |
} |
244 |
|
250 |
|
245 |
/** |
251 |
/** |
Lines 249-255
Link Here
|
249 |
* @return ICDISession |
255 |
* @return ICDISession |
250 |
* @throws IOException |
256 |
* @throws IOException |
251 |
*/ |
257 |
*/ |
252 |
public ICDISession createCSession(String gdb, File program, int pid, String[] targetParams, File cwd, String gdbinit) throws IOException, MIException { |
258 |
public ICDISession createCSession(String gdb, IFile program, int pid, String[] targetParams, File cwd, String gdbinit) throws IOException, MIException { |
253 |
if (gdb == null || gdb.length() == 0) { |
259 |
if (gdb == null || gdb.length() == 0) { |
254 |
gdb = GDB; |
260 |
gdb = GDB; |
255 |
} |
261 |
} |
Lines 262-268
Link Here
|
262 |
if (program == null) { |
268 |
if (program == null) { |
263 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
269 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
264 |
} else { |
270 |
} else { |
265 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
271 |
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
266 |
} |
272 |
} |
267 |
Process pgdb = getGDBProcess(args); |
273 |
Process pgdb = getGDBProcess(args); |
268 |
MISession session; |
274 |
MISession session; |
Lines 298-304
Link Here
|
298 |
//@@@ We have to manually set the suspended state when we attach |
304 |
//@@@ We have to manually set the suspended state when we attach |
299 |
session.getMIInferior().setSuspended(); |
305 |
session.getMIInferior().setSuspended(); |
300 |
session.getMIInferior().update(); |
306 |
session.getMIInferior().update(); |
301 |
return new Session(session, true); |
307 |
return new Session(session, getAddressFactory(program), true); |
302 |
} |
308 |
} |
303 |
|
309 |
|
304 |
/** |
310 |
/** |
Lines 423-428
Link Here
|
423 |
getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, IMIConstants.DEF_REQUEST_LAUNCH_TIMEOUT); |
429 |
getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, IMIConstants.DEF_REQUEST_LAUNCH_TIMEOUT); |
424 |
} |
430 |
} |
425 |
|
431 |
|
|
|
432 |
protected IAddressFactory getAddressFactory(IFile exe) |
433 |
{ |
434 |
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( exe ); |
435 |
if ( cFile instanceof IBinary ) |
436 |
{ |
437 |
return ((IBinary)cFile).getAddressFactory(); |
438 |
} |
439 |
return null; |
440 |
} |
441 |
|
426 |
/* (non-Javadoc) |
442 |
/* (non-Javadoc) |
427 |
* @see org.eclipse.core.runtime.Plugin#shutdown() |
443 |
* @see org.eclipse.core.runtime.Plugin#shutdown() |
428 |
*/ |
444 |
*/ |