Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--features/org.eclipse.tm.tcf.site/site.xml2
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc3.i386.rpmbin112084 -> 104504 bytes
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc5.i386.rpmbin135727 -> 126298 bytes
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh4.i386.rpmbin112029 -> 104484 bytes
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh5.i386.rpmbin119111 -> 112151 bytes
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java3
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFTargetTab.java135
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/agent/GNU/Linux/i386/agentbin0 -> 285209 bytes
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/agent/Windows/i386/agent.exebin0 -> 260096 bytes
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java7
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java24
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLocalAgent.java197
12 files changed, 298 insertions, 70 deletions
diff --git a/features/org.eclipse.tm.tcf.site/site.xml b/features/org.eclipse.tm.tcf.site/site.xml
index 399eef241..396df0dfb 100644
--- a/features/org.eclipse.tm.tcf.site/site.xml
+++ b/features/org.eclipse.tm.tcf.site/site.xml
@@ -3,7 +3,7 @@
<description url="http://dev.eclipse.org/svnroot/dsdp/org.eclipse.tm.tcf/releases/0.2.0">
TCF update site
</description>
- <feature url="features/org.eclipse.tm.tcf.feature_0.2.0.200906161402.jar" id="org.eclipse.tm.tcf.feature" version="0.2.0.200906161402">
+ <feature url="features/org.eclipse.tm.tcf.feature_0.2.0.200908261524.jar" id="org.eclipse.tm.tcf.feature" version="0.2.0.200908261524">
<category name="org.eclipse.tm"/>
</feature>
<category-def name="org.eclipse.tm" label="Remote Access and Device Development"/>
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc3.i386.rpm b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc3.i386.rpm
index 8a22e05df..9318a8807 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc3.i386.rpm
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc3.i386.rpm
Binary files differ
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc5.i386.rpm b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc5.i386.rpm
index c930e9e19..bef1e5796 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc5.i386.rpm
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.fc5.i386.rpm
Binary files differ
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh4.i386.rpm b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh4.i386.rpm
index 3fd250871..3864a3465 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh4.i386.rpm
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh4.i386.rpm
Binary files differ
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh5.i386.rpm b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh5.i386.rpm
index ff6ea0102..cfbe721a6 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh5.i386.rpm
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/agent/GNU/Linux/i386/tcf-agent-0.0.1-1.rh5.i386.rpm
Binary files differ
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java
index fb5271a7d..713e23fea 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@@ -207,6 +207,7 @@ public class TCFMainTab extends AbstractLaunchConfigurationTab {
});
}
+ @Override
protected void updateLaunchConfigurationDialog() {
super.updateLaunchConfigurationDialog();
working_dir_text.setEnabled(!default_dir_button.getSelection());
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFTargetTab.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFTargetTab.java
index ad9705595..1ba03ebf0 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFTargetTab.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFTargetTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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,6 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TreeEvent;
@@ -50,6 +48,7 @@ import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.tm.internal.tcf.debug.launch.TCFLaunchDelegate;
+import org.eclipse.tm.internal.tcf.debug.launch.TCFLocalAgent;
import org.eclipse.tm.internal.tcf.debug.launch.TCFUserDefPeer;
import org.eclipse.tm.internal.tcf.debug.tests.TCFTestSuite;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
@@ -67,6 +66,8 @@ import org.eclipse.tm.tcf.services.ILocator;
*/
public class TCFTargetTab extends AbstractLaunchConfigurationTab {
+ private Button run_local_agent_button;
+ private Button use_local_agent_button;
private Text peer_id_text;
private Tree peer_tree;
private Runnable update_peer_buttons;
@@ -198,10 +199,41 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
GridData gd = new GridData(GridData.FILL_BOTH);
comp.setLayoutData(gd);
setControl(comp);
-
+ createVerticalSpacer(comp, 1);
+ createLocalAgentButtons(comp);
+ createVerticalSpacer(comp, 1);
createTargetGroup(comp);
}
+ private void createLocalAgentButtons(Composite parent) {
+ Composite local_agent_comp = new Composite(parent, SWT.NONE);
+ GridLayout local_agent_layout = new GridLayout();
+ local_agent_layout.numColumns = 1;
+ local_agent_layout.marginHeight = 0;
+ local_agent_layout.marginWidth = 0;
+ local_agent_comp.setLayout(local_agent_layout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ local_agent_comp.setLayoutData(gd);
+
+ run_local_agent_button = createCheckButton(local_agent_comp, "Run instance of TCF agent on the local host");
+ run_local_agent_button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ run_local_agent_button.setEnabled(true);
+
+ use_local_agent_button = createCheckButton(local_agent_comp, "Use local host as a target");
+ use_local_agent_button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ use_local_agent_button.setEnabled(true);
+ }
+
private void createTargetGroup(Composite parent) {
Font font = parent.getFont();
@@ -225,11 +257,6 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
peer_id_text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
peer_id_text.setFont(font);
peer_id_text.setEditable(false);
- peer_id_text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateLaunchConfigurationDialog();
- }
- });
createVerticalSpacer(group, top_layout.numColumns);
@@ -314,10 +341,7 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
peer_tree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
- TreeItem[] selections = peer_tree.getSelection();
- if (selections.length == 0) return;
- assert selections.length == 1;
- final PeerInfo info = findPeerInfo(selections[0]);
+ final PeerInfo info = findPeerInfo(peer_id_text.getText());
if (info == null) return;
new PeerPropsDialog(getShell(), getImage(), info.attrs,
info.peer instanceof TCFUserDefPeer).open();
@@ -331,13 +355,7 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
}
@Override
public void widgetSelected(SelectionEvent e) {
- update_peer_buttons.run();
- TreeItem[] selections = peer_tree.getSelection();
- if (selections.length > 0) {
- assert selections.length == 1;
- PeerInfo info = findPeerInfo(selections[0]);
- if (info != null) peer_id_text.setText(getPath(info));
- }
+ updateLaunchConfigurationDialog();
}
});
peer_tree.addTreeListener(new TreeListener() {
@@ -408,9 +426,7 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
button_edit.addSelectionListener(sel_adapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- TreeItem[] selection = peer_tree.getSelection();
- if (selection.length == 0) return;
- final PeerInfo info = findPeerInfo(selection[0]);
+ final PeerInfo info = findPeerInfo(peer_id_text.getText());
if (info == null) return;
if (new PeerPropsDialog(getShell(), getImage(), info.attrs,
info.peer instanceof TCFUserDefPeer).open() != Window.OK) return;
@@ -433,9 +449,7 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
button_remove.addSelectionListener(sel_adapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- TreeItem[] selection = peer_tree.getSelection();
- if (selection.length == 0) return;
- final PeerInfo info = findPeerInfo(selection[0]);
+ final PeerInfo info = findPeerInfo(peer_id_text.getText());
if (info == null) return;
if (!(info.peer instanceof TCFUserDefPeer)) return;
Protocol.invokeLater(new Runnable() {
@@ -459,11 +473,7 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
button_test.addSelectionListener(sel_adapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- TreeItem[] selection = peer_tree.getSelection();
- if (selection.length > 0) {
- assert selection.length == 1;
- runDiagnostics(selection[0], false);
- }
+ runDiagnostics(peer_id_text.getText(), false);
}
});
final MenuItem item_test = new MenuItem(menu, SWT.PUSH);
@@ -476,11 +486,7 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
button_loop.addSelectionListener(sel_adapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- TreeItem[] selection = peer_tree.getSelection();
- if (selection.length > 0) {
- assert selection.length == 1;
- runDiagnostics(selection[0], true);
- }
+ runDiagnostics(peer_id_text.getText(), true);
}
});
final MenuItem item_loop = new MenuItem(menu, SWT.PUSH);
@@ -492,9 +498,7 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
update_peer_buttons = new Runnable() {
public void run() {
- PeerInfo info = null;
- TreeItem[] selection = peer_tree.getSelection();
- if (selection.length > 0) info = findPeerInfo(selection[0]);
+ PeerInfo info = findPeerInfo(peer_id_text.getText());
button_edit.setEnabled(info != null);
button_remove.setEnabled(info != null && info.peer instanceof TCFUserDefPeer);
button_test.setEnabled(info != null);
@@ -509,6 +513,26 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
}
@Override
+ protected void updateLaunchConfigurationDialog() {
+ super.updateLaunchConfigurationDialog();
+ if (use_local_agent_button.getSelection()) {
+ peer_tree.setEnabled(false);
+ String id = TCFLocalAgent.getLocalAgentID();
+ if (id != null) peer_id_text.setText(id);
+ }
+ else {
+ peer_tree.setEnabled(true);
+ TreeItem[] selections = peer_tree.getSelection();
+ if (selections.length > 0) {
+ assert selections.length == 1;
+ PeerInfo info = findPeerInfo(selections[0]);
+ if (info != null) peer_id_text.setText(getPath(info));
+ }
+ }
+ update_peer_buttons.run();
+ }
+
+ @Override
public void dispose() {
Protocol.invokeAndWait(new Runnable() {
public void run() {
@@ -530,40 +554,27 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
public void initializeFrom(ILaunchConfiguration configuration) {
try {
- String id = configuration.getAttribute(
- TCFLaunchDelegate.ATTR_PEER_ID, (String)null);
- if (id != null) {
- peer_id_text.setText(id);
- TreeItem item = findItem(findPeerInfo(id));
- if (item != null) {
- peer_tree.setSelection(item);
- update_peer_buttons.run();
- }
- }
+ String id = configuration.getAttribute(TCFLaunchDelegate.ATTR_PEER_ID, (String)null);
+ TreeItem item = findItem(findPeerInfo(id));
+ if (item != null) peer_tree.setSelection(item);
+ run_local_agent_button.setSelection(configuration.getAttribute(TCFLaunchDelegate.ATTR_RUN_LOCAL_AGENT, true));
+ use_local_agent_button.setSelection(configuration.getAttribute(TCFLaunchDelegate.ATTR_USE_LOCAL_AGENT, true));
}
catch (CoreException e) {
setErrorMessage(e.getMessage());
}
- }
-
- public boolean isValid(ILaunchConfiguration launchConfig) {
- String id = peer_id_text.getText().trim();
- if (id.length() == 0) {
- setErrorMessage("Specify a target ID");
- return false;
- }
- setErrorMessage(null);
- return super.isValid(launchConfig);
+ updateLaunchConfigurationDialog();
}
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
String id = peer_id_text.getText().trim();
if (id.length() == 0) id = null;
configuration.setAttribute(TCFLaunchDelegate.ATTR_PEER_ID, id);
+ configuration.setAttribute(TCFLaunchDelegate.ATTR_RUN_LOCAL_AGENT, run_local_agent_button.getSelection());
+ configuration.setAttribute(TCFLaunchDelegate.ATTR_USE_LOCAL_AGENT, use_local_agent_button.getSelection());
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(TCFLaunchDelegate.ATTR_PEER_ID, "TCFLocal");
}
private void disconnectPeer(final PeerInfo info) {
@@ -800,8 +811,8 @@ public class TCFTargetTab extends AbstractLaunchConfigurationTab {
return i.getItem(info.index);
}
- private void runDiagnostics(TreeItem item, boolean loop) {
- PeerInfo info = findPeerInfo(item);
+ private void runDiagnostics(String path, boolean loop) {
+ PeerInfo info = findPeerInfo(path);
if (info == null) return;
final Shell shell = new Shell(getShell(), SWT.TITLE | SWT.PRIMARY_MODAL);
GridLayout layout = new GridLayout();
diff --git a/plugins/org.eclipse.tm.tcf.debug/agent/GNU/Linux/i386/agent b/plugins/org.eclipse.tm.tcf.debug/agent/GNU/Linux/i386/agent
new file mode 100644
index 000000000..bb81e0280
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug/agent/GNU/Linux/i386/agent
Binary files differ
diff --git a/plugins/org.eclipse.tm.tcf.debug/agent/Windows/i386/agent.exe b/plugins/org.eclipse.tm.tcf.debug/agent/Windows/i386/agent.exe
new file mode 100644
index 000000000..614206f72
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug/agent/Windows/i386/agent.exe
Binary files differ
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java
index 80a7ef4b2..b90c6b989 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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.tm.internal.tcf.debug;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.tm.internal.tcf.debug.launch.TCFLocalAgent;
import org.eclipse.tm.internal.tcf.debug.launch.TCFUserDefPeer;
import org.eclipse.tm.internal.tcf.debug.model.TCFBreakpointsModel;
import org.eclipse.tm.tcf.protocol.Protocol;
@@ -51,6 +52,7 @@ public class Activator extends Plugin {
public void stop(BundleContext context) throws Exception {
bp_model.dispose();
bp_model = null;
+ TCFLocalAgent.destroy();
plugin = null;
super.stop(context);
}
@@ -75,7 +77,8 @@ public class Activator extends Plugin {
*/
public static void log(String msg, Throwable err) {
if (plugin == null || plugin.getLog() == null) {
- err.printStackTrace();
+ System.err.println(msg);
+ if (err != null) err.printStackTrace();
}
else {
plugin.getLog().log(new Status(IStatus.ERROR,
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java
index 14a52e379..dfd78ecc3 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
@@ -31,7 +31,9 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
ATTR_COPY_TO_REMOTE_FILE = ITCFConstants.ID_TCF_DEBUG_MODEL + ".CopyToRemote",
ATTR_PROGRAM_ARGUMENTS = ITCFConstants.ID_TCF_DEBUG_MODEL + ".ProgramArguments",
ATTR_WORKING_DIRECTORY = ITCFConstants.ID_TCF_DEBUG_MODEL + ".WorkingDirectory",
- ATTR_USE_TERMINAL = ITCFConstants.ID_TCF_DEBUG_MODEL + ".UseTerminal";
+ ATTR_USE_TERMINAL = ITCFConstants.ID_TCF_DEBUG_MODEL + ".UseTerminal",
+ ATTR_RUN_LOCAL_AGENT = ITCFConstants.ID_TCF_DEBUG_MODEL + ".RunLocalAgent",
+ ATTR_USE_LOCAL_AGENT = ITCFConstants.ID_TCF_DEBUG_MODEL + ".UseLocalAgent";
public ILaunch getLaunch(final ILaunchConfiguration configuration, final String mode) throws CoreException {
return new TCFTask<ILaunch>() {
@@ -48,8 +50,22 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
public void launch(final ILaunchConfiguration configuration, final String mode,
final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
- if (monitor != null) monitor.beginTask("Launching TCF debugger session", 1); //$NON-NLS-1$
- final String id = configuration.getAttribute(ATTR_PEER_ID, "");
+ String local_id = null;
+ int task_cnt = 1;
+ if (configuration.getAttribute(TCFLaunchDelegate.ATTR_RUN_LOCAL_AGENT, true)) {
+ task_cnt++;
+ if (monitor != null) monitor.beginTask("Starting TCF Agent", task_cnt); //$NON-NLS-1$
+ local_id = TCFLocalAgent.runLocalAgent();
+ }
+ else if (configuration.getAttribute(TCFLaunchDelegate.ATTR_USE_LOCAL_AGENT, true)) {
+ task_cnt++;
+ if (monitor != null) monitor.beginTask("Searching TCF Agent", task_cnt); //$NON-NLS-1$
+ local_id = TCFLocalAgent.getLocalAgentID();
+ }
+ if (monitor != null) monitor.beginTask("Launching TCF debugger session", task_cnt); //$NON-NLS-1$
+ final String id =
+ configuration.getAttribute(TCFLaunchDelegate.ATTR_USE_LOCAL_AGENT, true) ?
+ local_id : configuration.getAttribute(ATTR_PEER_ID, "");
Protocol.invokeLater(new Runnable() {
public void run() {
((TCFLaunch)launch).launchTCF(mode, id);
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLocalAgent.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLocalAgent.java
new file mode 100644
index 000000000..0f13f44dd
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLocalAgent.java
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.internal.tcf.debug.launch;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tm.internal.tcf.debug.Activator;
+import org.eclipse.tm.tcf.protocol.IPeer;
+import org.eclipse.tm.tcf.protocol.Protocol;
+import org.eclipse.tm.tcf.services.ILocator;
+import org.eclipse.tm.tcf.util.TCFTask;
+import org.osgi.framework.Bundle;
+
+/**
+ * This class checks that TCF Agent is running on the local host,
+ * and starts a new instance of the agent if it cannot be located.
+ */
+public class TCFLocalAgent {
+
+ private static final String
+ AGENT_HOST = "127.0.0.1",
+ AGENT_PORT = "1534";
+
+ private static Process agent;
+ private static boolean destroed;
+
+ private static String getAgentFileName() {
+ String os = System.getProperty("os.name");
+ String arch = System.getProperty("os.arch");
+ String fnm = "agent";
+ if (arch.equals("x86")) arch = "i386";
+ if (arch.equals("i686")) arch = "i386";
+ if (os.startsWith("Windows")) {
+ os = "Windows";
+ fnm = "agent.exe";
+ }
+ if (os.equals("Linux")) os = "GNU/Linux";
+ return "agent/" + os + "/" + arch + "/" + fnm;
+ }
+
+ static synchronized String runLocalAgent() throws CoreException {
+ if (destroed) return null;
+ String id = getLocalAgentID();
+ if (id != null) return id;
+ if (agent != null) {
+ agent.destroy();
+ agent = null;
+ }
+ Path fnm = new Path(getAgentFileName());
+ try {
+ Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
+ URL url = FileLocator.find(bundle, fnm, null);
+ if (url != null) {
+ URLConnection ucn = url.openConnection();
+ ucn.setRequestProperty("Method", "HEAD");
+ ucn.connect();
+ long mtime = ucn.getLastModified();
+ File f = Activator.getDefault().getStateLocation().append(fnm).toFile();
+ if (!f.exists() || mtime != f.lastModified()) {
+ f.getParentFile().mkdirs();
+ InputStream inp = url.openStream();
+ OutputStream out = new FileOutputStream(f);
+ byte[] buf = new byte[0x1000];
+ for (;;) {
+ int len = inp.read(buf);
+ if (len < 0) break;
+ out.write(buf, 0, len);
+ }
+ out.close();
+ inp.close();
+ f.setLastModified(mtime);
+ }
+ String[] cmd = {
+ f.getAbsolutePath(),
+ "-s",
+ "TCP:" + AGENT_HOST + ":" + AGENT_PORT
+ };
+ final Process prs = Runtime.getRuntime().exec(cmd);
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ int n = prs.waitFor();
+ synchronized (TCFLocalAgent.class) {
+ if (n != 0 && !destroed) {
+ Activator.log("TCF Agent exited with code " + n, null);
+ }
+ if (agent == prs) agent = null;
+ }
+ }
+ catch (InterruptedException x) {
+ Activator.log("TCF Agent Monitor interrupted", x);
+ }
+ }
+ };
+ t.setDaemon(true);
+ t.setName("TCF Agent Monitor");
+ t.start();
+ agent = prs;
+ return waitAgentReady();
+ }
+ }
+ catch (Throwable x) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, 0,
+ "Cannot start local agent: unhandled exception",
+ x));
+ }
+ throw new CoreException(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, 0,
+ "Cannot start local agent: file not available: " + fnm,
+ null));
+ }
+
+ private static boolean isLocalAgent(IPeer p) {
+ String host = p.getAttributes().get(IPeer.ATTR_IP_HOST);
+ String port = p.getAttributes().get(IPeer.ATTR_IP_PORT);
+ return AGENT_HOST.equals(host) && AGENT_PORT.equals(port);
+ }
+
+ public static synchronized String getLocalAgentID() {
+ return new TCFTask<String>() {
+ public void run() {
+ final ILocator locator = Protocol.getLocator();
+ for (IPeer p : locator.getPeers().values()) {
+ if (isLocalAgent(p)) {
+ done(p.getID());
+ return;
+ }
+ }
+ done(null);
+ }
+ }.getE();
+ }
+
+ private static String waitAgentReady() {
+ return new TCFTask<String>() {
+ public void run() {
+ final ILocator locator = Protocol.getLocator();
+ for (IPeer p : locator.getPeers().values()) {
+ if (isLocalAgent(p)) {
+ done(p.getID());
+ return;
+ }
+ }
+ final ILocator.LocatorListener listener = new ILocator.LocatorListener() {
+ public void peerAdded(IPeer p) {
+ if (!isDone() && isLocalAgent(p)) {
+ done(p.getID());
+ locator.removeListener(this);
+ }
+ }
+ public void peerChanged(IPeer peer) {
+ }
+ public void peerHeartBeat(String id) {
+ }
+ public void peerRemoved(String id) {
+ }
+ };
+ locator.addListener(listener);
+ Protocol.invokeLater(30000, new Runnable() {
+ public void run() {
+ if (!isDone()) {
+ error(new Exception("Timeout waiting for TCF Agent to start"));
+ locator.removeListener(listener);
+ }
+ }
+ });
+ }
+ }.getE();
+ }
+
+ public static synchronized void destroy() {
+ if (agent != null) {
+ destroed = true;
+ agent.destroy();
+ }
+ }
+}

Back to the top