From 7856453f3073ab05cd791f75decbe179998964b4 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 19 Jan 2016 20:58:31 -0500 Subject: [PATCH] Bug 488909: Unify services factory classes to extend more easily From org.eclipse.cdt.debug.gdbjtag.core, constructor GdbJtagDebugServicesFactory.GdbJtagDebugServicesFactory(String) has been replaced by GdbJtagDebugServicesFactory.GdbJtagDebugServicesFactory(String, ILaunchConfiguration) From org.eclipse.cdt.dsf.gdb, constructor GdbDebugServicesFactory.GdbDebugServicesFactory(String) has been replaced by GdbDebugServicesFactory.GdbDebugServicesFactory(String, ILaunchConfiguration) From org.eclipse.cdt.dsf.gdb, class GdbDebugServicesFactoryNS has been removed and its logic was merged into class GdbDebugServicesFactory Change-Id: Ifecba752cfc12da62f1447027b11c0bb1f7c0171 --- .../dsf/gdb/launching/GdbLaunchDelegate.java | 9 ++--- .../gdb/service/GdbDebugServicesFactory.java | 23 +++++++++++-- .../service/GdbDebugServicesFactoryNS.java | 34 ------------------- .../gdb/launch/GdbExtendedLaunchDelegate.java | 10 ++---- .../GdbExtendedDebugServicesFactory.java | 6 ++-- .../GdbExtendedDebugServicesFactoryNS.java | 31 ----------------- ...GDBJtagDSFLaunchConfigurationDelegate.java | 4 +-- .../service/GdbJtagDebugServicesFactory.java | 10 +++--- .../QtLocalDebugLaunchConfigDelegate.java | 2 +- 9 files changed, 35 insertions(+), 94 deletions(-) delete mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactoryNS.java delete mode 100644 dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactoryNS.java diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java index cd37ff473f4..7534f18c347 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java @@ -34,7 +34,6 @@ import org.eclipse.cdt.dsf.debug.sourcelookup.DsfSourceLookupDirector; import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; -import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactoryNS; import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; import org.eclipse.cdt.dsf.service.DsfServicesTracker; @@ -465,12 +464,8 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 * A subclass can override this method and provide its own ServiceFactory. * @since 4.1 */ - protected IDsfDebugServicesFactory newServiceFactory(ILaunchConfiguration config, String version) { - if (LaunchUtils.getIsNonStopMode(config) && isNonStopSupportedInGdbVersion(version)) { - return new GdbDebugServicesFactoryNS(version); - } - - return new GdbDebugServicesFactory(version); + protected IDsfDebugServicesFactory newServiceFactory(ILaunchConfiguration config, String version) { + return new GdbDebugServicesFactory(version, config); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java index ae9edbb3bd1..01615253b90 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 Ericsson and others. + * Copyright (c) 2008, 2016 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -90,11 +90,19 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { public static final String GDB_7_10_VERSION = "7.10"; //$NON-NLS-1$ private final String fVersion; - - public GdbDebugServicesFactory(String version) { + private final ILaunchConfiguration fConfiguration; + + /** @since 5.0 */ + public GdbDebugServicesFactory(String version, ILaunchConfiguration config) { fVersion = version; + fConfiguration = config; } + /** @since 5.0 */ + protected ILaunchConfiguration getConfiguration() { + return fConfiguration; + } + public String getVersion() { return fVersion; } @Override @@ -260,6 +268,15 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { @Override protected IRunControl createRunControlService(DsfSession session) { + // First check for the non-stop case + if (LaunchUtils.getIsNonStopMode(getConfiguration())) { + if (compareVersionWith(GDB_7_2_VERSION) >= 0) { + return new GDBRunControl_7_2_NS(session); + } + return new GDBRunControl_7_0_NS(session); + } + + // Else, handle all-stop mode if (compareVersionWith(GDB_7_10_VERSION) >= 0) { return new GDBRunControl_7_10(session); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactoryNS.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactoryNS.java deleted file mode 100644 index 34e432277bb..00000000000 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactoryNS.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Ericsson and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ericsson - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.service; - -import org.eclipse.cdt.dsf.debug.service.IRunControl; -import org.eclipse.cdt.dsf.service.DsfSession; - -/** - * This variant is for non-stop (NS) multi-threaded debugging, a gdb capability - * introduced in version 7.0. We provide a specialized NS implementation of - * the run control service; that's the only specialization. - */ -public class GdbDebugServicesFactoryNS extends GdbDebugServicesFactory { - - public GdbDebugServicesFactoryNS(String version) { - super(version); - } - - @Override - protected IRunControl createRunControlService(DsfSession session) { - if (compareVersionWith(GDB_7_2_VERSION) >= 0) { - return new GDBRunControl_7_2_NS(session); - } - return new GDBRunControl_7_0_NS(session); - } -} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunchDelegate.java index 96011424a13..fdde2dce7c3 100644 --- a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunchDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 Ericsson and others. + * Copyright (c) 2014, 2016 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,11 +14,9 @@ import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate; -import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.examples.dsf.gdb.GDBExamplePlugin; import org.eclipse.cdt.examples.dsf.gdb.service.GdbExtendedDebugServicesFactory; -import org.eclipse.cdt.examples.dsf.gdb.service.GdbExtendedDebugServicesFactoryNS; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.ILaunch; @@ -42,11 +40,7 @@ public class GdbExtendedLaunchDelegate extends GdbLaunchDelegate { @Override protected IDsfDebugServicesFactory newServiceFactory(ILaunchConfiguration config, String version) { - boolean nonStop = LaunchUtils.getIsNonStopMode(config); - if (nonStop && isNonStopSupportedInGdbVersion(version)) { - return new GdbExtendedDebugServicesFactoryNS(version); - } - return new GdbExtendedDebugServicesFactory(version); + return new GdbExtendedDebugServicesFactory(version, config); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactory.java index d92325900b5..cdbb6b2ee3e 100644 --- a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 Ericsson and others. + * Copyright (c) 2014, 2016 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,8 +23,8 @@ import org.eclipse.debug.core.ILaunchConfiguration; public class GdbExtendedDebugServicesFactory extends GdbDebugServicesFactory { - public GdbExtendedDebugServicesFactory(String version) { - super(version); + public GdbExtendedDebugServicesFactory(String version, ILaunchConfiguration config) { + super(version, config); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactoryNS.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactoryNS.java deleted file mode 100644 index a4c12aa3f1a..00000000000 --- a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactoryNS.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2015 Ericsson and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Marc Khouzam (Ericsson) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.gdb.service; - -import org.eclipse.cdt.dsf.debug.service.IRunControl; -import org.eclipse.cdt.dsf.gdb.service.GDBRunControl_7_0_NS; -import org.eclipse.cdt.dsf.gdb.service.GDBRunControl_7_2_NS; -import org.eclipse.cdt.dsf.service.DsfSession; - -public class GdbExtendedDebugServicesFactoryNS extends GdbExtendedDebugServicesFactory { - - public GdbExtendedDebugServicesFactoryNS(String version) { - super(version); - } - - @Override - protected IRunControl createRunControlService(DsfSession session) { - if (compareVersionWith(GDB_7_2_VERSION) >= 0) { - return new GDBRunControl_7_2_NS(session); - } - return new GDBRunControl_7_0_NS(session); - } -} diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java index 2976d8e8c5e..0b4ab20d2c7 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 - 2016 QNX Software Systems and others. + * Copyright (c) 2007, 2016 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,7 +45,7 @@ public class GDBJtagDSFLaunchConfigurationDelegate extends GdbLaunchDelegate { @Override protected IDsfDebugServicesFactory newServiceFactory(ILaunchConfiguration config, String version) { - return new GdbJtagDebugServicesFactory(version); + return new GdbJtagDebugServicesFactory(version, config); } @Override diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java index 208467b8a28..cd638975c02 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011,2015 Ericsson and others. + * Copyright (c) 2011, 2016 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,10 +23,10 @@ import org.eclipse.debug.core.ILaunchConfiguration; */ public class GdbJtagDebugServicesFactory extends GdbDebugServicesFactory { - - public GdbJtagDebugServicesFactory(String version) { - super(version); - } + /** @since 9.0 */ + public GdbJtagDebugServicesFactory(String version, ILaunchConfiguration config) { + super(version, config); + } @Override protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) { diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java index af7ed6fd443..2bf05390d69 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java @@ -69,7 +69,7 @@ public class QtLocalDebugLaunchConfigDelegate extends QtLaunchConfigurationDeleg Path exeFile = qtBuildConfig.getProgramPath(); gdbLaunch.setProgramPath(exeFile.toString()); - gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion)); + gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion, configuration)); Sequence servicesLaunchSequence = new ServicesLaunchSequence(gdbLaunch.getSession(), gdbLaunch, monitor); gdbLaunch.getSession().getExecutor().execute(servicesLaunchSequence);