From 6eb1e1da299e24a9a699c88fbe735a5db3bd3018 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 13 Mar 2016 19:18:34 +0000 Subject: Bug 489489: Adapt to API that is different in CDT 8 and 9 cleanupLaunch() was replaced by cleanupLaunch(ILaunch) in CDT 9, while TCF wants to support 8 and 9 from single code base the behaviour of cleanupLaunch has been copied to TEGdbAbstractLaunchDelegate. This method is deprecated and intended to be removed once TCF no longer supports CDT < 9. Change-Id: Ia06e9a708d38fa049a7960d34d559210a8d048bd Signed-off-by: Jonah Graham --- .../cdt/launching/TEGdbAbstractLaunchDelegate.java | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'target_explorer/plugins') diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java index 26c3ca162..dc8dcdd3b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java @@ -405,11 +405,43 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { throw new DebugException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), "Cannot attach to process", e)); //$NON-NLS-1$ } finally { if (!ok) { - cleanupLaunch(); + cleanupLaunchLocal(l); } } } + /** + * @deprecated While waiting for TCF to drop support for CDT < 9.0 we need this method copied + * from CDT 9.0. Once support for old CDT is removed this should become simply + * super.cleanupLaunch(ILaunch). + */ + @Deprecated + protected void cleanupLaunchLocal(ILaunch launch) throws DebugException { + if (launch instanceof GdbLaunch) { + final GdbLaunch gdbLaunch = (GdbLaunch)launch; + Query launchShutdownQuery = new Query() { + @Override + protected void execute(DataRequestMonitor rm) { + gdbLaunch.shutdownSession(rm); + } + }; + + gdbLaunch.getSession().getExecutor().execute(launchShutdownQuery); + + // wait for the shutdown to finish. + // The Query.get() method is a synchronous call which blocks until the + // query completes. + try { + launchShutdownQuery.get(); + } catch (InterruptedException e) { + throw new DebugException( new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "InterruptedException while shutting down debugger launch " + launch, e)); //$NON-NLS-1$ + } catch (ExecutionException e) { + throw new DebugException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), DebugException.REQUEST_FAILED, "Error in shutting down debugger launch " + launch, e)); //$NON-NLS-1$ + } + } + + } + /** * On Windows, if gdb was started as part of a batch script, the script does not exit silently * if it has been interrupted before. Therefore we listen for the completion of the -gdb-exit command -- cgit v1.2.3