Skip to content

Commit

Permalink
Merge pull request #3 in G/truffle from ~MICHAEL.VAN.DE.VANTER_ORACLE…
Browse files Browse the repository at this point in the history
….COM/truffle:fix-REPL-kill to master

Update the REPL debugger after change in handling of KillException.

* commit '34a435271d216211c708cf233a25df31abcf0565':
  REPL - tighten identification of KillException without dependency.
  REPL debugger:  fix handling of Kill reimplemented as subclass of ThreadDeath.
  • Loading branch information
mlvdv committed Apr 15, 2016
2 parents 1a94cdd + 34a4352 commit a82bd09
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
* <p>
* In order to get
* <ol>
* <li>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;</li>
* <li>The current startup sequence is based on method calls, not messages;</li>
* <li>Only a very few request types and keys are implemented, omitting for example request and
* session ids;</li>
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a82bd09

Please sign in to comment.