1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-16 20:55:44 +02:00

more implementation.

This commit is contained in:
Alain Magloire 2002-07-31 03:46:51 +00:00
parent 4f4deeebe7
commit d5f1ab4560
25 changed files with 507 additions and 142 deletions

View file

@ -0,0 +1,36 @@
<html>
<head>
</head>
<body>
<pre>
Note this is an interim the document and subject to changes.
****
This MI implementation is base on GDB/MI 5.2.1.
To create an MISession an InputStream and OutputStream are
needed(assuming this the pipe connected to gdb).
MISession MIPlugin.createSession(InputStream, OutputStream);
During initialisation of the session(MISession) two threads
are created(TxThread, RxThread). MI Commands created via the CommandFactory
are added to the TxQueue, the TxThread will then wake up
generate a token(ID) for the command and send it 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 would parse
the response constructing an MIOutput then search 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, clients interested in those
notifications should register to MISession.
****
MI <==> CDI Adapters
To do.
</pre>
</body>
</html>

View file

@ -0,0 +1,90 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.command.MIBreakAfter;
import org.eclipse.cdt.debug.mi.core.command.MIBreakCondition;
import org.eclipse.cdt.debug.mi.core.command.MIBreakDelete;
import org.eclipse.cdt.debug.mi.core.command.MIBreakDisable;
import org.eclipse.cdt.debug.mi.core.command.MIBreakEnable;
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
import org.eclipse.cdt.debug.mi.core.command.MIBreakList;
import org.eclipse.cdt.debug.mi.core.command.MIBreakWatch;
import org.eclipse.cdt.debug.mi.core.command.MIDataDisassemble;
import org.eclipse.cdt.debug.mi.core.command.MIDataEvaluateExpression;
import org.eclipse.cdt.debug.mi.core.command.MIDataListChangedRegisters;
import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterNames;
import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterValues;
import org.eclipse.cdt.debug.mi.core.command.MIDataReadMemory;
/**
*
*/
public class CommandFactory {
public MIBreakAfter createMIBreakAfter(int brknum, int count) {
return new MIBreakAfter(brknum, count);
}
public MIBreakCondition createMIBreakCondition (int brknum, String expr) {
return new MIBreakCondition(brknum, expr);
}
public MIBreakDelete createMIBreakDelete (int[] brknum) {
return new MIBreakDelete(brknum);
}
public MIBreakDisable createMIBreakDisable(int[] brknum) {
return new MIBreakDisable(brknum);
}
public MIBreakEnable createMIBreakEnable(int[] brknum) {
return new MIBreakEnable(brknum);
}
public MIBreakInsert createMIBreakInsert(boolean isTemporary, boolean isHardware,
String condition, int ignoreCount, String line) {
return new MIBreakInsert(isTemporary, isHardware, condition, ignoreCount, line);
}
public MIBreakInsert createMIBreakInsert(String regex) {
return new MIBreakInsert(regex);
}
public MIBreakList createMIBreakList() {
return new MIBreakList();
}
public MIBreakWatch createMIBreakWatch(boolean access, boolean read, String expression) {
return new MIBreakWatch(access, read, expression);
}
public MIDataDisassemble createMIDataDisassemble(String start, String end, boolean mixed) {
return new MIDataDisassemble(start, end, mixed);
}
public MIDataDisassemble createMIDataDisassemble(String file, int linenum, int lines, boolean mixed) {
return new MIDataDisassemble(file, linenum, lines, mixed);
}
public MIDataEvaluateExpression createMIDataEvaluateExpression(String expression) {
return new MIDataEvaluateExpression(expression);
}
public MIDataListChangedRegisters createMIDataListChangedRegisters() {
return new MIDataListChangedRegisters();
}
public MIDataListRegisterNames createMIDataListRegisterNames(int[] regno) {
return new MIDataListRegisterNames(regno);
}
public MIDataListRegisterValues createMIDataLIstRegisterValues(int fmt, int[] regno) {
return new MIDataListRegisterValues(fmt, regno);
}
public MIDataReadMemory createMIDataReadMemory(int offset, String address,
String wordFormat, int wordSize,
int rows, int cols, Character asChar) {
return new MIDataReadMemory(offset, address, wordFormat, wordSize,
rows, cols, asChar);
}
}

View file

