mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 01:45:33 +02:00
New file.
This commit is contained in:
parent
98af1928a2
commit
b73167960d
1 changed files with 87 additions and 0 deletions
|
@ -0,0 +1,87 @@
|
|||
package org.eclipse.cdt.debug.mi.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class SessionProcess extends Process {
|
||||
|
||||
MISession session;
|
||||
OutputStream out;
|
||||
|
||||
public SessionProcess(MISession s) {
|
||||
session = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Process#destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
session.getGDBProcess().destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Process#exitValue()
|
||||
*/
|
||||
public int exitValue() {
|
||||
return session.getGDBProcess().exitValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Process#getErrorStream()
|
||||
*/
|
||||
public InputStream getErrorStream() {
|
||||
return session.getMILogStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Process#getInputStream()
|
||||
*/
|
||||
public InputStream getInputStream() {
|
||||
return session.getMIConsoleStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Process#getOutputStream()
|
||||
*/
|
||||
public OutputStream getOutputStream() {
|
||||
if (out == null) {
|
||||
out = new OutputStream() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
public void write(int b) throws IOException {
|
||||
buf.append((char)b);
|
||||
if (b == '\n') {
|
||||
post();
|
||||
}
|
||||
}
|
||||
|
||||
// Encapsulate the string sent to gdb in a fake
|
||||
// command and post it to the TxThread.
|
||||
public void post() throws IOException {
|
||||
// Throw away the newline.
|
||||
String str = buf.toString().trim();
|
||||
CLICommand cmd = new CLICommand(str);
|
||||
buf.setLength(0);
|
||||
try {
|
||||
session.postCommand(cmd);
|
||||
} catch (MIException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Process#waitFor()
|
||||
*/
|
||||
public int waitFor() throws InterruptedException {
|
||||
return session.getGDBProcess().waitFor();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue