diff --git a/debug/org.eclipse.cdt.debug.mi.core/.classpath b/debug/org.eclipse.cdt.debug.mi.core/.classpath
index dcb50cb4820..43c9b09db27 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/.classpath
+++ b/debug/org.eclipse.cdt.debug.mi.core/.classpath
@@ -4,6 +4,7 @@
+
diff --git a/debug/org.eclipse.cdt.debug.mi.core/.project b/debug/org.eclipse.cdt.debug.mi.core/.project
index 801091af765..7434461909b 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/.project
+++ b/debug/org.eclipse.cdt.debug.mi.core/.project
@@ -3,6 +3,7 @@
org.eclipse.cdt.debug.mi.core
+ org.eclipse.cdt.core
org.eclipse.cdt.debug.core
org.eclipse.core.boot
org.eclipse.core.resources
diff --git a/debug/org.eclipse.cdt.debug.mi.core/plugin.xml b/debug/org.eclipse.cdt.debug.mi.core/plugin.xml
index 8e09f743cd2..c3b93c742ed 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.mi.core/plugin.xml
@@ -15,6 +15,7 @@
+
@@ -22,7 +23,7 @@
point="org.eclipse.cdt.debug.core.CDebugger">
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
index fc7d8001e96..5d4992caf56 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
@@ -20,7 +20,10 @@ public class GDBDebugger implements ICDebugger {
return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString());
}
catch (IOException e) {
- throw new CDIException("Error initializing");
+ throw new CDIException("Error initializing: " + e.getMessage());
+ }
+ catch (MIException e) {
+ throw new CDIException("Error initializing: " + e.getMessage());
}
}
@@ -29,8 +32,12 @@ public class GDBDebugger implements ICDebugger {
return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString(), pid);
}
catch (IOException e) {
- throw new CDIException("Error initializing");
+ throw new CDIException("Error initializing: " + e.getMessage());
}
+ catch (MIException e) {
+ throw new CDIException("Error initializing: " + e.getMessage());
+ }
+
}
public ICDISession createCoreSession(ILaunchConfiguration config, IFile exe, IPath corefile) throws CDIException {
@@ -38,8 +45,12 @@ public class GDBDebugger implements ICDebugger {
return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString(), corefile.toOSString());
}
catch (IOException e) {
- throw new CDIException("Error initializing");
+ throw new CDIException("Error initializing: " + e.getMessage());
}
+ catch (MIException e) {
+ throw new CDIException("Error initializing: " + e.getMessage());
+ }
+
}
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
index a37d740a20b..1e3a06e66dd 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
@@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
import org.eclipse.cdt.debug.mi.core.command.MITargetAttach;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin;
@@ -47,8 +48,8 @@ public class MIPlugin extends Plugin {
* @param out
* @return MISession
*/
- public MISession createMISession(InputStream in, OutputStream out) {
- return new MISession(in, out);
+ public MISession createMISession(Process process) throws MIException {
+ return new MISession(process);
}
/**
@@ -57,10 +58,10 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
- public ICDISession createCSession(String program) throws IOException {
+ public ICDISession createCSession(String program) throws IOException, MIException {
String[]args = new String[]{"gdb", "-q", "-i", "mi", program};
- Process gdb = Runtime.getRuntime().exec(args);
- MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream());
+ Process gdb = ProcessFactory.getFactory().exec(args);
+ MISession session = createMISession(gdb);
/*
try {
CommandFactory factory = session.getCommandFactory();
@@ -74,7 +75,7 @@ public class MIPlugin extends Plugin {
throw new IOException("Failed to attach");
}
*/
- return new CSession(session);
+ return new CSession(session, false);
}
/**
@@ -84,10 +85,10 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
- public ICDISession createCSession(String program, String core) throws IOException {
+ public ICDISession createCSession(String program, String core) throws IOException, MIException {
String[]args = new String[]{"gdb", "--quiet", "-i", "mi", program, core};
- Process gdb = Runtime.getRuntime().exec(args);
- MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream());
+ Process gdb = ProcessFactory.getFactory().exec(args);
+ MISession session = createMISession(gdb);
return new CSession(session);
}
@@ -98,10 +99,10 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
- public ICDISession createCSession(String program, int pid) throws IOException {
+ public ICDISession createCSession(String program, int pid) throws IOException, MIException {
String[]args = new String[]{"gdb", "--quiet", "-i", "mi", program};
- Process gdb = Runtime.getRuntime().exec(args);
- MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream());
+ Process gdb = ProcessFactory.getFactory().exec(args);
+ MISession session = createMISession(gdb);
try {
CommandFactory factory = session.getCommandFactory();
MITargetAttach attach = factory.createMITargetAttach(pid);
@@ -113,7 +114,7 @@ public class MIPlugin extends Plugin {
} catch (MIException e) {
throw new IOException("Failed to attach");
}
- return new CSession(session);
+ return new CSession(session, true);
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java
index 277294db9c3..b43f1692d51 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java
@@ -30,7 +30,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIParser;
* there a good change to confuse the parser.
*/
public class MISession extends Observable {
-
+ Process miProcess;
InputStream inChannel;
OutputStream outChannel;
@@ -59,9 +59,10 @@ public class MISession extends Observable {
* @param i the gdb input channel.
* @param o gdb output channel.
*/
- public MISession(InputStream i, OutputStream o) {
- inChannel = i;
- outChannel = o;
+ public MISession(Process process) throws MIException {
+ miProcess = process;
+ inChannel = process.getInputStream();
+ outChannel = process.getOutputStream();
factory = new CommandFactory();
@@ -84,23 +85,19 @@ public class MISession extends Observable {
// Disable a certain number of irritations from gdb.
// Like confirmation and screen size.
- try {
- MIInfo info;
+ MIInfo info;
- MIGDBSet confirm = new MIGDBSet(new String[]{"confirm", "off"});
- postCommand(confirm);
- info = confirm.getMIInfo();
+ MIGDBSet confirm = new MIGDBSet(new String[]{"confirm", "off"});
+ postCommand(confirm);
+ info = confirm.getMIInfo();
- MIGDBSet width = new MIGDBSet(new String[]{"width", "0"});
- postCommand(width);
- info = confirm.getMIInfo();
+ MIGDBSet width = new MIGDBSet(new String[]{"width", "0"});
+ postCommand(width);
+ info = confirm.getMIInfo();
- MIGDBSet height = new MIGDBSet(new String[]{"height", "0"});
- postCommand(height);
- info = confirm.getMIInfo();
- } catch (MIException e) {
- // FIXME: Do not catch the exception but pass it up.
- }
+ MIGDBSet height = new MIGDBSet(new String[]{"height", "0"});
+ postCommand(height);
+ info = confirm.getMIInfo();
}
/**
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java
index db435b694f1..d1f76a70731 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java
@@ -35,9 +35,20 @@ public class CSession implements ICDISession, ICDISessionObject {
MemoryManager memoryManager;
SignalManager signalManager;
SourceManager sourceManager;
+ ICDIConfiguration configuration;
CTarget ctarget;
+ public CSession(MISession s, boolean attach) {
+ commonSetup(s);
+ configuration = new Configuration(attach);
+ }
+
public CSession(MISession s) {
+ commonSetup(s);
+ configuration = new CoreFileConfiguration();
+ }
+
+ private void commonSetup(MISession s) {
session = s;
props = new Properties();
breakpointManager = new BreakpointManager(this);
@@ -49,7 +60,6 @@ public class CSession implements ICDISession, ICDISessionObject {
sourceManager = new SourceManager(this);
ctarget = new CTarget(this);
}
-
MISession getMISession() {
return session;
}
@@ -155,7 +165,7 @@ public class CSession implements ICDISession, ICDISessionObject {
* @see org.eclipse.cdt.debug.core.cdi.ICSuration()
*/
public ICDIConfiguration getConfiguration() {
- return new Configuration();
+ return configuration;
}
/**
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java
index b50e1f3392e..25f2ffadd10 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java
@@ -16,7 +16,11 @@ import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
* Window>Preferences>Java>Code Generation.
*/
public class Configuration implements ICDIConfiguration {
-
+ protected boolean fAttached;
+
+ public Configuration(boolean attached) {
+ fAttached = attached;
+ }
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsBreakpoints()
*/
@@ -28,7 +32,7 @@ public class Configuration implements ICDIConfiguration {
* @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsDisconnect()
*/
public boolean supportsDisconnect() {
- return false;
+ return fAttached ? true :false;
}
/**
@@ -77,7 +81,7 @@ public class Configuration implements ICDIConfiguration {
* @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsRestart()
*/
public boolean supportsRestart() {
- return true;
+ return fAttached ? false : true;
}
/**
@@ -98,6 +102,6 @@ public class Configuration implements ICDIConfiguration {
* @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsTerminate()
*/
public boolean supportsTerminate() {
- return true;
+ return fAttached ? false : true;
}
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CoreFileConfiguration.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CoreFileConfiguration.java
new file mode 100644
index 00000000000..5c67c33e8a9
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CoreFileConfiguration.java
@@ -0,0 +1,58 @@
+/*
+ * (c) Copyright QNX Software System Ltd. 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.cdt.debug.mi.core.cdi;
+
+import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
+
+public class CoreFileConfiguration implements ICDIConfiguration {
+
+ public boolean supportsTerminate() {
+ return true;
+ }
+
+ public boolean supportsDisconnect() {
+ return false;
+ }
+
+ public boolean supportsSuspendResume() {
+ return false;
+ }
+
+ public boolean supportsRestart() {
+ return false;
+ }
+
+ public boolean supportsStepping() {
+ return false;
+ }
+
+ public boolean supportsInstructionStepping() {
+ return false;
+ }
+
+ public boolean supportsBreakpoints() {
+ return false;
+ }
+
+ public boolean supportsRegisters() {
+ return true;
+ }
+
+ public boolean supportsRegisterModification() {
+ return false;
+ }
+
+ public boolean supportsMemoryRetrieval() {
+ return true;
+ }
+
+ public boolean supportsMemoryModification() {
+ return false;
+ }
+
+ public boolean supportsExpressionEvaluation() {
+ return true;
+ }
+}