mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 23:15: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:
parent
b6e864c88b
commit
bc2d280abd
9 changed files with 125 additions and 41 deletions
|
@ -4,6 +4,7 @@
|
|||
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
|
||||
<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.boot"/>
|
||||
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<name>org.eclipse.cdt.debug.mi.core</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>org.eclipse.cdt.core</project>
|
||||
<project>org.eclipse.cdt.debug.core</project>
|
||||
<project>org.eclipse.core.boot</project>
|
||||
<project>org.eclipse.core.resources</project>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<import plugin="org.eclipse.cdt.debug.core"/>
|
||||
<import plugin="org.eclipse.core.resources"/>
|
||||
<import plugin="org.eclipse.debug.core"/>
|
||||
<import plugin="org.eclipse.cdt.core"/>
|
||||
</requires>
|
||||
|
||||
|
||||
|
@ -22,7 +23,7 @@
|
|||
point="org.eclipse.cdt.debug.core.CDebugger">
|
||||
<debugger
|
||||
name="%GDBDebugger.name"
|
||||
modes="run"
|
||||
modes="run,core"
|
||||
class="org.eclipse.cdt.debug.mi.core.GDBDebugger"
|
||||
id="org.eclipse.cdt.debug.mi.core.CDebugger">
|
||||
</debugger>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue