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