Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] GDB Server core from Monta Vista

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.117
diff -u -r1.117 ChangeLog
--- ChangeLog	5 Apr 2003 02:37:59 -0000	1.117
+++ ChangeLog	6 Apr 2003 01:06:25 -0000
@@ -1,5 +1,14 @@
 2003-04-04 Alain Magloire
 
+	Code from Monta Vista to add a Session via GDBServer.
+	
+	* src/org/eclipse/cdt/debug/mi/core/MIPlugin.java:
+	* src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java:
+	* src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java:
+	* plugin.xml
+
+2003-04-04 Alain Magloire
+
 	* src/org/eclipse/cdt/debug/mi/core/cdt/VariableManager.java:
 	Check for null in update().
 
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/plugin.properties,v
retrieving revision 1.5
diff -u -r1.5 plugin.properties
--- plugin.properties	27 Nov 2002 16:26:25 -0000	1.5
+++ plugin.properties	6 Apr 2003 01:06:25 -0000
@@ -2,4 +2,5 @@
 providerName=Eclipse.org
 
 GDBDebugger.name=GDB Debugger
-CygwinGDBDebugger.name=Cygwin GDB Debugger
\ No newline at end of file
+CygwinGDBDebugger.name=Cygwin GDB Debugger
+GDBServer.name=GDB Server
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/plugin.xml,v
retrieving revision 1.14
diff -u -r1.14 plugin.xml
--- plugin.xml	16 Dec 2002 20:50:28 -0000	1.14
+++ plugin.xml	6 Apr 2003 01:06:25 -0000
@@ -37,6 +37,14 @@
             class="org.eclipse.cdt.debug.mi.core.CygwinGDBDebugger"
             id="org.eclipse.cdt.debug.mi.core.CygwinCDebugger">
       </debugger>
+      <debugger
+            platform="native"
+            name="%GDBServer.name"
+            modes="run"
+            cpu="native"
+            class="org.eclipse.cdt.debug.mi.core.GDBServerDebugger"
+            id="org.eclipse.cdt.debug.mi.core.GDBServerCDebugger">
+      </debugger>
    </extension>
 
 </plugin>
Index: src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java
diff -N src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java	6 Apr 2003 01:06:25 -0000
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     Monta Vista - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.debug.mi.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.debug.core.ICDebugger;
+import org.eclipse.cdt.debug.core.cdi.CDIException;
+import org.eclipse.cdt.debug.core.cdi.ICDISession;
+import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
+import org.eclipse.cdt.debug.mi.core.cdi.Session;
+import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+public class GDBServerDebugger implements ICDebugger {
+
+	void initializeLibraries(ILaunchConfiguration config, Session session) throws CDIException {
+		try {
+			ICDISharedLibraryManager mgr = session.getSharedLibraryManager();
+			if (mgr instanceof SharedLibraryManager) {
+				boolean autolib = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, false);
+				((SharedLibraryManager)mgr).setAutoLoadSymbols(autolib);
+			}			
+			List p = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_SOLIB_PATH, new ArrayList(1));
+			if (p.size() > 0) {
+				String[] paths = (String[])p.toArray(new String[0]);
+				mgr.setSharedLibraryPaths(paths);
+			}
+		} catch (CoreException e) {
+			throw new CDIException("Error initializing: " + e.getMessage());
+		}
+	}
+
+	public ICDISession createLaunchSession(ILaunchConfiguration config, IFile exe) throws CDIException {
+		try {
+			String gdb = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
+			File cwd = exe.getProject().getLocation().toFile();
+			String remote;
+			if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) {
+				remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid");
+				remote += ":";
+				remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid");
+			} else {
+				remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid");
+			}
+			String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
+			String[] args = new String[] {"remote", remote};
+			Session session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit);
+			initializeLibraries(config, session);
+			return session;
+		} catch (IOException e) {
+			throw new CDIException("Error initializing: " + e.getMessage());
+		} catch (MIException e) {
+			throw new CDIException("Error initializing: " + e.getMessage());
+		} catch (CoreException e) {
+			throw new CDIException("Error initializing: " + e.getMessage());
+		}
+	}
+
+	public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException {
+		throw new CDIException("GDBServer does not support attaching");
+	}
+
+	public ICDISession createCoreSession(ILaunchConfiguration config, IFile exe, IPath corefile) throws CDIException {
+		throw new CDIException("GDBServer does not support core files");
+	}
+}
Index: src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java
diff -N src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java	6 Apr 2003 01:06:25 -0000
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     Monta Vista - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.debug.mi.core;
+
+
+public interface IGDBServerMILaunchConfigurationConstants extends IMILaunchConfigurationConstants {
+
+	/**
+	 * Launch configuration attribute key. The "remote target xxx" value.
+	 */
+	public static final String ATTR_REMOTE_TCP = MIPlugin.getUniqueIdentifier() + ".REMOTE_TCP"; //$NON-NLS-1$
+	public static final String ATTR_HOST = MIPlugin.getUniqueIdentifier() + ".HOST"; //$NON-NLS-1$
+	public static final String ATTR_PORT = MIPlugin.getUniqueIdentifier() + ".PORT"; //$NON-NLS-1$
+	public static final String ATTR_DEV = MIPlugin.getUniqueIdentifier() + ".DEV"; //$NON-NLS-1$
+}
Index: src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java,v
retrieving revision 1.38
diff -u -r1.38 MIPlugin.java
--- src/org/eclipse/cdt/debug/mi/core/MIPlugin.java	28 Mar 2003 23:05:44 -0000	1.38
+++ src/org/eclipse/cdt/debug/mi/core/MIPlugin.java	6 Apr 2003 01:06:26 -0000
@@ -199,21 +199,22 @@
 		}
 		Process pgdb = ProcessFactory.getFactory().exec(args);
 		MISession session = createMISession(pgdb, null, MISession.ATTACH);
-		MIInfo info = null;
 		CommandFactory factory = session.getCommandFactory();
 		if (targetParams != null && targetParams.length > 0) {
 			MITargetSelect target = factory.createMITargetSelect(targetParams);
 			session.postCommand(target);
-			info = target.getMIInfo();
+			MIInfo info = target.getMIInfo();
 			if (info == null) {
 				throw new MIException("No answer");
 			}
 		}
-		MITargetAttach attach = factory.createMITargetAttach(pid);
-		session.postCommand(attach);
-		info = attach.getMIInfo();
-		if (info == null) {
-			throw new MIException("No answer");
+		if (pid > 0) {
+			MITargetAttach attach = factory.createMITargetAttach(pid);
+			session.postCommand(attach);
+			MIInfo info = attach.getMIInfo();
+			if (info == null) {
+				throw new MIException("No answer");
+			}
 		}
 		//@@@ We have to manually set the suspended state when we attach
 		session.getMIInferior().setSuspended();



Back to the top