Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2015-06-22 06:44:40 -0400
committerUwe Stieber2015-06-22 06:44:40 -0400
commit0f36150dc23095a093f606588c8623af60d78749 (patch)
treedbbdd56aa783bcee5b46de9964470a96b0562256 /target_explorer
parent717de89459f8af0475644f21cd6f6799023f5c83 (diff)
downloadorg.eclipse.tcf-0f36150dc23095a093f606588c8623af60d78749.tar.gz
org.eclipse.tcf-0f36150dc23095a093f606588c8623af60d78749.tar.xz
org.eclipse.tcf-0f36150dc23095a093f606588c8623af60d78749.zip
Target Explorer: Improve .gdbinit file handling
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/interfaces/IRemoteTEConfigurationConstants.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/IPreferenceKeys.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/PreferencesInitializer.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEGdbDebuggerPage.java30
5 files changed, 57 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/interfaces/IRemoteTEConfigurationConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/interfaces/IRemoteTEConfigurationConstants.java
index 5bd86df32..458ce9f38 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/interfaces/IRemoteTEConfigurationConstants.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/interfaces/IRemoteTEConfigurationConstants.java
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.launch.cdt.interfaces;
+import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.debug.core.DebugPlugin;
public interface IRemoteTEConfigurationConstants {
@@ -21,6 +22,7 @@ public interface IRemoteTEConfigurationConstants {
public static final String ATTR_GDBSERVER_PORT = DebugPlugin.getUniqueIdentifier() + ".ATTR_GDBSERVER_PORT"; //$NON-NLS-1$
public static final String ATTR_GDBSERVER_PORT_MAPPED_TO = DebugPlugin.getUniqueIdentifier() + ".ATTR_GDBSERVER_PORT_MAPPED_TO"; //$NON-NLS-1$
public static final String ATTR_GDBSERVER_COMMAND = DebugPlugin.getUniqueIdentifier() + ".ATTR_GDBSERVER_COMMAND"; //$NON-NLS-1$
+ public static final String ATTR_GDB_INIT = IGDBLaunchConfigurationConstants.ATTR_GDB_INIT + "_NEW"; //$NON-NLS-1$
public static final String ATTR_GDBSERVER_PORT_ALTERNATIVES = DebugPlugin.getUniqueIdentifier() + ".ATTR_GDBSERVER_PORT_ALTERNATIVES"; //$NON-NLS-1$
public static final String ATTR_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES = DebugPlugin.getUniqueIdentifier() + ".ATTR_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES"; //$NON-NLS-1$
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 ce9bf93b1..74970a337 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
@@ -9,6 +9,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.launch.cdt.launching;
+import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
@@ -19,6 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.debug.internal.core.DebugStringVariableSubstitutor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
@@ -61,6 +63,7 @@ import org.eclipse.tcf.te.tcf.processes.core.launcher.ProcessLauncher;
/**
* Abstract launch delegate implementation handling launching the gdbserver via TCF/TE.
*/
+@SuppressWarnings("restriction")
public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate {
/**
@@ -91,7 +94,7 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
*/
- @Override
+ @Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
// If not of the expected type --> return immediately
if (!(launch instanceof GdbLaunch)) return;
@@ -143,6 +146,7 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate {
final String gdbserverCommand = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_COMMAND, TEHelper.getStringPreferenceValue(isAttachLaunch ? IPreferenceKeys.PREF_GDBSERVER_COMMAND_ATTACH : IPreferenceKeys.PREF_GDBSERVER_COMMAND));
final List<String> gdbserverPortNumberAlternatives = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_ALTERNATIVES, TEHelper.getListPreferenceValue(isAttachLaunch ? IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_ALTERNATIVES : IPreferenceKeys.PREF_GDBSERVER_PORT_ALTERNATIVES));
final List<String> gdbserverPortNumberMappedToAlternatives = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES, TEHelper.getListPreferenceValue(isAttachLaunch ? IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO_ALTERNATIVES : IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES));
+ final String gdbinitFile = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDB_INIT, (String)null);
// Remember the originally configured port number and mapped to port number
final String origGdbserverPortNumber = gdbserverPortNumber.get();
@@ -303,9 +307,19 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate {
if (origGdbserverPortNumberMappedTo != null && !origGdbserverPortNumberMappedTo.equals(gdbserverPortNumberMappedTo.get())) {
wc.setAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO, gdbserverPortNumberMappedTo.get());
}
+
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, true);
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST, TEHelper.getCurrentConnection(config).getPeer().getAttributes().get(IPeer.ATTR_IP_HOST));
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, gdbserverPortNumberMappedTo.get() == null || "".equals(gdbserverPortNumberMappedTo.get()) ? gdbserverPortNumber.get() : gdbserverPortNumberMappedTo.get()); //$NON-NLS-1$
+
+ // Expand GDB initialization file location (if set)
+ if (gdbinitFile != null) {
+ String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
+ String expanded = new DebugStringVariableSubstitutor(projectName).performStringSubstitution(gdbinitFile);
+ File f = new File(expanded);
+ wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, f.canRead() && f.isFile() ? f.getAbsolutePath() : null);
+ }
+
wc.doSave();
try {
super.launch(config, mode, launch, monitor);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/IPreferenceKeys.java
index 67aad7392..3fbc0ad01 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/IPreferenceKeys.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/IPreferenceKeys.java
@@ -27,6 +27,11 @@ public interface IPreferenceKeys {
public static final String PREF_GDBSERVER_COMMAND = PREFIX + ".gdbserver.command"; //$NON-NLS-1$
/**
+ * The default GDB initialization file (String).
+ */
+ public static final String PREF_GDB_INIT = PREFIX + ".gdbserver.init"; //$NON-NLS-1$
+
+ /**
* The default (remote) gdbserver port (String).
*/
public static final String PREF_GDBSERVER_PORT = PREFIX + ".gdbserver.port"; //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/PreferencesInitializer.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/PreferencesInitializer.java
index 190e922a3..093d515ff 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/PreferencesInitializer.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/PreferencesInitializer.java
@@ -32,6 +32,11 @@ public class PreferencesInitializer extends AbstractPreferenceInitializer {
store.putDefaultString(IPreferenceKeys.PREF_GDBSERVER_COMMAND, "gdbserver"); //$NON-NLS-1$
/**
+ * GDB initialization file: ${system_property:user.home}/.gdbinit
+ */
+ store.putDefaultString(IPreferenceKeys.PREF_GDB_INIT, "${system_property:user.home}/.gdbinit"); //$NON-NLS-1$
+
+ /**
* Gdbserver default (remote) port: 2345
*/
store.putDefaultString(IPreferenceKeys.PREF_GDBSERVER_PORT, "2345"); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEGdbDebuggerPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEGdbDebuggerPage.java
index 9c9fdf0a9..0c705c54b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEGdbDebuggerPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEGdbDebuggerPage.java
@@ -15,6 +15,9 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.launch.cdt.tabs;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.GdbDebuggerPage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -64,6 +67,8 @@ public class TEGdbDebuggerPage extends GdbDebuggerPage {
TEHelper.getStringPreferenceValue(IPreferenceKeys.PREF_GDBSERVER_PORT));
configuration.setAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO,
TEHelper.getStringPreferenceValue(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO));
+ configuration.setAttribute(IRemoteTEConfigurationConstants.ATTR_GDB_INIT,
+ TEHelper.getStringPreferenceValue(IPreferenceKeys.PREF_GDB_INIT));
}
@Override
@@ -72,6 +77,7 @@ public class TEGdbDebuggerPage extends GdbDebuggerPage {
super.initializeFrom(configuration);
String gdbserverCommand = null;
+ String gdbinitFile = null;
String gdbserverPortNumber = null;
String portNumberMappedTo = null;
try {
@@ -86,13 +92,21 @@ public class TEGdbDebuggerPage extends GdbDebuggerPage {
portNumberMappedTo = configuration.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO,
TEHelper.getStringPreferenceValue(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO));
} catch (CoreException e) {}
+ try {
+ gdbinitFile = configuration.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDB_INIT,
+ TEHelper.getStringPreferenceValue(IPreferenceKeys.PREF_GDB_INIT));
+ } catch (CoreException e) {}
+
if (fGDBServerCommandText != null) fGDBServerCommandText.setText(gdbserverCommand);
if (fGDBServerPortNumberText != null) fGDBServerPortNumberText.setText(gdbserverPortNumber);
if (fGDBServerPortNumberMappedToText != null) fGDBServerPortNumberMappedToText.setText(portNumberMappedTo != null ? portNumberMappedTo : ""); //$NON-NLS-1$
+ if (fGDBInitText != null && gdbinitFile != null && !"".equals(gdbinitFile)) fGDBInitText.setText(gdbinitFile); //$NON-NLS-1$
setInitializing(false);
}
+ private final static Pattern VARIABLE = Pattern.compile("\\$\\{[^\\}]+\\}"); //$NON-NLS-1$
+
@Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
super.performApply(configuration);
@@ -102,6 +116,22 @@ public class TEGdbDebuggerPage extends GdbDebuggerPage {
configuration.setAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT, str);
str = fGDBServerPortNumberMappedToText != null ? fGDBServerPortNumberMappedToText.getText().trim() : null;
configuration.setAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO, str != null && !"".equals(str) ? str : null); //$NON-NLS-1$
+
+ // Get the content of the GDB initialization file entry field
+ str = fGDBInitText != null ? fGDBInitText.getText().trim() : null;
+ if (str != null) {
+ boolean hasVariables = false;
+ Matcher matcher = VARIABLE.matcher(str);
+ while (matcher.find()) {
+ String var = matcher.group();
+ if (!"".equals(var)) { //$NON-NLS-1$
+ hasVariables = true;
+ break;
+ }
+ }
+ if (!hasVariables) str = null;
+ }
+ configuration.setAttribute(IRemoteTEConfigurationConstants.ATTR_GDB_INIT, str);
}
protected void createGdbserverSettingsTab(TabFolder tabFolder) {

Back to the top