1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 02:35:37 +02:00

Change the MISession constructor to add a new argument

that will indicate the type of session being created.
Add 3 new methods that will return the type of session:
Post-mortem, attach or regular debug.
This commit is contained in:
Alain Magloire 2002-10-09 01:56:08 +00:00
parent fdf2c99a70
commit 0d8dcf74cc

View file

@ -31,6 +31,29 @@ import org.eclipse.cdt.utils.pty.PTY;
* 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 {
/**
* Normal program debuging.
*/
public final static int PROGRAM = 0;
/**
* Attach to a running process debuging.
*/
public final static int ATTACH = 1;
/**
* PostMortem analysis.
*/
public final static int CORE = 2;
/**
* Default wait() period for an answer after a query, 10 seconds.
*/
public static long REQUEST_TIMEOUT = 10000; // 10 * 1000 (~ 10 secs);
// hold the type of the session(post-mortem, attach etc ..)
int sessionType;
Process miProcess; Process miProcess;
InputStream inChannel; InputStream inChannel;
OutputStream outChannel; OutputStream outChannel;
@ -50,35 +73,32 @@ public class MISession extends Observable {
MIParser parser; MIParser parser;
long cmdTimeout = 10000; // 10 * 1000 (~ 10 secs); long cmdTimeout;
MIInferior inferior; MIInferior inferior;
/**
* Create the gdb session.
*
* @param Process gdb Process.
*/
public MISession(Process process) throws MIException {
this(process, null);
}
/** /**
* Create the gdb session. * Create the gdb session.
* *
* @param Process gdb Process. * @param Process gdb Process.
* @param pty Terminal to use for the inferior. * @param pty Terminal to use for the inferior.
* @param timeout time in milliseconds to wait for command response.
* @param type the type of debugin session.
*/ */
public MISession(Process process, PTY pty) throws MIException { public MISession(Process process, PTY pty, int timeout, int type) throws MIException {
miProcess = process; miProcess = process;
inChannel = process.getInputStream(); inChannel = process.getInputStream();
outChannel = process.getOutputStream(); outChannel = process.getOutputStream();
cmdTimeout = timeout;
sessionType = type;
factory = new CommandFactory(); factory = new CommandFactory();
parser = new MIParser(); parser = new MIParser();
// Do this first.
inferior = new MIInferior(this, pty); inferior = new MIInferior(this, pty);
txQueue = new CommandQueue(); txQueue = new CommandQueue();
@ -112,6 +132,7 @@ public class MISession extends Observable {
/** /**
* get MI Console Stream. * get MI Console Stream.
* The parser will make available the MI console stream output.
*/ */
public InputStream getMIStream() { public InputStream getMIStream() {
if (miInPipe == null) { if (miInPipe == null) {
@ -154,6 +175,41 @@ public class MISession extends Observable {
parser = p; parser = p;
} }
/**
* Set the type of session this is.
* Certain action will base on that, for example
* the inferior will not try to kill/destroy a
* attach session disconnected.
*/
public int getSessionType() {
return sessionType;
}
public void setSessionType(int type) {
sessionType = type;
}
/**
* The debug session is a program being debug.
*/
public boolean isProgramSession() {
return sessionType == PROGRAM;
}
/**
* The debug session is a program being attach to.
*/
public boolean isAttachSession() {
return sessionType == ATTACH;
}
/**
* The debug session is a core being analysed.
*/
public boolean isCoreSession() {
return sessionType == CORE;
}
/** /**
* Reset the default Command Timeout. * Reset the default Command Timeout.
*/ */
@ -170,7 +226,7 @@ public class MISession extends Observable {
/** /**
* equivalent to: * equivalent to:
* postCommand(cmd, 10 secs) * postCommand(cmd, cmdTimeout)
*/ */
public void postCommand(Command cmd) throws MIException { public void postCommand(Command cmd) throws MIException {
postCommand(cmd, cmdTimeout); postCommand(cmd, cmdTimeout);