mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
[202354] Support for Environment tab in DSF-GDB local application launch. Also, removal of unused classes.
This commit is contained in:
parent
eddb058986
commit
b9eb1cba13
14 changed files with 262 additions and 127 deletions
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2008, 2009 Ericsson and others.
|
||||
# Copyright (c) 2008, 2010 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
|
||||
|
@ -22,6 +22,7 @@ launchTab.arguments.name=Arguments
|
|||
launchTab.debugger.name=Debugger
|
||||
launchTab.sourceLookup.name=Source
|
||||
launchTab.common.name=Common
|
||||
launchTab.environment.name=Environment
|
||||
|
||||
editorTextHover.label=GDB Debugger
|
||||
editorTextHover.description=Shows formatted value in debugger hover
|
||||
|
|
|
@ -19,13 +19,21 @@
|
|||
<associatedDelegate delegate="org.eclipse.cdt.dsf.gdb.launch.localCLaunch"/>
|
||||
<placement after="org.eclipse.cdt.dsf.gdb.launch.mainTab"/>
|
||||
</tab>
|
||||
<tab
|
||||
id="org.eclipse.cdt.dsf.gdb.launch.localApplicationLaunch.environmentTab"
|
||||
group="org.eclipse.cdt.launch.applicationLaunchTabGroup"
|
||||
name="%launchTab.environment.name"
|
||||
class="org.eclipse.debug.ui.EnvironmentTab">
|
||||
<associatedDelegate delegate="org.eclipse.cdt.dsf.gdb.launch.localCLaunch"/>
|
||||
<placement after="org.eclipse.cdt.dsf.gdb.launch.argumentsTab"/>
|
||||
</tab>
|
||||
<tab
|
||||
id="org.eclipse.cdt.dsf.gdb.launch.localApplicationLaunch.debuggerTab"
|
||||
group="org.eclipse.cdt.launch.applicationLaunchTabGroup"
|
||||
name="%launchTab.debugger.name"
|
||||
class="org.eclipse.cdt.dsf.gdb.internal.ui.launching.LocalApplicationCDebuggerTab">
|
||||
<associatedDelegate delegate="org.eclipse.cdt.dsf.gdb.launch.localCLaunch"/>
|
||||
<placement after="org.eclipse.cdt.dsf.gdb.launch.argumentsTab"/>
|
||||
<placement after="org.eclipse.debug.ui.environmentTab"/>
|
||||
</tab>
|
||||
<tab
|
||||
id="org.eclipse.cdt.dsf.gdb.launch.localApplicationLaunch.sourceLookupTab"
|
||||
|
@ -143,16 +151,6 @@
|
|||
<placement after="org.eclipse.debug.ui.sourceLookupTab"/>
|
||||
</tab>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
||||
<launchConfigurationTabGroup
|
||||
class="org.eclipse.cdt.dsf.gdb.internal.ui.launching.GdbRemoteRunLaunchConfigurationTabGroup"
|
||||
id="org.eclipse.cdt.dsf.gdb.launch.remoteRunLaunchTabGroup"
|
||||
type="org.eclipse.cdt.dsf.gdb.launch.remoteCLaunch">
|
||||
</launchConfigurationTabGroup>
|
||||
</extension>
|
||||
|
||||
<extension point="org.eclipse.core.runtime.adapters">
|
||||
<factory
|
||||
class="org.eclipse.cdt.dsf.gdb.internal.ui.GdbAdapterFactory"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2005, 2010 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
|
||||
|
@ -55,7 +55,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public static final String TAB_ID = "org.eclipse.cdt.dsf.gdb.launch.argumentsTab";
|
||||
public static final String TAB_ID = "org.eclipse.cdt.dsf.gdb.launch.argumentsTab"; //$NON-NLS-1$
|
||||
|
||||
// Program arguments UI widgets
|
||||
protected Label fPrgmArgumentsLabel;
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.internal.ui.launching;
|
||||
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.CommonTab;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
|
||||
|
||||
public class GdbAttachLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
|
||||
*/
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
||||
new CMainTab(2), // In some case, we don't need to specify an executable
|
||||
// We don't know yet if we are going to do a remote or local session
|
||||
new CDebuggerTab(null, true),
|
||||
new SourceLookupTab(),
|
||||
new CommonTab()
|
||||
};
|
||||
setTabs(tabs);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Ericsson - Modified for DSF
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
|
||||
|
||||
import org.eclipse.cdt.dsf.gdb.service.SessionType;
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.CommonTab;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
|
||||
|
||||
public class GdbLocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
|
||||
*/
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
||||
new CMainTab(),
|
||||
new CArgumentsTab(),
|
||||
new CDebuggerTab(SessionType.LOCAL, false),
|
||||
new SourceLookupTab(),
|
||||
// new EnvironmentTab(),
|
||||
new CommonTab()
|
||||
};
|
||||
setTabs(tabs);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.internal.ui.launching;
|
||||
|
||||
import org.eclipse.cdt.dsf.gdb.service.SessionType;
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.CommonTab;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
|
||||
|
||||
public class GdbRemoteRunLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
|
||||
*/
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
||||
new CMainTab(),
|
||||
new CDebuggerTab(SessionType.REMOTE, false),
|
||||
new SourceLookupTab(),
|
||||
new CommonTab()
|
||||
};
|
||||
setTabs(tabs);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Ericsson and others.
|
||||
* Copyright (c) 2008, 2010 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
|
||||
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.cdt.dsf.gdb.launching;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
|
||||
|
@ -205,6 +206,28 @@ public class FinalLaunchSequence extends Sequence {
|
|||
requestMonitor.done();
|
||||
}
|
||||
}},
|
||||
/*
|
||||
* Specify environment variables if needed
|
||||
*/
|
||||
new Step() { @Override
|
||||
public void execute(final RequestMonitor requestMonitor) {
|
||||
boolean clear = false;
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
clear = fGDBBackend.getClearEnvironment();
|
||||
properties = fGDBBackend.getEnvironmentVariables();
|
||||
} catch (CoreException e) {
|
||||
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get environment information", e)); //$NON-NLS-1$
|
||||
requestMonitor.done();
|
||||
return;
|
||||
}
|
||||
|
||||
if (clear == true || properties.size() > 0) {
|
||||
fCommandControl.setEnvironment(properties, clear, requestMonitor);
|
||||
} else {
|
||||
requestMonitor.done();
|
||||
}
|
||||
}},
|
||||
/*
|
||||
* Enable non-stop mode if necessary
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Nokia and others.
|
||||
* Copyright (c) 2006, 2010 Wind River Systems, Nokia 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
|
||||
|
@ -22,6 +22,7 @@ import java.io.Reader;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -52,7 +53,10 @@ import org.eclipse.core.runtime.Status;
|
|||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.variables.VariablesPlugin;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
|
@ -77,6 +81,7 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
|||
private List<String> fSharedLibPaths;
|
||||
private String fProgramArguments;
|
||||
|
||||
private Properties fEnvVariables;
|
||||
private SessionType fSessionType;
|
||||
private Boolean fAttach;
|
||||
|
||||
|
@ -265,6 +270,54 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
|||
return fSharedLibPaths;
|
||||
}
|
||||
|
||||
/** @since 3.0 */
|
||||
public Properties getEnvironmentVariables() throws CoreException {
|
||||
if (fEnvVariables == null) {
|
||||
fEnvVariables = new Properties();
|
||||
|
||||
// if the attribute ATTR_APPEND_ENVIRONMENT_VARIABLES is set,
|
||||
// the LaunchManager will return both the new variables and the existing ones.
|
||||
// That would force us to delete all the variables in GDB, and then re-create then all
|
||||
// that is not very efficient. So, let's fool the LaunchManager into returning just the
|
||||
// list of new variables.
|
||||
|
||||
boolean append = fLaunchConfiguration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
|
||||
|
||||
String[] properties;
|
||||
if (append) {
|
||||
ILaunchConfigurationWorkingCopy wc = fLaunchConfiguration.copy(""); //$NON-NLS-1$
|
||||
// Don't save this change, it is just temporary, and in just a copy of our launchConfig.
|
||||
wc.setAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false);
|
||||
properties = DebugPlugin.getDefault().getLaunchManager().getEnvironment(wc);
|
||||
} else {
|
||||
// We're getting rid of the environment anyway, so this call will only yield the new variables.
|
||||
properties = DebugPlugin.getDefault().getLaunchManager().getEnvironment(fLaunchConfiguration);
|
||||
}
|
||||
|
||||
if (properties == null) {
|
||||
properties = new String[0];
|
||||
}
|
||||
|
||||
for (String property : properties) {
|
||||
int idx = property.indexOf('=');
|
||||
if (idx != -1) {
|
||||
String key = property.substring(0, idx);
|
||||
String value = property.substring(idx + 1);
|
||||
fEnvVariables.setProperty(key, value);
|
||||
} else {
|
||||
fEnvVariables.setProperty(property, ""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fEnvVariables;
|
||||
}
|
||||
|
||||
/** @since 3.0 */
|
||||
public boolean getClearEnvironment() throws CoreException {
|
||||
return !fLaunchConfiguration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Launch GDB process.
|
||||
* Allow subclass to override.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Nokia Corporation.
|
||||
* Copyright (c) 2008, 2010 Nokia Corporation.
|
||||
* 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
|
||||
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.dsf.gdb.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -79,6 +80,21 @@ public interface IGDBBackend extends IMIBackend {
|
|||
*/
|
||||
public List<String> getSharedLibraryPaths() throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns the list of user-specified variables.
|
||||
* If no variables are specified, should return an empty list.
|
||||
* Should not return null.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public Properties getEnvironmentVariables() throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns whether the native environment should be cleared before
|
||||
* setting the user-specified environment variables.
|
||||
*
|
||||
* @since 3.0 */
|
||||
public boolean getClearEnvironment() throws CoreException;
|
||||
|
||||
/**
|
||||
* Sends an interrupt signal to the GDB process.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2006, 2010 Wind River 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
|
||||
|
@ -15,10 +15,13 @@ package org.eclipse.cdt.dsf.gdb.service.command;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||
|
@ -48,11 +51,13 @@ import org.eclipse.cdt.dsf.mi.service.command.MIControlDMContext;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.MIInferiorProcess;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.MIRunControlEventProcessor;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.MIInferiorProcess.State;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakInsert;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecContinue;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecRun;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBExit;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetEnv;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIInferiorTTYSet;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
|
@ -399,6 +404,31 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
setMITracingStream(tracingStream);
|
||||
}
|
||||
|
||||
/** @since 3.0 */
|
||||
public void setEnvironment(Properties props, boolean clear, final RequestMonitor rm) {
|
||||
int count = 0;
|
||||
CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm);
|
||||
|
||||
// First clear the environment if requested.
|
||||
if (clear) {
|
||||
count++;
|
||||
queueCommand(
|
||||
new CLIUnsetEnv(getContext()),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), countingRm));
|
||||
}
|
||||
|
||||
// Now set the new variables
|
||||
for (Entry<Object,Object> property : props.entrySet()) {
|
||||
count++;
|
||||
String name = (String)property.getKey();
|
||||
String value = (String)property.getValue();
|
||||
queueCommand(
|
||||
new MIGDBSetEnv(getContext(), name, value),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), countingRm));
|
||||
}
|
||||
countingRm.setDoneCount(count);
|
||||
}
|
||||
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
||||
// Handle our "GDB Exited" event and stop processing commands.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2006, 2010 Wind River 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
|
||||
|
@ -15,10 +15,13 @@ package org.eclipse.cdt.dsf.gdb.service.command;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||
|
@ -51,11 +54,13 @@ import org.eclipse.cdt.dsf.mi.service.command.MIControlDMContext;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.MIInferiorProcess;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.MIRunControlEventProcessor_7_0;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.MIInferiorProcess.State;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakInsert;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecContinue;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecRun;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBExit;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetEnv;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIInferiorTTYSet;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakpoint;
|
||||
|
@ -533,6 +538,31 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
|||
setMITracingStream(tracingStream);
|
||||
}
|
||||
|
||||
/** @since 3.0 */
|
||||
public void setEnvironment(Properties props, boolean clear, RequestMonitor rm) {
|
||||
int count = 0;
|
||||
CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm);
|
||||
|
||||
// First clear the environment if requested.
|
||||
if (clear) {
|
||||
count++;
|
||||
queueCommand(
|
||||
new CLIUnsetEnv(getContext()),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), countingRm));
|
||||
}
|
||||
|
||||
// Now set the new variables
|
||||
for (Entry<Object,Object> property : props.entrySet()) {
|
||||
count++;
|
||||
String name = (String)property.getKey();
|
||||
String value = (String)property.getValue();
|
||||
queueCommand(
|
||||
new MIGDBSetEnv(getContext(), name, value),
|
||||
new DataRequestMonitor<MIInfo>(getExecutor(), countingRm));
|
||||
}
|
||||
countingRm.setDoneCount(count);
|
||||
}
|
||||
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
||||
// Handle our "GDB Exited" event and stop processing commands.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Ericsson and others.
|
||||
* Copyright (c) 2010 Ericsson and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.dsf.gdb.service.command;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||
|
@ -40,4 +41,16 @@ public interface IGDBControl extends ICommandControlService {
|
|||
* @since 2.0
|
||||
*/
|
||||
void setTracingStream(OutputStream tracingStream);
|
||||
|
||||
/**
|
||||
* Sets any user-defined environment variables for the inferior.
|
||||
*
|
||||
* If the 'clear' flag is true, all existing environment variables
|
||||
* will be removed and replaced with the new specified ones.
|
||||
* If 'clear' is false, the new variables are added to the existing
|
||||
* environment.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
void setEnvironment(Properties props, boolean clear, RequestMonitor requestMonitor);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 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.mi.service.command.commands;
|
||||
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* unset env [VARNAME]
|
||||
*
|
||||
* Deletes the environment variable VARNAME for the inferior, not GDB itself.
|
||||
* If VARNAME is omitted, all environment variables are deleted.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class CLIUnsetEnv extends CLICommand<MIInfo> {
|
||||
|
||||
/**
|
||||
* Delete all existing environment variables
|
||||
*/
|
||||
public CLIUnsetEnv(ICommandControlDMContext ctx) {
|
||||
this(ctx, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the environment variable specified by 'name'
|
||||
* If 'name' is null, all variables will be deleted.
|
||||
*/
|
||||
public CLIUnsetEnv(ICommandControlDMContext ctx, String name) {
|
||||
super(ctx, "unset env " + (name != null ? name : "")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 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.mi.service.command.commands;
|
||||
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* -gdb-set env VARNAME [=VALUE]
|
||||
*
|
||||
* Set environment variable VARNAME to VALUE. The value changes for your program only,
|
||||
* not for gdb itself. VALUE may be any string; the values of environment variables are
|
||||
* just strings, and any interpretation is supplied by your program itself. The VALUE
|
||||
* parameter is optional; if it is omitted, the variable is set to a null value.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
*/
|
||||
public class MIGDBSetEnv extends MIGDBSet
|
||||
{
|
||||
public MIGDBSetEnv(ICommandControlDMContext dmc, String name) {
|
||||
this(dmc, name, null);
|
||||
}
|
||||
|
||||
public MIGDBSetEnv(ICommandControlDMContext dmc, String name, String value) {
|
||||
super(dmc, new String[] { "env", name + (value != null && value.length() > 0 ? "=" + value : "")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue