mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
more work on the parser.
This commit is contained in:
parent
ec210de636
commit
fb8ec5c2d4
53 changed files with 1306 additions and 343 deletions
|
@ -6,19 +6,13 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* A checked exception representing a failure.
|
||||
*
|
||||
*/
|
||||
public class MIException extends CoreException {
|
||||
/**
|
||||
* Constructor for MIException.
|
||||
*/
|
||||
public MIException(IStatus status) {
|
||||
super(status);
|
||||
public class MIException extends Exception {
|
||||
public MIException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.eclipse.cdt.debug.mi.core;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.command.Command;
|
||||
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.MIParser;
|
||||
|
@ -32,7 +33,7 @@ public class MISession {
|
|||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
MISession(InputStream i, OutputStream o) {
|
||||
public MISession(InputStream i, OutputStream o) {
|
||||
inChannel = i;
|
||||
outChannel= o;
|
||||
factory = new CommandFactory();
|
||||
|
@ -94,6 +95,20 @@ public class MISession {
|
|||
parser = p;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void postCommand(Command cmd) {
|
||||
txQueue.addCommand(cmd);
|
||||
synchronized (cmd) {
|
||||
try {
|
||||
// FIXME: missing the predicate
|
||||
cmd.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Queue getTxQueue() {
|
||||
return txQueue;
|
||||
}
|
||||
|
|
|
@ -39,11 +39,12 @@ public class RxThread extends Thread {
|
|||
while (true) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.equals("(gdb)")) {
|
||||
if (line.startsWith("(gdb)")) {
|
||||
processMIOutput(buffer.toString());
|
||||
buffer = new StringBuffer();
|
||||
} else {
|
||||
buffer.append(line).append('\n');
|
||||
}
|
||||
buffer.append(line).append('\n');
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -62,8 +63,10 @@ public class RxThread extends Thread {
|
|||
int id = rr.geToken();
|
||||
Command cmd = rxQueue.removeCommand(id);
|
||||
if (cmd != null) {
|
||||
cmd.setMIOutput(response);
|
||||
cmd.notifyAll();
|
||||
synchronized (cmd) {
|
||||
cmd.setMIOutput(response);
|
||||
cmd.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ public class TxThread extends Thread {
|
|||
cmd.setToken(token);
|
||||
//System.out.println("Tx " + cmd.toString());
|
||||
try {
|
||||
out.write(cmd.toString().getBytes());
|
||||
String str = cmd.toString();
|
||||
out.write(str.getBytes());
|
||||
out.flush();
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
|
|
|
@ -12,37 +12,22 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
|||
/**
|
||||
*
|
||||
* Represents a CLI command.
|
||||
*
|
||||
* @author Mikhail Khodjaiants
|
||||
* @since Jul 11, 2002
|
||||
*/
|
||||
public class CLICommand extends Command
|
||||
{
|
||||
int token = -1;
|
||||
MIOutput miOutput = null;
|
||||
|
||||
|
||||
String operation = "";
|
||||
|
||||
public CLICommand(String oper) {
|
||||
operation = oper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text representation of this command.
|
||||
*
|
||||
* @return the text representation of this command
|
||||
*/
|
||||
public int getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(int t) {
|
||||
token = t;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setMIOutput(MIOutput mi) {
|
||||
miOutput = mi;
|
||||
}
|
||||
|
||||
public MIInfo getInfo () {
|
||||
return null;
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
|
@ -18,18 +19,43 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
|||
*/
|
||||
public abstract class Command
|
||||
{
|
||||
int token = 0;
|
||||
MIOutput output;
|
||||
|
||||
/**
|
||||
* Returns the identifier of this request.
|
||||
*
|
||||
* @return the identifier of this request
|
||||
*/
|
||||
public abstract int getToken();
|
||||
public int getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public abstract void setToken(int token);
|
||||
public void setToken(int token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public abstract String toString();
|
||||
public MIOutput getMIOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public abstract void setMIOutput(MIOutput mi);
|
||||
public void setMIOutput(MIOutput mi) {
|
||||
output = mi;
|
||||
}
|
||||
|
||||
public abstract MIInfo getInfo();
|
||||
/**
|
||||
* Parse the MIOutput generate after posting the command.
|
||||
*/
|
||||
public MIInfo getMIInfo () throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIInfo(out);
|
||||
if (info.isError()) {
|
||||
String s = info.getErrorMsg();
|
||||
throw new MIException(s);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -break-after NUMBER COUNT
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakInsertInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -break-insert [ -t ] [ -h ] [ -r ]
|
||||
|
@ -97,4 +102,16 @@ public class MIBreakInsert extends MICommand
|
|||
}
|
||||
setParameters(new String[]{line});
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIBreakInsertInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakListInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -break-list
|
||||
|
@ -44,4 +49,16 @@ public class MIBreakList extends MICommand
|
|||
public MIBreakList () {
|
||||
super("-break-list");
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIBreakListInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakWatchInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -break-watch [ -a | -r ]
|
||||
|
@ -34,4 +39,16 @@ public class MIBreakWatch extends MICommand
|
|||
}
|
||||
setParameters(new String[]{expr});
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIBreakWatchInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,6 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
|||
/**
|
||||
*
|
||||
* Represents a MI command.
|
||||
*
|
||||
* @author Mikhail Khodjaiants
|
||||
* @since Jul 11, 2002
|
||||
*/
|
||||
public class MICommand extends Command
|
||||
{
|
||||
|
@ -22,8 +19,6 @@ public class MICommand extends Command
|
|||
String[] options = empty;
|
||||
String[] parameters = empty;
|
||||
String operation = "";
|
||||
int token = -1;
|
||||
MIOutput miOutput = null;
|
||||
|
||||
public MICommand(String oper) {
|
||||
this.operation = oper;
|
||||
|
@ -78,7 +73,7 @@ public class MICommand extends Command
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
String command = getToken() + "-" + getOperation();
|
||||
String command = getToken() + getOperation();
|
||||
if (options != null && options.length > 0) {
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
command += " " + options[i];
|
||||
|
@ -95,30 +90,10 @@ public class MICommand extends Command
|
|||
parameters[i].indexOf(' ') != -1) {
|
||||
command += " \"" + parameters[i] + "\"";
|
||||
} else {
|
||||
command += " \"" + parameters[i] + "\"";
|
||||
command += " " + parameters[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return command + "\n";
|
||||
}
|
||||
|
||||
public int getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(int t) {
|
||||
token = t;
|
||||
}
|
||||
|
||||
public MIOutput getMIOutput() {
|
||||
return miOutput;
|
||||
}
|
||||
|
||||
public void setMIOutput(MIOutput mi) {
|
||||
miOutput = mi;
|
||||
}
|
||||
|
||||
public MIInfo getInfo () {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataDisassembleInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -data-disassemble
|
||||
|
@ -81,4 +86,16 @@ public class MIDataDisassemble extends MICommand
|
|||
}
|
||||
setParameters(new String[]{mixed});
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIDataDisassembleInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataEvaluateExpressionInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -data-evaluate-expression EXPR
|
||||
|
@ -20,4 +25,16 @@ public class MIDataEvaluateExpression extends MICommand
|
|||
public MIDataEvaluateExpression(String expr) {
|
||||
super("-data-evaluate-expression", new String[]{expr});
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIDataEvaluateExpressionInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataListChangedRegistersInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -data-list-changed-registers
|
||||
|
@ -18,4 +23,16 @@ public class MIDataListChangedRegisters extends MICommand
|
|||
public MIDataListChangedRegisters() {
|
||||
super("-data-list-changed-registers" );
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIDataListChangedRegistersInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataListRegisterNamesInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -data-list-register-names [ ( REGNO )+ ]
|
||||
|
@ -34,4 +39,16 @@ public class MIDataListRegisterNames extends MICommand
|
|||
setParameters(array);
|
||||
}
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIDataListRegisterNamesInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataListRegisterValuesInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -data-list-register-values FMT [ ( REGNO )*]
|
||||
|
@ -68,4 +73,16 @@ public class MIDataListRegisterValues extends MICommand
|
|||
setParameters(array);
|
||||
}
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIDataListRegisterValuesInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataReadMemoryInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -data-read-memory [ -o BYTE-OFFSET ]
|
||||
|
@ -54,13 +59,25 @@ public class MIDataReadMemory extends MICommand
|
|||
if (offset != 0) {
|
||||
setOptions(new String[]{"-o", Integer.toString(offset)});
|
||||
}
|
||||
if (asChar != null) {
|
||||
setParameters(new String[]{wordFormat, Integer.toString(wordSize),
|
||||
if (asChar == null) {
|
||||
setParameters(new String[]{address, wordFormat, Integer.toString(wordSize),
|
||||
Integer.toString(rows), Integer.toString(cols)});
|
||||
} else {
|
||||
setParameters(new String[]{wordFormat, Integer.toString(wordSize),
|
||||
setParameters(new String[]{address, wordFormat, Integer.toString(wordSize),
|
||||
Integer.toString(rows), Integer.toString(cols),
|
||||
asChar.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIDataReadMemoryInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -exec-return
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -exec-step-instruction
|
||||
|
@ -22,4 +26,17 @@ public class MIExecStepInstruction extends MICommand
|
|||
public MIExecStepInstruction() {
|
||||
super("-exec-step-instruction");
|
||||
}
|
||||
/*
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIExecStepInstructionInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIStackInfoDepthInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -stack-info-depth [ MAX-DEPTH ]
|
||||
|
@ -23,4 +28,16 @@ public class MIStackInfoDepth extends MICommand
|
|||
public MIStackInfoDepth(int maxDepth) {
|
||||
super("-stack-info-depth", new String[]{Integer.toString(maxDepth)});
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIStackInfoDepthInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIStackListArgumentsInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -stack-list-arguments SHOW-VALUES
|
||||
|
@ -43,4 +48,16 @@ public class MIStackListArguments extends MICommand
|
|||
params[2] = Integer.toString(high);
|
||||
setParameters(params);
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIStackListArgumentsInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -stack-list-frames [ LOW-FRAME HIGH-FRAME ]
|
||||
|
@ -42,6 +47,19 @@ public class MIStackListFrames extends MICommand
|
|||
}
|
||||
|
||||
public MIStackListFrames(int low, int high) {
|
||||
super("-stack-list-frames", new String[]{Integer.toString(low), Integer.toString(high)});
|
||||
super("-stack-list-frames", new String[]{Integer.toString(low),
|
||||
Integer.toString(high)});
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIStackListFramesInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIStackListLocalsInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -stack-list-locals PRINT-VALUES
|
||||
|
@ -25,4 +30,16 @@ public class MIStackListLocals extends MICommand
|
|||
setParameters(new String[]{"0"});
|
||||
}
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIStackListLocalsInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -stack-select-frame FRAMENUM
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIThreadListIdsInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -thread-list-ids
|
||||
|
@ -19,4 +24,16 @@ public class MIThreadListIds extends MICommand
|
|||
public MIThreadListIds() {
|
||||
super("-thread-list-ids");
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIThreadListIdsInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -thread-select THREADNUM
|
||||
|
@ -19,4 +24,16 @@ public class MIThreadSelect extends MICommand
|
|||
public MIThreadSelect(int threadNum) {
|
||||
super("-thread-select", new String[]{Integer.toString(threadNum)});
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIThreadSelectInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,19 +27,27 @@ public class MIArg {
|
|||
/**
|
||||
* Parsing a MIList of the form:
|
||||
* [{name="xxx",value="yyy"},{name="xxx",value="yyy"},..]
|
||||
* [name="xxx",name="xxx",..]
|
||||
*/
|
||||
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);
|
||||
MIValue[] values = miList.getMIValues();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] instanceof MITuple) {
|
||||
MIArg arg = getMIArg((MITuple)values[i]);
|
||||
if (arg != null) {
|
||||
aList.add(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
MIResult[] results = miList.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIConst) {
|
||||
String str = ((MIConst)value).getString();
|
||||
aList.add(new MIArg(str, ""));
|
||||
}
|
||||
}
|
||||
return ((MIArg[])aList.toArray(new MIArg[aList.size()]));
|
||||
}
|
||||
|
||||
|
@ -73,4 +81,8 @@ public class MIArg {
|
|||
}
|
||||
return arg;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name + "=" + value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,25 @@ public class MIAsm {
|
|||
return file;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (file.length() > 0) {
|
||||
buffer.append("line=\"").append(line);
|
||||
buffer.append("file=\"" + file + "\",");
|
||||
buffer.append("line_asm_insn=[");
|
||||
}
|
||||
buffer.append('{');
|
||||
buffer.append("address=\"" + Long.toHexString(address) +"\"");
|
||||
buffer.append(",func-name=\"" + func + "\"");
|
||||
buffer.append(",offset=\"").append(offset).append('"');
|
||||
buffer.append(",inst=\"" + inst + "\"");
|
||||
buffer.append('}');
|
||||
if (file.length() > 0) {
|
||||
buffer.append(']');
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
void parse(MITuple tuple) {
|
||||
MIResult[] results = tuple.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
|
@ -58,14 +77,14 @@ public class MIAsm {
|
|||
|
||||
if (var.equals("address")) {
|
||||
try {
|
||||
address = Long.parseLong(str);
|
||||
address = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("func-name")) {
|
||||
func = str;
|
||||
} else if (var.equals("offset")) {
|
||||
try {
|
||||
offset = Long.parseLong(str);
|
||||
offset = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("inst")) {
|
||||
|
|
|
@ -8,7 +8,7 @@ public abstract class MIAsyncRecord extends MIOOBRecord {
|
|||
|
||||
MIResult[] results = null;
|
||||
String asynClass = "";
|
||||
int token = -1;
|
||||
int token = 0;
|
||||
|
||||
public int getToken() {
|
||||
return token;
|
||||
|
@ -36,4 +36,27 @@ public abstract class MIAsyncRecord extends MIOOBRecord {
|
|||
public void setMIResults(MIResult[] res) {
|
||||
results = res;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (token != 0) {
|
||||
buffer.append(token);
|
||||
}
|
||||
if (this instanceof MIExecAsyncOutput) {
|
||||
buffer.append('*');
|
||||
} else if (this instanceof MIStatusAsyncOutput) {
|
||||
buffer.append('+');
|
||||
} else if (this instanceof MINotifyAsyncOutput) {
|
||||
buffer.append('=');
|
||||
}
|
||||
buffer.append(asynClass);
|
||||
if (results != null) {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
buffer.append(',');
|
||||
buffer.append(results.toString());
|
||||
}
|
||||
}
|
||||
buffer.append('\n');
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class MIBreakPoint {
|
|||
enabled = str.equals("y");
|
||||
} else if (var.equals("addr")) {
|
||||
try {
|
||||
address = Long.parseLong(str);
|
||||
address = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("func")) {
|
||||
|
|
|
@ -3,5 +3,4 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
/**
|
||||
*/
|
||||
public class MIConsoleStreamOutput extends MIStreamRecord {
|
||||
|
||||
}
|
||||
|
|
|
@ -19,4 +19,8 @@ public class MIConst extends MIValue {
|
|||
public String getString() {
|
||||
return cstring;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class MIDataListRegistersNamesInfo extends MIInfo {
|
||||
public class MIDataListRegisterNamesInfo extends MIInfo {
|
||||
|
||||
String[] names;
|
||||
|
||||
public MIDataListRegistersNamesInfo(MIOutput rr) {
|
||||
public MIDataListRegisterNamesInfo(MIOutput rr) {
|
||||
super(rr);
|
||||
}
|
||||
|
|
@ -6,16 +6,38 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
*/
|
||||
public class MIDataListRegisterValuesInfo extends MIInfo {
|
||||
|
||||
public class Register {
|
||||
int number;
|
||||
int value;
|
||||
}
|
||||
MIRegisterValue[] registers;
|
||||
|
||||
public MIDataListRegisterValuesInfo(MIOutput rr) {
|
||||
super(rr);
|
||||
}
|
||||
|
||||
Register [] getRegistersValues () {
|
||||
return null;
|
||||
MIRegisterValue[] getRegistersValues () {
|
||||
if (registers == null) {
|
||||
parse();
|
||||
}
|
||||
return registers;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
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-values")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIList) {
|
||||
registers = MIRegisterValue.getMIRegisterValues((MIList)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (registers == null) {
|
||||
registers = new MIRegisterValue[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,50 +1,168 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MIDataReadMemoryInfo extends MIInfo {
|
||||
|
||||
public class Memory {
|
||||
int addr;
|
||||
int [] data;
|
||||
String ascii;
|
||||
}
|
||||
|
||||
long addr;
|
||||
long nextRow;
|
||||
long prevRow;
|
||||
long nextPage;
|
||||
long prevPage;
|
||||
long numBytes;
|
||||
long totalBytes;
|
||||
MIMemory[] memories;
|
||||
|
||||
|
||||
public MIDataReadMemoryInfo(MIOutput rr) {
|
||||
super(rr);
|
||||
}
|
||||
|
||||
int getAddress() {
|
||||
return 0;
|
||||
public long getAddress() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
int getBytesNumber() {
|
||||
return 0;
|
||||
public long getNumberBytes() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return numBytes;
|
||||
}
|
||||
|
||||
int getTotalBytes() {
|
||||
return 0;
|
||||
public long getTotalBytes() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return totalBytes;
|
||||
}
|
||||
|
||||
int getNextRow() {
|
||||
return 0;
|
||||
public long getNextRow() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return nextRow;
|
||||
}
|
||||
|
||||
int getPreviousRow() {
|
||||
return 0;
|
||||
public long getPreviousRow() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return prevRow;
|
||||
}
|
||||
|
||||
int getNextPage() {
|
||||
return 0;
|
||||
public long getNextPage() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return nextPage;
|
||||
}
|
||||
|
||||
int getPreviousPage() {
|
||||
return 0;
|
||||
public long getPreviousPage() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return prevPage;
|
||||
}
|
||||
|
||||
Memory[] getMemories() {
|
||||
return null;
|
||||
public MIMemory[] getMemories() {
|
||||
if (memories == null) {
|
||||
parse();
|
||||
}
|
||||
return memories;
|
||||
}
|
||||
/*
|
||||
public String toString() {
|
||||
MIMemory[] mem = getMemories();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for (int i = 0; i < mem.length; i++) {
|
||||
buffer.append(Long.toHexString(mem[i].getAddress()));
|
||||
buffer.append(":");
|
||||
long[] data = mem[i].getData();
|
||||
for (int j = 0; j < data.length; j++) {
|
||||
buffer.append(" ").append(Long.toHexString(data[j]));
|
||||
}
|
||||
buffer.append("\t").append(mem[i].getAscii());
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
*/
|
||||
void parse() {
|
||||
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();
|
||||
MIValue value = results[i].getMIValue();
|
||||
String str = "";
|
||||
if (value != null && value instanceof MIConst) {
|
||||
str = ((MIConst)value).getString();
|
||||
}
|
||||
|
||||
if (var.equals("addr")) {
|
||||
try {
|
||||
addr = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("nr-bytes")) {
|
||||
try {
|
||||
numBytes = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("total-bytes")) {
|
||||
try {
|
||||
totalBytes = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("next-row")) {
|
||||
try {
|
||||
nextRow = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("prev-row")) {
|
||||
try {
|
||||
prevRow = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("next-page")) {
|
||||
try {
|
||||
nextPage = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("prev-page")) {
|
||||
try {
|
||||
prevPage = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("memory")) {
|
||||
if (value instanceof MIList) {
|
||||
parseMemory((MIList)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (memories == null) {
|
||||
memories = new MIMemory[0];
|
||||
}
|
||||
}
|
||||
|
||||
void parseMemory(MIList list) {
|
||||
MIValue[] values = list.getMIValues();
|
||||
memories = new MIMemory[values.length];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] instanceof MITuple) {
|
||||
memories[i] = new MIMemory((MITuple)values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MIFrame {
|
||||
|
@ -29,6 +27,25 @@ public class MIFrame {
|
|||
return level;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("level=\"" + level + "\"");
|
||||
buffer.append(",addr=\"" + Long.toHexString(addr) + "\"");
|
||||
buffer.append(",func=\"" + func + "\"");
|
||||
buffer.append(",file=\"" + file + "\"");
|
||||
buffer.append(",line=\"").append(line).append('"');
|
||||
buffer.append(",args=[");
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (i != 0) {
|
||||
buffer.append(',');
|
||||
}
|
||||
buffer.append("{name=\"" + args[i].getName());
|
||||
buffer.append(",value=\"" + args[i].getValue() + "}");
|
||||
}
|
||||
buffer.append(']');
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
void parse(MITuple tuple) {
|
||||
MIResult[] results = tuple.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
|
@ -46,7 +63,7 @@ public class MIFrame {
|
|||
}
|
||||
} else if (var.equals("addr")) {
|
||||
try {
|
||||
addr = Long.parseLong(str);
|
||||
addr = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("func")) {
|
||||
|
|
|
@ -36,6 +36,13 @@ public class MIInfo {
|
|||
return isResultClass(MIResultRecord.EXIT);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (miOutput != null) {
|
||||
return miOutput.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
boolean isResultClass(String rc) {
|
||||
if (miOutput != null) {
|
||||
MIResultRecord rr = miOutput.getMIResultRecord();
|
||||
|
@ -46,4 +53,24 @@ public class MIInfo {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
if (miOutput != null) {
|
||||
MIResultRecord rr = miOutput.getMIResultRecord();
|
||||
if (rr != null) {
|
||||
MIResult[] results = rr.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
if (var.equals("msg")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIConst) {
|
||||
String s = ((MIConst)value).getString();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,10 @@ public class MIList extends MIValue {
|
|||
final static MIResult[] nullResults = new MIResult[0];
|
||||
final static MIValue[] nullValues = new MIValue[0];
|
||||
|
||||
MIResult[] results;
|
||||
MIValue[] values;
|
||||
MIResult[] results = nullResults;;
|
||||
MIValue[] values = nullValues;
|
||||
|
||||
public MIResult[] getMIResults() {
|
||||
if (results == null) {
|
||||
return nullResults;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -22,13 +19,23 @@ public class MIList extends MIValue {
|
|||
}
|
||||
|
||||
public MIValue[] getMIValues() {
|
||||
if (values == null) {
|
||||
return nullValues;
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setMIValues(MIValue[] vals) {
|
||||
values = vals;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append('[');
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
buffer.append(results[i].toString());
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
buffer.append(values[i].toString());
|
||||
}
|
||||
buffer.append(']');
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MIMemory {
|
||||
long addr;
|
||||
long [] data = new long[0];
|
||||
String ascii = "";
|
||||
|
||||
public MIMemory(MITuple tuple) {
|
||||
parse(tuple);
|
||||
}
|
||||
|
||||
public long getAddress() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public long [] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getAscii() {
|
||||
return ascii;
|
||||
}
|
||||
|
||||
public String toSting() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("addr=\"" + Long.toHexString(addr) + "\"");
|
||||
buffer.append("data=[");
|
||||
for (int i = 0 ; i < data.length; i++) {
|
||||
if (i != 0) {
|
||||
buffer.append(',');
|
||||
}
|
||||
buffer.append('"').append(Long.toHexString(data[i])).append('"');
|
||||
}
|
||||
buffer.append(']');
|
||||
if (ascii.length() > 0) {
|
||||
buffer.append(",ascii=\"" + ascii + "\"");
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
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("addr")) {
|
||||
try {
|
||||
addr = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("data")) {
|
||||
if (value != null && value instanceof MIList) {
|
||||
parseData((MIList)value);
|
||||
}
|
||||
} else if (var.equals("ascii")) {
|
||||
ascii = str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void parseData(MIList list) {
|
||||
MIValue[] values = list.getMIValues();
|
||||
data = new long[values.length];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] instanceof MIConst) {
|
||||
String str = ((MIConst)values[i]).getString();
|
||||
try {
|
||||
data[i] = Long.decode(str).longValue();
|
||||
} catch (NumberFormatException e) {
|
||||
data[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ public class MIOutput {
|
|||
public static final String terminator = "(gdb)";
|
||||
public static final MIOOBRecord[] nullOOBRecord = new MIOOBRecord[0];
|
||||
MIResultRecord rr = null;
|
||||
MIOOBRecord[] oobs = null;
|
||||
MIOOBRecord[] oobs = nullOOBRecord;
|
||||
|
||||
|
||||
public MIResultRecord getMIResultRecord() {
|
||||
|
@ -19,12 +19,22 @@ public class MIOutput {
|
|||
}
|
||||
|
||||
public MIOOBRecord[] getMIOOBRecords() {
|
||||
if (oobs == null)
|
||||
return nullOOBRecord;
|
||||
return oobs;
|
||||
}
|
||||
|
||||
public void setMIOOBRecords(MIOOBRecord [] bands) {
|
||||
oobs = bands;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for (int i = 0; i < oobs.length; i++) {
|
||||
buffer.append(oobs[i].toString());
|
||||
}
|
||||
if (rr != null) {
|
||||
buffer.append(rr.toString());
|
||||
}
|
||||
buffer.append(terminator + "\n");
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,78 +4,77 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
|
||||
/**
|
||||
<pre>
|
||||
`OUTPUT ==>'
|
||||
`OUTPUT :'
|
||||
`( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'
|
||||
|
||||
`RESULT-RECORD ==>'
|
||||
`RESULT-RECORD :'
|
||||
` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'
|
||||
|
||||
`OUT-OF-BAND-RECORD ==>'
|
||||
`OUT-OF-BAND-RECORD :'
|
||||
`ASYNC-RECORD | STREAM-RECORD'
|
||||
|
||||
`ASYNC-RECORD ==>'
|
||||
`ASYNC-RECORD :'
|
||||
`EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'
|
||||
|
||||
`EXEC-ASYNC-OUTPUT ==>'
|
||||
`EXEC-ASYNC-OUTPUT :'
|
||||
`[ TOKEN ] "*" ASYNC-OUTPUT'
|
||||
|
||||
`STATUS-ASYNC-OUTPUT ==>'
|
||||
`STATUS-ASYNC-OUTPUT :'
|
||||
`[ TOKEN ] "+" ASYNC-OUTPUT'
|
||||
|
||||
`NOTIFY-ASYNC-OUTPUT ==>'
|
||||
`NOTIFY-ASYNC-OUTPUT :'
|
||||
`[ TOKEN ] "=" ASYNC-OUTPUT'
|
||||
|
||||
`ASYNC-OUTPUT ==>'
|
||||
`ASYNC-OUTPUT :'
|
||||
`ASYNC-CLASS ( "," RESULT )* NL'
|
||||
|
||||
`RESULT-CLASS ==>'
|
||||
`RESULT-CLASS :'
|
||||
`"done" | "running" | "connected" | "error" | "exit"'
|
||||
|
||||
`ASYNC-CLASS ==>'
|
||||
`ASYNC-CLASS :'
|
||||
`"stopped" | OTHERS' (where OTHERS will be added depending on the
|
||||
needs--this is still in development).
|
||||
|
||||
`RESULT ==>'
|
||||
`RESULT :'
|
||||
` VARIABLE "=" VALUE'
|
||||
|
||||
`VARIABLE ==>'
|
||||
`VARIABLE :'
|
||||
` STRING '
|
||||
|
||||
`VALUE ==>'
|
||||
`VALUE :'
|
||||
` CONST | TUPLE | LIST '
|
||||
|
||||
`CONST ==>'
|
||||
`CONST :'
|
||||
`C-STRING'
|
||||
|
||||
`TUPLE ==>'
|
||||
`TUPLE :'
|
||||
` "{}" | "{" RESULT ( "," RESULT )* "}" '
|
||||
|
||||
`LIST ==>'
|
||||
`LIST :'
|
||||
` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*
|
||||
"]" '
|
||||
|
||||
`STREAM-RECORD ==>'
|
||||
`STREAM-RECORD :'
|
||||
`CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'
|
||||
|
||||
`CONSOLE-STREAM-OUTPUT ==>'
|
||||
`CONSOLE-STREAM-OUTPUT :'
|
||||
`"~" C-STRING'
|
||||
|
||||
`TARGET-STREAM-OUTPUT ==>'
|
||||
`TARGET-STREAM-OUTPUT :'
|
||||
`"@" C-STRING'
|
||||
|
||||
`LOG-STREAM-OUTPUT ==>'
|
||||
`LOG-STREAM-OUTPUT :'
|
||||
`"&" C-STRING'
|
||||
|
||||
`NL ==>'
|
||||
`NL :'
|
||||
`CR | CR-LF'
|
||||
|
||||
`TOKEN ==>'
|
||||
`TOKEN :'
|
||||
_any sequence of digits_.
|
||||
|
||||
`C-STRING ==>'
|
||||
`C-STRING :'
|
||||
`""" SEVEN-BIT-ISO-C-STRING-CONTENT """'
|
||||
</pre>
|
||||
*/
|
||||
|
@ -93,244 +92,291 @@ public class MIParser {
|
|||
MIResultRecord rr = null;
|
||||
List oobs = new ArrayList(1);
|
||||
int id = -1;
|
||||
|
||||
|
||||
StringTokenizer st = new StringTokenizer(buffer, "\n");
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken();
|
||||
StringBuffer token = new StringBuffer(st.nextToken());
|
||||
|
||||
// Fetch the Token/Id
|
||||
if (Character.isDigit(token.charAt(0))) {
|
||||
if (token.length() > 0 && Character.isDigit(token.charAt(0))) {
|
||||
int i = 1;
|
||||
while (Character.isDigit(token.charAt(i)) && i < token.length()) {
|
||||
while (i < token.length() && Character.isDigit(token.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
String numbers = token.substring(i);
|
||||
String numbers = token.substring(0, i);
|
||||
try {
|
||||
id = Integer.parseInt(numbers);
|
||||
} catch(NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
// Consume the token.
|
||||
token = token.substring(i);
|
||||
token.delete(0, i);
|
||||
}
|
||||
|
||||
// Process ResultRecord | Out-Of-Band Records
|
||||
if (token.charAt(0) == '^') {
|
||||
rr = processMIResultRecord(token.substring(1), id);
|
||||
//} else if(token.startsWith(MIOutput.terminator)) {
|
||||
// break;
|
||||
} else {
|
||||
MIOOBRecord band = processMIOOBRecord(token.substring(1), id);
|
||||
if (token.length() > 0) {
|
||||
if (token.charAt(0) == '^') {
|
||||
token.deleteCharAt(0);
|
||||
rr = processMIResultRecord(token, id);
|
||||
//} else if(token.startsWith(MIOutput.terminator)) {
|
||||
// break;
|
||||
} else {
|
||||
MIOOBRecord band = processMIOOBRecord(token, id);
|
||||
if (band != null) {
|
||||
oobs.add(band);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MIOOBRecord[] bands = (MIOOBRecord[])oobs.toArray(new MIOOBRecord[oobs.size()]);
|
||||
MIOOBRecord[] bands =
|
||||
(MIOOBRecord[]) oobs.toArray(new MIOOBRecord[oobs.size()]);
|
||||
mi.setMIOOBRecords(bands);
|
||||
mi.setMIResultRecord(rr);
|
||||
return mi;
|
||||
}
|
||||
|
||||
MIResultRecord processMIResultRecord(String buffer, int id) {
|
||||
/**
|
||||
* Assuming '^' was deleted.
|
||||
*/
|
||||
MIResultRecord processMIResultRecord(StringBuffer buffer, int id) {
|
||||
MIResultRecord rr = new MIResultRecord();
|
||||
rr.setToken(id);
|
||||
if (buffer.startsWith(MIResultRecord.DONE)) {
|
||||
if (buffer.toString().startsWith(MIResultRecord.DONE)) {
|
||||
rr.setResultClass(MIResultRecord.DONE);
|
||||
buffer = buffer.substring(MIResultRecord.DONE.length());
|
||||
} else if (buffer.startsWith(MIResultRecord.ERROR)) {
|
||||
buffer.delete(0, MIResultRecord.DONE.length());
|
||||
} else if (buffer.toString().startsWith(MIResultRecord.ERROR)) {
|
||||
rr.setResultClass(MIResultRecord.ERROR);
|
||||
buffer = buffer.substring(MIResultRecord.ERROR.length());
|
||||
} else if (buffer.startsWith(MIResultRecord.EXIT)) {
|
||||
buffer.delete(0, MIResultRecord.ERROR.length());
|
||||
} else if (buffer.toString().startsWith(MIResultRecord.EXIT)) {
|
||||
rr.setResultClass(MIResultRecord.EXIT);
|
||||
buffer = buffer.substring(MIResultRecord.EXIT.length());
|
||||
} else if (buffer.startsWith(MIResultRecord.RUNNING)) {
|
||||
buffer.delete(0, MIResultRecord.EXIT.length());
|
||||
} else if (buffer.toString().startsWith(MIResultRecord.RUNNING)) {
|
||||
rr.setResultClass(MIResultRecord.RUNNING);
|
||||
buffer = buffer.substring(MIResultRecord.RUNNING.length());
|
||||
} else if (buffer.startsWith(MIResultRecord.CONNECTED)) {
|
||||
buffer.delete(0, MIResultRecord.RUNNING.length());
|
||||
} else if (buffer.toString().startsWith(MIResultRecord.CONNECTED)) {
|
||||
rr.setResultClass(MIResultRecord.CONNECTED);
|
||||
buffer = buffer.substring(MIResultRecord.CONNECTED.length());
|
||||
buffer.delete(0, MIResultRecord.CONNECTED.length());
|
||||
} else {
|
||||
// FIXME:
|
||||
// Error throw an exception?
|
||||
}
|
||||
|
||||
// Results are separated by commas.
|
||||
if (buffer.charAt(0) == ',') {
|
||||
String s = buffer.substring(1);
|
||||
MIResult[] res = processMIResults(s);
|
||||
if (buffer.length() > 0 && buffer.charAt(0) == ',') {
|
||||
buffer.deleteCharAt(0);
|
||||
MIResult[] res = processMIResults(buffer);
|
||||
rr.setMIResults(res);
|
||||
}
|
||||
return rr;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
MIOOBRecord processMIOOBRecord(String buffer, int id) {
|
||||
*/
|
||||
MIOOBRecord processMIOOBRecord(StringBuffer buffer, int id) {
|
||||
MIOOBRecord oob = null;
|
||||
char c = buffer.charAt(0);
|
||||
if (c == '*' || c == '+' || c == '=') {
|
||||
// Consume the first char
|
||||
buffer.deleteCharAt(0);
|
||||
MIAsyncRecord async = null;
|
||||
switch (c) {
|
||||
case '*':
|
||||
case '*' :
|
||||
async = new MIExecAsyncOutput();
|
||||
break;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
case '+' :
|
||||
async = new MIStatusAsyncOutput();
|
||||
break;
|
||||
break;
|
||||
|
||||
case '=':
|
||||
case '=' :
|
||||
async = new MINotifyAsyncOutput();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
async.setToken(id);
|
||||
// Extract the Async-Class
|
||||
int i = buffer.indexOf(',');
|
||||
int i = buffer.toString().indexOf(',');
|
||||
if (i != -1) {
|
||||
String asyncClass = buffer.substring(1, i);
|
||||
String asyncClass = buffer.substring(0, i);
|
||||
async.setAsyncClass(asyncClass);
|
||||
// Consume the async-class and the comma
|
||||
buffer = buffer.substring(i + 1);
|
||||
buffer.delete(0, i + 1);
|
||||
}
|
||||
MIResult[] res = processMIResults(buffer);
|
||||
async.setMIResults(res);
|
||||
oob = async;
|
||||
} else if (c == '~' || c == '@' || c == '&') {
|
||||
// Consume the first char
|
||||
buffer.deleteCharAt(0);
|
||||
MIStreamRecord stream = null;
|
||||
switch (c) {
|
||||
case '~':
|
||||
case '~' :
|
||||
stream = new MIConsoleStreamOutput();
|
||||
break;
|
||||
break;
|
||||
|
||||
case '@':
|
||||
case '@' :
|
||||
stream = new MITargetStreamOutput();
|
||||
break;
|
||||
break;
|
||||
|
||||
case '&':
|
||||
case '&' :
|
||||
stream = new MILogStreamOutput();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
stream.setCString(translateCString(buffer.substring(1)));
|
||||
stream.setCString(translateCString(buffer));
|
||||
oob = stream;
|
||||
}
|
||||
return oob;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assuming that the usual leading comma was consume.
|
||||
*/
|
||||
MIResult[] processMIResults(String buffer) {
|
||||
MIResult[] processMIResults(StringBuffer buffer) {
|
||||
List aList = new ArrayList();
|
||||
StringBuffer sb = new StringBuffer(buffer);
|
||||
MIResult result = processMIResult(sb);
|
||||
MIResult result = processMIResult(buffer);
|
||||
if (result != null) {
|
||||
aList.add(result);
|
||||
}
|
||||
while (sb.length() > 0 && sb.charAt(0) == ',') {
|
||||
sb.deleteCharAt(0);
|
||||
result = processMIResult(sb);
|
||||
while (buffer.length() > 0 && buffer.charAt(0) == ',') {
|
||||
buffer.deleteCharAt(0);
|
||||
result = processMIResult(buffer);
|
||||
if (result != null) {
|
||||
aList.add(result);
|
||||
}
|
||||
}
|
||||
return (MIResult[])aList.toArray(new MIResult[aList.size()]);
|
||||
return (MIResult[]) aList.toArray(new MIResult[aList.size()]);
|
||||
}
|
||||
|
||||
MIResult processMIResult(StringBuffer sb) {
|
||||
/**
|
||||
* Construct the MIResult. Characters will be consume/delete
|
||||
* has moving forward constructing the AST.
|
||||
*/
|
||||
MIResult processMIResult(StringBuffer buffer) {
|
||||
MIResult result = new MIResult();
|
||||
String buffer = sb.toString();
|
||||
int equal;
|
||||
if (Character.isLetter(buffer.charAt(0)) &&
|
||||
(equal = buffer.indexOf('=')) != -1) {
|
||||
if (buffer.length() > 0 && Character.isLetter(buffer.charAt(0))
|
||||
&& (equal = buffer.toString().indexOf('=')) != -1) {
|
||||
String variable = buffer.substring(0, equal);
|
||||
result.setVariable(variable);
|
||||
sb.delete(0, equal + 1);
|
||||
MIValue value = processMIValue(sb);
|
||||
buffer.delete(0, equal + 1);
|
||||
MIValue value = processMIValue(buffer);
|
||||
result.setMIValue(value);
|
||||
} else {
|
||||
result.setVariable(buffer);
|
||||
sb.setLength(0);
|
||||
result.setVariable(buffer.toString());
|
||||
buffer.setLength(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
MIValue processMIValue(StringBuffer sb) {
|
||||
/**
|
||||
* Find a MIValue implementation or return null.
|
||||
*/
|
||||
MIValue processMIValue(StringBuffer buffer) {
|
||||
MIValue value = null;
|
||||
if (sb.charAt(0) == '{') {
|
||||
sb.deleteCharAt(0);
|
||||
value = processMITuple(sb);
|
||||
} else if (sb.charAt(0) == '[') {
|
||||
sb.deleteCharAt(0);
|
||||
value = processMIList(sb);
|
||||
} else if (sb.charAt(0) == '"') {
|
||||
MIConst cnst = new MIConst();
|
||||
cnst.setCString(translateCString(sb));
|
||||
value = cnst;
|
||||
if (buffer.length() > 0) {
|
||||
if (buffer.charAt(0) == '{') {
|
||||
buffer.deleteCharAt(0);
|
||||
value = processMITuple(buffer);
|
||||
} else if (buffer.charAt(0) == '[') {
|
||||
buffer.deleteCharAt(0);
|
||||
value = processMIList(buffer);
|
||||
} else if (buffer.charAt(0) == '"') {
|
||||
buffer.deleteCharAt(0);
|
||||
MIConst cnst = new MIConst();
|
||||
cnst.setCString(translateCString(buffer));
|
||||
value = cnst;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
MIValue processMITuple(StringBuffer sb) {
|
||||
|
||||
/**
|
||||
* Assuming the starting '{' was deleted form the StringBuffer,
|
||||
* go to the closing '}' consuming/deleting all the characters.
|
||||
* This is usually call by processMIvalue();
|
||||
*/
|
||||
MIValue processMITuple(StringBuffer buffer) {
|
||||
MITuple tuple = new MITuple();
|
||||
List aList = new ArrayList(1);
|
||||
MIResult[] results = null;
|
||||
// Catch closing '}'
|
||||
while (sb.length() > 0 && sb.charAt(0) != '}') {
|
||||
MIResult res = processMIResult(sb);
|
||||
if (res != null) {
|
||||
aList.add(res);
|
||||
}
|
||||
while (buffer.length() > 0 && buffer.charAt(0) != '}') {
|
||||
results = processMIResults(buffer);
|
||||
}
|
||||
if (buffer.length() > 0 && buffer.charAt(0) == '}') {
|
||||
buffer.deleteCharAt(0);
|
||||
}
|
||||
if (results == null) {
|
||||
results = new MIResult[0];
|
||||
}
|
||||
MIResult[] results = (MIResult[])aList.toArray(new MIResult[aList.size()]);
|
||||
tuple.setMIResults(results);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
MIValue processMIList(StringBuffer sb) {
|
||||
|
||||
/**
|
||||
* Assuming the leading '[' was deleted, find the closing
|
||||
* ']' consuming/delete chars from the StringBuffer.
|
||||
*/
|
||||
MIValue processMIList(StringBuffer buffer) {
|
||||
MIList list = new MIList();
|
||||
List valueList = new ArrayList();
|
||||
List resultList = new ArrayList();
|
||||
// catch closing ']'
|
||||
return new MIList();
|
||||
}
|
||||
|
||||
String translateCString(String str) {
|
||||
return translateCString(new StringBuffer(str));
|
||||
}
|
||||
|
||||
// FIXME: TODO
|
||||
// FIXME: Side effect in the loop
|
||||
// FIXME: Deal with <repeat>
|
||||
String translateCString(StringBuffer sb) {
|
||||
boolean escape = false;
|
||||
boolean termination = false;
|
||||
if (sb.charAt(0) == '"') {
|
||||
sb.deleteCharAt(0);
|
||||
}
|
||||
int i = 0;
|
||||
for (i = 0; i < sb.length() || termination; i++) {
|
||||
switch (sb.charAt(i)) {
|
||||
case '\\':
|
||||
if (escape) {
|
||||
sb.setCharAt(i, '\\');
|
||||
sb.deleteCharAt(i - 1);
|
||||
escape = false;
|
||||
} else {
|
||||
escape = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (escape) {
|
||||
sb.setCharAt(i, '"');
|
||||
sb.deleteCharAt(i - 1);
|
||||
escape = false;
|
||||
} else {
|
||||
termination = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
escape = false;
|
||||
while (buffer.length() > 0 && buffer.charAt(0) != ']') {
|
||||
// Try for the MIValue first
|
||||
MIValue value = processMIValue(buffer);
|
||||
if (value != null) {
|
||||
valueList.add(value);
|
||||
} else {
|
||||
MIResult result = processMIResult(buffer);
|
||||
if (result != null) {
|
||||
resultList.add(result);
|
||||
}
|
||||
}
|
||||
if (buffer.length() > 0 && buffer.charAt(0) == ',') {
|
||||
buffer.deleteCharAt(0);
|
||||
}
|
||||
}
|
||||
return sb.substring(0, i);
|
||||
if (buffer.length() > 0 && buffer.charAt(0) == ']') {
|
||||
buffer.deleteCharAt(0);
|
||||
}
|
||||
MIValue[] values = (MIValue[])valueList.toArray(new MIValue[valueList.size()]);
|
||||
MIResult[] res = (MIResult[])resultList.toArray(new MIResult[resultList.size()]);
|
||||
list.setMIValues(values);
|
||||
list.setMIResults(res);
|
||||
return list;
|
||||
}
|
||||
|
||||
String translateCString(StringBuffer buffer) {
|
||||
boolean escape = false;
|
||||
boolean closingQuotes = false;
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
int index = 0;
|
||||
for (; index < buffer.length() && !closingQuotes; index++) {
|
||||
char c = buffer.charAt(index);
|
||||
if (c == '\\') {
|
||||
if (escape) {
|
||||
sb.append('\\').append(c);
|
||||
escape = false;
|
||||
} else {
|
||||
escape = true;
|
||||
}
|
||||
} else if (c == '"') {
|
||||
if (escape) {
|
||||
sb.append('\\').append(c);;
|
||||
escape = false;
|
||||
} else {
|
||||
// Bail out.
|
||||
closingQuotes = true;
|
||||
}
|
||||
} else {
|
||||
if (escape) {
|
||||
sb.append('\\');
|
||||
}
|
||||
sb.append(c);
|
||||
escape = false;
|
||||
}
|
||||
}
|
||||
buffer.delete(0, index);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MIRegisterValue {
|
||||
int name;
|
||||
long value;
|
||||
|
||||
public MIRegisterValue(int number, long value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("number=\"").append(name).append('"');
|
||||
buffer.append(',').append("value=\"" + Long.toHexString(value) + "\"");
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsing a MIList of the form:
|
||||
* [{number="1",value="0xffff"},{number="xxx",value="yyy"},..]
|
||||
*/
|
||||
public static MIRegisterValue[] getMIRegisterValues(MIList miList) {
|
||||
List aList = new ArrayList();
|
||||
MIValue[] values = miList.getMIValues();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] instanceof MITuple) {
|
||||
MIRegisterValue reg = getMIRegisterValue((MITuple)values[i]);
|
||||
if (reg != null) {
|
||||
aList.add(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ((MIRegisterValue[])aList.toArray(new MIRegisterValue[aList.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsing a MITuple of the form:
|
||||
* {number="xxx",value="yyy"}
|
||||
*/
|
||||
public static MIRegisterValue getMIRegisterValue(MITuple tuple) {
|
||||
MIResult[] args = tuple.getMIResults();
|
||||
MIRegisterValue 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 = "";
|
||||
}
|
||||
|
||||
try {
|
||||
int reg = Integer.parseInt(aName);
|
||||
long val = Long.decode(aValue).longValue();
|
||||
arg = new MIRegisterValue(reg, val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
}
|
|
@ -21,4 +21,11 @@ public class MIResult {
|
|||
public void setMIValue(MIValue val) {
|
||||
value = val;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (value != null) {
|
||||
return variable + "=" + value.toString();
|
||||
}
|
||||
return variable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public class MIResultRecord {
|
|||
public final static String EXIT ="exit";
|
||||
|
||||
static final MIResult[] nullResults = new MIResult[0];
|
||||
MIResult[] results = null;
|
||||
MIResult[] results = nullResults;
|
||||
String resultClass = "";
|
||||
int token = -1;
|
||||
|
||||
|
@ -34,13 +34,19 @@ public class MIResultRecord {
|
|||
}
|
||||
|
||||
public MIResult[] getMIResults() {
|
||||
if (results == null) {
|
||||
return nullResults;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setMIResults(MIResult[] res) {
|
||||
results = res;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(token).append('^').append(resultClass);
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
buffer.append(',').append(results[i].toString());
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,37 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
*/
|
||||
public class MIStackInfoDepthInfo extends MIInfo {
|
||||
|
||||
int depth;
|
||||
|
||||
public MIStackInfoDepthInfo(MIOutput out) {
|
||||
super(out);
|
||||
parse();
|
||||
}
|
||||
|
||||
public int getDepth() {
|
||||
return 0;
|
||||
return depth;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
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("depth")) {
|
||||
MIValue val = results[i].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
String str = ((MIConst)val).getString();
|
||||
try {
|
||||
depth = Integer.parseInt(str);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,58 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MIStackListArgumentsInfo extends MIInfo {
|
||||
|
||||
public class Frame {
|
||||
public class Args {
|
||||
String name;
|
||||
String value;
|
||||
}
|
||||
int level;
|
||||
Args[] args;
|
||||
}
|
||||
MIFrame[] frames;
|
||||
|
||||
public MIStackListArgumentsInfo(MIOutput out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
public Frame[] getFrames() {
|
||||
return null;
|
||||
public MIFrame[] getFrames() {
|
||||
if (frames == null) {
|
||||
parse();
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
|
||||
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("stack-args")) {
|
||||
MIValue val = results[i].getMIValue();
|
||||
if (val instanceof MIList) {
|
||||
parseStack((MIList)val, aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
frames = (MIFrame[])aList.toArray(new MIFrame[aList.size()]);
|
||||
}
|
||||
|
||||
void parseStack(MIList miList, List aList) {
|
||||
MIResult[] results = miList.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
if (var.equals("frame")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MITuple) {
|
||||
aList.add (new MIFrame((MITuple)value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,58 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MIStackListFramesInfo extends MIInfo {
|
||||
|
||||
public class Frame {
|
||||
int level;
|
||||
int addr;
|
||||
String function;
|
||||
String file;
|
||||
int line;
|
||||
}
|
||||
MIFrame[] frames;
|
||||
|
||||
public MIStackListFramesInfo(MIOutput out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
public Frame[] getFrames() {
|
||||
public MIFrame[] getFrames() {
|
||||
if (frames == null) {
|
||||
parse();
|
||||
}
|
||||
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("stack")) {
|
||||
MIValue val = results[i].getMIValue();
|
||||
if (val instanceof MIList) {
|
||||
parseStack((MIList)val, aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
frames = (MIFrame[])aList.toArray(new MIFrame[aList.size()]);
|
||||
}
|
||||
|
||||
void parseStack(MIList miList, List aList) {
|
||||
MIResult[] results = miList.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
if (var.equals("frame")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MITuple) {
|
||||
aList.add (new MIFrame((MITuple)value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,39 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
*/
|
||||
public class MIStackListLocalsInfo extends MIInfo {
|
||||
|
||||
public class Local {
|
||||
String name;
|
||||
String value;
|
||||
}
|
||||
MIArg[] locals;
|
||||
|
||||
public MIStackListLocalsInfo(MIOutput out) {
|
||||
super(out);
|
||||
parse();
|
||||
}
|
||||
|
||||
public Local[] getLocals() {
|
||||
return null;
|
||||
public MIArg[] getLocals() {
|
||||
if (locals == null) {
|
||||
parse();
|
||||
}
|
||||
return locals;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
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("locals")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIList) {
|
||||
locals = MIArg.getMIArgs((MIList)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (locals == null) {
|
||||
locals = new MIArg[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,15 @@ public abstract class MIStreamRecord extends MIOOBRecord {
|
|||
public void setCString(String str) {
|
||||
cstring = str;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (this instanceof MIConsoleStreamOutput) {
|
||||
return "~\"" + cstring + "\"\n";
|
||||
} else if (this instanceof MITargetStreamOutput) {
|
||||
return "@\"" + cstring + "\"\n";
|
||||
} else if (this instanceof MILogStreamOutput) {
|
||||
return "&\"" + cstring + "\"\n";
|
||||
}
|
||||
return "\"" + cstring + "\"\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,59 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MIThreadListIdsInfo extends MIInfo {
|
||||
|
||||
int[] threadIds;
|
||||
|
||||
public MIThreadListIdsInfo(MIOutput out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
public String[] getThreadIds() {
|
||||
return null;
|
||||
public int[] getThreadIds() {
|
||||
if (threadIds == null) {
|
||||
parse();
|
||||
}
|
||||
return threadIds;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
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("thread-ids")) {
|
||||
MIValue val = results[i].getMIValue();
|
||||
if (val instanceof MITuple) {
|
||||
parseThreadIds((MITuple)val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (threadIds == null) {
|
||||
threadIds = new int[0];
|
||||
}
|
||||
}
|
||||
|
||||
void parseThreadIds(MITuple tuple) {
|
||||
MIResult[] results = tuple.getMIResults();
|
||||
threadIds = new int[results.length];
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
if (var.equals("thread-id")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIConst) {
|
||||
String str = ((MIConst)value).getString();
|
||||
try {
|
||||
threadIds[i] = Integer.parseInt(str);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,26 +6,52 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
*/
|
||||
public class MIThreadSelectInfo extends MIInfo {
|
||||
|
||||
public class Frame {
|
||||
public class Arg {
|
||||
String name;
|
||||
String value;
|
||||
}
|
||||
int level;
|
||||
String function;
|
||||
Arg[] args;
|
||||
}
|
||||
|
||||
|
||||
int threadId;
|
||||
MIFrame frame;
|
||||
|
||||
public MIThreadSelectInfo(MIOutput out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
public String getNewThreadId() {
|
||||
return "";
|
||||
public int getNewThreadId() {
|
||||
if (frame == null) {
|
||||
parse();
|
||||
}
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public Frame getFrame() {
|
||||
return null;
|
||||
public MIFrame getFrame() {
|
||||
if (frame == null) {
|
||||
parse();
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
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("new-thread-ids")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIConst) {
|
||||
String str = ((MIConst)value).getString();
|
||||
try {
|
||||
threadId = Integer.parseInt(str);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
} else if (var.equals("frame")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MITuple) {
|
||||
frame = new MIFrame((MITuple)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,26 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
public class MITuple extends MIValue {
|
||||
|
||||
final static MIResult[] nullResults = new MIResult[0];
|
||||
MIResult[] results = null;
|
||||
MIResult[] results = nullResults;
|
||||
|
||||
public MIResult[] getMIResults() {
|
||||
if (results == null) {
|
||||
return nullResults;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setMIResults(MIResult[] res) {
|
||||
results = res;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append('{');
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
if (i != 0) {
|
||||
buffer.append(',');
|
||||
}
|
||||
buffer.append(results[i].toString());
|
||||
}
|
||||
buffer.append('}');
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
/**
|
||||
* @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 MIVariable {
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue