1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-21 07:55:24 +02:00

changed Runtime.exec to use ProcessFactory in cdt.core change

ICDISession.getConfiguration() to return a proper config based on run/attach/corefile
This commit is contained in:
David Inglis 2002-08-30 14:20:19 +00:00
parent b6e864c88b
commit bc2d280abd
9 changed files with 125 additions and 41 deletions

View file

@ -4,6 +4,7 @@
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/> <classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.core.resources"/> <classpathentry kind="src" path="/org.eclipse.core.resources"/>
<classpathentry kind="src" path="/org.eclipse.debug.core"/> <classpathentry kind="src" path="/org.eclipse.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.cdt.core"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/> <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/> <classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/> <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>

View file

@ -3,6 +3,7 @@
<name>org.eclipse.cdt.debug.mi.core</name> <name>org.eclipse.cdt.debug.mi.core</name>
<comment></comment> <comment></comment>
<projects> <projects>
<project>org.eclipse.cdt.core</project>
<project>org.eclipse.cdt.debug.core</project> <project>org.eclipse.cdt.debug.core</project>
<project>org.eclipse.core.boot</project> <project>org.eclipse.core.boot</project>
<project>org.eclipse.core.resources</project> <project>org.eclipse.core.resources</project>

View file

@ -15,6 +15,7 @@
<import plugin="org.eclipse.cdt.debug.core"/> <import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.core.resources"/> <import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.debug.core"/> <import plugin="org.eclipse.debug.core"/>
<import plugin="org.eclipse.cdt.core"/>
</requires> </requires>
@ -22,7 +23,7 @@
point="org.eclipse.cdt.debug.core.CDebugger"> point="org.eclipse.cdt.debug.core.CDebugger">
<debugger <debugger
name="%GDBDebugger.name" name="%GDBDebugger.name"
modes="run" modes="run,core"
class="org.eclipse.cdt.debug.mi.core.GDBDebugger" class="org.eclipse.cdt.debug.mi.core.GDBDebugger"
id="org.eclipse.cdt.debug.mi.core.CDebugger"> id="org.eclipse.cdt.debug.mi.core.CDebugger">
</debugger> </debugger>

View file

@ -20,7 +20,10 @@ public class GDBDebugger implements ICDebugger {
return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString()); return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString());
} }
catch (IOException e) { 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); return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString(), pid);
} }
catch (IOException e) { 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 { 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()); return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString(), corefile.toOSString());
} }
catch (IOException e) { 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());
}
} }
} }

View file

@ -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.MIBreakInsert;
import org.eclipse.cdt.debug.mi.core.command.MITargetAttach; import org.eclipse.cdt.debug.mi.core.command.MITargetAttach;
import org.eclipse.cdt.debug.mi.core.output.MIInfo; 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.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Plugin;
@ -47,8 +48,8 @@ public class MIPlugin extends Plugin {
* @param out * @param out
* @return MISession * @return MISession
*/ */
public MISession createMISession(InputStream in, OutputStream out) { public MISession createMISession(Process process) throws MIException {
return new MISession(in, out); return new MISession(process);
} }
/** /**
@ -57,10 +58,10 @@ public class MIPlugin extends Plugin {
* @return ICDISession * @return ICDISession
* @throws IOException * @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}; String[]args = new String[]{"gdb", "-q", "-i", "mi", program};
Process gdb = Runtime.getRuntime().exec(args); Process gdb = ProcessFactory.getFactory().exec(args);
MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream()); MISession session = createMISession(gdb);
/* /*
try { try {
CommandFactory factory = session.getCommandFactory(); CommandFactory factory = session.getCommandFactory();
@ -74,7 +75,7 @@ public class MIPlugin extends Plugin {
throw new IOException("Failed to attach"); 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 * @return ICDISession
* @throws IOException * @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}; String[]args = new String[]{"gdb", "--quiet", "-i", "mi", program, core};
Process gdb = Runtime.getRuntime().exec(args); Process gdb = ProcessFactory.getFactory().exec(args);
MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream()); MISession session = createMISession(gdb);
return new CSession(session); return new CSession(session);
} }
@ -98,10 +99,10 @@ public class MIPlugin extends Plugin {
* @return ICDISession * @return ICDISession
* @throws IOException * @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}; String[]args = new String[]{"gdb", "--quiet", "-i", "mi", program};
Process gdb = Runtime.getRuntime().exec(args); Process gdb = ProcessFactory.getFactory().exec(args);
MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream()); MISession session = createMISession(gdb);
try { try {
CommandFactory factory = session.getCommandFactory(); CommandFactory factory = session.getCommandFactory();
MITargetAttach attach = factory.createMITargetAttach(pid); MITargetAttach attach = factory.createMITargetAttach(pid);
@ -113,7 +114,7 @@ public class MIPlugin extends Plugin {
} catch (MIException e) { } catch (MIException e) {
throw new IOException("Failed to attach"); throw new IOException("Failed to attach");
} }
return new CSession(session); return new CSession(session, true);
} }

View file

@ -30,7 +30,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIParser;
* there a good change to confuse the parser. * there a good change to confuse the parser.
*/ */
public class MISession extends Observable { public class MISession extends Observable {
Process miProcess;
InputStream inChannel; InputStream inChannel;
OutputStream outChannel; OutputStream outChannel;
@ -59,9 +59,10 @@ public class MISession extends Observable {
* @param i the gdb input channel. * @param i the gdb input channel.
* @param o gdb output channel. * @param o gdb output channel.
*/ */
public MISession(InputStream i, OutputStream o) { public MISession(Process process) throws MIException {
inChannel = i; miProcess = process;
outChannel = o; inChannel = process.getInputStream();
outChannel = process.getOutputStream();
factory = new CommandFactory(); factory = new CommandFactory();
@ -84,23 +85,19 @@ public class MISession extends Observable {
// Disable a certain number of irritations from gdb. // Disable a certain number of irritations from gdb.
// Like confirmation and screen size. // Like confirmation and screen size.
try { MIInfo info;
MIInfo info;
MIGDBSet confirm = new MIGDBSet(new String[]{"confirm", "off"}); MIGDBSet confirm = new MIGDBSet(new String[]{"confirm", "off"});
postCommand(confirm); postCommand(confirm);
info = confirm.getMIInfo(); info = confirm.getMIInfo();
MIGDBSet width = new MIGDBSet(new String[]{"width", "0"}); MIGDBSet width = new MIGDBSet(new String[]{"width", "0"});
postCommand(width); postCommand(width);
info = confirm.getMIInfo(); info = confirm.getMIInfo();
MIGDBSet height = new MIGDBSet(new String[]{"height", "0"}); MIGDBSet height = new MIGDBSet(new String[]{"height", "0"});
postCommand(height); postCommand(height);
info = confirm.getMIInfo(); info = confirm.getMIInfo();
} catch (MIException e) {
// FIXME: Do not catch the exception but pass it up.
}
} }
/** /**

View file

@ -35,9 +35,20 @@ public class CSession implements ICDISession, ICDISessionObject {
MemoryManager memoryManager; MemoryManager memoryManager;
SignalManager signalManager; SignalManager signalManager;
SourceManager sourceManager; SourceManager sourceManager;
ICDIConfiguration configuration;
CTarget ctarget; CTarget ctarget;
public CSession(MISession s, boolean attach) {
commonSetup(s);
configuration = new Configuration(attach);
}
public CSession(MISession s) { public CSession(MISession s) {
commonSetup(s);
configuration = new CoreFileConfiguration();
}
private void commonSetup(MISession s) {
session = s; session = s;
props = new Properties(); props = new Properties();
breakpointManager = new BreakpointManager(this); breakpointManager = new BreakpointManager(this);
@ -49,7 +60,6 @@ public class CSession implements ICDISession, ICDISessionObject {
sourceManager = new SourceManager(this); sourceManager = new SourceManager(this);
ctarget = new CTarget(this); ctarget = new CTarget(this);
} }
MISession getMISession() { MISession getMISession() {
return session; return session;
} }
@ -155,7 +165,7 @@ public class CSession implements ICDISession, ICDISessionObject {
* @see org.eclipse.cdt.debug.core.cdi.ICSuration() * @see org.eclipse.cdt.debug.core.cdi.ICSuration()
*/ */
public ICDIConfiguration getConfiguration() { public ICDIConfiguration getConfiguration() {
return new Configuration(); return configuration;
} }
/** /**

View file

@ -16,7 +16,11 @@ import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
* Window>Preferences>Java>Code Generation. * Window>Preferences>Java>Code Generation.
*/ */
public class Configuration implements ICDIConfiguration { public class Configuration implements ICDIConfiguration {
protected boolean fAttached;
public Configuration(boolean attached) {
fAttached = attached;
}
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsBreakpoints() * @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() * @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsDisconnect()
*/ */
public boolean 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() * @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsRestart()
*/ */
public boolean 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() * @see org.eclipse.cdt.debug.core.cdi.ICDIConfiguration#supportsTerminate()
*/ */
public boolean supportsTerminate() { public boolean supportsTerminate() {
return true; return fAttached ? false : true;
} }
} }

View file

@ -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;
}
}