diff options
author | Doug Schaefer | 2016-11-07 16:28:45 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-11-09 16:40:17 +0000 |
commit | e9beafae109ba3881b74b4e42dde0250508c0140 (patch) | |
tree | 402e1c0faf690a77ccc946a8567084242ea41d70 /dsf-gdb/org.eclipse.cdt.dsf.gdb/src | |
parent | 5cafc1413ab4ef1eb29648d8c2ca993a2c4a2685 (diff) | |
download | org.eclipse.cdt-e9beafae109ba3881b74b4e42dde0250508c0140.tar.gz org.eclipse.cdt-e9beafae109ba3881b74b4e42dde0250508c0140.tar.xz org.eclipse.cdt-e9beafae109ba3881b74b4e42dde0250508c0140.zip |
Add Local Debug for Core Build launches. Qt Path var for Windows.
Adds gdb launching for Core Build launches. A common class is created
for things common to run and debug (and probably others).
At the bin directory containing qmake to the PATH var for builds and
launches since that's where the DLLs are.
Adds method and variable to GDBLaunch to override the default
environment.
Change-Id: I3ab3b48a2f99eaed50cdb4cfdc03959e9700abc5
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb/src')
2 files changed, 143 insertions, 0 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java new file mode 100644 index 00000000000..4ccc09812cf --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java @@ -0,0 +1,130 @@ +/*******************************************************************************
+ * Copyright (c) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.launching;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.debug.core.launch.CoreBuildLocalLaunchConfigDelegate;
+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
+import org.eclipse.cdt.dsf.concurrent.Query;
+import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
+import org.eclipse.cdt.dsf.concurrent.Sequence;
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
+import org.eclipse.cdt.dsf.gdb.launching.GdbSourceLookupDirector;
+import org.eclipse.cdt.dsf.gdb.launching.ServicesLaunchSequence;
+import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory;
+import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
+import org.eclipse.cdt.dsf.service.DsfServicesTracker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
+
+public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLocalLaunchConfigDelegate {
+
+ @Override
+ public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
+ throws CoreException {
+ GdbLaunch launch = new GdbLaunch(configuration, mode, null);
+ launch.setLaunchTarget(target);
+ launch.initialize();
+
+ GdbSourceLookupDirector locator = new GdbSourceLookupDirector(launch.getSession());
+ String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String) null);
+ if (memento == null) {
+ locator.initializeDefaults(configuration);
+ } else {
+ locator.initializeFromMemento(memento, configuration);
+ }
+
+ launch.setSourceLocator(locator);
+ return launch;
+ }
+
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ GdbLaunch gdbLaunch = (GdbLaunch) launch;
+ ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
+ IProject project = getProject(configuration);
+ ICBuildConfiguration buildConfig = getBuildConfiguration(project, mode, target, monitor);
+
+ Map<String, String> buildEnv = new HashMap<>();
+ buildConfig.setBuildEnvironment(buildEnv);
+ Properties envProps = new Properties();
+ envProps.putAll(buildEnv);
+ gdbLaunch.setInitialEnvironment(envProps);
+
+ IToolChain toolChain = buildConfig.getToolChain();
+ gdbLaunch.setGDBPath(toolChain.getCommandPath(Paths.get("gdb")).toString()); //$NON-NLS-1$
+ String gdbVersion = gdbLaunch.getGDBVersion();
+
+ Path exeFile = Paths.get(getBinary(buildConfig).getLocationURI());
+ gdbLaunch.setProgramPath(exeFile.toString());
+
+ gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion, configuration));
+
+ Sequence servicesLaunchSequence = new ServicesLaunchSequence(gdbLaunch.getSession(), gdbLaunch, monitor);
+ gdbLaunch.getSession().getExecutor().execute(servicesLaunchSequence);
+ try {
+ servicesLaunchSequence.get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Failure launching with gdb", e));
+ }
+
+ gdbLaunch.initializeControl();
+
+ gdbLaunch.addCLIProcess(gdbLaunch.getGDBPath().toOSString() + " (" + gdbVersion + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Query<Object> ready = new Query<Object>() {
+ @Override
+ protected void execute(final DataRequestMonitor<Object> rm) {
+ DsfServicesTracker tracker = new DsfServicesTracker(
+ GdbPlugin.getDefault().getBundle().getBundleContext(), gdbLaunch.getSession().getId());
+ IGDBControl control = tracker.getService(IGDBControl.class);
+ tracker.dispose();
+ control.completeInitialization(
+ new RequestMonitorWithProgress(ImmediateExecutor.getInstance(), monitor) {
+ @Override
+ protected void handleCompleted() {
+ if (isCanceled()) {
+ rm.cancel();
+ } else {
+ rm.setStatus(getStatus());
+ }
+ rm.done();
+ }
+ });
+ }
+ };
+
+ // Start it up
+ gdbLaunch.getSession().getExecutor().execute(ready);
+ try {
+ ready.get();
+ } catch (ExecutionException | InterruptedException e) {
+ throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Failure to start debug session", e));
+ }
+ }
+
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java index 48ec7751db1..2bf27f35e82 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java @@ -113,6 +113,7 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr private IMemoryBlockRetrievalManager fMemRetrievalManager; private IDsfDebugServicesFactory fServiceFactory; private ILaunchTarget fLaunchTarget; + private Properties fInitialEnv; private String fGdbVersion; @@ -897,6 +898,9 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr */ public Properties getEnvironmentVariables() throws CoreException { Properties envVariables = new Properties(); + if (fInitialEnv != null) { + envVariables.putAll(fInitialEnv); + } // if the attribute ATTR_APPEND_ENVIRONMENT_VARIABLES is set, // the LaunchManager will return both the new variables and the @@ -984,4 +988,13 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr return fLaunchTarget; } + /** + * Set the initial environment variables. These can then be overriden + * by launch configuration attributes. + * + * @since 5.2 + */ + public void setInitialEnvironment(Properties initialEnv) { + this.fInitialEnv = initialEnv; + } } |