Note this is an interim the document and subject to changes.


****
This MI implementation is base on GDB/MI 5.2.1.

* Command/Response channels
To create an MISession an InputStream and OutputStream are
needed(assuming it is the pipe connected to gdb).

	MISession misession = new MISession(InputStream, OutputStream);
	
During initialisation of the session(MISession) two threads
are created TxThread, RxThread and associative list queues
TxQueue and RxQueue:
- The RxThread thread is block on readig the output of the pipe(gdb) for
any responses.
- The TxThread thread is block waiting for command.

MI Commands are created via the CommandFactory and
are added to the TxQueue, the TxThread will then wake up
generate a token(ID) for the command and send it to the pipe(gdb), after
transmission the command is then move to the RxQueue waiting for the 
result(MIResultRecord).

Any responses will wake the RxThread, the thread will parse
the response constructing an MIOutput, then it searches the RxQueue
for any commands with the same token waking any thread waiting
for a synchronous response(MIResultRecord).  Any out-of-band
responses(MIOOBRecord) are dispatch to MISession observers, clients interested
in notifications should register to the MISession.

* MI Parsing
There is a generic MI parser (MIParser) constructing an syntax tree of the output.
For example, a ResultRecord response after a "-break-insert", the parser will
generate this tree:
	10-break-insert main
	10^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
			addr="0x08048468",func="main",file="hello.c",line="4",times="0"}

	- MIOutput
		- MIOOBRecord[0]
		- MIResutRecord
			- token = 10
			- ResultClass = "done"
			- MIResult[1]
				- MIResult[0]
					- variable = "bkpt"
					- value = MITuple
						- MIResult[9]
							- MiResult[0]
								- variable = "number"
								- MIConst = "1"
							- MiResult[1]
								- variable = "type"
								- MIConst = "breakpoint"
							- MiResult[2]
								- variable = "disp"
								- MIConst = "keep"
							- MiResult[3]
								- variable = "enabled"
								- MIConst = "y"
							- MiResult[4]
								- variable = "addr"
								- MIConst = "0x08048468"
							- MiResult[5]
								- variable = "func"
								- MIConst = "main"
							- MiResult[6]
								- variable = "file"
								- MIConst = "hello.c"
							- MiResult[7]
								- variable = "line"
								- MIConst = "4"
							- MiResult[8]
								- variable = "times"
								- MIConst = "0"

MICommands will do there own parsing:
	session = MISession(in, out);
	MIBreakInsert cmd = new MIBreakInsert("main");
	session.postCommand(cmd);	// sent to gdb.
	MIBreakInsertInfo info = cmd.getBreakInsertInfo(); // Parsing of the Result Record.

****
MI Process

For convienience, to java.lang.Process is provided.

		MISession.getSessionProcess();

This Process talks directly to gdb and is smart enough to wrap any command
in CLICommand etc ..

	MISession.getMIInferior()
	
MIInferior implements Process for the Inferiror.

*****
MI <==> CDI Adapters

 To do.