diff --git a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLClientContext.java b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLClientContext.java index 56868c4170d2..39fa003a7807 100644 --- a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLClientContext.java +++ b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLClientContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,9 +98,9 @@ interface REPLClientContext { void displayFailReply(String message); /** - * Send a message announcing current execution is being killed. + * notifies client that current execution has been killed. */ - void displayKillMessage(String message); + void notifyKilled(); /** * Recompute the client's command line prompt. 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 1901fa0009ad..2685d5016014 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -567,14 +567,13 @@ public com.oracle.truffle.tools.debug.shell.REPLMessage createRequest(REPLClient } final com.oracle.truffle.tools.debug.shell.REPLMessage request = new com.oracle.truffle.tools.debug.shell.REPLMessage(); request.put(com.oracle.truffle.tools.debug.shell.REPLMessage.OP, "kill"); - context.displayKillMessage(null); return request; } @Override void processReply(REPLClientContext context, com.oracle.truffle.tools.debug.shell.REPLMessage[] replies) { if (replies[0].get(com.oracle.truffle.tools.debug.shell.REPLMessage.STATUS).equals(com.oracle.truffle.tools.debug.shell.REPLMessage.SUCCEEDED)) { - context.displayReply(replies[0].get(com.oracle.truffle.tools.debug.shell.REPLMessage.DISPLAY_MSG)); + context.notifyKilled(); } else { context.displayFailReply(replies[0].get(com.oracle.truffle.tools.debug.shell.REPLMessage.DISPLAY_MSG)); } diff --git a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/SimpleREPLClient.java b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/SimpleREPLClient.java index 50a9e1c15317..2cd601d5133c 100644 --- a/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/SimpleREPLClient.java +++ b/truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/SimpleREPLClient.java @@ -63,9 +63,6 @@ *

* In order to get *

    - *
  1. A debugging session should start from this shell, but there is no machinery in place for - * doing that; instead, an entry into the language implementation creates both the server and this - * shell;
  2. *
  3. The current startup sequence is based on method calls, not messages;
  4. *
  5. Only a very few request types and keys are implemented, omitting for example request and * session ids;
  6. @@ -279,6 +276,10 @@ private class ClientContextImpl implements REPLClientContext { private String currentPrompt; + // A execution context stacked on top of this one was explicitly + // killed, and this context will receive the resulting exception. + private boolean killPending; + /** * Create a new context on the occasion of an execution halting. */ @@ -519,7 +520,12 @@ public void displayFailReply(String message) { } } - public void displayKillMessage(String message) { + public void notifyKilled() { + // A kill will not be received until after + // This context is released, so the exception + // must be handles specially by the + // context that will catch it. + predecessor.killPending = true; writer.println(clientContext.currentPrompt + " killed"); } @@ -606,7 +612,16 @@ private void startContextSession() { } else { assert false; // Should not happen. } - + } catch (ThreadDeath ex) { + if (ex.getClass() != ThreadDeath.class && killPending) { + // If the previous context was killed by REPL command, then + // assume this exception is the result and the REPL should + // continue debugging in this context. + killPending = false; + } else { + // A legitimate use of the exception + throw ex; + } } catch (REPLContinueException ex) { break; } catch (IOException e) {