From 9eace9fef4c4a4272f6bd1cfa3be5757fdb21422 Mon Sep 17 00:00:00 2001 From: Michael Van De Vanter Date: Sun, 7 Feb 2016 20:26:34 -0800 Subject: [PATCH] REPL debugger client: update to use new "repeat" option on stepping out. --- .../debug/shell/client/REPLRemoteCommand.java | 33 +++++++++++++++---- .../tools/debug/shell/server/REPLHandler.java | 16 ++++++--- .../tools/debug/shell/server/REPLServer.java | 4 +-- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLRemoteCommand.java b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLRemoteCommand.java index 9eb1c8957d44..5414214d3ebe 100644 --- a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLRemoteCommand.java +++ b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLRemoteCommand.java @@ -24,13 +24,13 @@ */ package com.oracle.truffle.tools.debug.shell.client; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.tools.debug.shell.REPLMessage; - import java.io.IOException; import java.util.Arrays; import java.util.List; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.tools.debug.shell.REPLMessage; + // TODO (mlvdv) write a real command line parser public abstract class REPLRemoteCommand extends REPLCommand { @@ -713,7 +713,7 @@ void processReply(REPLClientContext context, REPLMessage[] replies) { public static final REPLRemoteCommand STEP_INTO_CMD = new REPLRemoteCommand("step", "s", "(StepInto) next statement, going into functions.") { - private final String[] help = new String[]{"step into: step to next statement (into calls)", "step : step to nth next statement (into calls)"}; + private final String[] help = new String[]{"step: (StepInto) next statement (into calls)", "step : (StepInto) nth next statement (into calls)"}; @Override public String[] getHelp() { @@ -739,7 +739,7 @@ public REPLMessage createRequest(REPLClientContext context, String[] args) { return null; } } catch (NumberFormatException e) { - context.displayFailReply("Step into count \"" + nText + "\" not recognized"); + context.displayFailReply("Count \"" + nText + "\" not recognized"); return null; } } @@ -753,7 +753,14 @@ void processReply(REPLClientContext context, REPLMessage[] replies) { } }; - public static final REPLRemoteCommand STEP_OUT_CMD = new REPLRemoteCommand("finish", null, "(StepOut) continue to end of function") { + public static final REPLRemoteCommand STEP_OUT_CMD = new REPLRemoteCommand("finish", null, "(StepOut) return from function") { + + private final String[] help = new String[]{"finish: (StepOut) return from function", "finish : (StepOut) return from function times"}; + + @Override + public String[] getHelp() { + return help; + } @Override public REPLMessage createRequest(REPLClientContext context, String[] args) { @@ -764,6 +771,20 @@ public REPLMessage createRequest(REPLClientContext context, String[] args) { final REPLMessage request = new REPLMessage(); request.put(REPLMessage.OP, REPLMessage.STEP_OUT); + if (args.length >= 2) { + final String nText = args[1]; + try { + final int nSteps = Integer.parseInt(nText); + if (nSteps > 0) { + request.put(REPLMessage.REPEAT, Integer.toString(nSteps)); + } else { + return null; + } + } catch (NumberFormatException e) { + context.displayFailReply("Count \"" + nText + "\" not recognized"); + return null; + } + } return request; } diff --git a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLHandler.java b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLHandler.java index 29d9ce59d695..72f3cc33316e 100644 --- a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLHandler.java +++ b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLHandler.java @@ -663,8 +663,9 @@ public REPLMessage[] receive(REPLMessage request, REPLServer replServer) { if (repeat == null) { repeat = 1; } + final String countMessage = repeat == 1 ? "" : "<" + repeat + ">"; replServer.getCurrentContext().prepareStepInto(repeat); - return finishReplySucceeded(reply, "StepInto <" + repeat + "> enabled"); + return finishReplySucceeded(reply, "StepInto " + countMessage + " enabled"); } }; @@ -672,8 +673,14 @@ public REPLMessage[] receive(REPLMessage request, REPLServer replServer) { @Override public REPLMessage[] receive(REPLMessage request, REPLServer replServer) { - replServer.getCurrentContext().prepareStepOut(); - return finishReplySucceeded(createReply(), "StepOut enabled"); + final REPLMessage reply = createReply(); + Integer repeat = request.getIntValue(REPLMessage.REPEAT); + if (repeat == null) { + repeat = 1; + } + final String countMessage = repeat == 1 ? "" : "<" + repeat + ">"; + replServer.getCurrentContext().prepareStepOut(repeat); + return finishReplySucceeded(reply, "StepOut " + countMessage + " enabled"); } }; @@ -686,8 +693,9 @@ public REPLMessage[] receive(REPLMessage request, REPLServer replServer) { if (repeat == null) { repeat = 1; } + final String countMessage = repeat == 1 ? "" : "<" + repeat + ">"; replServer.getCurrentContext().prepareStepOver(repeat); - return finishReplySucceeded(reply, "StepOver <" + repeat + "> enabled"); + return finishReplySucceeded(reply, "StepOver " + countMessage + " enabled"); } }; diff --git a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLServer.java b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLServer.java index 351dc0f0ba16..afd3b625d39a 100644 --- a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLServer.java +++ b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/server/REPLServer.java @@ -476,8 +476,8 @@ String setLanguage(String name) throws IOException { return language.getName(); } - void prepareStepOut() { - event.prepareStepOut(); + void prepareStepOut(int repeat) { + event.prepareStepOut(repeat); } void prepareStepInto(int repeat) {