Skip to content

Commit a82bd09

Browse files
committed
Merge pull request #3 in G/truffle from ~MICHAEL.VAN.DE.VANTER_ORACLE.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.
2 parents 1a94cdd + 34a4352 commit a82bd09

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLClientContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -98,9 +98,9 @@ interface REPLClientContext {
9898
void displayFailReply(String message);
9999

100100
/**
101-
* Send a message announcing current execution is being killed.
101+
* notifies client that current execution has been killed.
102102
*/
103-
void displayKillMessage(String message);
103+
void notifyKilled();
104104

105105
/**
106106
* Recompute the client's command line prompt.

truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/REPLRemoteCommand.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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
567567
}
568568
final com.oracle.truffle.tools.debug.shell.REPLMessage request = new com.oracle.truffle.tools.debug.shell.REPLMessage();
569569
request.put(com.oracle.truffle.tools.debug.shell.REPLMessage.OP, "kill");
570-
context.displayKillMessage(null);
571570
return request;
572571
}
573572

574573
@Override
575574
void processReply(REPLClientContext context, com.oracle.truffle.tools.debug.shell.REPLMessage[] replies) {
576575
if (replies[0].get(com.oracle.truffle.tools.debug.shell.REPLMessage.STATUS).equals(com.oracle.truffle.tools.debug.shell.REPLMessage.SUCCEEDED)) {
577-
context.displayReply(replies[0].get(com.oracle.truffle.tools.debug.shell.REPLMessage.DISPLAY_MSG));
576+
context.notifyKilled();
578577
} else {
579578
context.displayFailReply(replies[0].get(com.oracle.truffle.tools.debug.shell.REPLMessage.DISPLAY_MSG));
580579
}

truffle/com.oracle.truffle.tools.debug.shell/src/com/oracle/truffle/tools/debug/shell/client/SimpleREPLClient.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
* <p>
6464
* In order to get
6565
* <ol>
66-
* <li>A debugging session should start from this shell, but there is no machinery in place for
67-
* doing that; instead, an entry into the language implementation creates both the server and this
68-
* shell;</li>
6966
* <li>The current startup sequence is based on method calls, not messages;</li>
7067
* <li>Only a very few request types and keys are implemented, omitting for example request and
7168
* session ids;</li>
@@ -279,6 +276,10 @@ private class ClientContextImpl implements REPLClientContext {
279276

280277
private String currentPrompt;
281278

279+
// A execution context stacked on top of this one was explicitly
280+
// killed, and this context will receive the resulting exception.
281+
private boolean killPending;
282+
282283
/**
283284
* Create a new context on the occasion of an execution halting.
284285
*/
@@ -519,7 +520,12 @@ public void displayFailReply(String message) {
519520
}
520521
}
521522

522-
public void displayKillMessage(String message) {
523+
public void notifyKilled() {
524+
// A kill will not be received until after
525+
// This context is released, so the exception
526+
// must be handles specially by the
527+
// context that will catch it.
528+
predecessor.killPending = true;
523529
writer.println(clientContext.currentPrompt + " killed");
524530
}
525531

@@ -606,7 +612,16 @@ private void startContextSession() {
606612
} else {
607613
assert false; // Should not happen.
608614
}
609-
615+
} catch (ThreadDeath ex) {
616+
if (ex.getClass() != ThreadDeath.class && killPending) {
617+
// If the previous context was killed by REPL command, then
618+
// assume this exception is the result and the REPL should
619+
// continue debugging in this context.
620+
killPending = false;
621+
} else {
622+
// A legitimate use of the exception
623+
throw ex;
624+
}
610625
} catch (REPLContinueException ex) {
611626
break;
612627
} catch (IOException e) {

0 commit comments

Comments
 (0)