@ -0,0 +1,30 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIBreakListInfo extends MIInfo {
public class BreakPoint {
int number;
String type;
String disposition;
boolean enabled;
int address;
String what;
int times;
}
public MIBreakListInfo(MIResultRecord rr) {
super(rr);
}
int getCount() {
return 0;
}
BreakPoint[] getBreakPoints() {
return null;
}
}

View file

@ -0,0 +1,20 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIBreakWatchInfo extends MIInfo {
public MIBreakWatchInfo(MIResultRecord rr) {
super(rr);
}
public int getNumber () {
return 0;
}
public String getExpression() {
return null;
}
}

View file

@ -0,0 +1,36 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIBreakpointHitInfo extends MIInfo {
public MIBreakpointHitInfo(MIResultRecord record) {
super(record);
}
int getBreakNumber() {
return 0;
}
String getFunction() {
return null;
}
int getAddress() {
return 0;
}
String getFileName() {
return null;
}
int getLineNumber() {
return 0;
}
String[] getArguments () {
return null;
}
}

View file

@ -1,34 +1,32 @@
package org.eclipse.cdt.debug.mi.core; package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/** /**
* @author alain
*
*/ */
public class MIBreakpointInfo extends MIInfo { public class MIBreakpointInfo extends MIInfo {
int line, number; public MIBreakpointInfo(MIResultRecord record) {
String function, file; super(record);
public MIBreakpointInfo(int no, String func, String filename, int lineno) {
number = no;
function = func;
file = filename;
line = lineno;
} }
public int getNumber() { int getBreakNumber() {
return number; return 0;
} }
public String getFunction() { String getFunction() {
return function; return null;
} }
public String getFile() { int getAddress() {
return file; return 0;
} }
public int getLineNumber() { String getFileName() {
return line; return null;
}
int getLineNumber() {
return 0;
} }
} }

View file

@ -0,0 +1,29 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIDataDisassembleInfo extends MIInfo {
public class ASM {
int address;
String function;
int offset;
String instruction;
int line;
String file;
}
public MIDataDisassembleInfo(MIResultRecord rr) {
super(rr);
}
public int getCount() {
return 0;
}
public ASM[] getData() {
return null;
}
}

View file

@ -0,0 +1,16 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIDataEvaluateExpressionInfo extends MIInfo{
public MIDataEvaluateExpressionInfo(MIResultRecord rr) {
super(rr);
}
public String getValue() {
return null;
}
}

View file

@ -0,0 +1,16 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIDataListChangedRegistersInfo extends MIInfo {
public MIDataListChangedRegistersInfo(MIResultRecord rr) {
super(rr);
}
int [] getRegisters () {
return null;
}
}

View file

@ -0,0 +1,21 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIDataListRegisterValuesInfo extends MIInfo {
public class Register {
int number;
int value;
}
public MIDataListRegisterValuesInfo(MIResultRecord rr) {
super(rr);
}
Register [] getRegistersValues () {
return null;
}
}

View file

@ -0,0 +1,16 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIDataListRegistersNamesInfo extends MIInfo {
public MIDataListRegistersNamesInfo(MIResultRecord rr) {
super(rr);
}
String[] getRegistersNames () {
return null;
}
}

View file

@ -0,0 +1,50 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/**
*/
public class MIDataReadMemoryInfo extends MIInfo {
public class Memory {
int addr;
int [] data;
String ascii;
}
public MIDataReadMemoryInfo(MIResultRecord rr) {
super(rr);
}
int getAddress() {
return 0;
}
int getBytesNumber() {
return 0;
}
int getTotalBytes() {
return 0;
}
int getNextRow() {
return 0;
}
int getPreviousRow() {
return 0;
}
int getNextPage() {
return 0;
}
int getPreviousPage() {
return 0;
}
Memory[] getMemories() {
return null;
}
}

View file

@ -12,17 +12,14 @@ import org.eclipse.core.runtime.IStatus;
/** /**
* *
* A checked exception representing a failure. * A checked exception representing a failure.
* *
* @author Mikhail Khodjaiants
* @since Jul 11, 2002
*/ */
public class MIException extends CoreException public class MIException extends CoreException
{ {
/** /**
* Constructor for MIException. * Constructor for MIException.
*/ */
public MIException( IStatus status ) public MIException(IStatus status) {
{ super(status);
super( status );
} }
} }

View file

