mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
more work on the parser
This commit is contained in:
parent
f63d52130f
commit
ec210de636
25 changed files with 857 additions and 145 deletions
|
@ -9,6 +9,7 @@ Note this is an interim the document and subject to changes.
|
||||||
****
|
****
|
||||||
This MI implementation is base on GDB/MI 5.2.1.
|
This MI implementation is base on GDB/MI 5.2.1.
|
||||||
|
|
||||||
|
* Command/Response channels
|
||||||
To create an MISession an InputStream and OutputStream are
|
To create an MISession an InputStream and OutputStream are
|
||||||
needed(assuming this the pipe connected to gdb).
|
needed(assuming this the pipe connected to gdb).
|
||||||
MISession MIPlugin.createSession(InputStream, OutputStream);
|
MISession MIPlugin.createSession(InputStream, OutputStream);
|
||||||
|
@ -26,6 +27,57 @@ for a synchronous response(MIResultRecord). Any out-of-band
|
||||||
responses(MIOOBRecord) are dispatch, clients interested in those
|
responses(MIOOBRecord) are dispatch, clients interested in those
|
||||||
notifications should register to MISession.
|
notifications should register to MISession.
|
||||||
|
|
||||||
|
* MI Parsing
|
||||||
|
There is a generic MI parser (MIParser) constructing an Abstract
|
||||||
|
Syntax Tree. For example, a ResultRecord response after a
|
||||||
|
break-insert, the parser will generate this AST:
|
||||||
|
-break-insert main
|
||||||
|
^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 = 0
|
||||||
|
- 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 <==> CDI Adapters
|
MI <==> CDI Adapters
|
||||||
|
|
|
@ -2,7 +2,6 @@ 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.Reader;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
|
@ -13,8 +12,8 @@ import org.eclipse.cdt.debug.mi.core.output.MIParser;
|
||||||
*/
|
*/
|
||||||
public class MISession {
|
public class MISession {
|
||||||
|
|
||||||
InputStream in;
|
InputStream inChannel;
|
||||||
OutputStream out;
|
OutputStream outChannel;
|
||||||
|
|
||||||
Thread txThread;
|
Thread txThread;
|
||||||
Thread rxThread;
|
Thread rxThread;
|
||||||
|
@ -22,9 +21,9 @@ public class MISession {
|
||||||
Queue txQueue;
|
Queue txQueue;
|
||||||
Queue rxQueue;
|
Queue rxQueue;
|
||||||
|
|
||||||
Reader consoleStream = null;
|
OutputStream consoleStream = null;
|
||||||
Reader targetStream = null;
|
OutputStream targetStream = null;
|
||||||
Reader logStream = null;
|
OutputStream logStream = null;
|
||||||
|
|
||||||
CommandFactory factory;
|
CommandFactory factory;
|
||||||
|
|
||||||
|
@ -34,8 +33,8 @@ public class MISession {
|
||||||
* The constructor.
|
* The constructor.
|
||||||
*/
|
*/
|
||||||
MISession(InputStream i, OutputStream o) {
|
MISession(InputStream i, OutputStream o) {
|
||||||
in = i;
|
inChannel = i;
|
||||||
out = o;
|
outChannel= o;
|
||||||
factory = new CommandFactory();
|
factory = new CommandFactory();
|
||||||
parser = new MIParser();
|
parser = new MIParser();
|
||||||
txQueue = new Queue();
|
txQueue = new Queue();
|
||||||
|
@ -49,21 +48,21 @@ public class MISession {
|
||||||
/**
|
/**
|
||||||
* Set Console Stream.
|
* Set Console Stream.
|
||||||
*/
|
*/
|
||||||
public void setConsoleStream(Reader console) {
|
public void setConsoleStream(OutputStream console) {
|
||||||
consoleStream = console;
|
consoleStream = console;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Target Stream.
|
* Set Target Stream.
|
||||||
*/
|
*/
|
||||||
public void setTargetStreamOutput(Reader target) {
|
public void setTargetStreamOutput(OutputStream target) {
|
||||||
targetStream = target;
|
targetStream = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Log Stream
|
* Set Log Stream
|
||||||
*/
|
*/
|
||||||
public void setLogStreamOutput(Reader log) {
|
public void setLogStreamOutput(OutputStream log) {
|
||||||
logStream = log;
|
logStream = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,12 +102,12 @@ public class MISession {
|
||||||
return rxQueue;
|
return rxQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream getInputStream() {
|
InputStream getChannelInputStream() {
|
||||||
return in;
|
return inChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream getOutputStream() {
|
OutputStream getChannelOutputStream() {
|
||||||
return out;
|
return outChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
MIOutput parse(String buffer) {
|
MIOutput parse(String buffer) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class RxThread extends Thread {
|
||||||
*/
|
*/
|
||||||
public void run () {
|
public void run () {
|
||||||
BufferedReader reader =
|
BufferedReader reader =
|
||||||
new BufferedReader(new InputStreamReader(session.getInputStream()));
|
new BufferedReader(new InputStreamReader(session.getChannelInputStream()));
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class TxThread extends Thread {
|
||||||
// - Remove from the TxQueue
|
// - Remove from the TxQueue
|
||||||
// - Move to the RxQueue
|
// - Move to the RxQueue
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
OutputStream out = session.getOutputStream();
|
OutputStream out = session.getChannelOutputStream();
|
||||||
cmd.setToken(token);
|
cmd.setToken(token);
|
||||||
//System.out.println("Tx " + cmd.toString());
|
//System.out.println("Tx " + cmd.toString());
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -32,8 +32,8 @@ public class CommandFactory {
|
||||||
return new MIBreakInsert(isTemporary, isHardware, condition, ignoreCount, line);
|
return new MIBreakInsert(isTemporary, isHardware, condition, ignoreCount, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIBreakInsert createMIBreakInsert(String regex) {
|
public MIBreakInsert createMIBreakInsert(String func) {
|
||||||
return new MIBreakInsert(regex);
|
return new MIBreakInsert(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIBreakList createMIBreakList() {
|
public MIBreakList createMIBreakList() {
|
||||||
|
|
|
@ -50,6 +50,10 @@ package org.eclipse.cdt.debug.mi.core.command;
|
||||||
*/
|
*/
|
||||||
public class MIBreakInsert extends MICommand
|
public class MIBreakInsert extends MICommand
|
||||||
{
|
{
|
||||||
|
public MIBreakInsert(String func) {
|
||||||
|
this(false, false, null, 0, func);
|
||||||
|
}
|
||||||
|
|
||||||
public MIBreakInsert(boolean isTemporary, boolean isHardware,
|
public MIBreakInsert(boolean isTemporary, boolean isHardware,
|
||||||
String condition, int ignoreCount, String line) {
|
String condition, int ignoreCount, String line) {
|
||||||
super("-break-insert");
|
super("-break-insert");
|
||||||
|
@ -93,8 +97,4 @@ public class MIBreakInsert extends MICommand
|
||||||
}
|
}
|
||||||
setParameters(new String[]{line});
|
setParameters(new String[]{line});
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIBreakInsert(String regex) {
|
|
||||||
super("-break-insert", new String[]{"-r"}, new String[]{regex});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,10 @@ public class MICommand extends Command
|
||||||
token = t;
|
token = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MIOutput getMIOutput() {
|
||||||
|
return miOutput;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMIOutput(MIOutput mi) {
|
public void setMIOutput(MIOutput mi) {
|
||||||
miOutput = mi;
|
miOutput = mi;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class MIArg {
|
||||||
|
String name;
|
||||||
|
String value;
|
||||||
|
|
||||||
|
public MIArg(String name, String value) {
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsing a MIList of the form:
|
||||||
|
* [{name="xxx",value="yyy"},{name="xxx",value="yyy"},..]
|
||||||
|
*/
|
||||||
|
public static MIArg[] getMIArgs(MIList miList) {
|
||||||
|
List aList = new ArrayList();
|
||||||
|
MIResult[] results = miList.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
MIArg arg = getMIArg((MITuple)value);
|
||||||
|
if (arg != null) {
|
||||||
|
aList.add(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ((MIArg[])aList.toArray(new MIArg[aList.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsing a MITuple of the form:
|
||||||
|
* {name="xxx",value="yyy"}
|
||||||
|
*/
|
||||||
|
public static MIArg getMIArg(MITuple tuple) {
|
||||||
|
MIResult[] args = tuple.getMIResults();
|
||||||
|
MIArg arg = null;
|
||||||
|
if (args.length == 2) {
|
||||||
|
// Name
|
||||||
|
String aName = "";
|
||||||
|
MIValue value = args[0].getMIValue();
|
||||||
|
if (value != null && value instanceof MIConst) {
|
||||||
|
aName = ((MIConst)value).getString();
|
||||||
|
} else {
|
||||||
|
aName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value
|
||||||
|
String aValue = "";
|
||||||
|
value = args[1].getMIValue();
|
||||||
|
if (value != null && value instanceof MIConst) {
|
||||||
|
aValue = ((MIConst)value).getString();
|
||||||
|
} else {
|
||||||
|
aValue = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
arg = new MIArg(aName, aValue);
|
||||||
|
}
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class MIAsm {
|
||||||
|
long address;
|
||||||
|
String func = "";
|
||||||
|
long offset;
|
||||||
|
String inst = "";
|
||||||
|
int line;
|
||||||
|
String file = "";
|
||||||
|
|
||||||
|
public MIAsm(MITuple tuple) {
|
||||||
|
parse(tuple);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFunction() {
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInstruction() {
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLine() {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse(MITuple tuple) {
|
||||||
|
MIResult[] results = tuple.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
parse((MITuple)value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value != null && value instanceof MIConst) {
|
||||||
|
str = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("address")) {
|
||||||
|
try {
|
||||||
|
address = Long.parseLong(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("func-name")) {
|
||||||
|
func = str;
|
||||||
|
} else if (var.equals("offset")) {
|
||||||
|
try {
|
||||||
|
offset = Long.parseLong(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("inst")) {
|
||||||
|
inst = str;
|
||||||
|
} else if (var.equals("line")) {
|
||||||
|
try {
|
||||||
|
line = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("file")) {
|
||||||
|
file = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ^done,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x08048468",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="4"}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MIBreakHitInfo {
|
||||||
|
|
||||||
|
int bkptno;
|
||||||
|
int threadId;
|
||||||
|
MIFrame frame;
|
||||||
|
String file = "";
|
||||||
|
int line;
|
||||||
|
MIExecAsyncOutput exec;
|
||||||
|
MIResultRecord rr;
|
||||||
|
|
||||||
|
public MIBreakHitInfo(MIExecAsyncOutput record) {
|
||||||
|
exec = record;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIBreakHitInfo(MIResultRecord record) {
|
||||||
|
rr = record;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBreakNumber() {
|
||||||
|
return bkptno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLine() {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse () {
|
||||||
|
MIResult[] results = null;
|
||||||
|
if (exec != null) {
|
||||||
|
results = exec.getMIResults();
|
||||||
|
} else if (rr != null) {
|
||||||
|
results = rr.getMIResults();
|
||||||
|
}
|
||||||
|
if (results != null) {
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
if (value != null && value instanceof MIConst) {
|
||||||
|
str = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("bkptno")) {
|
||||||
|
try {
|
||||||
|
bkptno = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("thread-id")) {
|
||||||
|
try {
|
||||||
|
threadId = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("frame")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
frame = new MIFrame((MITuple)value);
|
||||||
|
}
|
||||||
|
} else if (var.equals("file")) {
|
||||||
|
file = str;
|
||||||
|
} else if (var.equals("line")) {
|
||||||
|
try {
|
||||||
|
line = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -break-insert main
|
||||||
|
* ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08048468",func="main",file="hello.c",line="4",times="0"}
|
||||||
|
*/
|
||||||
|
public class MIBreakInsertInfo extends MIInfo {
|
||||||
|
|
||||||
|
MIBreakPoint[] breakpoints;
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
List aList = new ArrayList(1);
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIResultRecord rr = out.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("bkpt")) {
|
||||||
|
MIValue val = results[i].getMIValue();
|
||||||
|
if (val instanceof MITuple) {
|
||||||
|
aList.add(new MIBreakPoint((MITuple)val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
breakpoints = (MIBreakPoint[])aList.toArray(new MIBreakPoint[aList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIBreakInsertInfo(MIOutput record) {
|
||||||
|
super(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIBreakPoint[] getBreakPoints() {
|
||||||
|
if (breakpoints == null) {
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
return breakpoints;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,26 +1,73 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A -break-list result-record is the form:
|
||||||
|
* <pre>
|
||||||
|
* ^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[..],body=[brkpt={},brkpt={}]}
|
||||||
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class MIBreakListInfo extends MIInfo {
|
public class MIBreakListInfo extends MIInfo {
|
||||||
|
|
||||||
public class BreakPoint {
|
MIBreakPoint[] breakpoints;
|
||||||
int number;
|
|
||||||
String type;
|
|
||||||
String disposition;
|
|
||||||
boolean enabled;
|
|
||||||
int address;
|
|
||||||
String what;
|
|
||||||
int times;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MIBreakListInfo(MIOutput rr) {
|
public MIBreakListInfo(MIOutput rr) {
|
||||||
super(rr);
|
super(rr);
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakPoint[] getBreakPoints() {
|
public MIBreakPoint[] getBreakPoints() {
|
||||||
return null;
|
if (breakpoints == null) {
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
return breakpoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
List aList = new ArrayList(1);
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIResultRecord rr = out.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("BreakpointTable")) {
|
||||||
|
parseTable(results[i].getMIValue(), aList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
breakpoints = (MIBreakPoint[])aList.toArray(new MIBreakPoint[aList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseTable(MIValue val, List aList) {
|
||||||
|
if (val instanceof MITuple) {
|
||||||
|
MIResult[] table = ((MITuple)val).getMIResults();
|
||||||
|
for (int j = 0; j < table.length; j++) {
|
||||||
|
String variable = table[j].getVariable();
|
||||||
|
if (variable.equals("body")) {
|
||||||
|
parseBody(table[j].getMIValue(), aList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseBody(MIValue body, List aList) {
|
||||||
|
if (body instanceof MIList) {
|
||||||
|
MIResult[] bkpts = ((MIList)body).getMIResults();
|
||||||
|
for (int i = 0; i < bkpts.length; i++) {
|
||||||
|
String b = bkpts[i].getVariable();
|
||||||
|
if (b.equals("bkpt")) {
|
||||||
|
MIValue value = bkpts[i].getMIValue();
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
aList.add(new MIBreakPoint((MITuple)value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class MIBreakPoint {
|
||||||
|
|
||||||
|
int number;
|
||||||
|
String type = "";
|
||||||
|
String disp = "";
|
||||||
|
boolean enabled;
|
||||||
|
long address;
|
||||||
|
String func = "";
|
||||||
|
String file = "";
|
||||||
|
int line;
|
||||||
|
int times;
|
||||||
|
String what = "";
|
||||||
|
|
||||||
|
public MIBreakPoint(MITuple tuple) {
|
||||||
|
parse(tuple);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisposition() {
|
||||||
|
return disp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFunction() {
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLine() {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimes() {
|
||||||
|
return times;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWhat() {
|
||||||
|
return what;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse(MITuple tuple) {
|
||||||
|
MIResult[] results = tuple.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
if (value != null && value instanceof MIConst) {
|
||||||
|
str = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("number")) {
|
||||||
|
try {
|
||||||
|
number = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("type")) {
|
||||||
|
type = str;
|
||||||
|
} else if (var.equals("disp")) {
|
||||||
|
disp = str;
|
||||||
|
} else if (var.equals("enabled")) {
|
||||||
|
enabled = str.equals("y");
|
||||||
|
} else if (var.equals("addr")) {
|
||||||
|
try {
|
||||||
|
address = Long.parseLong(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("func")) {
|
||||||
|
func = str;
|
||||||
|
} else if (var.equals("file")) {
|
||||||
|
file = str;
|
||||||
|
} else if (var.equals("line")) {
|
||||||
|
try {
|
||||||
|
line = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("times")) {
|
||||||
|
try {
|
||||||
|
times = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("what") || var.equals("exp")) {
|
||||||
|
what = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +1,50 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* -break-watch buf
|
||||||
|
* ^done,wpt={number="2",exp="buf"}
|
||||||
*/
|
*/
|
||||||
public class MIBreakWatchInfo extends MIInfo {
|
public class MIBreakWatchInfo extends MIInfo {
|
||||||
|
|
||||||
|
MIBreakPoint[] watchpoints = null;
|
||||||
|
|
||||||
public MIBreakWatchInfo(MIOutput rr) {
|
public MIBreakWatchInfo(MIOutput rr) {
|
||||||
super(rr);
|
super(rr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumber () {
|
public MIBreakPoint[] getBreakpoints () {
|
||||||
return 0;
|
if (watchpoints == null) {
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
return watchpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExpression() {
|
|
||||||
return null;
|
void parse() {
|
||||||
|
List aList = new ArrayList(1);
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIResultRecord rr = out.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("wpt")) {
|
||||||
|
MIValue val = results[i].getMIValue();
|
||||||
|
if (val instanceof MITuple) {
|
||||||
|
aList.add(new MIBreakPoint((MITuple)val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
watchpoints = (MIBreakPoint[])aList.toArray(new MIBreakPoint[aList.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class MIBreakpointHitInfo extends MIInfo {
|
|
||||||
|
|
||||||
public MIBreakpointHitInfo(MIOutput 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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class MIBreakpointInfo extends MIInfo {
|
|
||||||
|
|
||||||
public MIBreakpointInfo(MIOutput record) {
|
|
||||||
super(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getBreakNumber() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getFunction() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getAddress() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getFileName() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getLineNumber() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,4 +12,11 @@ public class MIConst extends MIValue {
|
||||||
public void setCString(String str) {
|
public void setCString(String str) {
|
||||||
cstring = str;
|
cstring = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate gdb c-string.
|
||||||
|
*/
|
||||||
|
public String getString() {
|
||||||
|
return cstring;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,68 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class MIDataDisassembleInfo extends MIInfo {
|
public class MIDataDisassembleInfo extends MIInfo {
|
||||||
|
|
||||||
public class ASM {
|
MIAsm[] asms;
|
||||||
int address;
|
|
||||||
String function;
|
|
||||||
int offset;
|
|
||||||
String instruction;
|
|
||||||
int line;
|
|
||||||
String file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MIDataDisassembleInfo(MIOutput rr) {
|
public MIDataDisassembleInfo(MIOutput rr) {
|
||||||
super(rr);
|
super(rr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASM[] getData() {
|
public MIAsm[] getAsm() {
|
||||||
return null;
|
if (asms == null) {
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
return asms;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
List aList = new ArrayList();
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIResultRecord rr = out.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("asm_insns")) {
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (value instanceof MIList) {
|
||||||
|
parse((MIList)value, aList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asms = (MIAsm[])aList.toArray(new MIAsm[aList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse(MIList list, List aList) {
|
||||||
|
// src and assenbly is different
|
||||||
|
MIResult[] results = list.getMIResults();
|
||||||
|
if (results != null && results.length > 0) {
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("src_and_asm_line")) {
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
aList.add(new MIAsm((MITuple)value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MIValue[] values = list.getMIValues();
|
||||||
|
if (values != null && values.length > 0) {
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (values[i] instanceof MITuple) {
|
||||||
|
aList.add(new MIAsm((MITuple)values[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,36 @@ package org.eclipse.cdt.debug.mi.core.output;
|
||||||
*/
|
*/
|
||||||
public class MIDataEvaluateExpressionInfo extends MIInfo{
|
public class MIDataEvaluateExpressionInfo extends MIInfo{
|
||||||
|
|
||||||
|
String expr;
|
||||||
|
|
||||||
public MIDataEvaluateExpressionInfo(MIOutput rr) {
|
public MIDataEvaluateExpressionInfo(MIOutput rr) {
|
||||||
super(rr);
|
super(rr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getExpression() {
|
||||||
return null;
|
if (expr == null) {
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
expr = "";
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIResultRecord rr = out.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("value")) {
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
expr = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,62 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class MIDataListChangedRegistersInfo extends MIInfo {
|
public class MIDataListChangedRegistersInfo extends MIInfo {
|
||||||
|
|
||||||
|
int[] registers;
|
||||||
|
|
||||||
public MIDataListChangedRegistersInfo(MIOutput rr) {
|
public MIDataListChangedRegistersInfo(MIOutput rr) {
|
||||||
super(rr);
|
super(rr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] getRegisters() {
|
int[] getRegisters() {
|
||||||
return null;
|
if (registers == null) {
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
return registers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
List aList = new ArrayList();
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIResultRecord rr = out.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("changed-registers")) {
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (value instanceof MIList) {
|
||||||
|
parseRegisters((MIList)value, aList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
registers = new int[aList.size()];
|
||||||
|
for (int i = 0; i < aList.size(); i++) {
|
||||||
|
String str = (String)aList.get(i);
|
||||||
|
try {
|
||||||
|
registers[i] = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseRegisters(MIList list, List aList) {
|
||||||
|
MIValue[] values = list.getMIValues();
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (values[i] instanceof MIConst) {
|
||||||
|
String str = ((MIConst)values[i]).getString();
|
||||||
|
if (str != null && str.length() > 0) {
|
||||||
|
aList.add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,55 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class MIDataListRegistersNamesInfo extends MIInfo {
|
public class MIDataListRegistersNamesInfo extends MIInfo {
|
||||||
|
|
||||||
|
String[] names;
|
||||||
|
|
||||||
public MIDataListRegistersNamesInfo(MIOutput rr) {
|
public MIDataListRegistersNamesInfo(MIOutput rr) {
|
||||||
super(rr);
|
super(rr);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] getRegistersNames () {
|
String[] getRegistersNames () {
|
||||||
return null;
|
if (names == null) {
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
List aList = new ArrayList();
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIResultRecord rr = out.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("register-names")) {
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (value instanceof MIList) {
|
||||||
|
parseRegisters((MIList)value, aList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names = (String[])aList.toArray(new String[aList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseRegisters(MIList list, List aList) {
|
||||||
|
MIValue[] values = list.getMIValues();
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (values[i] instanceof MIConst) {
|
||||||
|
String str = ((MIConst)values[i]).getString();
|
||||||
|
if (str != null && str.length() > 0) {
|
||||||
|
aList.add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class MIFrame {
|
||||||
|
|
||||||
|
int level;
|
||||||
|
long addr;
|
||||||
|
String func;
|
||||||
|
String file;
|
||||||
|
int line;
|
||||||
|
MIArg[] args = new MIArg[0];
|
||||||
|
|
||||||
|
public MIFrame(MITuple tuple) {
|
||||||
|
parse(tuple);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIArg[] getArgs() {
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFunction() {
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse(MITuple tuple) {
|
||||||
|
MIResult[] results = tuple.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
if (value != null && value instanceof MIConst) {
|
||||||
|
str = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("level")) {
|
||||||
|
try {
|
||||||
|
level = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("addr")) {
|
||||||
|
try {
|
||||||
|
addr = Long.parseLong(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("func")) {
|
||||||
|
func = str;
|
||||||
|
} else if (var.equals("file")) {
|
||||||
|
file = str;
|
||||||
|
} else if (var.equals("line")) {
|
||||||
|
try {
|
||||||
|
line = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("args")) {
|
||||||
|
if (value instanceof MIList) {
|
||||||
|
args = MIArg.getMIArgs((MIList)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,38 @@ public class MIInfo {
|
||||||
miOutput = record;
|
miOutput = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
MIOutput getMIOutput () {
|
public MIOutput getMIOutput () {
|
||||||
return miOutput;
|
return miOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDone() {
|
||||||
|
return isResultClass(MIResultRecord.DONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return isResultClass(MIResultRecord.RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConnected() {
|
||||||
|
return isResultClass(MIResultRecord.CONNECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isError() {
|
||||||
|
return isResultClass(MIResultRecord.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExit() {
|
||||||
|
return isResultClass(MIResultRecord.EXIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isResultClass(String rc) {
|
||||||
|
if (miOutput != null) {
|
||||||
|
MIResultRecord rr = miOutput.getMIResultRecord();
|
||||||
|
if (rr != null) {
|
||||||
|
String clazz = rr.getResultClass();
|
||||||
|
return clazz.equals(rc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class MIParser {
|
||||||
if (buffer.charAt(0) == ',') {
|
if (buffer.charAt(0) == ',') {
|
||||||
String s = buffer.substring(1);
|
String s = buffer.substring(1);
|
||||||
MIResult[] res = processMIResults(s);
|
MIResult[] res = processMIResults(s);
|
||||||
rr.setResults(res);
|
rr.setMIResults(res);
|
||||||
}
|
}
|
||||||
return rr;
|
return rr;
|
||||||
}
|
}
|
||||||
|
@ -304,10 +304,12 @@ public class MIParser {
|
||||||
if (sb.charAt(0) == '"') {
|
if (sb.charAt(0) == '"') {
|
||||||
sb.deleteCharAt(0);
|
sb.deleteCharAt(0);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < sb.length() || termination; i++) {
|
int i = 0;
|
||||||
|
for (i = 0; i < sb.length() || termination; i++) {
|
||||||
switch (sb.charAt(i)) {
|
switch (sb.charAt(i)) {
|
||||||
case '\\':
|
case '\\':
|
||||||
if (escape) {
|
if (escape) {
|
||||||
|
sb.setCharAt(i, '\\');
|
||||||
sb.deleteCharAt(i - 1);
|
sb.deleteCharAt(i - 1);
|
||||||
escape = false;
|
escape = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -315,22 +317,6 @@ public class MIParser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
|
||||||
if (escape) {
|
|
||||||
sb.setCharAt(i, '\n');
|
|
||||||
sb.deleteCharAt(i - 1);
|
|
||||||
escape = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r':
|
|
||||||
if (escape) {
|
|
||||||
sb.setCharAt(i, '\n');
|
|
||||||
sb.deleteCharAt(i - 1);
|
|
||||||
escape = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
if (escape) {
|
if (escape) {
|
||||||
sb.setCharAt(i, '"');
|
sb.setCharAt(i, '"');
|
||||||
|
@ -345,6 +331,6 @@ public class MIParser {
|
||||||
escape = false;
|
escape = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.substring(0, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,14 +33,14 @@ public class MIResultRecord {
|
||||||
resultClass = type;
|
resultClass = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIResult[] getResults() {
|
public MIResult[] getMIResults() {
|
||||||
if (results == null) {
|
if (results == null) {
|
||||||
return nullResults;
|
return nullResults;
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResults(MIResult[] res) {
|
public void setMIResults(MIResult[] res) {
|
||||||
results = res;
|
results = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue