Hi Gary,
I updated my changes to do the wait() for step, stepi, cont, and next. Some issues turned up when testing. A number of tests were timing out occasionally, I believe because sometimes the event was handled (and the notify() call already completed) before we ever got to the handler.wait() call. Although I never confirmed this was the cause, it certainly seems feasible. There were also issues with the prompt printed by TTY:executeCommand(). I've come to realize that it should really always be printed before any event handling. Currently that seems to be the case, probably due to the Thread.yield() I mention below in event handling code like stepEvent(), although I don't think it's necessarily guaranteed. However, with my changes prompt was always printed after the event was done being handled, and this proved to be a problem for some tests. When executing the "cont" command, it seems this prompt is expected to be "> ", which is the prompt printed if the VM is not currently suspended. Some tests count on this, mostly because they call jdb.receiveReplyFor(), and pass in the number of prompts that are expected. jdb.receiveReplyFor() does not count "> ". My change ended up making the printPrompt() in TTY:executeCommand() print as "main[1]" after a "cont" command, because the added synchronizing was making it not print until the thread was suspended. This caused some tests to fail because the expected reply was not yet received, even after jdb.receiveReplyFor() had returned (it was basically returning one prompt too soon). I started thinking that the synchronized approach probably needs a large synchronized block in TTY:executeCommand(). But then I figured out a much easier solution. Thinking more about the "prompt after cont" issue, it occurred to me that maybe we just need to print out the prompt before executing the command, so it's not possible for events to come in before the prompt is printed (or worse yet, in the middle of event handling output). Doing this ends up looking much like your original suggestion to set printPrompt = false for "cont", "step", "stepi", and "next", except I also added a call printPrompt() before doing this (Dan an I had rejected your proposal to simply remove the prompt, since it did server a purpose). For example: } else if (cmd.equals("cont")) { MessageOutput.printPrompt(); showPrompt = false; evaluator.commandCont(); But this does cause the issue I brought up above that the prompt from "cont" is expected (by a number of tests) to be "> ", but since the above code is executed while the vm is suspended, it ends up being main[1]. I fixed this by adding a "simple" argument to printPrompt() so we can force it to be "> " when needed. This will maintain compatibility with anyone making assumptions about what the prompt should look like. Here's the webrev, which seems to be working. I've run about 1000 iterations on all platforms. So far it seems to be working. There have been some failures, but for the most part I've also seen those with clean repos, and the ones that I haven't I don't believe are related to my changes. http://cr.openjdk.java.net/~cjplummer/8169718/webrev.01/ One other comment about your initial fix to set showPrompt = false: + showPrompt = false; // asynchronous command I'm not sure if the "asynchronous command" comment was intentional or just the result of the copy-and-paste. I just want to clarify what is meant by "asynchronous command" in the other places where this comment appears. There are a few commands that are executed async on a different thread. If you look in Commands.java, you'll see how these commands use the AsyncExecution class to handle execution of the command. I'm not sure why this is done, because all these commands look like ones that are inherently synchronous, yet they are always run on a different thread, and as a result may not be complete when execution returns to TTY::executeCommand(). These commands also all set showPrompt = false, but the prompt is printed by AsyncExecution when complete. So, the point is the commands which are inherently async, like "step" and "cont", are not async w.r.t. these "asynchronous command" comments or the AsyncExecution class. Chris On 7/27/18 4:27 PM, Chris Plummer wrote:
|
- Re: RFR: JDK-8169718: nsk/jdb/loca... Gary Adams
- Re: RFR: JDK-8169718: nsk/jdb/... Chris Plummer
- Re: RFR: JDK-8169718: nsk... Gary Adams
- Re: RFR: JDK-8169718:... Chris Plummer
- Re: RFR: JDK-8169718:... Gary Adams
- Re: RFR: JDK-8169718:... Chris Plummer
- Re: RFR: JDK-8169718:... Gary Adams
- Re: RFR: JDK-8169718:... Chris Plummer
- Re: RFR: JDK-8169718: nsk/jdb/locals/locals002:... Gary Adams
- Re: RFR: JDK-8169718: nsk/jdb/locals/local... Chris Plummer
- Re: RFR: JDK-8169718: nsk/jdb/locals/l... Chris Plummer
- Re: RFR: JDK-8169718: nsk/jdb/loca... serguei.spit...@oracle.com
- Re: RFR: JDK-8169718: nsk/jdb/... Chris Plummer
- Re: RFR: JDK-8169718: nsk... serguei.spit...@oracle.com
- Re: RFR: JDK-8169718: nsk... Gary Adams
- Re: RFR: JDK-8169718:... Gary Adams
- Re: RFR: JDK-8169718:... Chris Plummer
- RFR: JDK-8169718: nsk/jdb/locals/locals002: ERR... gary.ad...@oracle.com
- Re: RFR: JDK-8169718: nsk/jdb/locals/local... Gary Adams
- Re: RFR: JDK-8169718: nsk/jdb/locals/l... Alex Menkov
- Re: RFR: JDK-8169718: nsk/jdb/loca... Gary Adams