@ -1,12 +1,18 @@
package org.eclipse.cdt.debug.mi.core; package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/** /**
* @author alain
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/ */
public class MIInfo { public class MIInfo {
MIResultRecord resultRecord;
public MIInfo(MIResultRecord record) {
resultRecord = record;
}
MIResultRecord getResultRecord () {
return resultRecord;
}
} }

View file

@ -1,5 +1,8 @@
package org.eclipse.cdt.debug.mi.core; package org.eclipse.cdt.debug.mi.core;
import java.io.InputStream;
import java.io.OutputStream;
import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Plugin;
@ -34,7 +37,7 @@ public class MIPlugin extends Plugin {
/** /**
* Create a MI Session. * Create a MI Session.
*/ */
public MISession createSession(Process proc) { public MISession createMISession(InputStream in, OutputStream out) {
return new MISession(proc); return new MISession(in, out);
} }
} }

View file

@ -2,7 +2,7 @@ package org.eclipse.cdt.debug.mi.core;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Writer; import java.io.Reader;
import org.eclipse.cdt.debug.mi.core.output.MIOutput; import org.eclipse.cdt.debug.mi.core.output.MIOutput;
@ -11,54 +11,42 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
*/ */
public class MISession { public class MISession {
Process process; InputStream in;
Writer consoleStreamOutput = null; OutputStream out;
Writer targetStreamOutput = null; Reader consoleStream = null;
Writer logStreamOutput = null; Reader targetStream = null;
Reader logStream = null;
/** /**
* The constructor. * The constructor.
*/ */
MISession(Process proc) { MISession(InputStream i, OutputStream o) {
process = proc; in = i;
out = o;
} }
/** /**
* Set Console Stream. * Set Console Stream.
*/ */
public void setConsoleStreamOutput(Writer consoleOutput) { public void setConsoleStream(Reader console) {
consoleStreamOutput = consoleOutput; consoleStream = console;
} }
/** /**
* Set Target Stream. * Set Target Stream.
*/ */
public void setTargetStreamOutput(Writer targetOutput) { public void setTargetStreamOutput(Reader target) {
targetStreamOutput = targetOutput; targetStream = target;
} }
/** /**
* Set Log Stream * Set Log Stream
*/ */
public void setLogStreamOutput(Writer logOutput) { public void setLogStreamOutput(Reader log) {
logStreamOutput = logOutput; logStream = log;
} }
MIOutput parse(String buffer) { MIOutput parse(String buffer) {
return null; return null;
} }
OutputStream getSessionInputStream() {
if (process != null) {
process.getOutputStream();
}
return null;
}
InputStream getSessionOutputStream() {
if (process != null) {
process.getInputStream();
}
return null;
}
} }

View file

@ -7,7 +7,7 @@
package org.eclipse.cdt.debug.mi.core.command; package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIInfo; import org.eclipse.cdt.debug.mi.core.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIOutput; import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/** /**
* *
@ -31,7 +31,7 @@ public class CLICommand extends Command
return ""; return "";
} }
public MIInfo parse (MIOutput out) { public MIInfo getInfo (MIResultRecord rr) {
return new MIInfo(); return new MIInfo(rr);
} }
} }

View file

@ -7,7 +7,7 @@
package org.eclipse.cdt.debug.mi.core.command; package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIInfo; import org.eclipse.cdt.debug.mi.core.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIOutput; import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/** /**
* *
@ -27,5 +27,5 @@ public abstract class Command
public abstract String toString(); public abstract String toString();
public abstract MIInfo parse(MIOutput out); public abstract MIInfo getInfo(MIResultRecord rr);
} }

View file

@ -50,11 +50,51 @@ package org.eclipse.cdt.debug.mi.core.command;
*/ */
public class MIBreakInsert extends MICommand public class MIBreakInsert extends MICommand
{ {
public MIBreakInsert(String[] params) { public MIBreakInsert(boolean isTemporary, boolean isHardware,
super("-break-insert", params); String condition, int ignoreCount, String line) {
super("-break-insert");
int i = 0;
if (isTemporary || isHardware) {
i++;
}
if (condition != null) {
i += 2;
}
if (ignoreCount > 0) {
i += 2;
}
String[] opts = new String[i];
i = 0;
if (isTemporary) {
opts[i] = "-t";
i++;
} else if (isHardware) {
opts[i] = "-h";
i++;
}
if (condition != null) {
opts[i] = "-c";
i++;
opts[i] = condition;
i++;
}
if (ignoreCount > 0) {
opts[i] = "-i";
i++;
opts[i] = Integer.toString(ignoreCount);
i++;
}
if (opts.length > 0) {
setOptions(opts);
}
setParameters(new String[]{line});
} }
public MIBreakInsert(String[] opts, String[] params) { public MIBreakInsert(String regex) {
super("-break-insert", opts, params); super("-break-insert", new String[]{"-r"}, new String[]{regex});
} }
} }

