[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Third times a charm - Cygwin GDB - mi.core
|
Title: Third times a charm - Cygwin GDB - mi.core
This attempt uses Dave Inglis's idea to create a new command factory for Cygwin GDB as a subclass of the regular command factory and overrides the MIEnvironmentDirectory command that was causing the timeout. I have also used Sam Robb's idea to use cygpath to generate the correct path names for cygwin. Please review. The mi.ui patch is still required as is.
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.38
diff -u -r1.38 ChangeLog
--- ChangeLog 25 Nov 2002 17:08:07 -0000 1.38
+++ ChangeLog 26 Nov 2002 19:06:40 -0000
@@ -1,3 +1,15 @@
+2002-11-26 Doug Schaefer
+
+ * src/.../mi/core/CygwinGDBDebugger.java
+ New Debugger that provides the Cygwin Command Factory to the MISession
+ * src/.../mi/core/command/CygwinCommandFactory.java
+ New Command Factory for Cygwin specific implementations of the commands
+ * src/.../mi/core/command/CygwinMIEnvironmentDirectory.java
+ New. Subclasses the MIEnvironmentDirectory command to convert the
+ paths using cygpath.
+ * plugin.xml
+ Defines the new debugger extension.
+
2002-11-25 Alain Magloire
* src/.../mi/core/cdi/Watchpoint.java:
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/plugin.xml,v
retrieving revision 1.12
diff -u -r1.12 plugin.xml
--- plugin.xml 13 Nov 2002 14:00:45 -0000 1.12
+++ plugin.xml 26 Nov 2002 19:06:39 -0000
@@ -22,12 +22,20 @@
<extension
point="org.eclipse.cdt.debug.core.CDebugger">
<debugger
+ platform="native"
name="%GDBDebugger.name"
modes="run,core,attach"
+ cpu="native"
class="org.eclipse.cdt.debug.mi.core.GDBDebugger"
- id="org.eclipse.cdt.debug.mi.core.CDebugger"
- cpu="native"
- platform="native">
+ id="org.eclipse.cdt.debug.mi.core.CDebugger">
+ </debugger>
+ <debugger
+ platform="win32"
+ name="Cygwin GDB Debugger"
+ modes="run,core,attach"
+ cpu="native"
+ class="org.eclipse.cdt.debug.mi.core.CygwinGDBDebugger"
+ id="org.eclipse.cdt.debug.mi.core.CygwinCDebugger">
</debugger>
</extension>
Index: src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java
diff -N src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java 26 Nov 2002 19:06:40 -0000
@@ -0,0 +1,44 @@
+/*
+ * (c) Copyright Rational Software Corporation. 2002.
+ * All Rights Reserved.
+ */
+
+package org.eclipse.cdt.debug.mi.core;
+
+import org.eclipse.cdt.debug.core.cdi.CDIException;
+import org.eclipse.cdt.debug.core.cdi.ICDISession;
+import org.eclipse.cdt.debug.mi.core.cdi.CSession;
+import org.eclipse.cdt.debug.mi.core.command.CygwinCommandFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+/**
+ * @author Doug Schaefer
+ *
+ * Cygwin GDB Debugger overrides the GDB Debugger to apply the Cygwin
+ * Command Factory to the MI Session.
+ */
+public class CygwinGDBDebugger extends GDBDebugger {
+
+ static final CygwinCommandFactory commandFactory = new CygwinCommandFactory();
+
+ public ICDISession createLaunchSession(ILaunchConfiguration config, IFile exe) throws CDIException
+ {
+ CSession session = (CSession)super.createLaunchSession(config, exe);
+ session.getMISession().setCommandFactory(commandFactory);
+ return session;
+ }
+
+ public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException {
+ CSession session = (CSession)super.createAttachSession(config, exe, pid);
+ session.getMISession().setCommandFactory(commandFactory);
+ return session;
+ }
+
+ public ICDISession createCoreSession(ILaunchConfiguration config, IFile exe, IPath corefile) throws CDIException {
+ CSession session = (CSession)super.createCoreSession(config, exe, corefile);
+ session.getMISession().setCommandFactory(commandFactory);
+ return session;
+ }
+}
Index: src/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java
diff -N src/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/command/CygwinCommandFactory.java 26 Nov 2002 19:06:41 -0000
@@ -0,0 +1,21 @@
+/*
+ *(c) Copyright Rational Software Corporation, 2002
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.mi.core.command;
+
+/**
+ * @author Doug Schaefer
+ *
+ * Cygwin Command Factory overrides the regular Command Factory to allow for
+ * commands to take into account the cygwin environment.
+ */
+public class CygwinCommandFactory extends CommandFactory {
+
+ public MIEnvironmentDirectory createMIEnvironmentDirectory(String[] pathdirs) {
+ return new CygwinMIEnvironmentDirectory(pathdirs);
+ }
+
+}
Index: src/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentDirectory.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentDirectory.java
diff -N src/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentDirectory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/command/CygwinMIEnvironmentDirectory.java 26 Nov 2002 19:06:41 -0000
@@ -0,0 +1,41 @@
+/*
+ *(c) Copyright Rational Software Corporation, 2002
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.mi.core.command;
+
+import java.io.ByteArrayOutputStream;
+
+import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * @author Doug Schaefer
+ *
+ * Cygwin implementation of the MIEnvironmentDirectory command. In the cygwin
+ * environment, the paths are DOS paths and need to be converted to cygwin
+ * style paths before passing them to gdb.
+ */
+public class CygwinMIEnvironmentDirectory extends MIEnvironmentDirectory {
+
+ CygwinMIEnvironmentDirectory(String [] paths) {
+ super(paths);
+
+ String[] newpaths = new String[paths.length];
+ for (int i = 0; i < paths.length; i++) {
+ // Use the cygpath utility to convert the path
+ CommandLauncher launcher = new CommandLauncher();
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+ launcher.execute(new Path("cygpath"), new String [] { paths[i] }, new String [0], new Path("."));
+ if (launcher.waitAndRead(output, output) != CommandLauncher.OK)
+ newpaths[i] = paths[i];
+ else
+ newpaths[i] = output.toString().trim();
+ }
+
+ setParameters(newpaths);
+ }
+}
Doug Schaefer
Senior Staff Software Engineer
Rational - the software development company
Ottawa (Kanata), Ontario, Canada