1. renamed DebugResponseStack to DebugResponseVariables
2. added getGlobal to DebugStackState for supporting the Globals view 3. converted tabs to 4 whitespaces in some files
This commit is contained in:
@@ -43,7 +43,7 @@ import lua.debug.request.DebugRequestType;
|
|||||||
import lua.debug.response.DebugResponse;
|
import lua.debug.response.DebugResponse;
|
||||||
import lua.debug.response.DebugResponseCallgraph;
|
import lua.debug.response.DebugResponseCallgraph;
|
||||||
import lua.debug.response.DebugResponseSimple;
|
import lua.debug.response.DebugResponseSimple;
|
||||||
import lua.debug.response.DebugResponseStack;
|
import lua.debug.response.DebugResponseVariables;
|
||||||
import lua.io.LocVars;
|
import lua.io.LocVars;
|
||||||
import lua.io.Proto;
|
import lua.io.Proto;
|
||||||
import lua.value.LTable;
|
import lua.value.LTable;
|
||||||
@@ -328,7 +328,9 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
|||||||
} else if (DebugRequestType.stack == requestType) {
|
} else if (DebugRequestType.stack == requestType) {
|
||||||
DebugRequestStack stackRequest = (DebugRequestStack) request;
|
DebugRequestStack stackRequest = (DebugRequestStack) request;
|
||||||
int index = stackRequest.getIndex();
|
int index = stackRequest.getIndex();
|
||||||
return new DebugResponseStack(getStack(index));
|
return new DebugResponseVariables(getStack(index));
|
||||||
|
} else if (DebugRequestType.global == requestType) {
|
||||||
|
return new DebugResponseVariables(getGlobals());
|
||||||
} else if (DebugRequestType.stepInto == requestType) {
|
} else if (DebugRequestType.stepInto == requestType) {
|
||||||
DebugEvent event = new DebugEvent(
|
DebugEvent event = new DebugEvent(
|
||||||
DebugEventType.resumedOnSteppingInto);
|
DebugEventType.resumedOnSteppingInto);
|
||||||
@@ -485,6 +487,26 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the visible globals to the current VM.
|
||||||
|
* @return the visible globals.
|
||||||
|
*/
|
||||||
|
public Variable[] getGlobals() {
|
||||||
|
Vector variables = new Vector();
|
||||||
|
variables.addElement(
|
||||||
|
new TableVariable(0,
|
||||||
|
"*Globals*",
|
||||||
|
Lua.LUA_TTABLE,
|
||||||
|
(LTable) _G));
|
||||||
|
|
||||||
|
Variable[] result = new Variable[variables.size()];
|
||||||
|
for (int i = 0; i < variables.size(); i++) {
|
||||||
|
result[i] = (Variable) variables.elementAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void dumpStack(int index) {
|
private void dumpStack(int index) {
|
||||||
CallInfo callInfo = calls[index];
|
CallInfo callInfo = calls[index];
|
||||||
LocVars[] localVariables = callInfo.closure.p.locvars;
|
LocVars[] localVariables = callInfo.closure.p.locvars;
|
||||||
|
|||||||
@@ -16,160 +16,164 @@ import lua.debug.request.DebugRequestStack;
|
|||||||
import lua.debug.request.DebugRequestType;
|
import lua.debug.request.DebugRequestType;
|
||||||
import lua.debug.response.DebugResponseCallgraph;
|
import lua.debug.response.DebugResponseCallgraph;
|
||||||
import lua.debug.response.DebugResponseSimple;
|
import lua.debug.response.DebugResponseSimple;
|
||||||
import lua.debug.response.DebugResponseStack;
|
import lua.debug.response.DebugResponseVariables;
|
||||||
|
|
||||||
public class SerializationHelper {
|
public class SerializationHelper {
|
||||||
|
|
||||||
public static byte[] serialize(Serializable object) throws IOException {
|
public static byte[] serialize(Serializable object) throws IOException {
|
||||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||||
DataOutputStream dout = new DataOutputStream(bout);
|
DataOutputStream dout = new DataOutputStream(bout);
|
||||||
|
|
||||||
serialize(object, dout);
|
serialize(object, dout);
|
||||||
|
|
||||||
byte[] data = bout.toByteArray();
|
byte[] data = bout.toByteArray();
|
||||||
|
|
||||||
bout.close();
|
bout.close();
|
||||||
dout.close();
|
dout.close();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Serializable deserialize(byte[] data) throws IOException {
|
public static Serializable deserialize(byte[] data) throws IOException {
|
||||||
ByteArrayInputStream bin = new ByteArrayInputStream(data);
|
ByteArrayInputStream bin = new ByteArrayInputStream(data);
|
||||||
DataInputStream din = new DataInputStream(bin);
|
DataInputStream din = new DataInputStream(bin);
|
||||||
|
|
||||||
Serializable object = deserialize(din);
|
Serializable object = deserialize(din);
|
||||||
|
|
||||||
bin.close();
|
bin.close();
|
||||||
din.close();
|
din.close();
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static final int SERIAL_TYPE_NullableString = 0;
|
static final int SERIAL_TYPE_NullableString = 0;
|
||||||
static final int SERIAL_TYPE_TableVariable = 1;
|
static final int SERIAL_TYPE_TableVariable = 1;
|
||||||
static final int SERIAL_TYPE_Variable = 2;
|
static final int SERIAL_TYPE_Variable = 2;
|
||||||
static final int SERIAL_TYPE_DebugResponseCallgraph = 3;
|
static final int SERIAL_TYPE_DebugResponseCallgraph = 3;
|
||||||
static final int SERIAL_TYPE_DebugResponseStack = 4;
|
static final int SERIAL_TYPE_DebugResponseVariables = 4;
|
||||||
static final int SERIAL_TYPE_DebugResponseSimple = 5;
|
static final int SERIAL_TYPE_DebugResponseSimple = 5;
|
||||||
static final int SERIAL_TYPE_StackFrame = 6;
|
static final int SERIAL_TYPE_StackFrame = 6;
|
||||||
static final int SERIAL_TYPE_DebugRequestType = 7;
|
static final int SERIAL_TYPE_DebugRequestType = 7;
|
||||||
static final int SERIAL_TYPE_DebugRequest = 8;
|
static final int SERIAL_TYPE_DebugRequest = 8;
|
||||||
static final int SERIAL_TYPE_DebugRequestStack = 9;
|
static final int SERIAL_TYPE_DebugRequestStack = 9;
|
||||||
static final int SERIAL_TYPE_DebugRequestLineBreakpointToggle = 10;
|
static final int SERIAL_TYPE_DebugRequestLineBreakpointToggle = 10;
|
||||||
static final int SERIAL_TYPE_DebugEventType = 11;
|
static final int SERIAL_TYPE_DebugEventType = 11;
|
||||||
static final int SERIAL_TYPE_DebugEvent = 12;
|
static final int SERIAL_TYPE_DebugEvent = 12;
|
||||||
static final int SERIAL_TYPE_DebugEventBreakpoint = 13;
|
static final int SERIAL_TYPE_DebugEventBreakpoint = 13;
|
||||||
static final int SERIAL_TYPE_DebugEventError = 14;
|
static final int SERIAL_TYPE_DebugEventError = 14;
|
||||||
|
|
||||||
public static void serialize(Serializable object, DataOutputStream dout)
|
|
||||||
throws IOException {
|
|
||||||
if (object instanceof NullableString) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_NullableString);
|
|
||||||
NullableString.serialize(dout, (NullableString)object);
|
|
||||||
} else if (object instanceof TableVariable) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_TableVariable);
|
|
||||||
TableVariable.serialize(dout, (TableVariable)object);
|
|
||||||
} else if (object instanceof Variable) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_Variable);
|
|
||||||
Variable.serialize(dout, (Variable)object);
|
|
||||||
} else if (object instanceof StackFrame) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_StackFrame);
|
|
||||||
StackFrame.serialize(dout, (StackFrame)object);
|
|
||||||
} else if (object instanceof DebugResponseSimple) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugResponseSimple);
|
|
||||||
DebugResponseSimple.serialize(dout, (DebugResponseSimple)object);
|
|
||||||
} else if (object instanceof DebugResponseStack) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugResponseStack);
|
|
||||||
DebugResponseStack.serialize(dout, (DebugResponseStack)object);
|
|
||||||
} else if (object instanceof DebugResponseCallgraph) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugResponseCallgraph);
|
|
||||||
DebugResponseCallgraph.serialize(dout, (DebugResponseCallgraph)object);
|
|
||||||
} else if (object instanceof DebugRequestType) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugRequestType);
|
|
||||||
DebugRequestType.serialize(dout, (DebugRequestType)object);
|
|
||||||
} else if (object instanceof DebugRequestStack) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugRequestStack);
|
|
||||||
DebugRequestStack.serialize(dout, (DebugRequestStack)object);
|
|
||||||
} else if (object instanceof DebugRequestLineBreakpointToggle) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugRequestLineBreakpointToggle);
|
|
||||||
DebugRequestLineBreakpointToggle.serialize(dout, (DebugRequestLineBreakpointToggle)object);
|
|
||||||
} else if (object instanceof DebugRequest) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugRequest);
|
|
||||||
DebugRequest.serialize(dout, (DebugRequest)object);
|
|
||||||
} else if (object instanceof DebugEventType) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugEventType);
|
|
||||||
DebugEventType.serialize(dout, (DebugEventType)object);
|
|
||||||
} else if (object instanceof DebugEventBreakpoint) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugEventBreakpoint);
|
|
||||||
DebugEventBreakpoint.serialize(dout, (DebugEventBreakpoint)object);
|
|
||||||
} else if (object instanceof DebugEventError) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugEventError);
|
|
||||||
DebugEventError.serialize(dout, (DebugEventError)object);
|
|
||||||
} else if (object instanceof DebugEvent) {
|
|
||||||
dout.writeInt(SERIAL_TYPE_DebugEvent);
|
|
||||||
DebugEvent.serialize(dout, (DebugEvent)object);
|
|
||||||
} else {
|
|
||||||
// catch the errors: forgot to implement serialization/deserialization
|
|
||||||
throw new RuntimeException("serialization operation is not supported");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Serializable deserialize(DataInputStream din)
|
|
||||||
throws IOException {
|
|
||||||
Serializable object = null;
|
|
||||||
int type = din.readInt();
|
|
||||||
switch (type) {
|
|
||||||
case SERIAL_TYPE_NullableString:
|
|
||||||
object = NullableString.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_TableVariable:
|
|
||||||
object = TableVariable.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_Variable:
|
|
||||||
object = Variable.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_StackFrame:
|
|
||||||
object = StackFrame.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugResponseSimple:
|
|
||||||
object = DebugResponseSimple.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugResponseCallgraph:
|
|
||||||
object = DebugResponseCallgraph.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugResponseStack:
|
|
||||||
object = DebugResponseStack.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugRequestType:
|
|
||||||
object = DebugRequestType.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugRequestStack:
|
|
||||||
object = DebugRequestStack.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugRequestLineBreakpointToggle:
|
|
||||||
object = DebugRequestLineBreakpointToggle.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugRequest:
|
|
||||||
object = DebugRequest.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugEventType:
|
|
||||||
object = DebugEventType.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugEventBreakpoint:
|
|
||||||
object = DebugEventBreakpoint.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugEventError:
|
|
||||||
object = DebugEventError.deserialize(din);
|
|
||||||
break;
|
|
||||||
case SERIAL_TYPE_DebugEvent:
|
|
||||||
object = DebugEvent.deserialize(din);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("deserialization operation is not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
return object;
|
public static void serialize(Serializable object, DataOutputStream dout)
|
||||||
}
|
throws IOException {
|
||||||
|
if (object instanceof NullableString) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_NullableString);
|
||||||
|
NullableString.serialize(dout, (NullableString) object);
|
||||||
|
} else if (object instanceof TableVariable) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_TableVariable);
|
||||||
|
TableVariable.serialize(dout, (TableVariable) object);
|
||||||
|
} else if (object instanceof Variable) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_Variable);
|
||||||
|
Variable.serialize(dout, (Variable) object);
|
||||||
|
} else if (object instanceof StackFrame) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_StackFrame);
|
||||||
|
StackFrame.serialize(dout, (StackFrame) object);
|
||||||
|
} else if (object instanceof DebugResponseSimple) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugResponseSimple);
|
||||||
|
DebugResponseSimple.serialize(dout, (DebugResponseSimple) object);
|
||||||
|
} else if (object instanceof DebugResponseVariables) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugResponseVariables);
|
||||||
|
DebugResponseVariables.serialize(dout, (DebugResponseVariables) object);
|
||||||
|
} else if (object instanceof DebugResponseCallgraph) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugResponseCallgraph);
|
||||||
|
DebugResponseCallgraph.serialize(dout,
|
||||||
|
(DebugResponseCallgraph) object);
|
||||||
|
} else if (object instanceof DebugRequestType) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugRequestType);
|
||||||
|
DebugRequestType.serialize(dout, (DebugRequestType) object);
|
||||||
|
} else if (object instanceof DebugRequestStack) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugRequestStack);
|
||||||
|
DebugRequestStack.serialize(dout, (DebugRequestStack) object);
|
||||||
|
} else if (object instanceof DebugRequestLineBreakpointToggle) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugRequestLineBreakpointToggle);
|
||||||
|
DebugRequestLineBreakpointToggle.serialize(dout,
|
||||||
|
(DebugRequestLineBreakpointToggle) object);
|
||||||
|
} else if (object instanceof DebugRequest) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugRequest);
|
||||||
|
DebugRequest.serialize(dout, (DebugRequest) object);
|
||||||
|
} else if (object instanceof DebugEventType) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugEventType);
|
||||||
|
DebugEventType.serialize(dout, (DebugEventType) object);
|
||||||
|
} else if (object instanceof DebugEventBreakpoint) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugEventBreakpoint);
|
||||||
|
DebugEventBreakpoint.serialize(dout, (DebugEventBreakpoint) object);
|
||||||
|
} else if (object instanceof DebugEventError) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugEventError);
|
||||||
|
DebugEventError.serialize(dout, (DebugEventError) object);
|
||||||
|
} else if (object instanceof DebugEvent) {
|
||||||
|
dout.writeInt(SERIAL_TYPE_DebugEvent);
|
||||||
|
DebugEvent.serialize(dout, (DebugEvent) object);
|
||||||
|
} else {
|
||||||
|
// catch the errors: forgot to implement
|
||||||
|
// serialization/deserialization
|
||||||
|
throw new RuntimeException(
|
||||||
|
"serialization operation is not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Serializable deserialize(DataInputStream din)
|
||||||
|
throws IOException {
|
||||||
|
Serializable object = null;
|
||||||
|
int type = din.readInt();
|
||||||
|
switch (type) {
|
||||||
|
case SERIAL_TYPE_NullableString:
|
||||||
|
object = NullableString.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_TableVariable:
|
||||||
|
object = TableVariable.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_Variable:
|
||||||
|
object = Variable.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_StackFrame:
|
||||||
|
object = StackFrame.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugResponseSimple:
|
||||||
|
object = DebugResponseSimple.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugResponseCallgraph:
|
||||||
|
object = DebugResponseCallgraph.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugResponseVariables:
|
||||||
|
object = DebugResponseVariables.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugRequestType:
|
||||||
|
object = DebugRequestType.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugRequestStack:
|
||||||
|
object = DebugRequestStack.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugRequestLineBreakpointToggle:
|
||||||
|
object = DebugRequestLineBreakpointToggle.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugRequest:
|
||||||
|
object = DebugRequest.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugEventType:
|
||||||
|
object = DebugEventType.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugEventBreakpoint:
|
||||||
|
object = DebugEventBreakpoint.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugEventError:
|
||||||
|
object = DebugEventError.deserialize(din);
|
||||||
|
break;
|
||||||
|
case SERIAL_TYPE_DebugEvent:
|
||||||
|
object = DebugEvent.deserialize(din);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException(
|
||||||
|
"deserialization operation is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,14 +46,16 @@ public class DebugRequest implements Serializable {
|
|||||||
return type.toString();
|
return type.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void serialize(DataOutputStream out, DebugRequest request)
|
public static void serialize(DataOutputStream out, DebugRequest request)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
DebugRequestType type = request.getType();
|
DebugRequestType type = request.getType();
|
||||||
SerializationHelper.serialize(type, out);
|
SerializationHelper.serialize(type, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DebugRequest deserialize(DataInputStream in) throws IOException {
|
public static DebugRequest deserialize(DataInputStream in)
|
||||||
DebugRequestType type = (DebugRequestType) SerializationHelper.deserialize(in);
|
throws IOException {
|
||||||
return new DebugRequest(type);
|
DebugRequestType type = (DebugRequestType) SerializationHelper
|
||||||
}
|
.deserialize(in);
|
||||||
|
return new DebugRequest(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import lua.debug.EnumType;
|
|||||||
public class DebugRequestType extends EnumType {
|
public class DebugRequestType extends EnumType {
|
||||||
public static final DebugRequestType start = new DebugRequestType("start", 0);
|
public static final DebugRequestType start = new DebugRequestType("start", 0);
|
||||||
public static final DebugRequestType resume = new DebugRequestType("resume", 1);
|
public static final DebugRequestType resume = new DebugRequestType("resume", 1);
|
||||||
public static final DebugRequestType suspend = new DebugRequestType("suspend", 2);
|
public static final DebugRequestType suspend = new DebugRequestType("suspend", 2);
|
||||||
public static final DebugRequestType exit = new DebugRequestType("exit", 3);
|
public static final DebugRequestType exit = new DebugRequestType("exit", 3);
|
||||||
public static final DebugRequestType lineBreakpointSet = new DebugRequestType("lineBreakpointSet", 4);
|
public static final DebugRequestType lineBreakpointSet = new DebugRequestType("lineBreakpointSet", 4);
|
||||||
public static final DebugRequestType lineBreakpointClear = new DebugRequestType("lineBreakpointClear", 5);
|
public static final DebugRequestType lineBreakpointClear = new DebugRequestType("lineBreakpointClear", 5);
|
||||||
@@ -41,6 +41,7 @@ public class DebugRequestType extends EnumType {
|
|||||||
public static final DebugRequestType stepInto = new DebugRequestType("stepInto", 10);
|
public static final DebugRequestType stepInto = new DebugRequestType("stepInto", 10);
|
||||||
public static final DebugRequestType stepOver = new DebugRequestType("stepOver", 11);
|
public static final DebugRequestType stepOver = new DebugRequestType("stepOver", 11);
|
||||||
public static final DebugRequestType stepReturn = new DebugRequestType("stepReturn", 12);
|
public static final DebugRequestType stepReturn = new DebugRequestType("stepReturn", 12);
|
||||||
|
public static final DebugRequestType global = new DebugRequestType("global", 13);
|
||||||
|
|
||||||
protected static final DebugRequestType[] ENUMS = new DebugRequestType[] {
|
protected static final DebugRequestType[] ENUMS = new DebugRequestType[] {
|
||||||
start,
|
start,
|
||||||
@@ -55,7 +56,8 @@ public class DebugRequestType extends EnumType {
|
|||||||
stack,
|
stack,
|
||||||
stepInto,
|
stepInto,
|
||||||
stepOver,
|
stepOver,
|
||||||
stepReturn
|
stepReturn,
|
||||||
|
global
|
||||||
};
|
};
|
||||||
|
|
||||||
public DebugRequestType(String name, int ordinal) {
|
public DebugRequestType(String name, int ordinal) {
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ import java.io.IOException;
|
|||||||
import lua.debug.SerializationHelper;
|
import lua.debug.SerializationHelper;
|
||||||
import lua.debug.Variable;
|
import lua.debug.Variable;
|
||||||
|
|
||||||
public class DebugResponseStack implements DebugResponse {
|
public class DebugResponseVariables implements DebugResponse {
|
||||||
protected Variable[] variables;
|
protected Variable[] variables;
|
||||||
|
|
||||||
public DebugResponseStack(Variable[] variables) {
|
public DebugResponseVariables(Variable[] variables) {
|
||||||
if (variables == null) {
|
if (variables == null) {
|
||||||
this.variables = new Variable[0];
|
this.variables = new Variable[0];
|
||||||
} else {
|
} else {
|
||||||
this.variables = variables;
|
this.variables = variables;
|
||||||
}
|
}
|
||||||
@@ -54,21 +54,23 @@ public class DebugResponseStack implements DebugResponse {
|
|||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void serialize(DataOutputStream out, DebugResponseStack response)
|
public static void serialize(DataOutputStream out,
|
||||||
|
DebugResponseVariables response)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Variable[] variables = response.getVariables();
|
Variable[] variables = response.getVariables();
|
||||||
out.writeInt(variables == null ? 0 : variables.length);
|
out.writeInt(variables == null ? 0 : variables.length);
|
||||||
for (int i = 0; i < variables.length; i++) {
|
for (int i = 0; i < variables.length; i++) {
|
||||||
SerializationHelper.serialize(variables[i], out);
|
SerializationHelper.serialize(variables[i], out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DebugResponseStack deserialize(DataInputStream in) throws IOException {
|
public static DebugResponseVariables deserialize(DataInputStream in)
|
||||||
int count = in.readInt();
|
throws IOException {
|
||||||
Variable[] variables = new Variable[count];
|
int count = in.readInt();
|
||||||
for (int i = 0; i < count; i++) {
|
Variable[] variables = new Variable[count];
|
||||||
variables[i] = (Variable) SerializationHelper.deserialize(in);
|
for (int i = 0; i < count; i++) {
|
||||||
}
|
variables[i] = (Variable) SerializationHelper.deserialize(in);
|
||||||
return new DebugResponseStack(variables);
|
}
|
||||||
}
|
return new DebugResponseVariables(variables);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ import junit.framework.TestCase;
|
|||||||
import lua.Lua;
|
import lua.Lua;
|
||||||
import lua.debug.response.DebugResponseCallgraph;
|
import lua.debug.response.DebugResponseCallgraph;
|
||||||
import lua.debug.response.DebugResponseSimple;
|
import lua.debug.response.DebugResponseSimple;
|
||||||
import lua.debug.response.DebugResponseStack;
|
import lua.debug.response.DebugResponseVariables;
|
||||||
|
|
||||||
public class DebugResponseTest extends TestCase {
|
public class DebugResponseTest extends TestCase {
|
||||||
public void testDebugResponseSimpleSerialization() {
|
public void testDebugResponseSimpleSerialization() {
|
||||||
@@ -46,10 +46,10 @@ public class DebugResponseTest extends TestCase {
|
|||||||
|
|
||||||
private void doTestDebugResponseStackSerialization(Variable[] variables)
|
private void doTestDebugResponseStackSerialization(Variable[] variables)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
DebugResponseStack stackIn = new DebugResponseStack(variables);
|
DebugResponseVariables stackIn = new DebugResponseVariables(variables);
|
||||||
byte[] data = SerializationHelper.serialize(stackIn);
|
byte[] data = SerializationHelper.serialize(stackIn);
|
||||||
DebugResponseStack stackOut
|
DebugResponseVariables stackOut
|
||||||
= (DebugResponseStack) SerializationHelper.deserialize(data);
|
= (DebugResponseVariables) SerializationHelper.deserialize(data);
|
||||||
Variable[] variablesIn = stackIn.getVariables();
|
Variable[] variablesIn = stackIn.getVariables();
|
||||||
Variable[] variablesOut = stackOut.getVariables();
|
Variable[] variablesOut = stackOut.getVariables();
|
||||||
assertNotNull(variablesIn);
|
assertNotNull(variablesIn);
|
||||||
|
|||||||
Reference in New Issue
Block a user