View file

@ -21,10 +21,17 @@ package org.eclipse.cdt.debug.mi.core.command;
*/ */
public class MIBreakWatch extends MICommand public class MIBreakWatch extends MICommand
{ {
public MIBreakWatch (String[] opts, String expr) { public MIBreakWatch (boolean access, boolean read, String expr) {
super("-break-watch", opts, new String[]{expr}); super("-break-watch");
} String[] opts = null;
public MIBreakWatch (String expr) { if (access) {
super("-break-watch", new String[]{expr}); opts = new String[] {"-a"};
} else if (read) {
opts = new String[] {"-r"};
}
if (opts != null) {
setOptions(opts);
}
setParameters(new String[]{expr});
} }
} }

View file

@ -7,7 +7,7 @@
package org.eclipse.cdt.debug.mi.core.command; package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIInfo; import org.eclipse.cdt.debug.mi.core.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIOutput; import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
/** /**
* *
@ -102,7 +102,7 @@ public class MICommand extends Command
token = t; token = t;
} }
public MIInfo parse (MIOutput out) { public MIInfo getInfo (MIResultRecord rr) {
return new MIInfo(); return new MIInfo(rr);
} }
} }

View file

@ -1,28 +0,0 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIException;
/**
*
* Allows clients to communicate with the debug engine by posting
* MI requests.
*
* @author Mikhail Khodjaiants
* @since Jul 11, 2002
*/
public interface MICommandManager
{
/**
* Posts request to the debug engine.
*
* @param request - the request to post
* @throws MIException if this method fails. Reasons include:
*/
void postRequest (Command request) throws MIException;
}

View file

@ -61,11 +61,24 @@ package org.eclipse.cdt.debug.mi.core.command;
*/ */
public class MIDataDisassemble extends MICommand public class MIDataDisassemble extends MICommand
{ {
public MIDataDisassemble(String[] params) { public MIDataDisassemble(String start, String end, boolean mode) {
super("-data-disassemble", params); super("-data-disassemble");
setOptions(new String[]{"-s", start, "-e", end});
String mixed = "0";
if (mode) {
mixed = "1";
}
setParameters(new String[]{mixed});
} }
public MIDataDisassemble(String[] opts, String[] params) { public MIDataDisassemble(String file, int linenum, int lines, boolean mode) {
super("-data-disassemble", opts, params); super("-data-disassemble");
setOptions(new String[]{"-f", file, "-l",
Integer.toString(linenum), "-n", Integer.toString(lines)});
String mixed = "0";
if (mode) {
mixed = "1";
}
setParameters(new String[]{mixed});
} }
} }

View file

@ -47,11 +47,20 @@ package org.eclipse.cdt.debug.mi.core.command;
public class MIDataReadMemory extends MICommand public class MIDataReadMemory extends MICommand
{ {
public MIDataReadMemory(String[] params) { public MIDataReadMemory (int offset, String address,
super("-data-read-memory", params); String wordFormat, int wordSize,
} int rows, int cols, Character asChar) {
super("-data-read-memory");
public MIDataReadMemory(String[] opts, String[] params) { if (offset != 0) {
super("-data-read-memory", opts, params); setOptions(new String[]{"-o", Integer.toString(offset)});
}
if (asChar != null) {
setParameters(new String[]{wordFormat, Integer.toString(wordSize),
Integer.toString(rows), Integer.toString(cols)});
} else {
setParameters(new String[]{wordFormat, Integer.toString(wordSize),
Integer.toString(rows), Integer.toString(cols),
asChar.toString()});
}
} }
} }

View file

@ -1,28 +0,0 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIException;
/**
*
* Allows clients to communicate with the debug engine by posting
* MI requests.
*
* @author Mikhail Khodjaiants
* @since Jul 11, 2002
*/
public interface MIRequestManager
{
/**
* Posts request to the debug engine.
*
* @param request - the request to post
* @throws MIException if this method fails. Reasons include:
*/
void postRequest (Command request) throws MIException;
}