diff --git a/.classpath b/.classpath index 9904b923..ade268a2 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/src/main/java/lua/debug/DebugStackState.java b/src/main/java/lua/debug/DebugStackState.java index 5e3d665a..c3595fd5 100644 --- a/src/main/java/lua/debug/DebugStackState.java +++ b/src/main/java/lua/debug/DebugStackState.java @@ -33,6 +33,7 @@ import lua.StackState; import lua.addon.compile.LexState; import lua.debug.event.DebugEvent; import lua.debug.event.DebugEventBreakpoint; +import lua.debug.event.DebugEventError; import lua.debug.event.DebugEventType; import lua.debug.request.DebugRequest; import lua.debug.request.DebugRequestLineBreakpointToggle; @@ -43,7 +44,6 @@ import lua.debug.response.DebugResponse; import lua.debug.response.DebugResponseCallgraph; import lua.debug.response.DebugResponseSimple; import lua.debug.response.DebugResponseStack; -import lua.io.Closure; import lua.io.LocVars; import lua.io.Proto; import lua.value.LTable; @@ -51,14 +51,22 @@ import lua.value.LValue; public class DebugStackState extends StackState implements DebugRequestListener { - private static final boolean DEBUG = false; + // stepping constants and stepping state + protected static final int STEP_NONE = 0; + protected static final int STEP_OVER = 1; + protected static final int STEP_INTO = 2; + protected static final int STEP_RETURN = 3; + protected int stepping = STEP_NONE; + protected boolean shouldPauseForStepping = false; + protected int steppingFrame = -1; protected Hashtable breakpoints = new Hashtable(); protected boolean exiting = false; protected boolean suspended = false; - protected boolean stepping = false; protected int lastline = -1; + protected String lastSource; protected DebugSupport debugSupport = null; + public DebugStackState() {} @@ -104,7 +112,6 @@ public class DebugStackState extends StackState implements DebugRequestListener error(message, 1); } - private void printLuaTrace() { System.out.println( "Lua location: "+getFileLine(cc) ); for ( int cindex=cc-1; cindex>=0; cindex-- ) @@ -117,10 +124,15 @@ public class DebugStackState extends StackState implements DebugRequestListener super.exec(); } catch (AbortException e) { // ignored. Client aborts the debugging session. + } catch ( RuntimeException t ) { + // let other exceptions be processed + // the same as the base class to minimize differences + // between the debug and non-debug behavior + + debugSupport.notifyDebugEvent(new DebugEventError(t.getMessage())); + suspend(); + throw t; } - // let other exceptions be processed - // the same as the base class to minimize differences - // between the debug and non-debug behavior } @@ -131,41 +143,65 @@ public class DebugStackState extends StackState implements DebugRequestListener } if(DebugUtils.IS_DEBUG) - DebugUtils.println("entered debugHook..."); + DebugUtils.println("entered debugHook on pc=" + pc + "..."); synchronized ( this ) { + CallInfo currentCallInfo = calls[cc]; + Proto currentProto = currentCallInfo.closure.p; - // anytime the line doesn't change we keep going - int line = getLineNumber(calls[cc]); - if ( !stepping && lastline == line ) { + // if we are not stepping, we keep going if the line doesn't change + int line = getLineNumber(currentCallInfo); + String source = DebugUtils.getSourceFileName(currentProto.source); + if ( !isStepping() && lastline == line && source.equals(lastSource) ) { return; } + if(DebugUtils.IS_DEBUG) DebugUtils.println("debugHook - executing line: " + line); + + int i = currentProto.code[pc]; + int opCode = StackState.GET_OPCODE(i); + if (isStepping() && + opCode == StackState.OP_RETURN && cc == 0) { + cancelStepping(); + } else if (shouldPauseForStepping) { + shouldPauseForStepping = false; + suspendOnStepping(); + } else if ( stepping == STEP_INTO ) { + if (lastline != line){ + suspendOnStepping(); + } else if (opCode == StackState.OP_CALL) { + shouldPauseForStepping = true; + } + } else if (stepping == STEP_OVER) { + if ((lastline != line && steppingFrame == cc) || (steppingFrame > cc)) { + suspendOnStepping(); + } + } else if (stepping == STEP_RETURN) { + if ((opCode == StackState.OP_RETURN && cc == this.steppingFrame) || + (opCode == StackState.OP_TAILCALL && cc == this.steppingFrame)){ + shouldPauseForStepping = true; + } + } + + // check for a break point if we aren't suspended already + if ( !suspended && lastline != line) { + if (DebugUtils.IS_DEBUG) + DebugUtils.println("Source: " + currentProto.source); + String breakpointKey = constructBreakpointKey(source, line); + if (breakpoints.containsKey(breakpointKey)){ + if(DebugUtils.IS_DEBUG) + DebugUtils.println("hitting breakpoint " + constructBreakpointKey(source, line)); + + debugSupport.notifyDebugEvent(new DebugEventBreakpoint(source, line)); + suspended = true; + } + } + // save line in case next op is a step lastline = line; - - if ( stepping ) { - DebugUtils.println("suspended by stepping at pc=" + pc); - //TODO: notifyDebugEventListeners(new DebugEventStepping()); - suspended = true; - } else if ( !suspended ) { - // check for a break point if we aren't suspended already - Proto p = calls[cc].closure.p; - String source = DebugUtils.getSourceFileName(p.source); - if ( breakpoints.containsKey(constructBreakpointKey(source, line))){ - if(DebugUtils.IS_DEBUG) { - DebugUtils.println("hitting breakpoint " + constructBreakpointKey(source, line)); - } - if (debugSupport != null) { - debugSupport.notifyDebugEvent(new DebugEventBreakpoint(source, line)); - } - suspended = true; - } else { - return; - } - } + lastSource = source; // wait for a state change while (suspended && !exiting ) { @@ -180,6 +216,23 @@ public class DebugStackState extends StackState implements DebugRequestListener } } + private boolean isStepping() { + return stepping != STEP_NONE; + } + + private void cancelStepping() { + debugSupport.notifyDebugEvent(new DebugEvent(DebugEventType.resumedOnSteppingEnd)); + stepping = STEP_NONE; + steppingFrame = -1; + shouldPauseForStepping = false; + } + + private void suspendOnStepping() { + debugSupport.notifyDebugEvent(new DebugEvent(DebugEventType.suspendedOnStepping)); + suspended = true; + steppingFrame = -1; + } + /** * Get the current line number * @param pc program counter @@ -199,7 +252,9 @@ public class DebugStackState extends StackState implements DebugRequestListener throw new IllegalStateException("DebugStackState is not equiped with DebugSupport."); } - DebugUtils.println("DebugStackState is handling request: " + request.toString()); + if (DebugUtils.IS_DEBUG) + DebugUtils.println("DebugStackState is handling request: " + request.toString()); + DebugRequestType requestType = request.getType(); if (DebugRequestType.start == requestType) { DebugEvent event = new DebugEvent(DebugEventType.started); @@ -234,8 +289,20 @@ public class DebugStackState extends StackState implements DebugRequestListener DebugRequestStack stackRequest = (DebugRequestStack) request; int index = stackRequest.getIndex(); return new DebugResponseStack(getStack(index)); - } else if (DebugRequestType.step == requestType) { - step(); + } else if (DebugRequestType.stepInto == requestType) { + DebugEvent event = new DebugEvent(DebugEventType.resumedOnSteppingInto); + debugSupport.notifyDebugEvent(event); + stepInto(); + return DebugResponseSimple.SUCCESS; + } else if (DebugRequestType.stepOver == requestType) { + DebugEvent event = new DebugEvent(DebugEventType.resumedOnSteppingOver); + debugSupport.notifyDebugEvent(event); + stepOver(); + return DebugResponseSimple.SUCCESS; + } else if (DebugRequestType.stepReturn == requestType) { + DebugEvent event = new DebugEvent(DebugEventType.resumedOnSteppingReturn); + debugSupport.notifyDebugEvent(event); + stepReturn(); return DebugResponseSimple.SUCCESS; } @@ -248,7 +315,7 @@ public class DebugStackState extends StackState implements DebugRequestListener public void suspend() { synchronized ( this ) { suspended = true; - stepping = false; + stepping = STEP_NONE; lastline = -1; this.notify(); } @@ -260,7 +327,7 @@ public class DebugStackState extends StackState implements DebugRequestListener public void resume() { synchronized ( this ) { suspended = false; - stepping = false; + stepping = STEP_NONE; this.notify(); } } @@ -278,7 +345,7 @@ public class DebugStackState extends StackState implements DebugRequestListener debugSupport.stop(); debugSupport = null; } - }, 300); + }, 500); exit(); } @@ -298,9 +365,14 @@ public class DebugStackState extends StackState implements DebugRequestListener * @param N the line to set the breakpoint at */ public void setBreakpoint(String source, int lineNumber) { - DebugUtils.println("adding breakpoint " + constructBreakpointKey(source, lineNumber)); + if (DebugUtils.IS_DEBUG) { + DebugUtils.print("source: " + source + " line:" + lineNumber); + DebugUtils.println("adding breakpoint " + constructBreakpointKey(source, lineNumber)); + } + synchronized ( this ) { - breakpoints.put(constructBreakpointKey(source, lineNumber), Boolean.TRUE ); + String normalizedFileName = DebugUtils.getSourceFileName(source); + breakpoints.put(constructBreakpointKey(normalizedFileName, lineNumber), Boolean.TRUE ); } } @@ -315,7 +387,8 @@ public class DebugStackState extends StackState implements DebugRequestListener if(DebugUtils.IS_DEBUG) DebugUtils.println("removing breakpoint " + constructBreakpointKey(source, lineNumber)); synchronized ( this ) { - breakpoints.remove(constructBreakpointKey(source, lineNumber)); + String normalizedFileName = DebugUtils.getSourceFileName(source); + breakpoints.remove(constructBreakpointKey(normalizedFileName, lineNumber)); } } @@ -364,9 +437,11 @@ public class DebugStackState extends StackState implements DebugRequestListener LValue value = stack[callInfo.base + i]; if (value != null) { int type = value.luaGetType(); - DebugUtils.print("\tType: " + Lua.TYPE_NAMES[type]); + if (DebugUtils.IS_DEBUG) + DebugUtils.print("\tType: " + Lua.TYPE_NAMES[type]); if (type == Lua.LUA_TTABLE) { - DebugUtils.println(" (selected)"); + if (DebugUtils.IS_DEBUG) + DebugUtils.println(" (selected)"); variables.addElement( new TableVariable(localVariableCount++, varName, @@ -374,20 +449,24 @@ public class DebugStackState extends StackState implements DebugRequestListener (LTable) value)); } else if (type != Lua.LUA_TFUNCTION && type != LUA_TTHREAD) { - DebugUtils.println(" (selected)"); + if (DebugUtils.IS_DEBUG) + DebugUtils.println(" (selected)"); variables.addElement( new Variable(localVariableCount++, varName, type, value.toString())); } else { - DebugUtils.println(""); + if (DebugUtils.IS_DEBUG) + DebugUtils.println(""); } } else { - DebugUtils.println(""); + if (DebugUtils.IS_DEBUG) + DebugUtils.println(""); } } else { - DebugUtils.println(""); + if (DebugUtils.IS_DEBUG) + DebugUtils.println(""); } } @@ -400,13 +479,43 @@ public class DebugStackState extends StackState implements DebugRequestListener /** - * single step forward (go to next statement) + * step over to next line */ - public void step() { + public void stepOver() { synchronized ( this ) { - suspended = false; - stepping = true; + if (DebugUtils.IS_DEBUG) + DebugUtils.println("stepOver on cc=" + cc + "..."); + + suspended = false; + stepping = STEP_OVER; + steppingFrame = cc; this.notify(); } } + + /** + * step a single statement + */ + public void stepInto() { + synchronized ( this ) { + suspended = false; + stepping = STEP_INTO; + this.notify(); + } + } + + /** + * return from the method call + */ + public void stepReturn() { + synchronized ( this ) { + if (DebugUtils.IS_DEBUG) + DebugUtils.println("stepReturn on cc=" + cc + "..."); + + suspended = false; + stepping = STEP_RETURN; + steppingFrame = cc; + this.notify(); + } + } } diff --git a/src/main/java/lua/debug/DebugSupport.java b/src/main/java/lua/debug/DebugSupport.java index 8903a8f7..3af0c601 100644 --- a/src/main/java/lua/debug/DebugSupport.java +++ b/src/main/java/lua/debug/DebugSupport.java @@ -44,8 +44,10 @@ public class DebugSupport implements DebugRequestListener, DebugEventListener { this.vm = vm; } - protected void releaseServer() { - DebugUtils.println("shutting down the debug server..."); + protected void dispose() { + if (DebugUtils.IS_DEBUG) + DebugUtils.println("releasing the networkig resources..."); + if (requestReader != null) { try { requestReader.close(); @@ -83,11 +85,8 @@ public class DebugSupport implements DebugRequestListener, DebugEventListener { this.requestWatcherThread = new Thread(new Runnable() { public void run() { - if (getState() != STOPPED) { - handleRequest(); - } else { - releaseServer(); - } + loopForRequests(); + cleanup(); } }); this.requestWatcherThread.start(); @@ -104,11 +103,12 @@ public class DebugSupport implements DebugRequestListener, DebugEventListener { * @see lua.debug.j2se.DebugSupport#stop() */ public synchronized void stop() { - DebugUtils.println("stopping the debug support..."); + if (DebugUtils.IS_DEBUG) + DebugUtils.println("stopping the debug support..."); this.state = STOPPED; } - protected void handleRequest() { + protected void loopForRequests() { try { while (getState() != STOPPED) { int size = requestReader.readInt(); @@ -116,29 +116,29 @@ public class DebugSupport implements DebugRequestListener, DebugEventListener { requestReader.readFully(data); DebugRequest request = (DebugRequest) SerializationHelper.deserialize(data); - DebugUtils.println("SERVER receives request: " + request.toString()); + if (DebugUtils.IS_DEBUG) + DebugUtils.println("SERVER receives request: " + request.toString()); DebugResponse response = handleRequest(request); data = SerializationHelper.serialize(response); requestWriter.writeInt(data.length); requestWriter.write(data); requestWriter.flush(); - DebugUtils.println("SERVER sends response: " + response); - } - - if (getState() == STOPPED) { - cleanup(); - } + if (DebugUtils.IS_DEBUG) + DebugUtils.println("SERVER sends response: " + response); + } } catch (EOFException e) { - cleanup(); - } catch (IOException e) { + // expected during shutdown + } catch (Exception e) { e.printStackTrace(); } } private void cleanup() { - DebugUtils.println("SERVER terminated..."); - releaseServer(); + if (DebugUtils.IS_DEBUG) + DebugUtils.println("SERVER terminated..."); + + dispose(); System.exit(0); } @@ -160,7 +160,9 @@ public class DebugSupport implements DebugRequestListener, DebugEventListener { * @param event */ protected void sendEvent(DebugEvent event) { - DebugUtils.println("SERVER sending event: " + event.toString()); + if (DebugUtils.IS_DEBUG) + DebugUtils.println("SERVER sending event: " + event.toString()); + try { byte[] data = SerializationHelper.serialize(event); eventWriter.writeInt(data.length); diff --git a/src/main/java/lua/debug/DebugUtils.java b/src/main/java/lua/debug/DebugUtils.java index d694f973..a1f9950f 100644 --- a/src/main/java/lua/debug/DebugUtils.java +++ b/src/main/java/lua/debug/DebugUtils.java @@ -40,14 +40,14 @@ public class DebugUtils { } public static String getSourceFileName(LString source) { - String sourceStr = LoadState.getSourceName(source.toJavaString()); + String sourceStr = LoadState.getSourceName(source.toJavaString()); + return getSourceFileName(sourceStr); + } + + public static String getSourceFileName(String sourceStr) { if (!LoadState.SOURCE_BINARY_STRING.equals(sourceStr)) { - sourceStr = sourceStr.replace('\\', '/'); - int index = sourceStr.lastIndexOf('/'); - if (index != -1) { - sourceStr = sourceStr.substring(index + 1); - } + sourceStr = sourceStr.replace('\\', '/'); } - return sourceStr; + return sourceStr; } } diff --git a/src/main/java/lua/debug/SerializationHelper.java b/src/main/java/lua/debug/SerializationHelper.java index 16dd58b9..5551a7c7 100644 --- a/src/main/java/lua/debug/SerializationHelper.java +++ b/src/main/java/lua/debug/SerializationHelper.java @@ -8,6 +8,7 @@ import java.io.IOException; import lua.debug.event.DebugEvent; import lua.debug.event.DebugEventBreakpoint; +import lua.debug.event.DebugEventError; import lua.debug.event.DebugEventType; import lua.debug.request.DebugRequest; import lua.debug.request.DebugRequestLineBreakpointToggle; @@ -60,6 +61,7 @@ public class SerializationHelper { static final int SERIAL_TYPE_DebugEventType = 11; static final int SERIAL_TYPE_DebugEvent = 12; static final int SERIAL_TYPE_DebugEventBreakpoint = 13; + static final int SERIAL_TYPE_DebugEventError = 14; public static void serialize(Serializable object, DataOutputStream dout) throws IOException { @@ -102,6 +104,9 @@ public class SerializationHelper { } 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); @@ -154,7 +159,10 @@ public class SerializationHelper { break; case SERIAL_TYPE_DebugEventBreakpoint: object = DebugEventBreakpoint.deserialize(din); - break; + break; + case SERIAL_TYPE_DebugEventError: + object = DebugEventError.deserialize(din); + break; case SERIAL_TYPE_DebugEvent: object = DebugEvent.deserialize(din); break; diff --git a/src/main/java/lua/debug/event/DebugEventError.java b/src/main/java/lua/debug/event/DebugEventError.java index c650970e..67db2f5a 100644 --- a/src/main/java/lua/debug/event/DebugEventError.java +++ b/src/main/java/lua/debug/event/DebugEventError.java @@ -44,14 +44,13 @@ public class DebugEventError extends DebugEvent { return super.toString() + " detail: " + getDetail(); } - public static void serialize(DataOutputStream out, DebugEventError object) - throws IOException { - //TODO implement + public static void serialize(DataOutputStream out, DebugEventError object) + throws IOException { + out.writeUTF(object.getDetail()); } - public static DebugEvent deserialize(DataInputStream in) - throws IOException { - //TODO implement - return null; + public static DebugEvent deserialize(DataInputStream in) throws IOException { + String detail = in.readUTF(); + return new DebugEventError(detail); } } diff --git a/src/main/java/lua/debug/event/DebugEventType.java b/src/main/java/lua/debug/event/DebugEventType.java index c16237b4..d663501f 100644 --- a/src/main/java/lua/debug/event/DebugEventType.java +++ b/src/main/java/lua/debug/event/DebugEventType.java @@ -35,10 +35,13 @@ public class DebugEventType extends EnumType { public static DebugEventType suspendedOnStepping = new DebugEventType("suspendedOnStepping", 4); public static DebugEventType suspendedOnError = new DebugEventType("suspendedOnError", 5); public static DebugEventType resumedByClient = new DebugEventType("resumedByClient", 6); - public static DebugEventType resumedOnStepping = new DebugEventType("resumedOnStepping", 7); - public static DebugEventType resumedOnError = new DebugEventType("resumedOnError", 8); - public static DebugEventType error = new DebugEventType("error", 9); - public static DebugEventType terminated = new DebugEventType("terminated", 10); + public static DebugEventType resumedOnSteppingInto = new DebugEventType("resumedOnSteppingInto", 7); + public static DebugEventType resumedOnSteppingOver = new DebugEventType("resumedOnSteppingOver", 8); + public static DebugEventType resumedOnSteppingReturn = new DebugEventType("resumedOnSteppingReturn", 9); + public static DebugEventType resumedOnSteppingEnd = new DebugEventType("resumedOnSteppingEnd", 10); + public static DebugEventType resumedOnError = new DebugEventType("resumedOnError", 11); + public static DebugEventType error = new DebugEventType("error", 12); + public static DebugEventType terminated = new DebugEventType("terminated", 13); protected static DebugEventType[] ENUMS = new DebugEventType[] { started, @@ -48,7 +51,10 @@ public class DebugEventType extends EnumType { suspendedOnStepping, suspendedOnError, resumedByClient, - resumedOnStepping, + resumedOnSteppingInto, + resumedOnSteppingOver, + resumedOnSteppingReturn, + resumedOnSteppingEnd, resumedOnError, error, terminated @@ -62,7 +68,7 @@ public class DebugEventType extends EnumType { throws IOException { int ordinal = in.readInt(); if (ordinal < 0 || ordinal >= ENUMS.length) { - throw new RuntimeException("ordinal is out of the range."); + throw new RuntimeException("DebugEventType: ordinal is out of the range."); } return ENUMS[ordinal]; } diff --git a/src/main/java/lua/debug/j2me/DebugSupportImpl.java b/src/main/java/lua/debug/j2me/DebugSupportImpl.java index e7b92a0c..e340b4be 100644 --- a/src/main/java/lua/debug/j2me/DebugSupportImpl.java +++ b/src/main/java/lua/debug/j2me/DebugSupportImpl.java @@ -7,7 +7,6 @@ import javax.microedition.io.ServerSocketConnection; import javax.microedition.io.SocketConnection; import lua.debug.DebugSupport; -import lua.debug.DebugUtils; import lua.debug.event.DebugEvent; public class DebugSupportImpl extends DebugSupport { @@ -56,8 +55,8 @@ public class DebugSupportImpl extends DebugSupport { super.start(); } - protected void releaseServer() { - super.releaseServer(); + protected void dispose() { + super.dispose(); if (requestSocketConnection != null) { try { @@ -84,9 +83,9 @@ public class DebugSupportImpl extends DebugSupport { } } - protected void handleRequest() { + protected void loopForRequests() { synchronized (requestSocketConnection) { - super.handleRequest(); + super.loopForRequests(); } } diff --git a/src/main/java/lua/debug/j2se/DebugSupportImpl.java b/src/main/java/lua/debug/j2se/DebugSupportImpl.java index 283c2a84..1e61bf8f 100644 --- a/src/main/java/lua/debug/j2se/DebugSupportImpl.java +++ b/src/main/java/lua/debug/j2se/DebugSupportImpl.java @@ -28,7 +28,6 @@ import java.net.ServerSocket; import java.net.Socket; import lua.debug.DebugSupport; -import lua.debug.DebugUtils; import lua.debug.event.DebugEvent; public class DebugSupportImpl extends DebugSupport { @@ -61,8 +60,8 @@ public class DebugSupportImpl extends DebugSupport { super.start(); } - protected void releaseServer() { - super.releaseServer(); + protected void dispose() { + super.dispose(); if (clientRequestSocket != null) { try { @@ -89,9 +88,9 @@ public class DebugSupportImpl extends DebugSupport { } } - protected void handleRequest() { + protected void loopForRequests() { synchronized (clientRequestSocket) { - super.handleRequest(); + super.loopForRequests(); } } diff --git a/src/main/java/lua/debug/request/DebugRequestType.java b/src/main/java/lua/debug/request/DebugRequestType.java index 49980ee1..927b8848 100644 --- a/src/main/java/lua/debug/request/DebugRequestType.java +++ b/src/main/java/lua/debug/request/DebugRequestType.java @@ -28,21 +28,24 @@ import lua.debug.EnumType; public class DebugRequestType extends EnumType { - public static final DebugRequestType suspend = new DebugRequestType("suspend", 0); + public static final DebugRequestType start = new DebugRequestType("start", 0); public static final DebugRequestType resume = new DebugRequestType("resume", 1); - public static final DebugRequestType exit = new DebugRequestType("exit", 2); - public static final DebugRequestType lineBreakpointSet = new DebugRequestType("lineBreakpointSet", 3); - public static final DebugRequestType lineBreakpointClear = new DebugRequestType("lineBreakpointClear", 4); - public static final DebugRequestType watchpointSet = new DebugRequestType("watchpointSet", 5); - public static final DebugRequestType watchpointClear = new DebugRequestType("watchpointClear", 6); - public static final DebugRequestType callgraph = new DebugRequestType("callgraph", 7); - public static final DebugRequestType stack = new DebugRequestType("stack", 8); - public static final DebugRequestType step = new DebugRequestType("step", 9); - public static final DebugRequestType start = new DebugRequestType("start", 10); + public static final DebugRequestType suspend = new DebugRequestType("suspend", 2); + public static final DebugRequestType exit = new DebugRequestType("exit", 3); + public static final DebugRequestType lineBreakpointSet = new DebugRequestType("lineBreakpointSet", 4); + public static final DebugRequestType lineBreakpointClear = new DebugRequestType("lineBreakpointClear", 5); + public static final DebugRequestType watchpointSet = new DebugRequestType("watchpointSet", 6); + public static final DebugRequestType watchpointClear = new DebugRequestType("watchpointClear", 7); + public static final DebugRequestType callgraph = new DebugRequestType("callgraph", 8); + public static final DebugRequestType stack = new DebugRequestType("stack", 9); + public static final DebugRequestType stepInto = new DebugRequestType("stepInto", 10); + public static final DebugRequestType stepOver = new DebugRequestType("stepOver", 11); + public static final DebugRequestType stepReturn = new DebugRequestType("stepReturn", 12); protected static final DebugRequestType[] ENUMS = new DebugRequestType[] { - suspend, + start, resume, + suspend, exit, lineBreakpointSet, lineBreakpointClear, @@ -50,8 +53,9 @@ public class DebugRequestType extends EnumType { watchpointClear, callgraph, stack, - step, - start + stepInto, + stepOver, + stepReturn }; public DebugRequestType(String name, int ordinal) { @@ -61,7 +65,7 @@ public class DebugRequestType extends EnumType { public static DebugRequestType deserialize(DataInputStream in) throws IOException { int ordinal = in.readInt(); if (ordinal < 0 || ordinal >= ENUMS.length) { - throw new RuntimeException("ordinal is out of the range."); + throw new RuntimeException("DebugRequestType: ordinal is out of the range."); } return ENUMS[ordinal]; } diff --git a/src/test/java/lua/debug/DebugStackStateTest.java b/src/test/java/lua/debug/DebugStackStateTest.java index c7b256ae..424d6e44 100644 --- a/src/test/java/lua/debug/DebugStackStateTest.java +++ b/src/test/java/lua/debug/DebugStackStateTest.java @@ -60,7 +60,7 @@ public class DebugStackStateTest extends TestCase { // step for 5 steps for ( int i=0; i<5; i++ ) { - state.step(); + state.stepOver(); Thread.sleep(500); System.out.println("--- callgraph="+state.getCallgraph() ); System.out.println("--- stack="+state.getStack(0) );